Here is the piece of code, caused me issues:
mystr:
.string "ABCDEFGH"
.set mystrlen, . - mystr
.text
.globl main
.type main, @function
main:
sub $0x10, %rsp
movq $0x44434241, 0x8(%rsp)
lea 0x8(%rsp), %rcx
movq $4, %rax
movq $1, %rbx
//movq $mystr, %rcx
//movq $mystrlen, %rdx
movq $4, %rdx
int $0x80
movq $1, %rax
movq $0, %rbx
int $0x80
Represented fragment doesn't work, because while 64-bit addressing, registers for syscall arguments should be rdi, rsi, rdx to the 1st, 2nd and 3rd syscall arguments respectively, not rbx, rcx, rdx (as for call in x86-32).
But I'm interested in why do the commented out lines work fine with rbx, rcx, rdx?