在avr-gcc内联汇编中,如何跳转到标签加上运行时确定的偏移量?我想我可以用它来实现类似查找表的东西。
据我所知,可以通过将标签地址加载到 Z 寄存器,添加偏移量,然后使用 ijmp 指令来实现。但我不知道如何加载标签地址。这不起作用:
ldi r30,((label)>>0)&0xFF
ldi r31,((label)>>8)&0xFF
最佳答案
请改用可重定位表达式修饰符。引用binutils documentation :
lo8
This modifier allows you to use bits 0 through 7 of an address expression
as 8 bit relocatable expression.
hi8
This modifier allows you to use bits 7 through 15 of an address expression
as 8 bit relocatable expression. This is useful with, for example, the AVR
`ldi' instruction and `lo8' modifier.
For example
ldi r26, lo8(sym+10)
ldi r27, hi8(sym+10)
pm_lo8
This modifier allows you to use bits 0 through 7 of an address expression
as 8 bit relocatable expression. This modifier useful for addressing data
or code from Flash/Program memory. The using of `pm_lo8' similar to `lo8'.
pm_hi8
This modifier allows you to use bits 8 through 15 of an address expression
as 8 bit relocatable expression. This modifier useful for addressing data
or code from Flash/Program memory.
关于gcc - avr-gcc内联汇编: Jump to label with runtime offset,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25005005/