Say I have the following file.
.syntax unified .set ALIGNMENT, 4 .text .align ALIGNMENT .global fast_sqrt fast_sqrt: vsqrt.f32 s0, s0 bx lr
How do I assemble and link it into a project? The Makefile has a place for "user asm files", but it does not appear to be pulling the file in.
EDIT: The header follows so the routine can be called from C. Note that the above ASM routine has not been tested in another environment so it may be broken.
#ifndef FAST_SQRT_H #define FAST_SQRT_H extern float fast_sqrt(float); #endif // FAST_SQRT_H
EDIT 2: The tested X86_64 version follows. I never figured out how to conditionally include ASM files based on the target platform, so any insight on that front is appreciated.
.intel_syntax .set ALIGNMENT, 16 .text .global _fast_sqrt _fast_sqrt: sqrtss xmm0, xmm0 ret
EDIT 3: 64-bit ARM ASM version, tested in the simulator running on Apple Silicon.
.set ALIGNMENT, 8 .text .align ALIGNMENT .global _fast_sqrt _fast_sqrt: fsqrt s0, s0 ret
EDIT 4: Note that the Cortex M7 only supports Thumb2 instructions.