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

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