5

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?

phuclv
  • 37,963
  • 15
  • 156
  • 475
sandywho
  • 353
  • 1
  • 7
  • 16
  • 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 May 24 '17 at 01:22
  • 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 May 24 '17 at 01:24
  • 1
    An instruction containing both an immediate value and a memory address would be much longer than the instruction format allows. – Bo Persson May 24 '17 at 09:51
  • 3
    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 May 24 '17 at 17:20

1 Answers1

4

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.

old_timer
  • 69,149
  • 8
  • 89
  • 168
  • 1
    My question was, suppose Store Immediate(SI) is an instruction that stores a 32-bit immediate value to memory why is it not implemented in MIPS? – sandywho May 23 '17 at 23:58
  • 3
    Why would it be? why doesnt mips have a memory to memory move or add, etc? Why doesnt it have a HACF instruction? It certainly doesnt fit with the mips design thats for sure (store immediate to memory without a register being involved as the source) but you would have to go ask the designers what they were thinking that day. – old_timer May 24 '17 at 01:13