Content originally posted in LPCWare by ant on Tue Apr 26 23:34:25 MST 2011
Ok, that explains why putting the data before causes errors, but it doesn't explain the error on the last line. That's ok though, 'cause I got it working with your template, except for a few changes.
According to the LPC111x manual, it is cortex-m0, but you had cortex-m3. Changing it to cortex-m0 caused errors on two instructions, (mov r2, #100 and sub r4, r5). I removed the .syntax unified and then it worked. So here's what I got, that works (or at least seems to work).
Also, I don't understand why it is ".align 2", shouldn't that be just .align or .align 4? Seems odd to me.
Quote:
.cpu cortex-m0
.thumb
.align 2
.global asm_test
.thumb_func
asm_test:
ldr r6, .timer32b0base
ldr r5, [r6, #8] // timer value
mov r2, #100
ldr r1, .timer16b0base
str r2, [r1, #0x18] // Timer16B0 Match Reg 0
ldr r4, [r6, #8] // timer value
sub r4, r5
ldr r1, .rambase
str r4, [r1]
bx lr
.align 2
.timer32b0base: .word 0x40014000 // timer 32b0
.timer16b0base: .word 0x4000C000 // timer 16b0
.rambase: .word 0x10000000
.end