home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PROGRAMS / UTILS / DOS_HELP / ADVMSDOS.ZIP / HELLO-C.ASM < prev    next >
Encoding:
Assembly Source File  |  1986-06-19  |  2.8 KB  |  73 lines

  1.          name      hello
  2.          page      55,132
  3.          title     'HELLO.COM --- print Hello on terminal'
  4. ;
  5. ; HELLO.COM utility to demonstrate various parts
  6. ; of a functional COM-type assembly language program.
  7. ;
  8. ; Copyright (C) 1983 Ray Duncan
  9. ;
  10. ; To assemble, link, and convert this program into 
  11. ; a COM file, follow these steps:
  12. ;
  13. ;    C>MASM HELLO-C;
  14. ;     C>LINK HELLO-C;
  15. ;    C>EXE2BIN HELLO-C.EXE HELLO.COM
  16. ;    C>DEL HELLO-C.EXE
  17. ;
  18. ; Ignore the message "Warning: no stack segment" from the Linker.
  19.  
  20.                              ;show use of some EQUATES:
  21. cr       equ       0dh       ;ASCII carriage return
  22. lf       equ       0ah       ;ASCII line feed
  23.  
  24.                              ;begin the "Code" segment
  25.                              ;containing executable machine code
  26. cseg     segment   para public 'CODE'
  27.  
  28.      org       100h         ;COM files always have
  29.                              ;ORIGIN of 100H
  30.  
  31.          assume    cs:cseg,ds:cseg,es:cseg,ss:cseg
  32.  
  33. print    proc      near      ;actual program code
  34.                              ;is completely contained
  35.                              ;in the "procedure" named
  36.                              ;"PRINT".  At entry all
  37.                  ;segment registers are =,    
  38.                              ;SP contains FFFEH,
  39.                  ;and there is a zero on
  40.                  ;top of the stack.
  41.                  ;
  42.                              ;put the offset of the
  43.                              ;message text into DX,
  44.          mov       dx,offset message
  45.                              ;now DS:DX specifies the
  46.                              ;full address of the message.
  47.          mov       ah,9      ;use the MS-DOS function 9
  48.          int       21h       ;to print the string.
  49.                              ;
  50.      mov       ax,4c00h  ;exit back to MS-DOS  
  51.          int       21h         ;with a "return code" of zero.
  52.                              ;
  53. print    endp                ;end of the "procedure"
  54.                              ;named "PRINT"
  55.                              ;
  56.                              ;for COM programs, 
  57.                              ;constants and variables
  58.                              ;are in the same segment as
  59.                  ;the executable code.
  60.                  ;
  61. message  db        cr,lf,'Hello!',cr,lf,'$'
  62.                              ;
  63. cseg     ends                ;end of the code segment
  64.                  ;containing executable
  65.                              ;program. 
  66.  
  67.                              ;the final "End" statement
  68.                              ;signals the end of this
  69.                              ;program source file, and gives
  70.                              ;the starting address of
  71.                              ;the executable program
  72.          end       print
  73.