I found an example and was editing it for gas.
extern printf
.global _start
.data
hello:
db "Hello", 0xa, 0
.text
_start:
mov %rdi, hello
mov %rax, 0
call printf
mov %rax, 0
ret
But it doesn't work. What's wrong? What does this mean:
hello:
db "Hello", 0xa, 0
I understand what it scope of memory, but I don't understand this string
db "Hello", 0xa, 0
And here
_start:
mov %rdi, hello
mov %rax, 0
call printf
mov %rax, 0
ret
os: linux (debian). intel 64-bit
It's is the null-byte-terminattor. Well-know as C-string.Such byte at end-of-string say where the string ends. For example,you pass the pointer to your string to call a routine,the routine will understand that the area of such string on memory is from begging a[0]
(in C terminology) until a[x] == 0
is seen.