Assembly language x86 - using NASM on Linux. EDX, ECX, EBX. EAX int 80h

1.3k Views Asked by At

This is a piece of assembly language code that my professor has given me. Can you talk me through how it works? Especially the "int 80h" parts. I've looked online for the answers but it doesn't really make sense to me.

section .data string: db "Hello World", 0x0a 
len:     equ $ - string

section .text 
global main 
main:
       mov edx, len
       mov ecx, string
       mov ebx, 1
       mov eax, 4
       int 80h
       cmp eax, 0        
       je go

go:
       xor ebx, ebx
       mov eax, 1
       int 80h

I understand that edx, ecx etc are register locations, however, I don't get how it substitutes.

I know that mov is mnemonic for move and je is jump if equal to but the rest is a bit out of my comfort zone.

My prof has thrown us in at the deep end here and wants to know who can figure it out first so any help is always appreciated.

1

There are 1 best solutions below

1
On BEST ANSWER

Firstly you should look x86 system_call. Then you can understand main func. "Hello world" in the first line is set to string value.The second line calculated the length of the variable and then system calls are used to print the message on the screen. If the operation fails, the program jump to "go" and call system_exit with "mov eax ,1". Finally "int 80h" means call kernel