ori
The ori
instruction stands for “or immediate”. It is used to perform a bitwise OR operation between a register and a 16-bit constant, with the result being stored in a register. Unlike li
, move
, and la
, ori
is not a pseudo-instruction.
Syntax
Here,
$t
is the target register,$s
is the source register, andconstant
is the 16-bit constant to be ORed with the contents of$s
.
The ori
instruction performs the following steps:
- It takes the contents of register
$s
and the 16-bit constant. - It performs a bitwise OR operation between the two.
- It stores the result into the target register
$t
.
Example:
lui $t1, 0x1234
loads the constant value0x1234
into the upper 16 bits of the register$t1
, resulting in0x12340000
in$t1
ori $t1, $t1, 0x5678
performs a bitwise OR operation between the contents of$t1
(0x12340000
) and0x5678
, resulting in0x12345678
in$t1
Note
The
ori
instruction is often used in combination with thelui
instruction to form larger constants or addresses. For example, to load a 32-bit constant into a register, you could uselui
to load the upper 16 bits andori
to load the lower 16 bits. Similarly, to load the address of a label into a register, you could uselui
to load the upper 16 bits of the