指令代码



我无法理解计算机如何实现二进制操作。

首先,指令存储在存储单元中。

然后,CPU中的控制单元接受该指令将其存储在指令寄存器(IR(中。

之后,CU 使用指令解码器 (ID( 对指令代码中的操作代码进行解码。

假设操作码 = 总和

如果是这样,我们需要两个操作数。有些书说,在指令代码的地址部分只有一个操作数地址。

第二个操作数在哪里?

第二个操作数的地址在哪里?

大多数情况下,第二个操作数已经存储在CPU的寄存器中,即ALU(算术逻辑单元(。

指令序列可能如下所示:

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

现代 CPU 有很多寄存器,因此现代 CPU 的指令序列可能如下所示:

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

希望这能为您清除它。

最新更新