Addressing Mode Wannachai Wannasawade Department of Computer Education Faculty of Technical...
-
Upload
bianca-oliff -
Category
Documents
-
view
216 -
download
2
Transcript of Addressing Mode Wannachai Wannasawade Department of Computer Education Faculty of Technical...
Addressing Mode
Wannachai WannasawadeDepartment of Computer Education
Faculty of Technical Education, KMITNB.
2
ในการพั�ฒนาโปรแกรมต่�าง ๆ ม�การอ้�าง ถึ�งต่�าแหน�งขอ้งข�อ้ม�ล ต่ามที่��ม�ในคำ�าสั่��งขอ้ง
ไมโคำรโพัรเซสั่เซอ้ร" ซ��งม�หลายวิ%ธี� ในการต่%ดต่�อ้ ด�งน�(นสั่%�งที่��จะต่�อ้งเร�ยนร� �คำ+อ้
Addressing ModeAddressing Mode หร+อ้วิ%ธี�การวิ%ธี�การอ้�างต่�าแหน�งอ้�างต่�าแหน�ง
วิ%ธี�การอ้�างต่�าแหน�งแบ่�งได� วิ%ธี�การอ้�างต่�าแหน�งแบ่�งได� 3 3 แบ่บ่คำ+อ้แบ่บ่คำ+อ้ Data Addressing ModeData Addressing Mode Program Memory Addressing ModeProgram Memory Addressing Mode Stack Memory Addressing ModeStack Memory Addressing Mode
3Data Addressing ModeData Addressing Mode Register addressing Immediate addressing Direct addressing Register indirect address Base-plus-index addressing Register relative addressing Base relative-plus-index addressing Scaled-index address
4
Register AddressingRegister AddressingTransfer byte or word from source register or memory location to destination register or memory location
Data Addressing ModeData Addressing Mode
5Data Addressing ModeData Addressing ModeMOV BX,CX
6
Immediate AddressingImmediate AddressingTransfer source immediate byte or word of data into the destination register or memory location
Data Addressing ModeData Addressing Mode
7Data Addressing ModeData Addressing ModeMOV EAX,13456H
8
Direct AddressingDirect AddressingMoves byte or word between a memory location and register
Direct Addressing move between memory location and AL,AX or EAX Displacement Addressing applies to almost any instruction in the instruction set
Data Addressing ModeData Addressing Mode
9Data Addressing ModeData Addressing Mode
10Data Addressing ModeData Addressing ModeMOV AL,[1234H]
11
Register Indirect AddressingRegister Indirect AddressingTransfer byte or word between register and memory location address by index or base register
Data Addressing ModeData Addressing Mode
12Data Addressing ModeData Addressing ModeMOV AX,[BX]
13
Base-Plus-Index AddressingBase-Plus-Index AddressingTransfer byte or word between register and memory location address by base register (BX or BP) plus index register (DI or SI)
Data Addressing ModeData Addressing Mode
14Data Addressing ModeData Addressing ModeMOV DX,[BX+DI]
15
Register-Relative AddressingRegister-Relative AddressingMoves byte or word between register and memory location address by index or base register plus displacement
Data Addressing ModeData Addressing Mode
16Data Addressing ModeData Addressing ModeMOV AX,[BX+1000H]
17
Base Relative-Plus-Index AddressingBase Relative-Plus-Index AddressingTransfer byte or word between register and memory location address by base register and index register plus displacement
Data Addressing ModeData Addressing Mode
18Data Addressing ModeData Addressing ModeMOV AX,[BX+SI+1000H]
19
Scale-Index AddressingScale-Index AddressingAvailable 80386-Pentium used second register of pair of register is modified by the scale factor of 2X, 4X or 8X to generate the operand memory address
Data Addressing ModeData Addressing Mode
20Program Memory Program Memory Addressing ModeAddressing ModeUsed with the JMP and CALL
instruction
ม�ใช้�งาน 3 แบ่บ่คำ+อ้
Direct Program Memory Direct Program Memory
AddressingAddressing
Relative Program Relative Program
Memory AddressingMemory Addressing
Indirect Program Indirect Program
Memory AddressingMemory Addressing
21
OpcodeOffset(low)Offset(High) Segment(high)Segment(low)
E A 0 0
0 0
0 0
1 0
Direct Program Memory AddressingDirect Program Memory AddressingWhat many early microprocessors
used for all jumps and calls and also
used in high-level languages. For
example, JMP [10000H]
Used in intersegment jumpsintersegment jumps or often called ffar jumpar jump
22Relative Program Memory AddressingRelative Program Memory Addressing
Not available in all early
microprocessors, but available to
some family of microprocessors.
Relative means relative to
instruction Pointer (IP) used in
short jumpshort jump or call (+127 and -
128 byte from next instruction)
and near jumpnear jump or call (64K bytes)
23Indirect Program Memory AddressingIndirect Program Memory AddressingAllows several forms of program indirect memory addressing for JMP and CALL. This type of jump is sometimes called indirect-indirectindirect-indirect or double-indirect jumpdouble-indirect jumpExamples of indirect program memory addressing
JMP AXJMP CXJMP NEAR PTR [BX]JMP TABLE [BX]JMP ECX
24Stack Memory Addressing ModeStack Memory Addressing Mode
The stack plays an importance
role in all microprocessor. It
holds data temporarily and
stores return address of
procedures. Used by PUSHPUSH and
POPPOP that maintained by two
register
Stack Pointer register (SP
or ESP)
Stack Segment register
(SS)
25Stack Memory Addressing ModeStack Memory Addressing ModePUSH and POP a) PUSH BXPUSH BX b) POP CXPOP CX
26
เป.นกล/�มคำ�าสั่��งที่��ไมโคำรโพัรเซสั่เซอ้ร"ร� �จ�ก และเข�าใจ ซ��งสั่ามารถึแบ่�งเป.นกล/�มต่�าง ๆ
ได�ด�งน�( Data Movement
Instructions
Arithmetic and Logic
Instructions
Program Control
Instructions
27
Opcode 1-2 bytesMOD-REG-R/M
0-1 bytesDisplacement
0-1 bytesImmediate0-2 bytes
16 bits Instruction mode
Opcode 1-2 bytes
MOD-REG-R/M0-1 bytes
Displacement0-4 bytes
Immediate0-4 bytes
Scaled-index0-1 bytes
Operand size0-1 bytes
Address size0-1 bytes
32 bits Instruction mode(80386,80486 and Pentium)
MOV InstructionMOV Instruction
28
PUSH and POP Load-Effective Address
LEA LDS LESLFS LGS LSS
String Data TransferLODS STOS MOVSINS OUTS
XCHG LAHF and SAHF XLAT IN and OUT
29
MOVSX and MOVZX
BSWAP
CMOV
Segment Override Prefix
30
AdditionAddition Register Addition Immediate Addition Memory to Register Addition Array Addition Increment Addition Addition with Carry
31
SubtractionSubtraction Register Subtraction Immediate Subtraction Decrement Subtraction Subtract with Borrow
32
ComparisonComparison CMP (Compare) CMPXCHG (Compare and Exchange) used in 80486 - Pentium
33
MultiplicationMultiplication 8 bit Multiplication 16 bit Multiplication Special Immediate 16 bit Multiplication 32 bit Multiplication
34
DivisionDivision 8 bit Division 16 bit Division 32 bit Division
35
BCD and ASCIIBCD and ASCII BCD Arithmetic
DAA DAS
ASCII Arithmetic AAA AAD AAM AAS
36
Basic LogicBasic Logic AND OR XOR TEST and Bit Test NOT and NEG
37
Shift Shift SHL SHR SAR SAL SHLD SHRD
38
RotateRotate ROL ROR RCL RCR
39
Bit Scan InstructionBit Scan Instruction BSF BSR
StringString ComparisonsComparisons SCAS CMPS
40
Jump GroupJump Group Unconditional Jump (JMP)
Short Jump Near Jump Far Jump Jumps with Register Operands Indirect Jumps Using Index
41
Jump GroupJump Group Conditional Jump and Condition SetsJA JAE JB JBEJC JE or JZ JG JGEJL JLE JNC JNE or JNZJNO JNS JNP or JPO JOJP or JPE JS JCXZJECXZLOOP Condition LOOPs
42
ProceduresProcedures CALL
Near CALL Far CALL CALL with Register Operands CALL with Indirect Memory Address
RET
43
Other InstructionsOther Instructions Interrupt Instructions
INT X IRET/IRETD
WAIT HLT NOP
44
Other InstructionsOther Instructions LOCK Prefix ESC BOUND ENTER and LEAVE