Assemblers

 

Assemblers

In order to produce a hex output file that can run on a microcontroller, your assembly source code must be passed through an assembler specific to the chip's architecture.

Unlike compilers which may produce different outputs when given the same source code, assemblers essentially perform a one to one translation of instruction mnemonics and operands into machine code. All assemblers should produce the same output when given the same source code. The main difference between assemblers is their support for various directives and the development environments they offer.

There are a number of free AVR assemblers available, the details of which are outlined below.

AVRASM2 (Atmel Studio)

AVRASM2 is the official Atmel assembler. AVRASM2 comes with Atmel Studio and will be used automatically when building a solution in the Studio. It has the most support and flexibility of any of the AVR assemblers.

If your biggest problem with AVRASM2 is being stuck in the Atmel development environment, I have good news. AVRASM2 can be called from the command line, meaning you can use whatever code editor and makefile you like.

However, one of the most useful features of Atmel Studio is its integrated simulation and debug tools. Programs can be stepped through line by line and the contents of registers, SRAM, and EEPROM can be directly inspected. Particularly in assembly, this is an invaluable resource and will make your life significantly easier when learning to code.


The biggest drawback to Atmel Studio is that it is only available on Windows, although it is possible to run it using Wine on Linux and Mac.

If you are developing on Windows this is probably your best option, even if you choose to use it without the Atmel Studio IDE. However, if you are on Linux or Mac, you may want to consider one of the below alternatives.

AVRA

AVRA is an open source assembler that shares much of the same syntax as AVRASM2. However, AVRA is easily available on Linux and Mac (although surprisingly a bit trickier on Windows). AVRA provides the ability to assemble files from the command line by simply typing

$ avra filename.asm

If you need more information about the command line options offered by AVRA a simple guide can be found here.

Documentation for AVRA can be found on at here and AVRA can be downloaded from the sourceforge link here.


GAVRASM

GAVRASM is another open source assembler available on multiple platforms.


AVR-AS

AVR-AS is a GNU assembler that comes with the WinAVR toolchain. It is also available on Mac OS X in the CrossPack package. AVR-AS is excellent for writing inline assembly code in C code but I would not recommend it as a standalone assembler. AVR-AS cannot be used directly, programs must be passed through avr-gcc first. The examples presented in the following sections will not work with AVR-AS.

Post a Comment

Post a Comment (0)

Previous Post Next Post