This is a project I worked on long ago to help students with their course. Click the “Notes” and see the bottom right card to learn more about how to use this fully functionaly Cortex-M0 simulator and assembler written in vanilla Javascript.
.cpu cortex-m0 .thumb .syntax unified .fpu softvfp loadaddr: push {r4,r5,r6,r7,lr} movs r4,#0x44 movs r5,#0x55 movs r6,#0x66 movs r7,#0x77 ldr r0,=xvar pop {r4,r5,r6,r7,pc} .data .align 4 xvar: .word 0x12345678 .space 4 .text .global main main: nop bl loadaddr ldr r1,[r0,#0] adds r2,r1,#5 str r2,[r0,#4] adds r0,r0,#1 // Change r0 to an odd address, so... ldr r2,[r0,#0] // ...this will HardFault.
.cpu cortex-m0 .thumb .syntax unified .fpu softvfp .org 0x08000000 startup: bl main loop: b loop
Register | Value |
---|---|
R0 | |
R1 | |
R2 | |
R3 | |
R4 | |
R5 | |
R6 | |
R7 | |
R8 | |
R9 | |
R10 | |
R11 | |
R12 | |
SP | |
LR | |
PC | |
APSR |