In 64bit x86 assembly nasm, how can I move a single byte from the register into a memory location defined in section .data?
I understand that this works
global _main
section .data
quotient db 0x0, 0x0, 0x30, 0xa ; 3 digit + newline
remainder db 0x0, 0x0, 0x30, 0xa; 3 digit + newline
section .text
_main:
mov rax, 0x2000004
mov rdi, 1
mov rsi, quotient
mov rdx, 8
syscall ; outputs 0 /newline 0 /newline as expected
exit:
mov rax, 0x2000001
mov rdi, 0
syscall
Also I know you can set a single byte using a byte keyword
mov rbx, quotient ; move location of quotient into memory
mov [rbx], byte 0x31 ; change first byte to ascii '1'
this would output 1 0 /newline 0 /newline as expected
However suppose I want to set it as a register value
mov rbx, quotient ; move location of quotient into memory
mov r8, 0x31 ; set another register to ascii '1'
mov [rbx], r8 ; write the register value into memory
This does output 1 but it seems to overwrite every byte in memory after that so the newlines get removed.
My question is how can I write a single 'byte' from register into the memory location?
