Reputation: 11
There is a question that I can't completely understand because of various answers I have saw , this is the instructions set :
lui $1,0xffffff00
ori $12,$1,0x0000ffff
sra $10,$12,0x00000010
and $8,$12,$10
The question is if you change the Ori instruction to addi , what will be the value of $8 ?
Upvotes: 0
Views: 281
Reputation: 26656
The problem is that there are many MIPS assemblers, and that the assemblers vary, so you have to know which one you're working with to understand what machine code you're actually getting (or if it will even accept that input).
Then from the machine code, we can go strictly by the MIPS specification, and know exactly what a code sequence will do.
However, the main difference on MIPS for addi
vs. ori
— beyond the "add" vs. "or" part — is that though these are both I-Type instructions having 16-bit immediate, addi
will employ sign extension to bring the 16-bit immediate to 32 bits for the addition, while ori
will apply zero extension to bring the 16-bit immediate to 32 bits for the logical or operation.
Otherwise, since the low bits in $1
are zeros anyway, the actual add vs. or doesn't make a difference: add vs. or are the same if there's no carry, and when adding to zero there's no carry.
Upvotes: 1