home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / progm / assemutl.zip / MORERAM.ASM < prev    next >
Assembly Source File  |  1984-01-02  |  7KB  |  242 lines

  1. title    moreram 12-16-83    [12-16-83]
  2. ;-------------------------------------------------------------------------------
  3. ; MORERAM.COM - by Daniel M. O'Brien (v 1.0) 21 Dec 1983
  4. ;
  5. ;          - freely adapted from a PC-WORLD User-to-User column program
  6. ;        of the same name (object disassembled using ASMGEN) and from
  7. ;        a program shown in a DR. DOBBS Journal article
  8. ;        (Socha's 16 bit Toolkit) called MEMSIZE.
  9. ;
  10. ; This program has two (or three) purposes.
  11. ;
  12. ;    1) Allow a PC to use more memory than is allowed via the motherboard
  13. ;    memory switches (544 K bytes for the 64K motherboard and 640 K bytes
  14. ;    for the newer 256K motherboard). And because of 1)...
  15. ;
  16. ;    2) Allow faster power-up sequence by setting the motherboard memory
  17. ;    switch settings to 64 K bytes installed.
  18. ;
  19. ;    And as long as we are in the neighborhood...
  20. ;
  21. ;    3) Patch the ROM BIOS data area to indicate that this PC has four
  22. ;    floppy diskettes installed (instead of the normal two). This is for
  23. ;    ram disk emulation programs that require the motherboard equipment
  24. ;    options switch to be set to include the number of ram disks.
  25. ;    This is most notably required by the AST RESEARCH ramdisk program
  26. ;    called SUPERDRV. This code is commented out. To use it you must
  27. ;    uncomment out the code and reassemble. Search for the string:
  28. ;
  29. ;            ;stub***
  30. ;
  31. ; Using MORERAM.
  32. ;
  33. ;    First, copy MORERAM.COM to your boot device (floppy or fixed).
  34. ;    Next, create or edit your AUTOEXEC.BAT file found on your
  35. ;    boot device to include MORERAM as the **FIRST** program that
  36. ;    will be executed. This is important as results are not guaranteed
  37. ;    if MORERAM is not the first command executed at boot time.
  38. ;    Next, open the covers of your PC and set the memory switches
  39. ;    to indicate that your PC only has 64K.
  40. ;
  41. ;    Now try rebooting your PC using the Alt-Ctrl-Del sequence.
  42. ;
  43. ;    MORERAM will first display a hello banner and the amount of
  44. ;    memory DOS thinks your PC has (should be 64K). Next, MORERAM
  45. ;    will pause a second or two while it determines how much memory
  46. ;    your PC really has. (It also clears this memory in the process
  47. ;    to eliminate PARITY 2 errors later).
  48. ;    Once the physical memory limit is determined, MORERAM will display
  49. ;    that amount and then automatically re-boot. (Don't get excited,
  50. ;    this won't loop indefinitely, because...) The next time MORERAM
  51. ;    is again executed from your AUTOEXEC.BAT it will find that the amount
  52. ;    of memory DOS thinks you have will be the same as that installed, and
  53. ;    a reboot will be avoided!
  54. ;
  55. ; I use this program on my PC that has 576K (64K + 512K) worth of memory.
  56. ; Also, I have successfully tested it with 704K (64K + 512K + 128K) of memory,
  57. ; but this requires placing memory into the semi-forbidden zone (segment A000)
  58. ; designated by IBM as "reserved". But that's ok, as long as you don't install
  59. ; memory beyond this into the B000 segment where monochrome and graphics display
  60. ; memory live!
  61. ;
  62. ; Questions or comments should be left for me (DAN OBRIEN) on Gene Plantz'
  63. ; BBS in Chicago, IL (312-882-4227). I will attempt to fix bugs that may
  64. ; crop up, but I make no guarantees. You use this at your own risk (just like
  65. ; I do!). If you break something valuable, it's your own fault.
  66. ;
  67. ;-------------------------------------------------------------------------------
  68.  
  69.  
  70. lf    equ    0ah
  71. cr    equ    0dh
  72. ;
  73. ;initial values :    cs:ip    0000:0100
  74. ;            ss:sp    0000:ffff
  75.  
  76. s0000    segment
  77.     assume ds:s0000, ss:s0000 ,cs:s0000 ,es:s0000
  78.     org    $+0100h
  79.  
  80. start:    jmp    begin
  81.  
  82. hello    db    "MORE RAM than switches (v 1.0) "
  83.     db    "by Daniel M. O'Brien (21 Dec 1983)",cr,lf,'$'
  84. inmem    db    " Current memory is $"
  85. kbytes    db    " K bytes. $"
  86. findmem db    cr,lf," Physical memory is $"
  87. analyze db    " Analyzing & Clearing...$"
  88. reboot    db    " Re-Booting...",cr,lf,'$'
  89. done    db    cr,lf," Memory size is set correctly.",cr,lf,'$'
  90.  
  91. begin:
  92.     mov    dx,offset hello     ; say hello
  93.     mov    ah,9
  94.     int    21h
  95.  
  96.     mov    dx,offset inmem     ; how much memory?
  97.     mov    ah,9
  98.     int    21h
  99.  
  100.     mov    ax,ds:2     ; get top segment number from program prefix
  101.  
  102.     push    ds        ; save ds for later
  103.  
  104.     push    ax        ; save top segment number for later
  105.     mov    cl,6        ; convert to K bytes
  106.     shr    ax,cl
  107.     call    decout        ; and display
  108.  
  109.     mov    dx,offset kbytes    ; display "K bytes"
  110.     mov    ah,9
  111.     int    21h
  112.  
  113.     mov    dx,offset analyze    ; display analyzing message
  114.     mov    ah,9
  115.     int    21h
  116.  
  117.     xor    ax,ax        ; stop parity errors while we poke around
  118.     out    0a0h,al
  119.  
  120.     pop    ax        ; recover top segment number
  121.  
  122. loop:    mov    bx,0        ; look into this 16 byte "segment"
  123. ;    cmp    ax,0a000h    ; is ax = beginning of "reserved" addrs?
  124.                 ; stop at display memory instead!
  125.     cmp    ax,0b000h    ; is ax = beginning of "reserved" addrs?
  126.     je    ramend        ; yes, so end of ram
  127.     mov    ds,ax        ; no, so use this as segment
  128.     mov    [bx],ax     ; write contents of ax to ds:bx...
  129.     mov    cx,[bx]     ;... and read it back to cx
  130.     cmp    ax,cx        ; does data read = data written?
  131.     jne    ramend        ; if it not, then ran out of ram!
  132.  
  133.     mov    cx,8        ;    else - reset this 16 byte area
  134.     mov    es,ax
  135.     xor    ax,ax        ;      reset means 0000h
  136.     xor    di,di
  137.     rep    stosw        ;    to prevent parity errors when used
  138.  
  139.     mov    ax,ds        ; copy ds to ax...
  140.     inc    ax        ;... increment it...
  141.     jmp    loop        ;... and loop
  142.  
  143. ramend:
  144.     mov    bx,ax        ; found real end of ram - save it
  145.  
  146.     mov    al,80h        ; enable parity errors for the future
  147.     out    0a0h,al
  148.  
  149.     mov    ax,bx        ; convert segments to K bytes
  150.     mov    cl,6
  151.     shr    ax,cl
  152.  
  153.     mov    bx,40h        ; point to bios data area
  154.     mov    ds,bx
  155.     mov    bx,13h        ; and to memory size word in particular
  156.  
  157.     cmp    [bx],ax     ; same size?
  158.     je    exit        ; yes-then we must have done this before
  159.  
  160.     mov    [bx],ax     ; else - update and
  161.     push    ax
  162.  
  163. ; remove comments to patch equipment flag to indicate 4 floppies attached.
  164. ; especially useful for AST RESEARCH's SUPERDRV.
  165.  
  166. ;stub** mov    bx,10h        ; point to equipment flag
  167. ;stub** mov    ax,[bx]     ; get equipment flag
  168. ;stub** or    ax,00c0h    ; set installed floppy count to 4
  169. ;stub** mov    [bx],ax     ; and restore to proper spot
  170.  
  171.     pop    ax        ; get ds back but save ax on stack
  172.     pop    ds
  173.     push    ax
  174.  
  175.     mov    dx,offset findmem    ; tell how much memory we found
  176.     mov    ah,9
  177.     int    21h
  178.  
  179.     pop    ax        ; get K byte count
  180.     call    decout
  181.  
  182.     mov    dx,offset kbytes
  183.     mov    ah,9
  184.     int    21h
  185.  
  186.     mov    dx,offset reboot    ; tell them about reboot
  187.     mov    ah,9
  188.     int    21h
  189.  
  190.     int    19h        ; re-boot
  191.  
  192. exit:
  193.     pop    ds
  194.     mov    dx,offset done
  195.     mov    ah,9
  196.     int    21h
  197.  
  198.     int    20h        ; exit to dos
  199.  
  200.  
  201. ; quick and probably dirty - display decimal in ax routine
  202.  
  203. decout:
  204.     push    ax
  205.     push    bx
  206.     push    cx
  207.     push    dx
  208.  
  209.     xor    cx,cx        ;counter of digits
  210.     mov    bx,10        ;divide by 10 for conversion
  211.  
  212. decimal$loop:
  213.     xor    dx,dx        ;clear for divide
  214.     div    bx        ;get remainder and quotient
  215.     add    dx,'00'         ;make remainder ascii
  216.     push    dx        ;save it
  217.     inc    cx        ;and count it
  218.     or    ax,ax        ;out of digits?
  219.     jnz    decimal$loop    ;no-loop on the decimal
  220.  
  221. decimal$out:
  222.     pop    dx        ;get digit
  223.     mov    ah,2        ;print digit
  224.     int    21h
  225.     loop    decimal$out    ;and loop
  226.  
  227.     pop    dx
  228.     pop    cx
  229.     pop    bx
  230.     pop    ax
  231.     ret
  232.  
  233. s0000    ends
  234.  
  235.     end    start
  236. p    ax
  237.     ret
  238.  
  239. s0000    ends
  240.  
  241.     end    start
  242.