I am attempting to learn Assembly (x86 Assembly on Windows using NASM) but am having trouble understanding what this is doing.

Can someone please explain line by line what this code is doing? I have commented the lines that I think I know what they do, but I'm not sure.

section .text ;text section : Where the code goes
org 0x100 ;Start location of the program?
	mov ah, 0x9 ;No idea
	mov dx, hello ;Moves hello into dx, not sure what dx is though (I know its a register)
	int 0x21 ;calls the OS interupt, to make it output?
	
	mov ax, 0x4c00 ;No idea
	int 0x21 ;Calls it again?
section .data ;Data section : where variables are stored
hello: db 'Hello, world!', 13, 10, '$' ; Don't get the '$' at the end

Thank you to anyone who helps me with this.

Recommended Answers

All 5 Replies

int 21h, ax = 09, writes the string in dx to the screen. You would have known that if you had bothered to google for "int 21h".

mov ax, 0x9 has to do with the outputting?

What is the other int 0x21 for?

int 21h is a general purpose interrupt with many different functions -- each function is identified by the value of the ax register. google for in21 functions and you will find them all.

If you want to learn assembly then the place to look is in a good book.

I understand this code now, thank you. Can you recommend any books?

I cut my teeth an older version this one by Peter Norton, way back in the days before MS-Windows

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.