ARM32 instruction MOV, #imm will use the immed_8r encoding, basically immed_8r we cared is:
xxxxxxxx xxxxxxxx xxxxrrrr bbbbbbbb
Here rrrr is number of bits need do right shift, bbbbbbbb is 8bit immediate. The final immediate using immed_8r encoding is:
- static unsigned ror(unsigned x, unsigned b)
-
{
-
unsigned ret;
-
-
ret = (x >> b) | (( x & ( (1 << b) -1 ) ) << (32 - b) );
-
-
return ret;
-
}
-
-
static unsigned immed_8r(unsigned imm, unsigned sh)
-
{
-
unsigned i;
-
-
for (i = 0; i < sh; i++) {
-
imm = ror(imm, 2); /* we can do 2*15 == 30 ROR totally */
-
}
-
-
return imm;
-
}
阅读(1345) | 评论(0) | 转发(0) |