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
/
SEVAL1.Z80
< prev
next >
Wrap
Text File
|
2000-06-30
|
1KB
|
64 lines
;
; SYSLIB Module Name: SEVAL1
; Author: Richard Conn
; SYSLIB Version Number: 3.6
; Module Version Number: 1.1
public eval10
;
; EVAL10 --
; Convert the string of ASCII decimal 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.
;
EVAL10:
PUSH BC ; SAVE BC
LD DE,0 ; SET DE=0 INITIALLY
; Get next digit and check for '0' - '9'
E10L:
LD A,(HL) ; GET BYTE
CP '0' ; CHECK FOR RANGE
JP C,DONE
SUB '0' ; CONVERT TO BINARY
CP 10 ; CHECK FOR RANGE
JP NC,DONE
PUSH AF ; SAVE VALUE
; Multiply DE by 10
MUL10:
PUSH HL ; SAVE HL
LD H,D ; HL=DE
LD L,E
ADD HL,HL ; *2
ADD HL,HL ; *4
ADD HL,DE ; *5
ADD HL,HL ; *10
EX DE,HL
POP HL ; RESTORE HL
; Add in A
POP AF ; GET LATEST DIGIT
ADD A,E ; A=A+E
LD E,A
LD A,D ; ADD TO D IF NECESSARY
ADC A,0
LD D,A ; STORE RESULT
; Continue
INC HL ; PT TO NEXT CHARACTER
JP E10L
; Done -- Result already in DE; Set A=E
DONE:
LD A,E ; A=E
POP BC ; RESTORE BC
RET
END