C:\Program\Arduino/DivisionBenchmark.ino:48: undefined reference to `align32'
I have been staring myself blind on this for hours now. Can anybody spot what i am missing? As i can see both projects have a identical structure, one works, the other doesn't
I didn't want to use a library structure and messing around with the standard inline asm code wasn't working as I wanted. I didn't find anyone had documented this was possible, but it works perfectly for what I do - maybe it can assist you as well.
is it actually compiling the assembler file in the first place? (ie: verbose on with compilation)
it could be that it finds the file with the extension .S (uppercase) but not the one with .s (lowercase).
the error message says "yes, we know the function exists... but going through all the files we compiled, we cannot find it"
Yep you need uppercase S, and a good reason for using an S file it that the ASM code is more readable if there is a lot of it, not that many people have a need for a lot of ASM code these days.
There IS one area where assembler code is needed in the arduino and that is division.
From one of my programs benchmarking 16 bit division by a constant (13 in this case) all numerators from 1 to 65535:
compiler generated division: 895 us
assembler shift/multiply with pre computed constants 263us
shift multiply in C with pre-computed constants: 384us
on arduino (specifically 8bit Atmel CPU's) - the only way to really get speed is to use assembly.
the issue is that in C, all int's are upcast to 16bit (as thats the minimum size of an int) so anything with bitwise operations is expensive. i rewrote my BigInt code for RSA 2048 - the original speed was 65 seconds, after removing the C and replacing with assembler - it was 32 seconds. assembler is definitely a must for some projects, especially when gcc cannot optimise C code sufficiently.
you can do some amazing stuff at such a low level, reminds me of programming z80 and 8502 CPU's back in the day programmers are expecting so much RAM and power and expect to run over-bloated, clunky apps.
I certainly miss ASM, when I started that's pretty much all their was and I did many commercial applications in Z8/80/8000 and 65/68xx assembly language and just 2k of EPROM in some cases.
I remember doing things like tokenising strings to save space so
"Open the gate"
"Close the gate"
Would be
"Open",1,2
"Close",1,3
where the 1, 2 and 3 indexed into a table of common words and the spaces were implied.
And no bytes or ints for flags, they where all packed into bits. Ahhh those where the days
You guys are right in that it is faster, but I think few people actually need that, although I did get close recently when I was going to do some networking stuff and needed to detect a bit clash the "instant" it happened.