Skip to content

Instantly share code, notes, and snippets.

@postspectacular
Last active September 24, 2015 02:22
Show Gist options
  • Save postspectacular/5f973eb924badd5b57ec to your computer and use it in GitHub Desktop.
Save postspectacular/5f973eb924badd5b57ec to your computer and use it in GitHub Desktop.
ARM ASM label addressing/dereferencing note
.syntax unified
.cpu cortex-m4
.thumb
.thumb_func
foo:
ldr r0, =timer @ load address of label
ldr r1, [r0, #4] @ load word following bar ( => SysTick_VAL => 8 )
ldr r0, [r0] @ deref label addr => SysTick_BASE
ldr r0, [r0, r1] @ => val of [SysTick_BASE + SysTick_VAL]
ldr r0, timer @ load word at label ( => SysTick_Base )
ldr r0, [r0, #4] @ deref addr + 4 (=> val of [SysTick_BASE + SysTick_LOAD])
ldr r0, [r0, SysTick_VAL] @ => val of [SysTick_BASE + SysTick_VAL]
.equ SysTick_Base, 0xE000E100
.equ SysTick_CTRL, 0x00
.equ SysTick_LOAD, 0x04
.equ SysTick_VAL, 0x08
timer:
.word SysTick_Base
.word SysTick_VAL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment