home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 5 / ctrom5b.zip / ctrom5b / DOS / UTILITY / GEHEUGEN / UMBGWJ10 / REDXMS.ASM < prev    next >
Assembly Source File  |  1994-11-25  |  5KB  |  184 lines

  1. ;; redxms.asm
  2. ;; Reduce extended memory size
  3. ;; Copyright (C) 1993  Grzegorz W. Jablonski
  4. ;;
  5. ;; This program is free software; you can redistribute it and/or modify
  6. ;; it under the terms of the GNU General Public License as published by
  7. ;; the Free Software Foundation; either version 2 of the License, or
  8. ;; (at your option) any later version.
  9. ;;
  10. ;; This program is distributed in the hope that it will be useful,
  11. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. ;; GNU General Public License for more details.
  14. ;;
  15. ;; You should have received a copy of the GNU General Public License
  16. ;; along with this program; if not, write to the Free Software
  17. ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. ;;
  19. ;; To contact the author about changes, enhancements, bug reports, or
  20. ;; other comments, send electronic mail to:
  21. ;;
  22. ;;      gwj@j-23.p.lodz.pl (from Internet sites)
  23. ;;
  24. ;; If you are unable to contact the author through electronic mail,
  25. ;; try sending a letter (as a last resort, only) to the following address:
  26. ;;
  27. ;;      Grzegorz W. Jablonski
  28. ;;      ul. Lanowa 6B m 64
  29. ;;      91-103 Lodz
  30. ;;      POLAND
  31. ;;
  32. ;; Please note that mail sent to this address may not yield a response
  33. ;; for several months!
  34. ;;
  35. ;; This program is to be used together with UMB_GWJ.SYS to decrease
  36. ;; reported entended memory size
  37.  
  38.     ideal                           ; Use TASM Ideal mode syntax
  39.     p286n                           ; Assemble for the 80286 (real mode)
  40.     locals  $$                      ; local labels preceded by '$$'
  41.  
  42. extsiz  equ     3200                    ; size of extended memory after change
  43.  
  44. rhds    equ     (rh ds:si)
  45. rhes    equ     (rh es:di)
  46.  
  47. struc   rh                              ; request header
  48. len     db      ?
  49. dev     db      ?
  50. cmd     db      ?
  51. st      dw      ?
  52. rsvd    dq      ?
  53. ct      db      ?
  54. aoff    dw      ?
  55. aseg    dw      ?
  56. dptr    dd      ?
  57. ends
  58.  
  59. segment redxms    use16                   ; low-memory resident segment
  60.  
  61. devhdr  dd      -1                      ; device header
  62. devflg  dw      0a000h
  63. devstr  dw      redxmsstr
  64. devint  dw      redxmsint0
  65. devnam  db      'REDXMSX0'
  66.  
  67. label   rhptr   dword                   ; pointer to request header
  68. rhoff   dw      ?
  69. rhseg   dw      ?
  70.  
  71. label           OrgIntr15 dword         ; old interrupt function pointer
  72. int15off        dw       ?
  73. int15seg        dw       ?
  74.  
  75. proc    redxmsstr far                     ; strategy routine
  76.     assume  cs:redxms
  77.  
  78.     mov     [redxms:rhoff], bx
  79.     mov     [redxms:rhseg], es
  80.     ret
  81. endp
  82.  
  83. proc    redxmsint far                     ; resident interrupt routine
  84.     assume  cs:redxms
  85.  
  86.     push    si                      ; save registers
  87.     push    ds
  88.     lds     si, [redxms:rhptr]        ; ds:si = request header
  89.     mov     [rhds.st], 8103h        ; return error (unknown command)
  90.     pop     ds                      ; restore registers
  91.     pop     si
  92.     ret
  93. endp
  94.  
  95. proc    intr15  far
  96.     assume  cs:redxms
  97.  
  98.     cmp     ah,88h
  99.     je      $$1
  100.     jmp     [redxms:OrgIntr15]
  101. $$1:    mov     ax,extsiz
  102.     iret
  103. endp    intr15
  104.  
  105.  
  106. label   endres  unknown
  107.  
  108. oldss   dw      ?
  109. oldsp   dw      ?
  110.  
  111. proc    rpopf   near    ; for reliable popf
  112.     iret
  113. endp    rpopf
  114.  
  115. proc    redxmsint0 far                    ; initial interrupt routine
  116.     assume  cs:redxms, ds:redxms
  117.  
  118.     pushf                           ; save flags
  119.     push    cs
  120.     pusha                           ; save registers
  121.     push    ds
  122.     push    es
  123.     push    cs
  124.     pop     ds
  125.     les     di, [rhptr]             ; es:di = request header
  126.     mov     [rhes.st], 8103h        ; assume error (unknown command)
  127.     mov     al, [rhes.cmd]          ; only cmd 0, INIT is legal
  128.     or      al, al
  129.     jnz     short $$1
  130.     call    init
  131.  
  132. $$1:    pop     es                      ; restore registers
  133.     pop     ds
  134.     popa
  135.     call    rpopf                   ; restore flags before returning
  136.     ret
  137. endp
  138.  
  139. proc    init    near                    ; initialize driver
  140.     assume  cs:redxms, ds:redxms
  141.  
  142.     mov     [oldss], ss             ; save old stack
  143.     mov     [oldsp], sp
  144.     mov     bx, ds
  145.     mov     ss, bx                  ; enable new stack
  146.     mov     sp, offset stktop
  147.     push    es
  148.     xor     ax,ax
  149.     mov     es,ax
  150.     cli
  151.     mov     ax,[es:4*15h]
  152.     mov     [int15off],ax
  153.     mov     ax,[es:4*15h+2]
  154.     mov     [int15seg],ax
  155.     mov     ax,offset intr15
  156.     mov     [es:4*15h],ax
  157.     mov     ax,cs
  158.     mov     [es:4*15h+2],ax
  159.     mov     al,52h
  160.     out     22h,al
  161.     mov     al,0bfh
  162.     out     23h,al
  163.     sti
  164.     mov     ah,52h
  165.     int     21h
  166.     add     bx,45h          ; [es:bx] - extended memory size in kB
  167.     mov     [es:bx],extsiz
  168.     pop     es
  169.     mov     [devint], offset redxmsint; enable resident interrupt routine
  170.     mov     [rhes.aseg], cs         ; discard initialization section
  171.     mov     [rhes.aoff], offset endres
  172.     mov     [rhes.st], 0100h        ; return success code
  173.     mov     ss, [oldss]             ; restore old stack
  174.     mov     sp, [oldsp]
  175.     ret
  176. endp
  177.     align   4                       ; start stack on dword boundary
  178.  
  179. stkbot  db      512 dup (?)             ; initialization stack
  180. label   stktop  word
  181.  
  182. ends    redxms
  183.     end
  184.