13
\$\begingroup\$

For my venture into microprocessing, I decided to go with Atmel AVR due to the vast resources available. The Arduino seems to have a lot as well, not to mention their starter kits seem more "at my level."

The problem is I want to learn it in assembly first, and then go to C/C++ or whatever Arduino uses, but I've heard Arduino won't take AVR assembly. Is this true? Is there any way around that?

Edit: I would go with the ATMEL STK500, but for a first timer it looks VERY complicated. Is there any reason why I can't just get an 8 bit AVR and put it on a breadboard and experiment that way? (I guess I'd have to figure out how to interface them as such.)

Edit2: This is what I was thinking

http://www.adafruit.com/index.php?main_page=product_info&cPath=17&products_id=193

\$\endgroup\$
  • \$\begingroup\$ How it is going? So which solution have you considered? I bought Arduino Uo and looking for a way to develop in assembler as well \$\endgroup\$ – sll Nov 10 '12 at 15:50
  • \$\begingroup\$ I would suggest to use 89c51 (8051) controller for assembly language \$\endgroup\$ – Photon001 Jun 15 at 23:52
6
\$\begingroup\$

The Arduino boards can be programmed in assembly. All you need is an ICSP Cable (In Circuit Serial Programmer) and the AVR toolchain (free from ATMEL) to write to the board. You then get the advantage of on board debugging.

As you suggested, you can just slap an ATMEL chip on a breadboard and go to town.

The kit you referenced looks like a great starting point. You can take the chip right off the board and stick it on your own breadboard (as long as it has correctly regulated power and you account for the clock).

EDIT: Apparently you don't need an ICSP to load assembly programs. See comment below for details.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Ya I'd prolly want to stick with Not putting it on my own breadboard right now lol Im not that great with circuits. \$\endgroup\$ – user3073 Apr 8 '11 at 19:27
  • \$\begingroup\$ @Sauron - hah - either way is good. Whatever gets you hooked! The good thing is the individual chips are pretty cheap (a couple of bucks or so). \$\endgroup\$ – RQDQ Apr 8 '11 at 19:29
  • \$\begingroup\$ This answer is substantially misleading: NO ISP IS NEEDED. The bootloader used by Arduino predates the Arduino project and has no idea whatsoever if the file being loaded originated with a compiler or an assembler. Please don't perpetuate the misconception that the bootloader in an Arduino has anything to do with the method of writing programs to target the hardware; it is simply a convenient mechanism to get code of any origin into the chip. \$\endgroup\$ – Chris Stratton Jun 16 at 0:36
  • \$\begingroup\$ @ChrisStratton - thanks for your feedback. I've updated my answer to incorporate your feedback. \$\endgroup\$ – RQDQ Jun 16 at 23:10
6
\$\begingroup\$

The Arduino IDE can be "fixed" to accommodate Assembly code. Here is the wiki: http://www.cs.nmsu.edu/~jcook/arduino/index.php?n=Notes.AssemblyMods

| improve this answer | |
\$\endgroup\$
  • 1
    \$\begingroup\$ the url seems to be broken \$\endgroup\$ – Foad Oct 22 '19 at 13:01
2
\$\begingroup\$

As far as I know there should be nothing specific about the Arduino bootloader that could prevent you from using assembly instead of C. The Arduino IDE may make it difficult to upload you own .hex files but it looks like the Arduino bootloader is STK500 compatible so you should be able to use it with avrdude.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Yes, actually, the Arduino IDE itself uses avrdude to perform the upload. \$\endgroup\$ – Chris Stratton Feb 5 '13 at 21:32
2
\$\begingroup\$

Not difficult at all.

http://www.dwelch.com/arduino/

You need to look at I think ser.c on my page to pick which card. some use different serial port speeds by default, and different reset schemes to get into the programming mode. If you look at the arduino firmware you find that hardly any of the avr programming commands are really supported. Dont really need them anyway.

| improve this answer | |
\$\endgroup\$
2
\$\begingroup\$

the arduino can be programmed with assembly using GCC-AVR Inline Assembler check this link for GCC-AVR Inline Assembler Cookbook

http://web.stanford.edu/class/ee281/projects/aut2002/yingzong-mouse/media/GCCAVRInlAsmCB.pdf

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

Arduino boards (Uno and Duemilanove at any rate) have a standard AVR programming connector which is supported by Atmel programmers and debuggers via AVR Studio. Studio supports assembler and C. A suitable programmer is the AVRISP MkII, and the AVR Dragon offers both programming and debugging. I'd get the latter, it's more expensive at $50, but the debugging facility is invaluable. You can also use those tools with a standard AVR chip (not Arduino) plugged into a breadboard or a PCB.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ While it's true that they have an ICSP header, there's no need to use it. The bootloader works equally well with any means of program authorship, and in fact even the Arduino IDE relies on the pre-existing command-line utility program avrdude to operate the bootloader. \$\endgroup\$ – Chris Stratton Jun 16 at 0:40
1
\$\begingroup\$

The Arduino is comprised of two pieces: the hardware and the IDE. The IDE mainly (if not completely) restricts you to C and C++ (with some syntactical sugar the developers have thrown in to make it a little more like Processing/Java). There's a chance that the IDE will recognize .s or .S files in the same directory as a standard sketch (.pde), but I wouldn't hang my hat on that.

There's nothing special about the hardware. It's a nice, friendly board with lots of nifty features that µC neophytes will appreciate, but if you want to just program the AVR via the ISP header, you can do that, too. You'll need something like the Atmel AVRISP mkII, or any other programmer that works with the 2x3 row connector on the Arduino board. Look for ones that are compatible with the avrdude program that you'll use to upload your applications. Stay away from Adafruit's USBtinyISP; I've had horrible luck with it and ended up buying the Atmel one I linked for less than $40 from Mouser.

| improve this answer | |
\$\endgroup\$
  • 1
    \$\begingroup\$ Strange, I've had nothing but good experiences with the Atmel IDE and the usbtiny, Also buspirate will double as an isp for many different platforms, great little tool \$\endgroup\$ – crasic Apr 9 '11 at 5:22
  • \$\begingroup\$ There's no need for an ICSP adapter, the bootloader works fine with any means of program authorship \$\endgroup\$ – Chris Stratton Jun 16 at 0:41
1
\$\begingroup\$

The Aruduino can absolutely be programmed in assembly. And you don't even need an ICSP cable to do it!

Okay, in fairness, this is not the same as programming it in pure assembly from the ground up.

But you can inline assembly in C. Which means that you can load code onto your Arduino that has inline assembly, which will then execute. Consider the TVOut library, which allows the Arduino to output NTSC/PAL to a TV.

That library is very time-sensitive (since it is outputting to a TV, each scanline has to be written at the right time.) So it uses inline assembly to speed up the process. Looking at line 89 of this file from the library, the author is using some of the assembly macros that he wrote.

Now. I suspect that he did not write them using the default Arduino IDE. But this library calls upon his inline asm code, which anyone can import, compile, and execute via their interface.

Best of luck!

| improve this answer | |
\$\endgroup\$
  • 3
    \$\begingroup\$ Actually, you can do assembly source files too, you just have to skip the Arduino IDE and interact with the back end tools such as avr-gcc (or whatever you use as an assembler) and avrdude directly. \$\endgroup\$ – Chris Stratton Feb 5 '13 at 21:33
1
\$\begingroup\$

I use Linux as my host platform, but I think these tools are also available for Windows varieties.

I use "avra" for the assembly to hex code converter (compiler)

Then I program the chip using a USBTiny programmer and the "avrdude" programming tool.

I believe both of these tools are open source.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy