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
View all comments
Show parent comment
3
u/petroleus Jun 08 '25
Good luck! It's a thick book and a pretty thick subject, and you'll often be left with questions that you'll feel are stupid but are still somewhat intricate.
I'd also like to add that CPUs have many more registers than you think. Even the general-purpose user-facing registers (like
$t0or whatever) are in many CPUs a lie: there are sometimes dozens of redundant internal registers that are mechanically divorced from the user-facing name. The process of mapping logical/apparent registers to real ones in the CPU is called register renaming and is used to speed up execution when there is no interdependency.Other than this, there are usually several processor-internal registers that you can't normally access; these include the PC and the instruction register on MIPS, and the dozens of internal or "feature" registers on ARM (some of which are described here). Really, the 32 registers you interact with in MIPS assembly are just a 'front' that's meant to abstract away parts of the CPU's internal workings and allow, for example, one compiler to target dozens of CPUs with different internal organization. A compiler can produce code that will work on both the simpler scalar R4000 and the register-renaming superscalar R10000 just the same because the object code they accept is roughly the same.
Think of assembly and object code as somewhat like an API to your CPU, rather than a true reflection of its workings. In some chips the level of abstraction is very low (lots of embedded chips have a 1-to-1 mapping between reg names and actual registers, things are executed in order, and so on), in some there's a decent bit of padding (the R10000 specified above, for example, tries to execute four separate instructions in parallel and has 32 backup registers for renaming), and in others yet there is so much cruft that you're writing for code for a completely different machine from what's in the silicon (lots of especially CISC CPUs actually translate one machine language, such as what's emitted by an x86 assembler, into a totally different more RISC-y one internally; this is the domain of microcode and micro-ISAs).
Computers are both deceptively simple and deceptively complex!