*************************************************************** * * * Module ID: NICOMMON.LIB By: GLH/W6BSK * * Last Updated: 28 Apr 85 * * Function : Common subroutines Version : 1.00 * * for use with inputs * * Entry: * * Exit : * * * *************************************************************** ; EQU Table asmask equ 01111111b ; Strip parity (MSB) mask ucmask equ 01011111b ; Upper case conversion mask ; Verify valid hex value and convert to binary chkhex: push b ; Stack working register ani asmask ; Mask for 7-bit ASCII cpi '9'+1 ; Test for 0-9 jc chkde1 ; Probably - test decimal ani ucmask ; Try for A-F mvi c,'A' ; Set upper and lower limits mvi b,'F' ; in BC call limits ; and verify. jc chkerr ; Not in legal range. sui 37h ; Don't like "'0'+7". pop b ; Converted from ASCII, go. ret ; Verify valid decimal number and convert to binary chkdec: push b ; Stack working register chekde1: ani asmask ; Strip MSB mvi c,'0' ; Set upper and lower limits mvi b,'9' ; in BC call limits jc chkerr ; Oops. sui '0' ; Convert to binary pop b ; Restore and ret ; go home. chkerr: sui '0' ; Convert anyway, but stc ; flag error. pop b ; Clean stack ret ; Check for A => C, and A=< B. ; Limits are in BC, returns carry set if out of bounds. limits: cmp c ; Is A .GE. C? rc ; Nope. inr b ; Yes, increment B cmp b ; Is A .LE. B? cmc ; Complement the carry- ret ; and return. Š ; Find first hex character in buffer (DE pointer into buffer) hfield: ldax d ; Load a character cpi 0 ; Die if at line end jnz hfiel1 ; else continue. stc ; Set carry for line end. ret ; and return flagged. hfiel1: call chkhex ; Verify hex rnc ; and return if it is. inx d ; Move on to next if not jmp hfield ; until the world ends. ; Find first decimal value in buffer dfield: ldax d ; Load character cpi 0 ; and test for line end jnz dfiel1 stc ; Flag line end, as usual ret dfiel1: call chkdec ; Test for valid character rnc ; and accept it if so. inx d ; Else keep trying. jmp dfield