; ; Module Name: MEVALB24 ; Author: Steven Cohen ; Based on Richard Conn's EVAL2 ; March 10, 1987 ; public EVALB24 EXT DOUBLE24,ZEROBUF ; ; EVALB24 ; Convert a string of ASCII binary digits ; into a binary value; string is converted until invalid digit is ; encountered. ; ; INPUT: DE POINTS TO a 3-byte buffer in which the converted ; value is to be stored. ; HL POINTS TO the first byte of the string to be converted ; OUTPUT: HL points to error character if any ; A contains the lowest order 8 bits of the value ; carry flag set indicates error ; EVALB24: PUSH BC ; SAVE BC CALL ZEROBUF ; Get next digit and check for '0' - '1' E2L: LD A,(HL) ; GET BYTE SUB '0' CP 0 ; CHECK FOR RANGE JR C,DONE CP 2 ; CHECK FOR RANGE JR NC,DONE ; Multiply buffer by 2 MUL2: PUSH DE PUSH HL PUSH AF ; SAVE VALUE EX DE,HL CALL DOUBLE24 ; ; Add in A ; LD A,(HL) ; get low-order digit LD B,A ; preserve in B POP AF ; GET LATEST DIGIT OR B ; or in latest digit LD (HL),A ; put it in buffer POP HL POP DE ; ; Continue ; INC HL ; PT TO NEXT CHARACTER JP E2L ; ; Done -- Result already in buffer pted to by DE; Set A=its lowest byte ; DONE: LD A,(DE) ; A=first byte of numeric buffer POP BC ; RESTORE BC RET END