home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
magazine
/
progjour
/
1990
/
05
/
wmisc.asm
< prev
next >
Wrap
Assembly Source File
|
1990-07-06
|
2KB
|
82 lines
title miscellaneous procedures
include asm.inc
.code
extn malloc_raw
public calloc_read,save_most
;; calloc raw
;
; entry CX request bytes size (0<x<0FFF0h)
; exit ES:DI storage bucket pointer
; Cf if not enough memory or request too large
; uses AX
;
calloc_raw proc
call malloc_raw
jc car1
pushm cx,di
mov al,0
rep stosb
popm di,cx
car1: ret
calloc_raw endp
;; calloc read
;
; entry CX requested byte count
; exit DS:SI pointer to zeroed storage bucket
; Cf if no storage
; uses AX
;
calloc_read proc
pushm di,es
call calloc_raw
jc cal1
push es
pop ds
mov si,di
cal1: popm es,di
ret
calloc_read endp
;; restore most
;
; note never call this routine
;
restore_most proc
popm bp,es,ds,si,di,dx,cx,bx
ret
restore_most endp
;; save most
;
; note saves all registers except AX and BP. however, the current
; version also saves BP because the code works out that way.
; the registers are automatically restored. this routine is
; called with a return address as the top of stack.
;
save_most proc ; +16 inner ret adr, +18 outer ret adr
push cx ; +14
push dx ; +12
push di ; +10
push si ; +8
push ds ; +6
push es ; +4
push bp ; +2
lea bp,restore_most ; after execution of inner
push bp ; +0 routine, return to restore_most
mov bp,sp
xchg bx,[bp+16] ; bx above cx
push bx ; -2 setup return to inner routine
mov bx,[bp+16] ; restore original BX and BP
mov bp,[bp+2]
ret
save_most endp
end