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

  1.          name      hello
  2.          page      55,132
  3.          title     'HELLO.EXE --- print Hello on terminal'
  4. ;
  5. ; HELLO.EXE utility to demonstrate various parts
  6. ; of a functional EXE-type assembly language program,
  7. ; use of segments, and a MS-DOS function call.
  8. ;
  9. ; Ray Duncan, September 1983
  10. ;
  11. ; To assemble, link, and convert this program into 
  12. ; an EXE file, follow these steps:
  13. ;
  14. ;    C>MASM HELLO-E;
  15. ;     C>LINK HELLO-E;
  16. ;
  17.  
  18.                              ;show use of some EQUATES:
  19. cr       equ       0dh       ;ASCII carriage return
  20. lf       equ       0ah       ;ASCII line feed
  21.  
  22.                              ;begin the "Code" segment
  23.                              ;containing executable
  24.                              ;machine code
  25. cseg     segment   para public 'CODE'
  26.  
  27.          assume    cs:cseg,ds:dseg,ss:stack
  28.  
  29. print    proc      far       ;actual program code
  30.                              ;is completely contained
  31.                              ;in the "procedure" named
  32.                              ;"PRINT".
  33.                              ;
  34.                              ;set Data Segment Register
  35.                              ;to point to the Data Segment
  36.                              ;of this program, so that the
  37.                              ;message we want to print is
  38.                              ;addressable.
  39.          mov       ax,dseg
  40.          mov       ds,ax
  41.                              ;now put the offset of the
  42.                              ;message text into DX,
  43.          mov       dx,offset message
  44.                              ;now DS:DX specifies the
  45.                              ;full address of the message.
  46.          mov       ah,9      ;use the MS-DOS function 9
  47.          int       21h       ;to print the string.
  48.                              ;
  49.      mov        ax,4c00h  ;exit back to MS-DOS with
  50.          int       21h       ;"return code" of zero.    
  51.  
  52. print    endp                ;end of the "procedure"
  53.                              ;named "PRINT"
  54.                              ;
  55. cseg     ends                ;end of the code segment
  56.                              ;containing executable
  57.                              ;program.
  58.                              ;
  59.                              ;now we define a data segment
  60.                              ;containing our program's
  61.                              ;constants and variables.
  62. dseg     segment   para 'DATA'
  63.                              ;
  64. message  db        cr,lf,'Hello!',cr,lf,'$'
  65.                              ;
  66. dseg     ends
  67.                              ;
  68.                              ;lastly, we define a Stack
  69.                              ;Segment which contains
  70.                              ;a scratch area of memory
  71.                              ;for use by our program's stack
  72. stack    segment   para stack 'STACK'
  73.                              ;allow 64 words in this case
  74.          dw       64 dup (?)
  75.  
  76. stack    ends
  77.                              ;the final "End" statement
  78.                              ;signals the end of this
  79.                              ;program source file, and gives
  80.                              ;the starting address of
  81.                              ;the executable program
  82.          end       print
  83.