home *** CD-ROM | disk | FTP | other *** search
- .MODEL SMALL
-
- INCLUDE equates.inc
- INCLUDE instance.inc
- INCLUDE messages.inc
- INCLUDE objects.inc
-
- IF1
- INCLUDE macros.mac
- INCLUDE objects.mac
- ENDIF
-
- EXTRN sendMsg:NEAR
-
- EXTRN DosError:WORD
- EXTRN Self:WORD
-
- .CODE
-
- IF Dbug
- PUBLIC allocMem
- ENDIF
- COMMENT %
- ==============================================================================
- Allocates a block of memory.
-
- =============================================================================%
- allocMem PROC NEAR
- getInst bx,MemSize,Self ;Get number of paras to alloc
- setInst MemSeg,Nil,,2 ;Clear memory segment
- mov ah,48h ;DOS service number
- int DosInt ;DOS interrupt
- jc alm1 ;Jump if dosErr
- setInst MemSeg,ax ;Save seg addr
- jmp alm2 ;Exit
-
- alm1: send DosError,Error,ax ;Handle error
- alm2: ret
- allocMem ENDP
-
-
-
- IF Dbug
- PUBLIC freeMem
- ENDIF
- COMMENT %
- ==============================================================================
- Frees previously allocated memory block.
-
- =============================================================================%
- freeMem PROC NEAR
- getInst ax,MemSeg,Self ;Get seg addr of allocted mem
- null ax,frm2 ;Already freed? - Exit
-
- push es
- mov es,ax ;Set segment register
- mov ah,49h ;DOS service number
- int DosInt ;DOS interrupt
- pop es
- jc frm1 ;Jump if dosErr
-
- setInst MemSeg,Nil,,2 ;Clear memory segment
- jmp frm2 ;Exit
-
- frm1: send DosError,Error,ax ;Handle error
- frm2: ret
- freeMem ENDP
-
-
-
- .DATA
-
- defMsg MemMngr,\
- Open,\
- <allocMem,,>
-
- defMsg MemMngr,\
- Close,\
- <,,freeMem>
-
- defObj MemMngr,\
- <>,\
- <>,\
- <Open,Close>
-
-
-
- END