does anyone know how the CPU determines which register should receive the result produced by an instruction?
anyone???
does anyone know how the CPU determines which register should receive the result produced by an instruction?
anyone???
That would depend on the instruction. Many instructions take the destination register as an argument, and others have defined behavior as to where a result is stored. For example, the ADD instruction:
add $d, $s, $t
The result of $s + $t is stored into $d
It's encoded in the instruction. For example, "add" takes dest, op1, op2 and does dest = op1+op2.
For basic instructions like an add or a dub you need to define the register it goes into. mul and div instructions put values in hi and lo registers.