LCD Type MCU
Managing Multiple Banks
For the HT49RU80/HT49CU80 devices, which have multiple Program Memory banks, there are
some special considerations that have to be taken into account. First, the sections of program
which are to be located into different banks are placed using the ROMBANK directive. When using
the
²CALL²
instruction to call routines located in a different bank, or when using the
²JMP²
instruc-
tions to directly jump to a location in a different bank, the target bank must be first selected by cor-
rectly setting up the Bank Pointer prior to executing the
²CALL²
or
²JMP²
instruction. This of
course can be achieved by directly controlling Bit 5 of the Bank Pointer, BP, but can also be done
by using the BANK directive as shown in the example. Then, when a
²CALL²
or
²JMP²
instruction
is executed, the Bank Pointer value stored in the BP register will be automatically loaded into the
Program Counter. When the
²RET²
instruction is encountered in a subroutine called from a differ-
ent bank, the program will automatically return to the original bank, however, the BP value will not
be changed and will remain at the value where the subroutine is located. For this reason the BP
must be carefully managed when moving between banks. The following example for the
HT49RU80/HT49CU80 devices illustrates how to use the
²CALL²
and
²JMP²
instructions be-
tween different banks:
include HT49RU80.inc
:
:
; define rombank 0
rombank 0 codesec0
rombank 1 codesec1
; define rombank 1
:
:
codesec0 .section at 000h
¢code¢
; locates the following program section
; into Bank 0
clr bp
; re-initializing the BP
jmp start
:
:
start:
:
:
lab0:
:
:
mov a, BANK routb1
mov bp,a
call routb1
clr bp
;
;
;
;
;
:
;
:
;
codesec1 .section at 000h
¢code¢
;
;
:
:
routb1 proc
:
:
ret
;
;
routb1 endp
:
:
routine
²routb1²
is located in Bank 1
load bank number for routb1 into BP
call subroutine located in Bank 1
program will return to this location
after RET in Bank 1
but BP will retain Bank 1 value
so clear the BP
locates following program section
into Bank 1
return program to Bank 0 but BP will
retain Bank 1 value
28
Home Index Bookmark Pages Text
Previous Next
Pages: Home Index