RAM Overlay
6-10
6.4.2 RAM Overlay
RAM is reserved for variables in the following way. The start address of the
variable is equal to the address of the previous variable, plus the size of that
variable. The size of VAR1 thus depends on the start address of the next
variable. In the example below, dac_buffer starts 2 bytes (one word) after
current_buffer. This means that current_buffer must be one word long. The
variable after dac_buffer, save_dac_r0, starts 2 bytes (one word) after
dac_buffer. Therefore, dac_buffer is one word long. Similarly, save_dac_stat
starts 10 bytes (5 words) after save_dac_regs, therefore, save_dac_regs is a
variable five words long.
dac_buffer equ current_buffer + 2 * 1 ;RESW 1
save_dac_r0 equ dac_buffer + 2 * 1 ;RESW 1
save_dac_regsequ save_dac_r0 + 2 * 1 ;RESW 5
save_dac_statequ save_dac_regs + 2 * 5 ;RESW 1
The above method should be used to declare all customer variables. This is
illustrated in the next section.
6.4.3 Adding Customer Variables
New variables should either be added directly to MAIN_RAM.IRX or should be
included as a module RAM.IRX file. To add a variable new_var, size one word,
would require adding the variable itself and modifying the
RAMEND_CUSTOMER constant. The original MAIN_RAM.IRX file is shown
below.
;****************************************************************
; MAIN_RAM.IRX
;
; Start of memory for MAIN module is defined in
; include”..\ram\ram.irx”
;****************************************************************
; General purpose variables
ledpattern equ RAMSTART_CUSTOMER + 2 * 1
keypress equ ledpattern + 2 * 1
tabadr equ leypress + 2 * 1
; Time 1 interrupt variables
save_tim1_stat equ save_tim1_a0a + 2 * 1
save_tim2_a0 equ save_tim2_stat + 2 * 1
save_tim2_a0a equ save_tim2_a0 + 2 * 1
; Time 2 interrupt variables