Blog Archive

Saturday, August 29, 2009

Hello World Example for Assembly language

"Hello World" is the first program one usually writes when
learning a new programming language.
So this post is for those peoples how are trying to learn
assembly language for x86 architecture.

data segment
msg db "hello, world!...$"

stack segment
db 30 dup(0); optional part

code segment
; set segment registers:
mov ax, data
mov ds, ax
mov es, ax

;this prints Hello World
lea dx, msg
mov ah, 09h
int 21h

; wait for any key press
mov ah, 1
int 21h

; return control to os:
mov ah, 4ch
int 21h

No comments:

Post a Comment