问题
This might seem like a stupid question, but I cant really tell what I'm missing
On ARM 7:
I have a 8 digit number in register 0, say
10110111
I want to 'loop' through this and do something with the current bit until the 8 bits are up, but I'm having alot of trouble with this simple issue..
My logic is:
- get MSB / LSB of number in r0
- shift it to r1
- lsl / lsr r0
But from this logic, I dont know how you would get the MSB / LSB. Could anyone help me out? Or is there a better way of looping through this?
Thank you!
回答1:
Check out the rbit and clz instructions. These allow you to compute the MSB and LSB index.
回答2:
I'm having a hard time understanding your issue. But if you shift with flags LSLS you can read the carrybit and it from there.
回答3:
I've got a workaround to this issue, but I'm not sure it's the best method.
Solution:
Use a 2nd register with value 1, with every iteration, AND (r0,r1) thats your bit. Then just LSL r1, and continue.
eg
mov r0, #0b10101010 @original
mov r1, #1
loop:
and r2,r0,r1 @this is your bit
lsl r1
b loop
来源:https://stackoverflow.com/questions/44069659/get-msb-lsb-in-register