向左移动 3 个不同大小的寄存器
Moving 3 different sizes of registers to the left
有没有一种简单的通用方法可以将 3 个寄存器移动为
- 0000 0001
- 0000 0011
- 0000 0111
将更改为
- 1000 0000
- 1100 0000
- 1110 0000
我希望它是通用的,而不是每个子程序都是独立的。
我的架构是:ATmega8535 - 16 bits
.
我想到的是:
changeOrientation: swap r0 //move right nibble to the right e.g. from 0000 0001 to 0001 0000
com r0 //change all 0 to 1 and 1 to 0 so e.g. from 0001 0000 to 1110 0000
andi r0, F0 //keep only left nibble so e.g. from 1111 1110 to 1111 0000
然后我卡住了。我现在想不出任何帮助和意见,我将不胜感激。谢谢!
如果真的只有这3种情况:
loop1: ror r0
brcs loop1
这将向右循环直到进位标志为 0,这意味着最后一个 1 已移入。
有没有一种简单的通用方法可以将 3 个寄存器移动为
- 0000 0001
- 0000 0011
- 0000 0111
将更改为
- 1000 0000
- 1100 0000
- 1110 0000
我希望它是通用的,而不是每个子程序都是独立的。
我的架构是:ATmega8535 - 16 bits
.
我想到的是:
changeOrientation: swap r0 //move right nibble to the right e.g. from 0000 0001 to 0001 0000
com r0 //change all 0 to 1 and 1 to 0 so e.g. from 0001 0000 to 1110 0000
andi r0, F0 //keep only left nibble so e.g. from 1111 1110 to 1111 0000
然后我卡住了。我现在想不出任何帮助和意见,我将不胜感激。谢谢!
如果真的只有这3种情况:
loop1: ror r0
brcs loop1
这将向右循环直到进位标志为 0,这意味着最后一个 1 已移入。