I tried to make some simple assembly code to print out a number with the assembly. I try to it with a printf function call. Then I run the code I get no output and when I debug it with gdb
I get a message that says:
__printf (format=0x601040 "Result: %d") at printf.c:28
28 printf.c: No such file or directory.
I compile it with:
gcc -g -c print.s -o file.o
And then linked it with:
gcc file.o -o file
When I searched on this problem I found that I should test with
gcc file.o -o file -lc /lib64/ld-linux-x86-64.so.2
But the result was the same.
My code
.data
OUT: .asciz "Result: %d" #The output string
.text
.global main
main:
jmp print
print:
mov $OUT, %rdi # Our preperation string
mov $5, %rsi # Value to be printed
xor %rax, %rax # zero out
call printf # call the function
#TODO: Jump back
exit:
mov $60, %rax # Call the exit syscall
mov $0, %rdi # error code 0
syscall # Interupt kernel and make the syscall