jc ret
mov dx, -1
push dx ;stack position marker
C1: mov dl, al
call ValCh ;returns hex number in dx
jc A1 ;no more numbers. return
push dx
lodsb
jmp short C1
;---------------------------------------
AddNum: xor ax, ax ;add up nibbles
xor cx, cx ;shl index
C2: pop dx
cmp dx, -1 ;stack marker
je A2 ;no more numbers. ret
cmp cl, 0 ;avoid looping error while "shl"ing
je C4
push cx
push ax
mov ax, 4 ;keep ah zero
mul cl
mov cl, al
C3: shl dx, 1 ;keep it 8086 code
loop C3
pop ax
pop cx
C4: add ax, dx
inc cx
cmp cx, 5 ;only 4 nipples to a customer
jb C2
;---------------------------------------
Err2: pop dx ;error. reset stack
cmp dx, -1 ;stack marker
jne Err2
stc
ret
;-------------------------------------------------------------------------
; ValCh Convert ASCII digit char to binary value
;---------------------------------------------------------------
; Input:
; dl = ASCII digit '0'..'9'; 'A'..'F'
; ; bx = base (2=binary, 10=decimal, 16=hexadecimal)
; Output:
; cf = 0: dx = equivalent binary value
; cf = 1: bad char for this number base (dx is meaningless)
; Registers:
; dx
;---------------------------------------------------------------
ValCh proc
cmp dl, ':' ;(as used here)
je V2
cmp dl, '9' ; Check for possible hex digit
jbe V1 ; Probably '0'..'9', jump
cmp dl, 'F'
jbe V0
xor dl, 20h ; assure upper case
V0: sub dl, 7 ; Adjust hex digit to 3A..3F range
V1:
sub dl, '0' ; Convert ASCII to decimal
test dl, 0f0h ; Check 4 msbs (sets cf=0) 11110000b
jnz V2 ; Jump if error (not digit or A-F)
xor dh, dh ; Convert byte in dl to word in dx
; cmp dx, bx ; Compare to number base (cf=1 if ok)
cmp dx, 10h ;base 16 (hardwired)
V2:
cmc ; Complement cf to set/reset err flag
ret ; Return to caller
ValCh endp
;--------------------------------------------------------------------
Hlp db 13,10,'PeekPoke v1 3-97 by Barry_Block@p42.f901.n280.z2.fidonet.org'
db 13,10,10,'Usage: PeekPoke [seg:offset] [?,=] [b,w,d] {hex pair}'
db 13,10,9,'segment:offset in hexidecmal'
db 13,10,9,'? (peek), = (poke)'
db 13,10,9,'b (byte), w (word), d (doubleword)'
db 13,10,9,'{If used, hex data to poke, upper & lower nibble.}'
db 13,10,10,'Examples:'
db 13,10,9,'PeekPoke 40:0 ? w',9,9,'(show com1 address)'
db 13,10,9,'PeekPoke 40:8 = d 78027803',9,'(exchange lpt1/lpt2)'
db 13,10,9,'PeekPoke B800:0 = w 010e',9,'(note the leading 0!)'
db 13,10,9,'(put a yellow face at the top left of a mode 3 screen)'
crlf db 13,10,36
data segment
org 1024+256
opt db ?
siz dw ?
oset dw ?
_seg dw ?
pok db ?
;end of file
--- Terminate 4.00/Pro
---------------
* Origin: EBO-BBS A'dam +31-20-6002828 (2:280/901.42)
|