home *** CD-ROM | disk | FTP | other *** search
- ; Name xbdos -- Access to DOS Functions
- ;
- ; Synopsis iret = xbdos(fn,dx);
- ; int iret Flags returned by DOS function
- ; int fn DOS function number
- ; int dx Value to be placed in the DX register
- ;
- ; Description xbdos is the gate to the DOS functions. This version
- ; replaces bdos as distributed with the Microsoft (Lattice)
- ; C compiler. It is functionally the same, but it also
- ; externalizes the registers necessary for the extended
- ; BDOS functions.
- ;
- ; Returns iret The value of AL, zero expanded upon
- ; return from the DOS function call.
- ; unsigned _cxreg,_dxreg Values of the CX and DX registers
- ; upon return from the DOS function call.
- ;
-
- dgroup group data
- data segment word public 'DATA'
- assume ds:dgroup
- public _cxreg,_dxreg,_axreg,_bxreg,_direg,_sireg
- _axreg dw 0
- _bxreg dw 0
- _cxreg dw 0
- _dxreg dw 0
- _direg dw 0
- _sireg dw 0
- data ends
-
- ; Function code
-
- pgroup group prog
- prog segment byte public 'PROG'
- assume cs:pgroup
- public xbdos
- xbdos proc near
- push bp ; Save frame pointer
- mov bp,sp ; Set the stack pointer to top of frame
- mov ax,[bp + 4]
- mov ah,al
- mov al,byte ptr _axreg
- mov bx,_bxreg
- mov cx,_cxreg
- mov di,_direg
- mov si,_sireg
- mov dx,[bp + 6]
-
- int 21h ; DOS function call AH
-
- mov _bxreg,bx
- mov _cxreg,cx ; Recover CX and DX registers
- mov _dxreg,dx
- mov _sireg,si
- mov _direg,di
- mov _axreg,ax
- pushf ; push flags onto stack for return
- pop ax ; put return into ax
- pop bp ; Recover frame pointer
- ret
- xbdos endp
- prog ends
- end