However I'm running into hard-faults, which I *think* I've substantiated shouldn't be occurring. Would anyone with more assembler know-how care to comment on whether what I'm seeing is (a) expected and I'm failing to grasp something fundamental, or (b) what I think it is i.e. a bug worth reporting?
I've tested that passing a value into an assembler function doesn't mangle it;
Code: Select all
@micropython.asm_thumb
def test(r0):
nop()
>>> test(stm.GPIOA)
-1073610752
>>> stm.GPIOA
-1073610752
@micropython.asm_thumb
def test():
movwt(r0, stm.GPIOA)
>>> test()
-1073610752
I've tested that ldr [register, offset] is functionally identical to [register+offset, 0];
Code: Select all
@micropython.asm_thumb
def test():
movwt(r0, stm.GPIOA)
ldr(r0, [r0, stm.GPIO_MODER])
>>> test()
-694157312
@micropython.asm_thumb
def test():
movwt(r0, stm.GPIOA)
add(r0, stm.GPIO_MODER)
ldr(r0, [r0, 0])
>>> test()
-694157312
Because we don't have add(reg,reg) in assembler, and because values like stm.GPIOA and stm.GPIO_MODER don't intersect, I've tested (above) ldr[register, offset] == ldr[register+offset, 0] and also == ldr[register|offset, 0] (hereunder);
Code: Select all
@micropython.asm_thumb
def test():
movwt(r0, stm.GPIOA)
movwt(r1, stm.GPIO_MODER)
orr(r0, r1)
ldr(r0, [r0, 0])
>>> test()
-694157312
So, onto what I was trying to do in the first place, which doesn't work, and I'm assuming is a bug;
Code: Select all
@micropython.asm_thumb
def peek(r0):
ldr(r0, [r0, stm.GPIO_MODER])
>>> peek(stm.GPIOA)
***Hard Fault***
Code: Select all
@micropython.asm_thumb
def peek(r0, r1):
orr(r0, r1)
ldr(r0, [r0, 0])
>>> peek(stm.GPIOA, stm.GPIO_MODER)
***Hard Fault***