2

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.

asked May 10, 2012 at 10:12
4
  • Not really an answer, but avr-asm.tripod.com may help Commented May 10, 2012 at 10:16
  • @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. Commented May 10, 2012 at 10:29
  • 1
    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 sample Commented May 10, 2012 at 13:43
  • 1
    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) Commented May 10, 2012 at 13:46

3 Answers 3

3

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.

answered May 10, 2012 at 12:05

Comments

2

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

answered May 10, 2012 at 10:38

1 Comment

404 - Not Found
0

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.

answered Jan 12, 2013 at 0:33

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.