Reputation: 11
I am fairly new to Arduino, but not to programming. I recently bought an Arduino Uno, and despite initially learning that it could only be programmed in c,I have wanted to see if I could program it in assembly language. If anyone would be able to show me how I can on Mac osx or recommend any tutorials for learning this, it would be greatly appreciated. Also if this question is redundant,I am sorry, but please refer me to the answer that answers my question.
Upvotes: 0
Views: 4545
Reputation: 2827
Several options.
You may be able to get the following windows to run under MAC.
And for any OS
The later actually using the Arduino's IDE to have assembly directly along side the C++, as it is using GCC, has the significant advantage that you can continue to use the Arduino Boot loader.
You can grep(file search) through the .\arduino-1.5.5\hardware\arduino. directories searching for "asm" looking plenty of examples
Example: 1
asm("nop");//50ns on 20Mhz, 62.5ns on 16Mhz
Example: 2
__asm__ __volatile__ \
( \
"movw r0, %3\n\t" \
"sts %0, %1\n\t" \
"spm\n\t" \
"clr r1\n\t" \
: \
: "i" (_SFR_MEM_ADDR(__SPM_REG)), \
"r" ((uint8_t)__BOOT_PAGE_FILL), \
"z" ((uint16_t)address), \
"r" ((uint16_t)data) \
: "r0" \
);
Example 3:
asm volatile ( \
"clr r26 \n\t" \
"mul %A1, %B2 \n\t" \
"movw %A0, r0 \n\t" \
"mul %A1, %A2 \n\t" \
"add %A0, r1 \n\t" \
"adc %B0, r26 \n\t" \
"lsr r0 \n\t" \
"adc %A0, r26 \n\t" \
"adc %B0, r26 \n\t" \
"clr r1 \n\t" \
: \
"=&r" (intRes) \
: \
"d" (charIn1), \
"d" (intIn2) \
: \
"r26" \
)
http://www.nongnu.org/avr-libc/user-manual/inline_asm.html
Upvotes: 4
Reputation: 3070
Here is a blog post that may answer your question: http://forum.arduino.cc/index.php/topic,37130.0.html
But as the RuggedCircuits says: "Final word of advice: it's really not worth it"
Hope it helps!
Upvotes: 0