;**************************************************************
;***    XMS0B.ASM                                           ***
;***                                                        ***
;***    function        XMS_Xms.moveXM(                     ***
;***                        var packet:     XMS_MovePacket) ***
;***                        : Boolean;                      ***
;***                                                        ***
;***    Moves an area of of memory between or within XMS    ***
;***    and/or conventional memory.                         ***
;***                                                        ***
;**************************************************************

        .model  large,pascal 

        include xmsdefs.asm 

        extrn   errno:WORD  
        extrn   xmsHandler:DWord

;
;   Define entry point
;
        public  XMS_Xms@moveXM

        .code

XMS_Xms@moveXM      proc    packet:Far Ptr Word, self:DWord

    ;   We are required to pass the packet address in DS:SI.
    ;   As a result, we need to save DS. Further, we need to
    ;   copy DS to ES, so that we can find the address of the
    ;   xmsHandler when we need it.

        push    si                  ; Save SI

        push    ds                  ; Move DS to ES
        pop     es

        lds     si,packet           ; DS:SI gets packet address

        mov     ah,XMSMoveXM        ; Function code
        call    es:xmsHandler       ; call the guy

        push    es                  ; restore DS
        pop     ds

        or      ax,ax               ; AX=0 means error
        jz      errorReturn

        mov     ax,XMSErrOK         ; No error
        pop     si                  ; Restore SI
        ret

errorReturn:
        mov     al,bl               ; Move error code to AL
        xor     ah,ah               ; Zero extend to 16 bits
        mov     errno,ax            ; Copy to errno
        pop     si                  ; Restore SI
        ret

XMS_Xms@moveXM      endp            ; end of procedure

        end
