home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS 1992 June / SIMTEL_0692.cdr / msdos / dirutl / treesurg.arc / XBDOS.ASM < prev   
Encoding:
Assembly Source File  |  1986-10-05  |  2.2 KB  |  65 lines

  1. ; Name          xbdos -- Access to DOS Functions
  2. ;
  3. ; Synopsis      iret = xbdos(fn,dx);
  4. ;               int iret          Flags returned by DOS function
  5. ;               int fn            DOS function number
  6. ;               int dx            Value to be placed in the DX register
  7. ;
  8. ; Description   xbdos is the gate to the DOS functions.  This version
  9. ;               replaces bdos as distributed with the Microsoft (Lattice)
  10. ;               C compiler.  It is functionally the same, but it also
  11. ;               externalizes the registers necessary for the extended
  12. ;               BDOS functions.
  13. ;
  14. ; Returns       iret              The value of AL, zero expanded upon
  15. ;                                 return from the DOS function call.
  16. ;               unsigned _cxreg,_dxreg  Values of the CX and DX registers
  17. ;                                 upon return from the DOS function call.
  18. ;
  19.  
  20. dgroup   group     data
  21. data     segment   word public 'DATA'
  22.          assume    ds:dgroup
  23.          public    _cxreg,_dxreg,_axreg,_bxreg,_direg,_sireg
  24. _axreg   dw        0
  25. _bxreg   dw        0
  26. _cxreg   dw        0
  27. _dxreg   dw        0
  28. _direg   dw        0
  29. _sireg   dw        0
  30. data     ends
  31.  
  32. ;        Function code
  33.  
  34. pgroup   group     prog
  35. prog     segment   byte public 'PROG'
  36.          assume    cs:pgroup
  37.          public    xbdos
  38. xbdos    proc      near
  39.          push      bp             ; Save frame pointer
  40.          mov       bp,sp          ; Set the stack pointer to top of frame
  41.          mov       ax,[bp + 4]
  42.          mov       ah,al
  43.          mov       al,byte ptr _axreg
  44.          mov       bx,_bxreg
  45.          mov       cx,_cxreg
  46.          mov       di,_direg
  47.          mov       si,_sireg
  48.          mov       dx,[bp + 6]
  49.  
  50.          int       21h            ; DOS function call AH
  51.  
  52.          mov       _bxreg,bx
  53.          mov       _cxreg,cx      ; Recover CX and DX registers
  54.          mov       _dxreg,dx
  55.          mov       _sireg,si
  56.          mov       _direg,di
  57.          mov       _axreg,ax
  58.          pushf                    ; push flags onto stack for return
  59.          pop       ax             ; put return into ax
  60.          pop       bp             ; Recover frame pointer
  61.          ret
  62. xbdos    endp
  63. prog     ends
  64.          end
  65.