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!

Maria Zverina
  • 5,168
  • 5
  • 30
  • 42
ohblahitsme
  • 741
  • 1
  • 7
  • 18
  • Here is another (free) book about ARM assembly: http://yurichev.com/writings/RE_for_beginners-en.pdf –  Oct 05 '13 at 21:11

5 Answers5

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!! :)

techraf
  • 4,319
  • 10
  • 31
  • 42
Maria Zverina
  • 5,168
  • 5
  • 30
  • 42
  • I would just like to update this in place for current (February 2020) readers: the Raspberry Pi 4 Model B uses the ARMv8 instruction set. – God of Biscuits Feb 20 '20 at 17:55
5

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.
Piotr Justyna
  • 151
  • 1
  • 3
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.

schen
  • 31
  • 1
2

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.

Dark Ronin
  • 21
  • 1
2

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