I have some errors then linking with ld:
lr3nix.asm:(.text+0x1): relocation truncated to fit: R_X86_64_8 against `.data'
lr3nix.asm:(.text+0x3): relocation truncated to fit: R_X86_64_8 against `.data'
lr3nix.asm:(.text+0x10): relocation truncated to fit: R_X86_64_8 against `.data'
lr3nix.asm:(.text+0x12): relocation truncated to fit: R_X86_64_8 against `.data'
Nasm doesn't show errors.
My version of nasm: 2.09.10
Version of ld: GNU ld (GNU Binutils for Ubuntu) 2.22
I compile: nasm -f elf64 lr3nix.asm
Source code of my prog:
section .data
a: db 43
b: db -6
c: db -20
d: db 47
hex: db '0123456789ABCDEF'
msg: db 'Result: ',0x0
msgL: db $-msg
section .bss
res: resb 1
out_str resb 4
section .text
%define STDOUT 1
%macro write 2
mov rax, 4
mov rbx, STDOUT
mov rcx, %1
mov rdx, %2
int 0x80
%endmacro
global _start
_start:
mov al, a
mov bl, c
or al, bl
not al
mov [res], al
mov al, b
mov bl, d
or al, bl
and [res], al
res2hex:
xor rsi, rsi
xor rax, rax
mov al, [res]
shr rax, 4
mov rsi, rax
add rsi, [hex+rsi]
mov rax, rsi
mov [out_str], al
xor rsi, rsi
xor rax, rax
add rax, 0x0F
mov rsi, rax
add rsi, [hex+rsi]
mov rax, rsi
mov [out_str+1], al
mov byte [out_str+2], 0xA
mov byte [out_str+3], 0x0
print_res:
write msg, msgL
write out_str, 4
quit:
mov rax, 1
mov rbx, 0
int 0x80