I cannot understand how the computer implement a binary operation.
First of all, an instruction is stored in the memory unit.
Then, control unit in CPU takes this instruction to store it in instruction register(IR) in itself.
After that, CU decodes operation code in the instruction code by using instruction decoder (ID).
Assume that opcode = sum
If it is so, we need two operands. Some books tell that there is only one address of operand in the address part of the instruction code.
Where is second operand ?
Where is address of second operand ?
Mostly of the time, the second operand is already stored in a register of the CPU, the ALU (Arithmetic Logical Unit).
The instruction sequence may look like this:
lda $1234 ' loads value from memory address $1234 into ALU
add #20 ' adds value 20 to the value stored in ALU and stores the result in the ALU again
sda $5678 ' stores the resulting value from the ALU in the memory at address $5678
Modern CPUs have a lot of registers, so the instruction sequence for a modern CPU may look like this:
load ax, $1234 ' loads value from memory address $1234 into AX
load bx, [si+2] ' load the value from the address stored in register SI+2
add ax, bx ' adds the value in register BX to the value in register AX and stores the result in AX
store di+5, ax ' stores the value of register in memory at address stored in DI+5
Hopefully this clears it up for you.