home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / advos2 / ch03 / hello.asm < prev    next >
Encoding:
Assembly Source File  |  1988-12-12  |  1.4 KB  |  63 lines

  1.     title   HELLO -- Display Message on stdout
  2.         page    55,132
  3.         .286
  4.  
  5. ;
  6. ; HELLO.EXE
  7. ;
  8. ; A simple OS/2 assembly language program.
  9. ;
  10. ; Copyright (C) 1986 Ray Duncan
  11. ;
  12.  
  13. stdin   equ     0          ; standard input handle
  14. stdout  equ     1          ; standard output handle
  15. stderr  equ     2          ; standard error handle
  16.  
  17.         extrn   DosWrite:far
  18.         extrn   DosExit:far
  19.  
  20. DGROUP  group   _DATA
  21.  
  22.  
  23. _DATA   segment word public 'DATA'
  24.  
  25. msg     db      0dh,0ah,"Hello World!",0dh,0ah
  26. msg_len equ     $-msg
  27.  
  28. wlen    dw      ?          ; receives bytes written
  29.  
  30. _DATA   ends
  31.  
  32.  
  33. _TEXT   segment word public 'CODE'
  34.  
  35.         assume  cs:_TEXT,ds:DGROUP
  36.  
  37. print   proc    far
  38.  
  39.         push    stdout     ; standard output handle
  40.         push    ds         ; address of data
  41.         push    offset DGROUP:msg
  42.         push    msg_len    ; length of data
  43.         push    ds         ; receives bytes written
  44.         push    offset DGROUP:wlen
  45.         call    DosWrite   ; transfer to OS/2
  46.     or    ax,ax      ; was write successful?
  47.     jnz    error      ; jump if function failed
  48.  
  49.         push    1          ; terminate all threads
  50.         push    0          ; return success code
  51.         call    DosExit    ; transfer to OS/2
  52.  
  53. error:  push    1          ; terminate all threads
  54.         push    1          ; return error code
  55.         call    DosExit    ; transfer to OS/2
  56.  
  57. print   endp
  58.  
  59. _TEXT   ends
  60.  
  61.         end     print
  62.  
  63.