home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / RGASM.RAR / ASMCODE.EXE / CHAPT12 / DOSCOM.ASM < prev    next >
Encoding:
Assembly Source File  |  1994-08-27  |  2.8 KB  |  73 lines

  1. ;**********************************************************************
  2. ;
  3. ;  Program DosCom ( Chapter 12 )
  4. ;  Screen input/output interactive system for PC.  Version 1.4
  5. ;
  6. ;  Input MS DOS command processing
  7. ;
  8. ;  Author:  I.A.Sopin  Voronegh, 1991.
  9. ;
  10. ;  Specified in C program as
  11. ;
  12. ;   int near  DOSCOM (char near *Comand)
  13. ;
  14. ;  Parameter:
  15. ;
  16. ;  char near *Comand - ASCIIZ string containing the DOS command to be executed
  17. ;
  18. ;  Parameters are passed by reference through the stack.
  19. ;
  20. ;
  21. ;
  22. ;
  23. ;**********************************************************************
  24.     .MODEL  SMALL, C
  25.     PUBLIC  DOSCOM
  26.     .CODE
  27.  
  28. DOSCOM  PROC    NEAR C uses BX CX DX SI DI DS ES, AddrStr: word
  29. ;
  30. ;----------------------------------------------------------
  31. ;  Receive parameters from the PARM list:
  32.     mov     si,AddrStr
  33. ;----------------------------------------------------------
  34. ;  Define the command length and pass its text contents
  35.     xor     bx,bx                   ;  clear length counter
  36.     mov     ax,cs                   ;
  37.     mov     es,ax                   ;
  38.     lea     di,COMAND+1             ;  output buffer address
  39.     mov     cx,129                  ;  loop counter
  40. M0:     lodsb                           ;
  41.     and     al,al                   ;  end of MS DOS command text?
  42.     jz      M1                      ;  execute the command
  43.     stosb                           ;  move DS:SI ---> ES:DI
  44.     inc     bx                      ;  process the next character; inc length counter
  45.     loop    M0                      ;  goto the loop beginning
  46.     mov     ax,-1                   ;  error code
  47.     jmp     Exit                    ;  exit on error
  48. ;----------------------------------------------------------
  49. ;  MS DOS command execution (int 2Eh)
  50. M1:     mov     byte ptr ES:[di],0dh    ;  move CR code to the output buffer
  51.     mov     CS:COMAND,bl            ;  store the command length
  52.     mov     CS:SSKEEP,SS            ;  save SS register
  53.     mov     CS:SPKEEP,SP            ;  save SP register
  54.     mov     ax,cs                   ;
  55.     mov     ds,ax                   ;  file path string segment address
  56.     lea     si,COMAND               ;  SI:= file path string offset
  57.     int     2eh                     ;  command execution
  58.     mov     SS,CS:SSKEEP            ;  restore SS contents
  59.     mov     SP,CS:SPKEEP            ;  restore SP contents
  60.     xor     ax,ax                   ;
  61. ;----------------------------------------------------------
  62. ;  Pop registers and exit
  63. Exit:   RET
  64. ;----------------------------------------------------------
  65. ;  Data in the code segment
  66. SSKEEP  DW      0                       ;  Stack segment contents
  67. SPKEEP  DW      0                       ;  SP contents
  68. COMAND  DB      0                       ;  the command length
  69.     DB      128  dup (?)            ;  the command text
  70. DOSCOM  ENDP
  71.     END
  72.