134
K
A
DAK
AMX Memory Manager
The Memory Assignment Procedure can be coded in assembler as a FAR procedure.USER_CODE SEGMENT BYTE 'CODE'
;ASSUME CS:USER_CODE
;PUBLIC MEMPROC
;
PARAM STRUC ;Define parameters on stack
DW ? ;Save BP
DD ? ;Return address
MEMSIZEP DD ? ;A(storage for section size in bytes)
MEMPTRP DD ? ;A(storage for memory section pointer)
PARAM ENDS
;
MEMPROC PROC FAR
PUSH BP
MOV BP,SP ;SS:BP = A(parameters on stack)
:
SetAX=0ifmemory section is not available
:
OR AX,AX
JZ MEMEXIT ;No section; AX = 0
:
Let DX:AX = size of memory section in bytes
LES BX,[BP].MEMSIZEP ;ES:BX = A(memory size)
MOV WORD PTR ES:[BX],AX
MOV WORD PTR ES:[BX+2],DX
:
Let DS:SI = A(memory section)
LES BX,[BP].MEMPTRP ;ES:BX = A(memory pointer)
MOV WORD PTR ES:[BX],SI
MOV WORD PTR ES:[BX+2],DS
MOV AX,1 ;AX <> 0
;
MEMEXIT: POP BP
RET
;
MEMPROC ENDP
;
USER_CODE ENDS