Create a new 32bit value from an existing register value in mips

1

I am new to mips. I have the following instruction:

addi $s3, $0, '\n'

$s3 is now equal to 0x0000000a

Now I want to set $s4 to be 0x1001000a

I am trying this:

lui     $s4, 0x1001
ori     $s4, $s4, $s3

But I am getting an error on the ori statement. Any help would be appreciated. Thanks.

mips
mips32
asked on Stack Overflow Aug 15, 2016 by Robert Smith

1 Answer

1

The i in ori means "immediate" - this form of the instruction expects an immediate (literal constant) for the third argument.

In your case you have a register for the third argument, so you just want or:

lui     $s4, 0x1001
or      $s4, $s4, $s3

See this handy MIPS instruction set reference.

answered on Stack Overflow Aug 15, 2016 by Paul R • edited Aug 15, 2016 by Paul R

User contributions licensed under CC BY-SA 3.0