andi vs. addi instruction in MIPS with negative immediate constant

后端 未结 3 1145
没有蜡笔的小新
没有蜡笔的小新 2021-01-15 23:22

Assume $t2=0x55555550, then executing the following instruction:

andi $t2, $t2, -1

$t2 becomes

3条回答
  •  悲&欢浪女
    2021-01-15 23:54

    MIPS Reference Sheet

    From this reference sheet, for the andi instruction, it clearly says that sign extension done on the immediate is zero extension. It is similar for the ori instruction as well. For the sequence of operations you are using, this is exactly what MIPS is supposed to do. For doing what you intend to do, you should store 0xFFFFFFFF in some other register, and use "and" operation.

提交回复
热议问题