Reputation: 11
Why use "ori" in this code?
#case 3:
switch02_code_3 :
#a [ 5 ] = 50000;
ori $t0 , $zero , 0xC350 # $t0 <− 0x0000C350 = 50000
la $t1 , a # $t1 <− base address from a
sw $t0 , 20($t1) # a [ 5 ] = 50000
#break;
j switch02_end # finish switch block
I don't see why it is necessary to expand the number of bits
Upvotes: 0
Views: 123
Reputation: 1688
That line is li $t0,0xC350
. The li
instruction isn't real, it uses addi
or ori
to do the job. Since 0xC350
exceeds 0x7FFF
, using addi
would result in sign-extension which wasn't what the programmer wrote in the source code (most likely li $t0,0xC350
)
Upvotes: 2