home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast.iso / pcmag / vol7n08.zip / MEM512.ASM < prev    next >
Assembly Source File  |  1988-04-26  |  2KB  |  96 lines

  1. TITLE    'MEM512 - limit memory size to 512K
  2.  
  3. ;  This program will limit the amount of RAM known to the operating system
  4. ;  to 512K bytes.
  5. ;
  6. ;     If more than 512K is installed in the system, the memory size variable
  7. ;     is set to 512(K) and the system is rebooted without ROM diagnostics 
  8. ;     or memory re-sizing.
  9. ;
  10. ;     If the amount of RAM installed is less than or equal to 512K bytes,
  11. ;     a message is displayed informing the user of the amount of RAM in the
  12. ;     system.  No further action is taken.
  13.  
  14. MEMSIZE    EQU    512            ;Limit of memory size (in K)
  15.  
  16. ;
  17. ;  Macro to print a string of text end by '$'
  18. ;
  19. PRINT    MACRO    STRING
  20.     MOV    DX,OFFSET STRING
  21.     MOV    AH,9
  22.     INT    21H
  23.     ENDM
  24.  
  25. ;
  26. ;  Macro to delay so user can read message on screen
  27. ;
  28. DELAY     MACRO
  29.      LOCAL    DELAY_1,DELAY_2
  30.      MOV    AL,5
  31. DELAY_1: MOV    CX,0FFFFh
  32. DELAY_2: LOOP    DELAY_2
  33.      DEC    AL
  34.      JNZ    DELAY_1
  35.      ENDM
  36.  
  37. ;
  38. ;  Code segment starts here
  39. ;
  40. CSEG    SEGMENT
  41.     ORG    100H
  42.     ASSUME    CS:CSEG,DS:CSEG
  43.  
  44. INIT:    PRINT    STRTMSG            ;Display the "start" message
  45.  
  46.     MOV    BX,40H            ;DS:BX <= ptr to mem size variable
  47.     MOV    DS,BX
  48.     MOV    BX,13H
  49.     MOV    AX,WORD PTR [BX]    ;AX <= memory size value
  50.     CMP    AX,MEMSIZE
  51.     JBE    MEM_OK            ;Jump if memory size LE 512K
  52.  
  53. ;
  54. ;  Memory size is greater than 512K - set the memory size variable to 512(K)
  55. ;    and reboot the system without re-sizing memory
  56. ;
  57.     MOV    WORD PTR [BX],MEMSIZE    ;Set memory size to 512K
  58.     PUSH    CS            ;Restore DS to "CSEG"
  59.     POP    DS
  60.     PRINT    REBTMSG            ;Tell user we're rebooting
  61.     DELAY
  62.     INT    19H            ;Read bootstrap from disk; pass control
  63.  
  64. ;
  65. ;  Memory size is less than or equal to 512K - tell user the current amount
  66. ;    of memory and take no further action.
  67. ;
  68. MEM_OK:    PUSH    CS            ;Restore DS to "CSEG"
  69.     POP    DS
  70.  
  71. ;  Move ASCII value of mem size to output string.  Mem size is in AX.
  72.  
  73.     DIV    BYTE_10
  74.     OR    AH,30H
  75.     MOV    KBYTES[2],AH
  76.     AAM
  77.     OR    AX,3030H
  78.     XCHG    AH,AL
  79.     MOV    WORD PTR KBYTES,AX
  80.     PRINT    SIZEMSG            ;Display the message
  81.  
  82.     INT    20H            ;Exit to DOS
  83.  
  84. ;------------------------------------------------------------------------------
  85.  
  86. REBTMSG    DB    'Rebooting to set memory size to 512K',13,10,'$'
  87. SIZEMSG    DB    'System memory size is currently '
  88. KBYTES    DB    3 dup ('0'),'K',13,10,'$'
  89. STRTMSG DB    10,13,'MEM-512 tricks DOS into thinking '
  90.     DB    'system has 512K or less of RAM.',13,10,'$'
  91.  
  92. BYTE_10    DB    10            ;Used by Divide instruction in MEM_OK
  93.  
  94. CSEG    ENDS
  95.     END INIT
  96.