home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / advmsdos / chap03 / hello_c.asm next >
Encoding:
Assembly Source File  |  1988-10-01  |  1.2 KB  |  59 lines

  1.     title    HELLO.COM --- print hello on terminal
  2.     page    55,132
  3.  
  4. ;
  5. ; HELLO-C.ASM    Demonstrates components of a
  6. ;         functional COM-type assembly 
  7. ;         language program, and an MS-DOS
  8. ;        function call.
  9. ;
  10. ; Copyright (C) 1988 Ray Duncan
  11. ;
  12. ; Build:  MASM HELLO-C;
  13. ;         LINK HELLO-C;
  14. ;         EXE2BIN HELLO.EXE HELLO.COM
  15. ;         DEL HELLO.EXE
  16. ;
  17. ; Usage:  HELLO
  18. ;
  19.  
  20. stdin    equ    0        ; standard input handle
  21. stdout    equ    1        ; standard output handle
  22. stderr    equ    2        ; standard error handle
  23.  
  24. cr    equ    0dh           ; ASCII carriage return
  25. lf    equ    0ah           ; ASCII line feed
  26.  
  27.  
  28. _TEXT    segment    word public 'CODE'
  29.  
  30.     org    100h        ; COM files always have
  31.                 ; an origin of 100H
  32.  
  33.     assume    cs:_TEXT,ds:_TEXT,es:_TEXT,ss:_TEXT
  34.  
  35. print     proc    near           ; entry point from MS-DOS
  36.  
  37.     mov    ah,40h        ; function 40H = write
  38.     mov    bx,stdout    ; handle for standard output
  39.     mov    cx,msg_len    ; length of message
  40.     mov    dx,offset msg    ; address of message
  41.     int    21h        ; transfer to MS-DOS
  42.  
  43.     mov    ax,4c00h    ; exit, return code = 0
  44.     int    21h        ; transfer to MS-DOS
  45.  
  46. print    endp
  47.  
  48.  
  49. msg    db    cr,lf        ; message to display
  50.     db    'Hello World!',cr,lf
  51.  
  52. msg_len    equ    $-msg        ; length of message
  53.                 
  54.  
  55. _TEXT    ends
  56.  
  57.      end    print        ; defines entry point
  58.  
  59.