Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

What is arm-emu?

arm-emu is a:

  • assembler
  • virtual machine

for a toy arm32 architecture.

I am not aiming for 1 to 1 parity with a real arm computer. This project is just for fun.

Inspiration

This all started when I wanted to learn assembly and found this https://peterhigginson.co.uk/ARMlite/doc.php.

ARMlite simulates a simple computer built around a cut-down version of a 32-bit ARM processor.

ARMlite is a webapp, with a code editor, view into registers/memory status flags input and output and a screen.

I plan for any valid armlite program to be about the same for arm-emu.

arm-emu Installation

arm-emu provides the cli, assembler and the virtual machine.

Binary

Building From Source

Hello World

To write a simple arm-emu program we must first know a couple of things.

arm-emu cli

To assemble a program and run it

$ arm-emu <path-to-file>

arm-emu Assembler

Comments

Nothing special about comments.

;  single line comment
// single line comment

/* multi
 * line
 * comment
*/

Note on nesting comments. You can’t nest multiple multiline comments together.

/* We can
 * // nest comments like this
*/

// or /* like */ this

// [DO NOT DO THIS!]
/* But not like
  /* this */
*/

Case Sensitivity

Instructions and registers can be written upper or lowercase but can’t be mixed.

mov R0, #41
ADD r0, r0, #1

Labels are case sensitive.

Labels

Labels are case sensitive.

Name collisions result in a error.

They are defined like this

loop:
  add r0, r0, #1
  cmp r0, #100
  bne loop
  

Assembly Directives

Assembly directives are instructions for the assembler.

arm-emu virtual machine

arm-emu vm is 32-bit machine.

Registers

All registers are of size 32-bits.

They are 13 general purpose registers. From (r0..r12)

  • SP (stack pointer)
  • LR (link register)
  • PC (program counter)

Status bits

  • N
  • Z
  • C
  • V

Input/Output

Screen