home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / progm / assemutl.zip / MEMDRV.ASM < prev    next >
Assembly Source File  |  1985-05-11  |  10KB  |  356 lines

  1. title    ramdvr 01-01-84        [01-01-84]
  2. ;-------------------------------------------------------------------------------
  3. ; RAMDVR.SYS -- Modification to Dan O'Brien's excellent program by
  4. ;        Tom Perry, CIS 70455,751 or FORUM ][ 305/772-4444.
  5. ;
  6. ;        This modified version performs the same function described
  7. ;        below.    The only difference is that it runs as a "device
  8. ;        driver" on DOS 2.0 and up.  This means not only that it gets
  9. ;        control earlier and thus works faster, but also that it will
  10. ;        not cripple the system if you want to install a device that
  11. ;        takes a fair amount of memory.    For instance, I had a virtual
  12. ;        disk driver that uses 180K.  With switches set for 64K, it
  13. ;        could not be installed.  To get around this with MORRAM.COM,
  14. ;        you have to put logic in AUTOEXEC.BAT to switch between two
  15. ;        CONFIG.SYS files; it can be done (I did it for a while), but
  16. ;        it's messy and takes more disk space -- a LOT more if you're
  17. ;        working with a hard file with its large allocation unit.
  18. ;
  19. ;        To use this version, simply create a file on your boot disk
  20. ;        named CONFIG.SYS containing the line DEVICE=RAMDVR.SYS
  21. ;        and copy RAMDVR.SYS onto the boot disk.  If you already have
  22. ;        a CONFIG file, enter DEVICE=RAMDVR.SYS as its first line.
  23. ;        Set your switches for 64K, turn on the machine, and notice
  24. ;        the difference.  To learn how it works, read Dan's description
  25. ;        below.
  26. ;
  27. ;        There IS a penalty for doing it this way: Part of the program
  28. ;        remains permanently installed in the system as a device driver,
  29. ;        eating up a few bytes of precious RAM.    I have left enough to
  30. ;        keep the system from crashing if the device driver is driven
  31. ;        again (for instance, by a MODE RAMCHECK command).  More bytes
  32. ;        could be saved if you're willing to take that slight risk;
  33. ;        probably the minimum you'd need to keep is the four bytes
  34. ;        constituting the device driver chain at label "next_dev";
  35. ;        uncomment the indicated line if you want to try this.
  36.  
  37.  
  38. ; MORERAM.COM - by Daniel M. O'Brien (v 1.0) 21 Dec 1983
  39. ;
  40. ;          - freely adapted from a PC-WORLD User-to-User column program
  41. ;        of the same name (object disassembled using ASMGEN) and from
  42. ;        a program shown in a DR. DOBBS Journal article
  43. ;        (16 bit Toolkit) called MEMSIZE.
  44. ;
  45. ; This program has two (or three) purposes.
  46. ;
  47. ;    1) Allow a PC to use more memory than is allowed via the motherboard
  48. ;    memory switches (544 K bytes for the 64K motherboard and 640 K bytes
  49. ;    for the newer 256K motherboard). And because of 1)...
  50. ;
  51. ;    2) Allow faster power-up sequence by setting the motherboard memory
  52. ;    switch settings to 64 K bytes installed.
  53. ;
  54. ;    And as long as we are in the neighborhood...
  55. ;
  56. ;    3) Patch the ROM BIOS data area to indicate that this PC has four
  57. ;    floppy diskettes installed (instead of the normal two). This is for
  58. ;    ram disk emulation programs that require the motherboard equipment
  59. ;    options switch to be set to include the number of ram disks.
  60. ;    This is most notably required by the AST RESEARCH ramdisk program
  61. ;    called SUPERDRV. This code is commented out. To use it you must
  62. ;    uncomment out the code and reassemble. Search for the string:
  63. ;
  64. ;            ;stub***
  65. ;
  66. ; Using MORERAM.
  67. ;
  68. ;    First, copy MORERAM.COM to your boot device (floppy or fixed).
  69. ;    Next, create or edit your AUTOEXEC.BAT file found on your
  70. ;    boot device to include MORERAM as the **FIRST** program that
  71. ;    will be executed. This is important as results are not guaranteed
  72. ;    if MORERAM is not the first command executed at boot time.
  73. ;    Next, open the covers of your PC and set the memory switches
  74. ;    to indicate that your PC only has 64K.
  75. ;
  76. ;    Now try rebooting your PC using the Alt-Ctrl-Del sequence.
  77. ;
  78. ;    MORERAM will first display a hello banner and the amount of
  79. ;    memory DOS thinks your PC has (should be 64K). Next, MORERAM
  80. ;    will pause a second or two while it determines how much memory
  81. ;    your PC really has. (It also clears this memory in the process
  82. ;    to eliminate PARITY 2 errors later).
  83. ;    Once the physical memory limit is determined, MORERAM will display
  84. ;    that amount and then automatically re-boot. (Don't get excited,
  85. ;    this won't loop indefinitely, because...) The next time MORERAM
  86. ;    is again executed from your AUTOEXEC.BAT it will find that the amount
  87. ;    of memory DOS thinks you have will be the same as that installed, and
  88. ;    a reboot will be avoided!
  89. ;
  90. ; I use this program on my PC that has 576K (64K + 512K) worth of memory.
  91. ; Also, I have successfully tested it with 704K (64K + 512K + 128K) of memory,
  92. ; but this requires placing memory into the semi-forbidden zone (segment A000)
  93. ; designated by IBM as "reserved". But that's ok, as long as you don't install
  94. ; memory beyond this into the B000 segment where monochrome and graphics display
  95. ; memory live!
  96. ;
  97. ; Questions or comments should be left for me (DAN OBRIEN) on Gene Plantz'
  98. ; BBS in Chicago, IL (312-882-4227). I will attempt to fix bugs that may
  99. ; crop up, but I make no guarantees. You use this at your own risk (just like
  100. ; I do!). If you break something valuable, it's your own fault.
  101. ;
  102. ;-------------------------------------------------------------------------------
  103.  
  104.  
  105. lf    equ    0ah
  106. cr    equ    0dh
  107. ;
  108. ;initial values :    cs:ip    0000:0100
  109. ;            ss:sp    0000:ffff
  110.  
  111. s0000    segment
  112.     assume ds:s0000, ss:s0000 ,cs:s0000 ,es:s0000
  113.     org    $+0000h
  114. ;
  115. ;    device driver header and logic added 1-1-84 by Tom Perry.
  116. ;
  117. next_dev    dd    -1
  118.         dw    8000h           ;char device
  119. strategy    dw    dstrategy
  120. interrupt    dw    dinterrupt
  121. whatcall    db    'RAMCHECK'      ;name
  122.  
  123. dstrategy    proc    far
  124.  
  125.     mov    cs:rh_seg,es
  126.     mov    cs:rh_off,bx        ;save ptr to request header
  127.     ret
  128.  
  129. dstrategy    endp
  130.  
  131. rh_off    dw    0
  132. rh_seg    dw    0
  133.  
  134. dinterrupt    proc    far
  135.  
  136.     cld
  137.     push    ds
  138.     push    es
  139.     push    ax
  140.     push    bx
  141.     push    cx
  142.     push    dx
  143.     push    di
  144.     push    si
  145.  
  146.     mov    al,switch
  147.     cmp    al,0ffh
  148.     je    continue
  149.     mov    al,0ffh
  150.     mov    switch,al
  151.  
  152.     call    memdrvr
  153.  
  154.     mov    bx,rh_off
  155.     mov    ax,rh_seg
  156.     mov    es,ax        ;pt to req hdr
  157.     mov    ds,ax
  158.     mov    ax,offset last_place
  159. ;*risk    mov    ax,offset strategy ;USE THIS LINE TO SAVE RAM AT SOME RISK!
  160.     mov    14[bx],ax    ;set ending address
  161.     mov    ax,cs
  162.     mov    16[bx],ax    ; including segment
  163. continue:
  164.     mov    ax,0100h
  165.     or    3[bx],ax    ;set device status as DONE with NO ERROR
  166.  
  167.     pop    si
  168.     pop    di
  169.     pop    dx
  170.     pop    cx
  171.     pop    bx
  172.     pop    ax
  173.     pop    es
  174.     pop    ds
  175.  
  176.     ret
  177.  
  178. switch    db    0,0,0        ;one time switch & bug protection
  179. last_place db    'LAST PLACE'
  180.  
  181. dinterrupt    endp
  182.  
  183.  
  184. memdrvr proc    near
  185.  
  186. ;    end of device driver modifications by Tom Perry
  187. ;    (except as noted below).
  188.  
  189. start:    jmp    begin
  190.  
  191. hello    db    "Device driver to use MORE RAM than switches (v 1.1) ",cr,lf
  192.     db    "by Daniel M. O'Brien and Tom Perry (1 Jan 1984)",cr,lf,lf,'$'
  193. inmem    db    " Current memory is $"
  194. kbytes    db    " K bytes. $"
  195. findmem db    cr,lf," Physical memory is $"
  196. analyze db    " Analyzing & Clearing...$"
  197. reboot    db    " Re-Booting...",cr,lf,'$'
  198. done    db    cr,lf," Memory size is set correctly.",cr,lf,'$'
  199.  
  200. begin:
  201.     mov    dx,offset hello     ; say hello
  202.     mov    ah,9
  203.     int    21h
  204.  
  205.     mov    dx,offset inmem     ; how much memory?
  206.     mov    ah,9
  207.     int    21h
  208.  
  209. ; next 3 lines of code added 1-1-84 by Tom Perry for device driver environment.
  210.  
  211.     int    12h        ; ask bios how much memory
  212.     mov    cl,6
  213.     shl    ax,cl        ;shift left 6 times to look like PSP+2
  214.  
  215. ;    mov    ax,ds:2     ; get top segment number from program prefix
  216.  
  217.     push    ds        ; save ds for later
  218.  
  219.     push    ax        ; save top segment number for later
  220.     mov    cl,6        ; convert to K bytes
  221.     shr    ax,cl
  222.     call    decout        ; and display
  223.  
  224.     mov    dx,offset kbytes    ; display "K bytes"
  225.     mov    ah,9
  226.     int    21h
  227.  
  228.     mov    dx,offset analyze    ; display analyzing message
  229.     mov    ah,9
  230.     int    21h
  231.  
  232.     xor    ax,ax        ; stop parity errors while we poke around
  233.     out    0a0h,al
  234.  
  235.     pop    ax        ; recover top segment number
  236.  
  237. loop:    mov    bx,0        ; look into this 16 byte "segment"
  238. ;    cmp    ax,0a000h    ; is ax = beginning of "reserved" addrs?
  239.                 ; stop at display memory instead!
  240.     cmp    ax,0b000h    ; is ax = beginning of "reserved" addrs?
  241.     je    ramend        ; yes, so end of ram
  242.     mov    ds,ax        ; no, so use this as segment
  243.     mov    [bx],ax     ; write contents of ax to ds:bx...
  244.     mov    cx,[bx]     ;... and read it back to cx
  245.     cmp    ax,cx        ; does data read = data written?
  246.     jne    ramend        ; if it not, then ran out of ram!
  247.  
  248.     mov    cx,8        ;    else - reset this 16 byte area
  249.     mov    es,ax
  250.     xor    ax,ax        ;      reset means 0000h
  251.     xor    di,di
  252.     rep    stosw        ;    to prevent parity errors when used
  253.  
  254.     mov    ax,ds        ; copy ds to ax...
  255.     inc    ax        ;... increment it...
  256.     jmp    loop        ;... and loop
  257.  
  258. ramend:
  259.     mov    bx,ax        ; found real end of ram - save it
  260.  
  261.     mov    al,80h        ; enable parity errors for the future
  262.     out    0a0h,al
  263.  
  264.     mov    ax,bx        ; convert segments to K bytes
  265.     mov    cl,6
  266.     shr    ax,cl
  267.  
  268.     mov    bx,40h        ; point to bios data area
  269.     mov    ds,bx
  270.     mov    bx,13h        ; and to memory size word in particular
  271.  
  272.     cmp    [bx],ax     ; same size?
  273.     je    exit        ; yes-then we must have done this before
  274.  
  275.     mov    [bx],ax     ; else - update and
  276.     push    ax
  277.  
  278. ; remove comments to patch equipment flag to indicate 4 floppies attached.
  279. ; especially useful for AST RESEARCH's SUPERDRV.
  280.  
  281. ;stub** mov    bx,10h        ; point to equipment flag
  282. ;stub** mov    ax,[bx]     ; get equipment flag
  283. ;stub** or    ax,00c0h    ; set installed floppy count to 4
  284. ;stub** mov    [bx],ax     ; and restore to proper spot
  285.  
  286.     pop    ax        ; get ds back but save ax on stack
  287.     pop    ds
  288.     push    ax
  289.  
  290.     mov    dx,offset findmem    ; tell how much memory we found
  291.     mov    ah,9
  292.     int    21h
  293.  
  294.     pop    ax        ; get K byte count
  295.     call    decout
  296.  
  297.     mov    dx,offset kbytes
  298.     mov    ah,9
  299.     int    21h
  300.  
  301.     mov    dx,offset reboot    ; tell them about reboot
  302.     mov    ah,9
  303.     int    21h
  304.  
  305.     int    19h        ; re-boot
  306.  
  307. exit:
  308.     pop    ds
  309.     mov    dx,offset done
  310.     mov    ah,9
  311.     int    21h
  312.  
  313. ; exit via return to caller instead of int 20h exit to DOS.
  314. ; changed 1-1-84 by Tom Perry for device driver environment.
  315.  
  316.     ret
  317.  
  318.  
  319. ; quick and probably dirty - display decimal in ax routine
  320.  
  321. decout:
  322.     push    ax
  323.     push    bx
  324.     push    cx
  325.     push    dx
  326.  
  327.     xor    cx,cx        ;counter of digits
  328.     mov    bx,10        ;divide by 10 for conversion
  329.  
  330. decimal$loop:
  331.     xor    dx,dx        ;clear for divide
  332.     div    bx        ;get remainder and quotient
  333.     add    dx,'00'         ;make remainder ascii
  334.     push    dx        ;save it
  335.     inc    cx        ;and count it
  336.     or    ax,ax        ;out of digits?
  337.     jnz    decimal$loop    ;no-loop on the decimal
  338.  
  339. decimal$out:
  340.     pop    dx        ;get digit
  341.     mov    ah,2        ;print digit
  342.     int    21h
  343.     loop    decimal$out    ;and loop
  344.  
  345.     pop    dx
  346.     pop    cx
  347.     pop    bx
  348.     pop    ax
  349.     ret
  350.  
  351. memdrvr endp
  352.  
  353. s0000    ends
  354.  
  355.     end
  356.