After storing the results of cpuid
in the unallocated memory spaces buff
and numb
, I would like to append a newline
character to each of them. So, I made the unallocated spaces 1 byte longer than necessary.
The whole code is:
section .bss
buff resb 13
numb resb 5
section .text
global _start
_start:
mov eax, 0
cpuid
mov dword [numb], eax
mov dword [buff+0], ebx
mov dword [buff+4], edx
mov dword [buff+8], ecx
mov byte [numb+4], newl
mov byte [buff+12], newl
mov rax, 1
mov rdi, 1
mov rsi, buff
mov rdx, 13
syscall
mov rax, 1
mov rdi, 1
mov rsi, numb
mov rdx, 5
syscall
mov rax, 60
mov rdi, 0
syscall
section .data:
newl: db 0x0A
My attempt to append a newline follows the same syntax used in the previous lines:
mov byte [numb+4], newl
mov byte [buff+12], newl
But the linker generates this error:
$ nasm -f elf64 test_cpuid.s
$ ld -o test_cpuid test_cpuid.o
test_cpuid.o: in function `_start':
test_cpuid.s:(.text+0x2a): relocation truncated to fit: R_X86_64_8 against `.data:'
test_cpuid.s:(.text+0x32): relocation truncated to fit: R_X86_64_8 against `.data:'
How to fix this? Maybe I used a wrong syntax?