Hello All,
I would like to include a function written in assembler into my AVR Studio C project (yes it really does need to be in assembler, honestly, let's not debate this).
void HardwareInterface(unsigned char) __attribute__((naked));
void HardwareInterface(unsigned char DataForStuff)
{ cli(); // disable interrupts until all LEDs updated
asm volatile
(" LDI R18, 0x00 // Useful comment
label:
OUT DDRB, R18 // Useful comment
//Blah blah blah lots of lovely assembler >>>>
OUT PORTC, R18 // Useful comment
");
sei(); // Update complete > re-enable_interrupts
return ;
}
This doesn't work (clearly, as I am posting :P ). I can make it compile by putting every single Mnemonic in a wrapper >
asm volatile (" LDI R18, 0x00");
asm volatile (" LDI R18, 0x00");
asm volatile (" LDI R18, 0x00");
But that seems very inefficient and also how do I add a label?
Can someone please help and give me a good example?
All the Best
Dren