home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / asmutil / dosexec.zip / CHILD.ASM next >
Assembly Source File  |  1989-06-07  |  1KB  |  68 lines

  1.     name    child
  2.     title    'CHILD process'
  3. ;
  4. ; CHILD.EXE --- a simple process loaded by PARENT.EXE
  5. ; to demonstrate the MS-DOS EXEC call, subfunction 00H.
  6. ;
  7. ; Ray Duncan, June 1987
  8. ;
  9.  
  10. stdin    equ    0    ; standard input
  11. stdout    equ    1    ; standard outpu
  12. stderr    equ    2    ; standard error
  13.  
  14. cr    equ    0dh    ; ASCII carriage return
  15. lf    equ    0ah    ; ASCII linefeed
  16.  
  17.  
  18. DGROUP    group    _DATA,STACK
  19.  
  20.  
  21. _TEXT     segment byte public 'CODE'    ; executable code segment
  22.  
  23.     assume  cs:_TEXT,ds:_DATA,ss:STACK
  24.  
  25. main    proc    far    ; entry point from MS-DOS
  26.  
  27.     mov    ax,_DATA    ; set DS = our data segment
  28.     mov    ds,ax
  29.  
  30.             ; display child message ...
  31.     mov    dx,offset msg    ; DS:DX = address of message
  32.     mov    cx,msg_len    ; CX = length of message
  33.     mov    bx,stdout    ; BX = standard output handle
  34.     mov    ah,40h    ; AH = fxn 40h, write 
  35.             ; file/device
  36.     int    21h    ; transfer to MS-DOS
  37.     jc    main2    ; jump if any error
  38.  
  39.     mov    ax,4c00h    ; no error, terminate child
  40.     int    21h    ; with return code = 0
  41.  
  42. main2:    mov    ax,4c01h    ; error, terminate child
  43.     int    21h    ; with return code = 1
  44.  
  45. main    endp        ; end of main procedure
  46.  
  47. _TEXT    ends
  48.  
  49.  
  50. _DATA    segment para public 'DATA'    ; static & variable data 
  51.             ; segment
  52.  
  53. msg    db    cr,lf,'Child executing!',cr,lf
  54. msg_len equ $-msg
  55.  
  56. _DATA    ends
  57.  
  58.  
  59. STACK    segment para stack 'STACK'
  60.  
  61.     dw    64 dup (?)
  62.  
  63. STACK    ends
  64.  
  65.  
  66.     end    main    ; defines program entry point
  67.  
  68.