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.
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.
The following changes to PlaydateSDK/C_API/buildsupport/common.mk kind of work, but different x86_64 and arm .s files need to be supplied to make pdc and make device, respectively.
Part of the makefile follows. Basically, switching is being done manually and there is no hardware to test on at this point.
ASMTest/Makefile
# List C source files here
SRC = src/main.c
#SRC = src/main.c src/dummy_sqrt.c
# List ASM source files here
#ASRC = src/fast_sqrt_x86_64.s
ASRC = src/fast_sqrt_arm.s
Having said that, the x86_64 ASM appears to be working properly in the simulator.
// modified Hello World example message
pd->system->formatString(&message, "d=%.3f", fast_sqrt(x*x+y*y));
The following changes to PlaydateSDK/C_API/buildsupport/common.mk allow make to be run without manually modifying the ASM .s file to be used for different targets. Note that the assumption is that the simulator runs X86_64 ASM, and hardware runs ARM7 ASM. There may be a better way of doing this.
EDIT: Note that it is possible to move a modified version of common.mk into the project directory and include that instead of PlaydateSDK/C_API/buildsupport/common.mk.
ASMTest demo source code attached. The d-pad, buttons, and crank can be used to control the distance in different ways. As listed above, the square root is calculated using an assembly routine.
EDIT: New upload that actually builds and runs on hardware! Files modified to use Simulator ASM that runs on Apple Silicon, but the X86_64 .s file is still in the project.
You could probably use arch or uname and provide an environment variable to select the proper assembly file. This would likely be easier done from a cmake file.
I recently summarized ASM Playdate Development in a blog post. It may be easier to follow for anyone who is looking for something in a tutorial format.