r/computerscience • u/Tranomial_2 • Nov 02 '25
Help How CPUs store opcode in registers
For example an x64 CPU architecture has registers that are 64 bits wide. How does the IR store opcode + addresses of operands? Does the opcode take the 64 bits but hints at the CPU to use the next few bytes as operands? Does the CPU have an IR that is wider than 64 bits? I want to know the exact mechanism. Also if you can provide sources that would be appreciated.
Edit: I did some research, I found out that there is a special purpose register called MAR. So what I think happens is that the CPU decodes a load instruction for example and decides "This is a load instruction so the next few bytes are definitely the operand". It loads the operands address from the program counter register (PC) to the MAR.
Am I onto something or is that totally wrong?
View all comments
Show parent comment
9
u/thesnootbooper9000 Nov 02 '25
No, OP seems to have been taught one of the 1980s models where you have a separate PC and IR. The PC is used to load an opcode into the IR, where it sits around to be decoded and is read by various other circuits to decide what to compute and which muxes and demuxes are set to do the operation. The idea here is that the instruction opcode needs to persist for a while, so it has to be in a register. This isn't how CPUs work exactly, but it's not a bad explanation for a very simple processor.