I read books on assembly language, a chapter about instructions. I understand what is doing the instruction mov, but i don't understand how do I check and see a result. I wrote a hello world.
.global _start
.data
some_var:
.long 0x000721
.text
_start:
mov $1, %rax # system call 1 is write
mov $1, %rdi # file handle 1 is stdout
# mov $message, %rsi # address of string to output
mov $0x1, %rsi
mov $2, %rdx # number of bytes
syscall # invoke operating system to do the write
# exit(0)
mov $60, %rax # system call 60 is exit
xor %rdi, %rdi # we want return code 0
syscall # invoke operating system to exit
message:
.ascii "Hello, Universe)\n"
But why it doesn't work. How do I see the value at memory and register?
os: linux (debian). intel 64-bit
You need an address in rsi
, not a value.
That's why it works with
mov $message, %rsi
but not with
mov $0x1, %rsi
If you want to print numbers, you need a routine to convert numbers into ASCII strings first (basically you need to write a simple version of printf
).