Code:
.text
.global _start
_start:
push $0x0a # Higher value of rsp
push $'D' # |
push $'L' # |
push $'R' # |
push $'O' # |
push $'W' # | decreasing value of rsp
push $0x20 # |
push $'O' # |
push $'L' # |
push $'L' # |
push $'E' # |
push $'H' # V
mov %rsp, %rcx # rcx points to address in rsp
mov $96, %rdx # 12 * 8 bytes, each push is 8 bytes
mov $4, %rax # sys_write
mov $1, %rbx # stdout
int $0x80 # interrupt
exit:
mov $1, %rax
mov $0, %rbx
int $0x80
In the above code, rsp
will point ahead of character 'H'. By having rcx
point to that address, I tried printing 96 bytes
from that location.
This means, I tried to treat the entire stack as a string of 96 bytes
, starting at rsp
.
I assumed that sys_write
increases the address in rcx
to traverse the bytes of a string. If that is the case, this method should print something.
Nah, nothing got printed. Not even garbage. Some 0
chars might've been printed, but I won't know that. Why did this not work?