Category : C Source Code
Archive   : C-TOOLBX.ZIP
Filename : MEMORY.ASM
; start data section
include begdata.ha
include enddata.ha
;
; start code section
;
include begcode.ha
;
; peek - get a byte from another segment
;
; USAGE: byte_value = peek(segment_address,0ffset_address) ;
;
peek_args struc ; input arguments
dw 0 ; saved BP value
dw 0 ; return address
peek_seg dw 0 ; segment part of address
peek_off dw 0 ; offset part of the address
peek_args ends
;
public peek
peek:
push bp
mov bp,sp ; set our argument pointer
push es
mov ax,word ptr peek_seg[bp] ; load segmented address
mov bx,word ptr peek_off[bp]
mov es,ax
mov al,es:byte ptr [bx]
xor ah,ah
pop es
pop bp
ret
;
;
; poke - store a byte in another segment
;
; USAGE: poke(byte_value,segment_address,offset_address) ;
;
poke_args struc ; input arguments
dw 0 ; saved BP value
dw 0 ; return address
poke_byte dw 0 ; byte value to store
poke_seg dw 0 ; segment part of address
poke_off dw 0 ; offset part of the address
poke_args ends
;
public poke
poke:
push bp
mov bp,sp ; set our argument pointer
push es
mov ax,word ptr poke_seg[bp] ; load segmented address
mov bx,word ptr poke_off[bp]
mov es,ax
mov ax,word ptr poke_byte[bp] ; load the data value
mov es:byte ptr [bx],al ; write it to the port
pop es
pop bp
ret
;
; lmove - move data between segments
;
; USAGE: lmove(dest_offset,dest_segment,source_offset,
; source_segment,number_bytes) ;
;
lmove_args struct ; input parameters
dw 0 ; saved BP value
dw 0 ; return address
destseg dw 0 ; destination segment address
doff dw 0 ; destination offset address
srcseg dw 0 ; source segment address
soff dw 0 ; source offset address
mbytes dw 0 ; number of bytes to move
lmove_args ends
;
public lmove
lmove:
push bp
mov bp,sp ; set argument pointer
push ds ; save register values
push es
push si
push di
cld
mov ax,word ptr destseg[bp] ; load dest. address
mov es,ax
mov di,word ptr doff[bp]
mov ax,word ptr srcseg[bp] ; load source address
mov ds,ax
mov si,word ptr soff[bp]
mov cx,word ptr mbytes[bp] ; load the byte count
rep movsb ; move the data
pop di ; restore register values
pop si
pop es
pop ds
pop bp
ret
;
; get_cs - get CS segment address
; usage: cs_value = get_cs()
public get_cs
get_cs: mov ax,cs
ret
;
; get_ds - get DS segment address
; usage: ds_value = get_ds()
public get_ds
get_ds: mov ax,ds
ret
;
include endcode.ha
end
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/