2

I'm trying to understand a program that I have disassembled. I'm understanding it so far.

However, I do not understand why the program is AND'ing an integer with 0x7F. It also likes to AND an integer with 0xFF. The program is somewhat of a random number generator.

What does this accomplish?

I think AND'ing with 0xFF takes the lower byte (of a register) and discards the rest?

Specifically in MIPS ASM:

## r2 = 0xfd    r3 = 0x10 ##

andi r2,r2,0x00ff       # What? Why?
andi r3,r3,0x007f       # What? Why?
4

1 回答 1

4

与 0x7f 进行“与”运算用于删除最高有效位,因为 0x7f 是 0111 1111 并确保该数字为正数。与 0xff 进行“与”运算则相反。

于 2013-03-13T19:54:11.127 回答