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
/
SLIB2.LBR
/
SHIF1.Z80
< prev
next >
Wrap
Text File
|
2000-06-30
|
1KB
|
61 lines
;
; SYSLIB Module Name: HIF1
; Author: Richard Conn
; SYSLIB Version Number: 3.6
; Module Version Number: 1.1
public hif1
;
; HIF1 is an arithmetic IF facility. A key value is passed in the DE register
; pair and a test value is passed in the HL register pair:
;
; LXI D,5 ; key value
; LXI H,TEST ; test value
; CALL HIF1
; DW HLTD ; go here if HL < DE
; DW HEQD ; go here if HL = DE
; DW HGTD ; go here if HL > DE
;
hif1:
ex (sp),hl ; get return address
ld (return),hl
ex (sp),hl
ld (hlsave),hl ; save HL
push de ; save regs
push af
ld a,h ; compare highs
cp d
jp c,less
jp nz,greater
ld a,l ; highs are equal, compare lows
cp e
jp c,less
jp nz,greater
ld de,2 ; HL = DE, so offset is 2 bytes
jp goto
greater:
ld de,4 ; HL > DE, so offset is 4 bytes
jp goto
less:
ld de,0 ; HL < DE, so offset is 0 bytes
goto:
ld hl,(return) ; get return address
add hl,de ; add in offset
ld a,(hl) ; get low
inc hl
ld h,(hl) ; get high
ld l,a ; HL = address to return to
pop af ; restore regs
pop de
ex (sp),hl ; set return address on stack
ld hl,(hlsave) ; restore HL
ret
;
; Save buffers
;
hlsave: ds 2 ; original HL
return: ds 2 ; original return address
end