; ; SYSLIB Module Name: SEVAL4 ; Author: Richard Conn ; SYSLIB Version Number: 2.0 ; Module Version Number: 1.0 ; Module Entry Points: ; EVAL2 ; Module External References: ; None ; ; ; 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 B ; SAVE BC LXI D,0 ; SET DE=0 INITIALLY ; Get next digit and check for '0' - '9' E2L: MOV A,M ; GET BYTE SUI '0' ; CHECK FOR RANGE JC DONE CPI 2 JNC DONE ; Multiply DE by 2 MUL2: PUSH H ; SAVE HL LXI H,0 ; ACC=0 DAD D ; HL=DE DAD D ; HL=DE+DE MOV D,H ; DE=HL MOV E,L POP H ; RESTORE HL ADD E ; A=A+E MOV E,A MOV A,D ; ADD TO D IF NECESSARY ACI 0 ; Continue INX H ; PT TO NEXT CHARACTER JMP E2L ; Done -- Result already in DE; Set A=E DONE: MOV A,E ; A=E POP B ; RESTORE BC RET END