hello-world

Home > Courses > Intel x86 Assembly > Hello World

Please try out this sample program. This will ensure that your assembler and linker are working properly. If you cannot assemble or link these files, please check your path settings. You need to be able to access TASM.exe and TLINK.exe.

TITLE hi_world.asm

;=======================================================================

; Hello World application - prints "Hello World" to the screen

;=======================================================================


;Some Useful Constants

STDIN EQU 0

STDOUT EQU 1

STDERR EQU 2

LF EQU 0Ah

CR EQU 0Dh


_DATA SEGMENT USE16 BYTE PUBLIC 'DATA'

myString DB "Hello World", CR, LF, "$"

_DATA ENDS


_TEXT SEGMENT USE16 WORD PUBLIC 'CODE'

ASSUME cs:_TEXT, ds:_DATA


Start:

mov ax, _DATA ; set DS to point to our data segment

mov ds, ax


mov ah, 09h ; function: print string $ terminated

mov dx, OFFSET myString ; pointer to string

int 21h


mov ax, 4C00h ; function: exit program and return to DOS

int 21h


_TEXT ENDS


_STACK SEGMENT USE16 STACK 'STACK'

DW 100 dup(?)

_STACK ENDS


END Start