MIPS has a Load Immediate (LI
) pseudo instruction to load a 32-bit immediate value into a register. But it does not have Store Immediate (SI
) instruction to store a 32-bit immediate value to Memory. Can someone explain me why?
2
votes
mips does not have a load immediate instruction, there is lui and ori which are real instructions li is a pseudo instruction, think of it as a macro.
– old_timer
none of these (lui, nor ori) operate on memory, so having an si "just like" li would also mean not operating on memory.
– old_timer
An instruction containing both an immediate value and a memory address would be much longer than the instruction format allows.
– Bo Persson
Pseudo-instructions are a feature of the assembler, not the processor. MIPS CPUs don't have a LI instruction, it's MIPS assemblers that have a LI pseudo-instruction. That means there's nothing stopping you from creating your own assembler, or modifying an existing one, to create your own SI pseudo-instruction. You might even be able to do it using the macro features of an existing assembler. However you need to make your pseudo-instruction generate real MIPS instructions that a MIPS CPU can execute. So you need to figure out what real MIPS instructions your SI instruction would use.
– Ross Ridge
1 Answers
4
votes
load immediate is from immediate to register, store immediate would be register to...immediate...that doesnt make sense. you want to store to memory you load a register with data a register with an address and do a store. it is (supposedly) a load and store architecture, you do everything (memory-wise) through registers, not directly.