AVR inline assembler incorrectly assembles LD, LDD, ST, STD opcodes
Original Reporter info from Mantis: georghieber
-
Reporter name: Georg Hieber
Original Reporter info from Mantis: georghieber
- Reporter name: Georg Hieber
Description:
the following code snippet in an assembler function
st Z , r24
dec r25
ld r22, Y
compiles to:
# [146] st.Z , r24 st r30,r24 # [147] dec.r25 dec r25 # [148] ld r22, Y ld r22,r28
Instead of passing 'Z' and 'Y' literally into the assembler file, they are resolved to r30 and r28 - which is wrong in this case. The pre-decrement and post-increment versions 'Z+', '-Y' compile correctly.
Also LDD and SDD don't work:
std Z+0 , r24
dec r25
ldd r22, Y+0
results in:
# [146] std.Z+0 , r24 std 0,r24 # [147] dec.r25 dec r25 # [148] ldd r22, Y+0 ldd r22,0
simply omitting the index register and only passing the displacement.
Additional information:
the bug is critical. It prevents accessing the stack frame in an assembler procedure, or iterations through a data structure loading a byte, doing something with it, and storing it back.