Assembly Lang. – Intel 8086 Addressing modes – 1

Slides:



Advertisements
Similar presentations
Intel 8086.
Advertisements

There are two types of addressing schemes:
Microprocessor Fundamentals Week 5 Mount Druitt College of TAFE Dept. Electrical Engineering 2008.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#3) By Dr. Syed Noman.
Addressing modes The way in which an operand is specified is called the Address Mode.
6-1 ECE 424 Design of Microprocessor-Based Systems Haibo Wang ECE Department Southern Illinois University Carbondale, IL Intel 8088 Addressing modes.
Lect 3: Instruction Set and Addressing Modes. 386 Instruction Set (3.4) –Basic Instruction Set : 8086/8088 instruction set –Extended Instruction Set :
Azir ALIU 1 What is an assembly language?. Azir ALIU 2 Inside the CPU.
Addressing modes – 1 The way in which an operand is specified is called the Address Mode.
The 8086 Assembly Programming Data Allocation & Addressing Modes
ICS312 Set 3 Pentium Registers. Intel 8086 Family of Microprocessors All of the Intel chips from the 8086 to the latest pentium, have similar architectures.
Lect 4: Instruction Set and Addressing Modes. 386 Instruction Set (3.4)  Basic Instruction Set : 8086/8088 instruction set  Extended Instruction Set.
1/2002JNM1 Positional Notation (Hex Digits). 1/2002JNM2 Problem The 8086 has a 20-bit address bus. Therefore, it can access 1,048,576 bytes of memory.
MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR1 Addressing Mode.
Types of Registers (8086 Microprocessor Based)
INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
Faculty of Engineering, Electrical Department,
ΠΟΛΥΤΕΧΝΙΚΗ ΣΧΟΛΗ Τμήμα Ηλεκτρολογών Μηχανικών και Τεχνολογίας Υπολογιστών Μικρουπολογιστές & Μικροσυστήματα ΙΙ Καθηγητής Σταύρος Α. Κουμπιάς Πανεπιστημίου.
8086 Internal Architecture
University of Sargodha, Lahore Campus Prepared by Ali Saeed.
Computer Organization Instructions Language of The Computer (MIPS) 2.
Assembly Language Data Movement Instructions. MOV Instruction Move source operand to destination mov destination, source The source and destination are.
Internal Programming Architecture or Model
Computer Organization & Assembly Language University of Sargodha, Lahore Campus Prepared by Ali Saeed.
Microprocessors CSE- 341 Dr. Jia Uddin Assistant Professor, CSE, BRAC University Dr. Jia Uddin, CSE, BRAC University.
I NTEL 8086 M icroprocessor بسم الله الرحمن الرحيم 1.
Microprocessors CSE- 341 Dr. Jia Uddin Assistant Professor, CSE, BRAC University Dr. Jia Uddin, CSE, BRAC University.
Computer Science 516 Intel x86 Overview. Intel x86 Family Eight-bit 8080, 8085 – 1970s 16-bit 8086 – was internally 16 bits, externally 8 bits.
Chapter 12 Processor Structure and Function. Central Processing Unit CPU architecture, Register organization, Instruction formats and addressing modes(Intel.
Instruction set Architecture
Part of the Assembler Language Programmers Toolbox
A Closer Look at Instruction Set Architectures
Introduction to 8086 Microprocessor
COURSE OUTCOMES OF MICROPROCESSOR AND PROGRAMMING
Instruksi Set Prosesor 8088
ADDRESSING MODES.
Microprocessor Systems Design I
Microprocessor and Assembly Language
Assembly IA-32.
Assembly Language Programming Part 2
ADDRESSING MODES.
Intel 8088 (8086) Microprocessor Structure
Processor Processor characterized by register set (state variables)
Chapter 3 Addressing Modes
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Computer Organization and Assembly Language (COAL)
Microprocessor and Assembly Language
Defining Types of data expression Dn [name] expression Dn [name]
Symbolic Instruction and Addressing
Introduction to Assembly Language
BIC 10503: COMPUTER ARCHITECTURE
Data Addressing Modes • MOV AX,BX; This instruction transfers the word contents of the source-register(BX) into the destination register(AX). • The source.
Intel 8088 (8086) Microprocessor Structure
8086 Registers Module M14.2 Sections 9.2, 10.1.
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Symbolic Instruction and Addressing
(Array and Addressing Modes)
Chapter 3: Addressing Modes
Computer Architecture and the Fetch-Execute Cycle
68000 Architecture, Data Types and Addressing Modes
Symbolic Instruction and Addressing
(Array and Addressing Modes)
CNET 315 Microprocessor & Assembly Language
Lecture 06 Programming language.
Unit-I 80386DX Architecture
COMP 1321 Digital Infrastructure
Chapter 6 –Symbolic Instruction and Addressing
Intel 8086.
Chapter 8: Instruction Set 8086 CPU Architecture
(Array and Addressing Modes)
Presentation transcript:

Assembly Lang. – Intel 8086 Addressing modes – 1 The way in which an operand is specified is called the Address Mode.

Flexible access to memory, allowing you to easily access variables, arrays, records, pointers, and other complex data types. Mastery of the 80x86 addressing modes is the first step towards mastering 80x86 assembly language.

x86 instructions use five different operand types: registers, constants, and three memory addressing schemes. Each form is called an addressing mode. http://www.electronics.dit.ie/staff/tscarff/8086_address_modes/8086_address_modes.htm

x86 processors support  the register addressing mode , the immediate addressing mode, the direct addressing mode, the indirect addressing mode, the base plus index addressing mode, the register relative addressing mode, & the base relative plus index addressing mode.

1. Register AM mov ax, ax mov ax, bx mov ax, cx mov ax, dx The first instruction accomplishes absolutely nothing. It copies the value from the ax register back into the ax register. The remaining three instructions copy the value of bx, cx and dx into ax. Note that the original values of bx, cx, and dx remain the same. The first operand (the destination) is not limited to ax; you can move values to any of these registers.

By specifying the name of the register as an operand to the instruction, you may access the contents of that register. mov AX, BL  ok? The eight and 16 bit registers are certainly valid operands for this instruction. The only restriction is that both operands must be the same size.

mov ax, bx ;Copies the value from BX into AX mov dl, al ;Copies the value from AL into DL mov si, dx ;Copies the value from DX into SI mov sp, bp ;Copies the value from BP into SP mov dh, cl ;Copies the value from CL into DH mov ax, ax ;Yes, this is legal!

2. Immediate AM – constant mov ax, 25 mov bx, 195 mov cx, 2056 mov dx, 1000 These instructions are all pretty straightforward.  They load their respective registers with the specified hexadecimal constant.

There are three addressing modes which deal with accessing data in memory. These addressing modes take the following forms: mov ax, [1000] mov ax, [bx] mov ax, [1000+bx]

Direct [memory] AM – operand is variable mov ax, [1000] uses the direct addressing mode to load ax  with the 16 bit value  stored in memory  starting at location 1000 hex.

Indirect [mem] AM mov ax, [bx] It loads ax from the memory location specified by the contents of the bx register. This is an indirect addressing mode. Rather than using the value in bx, this instruction accesses to the memory location whose address appears in bx.  Pointer of the memory location [C prog.]

mov bx, 1000 mov ax, [bx] are equivalent to the single instruction: mov ax, [1000]

Base + index AM mov ax, [1000+bx] This instruction adds the contents of bx with 1000 to produce the address of the memory value to fetch. This instruction is useful for accessing elements of arrays, records, and other data structures.

8086 AM

Marut – 10.2.2 Based & Indexed AM Offset address is obtained by adding a number called displacement to the contents of a register. Displacement  Offset address of a variable A constant +/- The offset address of a variable +/- a const.

Syntax of an operand~ [reg. + displacement] [displacement + reg] dipl. + [reg.] displ[reg] Reg. must be BX, SI or DI  DS contains the segment no. of the operand’s address BP  SS has the segment no.

Based/Indexed AM is Based  if BX (base reg) or, BP (base pointer) is used. AM is indexed  if SI (source index) or, DI (destination index) is used. e.g., W is a word array, BX contains 4. MOV AX, W[BX] The displacement is the offset address of variable W. The instruction moves the element at address W+4 to AX. This is the 3rd element in the array.

Other forms of previous example… MOV AX, W[BX] MOV AX, [W+BX] MOV AX, [BX+W] MOV AX, W+[BX] MOV AX, [BX]+W

Indexed – SI source index or DI dest index E.g., suppose SI contains the address of a word array W. Instruction – MOV AX, [SI+2] ;displ is 2 The instruction moves the contents of W+2 to AX. This is the 2nd element of the array Other forms:

Other forms MOV AX, [SI+2] ;displ is 2 MOV AX, 2+[SI] MOV AX, [SI]+2

Q. Write some code to sum in AX the elements of an array. Idea is to set a pointer to the base of the array, & let it move up the array, & summing elements as it goes. XOR AX, AX ;AX holds sum LEA SI, W ;SI points to array W MOV CX, 10 ;CX has no. of elements ADDARRAY: ADD AX, [SI] ;sum=sum + element ADD SI, 2 ;move pointer to the next element LOOP ADDARRAY ;loop until done loop

This is done by  Register indirect AM. Add 2 as it is WORD not BYTE array LEA moves the source offset address – into the destination.

The same - using based AM Based AM – BX [base reg] or BP [base pointer] The idea is to cleat BX – then add 2 to it on each trip – through summation loop. XOR AX, BX ;AX holds sum XOR BX, BX ;clear base reg BX MOV CX, 10 ;CX has no. of elements ADDARRAY: ADD AX, W[BX] ;sum=sum+element ADD BX, 2 ;index next element LOOP ADDARRAY ;loop until done

LEA – Load effective address Loads an offset memory address to a register LEA destination, source The offset address of the source memory operand is placed in the destination, which is a general register.

LOOP LOOP CX is decremented by 1, If the result is not zero, then control is transferred to the labeled instruction; Else, control flows to the next instruction Flags affected – none

8086 Memory Addressing Modes The 8086 provides 17 different ways to access memory! 17!! But – variants of one another. 5 basics are – displacement-only, base, displacement + base, base + indexed, and displacement + base + indexed. http://www.ic.unicamp.br/~celio/mc404s2-03/addr_modes/intel_addr.html

I. Displacement Only Addressing Mode displacement-only (or direct) addressing mode consists of a 16 bit constant that specifies the address of the target location. mov al, ds:[8088h] loads the al register with a copy of the byte at memory location 8088h. Likewise, the instruction mov ds:[1234h],dl stores the value in the dl register to memory location 1234h:

Indexed addressing uses a register (implicitly or explicitly) as an offset, which is added to the address in the operand to determine the effective address of the data. Based addressing is similar except that a base register is used instead of an index register. The difference between these two is that an index register holds an offset relative to the address given in the instruction, a base register holds a base address where the address field represents a displacement from this base.

Pipelining Some CPUs divide the fetch-decode-execute cycle into smaller steps. These smaller steps can often be executed in parallel to increase throughput. Such parallel execution is called instruction-level pipelining. This term is sometimes abbreviated ILP in the literature.