I am new to assembly programming (x86 32bit architecture) and have a question about the following piece of code:
SECTION .data
Msg: db "Hello", 10
Len: equ $-Msg
SECTION .text
global _start
_start:
; Printing Msg to stdout
mov eax, 4
mov ebx, 1
mov ecx, Msg ; Passing the ADDRESS to the beginning of what's stored in Msg
mov edx, Len ; Are we passing the address of Len, or the value of Len?
int 80H
; Terminating
mov eax, 1
mov ebx, 0
int 80H
I was told that mov ecx, Msg instruction moves the address of where the Msg is stored into the ecx register.
What about the next instruction mov edx, Len?
If we move the
Lenvalue to theedxregister, then shouldn't the instruction be written differently, likemov edx, [Len]?If we move the address of
Lenthen why is the system call to print the message so complicated? Why do you need a register to contain an address to the length of the message rather than the actual length value?