I'd like to share this and see if there are any comments.
It is a peek/poke utility for 4DOS batchfiles to add even more
flexibility to them. I guess it does not do anything that debug can't do...
I wish I could LHA and UUE it but that's not the policy in this echo :(
So, this is one of three posts.
;-------------------------------------------------------------------------
;peekpoke.asm by Barry Block v1 3-97 A86 comfile
;to peek or poke hex data from/to memory. byte, word, doubleword supported.
;to be callable from a batchfile and return the peek to standard output.
o EQU offset
;-----------------------------------------------------------program flow--
call Address
jc Usage
call Option
jc Usage
call Size
jc Usage
cmp b opt,'?'
je Peek
cmp b opt,'='
je Poke
Quit: mov ax, 4c00h
int 21h
;-------------------------------------------------------------------------
Usage: ;Syntax error. show message & quit
mov dx, o hlp
mov ah, 9
int 21h
mov ax, 4c01h
int 21h
;-------------------------------------------------------------------------
Peek:
mov si, [oset] ;load offset to peek at
mov cx, [siz] ;b,w,d (1 2 4)
push ds
push w[_seg]
pop ds ;load segment to peek at
P1: lodsb
cmp al,15 ;gets a leading zero printed
ja P2
push ax
mov dl, '0'
mov ah, 2
int 21h
pop ax
P2: call PrtHex
loop P1
pop ds ;restore default data segment
mov dx, o crlf ;add cr,lf to end of string
mov ah, 9
int 21h
jmp quit
;-------------------------------------------------------------------------
PrtHex: ;prints AX as a hex number
push cx,ax
mov cx, -1 ;Ending flag
push cx
mov cx, 10h ;Divide by 16
PH1: mov dx, 0
div cx ;Divide by 16
add dx, 30h ;Convert to ASCII
push dx ;Store remainder
cmp ax, 0 ;Are we done?
jne PH1 ;No, so continue
PH2: pop dx ;Character is now in DL
cmp dx, -1 ;Is it the ending flag?
je PH4 ;Yes, so continue
cmp dl, '9' ;Greater than 9?
jbe PH3
add dl, 7 ;Convert to hex
PH3: mov ah, 02h ;Output a character
int 21h
jmp short PH2 ;Keep doing it
PH4: pop ax,cx
ret
;-------------------------------------------------------------------------
Poke:
call SkipSpace
mov cx, -1
push cx ;keep it 8086 code
mov di, o pok
mov cx, [siz]
dec si
K1: call K2 ;read commandline. get digit
shl dx, 1 ;keep it 8086 code
shl dx, 1
shl dx, 1
shl dx, 1
push dx ;store hi nibble
--- Terminate 4.00/Pro
---------------
* Origin: EBO-BBS A'dam +31-20-6002828 (2:280/901.42)
|