home *** CD-ROM | disk | FTP | other *** search
- name hello
- page 55,132
- title 'HELLO.COM --- print Hello on terminal'
- ;
- ; HELLO.COM utility to demonstrate various parts
- ; of a functional COM-type assembly language program.
- ;
- ; Copyright (C) 1983 Ray Duncan
- ;
- ; To assemble, link, and convert this program into
- ; a COM file, follow these steps:
- ;
- ; C>MASM HELLO-C;
- ; C>LINK HELLO-C;
- ; C>EXE2BIN HELLO-C.EXE HELLO.COM
- ; C>DEL HELLO-C.EXE
- ;
- ; Ignore the message "Warning: no stack segment" from the Linker.
-
- ;show use of some EQUATES:
- cr equ 0dh ;ASCII carriage return
- lf equ 0ah ;ASCII line feed
-
- ;begin the "Code" segment
- ;containing executable machine code
- cseg segment para public 'CODE'
-
- org 100h ;COM files always have
- ;ORIGIN of 100H
-
- assume cs:cseg,ds:cseg,es:cseg,ss:cseg
-
- print proc near ;actual program code
- ;is completely contained
- ;in the "procedure" named
- ;"PRINT". At entry all
- ;segment registers are =,
- ;SP contains FFFEH,
- ;and there is a zero on
- ;top of the stack.
- ;
- ;put the offset of the
- ;message text into DX,
- mov dx,offset message
- ;now DS:DX specifies the
- ;full address of the message.
- mov ah,9 ;use the MS-DOS function 9
- int 21h ;to print the string.
- ;
- mov ax,4c00h ;exit back to MS-DOS
- int 21h ;with a "return code" of zero.
- ;
- print endp ;end of the "procedure"
- ;named "PRINT"
- ;
- ;for COM programs,
- ;constants and variables
- ;are in the same segment as
- ;the executable code.
- ;
- message db cr,lf,'Hello!',cr,lf,'$'
- ;
- cseg ends ;end of the code segment
- ;containing executable
- ;program.
-
- ;the final "End" statement
- ;signals the end of this
- ;program source file, and gives
- ;the starting address of
- ;the executable program
- end print