2
votes

I have recently bought an Arduino Uno, which is basically an atMega328 avr processor with all the details such as I/O and connection to the computer taking care of for you.

I have successfully written code using the Arduino IDE and the avr-gcc collection.However, I would like to write pure assembly code for it, and I have hit a dead-end, since there seems to be close to none documentation on that.That is, I would like to write 'pure' assembly, no inline c assembly and the like.I would like instructions on doing so and, if possible, an example program(the assembly output of gcc-avr was not that helpful, being incomprehensible and all ).
In particular:

  • How can one instruct avr-as to put that code in eg the interrupt vectors ?
  • What directives are available?
  • Where do .data and .bss sections go?

Pointing me to appropriate examples is appreciated.

3
Not really an answer, but avr-asm.tripod.com may helpJustin808
@Justin808 Thank you, but this site does not seem to talk about gas-specific syntax ,conventions etc, which is what I ask for, since the avr features are well-documented by Atmel.byrondrossos
github.com/dwelch67/avr_samples, unfortunately it appears my avr samples are not gnu assembler but avra. If you wander around the rest of my repos though you will see many many gas/gcc examples with about as simple a linker script as you can find. the same theme applies to any target, the linker script with the proper addresses for ram or rom and ram, the _start: symbol as your entry point, putting the boot asm code object first on the -ld command line to put it first in the binary, etc. If it doesnt help I can make an gnu as avr sampleold_timer
actually look at github.com/dwelch67/avriss there is a gcc-avr based example. my instruction set simulator may or may not be debugged, dont rely on it, but the example should show you want you are asking for, if you dont want the C code just dont compile and link it just leave the startup file as your only source. or add other assembly sources. with the exception of things forced by the linker script the entry code is the first object on the ld command line (ld puts things in the binary in the command line order)old_timer

3 Answers

3
votes

The best documentation I could find is the avr-gcc assembler tutorial.This explains that:

  • One can use the interrupt vectors using the avr-libc.In order to do it without external libraries, one can reference the source, as Brett Hale suggested.

  • It mentions the avr-specific directives.

It also comes with a simple example.

2
votes

I suggest you look the avr-libc library. Don't let the name mislead you. Most of it's highly optimized AVR assembler, with linker scripts, low level HW access, etc.

0
votes

The Arduino Wiki at http://www.cs.nmsu.edu/~jcook/arduino/index.php gives a way to do just that. It requires modifying and rebuilding the Arduino IDE to allow the assembly code (.s files) to be used.