A course in ML/AI for creative expression
Charles Martin - The Australian National University
Teaching second-year computing by coding in ARM assembly on real hardware.
Goals:
tl;dr: Can students do it? yes!
.thumb
.syntax unified
.global __reset
.section .vectors
.word __stack
.word __reset
.text
.thumb_func
__reset:
mov r0, #0
loop:
add r0, #1
nop
b loop
.syntax unified
.global main
.type main, %function
main:
nop
ldr r0, =hello
b main
.size main, .-main
.data
hello:
.word 0x424242
Short startup.S
program to load static .data
to RAM and setup interrupt vector
Visual Studio Code
arm-none-eabi
) - gcc
, gdb
, ld
, objcopy
, as
make
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.
use the LEDs to create a light show that changes over time
can use the speaker to create sound
input peripherals not allowed!
Need:
add
, sub
ldr
, str
ble
etcHelps:
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
Need:
bl
, bx lr
ldr=
pseudo-instructionHelps:
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
Lightning intro to operating systems. What’s the connection to ARM?
context switch, threads, scheduling, privilege, supervisor calls, exception model…
Challenge Lab: build a handcrafted context switch, then change between two programs (blinking one LED vs another)
.data
process_table:
.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?
Don’t tell the students “be careful”!
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.
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.”