Chapter 1 Hardware Structure
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 correct Bank and point from where the
subroutine was called. The following example illustrates how interrupts can be managed:
include HT49RU80.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 ext0_int.
; occurs - BP retains original value
mov accbuf0,a
mov a,bp
clr bp
jmp ext0_int
:
:
org 008h
mov accbuf1,a
mov a,bp
clr bp
jmp ext1_int
:
:
org 00Ch
:
:
ext0_int:
mov bp_ext0,a
mov a,status
mov statusbuf0,a
:
:
mov a,statusbuf0
mov status,a
mov a,bp_ext0
mov bp,a
mov a,accbuf0
reti
:
:
;
;
;
;
;
;
;
;
;
;
;
;
;
;
backup accumulator
backup Bank Pointer
clear BP to indicate Bank 0 otherwise
original BP value will remain and give
rise to false jmp or call addresses
jump to external 0 interrupt subroutine
jump here from any bank when ext1_int.
occurs - BP retains original value
backup accumulator
backup Bank Pointer
clear BP to indicate Bank 0 otherwise
original BP value will remain and give
rise to false jmp or call addresses
jump to external 1 interrupt subroutine
; jump here from any bank when Timer 0 int.
; occurs - BP retains original value
;
;
;
;
external 0 interrupt subroutine
backup Bank Pointer
backup status register
backup status register
; restore status register
; restore Bank Pointer
; restore accumulator
; return to main program and original
; calling bank
29
Home Index Bookmark Pages Text
Previous Next
Pages: Home Index