home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / database / rettig.zip / TRSOURCE.EXE / MEMHOG.ASM < prev    next >
Assembly Source File  |  1990-10-22  |  4KB  |  130 lines

  1. ; Utility: MEMHOG.ASM
  2. ;
  3. ; by Ralph Davis
  4. ; modified by Leonard Zerman
  5. ;
  6. ; Placed in the public domain by Tom Rettig Associates, 10/22/1990.
  7. ;
  8. ;************************************************
  9. CODESEG     SEGMENT  PARA PUBLIC 
  10.             ASSUME   CS:CODESEG,DS:CODESEG,ES:CODESEG
  11.             ORG      2CH
  12. ENV_BLOCK   LABEL    WORD
  13.             ORG      80H
  14. COM_LINE    LABEL    BYTE
  15.             ORG      100H
  16. ;------------------------------------------------
  17. MEMHOG      PROC     FAR
  18. START:      JMP      GO
  19. ;
  20. CURR_BLOCK  DW       ?
  21. TOO_MANY    DB       0DH,0AH,07H,'Only 1-3 digits permitted',0DH,0AH,'$'
  22. NO_MEMORY   DB       0DH,0AH,07H,'Insufficient memory',0DH,0AH,'$'
  23. ;
  24. GO:         PUSH     BX
  25.             PUSH     CX
  26.             PUSH     SI
  27.             PUSH     DS
  28.             PUSH     ES
  29.             PUSH     CS
  30.             POP      DS
  31.             MOV      SI,OFFSET COM_LINE
  32.             XOR      CX,CX
  33.             MOV      CL,[SI]
  34.             CMP      CL,0
  35.             JE       NO_GOOD
  36.             CMP      CL,20
  37.             JE       NO_GOOD
  38.             CMP      CL,4
  39.             JLE      OK
  40. NO_GOOD:    MOV      DX,OFFSET TOO_MANY
  41.             MOV      AH,9
  42.             INT      21H
  43.             JMP      BAD_EXIT
  44. ;
  45. OK:         
  46.             DEC      CL
  47.             ADD      SI,2               ; point to first digit
  48.             MOV      BX,10
  49.             XOR      AX,AX
  50.             XOR      DX,DX
  51. GET_DIGIT:  LODSB
  52.             SUB      AL,30H
  53.             XCHG     AX,DX
  54.             MUL      BL
  55.             ADD      AX,DX
  56.             XCHG     AX,DX
  57.             LOOP     GET_DIGIT
  58.             MOV      AX,DX
  59.             OR       AX,AX
  60.             JZ       FREE_MEM
  61.             PUSH     AX
  62.             PUSH     DS
  63.             XOR      AX,AX
  64.             MOV      DS,AX
  65.             MOV      BX,60H * 4
  66.             MOV      AX,[BX+2]
  67.             MOV      CS:CURR_BLOCK,AX
  68.             MOV      [BX+2],CS
  69.             POP      DS
  70.             POP      AX
  71.             MOV      BX,1024
  72.             MUL      BX
  73.             REPT     4 
  74.             CLC
  75.             RCR      DX,1
  76.             RCR      AX,1               ; divide by 16
  77.             ENDM
  78.             
  79. MEMHOG_2:
  80.             PUSH     AX
  81.             MOV      BX,OFFSET ENV_BLOCK
  82.             MOV      AX,WORD PTR [BX]
  83.             MOV      ES,AX
  84.             MOV      AH,49H
  85.             INT      21H
  86.             POP      AX
  87.             MOV      DX,AX
  88.             DEC      DX                 ; usually comes out
  89.                                         ; one paragraph too high
  90.             MOV      AH,31H
  91.             XOR      AL,AL
  92.             POP      ES
  93.             POP      DS
  94.             POP      SI
  95.             POP      CX
  96.             POP      BX
  97.             INT      21H
  98. ;
  99. BAD_EXIT:   POP      ES
  100.             POP      DS
  101.             POP      SI
  102.             POP      CX
  103.             POP      BX
  104.             INT      20H
  105. ;
  106. FREE_MEM:   XOR      AX,AX
  107.             MOV      DS,AX
  108.             MOV      BX,60H * 4
  109.             MOV      AX,[BX+2]
  110.             MOV      ES,AX
  111.             MOV      AX,CS:CURR_BLOCK
  112.             MOV      [BX+2],AX
  113.             MOV      AH,49H
  114.             INT      21H
  115.             POP      ES
  116.             POP      DS
  117.             POP      SI
  118.             POP      CX
  119.             POP      BX
  120.             INT      20H
  121. ;
  122. END_OF_PROC LABEL    BYTE
  123. ;
  124. MEMHOG      ENDP
  125. ;-------------------------------------------
  126. CODESEG     ENDS
  127. ;**********************************************
  128.             END       START
  129.  
  130.