How do I add an assembly file to a project?

I want to experiment with ARM assembly so I’m trying to add an assembly file to my project. I’ve tried naming it both asmTest.s and asmTest.S and tried adding it to CPP_SOURCES, C_SOURCES, and ASM_SOURCES in the Makefile. The first two give me “No rule to make target” and the last gives me errors from trying to include a few hundred .h files.

I can see some allowance for assembly files in libdaisy/Makefile but I can’t figure out to make it work. Any tips?

I think I found the problem. In libdaisy/core/Makefile I changed:

$(AS) -c $(CFLAGS) $< -o $@

to:

$(AS) -c $(ASFLAGS) $< -o $@

and added my asmTest.s file to ASM_SOURCES in my project’s Makefile. My little test is working fine now. My test is to use the assembly to set the blue value in the SimpleLED example project.

Here’s the cpp source:

#include "daisy_pod.h"

using namespace daisy;

DaisyPod hw;
Parameter p_knob1, p_knob2;

extern "C" float asmTest();

int main(void)
{
	hw.Init();
	float r = 0, g = 0, b = 0;
	p_knob1.Init(hw.knob1, 0, 1, Parameter::LINEAR);
	p_knob2.Init(hw.knob2, 0, 1, Parameter::LINEAR);

	hw.StartAdc();

	while (1)
	{
		r = p_knob1.Process();
		g = p_knob2.Process();
		b = asmTest();

		hw.led1.Set(r, g, b);

		hw.UpdateLeds();
	}

and here’s the assembly source:

        .global asmTest

asmTest:
        vmov    s0, #1
        bx      lr

I guess I’ll make a pull request in the libdaisy project.

2 Likes