Metal ARM x00 - Setup and Hello World (Lab Notes)

The purpose of Project 0 is to get my own, handwritten machine code running on my practically unused EK-TM4C123GXL board.

Goals

Work Completed

The final program is:

; Vector table should be at 0x0 on reset/power on

; vector table ------------------------------------------
; 0x00 - contains address of initial stack pointer: 0x2000.8000
00 80 00 20

; 0x04 - contains address of reset handler: 0x0000.0008 | 1 (thumb mode set)
09 00 00 00
; -------------------------------------------------------


; Reset handler - Continuously increments R0 ------------------------------------------
; 0x08 - MOV R0 0x01: 0b00100000.00000001 -> 0x2001
01 20 

; loop while incrementing R0
; 0x0A - ADD R0 0x01: 0b00110000.00000001 -> 0x3001
01 30

; branch back to the add
; 0x0C - B to 0x0A (-6 offset in bytes, -3 in halfwords): 0b11100111.11111101 -> 0xE7FD
FD E7
; -------------------------------------------------------------------------------------

Commands Used

> telnet localhost 4444
> flash write_image erase ./program.bin 0x00000000 bin
> arm-none-eabi-gdb
(gdb) target extended-remote :3333
Remote debugging using :3333
# ...
(gdb) monitor reset halt
[tm4c123gh6pm.cpu] halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x00000008 msp: 0x20008000
(gdb) stepi
halted: PC: 0x0000000a
(gdb) info registers
r0             0x1                 1
r1             0x0                 0
# ...
pc             0xa                 0xa
# ...

(gdb) stepi
halted: PC: 0x0000000c
(gdb) info registers
r0             0x2                 2
r1             0x0                 0
# ...
pc             0xc                 0xc
# ...

Next steps