home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
ZSYS
/
SIMTEL20
/
SYSLIB
/
SLIB1.LBR
/
SDGO2.Z80
< prev
next >
Wrap
Text File
|
2000-06-30
|
2KB
|
70 lines
;
; SYSLIB Module Name: DGOTO2
; Author: Richard Conn
; SYSLIB Version Number: 3.6
; Module Version Number: 1.1
public dgoto2
;
; DGOTO2 is a computed GOTO. When called, register pair HL = index of
; following address to branch to and register pair DE = maximum value
; allowed, as indicated:
;
; LXI H,INDEX ; zero-relative
; LXI D,2 ; max value allowed
; CALL DGOTO2
; JMP ADDR0 ; IF HL=0
; JMP ADDR1 ; IF HL=1
; JMP ADDR2 ; IF HL=2
; <error instructions> ; IF HL > DE
; ...
; ADDR0: ; COME HERE IF HL=0
; ...
; ADDR1: ; COME HERE IF HL=1
; ...
; ADDR2: ; COME HERE IF HL=2
; ...
;
dgoto2:
ld (hlsave),hl ; save HL
push af ; save regs
push de
ld a,d ; check for range error
cp h
jp c,rangerr ; H > D, so set max
jp nz,goto
ld a,e ; check for range error
cp l
jp nc,goto ; E >= L, H = D
rangerr:
ex de,hl ; HL = DE = return index
inc hl ; return index + 1 for error return
goto:
ld (index),hl ; save index
pop de ; restore regs
pop af
pop hl ; get return address
push de ; save regs
push af
push hl ; save return address
ld hl,(index) ; HL = index value
ld d,h ; DE = HL = index value
ld e,l
add hl,hl ; HL = index * 2
add hl,de ; HL = offset = index * 3
pop de ; get return address
add hl,de ; HL = destination address
pop af ; get regs
pop de
push hl ; set address of routine
ld hl,(hlsave) ; restore HL
ret
;
; Save buffer
;
hlsave: ds 2 ; original HL
index: ds 2 ; index entry
end