Operands Addressing(操作数寻址方式)

advertisement
指令与寻址方式
一、instruction
Sentence
(指令语句)
按指令的用途划分有:
1. Data Transfer (数据传送) —— MOV、PUSH、POP…
2. Arithmetic Operations (算术运算) —— ADD、SUB、INC…
3. Logical Operations (逻辑运算) —— OR、AND、NOT…
4. String Operation (字串操作) —— MOVS、LODS(取字串)…
5. Transfer (程序转移) —— JMP、CALL、RET…
6. CPU Control (控制语句) —— CLC(清进位)、CLI(关中断)
按指令的结构划分有:
1. 单操作数指令 —— OPR DEST
2. 双操作数指令 —— OPR DEST, SRC
3. 无操作数指令 —— OPR
二、Operands Addressing(操作数寻址方式)
—— How to lookup the Operands.
Assembler Format:
标号
操作码
目标
源
注释
[Identifier:] Operation [[Source][,Object]] [;Comment]
Operands
1. Immediate Addressing (立即寻址)
—— Operand in the instruction.
For Example:
MOV AX, 14
MOV SUM, 13
;14
AX
2. Register Addressing (寄存器寻址)
—— Operand in some registers.
For Example:
MOV
AH, BL
; BL
AH
3. Direct Addressing (直接寻址)
—— Operand address in the instruction.
For Example:
AX
内存低端
MOV
AX, [2000H]
......
AX = 3050
AH
代
码
段
AL
内存高端
; [DS:2000H]
50
DS:2000H
30
DS:2001H
......
数
据
段
4. Register Indirect Addressing(间接寻址)
—— Operand address in some registers.
For Example:
MOV
AX, [BX]
;[DS:BX]
AX
MOV
AX, [BP]
;[SS:BP]
AX
5. Indexed Addressing(变址寻址)
For Example 1:
MOV
AX, [BX][SI]
;[DS:(BX+SI)]
AX
MOV
AX, [BP][SI]
;[SS:(BP+SI)]
AX
〖8-5〗
For Example 2:
MY_2 DW 100 DUP(?)
...
MOV AX, MY_2[BX]
;[DS:(MY_2+BX)]
AX
For Example 3:
MY_3 DW 100 DUP(?)
...
MOV AX, MY_3[BX][SI] ;[DS:(MY_3+BX+SI)]
MOV AX, MY_3[BP][SI]
;[SS:(MY_3+BP+SI)]
AX
AX
注意: 变址的以下书写方式等效:
MY_3[BX][SI]
[BX][SI]+MY_3
[BX+SI]+MY_3
[BX+SI+MY_3]
〖8-6〗
几条指令说明:
• MOV
– Transfers data referenced by address of the second operand to
the address of the first operand
– General format
[Label:] MOV register/memory,register/memory/immediate
– Invalid MOV operations:
The only instructions that
• Memory to memory
allow both operands to
• Immediate to segment register
address memory directly
• Segment register to segment register
are MOVS and CMPS
– The operands must agree in size
• XCHG
– Swaps data items
– General format
[Label:] XCHG register/memory,register/memory
– Example:
Wordq dw ?
…
XCHG CL, BH
XCHG CX, WORDQ
• LEA
– Initialize a register with an offset address
– General format
[Label:] lea register, memory
– Example:
Databl db 25 dup(?)
Bytefld db ?
…
Lea bx, datatbl ;和mov bx,offset datatbl相同
Mov bytefld, [bx]
• INC and DEC
Increments and decrements the contents of registers
and memory locations by 1,respectively.
– Format:
[label:] INC/DEC
register/memory
– Depending on the result,the operations clear or set
the OF,SF,and ZF flags. This instruction does not
set the carry flag.
• INT
– INT指令退出正常处理过程并访问位于低端存储
器的中断向量表,以便确定所请求的例程的地址。
然后该操作转到BIOS或操作系统中去完成指定
的动作并返回程序继续原来的处理过程。
(An int instruction interrupts processing and accesses
the interrupt vector table in low memory to
determine the address of the requested routine.The
operation then transfers to DOS or to BIOS for
specified action and returns to your program to
resume processing.)
– INT performs the following:
• 标志寄存器的内容进栈
• 清除中断与陷阱标志
• CS寄存器进栈
• 指令指针(IP)(内有下一条指令的地址)
进栈
• Causes the required operation to be
performed
– 从中断中返回使用IRET
– The preceding process is entirely automatic.
数据传送的方向:
立即数
数据寄存器:AX、BX、CX、DX
内 存
指针寄存器:IP、SP、BP
变址寄存器:SI、DI
段寄存器:
CS、ES、DS、SS
Questions:
Page 106
6-2
6-3
6-6
6-7
6 – 13
Download