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.

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?

This article has been dead for over six months. Start a new discussion instead.