home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload
/
ShartewareOverload.cdr
/
database
/
rettig.zip
/
TRSOURCE.EXE
/
MEMHOG.ASM
< prev
next >
Wrap
Assembly Source File
|
1990-10-22
|
4KB
|
130 lines
; Utility: MEMHOG.ASM
;
; by Ralph Davis
; modified by Leonard Zerman
;
; Placed in the public domain by Tom Rettig Associates, 10/22/1990.
;
;************************************************
CODESEG SEGMENT PARA PUBLIC
ASSUME CS:CODESEG,DS:CODESEG,ES:CODESEG
ORG 2CH
ENV_BLOCK LABEL WORD
ORG 80H
COM_LINE LABEL BYTE
ORG 100H
;------------------------------------------------
MEMHOG PROC FAR
START: JMP GO
;
CURR_BLOCK DW ?
TOO_MANY DB 0DH,0AH,07H,'Only 1-3 digits permitted',0DH,0AH,'$'
NO_MEMORY DB 0DH,0AH,07H,'Insufficient memory',0DH,0AH,'$'
;
GO: PUSH BX
PUSH CX
PUSH SI
PUSH DS
PUSH ES
PUSH CS
POP DS
MOV SI,OFFSET COM_LINE
XOR CX,CX
MOV CL,[SI]
CMP CL,0
JE NO_GOOD
CMP CL,20
JE NO_GOOD
CMP CL,4
JLE OK
NO_GOOD: MOV DX,OFFSET TOO_MANY
MOV AH,9
INT 21H
JMP BAD_EXIT
;
OK:
DEC CL
ADD SI,2 ; point to first digit
MOV BX,10
XOR AX,AX
XOR DX,DX
GET_DIGIT: LODSB
SUB AL,30H
XCHG AX,DX
MUL BL
ADD AX,DX
XCHG AX,DX
LOOP GET_DIGIT
MOV AX,DX
OR AX,AX
JZ FREE_MEM
PUSH AX
PUSH DS
XOR AX,AX
MOV DS,AX
MOV BX,60H * 4
MOV AX,[BX+2]
MOV CS:CURR_BLOCK,AX
MOV [BX+2],CS
POP DS
POP AX
MOV BX,1024
MUL BX
REPT 4
CLC
RCR DX,1
RCR AX,1 ; divide by 16
ENDM
MEMHOG_2:
PUSH AX
MOV BX,OFFSET ENV_BLOCK
MOV AX,WORD PTR [BX]
MOV ES,AX
MOV AH,49H
INT 21H
POP AX
MOV DX,AX
DEC DX ; usually comes out
; one paragraph too high
MOV AH,31H
XOR AL,AL
POP ES
POP DS
POP SI
POP CX
POP BX
INT 21H
;
BAD_EXIT: POP ES
POP DS
POP SI
POP CX
POP BX
INT 20H
;
FREE_MEM: XOR AX,AX
MOV DS,AX
MOV BX,60H * 4
MOV AX,[BX+2]
MOV ES,AX
MOV AX,CS:CURR_BLOCK
MOV [BX+2],AX
MOV AH,49H
INT 21H
POP ES
POP DS
POP SI
POP CX
POP BX
INT 20H
;
END_OF_PROC LABEL BYTE
;
MEMHOG ENDP
;-------------------------------------------
CODESEG ENDS
;**********************************************
END START