Load 32-bit constant to register in MIPS

The immediate argument passed to addi is only 16 bits. To load a 32-bit immediate value that is outside the range of a 16-bit value you need to do it in two goes, as in the example from your text book.

(Anticipating a further question, the reason there is no load immediate or add immediate instruction which takes a 32-bit immediate value is because the MIPS ISA uses fixed size 32-bit instructions, so there are always < 32 bits available for any instruction arguments - this is very common in RISC architectures.)


Yes registers are 32-bits but how can you specify a 32-bit number in an instruction that is 32 bits? An instruction consists of opcode and data. So, you can't squeeze an opcode + 32-bit data in a single addi.

Tags:

Assembly

Mips