I have this unfinished assignment where I need to convert a negative float read from the keyboard without scanf and calculate its abs.
extern printf
section .data
numar dq 0.0
formatare db "%f"
section .bss
buffer resb 1
zecimi resb 8
negativ resb 1
section .text
global _start
_start:
mov eax, 10
jmp loop
loop:
mov rax, 0
mov rdi, 0
mov rsi, buffer
mov rdx, 1
syscall
cmp byte [buffer], 'A'
je end_loop
cmp byte [buffer], '-'
je set_negativ
mov rdx, qword [numar]
mul rdx
sub byte [buffer], '0'
add rdx, buffer
mov qword [numar], rdx
jmp loop
end_loop:
movsd xmm0, qword [numar]
mov rdi, formatare
mov eax, 1
call printf
mov rax, 1
mov rdi, 0
syscall
set_negativ:
mov byte [negativ], 1
jmp loop
;modul:
; fldl [numar]
; fabs
; fstpl [numar]
I wanted to compile it and print the number to at least check if the reading part works.
I ran nasm -f elf64 program.asm
and ld -m elf_x86_64 -lc program.o
with no errors, creating a 14kb ish a.out
file. The file is visible in ls
, it is visible in my file explorer, but running it does this:
$ ./a.out
bash: ./a.out: No such file or directory
The output of file
is this:
$ file a.out
a.out: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib/ld64.so.1, not stripped
I did give it permissions to execute with sudo chmod +x *
just to be safe and it still does not work. I am probably missing out something obvious but I could not find anything similar on the internet.
I expected to be able to run the program and see whether the code I wrote is valid or not so I could move on with the solution.