;**************************************************************
;***    EMS4C.ASM                                           ***
;***                                                        ***
;***    function        EMS_EmBlk.getPagesForHandle(        ***
;***                        var num_pages:  Word)           ***
;***                        : Boolean;                      ***
;***                                                        ***
;***    Gives the number of pages associated with a         ***
;***    given EMM handle.                                   ***
;***                                                        ***
;***                                                        ***
;***    (Ems Version 3.0)                                   ***
;**************************************************************

        .model  large,pascal   

        include emsdefs.asm 

        extrn   errno:WORD  

;
;   Define entry point
;
        public  EMS_EmBlk@getPagesForHandle

        .code

EMS_EmBlk@getPagesForHandle proc    num_pages:Far Ptr Word, handle:Far Ptr Word

;
;   DX takes the handle
;
        les     bx,handle
        mov     dx,es:[bx]

        mov     ah,GetPagesForHandle    ; Move function code
        int     Ems                     ; Do the ems call

        or      ah,ah                   ; Set flags
        jnz     error

;
;   Return the result:
;
        mov     ax,bx                   ; Number of pages
        les     bx,num_pages
        mov     es:[bx],ax              ; Give it back

        xor     ax,ax                   ; AX gets 0
        ret                             ; Return to caller

error:
        mov     al,ah                   ; Transfer return code to al
        xor     ah,ah                   ; Zero high byte
        mov     errno,ax                ; Save in errno too
        ret                             ; Return to caller

EMS_EmBlk@getPagesForHandle endp        ; End of procedure

        end                             ; End of source file

