;**************************************************************
;***    EMS41.ASM                                           ***
;***                                                        ***
;***    function        EMS_Ems.getPFA(                     ***
;***                        var page_frame: EMS_PageFrame)  ***
;***                        : Boolean;                      ***
;***                                                        ***
;***    Returns PFA through pfa_ptr parameter.              ***
;***    Gives 0 if no error, or an error code.              ***
;***                                                        ***
;***                                                        ***
;***    (Ems Version 3.0)                                   ***
;**************************************************************

        .model  large,pascal   

        include emsdefs.asm 

        extrn   errno:WORD  

;
;   Define entry point
;
        public  EMS_Ems@getPFA

        .code

EMS_Ems@getPFA  proc    pfa:Far Ptr DWord, self:DWord

        mov     ah,GetPFA               ; Move function code
        int     Ems                     ; Do the ems call

;
;   Check AH to see if an error occured:
;
        or      ah,ah                   ; Set flags
        jnz     error

;
;   BX has a segment address, put it in the high Word
;   of the caller's location, and put zero in the low
;   word giving BX:0000 for an address.
;
        mov     ax,bx                   ; Save bx
        les     bx,pfa                  ; Get address for return
        mov     es:[bx+2],ax            ; Put segment down
        xor     ax,ax                   ; AX gets a zero
        mov     es:[bx],ax              ; Put offset down

        ret                             ; Return to caller (AX == 0)

error:
        mov     al,ah
        xor     ah,ah                   ; Zero high byte
        mov     errno,ax                ; Save in errno too
        ret                             ; Return to caller

EMS_Ems@getPFA      endp                ; End of procedure

        end                             ; End of source file

