*************************************************************** * * * Module ID: xxxxxxxx.xxx By: GLH/W6BSK * * Last Updated: nn Jan 85 * * Function : Version : nnnn * * * * Entry: * * Exit : * * * *************************************************************** ; Input 1 to 3 decimal characters from command line li8dec: lxi h,tbuff+1 ; Point to transient buffer jmp ci8de1 ; and start loading. ; Input 1 to 3 decimal characters from console ci8dec: call cimsg ; Read an input line lxi h,inbuf+2 ; Look into it ci8de1: shld dibpnt ; Set up buffer pointer ; Input 1 to 3 decimal chars pointed to by DIBPNT ; Returns no carry set - legal input. ; Returns carry, A=00 no digits on line. ; Returns carry, A=FF overflow occurred. bi8dec: push h ; Stack HL call bi6dec ; Use 16bit input jc de8err ; Error return mov a,h ; else check 8bit overflow ora a jnz de8err ; Error occurred stc ; otherwise set carry cmc ; and then clear: this is the ; only way to guarantee no carry. bi8de1: mov a,l ;Load 8bit value pop h ; Clean stack ret de8err: stc ; Flag the error jmp bi8de1 ; Clean up and go. ; Input up to 5 dec chars from command line li6dec: lxi h,tbuff+1 jmp ci6de1 ; Input up to 5 dec chars from console ci6dec: call cimsg lxi h,inbuf+2 ci6de1: shld bibpnt Š; Input upt to 5 dec chars pointed to by DIBPNT ; Returns no carry if legal input ; Returns carry & HL=0000 if no digits on line ; Returns carry & HL=FFFF if overflow occurred bi6dec: push b push d lhld dibpnt ; Load pointer xchg ; into DE lxi h,0 ; Zero initially call dfield ; Find decimal jc bi6de4 ; Die if none in buffer bi6de1: ldax d ; Get a char and verify call chkdec jc bi6de3 ; Done if not 0-9 inx h ; Continue- dad h ; Double the previous value jc de6err ; and quit if overflows. mov b,h ; Save two times previous mov c,l ; value in BC dad h ; Now X4... jc de6err ; if overflow. dad h ; And X8. jc de6err ; why not? dad b ; for X10 total multiply. mvi b,0 mov c,a ; Add in the new digit dad b jc de6err ; as always jmp bi6de1 ; and if not, get another. bi6de3: stc ; Normal exit, all good. cmc bi6de4: xchg ; Update buffer pointer shld dibpnt xchg pop d pop b ret ; Clean stack and go. de6err: lxi h,-1 ; Load FFFF into HL stc ; and set carry flag. jmp bi6de4 ; Set DIBPNT to the input buffer to be parsed. dibpnt ds 2 ; Input buffer pointer