Assembler library

Hi you all, I have a rather humble question: a friend of mine ;) has a good and superfast routine written in assembler for Atmel168, and he wants to use it on Arduino, compiling it as a library. Now he as two files: the header file (superlibrary.h) and the assembler file (superlibrary.S). Being keen, he toss both files within hardware/libraries/Superlibrary and fires up Arduino. Rather surprisingly, no compilation occours and no messages are printed on console, even if the avr-gcc is expected to drink .S files as well as .c files. I told my friend that probably the somewhere there's a Makefile missing a .S rule... but is there someone having a better and more detailed explanation? or perhaps a solution? Thanks a lot, Paolo

Jeez... no one replying. Perhaps this is the wrong forum section?

Hi Paolo,

I doubt many here are writing anything for the arduino in assembler. The few cases where assembler code is faster than optimized C code, the assembler has been embedded in a C or C++ file using the asm directive. That is one way to get the assembler code recognized by the arduino build process.

What does the routine do?

Mem, thanks for your reply. The routine does the fast Fourier transform of an array of data. The fact is that it is not a product of mine, and I'm not so fluent in reading and understanding assembler. So I would like to use it as is, but it's kinda long (~600 lines) to be included with the asm directive. Of course I could write a new routine by my own, but I'm used to be lazy, you know, and moreover looks like that routine (named avrfft) scores quite good in terms of efficiency. Thanks again, -P.

Perhaps something in these links will help:

I'm actually interested in this issue due to the use of assembler in my Arduino and AVRUSB integration.

I think the short answer is that the way the IDE calls the avrgcc compiler doesn't include .S files automatically. I suspect inline asm directives might be the easiest approach (I don't think I can use them though as the code I use also "includes" more asm files) although another option would be to write a patch for the IDE. :-)

What I ended up doing is compiling the .S files separately and then putting the .o files generated in the library directory and they did get picked up.


Thanks, follower. In fact I was suspecting something like that.
I’ll try to compile it by hand…

I am using .S assembler files in my core. follower is right, you have to modify you IDE.

A first step is to find this line in

if (files_.endsWith(".c") || files*.endsWith(".cpp"))_
and replace it with this line:
if (files.endsWith(".S") || files_.endsWith(".c") || files.endsWith(".cpp"))*
and then you have to modify the and get the .S files into the build process.
I have a modified Arduino IDE that can compile the assembler files, I will try to create a patch if you are still interested._

I will try to create a patch if you are still interested.

That would be helpful. :-)


You can find the “LumiNet patch” in this thread:

this patch should work with all Arduino boards and includes the “assembler patch”. Tell me if this is working for you or if I need to create an isolated “assembler patch”.

Any body add fft library in Arduino project?