Creative Prediction with Neural Networks

A course in ML/AI for creative expression

Creative Computing on the BBC Microbit with Bare-Metal ARM Assembly

Charles Martin - The Australian National University

Ngunnawal & Ngambri Country


Teaching second-year computing by coding in ARM assembly on real hardware.


  • to build and cement mental models for computer organisation and code execution,
  • have the transformational experience of running code right on the metal with no guard rails!

tl;dr: Can students do it? yes!

BBC micro:bit v2

Bare-metal ARM Assembly - minimal example

    .syntax unified
        .global __reset

    .section .vectors
    .word __stack
    .word __reset

    mov r0, #0
    add r0, #1
    b loop

Build and flash with this .ld file and this Makefile.

COMP2300 template

.syntax unified
.global main

.type main, %function
  ldr r0, =hello

  b main
.size main, .-main

.word 0x424242

Short startup.S program to load static .data to RAM and setup interrupt vector


Context: Computer Organisation and Program Execution

  • COMP2300/COMP6300
  • 2nd year computing course, obligatory for all undergraduate computing majors, equivalent to “intro to computer systems”.
  • Since 2020: >400 students at start of semester, 325 passed in 2022.
  • Lectures and labs available online
  1. Digital Logic, CPU architecture (high level)
  2. Machine instructions, ALU operations
  3. Memory and memory instructions
  4. Conditional execution and control flow
  5. Functions
  6. Toolchains and Compilers
  7. Data structures in ASM
  8. Interrupts, context switches, asynchronism
  9. Networks
  10. Operating Systems
  11. CPU architectures
  12. Revision

Learning Activities

Labs: core of the course starts with mov r0, #1, ends with implementing context switching between two programs (YourNameOS 1.0).

Assignments: two open-ended, creative programming tasks in ARM assembly.

Assignment 1: Lightshow

use the LEDs to create a light show that changes over time

can use the speaker to create sound

input peripherals not allowed!

Lightshow Scaffolding


  • ALU operations: add, sub
  • memory operations: ldr, str
  • conditional branching: ble etc
  • control structions: if/then/while/for in ASM (Blinky)


  • functions
  • shifting operations
  • reading comprehension of the nrf52833 manual

Assignment 2: Digital Pet

must use the LED display to show a digital pet

must use (at least one) data structure in memory to store the “state” of the digital pet

must use interrupts to detect interactions with the microbit’s buttons

can use sound and any peripheral available on the microbit

Digital Pet Scaffolding:


  • functions bl, bx lr
  • memory directives, labels, ldr= pseudo-instruction
  • calling convention
  • interrupts (Buttons and Interrupts)
  • arrays/structs in ASM


  • SysTick and timers
  • high comprehension of the nrf52833 manual
  • patience

IO and Networks

How can computers connect to each other? How can we interpret voltage on a wire?

Interrupts leads to parallel or serial data transmission.

Construct basic UART (RS232/Serial) from first principles and using on-chip peripherals

Serial Output


Serial Experiments Charles

It's a UNIX system! I know this!

Lightning intro to operating systems. What’s the connection to ARM?

context switch, threads, scheduling, privilege, supervisor calls, exception model…

YourOS 1.0

Challenge Lab: build a handcrafted context switch, then change between two programs (blinking one LED vs another)

.word 0 @ index of currently-operating process
.word 0x20008000 @ stack pointer 1
.word 0x20007000 @ stack pointer 2


What can go wrong?

What can go right?

What can go wrong? Surprisingly little!

Don’t tell the students “be careful”!

  • 1-2 instances of students breaking microbit
  • 2 instances of bricking the microbit

Turns out: turning the GPIO on/off as fast as possible (1 cycle loop) messes up the USB connection: saved by special firmware prepared by microbit developers for us.

What can go right?

Assessments students want to do (crazy concept)

“This is the best course I’ve ever taken”

“I thought assembly would be boring, but it was really fun!”

“I feel like I learnt a lot from taking this course.”