Discussion:
how do you set values to registers in mips?
(too old to reply)
Jeremy Daniel Tzeng
2005-09-30 06:41:03 UTC
Permalink
question is the subject thanks.
Val
2005-09-30 08:14:06 UTC
Permalink
use
addi $reg,$0,value
Post by Jeremy Daniel Tzeng
question is the subject thanks.
Aaron Staley
2005-09-30 10:33:01 UTC
Permalink
Post by Jeremy Daniel Tzeng
question is the subject thanks.
In xspim, set value

in MIPS, add $reg, $reg, $zero
Navtej Sadhal
2005-09-30 19:05:27 UTC
Permalink
yes, that works.
if you wish to set immediates, you can use
addiu $reg, $reg, 5
remember that the immediate on addiu is signed, so if you give a negative
number, it will be sign extended to remain negative.
if you wish to just load in 16 bits to the lower portion of a register,
you can use:
ori $reg, $reg, 5
this will zero-extend the immediate.
Post by Aaron Staley
Post by Jeremy Daniel Tzeng
question is the subject thanks.
In xspim, set value
in MIPS, add $reg, $reg, $zero
[TA] Jeremy Huddleston
2005-09-30 18:10:16 UTC
Permalink
Post by Jeremy Daniel Tzeng
question is the subject thanks.
Almost all the mips instructions set the registers in one way or another,
so I assume you mean setting it to a specific number. You want to use the
'li' instruction... such as:

li $t0 10

--Jeremy
Loading...