home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / UTILITY / SYSTEM / A20TEST.ZIP / A20ON.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-01-18  |  4.6 KB  |  179 lines

  1.                 page    60, 132
  2.                 title   Gate A20 enable utility
  3.  
  4.  
  5. ;************************************************************************
  6. ;*
  7. ;*      Enable line A20.  This routine is hardware dependent and will
  8. ;*   only work properly on AT's and 100% compatibles.
  9. ;*
  10. ;************************************************************************
  11.  
  12.                 ORG     100h
  13. CODE            segment public 'CODE'
  14.                 assume cs:CODE, ds:CODE, es:CODE
  15.  
  16. Start:          jmp     EnableA20
  17.  
  18. A20OnMessage    db      13, 10, 'The A20 line is currently ENABLED.', 13, 10, '$'
  19. A20OffMessage   db      13, 10, 'The A20 line is currently DISABLED.', 13, 10, '$'
  20.  
  21. EnableA20:      mov     ax, cs
  22.                 add     ax, 0010h
  23.                 mov     ds, ax
  24.                 mov     es, ax
  25.                 mov     ax, 1
  26.                 call    AT_A20Handler
  27.  
  28. QueryA20:       call    IsA20On
  29.                 or      ax, ax
  30.                 jz      A20Off
  31.  
  32. A20On:          mov     dx, offset A20OnMessage
  33.                 jmp     short QueryDone
  34.  
  35. A20Off:         mov     dx, offset A20OffMessage
  36.  
  37. QueryDone:      mov     ah, 09h
  38.                 int     21h
  39.  
  40.                 mov     ax, 4C00h
  41.                 int     21h
  42.  
  43.  
  44. ;************************************************************************
  45. ;*
  46. ;*      Check line A20 status.
  47. ;*
  48. ;*      Proc    : IsA20On
  49. ;*      Params  : None
  50. ;*      Return  : AX = 1                --> A20 enabled
  51. ;*                AX = 0                --> A20 disabled
  52. ;*      Regs    : AX, CX, DI, SI & flags clobbered.
  53. ;*      Notes   :
  54. ;*
  55. ;************************************************************************
  56.  
  57. LowMemory       label   dword
  58.                 dw      00080h
  59.                 dw      00000h
  60.  
  61. HighMemory      label   dword
  62.                 dw      00090h
  63.                 dw      0FFFFh
  64.  
  65. IsA20On         proc    near
  66.  
  67.                 push    ds
  68.                 push    es
  69.  
  70.                 lds     si, es:LowMemory
  71.                 les     di, es:HighMemory
  72.                 mov     cx, 4
  73.                 cld
  74.                 repe    cmpsw
  75.  
  76.                 pop     es
  77.                 pop     ds
  78.                 xor     ax, ax
  79.  
  80.                 jcxz    IAONoWrap
  81.                 inc     ax
  82.  
  83. IAONoWrap:      xor     bl, bl
  84.                 ret
  85.  
  86. IsA20On         endp
  87.  
  88.  
  89. ;************************************************************************
  90. ;*
  91. ;*      Enable or disable line A20 on AT or 100% compatible.
  92. ;*
  93. ;*      Proc    : AT_A20Handler
  94. ;*      Params  : AX = 0                --> Disables A20
  95. ;*                AX = 1                --> Enables A20
  96. ;*      Return  : AX = 1                --> Operation successful
  97. ;*                AX = 0                --> Operation failed
  98. ;*      Regs    : AX, CX & flags clobbered.
  99. ;*      Notes   :
  100. ;*
  101. ;************************************************************************
  102.  
  103. AT_A20Handler   proc    near
  104.  
  105.                 or      ax, ax
  106.                 jz      AAHDisable
  107.  
  108. AAHEnable:      call    Sync8042
  109.                 jnz     AAHErr
  110.  
  111.                 mov     al, 0D1h
  112.                 out     64h, al
  113.                 call    Sync8042
  114.                 jnz     AAHErr
  115.  
  116.                 mov     al, 0DFh
  117.                 out     60h, al
  118.                 call    Sync8042
  119.                 jnz     AAHErr
  120.  
  121.                 mov     al, 0FFh
  122.                 out     64h, al
  123.                 call    Sync8042
  124.                 jnz     AAHErr
  125.                 jmp     short AAHExit
  126.  
  127. AAHDisable:     call    Sync8042
  128.                 jnz     AAHErr
  129.  
  130.                 mov     al, 0D1h
  131.                 out     64h, al
  132.                 call    Sync8042
  133.                 jnz     AAHErr
  134.  
  135.                 mov     al, 0DDh
  136.                 out     60h, al
  137.                 call    Sync8042
  138.                 jnz     AAHErr
  139.  
  140.                 mov     al, 0FFh
  141.                 out     64, al
  142.                 call    Sync8042
  143.  
  144. AAHExit:        mov     ax, 1
  145.                 ret
  146.  
  147. AAHErr:         xor     ax, ax
  148.                 ret
  149.  
  150. AT_A20Handler   endp
  151.  
  152.  
  153.  
  154. ;************************************************************************
  155. ;*
  156. ;*      Synchronize 8042 port.
  157. ;*
  158. ;*      Proc    : Sync8042
  159. ;*      Params  : None
  160. ;*      Return  :
  161. ;*      Regs    : AX, CX & flags clobbered.
  162. ;*      Notes   :
  163. ;*
  164. ;************************************************************************
  165.  
  166. Sync8042        proc    near
  167.  
  168.                 xor     cx, cx
  169. S8InSync:       in      al, 64h
  170.                 and     al, 2
  171.                 loopnz  S8InSync
  172.                 ret
  173.  
  174. Sync8042        endp
  175.  
  176.  
  177. CODE            ends
  178.                 end     Start
  179.