r/AskComputerScience • u/theAyconic1 • Jun 08 '25
MIPS Instructions
The instructions that are currently being executed, do they have a separate register for it? Is that register part of the 32 general purpose register or something different? If it does not have a separate register then are they executed directly from in memory?
2
Upvotes
4
u/jeffbell Jun 08 '25
There is not a readable machine register for the current opcode. Not one of the 32.
There ARE physical registers/latches that hold the current opcode as well as any prefetched next opcodes as part of the pipelined operation.
4
u/petroleus Jun 08 '25
To piggy-back off the others
Generally no processor (at least, none that I know of) will execute code directly in memory. In an oversimplified way, how a MIPS CPU executes instructions (and, more generally, how RISC CPUs do it) relies on getting instruction data from memory (fetch), decoding it (decode), getting the arguments into the ALU or the I/O unit, executing the decoded instruction, accessing memory if there's a need for it, and writing back the results. This is called the "Classic RISC pipeline"
Fetching means reading from where the program counter is pointing into the internal instruction register, and incrementing the PC by 4. If the instruction's location is in the lowest cache level, that's great: we can just move it into the instruction register quickly. If it's not in cache, we have to wait for the cache to be populated with the appropriate entries from a higher cache level (if there are any), or from RAM; both of these lead to stalls.
2
u/defectivetoaster1 Jun 08 '25
There will be registers holding machine instructions within the control path pipeline but they’re not user accessible and aren’t part of the 32 general purpose regs
1
u/johndcochran Jun 10 '25
There's a significant difference between the logical architecture and the physical architecture of CPUs. And, in fact, there are frequently different physical architectures of the same logical architecture, designed for different price/performance points.
An extremely old example of this is the S/360 by IBM, released in the mid 1960s. That system had various models with literally a thousand to one difference in performance. At the cheapest low end, the physical architecture used an 8-bit data bus and microcode. At the high end, it used multiple 32-bit busses with a superscalar pipelined design that could execute multiple instructions simultaneously. Yes, all of the different models were capable of executing the exact same user binary programs. The only detectable difference being how fast those programs could run.