先决条件 – 寻址模式
1. 直接寻址方式:
在直接寻址模式下,地址字段包含操作数的地址。
Effective Address(EA) = address field of operand
例子 –
将寄存器 A 的内容添加到累加器。
ADD A
在地址 A 的内存中查找操作数。访问数据只需要一个内存引用。因此,不需要额外的计算来计算出有效地址。
2. 隐式寻址方式:
操作数在指令的定义中隐式指定。它通常用于零或单地址指令。
示例 1:
增加寄存器 A 的内容。
INC A
这里隐式指定寄存器 A 既是源又是目标。
示例 2:
清除标志寄存器的内容。
CLC
上面的指令是一个零地址指令的例子。
直接寻址模式和隐式寻址模式的区别:
DIRECT ADDRESSING MODE | IMPLIED ADDRESSING MODE |
---|---|
Address fields contains the effective address of operand. | Effective address of operand is specified implicitly. |
Instruction size is larger since operand has to be explicitly specified. | Instruction size is smaller since operand is specified implicitly. |
It requires one reference to memory. | No memory references are required. |
Mostly used in 2 address instructions and more. | Mostly used in zero address and single address instructions. |
It is slower compared to implied mode. | It is a faster method. |
It has more range than implied mode. | It has less range than direct mode. |