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
/
SEVAL4.Z80
< prev
next >
Wrap
Text File
|
2000-06-30
|
1KB
|
55 lines
;
; SYSLIB Module Name: SEVAL4
; Author: Richard Conn
; SYSLIB Version Number: 3.6
; Module Version Number: 1.1
public eval2
;
; EVAL2 --
; Convert the string of ASCII binary digits pointed to by HL
; into a binary value; string is converted until invalid digit is
; encountered.
; On return, HL points to error character, DE=value, A=E (low
; order 8 bits of value). BC not affected.
;
EVAL2:
PUSH BC ; SAVE BC
LD DE,0 ; SET DE=0 INITIALLY
; Get next digit and check for '0' - '1'
E2L:
LD A,(HL) ; GET BYTE
SUB '0' ; CHECK FOR RANGE
JP C,DONE
CP 2
JP NC,DONE
; Multiply DE by 2
MUL2:
PUSH HL ; SAVE HL
LD HL,0 ; ACC=0
ADD HL,DE ; HL=DE
ADD HL,DE ; HL=DE+DE
LD D,H ; DE=HL
LD E,L
POP HL ; RESTORE HL
ADD A,E ; A=A+E
LD E,A
LD A,D ; ADD TO D IF NECESSARY
ADC 0
; Continue
INC HL ; PT TO NEXT CHARACTER
JP E2L
; Done -- Result already in DE; Set A=E
DONE:
LD A,E ; A=E
POP BC ; RESTORE BC
RET
END