Why does this work,
SYS_READ equ 0
SYS_WRITE equ 1
SYS_EXIT equ 60
STDIN equ 0
STDOUT equ 1
section .data
my_char: db 'a'
global _start
section .text
_start:
mov rax, SYS_WRITE
mov rdi, STDOUT
mov rsi, my_char
mov rdx, 1
syscall
mov rax, SYS_EXIT
mov rdi, 0
syscall
But this doesn't?
...
section .text
_start:
mov rax, SYS_WRITE
mov rdi, STDOUT
mov rsi, 'a' ; Replacing my variable with an immediate byte operand
mov rdx, 1
syscall
mov rax, SYS_EXIT
mov rdi, 0
syscall
I would think it's doing the same thing in memory, the first one setting the value of the rsi
register to 'a', and the second one doing the same, only I'm not using a variable.
Within memory, what is different? Is there any way to do something similar to my second example?