mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-06 20:13:40 +00:00
rp2040: fix incorrect inline assembly
The register r0 was used unconditionally. This is a bug: the compiler doesn't know it is clobbered and might consider it alive across the inline assembly expression. The fix is simple. It could probably be optimized, but this should at least fix the bug.
This commit is contained in:
committed by
Ron Evans
parent
cdd267fa10
commit
262291a80a
@@ -149,16 +149,13 @@ func (clk *clock) configure(src, auxsrc, srcFreq, freq uint32) {
|
||||
// Note XOSC_COUNT is not helpful here because XOSC is not
|
||||
// necessarily running, nor is timer... so, 3 cycles per loop:
|
||||
delayCyc := configuredFreq[clkSys]/configuredFreq[clk.cix] + 1
|
||||
arm.AsmFull(
|
||||
`
|
||||
ldr r0, {cyc}
|
||||
1:
|
||||
subs r0, #1
|
||||
bne 1b
|
||||
`,
|
||||
map[string]interface{}{
|
||||
"cyc": &delayCyc,
|
||||
})
|
||||
for delayCyc != 0 {
|
||||
// This could be done more efficiently but TinyGo inline
|
||||
// assembly is not yet capable enough to express that. In the
|
||||
// meantime, this forces at least 3 cycles per loop.
|
||||
delayCyc--
|
||||
arm.Asm("nop\nnop\nnop")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user