Home x86 Assembly <<< Previous Next >>>

Hello World !

As made popular by C and C++, the first program written for a language usually displays 'Hello World'.

Several popular ways to write Hello World in assembly are known. Two listings are given below:

PROGRAM 1

title Hello World

.dosseg
.model small
.stack 100h

.data
message db 'Hello, World!',13,10,'$'

.code
main proc
mov ax,@data
mov ds,ax

mov ah,9
mov dx,offset message
int 21h

mov ax,4C00h
int 21h
main endp
end main

PROGRAM 2

.model tiny
.code
.startup
mov dx,offset helloS
xchg bp,ax
int 21h
ret
helloS db 'Hello, World!$'
end

To run these two programs, do the following:

  1. Type out Program 1 into a text editor, such as Notepad.
  2. Save it as a .ASM file (e.g. save it as program1.asm) in a directory where ML.EXE was saved.
  3. Go to the directory where you have saved ML.EXE and LINK.EXE
  4. At the command prompt, type ML program1.asm
  5. If everything goes alright, you will get a file called program1.exe

Run the file program1.exe, and your message will be displayed.

In the same way, you can also compile the second program.

The difference between the two programs is that in the first case, you get an .EXE file, which is over 500 bytes large. In the second case, you'd get a .COM file which is 21 bytes in size.

Click to download Program1, and Program2

Home x86 Assembly <<< Previous Next >>>