home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / MAWK113.ZIP / mawk113 / msdos / xdosexec.asm < prev    next >
Assembly Source File  |  1991-10-28  |  1KB  |  68 lines

  1.  
  2. ;********************************************
  3. ; xdosexec.asm
  4. ; copyright 1991, Michael D. Brennan
  5. ; This is a source file for mawk, an implementation of
  6. ; the AWK programming language.
  7. ; Mawk is distributed without warranty under the terms of
  8. ; the GNU General Public License, version 2, 1991.
  9. ;*******************************************/
  10.  
  11. ; This is only used for small model DOS
  12. ; It executes a program via int 0x21 0x4b00
  13. ;
  14.  
  15. public  _xDOSexec
  16.  
  17. .model  small
  18.  
  19. ;  _xDOSexec(char *command, void *blockp)
  20.  
  21. command  equ  [bp+4]
  22. blockp   equ  [bp+6]
  23.  
  24. .data
  25. extrn  _errno : word
  26. .code
  27.  
  28. ss_save   dw   ?
  29. sp_save   dw   ?
  30.  
  31. _xDOSexec  proc  near
  32.  
  33.      push  bp
  34.      mov   bp, sp
  35.      push  si
  36.      push  di
  37.      push  ds
  38.      mov   ax, ds
  39.      mov   es, ax
  40.      mov   cs:ss_save, ss
  41.      mov   cs:sp_save, sp
  42.      mov   ax, 4b00h
  43.      mov   bx, blockp
  44.      mov   dx, command
  45.      int   21h
  46.      jc    @error
  47.      cli            ;   restore  stack
  48.      mov   ss, cs:ss_save
  49.      mov   sp, cs:sp_save
  50.      sti
  51.      mov   ax, 4d00h
  52.      int   21h      ;  get child exit code
  53. @exit:
  54.      pop   ds
  55.      pop   di
  56.      pop   si
  57.      pop   bp
  58.      ret
  59. @error:
  60.      mov   _errno, ax
  61.      mov   ax, -1
  62.      jmp   @exit
  63.  
  64. _xDOSexec  endp
  65. end
  66.