NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Microcontroller Programming » Using assembly on ATmega168 with Linux

September 19, 2009
by tech20
tech20's Avatar

I was wondering how you can use assembly with these microcontrollers in linux. I haven't use assembly before, but would like to learn with the microcontroller since it is more visual to see the results. Any help with tools/tutorials. I don't know how to even load up the assembly to the chip, so please, basics.

September 19, 2009
by mrobbins
(NerdKits Staff)

mrobbins's Avatar

Hi tech20,

We don't have any tutorials currently with assembly being used explicitly, but you will basically want to output a .hex file and use the same avrdude command line as we show how to do in The NerdKits Guide.

I can recommend that you take a look at this page: Using assembly code in-line with C code. I suspect you'd also want the AVR instruction set documentation which shows you what each machine instruction does.

In the past, I have used inline assembly on rare occasions when I need to specify exactly what I want the chip to do. That way, it's easier to link it into existing C code, and also can be compiled with avr-gcc. However, the program "avr-as" is the standalone assembler, and I think you'd have to run "avr-as" to convert your assembly code into machine object code (a .o file), and then would have to use "avr-objcopy" to make a .hex file, and then finally use avrdude for programming the chip.

Also see this thread where some other NerdKits users are using assembly for various things -- they might be able to help you out even more.

Hope that helps get you started!


Post a Reply

Please log in to post a reply.

Did you know that a motor is harder to turn when its terminals are shorted together? Learn more...