;* B register returns status info:
;* Bit D0: current /cts stat
;* D1set: /cts int received
;*
.z800
;Read in Z180 register names and
*include 180macro.lib ;macro for Z180 new instructions
;SCC
Registers
scc_ad: equ 0C3h ;addr of scc ch a - data
scc_ac: equ 0C2h ;addr of scc ch a - control
scc_bd: equ 0C1h ;addr of scc ch b - data
scc_bc: equ 0C0h ;addr of scc ch b - control
scc_a: equ 000h ;set 0ffh to test ch a
;clear 00h to test ch b.
if scc_a
scc_cont: equ scc_ac
else
scc_cont: equ scc_bc
endif
org 09000h ;top of user ram area
inttest: ld sp,top_of_sp ;init sp
ld a,high sccvect and 0ffh ;init i reg
ld i,a
im 2 ;set interrupt mode 2
call initscc ;initialize scc
ld b,0 ;clear status
ei ;enable interrupt
wait_loop: bit 1,b ;check int status
jr z,wait_loop ;if not, loop again
wait_here: jr $ ;interrupt has been received
;you can set breakpoint here!
;subroutine to initialize scc registers
;initialization table format is
;register number, then followed by the data to be written
;and the register number is 0ffh, then return
initscc: ld hl,scctab ;initialize scc
init0: ld a,(hl) ;get register number
cp 0ffh ;reached at the end of table?
ret z ;yes, return.
out (scc_cont),a ;write it
inc hl ;point to next data
ld a,(hl) ;get the data to be written
out (scc_cont),a ;write it
inc hl ;point to next data
jr init0 ;then loop
Comentarios a estos manuales