;**************************************************************
;***    XMS01.ASM                                           ***
;***                                                        ***
;***    function        XMS_Xms.allocHMA(                   ***
;***                        hmaBytes:       Word)           ***
;***                        : Boolean;                      ***
;***                                                        ***
;***    Allocates the High Memory Area to the program.      ***
;***    HmaBytes specifies the amount of HMA which the      ***
;***    the program intends to use. If it asks for a        ***
;***    sufficient amount, the request will be granted.     ***
;***                                                        ***
;**************************************************************

        .model  large,pascal 

        include xmsdefs.asm 

        extrn   errno:WORD  
        extrn   xmsHandler:DWord

;
;   Define entry point
;
        public  XMS_Xms@allocHMA

        .code

XMS_Xms@allocHMA    proc    hmaBytes:Word, self: DWord

        mov     dx,hmaBytes         ; Amount the app expects to use
        mov     ah,XMSAllocHMA      ; Function code
        call    xmsHandler          ; call the guy

        or      ax,ax               ; AX=0 means error
        jz      errorReturn

        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@allocHMA    endp            ; end of procedure

        end
