Presentation is loading. Please wait.

Presentation is loading. Please wait.

Addressing Mode Wannachai Wannasawade Department of Computer Education

Similar presentations


Presentation on theme: "Addressing Mode Wannachai Wannasawade Department of Computer Education"— Presentation transcript:

1 Addressing Mode Wannachai Wannasawade Department of Computer Education
Faculty of Technical Education, KMITNB.

2 Addressing Mode ในการพัฒนาโปรแกรมต่าง ๆ มีการอ้างถึงตำแหน่งของข้อมูล ตามที่มีในคำสั่งของไมโครโพรเซสเซอร์ ซึ่งมีหลายวิธีในการติดต่อ ดังนั้นสิ่งที่จะต้องเรียนรู้คือ Addressing Mode หรือวิธีการอ้างตำแหน่ง วิธีการอ้างตำแหน่งแบ่งได้ 3 แบบคือ Data Addressing Mode Program Memory Addressing Mode Stack Memory Addressing Mode

3 Data 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 Data Addressing Mode Register Addressing
Transfer byte or word from source register or memory location to destination register or memory location

5 Data Addressing Mode MOV BX,CX

6 Data Addressing Mode Immediate Addressing
Transfer source immediate byte or word of data into the destination register or memory location

7 Data Addressing Mode MOV EAX,13456H

8 Data Addressing Mode Direct Addressing
Moves 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

9 Data Addressing Mode

10 Data Addressing Mode MOV AL,[1234H]

11 Data Addressing Mode Register Indirect Addressing
Transfer byte or word between register and memory location address by index or base register

12 Data Addressing Mode MOV AX,[BX]

13 Data Addressing Mode Base-Plus-Index Addressing
Transfer byte or word between register and memory location address by base register (BX or BP) plus index register (DI or SI)

14 Data Addressing Mode MOV DX,[BX+DI]

15 Data Addressing Mode Register-Relative Addressing
Moves byte or word between register and memory location address by index or base register plus displacement

16 Data Addressing Mode MOV AX,[BX+1000H]

17 Data Addressing Mode Base Relative-Plus-Index Addressing
Transfer byte or word between register and memory location address by base register and index register plus displacement

18 Data Addressing Mode MOV AX,[BX+SI+1000H]

19 Data Addressing Mode Scale-Index Addressing
Available 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

20 Program Memory Addressing Mode
Used with the JMP and CALL instruction มีใช้งาน 3 แบบคือ Direct Program Memory Addressing Relative Program Memory Addressing Indirect Program Memory Addressing

21 Direct Program Memory Addressing
What many early microprocessors used for all jumps and calls and also used in high-level languages. For example, JMP [10000H] Opcode Offset(low) Offset(High) Segment(high) Segment(low) E A 0 0 1 0 Used in intersegment jumps or often called far jump

22 Relative 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 jump or call (+127 and -128 byte from next instruction) and near jump or call (64K bytes)

23 Indirect Program Memory Addressing
Allows several forms of program indirect memory addressing for JMP and CALL. This type of jump is sometimes called indirect-indirect or double-indirect jump Examples of indirect program memory addressing JMP AX JMP CX JMP NEAR PTR [BX] JMP TABLE [BX] JMP ECX

24 Stack Memory Addressing Mode
The stack plays an importance role in all microprocessor. It holds data temporarily and stores return address of procedures. Used by PUSH and POP that maintained by two register Stack Pointer register (SP or ESP) Stack Segment register (SS)

25 Stack Memory Addressing Mode
PUSH and POP a) PUSH BX b) POP CX

26 Instruction Set เป็นกลุ่มคำสั่งที่ไมโครโพรเซสเซอร์รู้จักและเข้าใจ ซึ่งสามารถแบ่งเป็นกลุ่มต่าง ๆ ได้ดังนี้ Data Movement Instructions Arithmetic and Logic Instructions Program Control Instructions

27 Data Movement Instructions
MOV Instruction Opcode 1-2 bytes MOD-REG-R/M 0-1 bytes Displacement 0-1 bytes Immediate 0-2 bytes 16 bits Instruction mode Address size 0-1 bytes Operand size 0-1 bytes Opcode 1-2 bytes MOD-REG-R/M 0-1 bytes Scaled-index 0-1 bytes Displacement 0-4 bytes Immediate 0-4 bytes 32 bits Instruction mode (80386,80486 and Pentium)

28 Data Movement Instructions
PUSH and POP Load-Effective Address LEA LDS LES LFS LGS LSS String Data Transfer LODS STOS MOVS INS OUTS XCHG LAHF and SAHF XLAT IN and OUT

29 Data Movement Instructions
MOVSX and MOVZX BSWAP CMOV Segment Override Prefix

30 Arithmetic and Logic Instructions
Addition Register Addition Immediate Addition Memory to Register Addition Array Addition Increment Addition Addition with Carry

31 Arithmetic and Logic Instructions
Subtraction Register Subtraction Immediate Subtraction Decrement Subtraction Subtract with Borrow

32 Arithmetic and Logic Instructions
Comparison CMP (Compare) CMPXCHG (Compare and Exchange) used in Pentium

33 Arithmetic and Logic Instructions
Multiplication 8 bit Multiplication 16 bit Multiplication Special Immediate 16 bit Multiplication 32 bit Multiplication

34 Arithmetic and Logic Instructions
Division 8 bit Division 16 bit Division 32 bit Division

35 Arithmetic and Logic Instructions
BCD and ASCII BCD Arithmetic DAA DAS ASCII Arithmetic AAA AAD AAM AAS

36 Arithmetic and Logic Instructions
Basic Logic AND OR XOR TEST and Bit Test NOT and NEG

37 Arithmetic and Logic Instructions
Shift SHL SHR SAR SAL SHLD SHRD

38 Arithmetic and Logic Instructions
Rotate ROL ROR RCL RCR

39 Arithmetic and Logic Instructions
Bit Scan Instruction BSF BSR String Comparisons SCAS CMPS

40 Program Comtrol Instructions
Jump Group Unconditional Jump (JMP) Short Jump Near Jump Far Jump Jumps with Register Operands Indirect Jumps Using Index

41 Program Comtrol Instructions
Jump Group Conditional Jump and Condition Sets JA JAE JB JBE JC JE or JZ JG JGE JL JLE JNC JNE or JNZ JNO JNS JNP or JPO JO JP or JPE JS JCXZ JECXZ LOOP Condition LOOPs

42 Program Comtrol Instructions
Procedures CALL Near CALL Far CALL CALL with Register Operands CALL with Indirect Memory Address RET

43 Program Comtrol Instructions
Other Instructions Interrupt Instructions INT X IRET/IRETD WAIT HLT NOP

44 Program Comtrol Instructions
Other Instructions LOCK Prefix ESC BOUND ENTER and LEAVE


Download ppt "Addressing Mode Wannachai Wannasawade Department of Computer Education"

Similar presentations


Ads by Google