20

After getting my Raspberry Pi, I decided that I wanted to learn how to write ARM assembly code. My question is, what do I need to get started? I assume that there is already a compiler installed but I don't know what it is (gcc maybe?). Any help is appreciated!

19

Depends on how much assembler you want to write. If you want to write only small snippets embedded in C code, than gcc is indeed what you are looking for. Examples of how to use the asm directive in C see inline asm reference at: ARM GCC Inline Assembler Cookbook

If on the other hand you want to write more than just small snippets than you'll be better of using a full assembler. This will be available as either as, gas or both (aliased).

And finally you'll need to learn a bit about the ARM instruction set. There is a handy reference at: ARM1176JZF-S Technical Reference Manual.

N.B. Please remember what RPi only support armv6 instructions - so don't try to use anything from armv7

Good luck!! :)

4

I started my adventure with ARM assembly code not too long ago myself and here are my resources:

  • Cambridge University published a very decent set of tutorials here: Baking Pi. It includes a template for your own OS, complete code examples for every tutorial and all instructions on how to build and run your code.
  • Additionally, this hefty book should cover all the bases: ARM System Developer's Guide.
3

Although I am quite comfortable with command line interface, I could not resist the convenience of GUI. A while ago, I discovered that I could use CodeBlocks IDE to develop ARM assembly language programs in a Raspberry Pi. So I wrote a tutorial and appended it to the Raspberry Pi assembly programming tutorial I wrote for the Mazidi ARM Assembly book website:

http://www.microdigitaled.com/ARM/ARM_ASM_books.htm

At the website, click on the link "ARM Assembly Programming Using Raspberry Pi GUI."

Hope this helps.

1

GCC is installed by default. If you're this new to Raspberry Pi I recommend you look at an easier programming language than ARM assembly. There aren't any IDEs for assembly so you'll have to use a text editor and assemble it through terminal. I recommend Gedit for ease of use. Though to get syntax highlighting for assembly I had to go to github, specifically shinyquagsire23's page. It's very pretty. As for help The best resource I've found is "Raspberry Pi Assembly Language: Raspbian Beginners" by Bruce Smith. You can find it on Amazon. He explains assembly in one of the clearest and simplest ways I have found.

1

Learn with runnable examples

I am working on: https://github.com/cirosantilli/arm-assembly-cheat

Features:

  • the exact same assembly can be run on a Linux host with QEMU user mode, so you can try stuff out faster on your host before going native on the Pi
  • covers both ARMv7 and ARMv8
  • good GDB setup out of the box, both on host and native
  • has asserts that show the assembly line number where things failed
  • uses the C standard library for IO, which makes it OS portable in theory, and allows to easily reuse goodies like printf and memcpy

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.