Asmutils.asm
Asmutils.asm
;
; Copyright (c) 1986-1997 Kevin G. Rhoads. All rights reserved.
;
;
;
include forframe.mac
;
;
DATA segment PUBLIC 'DATA' USE16
DATA ends
dgroup group DATA
code segment 'CODE' PUBLIC USE16
assume cs:code,ds:dgroup,es:dgroup,ss:dgroup
; USE: call prtsc
prtsc proc far
public prtsc
save
int 5
restore
ret
prtsc endp
;
;
; note -- in the below peeks and pokes, segoff:integer*4 refers to a
; long (dword) address, consisting of a segment and offset; this would be
; stored either in a 4-byte integer or in two 2-byte integers, in which case
; the first 2-byte integer is the offset and the second is the segment
;
;
; USE: integer = peek(segoff:integer*4)
peek proc far
peekb label far
public peek,peekb
save
les bx,dword ptr ss:[bp+argone1]
les bx,dword ptr es:[bx]
mov dx,0
mov ax,dx
mov al,byte ptr es:[bx]
restore
ret 4
peek endp
;USE: integer = peekw(segoff:integer*4)
peekw proc far
public peekw
save
les bx,dword ptr ss:[bp+argone1]
les bx,dword ptr es:[bx]
mov dx,0
mov ax,word ptr es:[bx]
restore
ret 4
db '(c) 1986-1993 Kevin G. Rhoads, all rights reserved.'
peekw endp
;USE: integer = peekd(segoff:integer*4)
peekd proc far
public peekd
save
les bx,dword ptr ss:[bp+argone1]
les bx,dword ptr es:[bx]
mov ax,word ptr es:[bx]
mov dx,word ptr es:[bx+2]
restore
ret 4
db '(c) 1986-1993 Kevin G. Rhoads, all rights reserved.'
peekd endp
; USE: call poke(segoff: integer*4, value)
poke proc far
pokeb label far
public poke,pokeb
save
les bx,dword ptr ss:[bp+argtwo2]
mov al,byte ptr es:[bx]
les bx,dword ptr ss:[bp+argone2]
les bx,dword ptr es:[bx]
mov byte ptr es:[bx],al
restore
ret 8
db '(c) 1986-1993 Kevin G. Rhoads, all rights reserved.'
poke endp
; USE: call pokew(segoff: integer*4, value)
pokew proc far
public pokew
save
les bx,dword ptr ss:[bp+argtwo2]
mov ax,word ptr es:[bx]
les bx,dword ptr ss:[bp+argone2]
les bx,dword ptr es:[bx]
mov word ptr es:[bx],ax
restore
ret 8
db '(c) 1986-1993 Kevin G. Rhoads, all rights reserved.'
pokew endp
; USE: call poked(segoff: integer*4, value)
poked proc far
public poked
save
les bx,dword ptr ss:[bp+argtwo2]
mov ax,word ptr es:[bx]
mov dx,word ptr es:[bx+2]
les bx,dword ptr ss:[bp+argone2]
les bx,dword ptr es:[bx]
mov word ptr es:[bx],ax
mov word ptr es:[bx+2],dx
restore
ret 8
db '(c) 1986-1993 Kevin G. Rhoads, all rights reserved.'
poked endp
;
; address returning routines, addsof returns 4-byte (segment:offset)
;
addsof proc far
addrof label far
public addsof,addrof
save
les ax,dword ptr ss:[bp+argone1]
mov dx,es
restore
ret 4
db '(c) 1986-1993 Kevin G. Rhoads, all rights reserved.'
addsof endp
;
offsof proc far ;return offset only
offof label far
public offsof,offof
save
les ax,dword ptr ss:[bp+argone1]
mov dx,0
restore
ret 4
db '(c) 1986-1993 Kevin G. Rhoads, all rights reserved.'
offsof endp
;
segmof proc far ;return segment only
segof label far
public segmof,segof
save
les ax,dword ptr ss:[bp+argone1]
mov ax,es
mov dx,0
restore
ret 4
db '(c) 1986-1993 Kevin G. Rhoads, all rights reserved.'
segmof endp
;
getcs proc far
public getcs
save
mov ax,cs
mov dx,0
restore
ret
db '(c) 1986-1993 Kevin G. Rhoads, all rights reserved.'
getcs endp
;
getds proc far
public getds
save
mov ax,ds
mov dx,0
restore
ret
db '(c) 1986-1993 Kevin G. Rhoads, all rights reserved.'
getds endp
;
getss proc far
public getss
save
mov ax,ss
mov dx,0
restore
ret
db '(c) 1986-1993 Kevin G. Rhoads, all rights reserved.'
getss endp
;
; call doint(intno,ax,bx,cx,dx,ds,es,si,di)
doint proc far
public doint
save
push ds
push bp
les di,dword ptr ss:[bp+argone9]
mov al,byte ptr es:[di]
mov byte ptr cs:[preint+1],al
les di,dword ptr ss:[bp+argtwo9]
mov ax,word ptr es:[di]
les di,dword ptr ss:[bp+argthree9]
mov bx,word ptr es:[di]
les di,dword ptr ss:[bp+argfour9]
mov cx,word ptr es:[di]
les di,dword ptr ss:[bp+argfive9]
mov dx,word ptr es:[di]
les di,dword ptr ss:[bp+argsix9]
mov si,word ptr es:[di]
mov ds,si
les di,dword ptr ss:[bp+argseven9]
mov si,word ptr es:[di]
mov cs:tempes,si
les di,dword ptr ss:[bp+argnine9]
mov si,word ptr es:[di]
mov cs:tempdi,si
les di,dword ptr ss:[bp+argeight9]
mov si,word ptr es:[di]
mov di,cs:tempes
mov es,di
mov di,cs:tempdi
jmp preint
preint: int 01d
mov cs:tempdi,di
mov di,es
mov cs:tempes,di
les di,dword ptr ss:[bp+argeight9]
mov word ptr es:[di],si
les di,dword ptr ss:[bp+argnine9]
mov si,cs:tempdi
mov word ptr es:[di],si
les di,dword ptr ss:[bp+argseven9]
mov si,cs:tempes
mov word ptr es:[di],si
les di,dword ptr ss:[bp+argsix9]
mov si,ds
mov word ptr es:[di],si
les di,dword ptr ss:[bp+argfive9]
mov word ptr es:[di],dx
les di,dword ptr ss:[bp+argfour9]
mov word ptr es:[di],cx
les di,dword ptr ss:[bp+argthree9]
mov word ptr es:[di],bx
les di,dword ptr ss:[bp+argtwo9]
mov word ptr es:[di],ax
pop bp
pop ds
restore
ret 36d
db '(c) 1986-1993 Kevin G. Rhoads, all rights reserved.'
tempes dw ?
tempdi dw ?
doint endp
;
code ends
end