I am trying to execute an assembly program which calculates the roots of a quadratic equation.
nasm -f elf64 assgn10.asm
gcc -o assgn10 assgn10.o
/usr/bin/ld: assgn10.o: relocation R_X86_64_32S against `.bss' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
I have used 2 macros.
%macro myprintf 1
mov rdi,formatpf
sub rsp,8
movsd xmm0,[%1]
mov rax,1
call printf
add rsp,8
syscall
%endmacro
%macro myscanf 1
mov rdi,formatsf
mov rax,0
mov rsi,qword[%1]
call scanf
;syscall
%endmacro
This is how my .bss section looks.
section .bss
a resq 1
b resq 1
c resq 1
b2 resq 1 ; b square
fac resq 1 ; 4ac
delta resq 1 ; delta value
rdelta resq 1 ; root of delta
r1 resq 1 ;root 1
r2 resq 1 ;root 2
ta resq 1 ; 2a
realn resq 1
img1 resq 1
img2 resq 1
The same program worked without fuss on a different PC.