home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 5 / ctrom5b.zip / ctrom5b / PROGRAM / ASM / ALIB30B / SYS2.ASM < prev    next >
Assembly Source File  |  1994-11-28  |  3KB  |  135 lines

  1.     page    66,132
  2. ;******************************** SYS2.ASM   *********************************
  3.  
  4. LIBSEG           segment byte public "LIB"
  5.         assume cs:LIBSEG , ds:nothing
  6.  
  7. ;----------------------------------------------------------------------------
  8. .xlist
  9.     include  mac.inc
  10.     include  common.inc
  11. .list
  12. ;----------------------------------------------------------------------------
  13.     extrn    lib_info:byte
  14. comment 
  15. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -( SYSTEM  )
  16. SPAWN_DOS - execute a second copy DOS
  17. ;
  18. ; inputs:    DS:[SI] points to command tail
  19. ;            See DOS function 4bh for more information on command tail.
  20. ;            
  21. ;            if DS:[SI] points to a nul byte, control is transfered
  22. ;            to the second copy of COMMAND.COM and you get a DOS prompt.
  23. ;            control is passed back to the calling program when EXIT is
  24. ;            entered at the DOS prompt.
  25. ;
  26. ;            if DS:[SI] points to a program name string, the program
  27. ;            will be executed, and control will pass back to the calling
  28. ;            program at the termination of the second program.
  29. ;            
  30. ; output:    nothing
  31. ;
  32. ;* * * * * * * * * * * * * *
  33. 
  34.     public    SPAWN_DOS
  35. SPAWN_DOS    proc    far
  36.      APUSH   BX,CX,DX,DI,SI
  37.      PUSHF
  38.      APUSH   DS,ES
  39.      CLD
  40.      MOV     ES,LIB_INFO.PSP_SEG
  41.      MOV     AX,ES:[002Ch]
  42.      MOV     CS:[ENVIORN_SEG],AX        ;SAVE ENVIORNMENT SEG
  43. ;
  44. ; check input string
  45. ;
  46.      push    si
  47.      mov     cx,0
  48. slp: lodsb
  49.      inc     cx
  50.      cmp     al,0
  51.      je      sl_tail
  52.      cmp     al,0dh
  53.      je      sl_tail
  54.      cmp     al,'<'
  55.      je      sl_tail
  56.      cmp     al,'>'
  57.      je      sl_tail
  58.      cmp     al,'|'
  59.      je      sl_tail
  60.      jne     slp
  61. sl_tail:
  62.      mov     byte ptr ds:[si-1],0dh
  63.      pop     si
  64.     
  65.      MOV     AX,CS
  66.      MOV     ES,AX
  67.      MOV     CS:[TAIL_SEG],AX
  68.      mov     cs:[fcb1_seg],ax
  69.      mov     cs:[fcb2_seg],ax
  70.      MOV     DI,offset S_PARAM
  71.      MOV     CS:[DI],CL
  72.      JCXZ    SYS_1
  73.      ADD     BYTE PTR CS:[DI],03
  74.      INC     DI
  75.      MOV     AX,432Fh            ;'C/'
  76.      STOSW
  77.      MOV     AL,20h    ; ' '
  78.      STOSB
  79.      REPZ    MOVSB
  80. SYS_1:
  81.      MOV     AL,0Dh
  82.      STOSB
  83.      CLI
  84.      MOV     CS:[S_STACK_OFF],SP
  85.      MOV     CS:[S_STACK_SEG],SS
  86.      STI
  87.      MOV     DS,CS:[ENVIORN_SEG]
  88.      XOR     AX,AX
  89.      MOV     DX,offset S_COMSPEC
  90. SYS_2:
  91.      MOV     SI,AX
  92.      INC     AX
  93.      MOV     DI,DX
  94.      MOV     CX,0008
  95.      REPZ    CMPSB
  96.      JNZ     SYS_2
  97.      MOV     DX,SI
  98.      MOV     BX,offset ENVIORN_SEG
  99.      MOV     AX,4B00h
  100.      INT     21h
  101.      CLI
  102.      MOV     SP,CS:[S_STACK_OFF]
  103.      MOV     SS,CS:[S_STACK_SEG]
  104.      STI
  105.      APOP    ES,DS
  106.      POPF
  107.      APOP    SI,DI,DX,CX,BX
  108.      RETF
  109.  
  110. S_COMSPEC    DB    'COMSPEC='
  111. S_PARAM        DB    132 DUP (0)
  112.  
  113. ENVIORN_SEG     DW    0
  114.  
  115.             DW    S_PARAM
  116. TAIL_SEG        dW      00
  117.  
  118. fcb1_ptr    dw    fcb1
  119. fcb1_seg    dw    0
  120.  
  121. fcb2_ptr    dw    fcb2
  122. fcb2_seg    dw    0
  123.  
  124. fcb1        db 11 dup (' '), 5 dup (0)
  125. fcb2        db 11 dup (' '), 5 dup (0)
  126.  
  127. S_STACK_SEG    DW    0    ;STACK SEG SAVE
  128. S_STACK_OFF    DW    0    ;STACK OFFSET SAVE
  129.  
  130. SPAWN_DOS    endp
  131.  
  132.  
  133. LIBSEG    ENDS
  134. ;;    end
  135.