13

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

JRE
  • 67,678
  • 8
  • 104
  • 179
  • 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 – sll Nov 10 '12 at 15:50
  • I would suggest to use 89c51 (8051) controller for assembly language – Photon001 Jun 15 '20 at 23:52

9 Answers9

7

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.

RQDQ
  • 520
  • 3
  • 13
  • Ya I'd prolly want to stick with Not putting it on my own breadboard right now lol Im not that great with circuits. –  Apr 08 '11 at 19:27
  • @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). – RQDQ Apr 08 '11 at 19:29
  • 1
    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. – Chris Stratton Jun 16 '20 at 00:36
  • @ChrisStratton - thanks for your feedback. I've updated my answer to incorporate your feedback. – RQDQ Jun 16 '20 at 23:10
7

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

Dr_ZAP
  • 71
  • 1
  • 1
2

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.

jpc
  • 5,302
  • 1
  • 24
  • 45
2

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.

old_timer
  • 8,203
  • 24
  • 33
2

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

jad
  • 21
  • 1
1

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.

Leon Heller
  • 38,774
  • 2
  • 60
  • 96
  • 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. – Chris Stratton Jun 16 '20 at 00:40
1

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.

blalor
  • 2,544
  • 3
  • 22
  • 24
  • 1
    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 – crasic Apr 09 '11 at 05:22
  • There's no need for an ICSP adapter, the bootloader works fine with any means of program authorship – Chris Stratton Jun 16 '20 at 00:41
1

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!

rascher
  • 953
  • 2
  • 11
  • 15
  • 3
    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. – Chris Stratton Feb 05 '13 at 21:33
1

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.

Mike
  • 2,146
  • 1
  • 14
  • 29