;**************************************************************
;***    XMS07.ASM                                           ***
;***                                                        ***
;***    function        XMS_Xms.getA20State(                ***
;***                        var a20State:   Word)           ***
;***                        : Boolean;                      ***
;***                                                        ***
;***    Returns the enable status of the A20 line.          ***
;***    A20State is TRUE (1) on return if A20 is enabled,   ***
;***    otherwise it is FALSE (0).                          ***
;***                                                        ***
;**************************************************************

        .model  large,pascal 

        include xmsdefs.asm 

        extrn   errno:WORD  
        extrn   xmsHandler:DWord

;
;   Define entry point
;
        public  XMS_Xms@getA20State

        .code

XMS_Xms@getA20State proc    a20State:Far Ptr Word, self: DWord

        mov     ah,XMSGetA20State   ; Function code
        call    xmsHandler          ; call the guy

        or      ax,ax               ; AX=0 may mean error
        jnz     goodReturn          ; AX<>0 means A20 enabled
        or      bl,bl               ; BL<>0 means error
        jnz     errorReturn

goodReturn:
        les     bx,a20State         ; Address to return result
        mov     es:[bx],ax          ; Flag gives A20 state
        mov     ax,XMSErrOK         ; No error
        ret

errorReturn:
        mov     al,bl               ; Move error code to AL
        xor     ah,ah               ; Zero extend to 16 bits
        mov     errno,ax            ; Copy to errno
        ret

XMS_Xms@getA20State endp            ; end of procedure

        end
