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
5
u/HenkPoley Nov 02 '25 edited Nov 02 '25
If you mean "Instruction Register" with IR, then that does not contain any instructions. It points to the place in memory where the instruction is read. For that reason it is also called Instruction Pointer (IP) or Program Counter (PC) in some assembly languages.
Of course there are places in the processor that store the bytes that make up the instructions that were read from memory. But those are usually not called registers. You'll find more about that when you look up terms like 'instruction decoding', or 'micro-ops'.