I was trying to make a counter which add from 0.0 to 1, I first implement the counter via fadd, then I have trouble to print floating point number.
Platform: Alpine Linux Aarch64 (3.20.2), GNU Binutils (2.42) (Running from a VM on my M2 Mac)
.global _start
.extern printf
.data
string: .asciz "Hello World! %fn" // Store String
f: .float 1.132 // Store the float 1.132
.text
_start:
loop:
ldr x0, =string // Load String into x0
ldr d1, =f // Load float into d1 (A float reg)
bl printf // Call printf in glibc
b exit // Branch to exit label
exit:
mov x8, #93 // Exit SYSCALL
mov x0, #0 // Exit code
svc 0 // Syscall
build.sh
as main.s -o main.o
ld -lc --dynamic-linker /lib/ld-musl-aarch64.so.1 main.o -o main
Output
Hello World! 0.00000