home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / dos_ency / 10 / child.asm next >
Encoding:
Assembly Source File  |  1988-08-11  |  1.9 KB  |  65 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 output
  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 file/device
  35.         int     21h                     ; transfer to MS-DOS
  36.         jc      main2                   ; jump if any error
  37.  
  38.         mov     ax,4c00h                ; no error, terminate child
  39.         int     21h                     ; with return code = 0
  40.  
  41. main2:  mov     ax,4c01h                ; error, terminate child
  42.         int     21h                     ; with return code = 1 
  43.  
  44. main    endp                            ; end of main procedure
  45.  
  46. _TEXT   ends
  47.  
  48.  
  49. _DATA   segment para public 'DATA'      ; static & variable data segment
  50.  
  51. msg     db      cr,lf,'Child executing!',cr,lf
  52. msg_len equ     $-msg
  53.  
  54. _DATA   ends
  55.  
  56.  
  57. STACK   segment para stack 'STACK'
  58.  
  59.         dw      64 dup (?)
  60.  
  61. STACK   ends
  62.  
  63.  
  64.         end     main                    ; defines program entry point
  65.