mov a, BANK routb1 ; routine ²routb1² is located in Bank 1
mov bp,a ; load bank number for routb1 into BP
call routb1 ; call subroutine located in Bank 1
clr bp.5 ; program will return to this location
; after RET in Bank 1
: ; but BP will retain Bank 1 value
: ; so clear the BP
codesec1 .section at 000h ¢code¢ ; locates following program section
; into Bank 1
:
:
routb1 proc
:
:
ret ; return program to Bank 0 but BP will
; retain Bank 1 value
routb1 endp
:
:
When managing interrupts, care has to be exercised in supervising the Bank Pointer. Irrespective
of what Bank the program is presently running in, when an interrupt occurs, whether it be an exter
-
nal interrupt or internal interrupt, the program will immediately jump to its respective interrupt vec
-
tor located in Bank 0. Note however that, although in all cases the program will jump to Bank 0, the
Bank Pointer will retain its original value and not indicate Bank 0. For this reason, after entering the
interrupt subroutine, in addition to the usual backup of the accumulator and status register, it is im
-
portant to backup its original value immediately and also clear the Bank Pointer to indicate Bank 0
especially if other calls or jumps are encountered within Bank 0. Before the ²RETI² instruction in
the interrupt subroutine is executed, the Bank Pointer, along with the accumulator and status regis
-
ter, must be restored to ensure the program returns to the same status from where the subroutine
was called. The following example illustrates how interrupts can be managed:
include HT48RU80.inc
:
:
rombank 0 codesec0 ; define rombank 0
rombank 1 codesec1 ; define rombank 1
:
:
codesec0 .section at 000h ¢code¢ ; locates the following program section
; into Bank 0
clr bp ; clear bank pointer after power-on reset
:
:
org 004h ; jump here from any bank when ext. int.
; occurs - BP retains original value
mov accbuf0,a ; backup accumulator
mov a,bp ; backup bank pointer
clr bp ; clear bp to indicate Bank 0 otherwise
; original BP value will remain and give
; rise to false jmp or call addresses
jmp ext_int ; jump to external interrupt subroutine
:
:
org 008h ; jump here from any bank when timer 0 int.
; occurs - BP retains original value
mov accbuf1,a ; backup accumulator
mov a,bp ; backup bank pointer
clr bp ; clear bp to indicate Bank 0 otherwise
; original BP value will remain and give
; rise to false jmp or call addresses
jmp tim0_int ; jump to timer 0 interrupt subroutine
:
:
Chapter 1 Hardware Structure
23