Khaled A. Al-Utaibi  Introduction  The MOV Instruction  The LEA Instruction  The Stack Instructions  The String Data Transfer.

Slides:



Advertisements
Similar presentations
Register In computer architecture, a processor register is a small amount of storage available on the CPU whose contents can be accessed more quickly than.
Advertisements

Judul Mata Kuliah Judul Pokok Bahasan 1/total Data Movement Instructions.
There are two types of addressing schemes:
For the example slides do not click the mouse to see the full animation Microprocessor 1 Dr.Raed Al-qadi 2009 for the example slides do not click the mouse.
Lect 3: Instruction Set and Addressing Modes. 386 Instruction Set (3.4) –Basic Instruction Set : 8086/8088 instruction set –Extended Instruction Set :
80x86 Instruction Set Dr. Qiang Lin.
Data Movement Instructions
The 8086 Assembly Programming Data Allocation & Addressing Modes
Gursharan Singh Tatla 21-Nov-20101www.eazynotes.com.
8086 : INSTRUCTION SET By, Pramod Sunagar Assistant Professor
Set 20 Interrupts. INTERRUPTS The Pentium has a mechanism whereby external devices can interrupt it. Devices such as the keyboard, the monitor, hard disks.
8-1 ECE 424 Design of Microprocessor-Based Systems Haibo Wang ECE Department Southern Illinois University Carbondale, IL x86 Instructions Part.
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.
Microcomputer & Interfacing Lecture 3
80x86 Processor Architecture
Topic – string – Ch. 11 [Marut] Ch. 4 [Brey] String Data Transfer Instructions – The Direction Flag – LODS Instructions – STOS Instructions – MOVS Instructions.
Gursharan Singh Tatla Block Diagram of Intel 8086 Gursharan Singh Tatla 19-Apr-17.
Lect 4: Instruction Set and Addressing Modes. 386 Instruction Set (3.4)  Basic Instruction Set : 8086/8088 instruction set  Extended Instruction Set.
An Introduction to 8086 Microprocessor.
CDP ECE Spring 2000 ECE 291 Spring 2000 Lecture 7: More on Addressing Modes, Structures, and Stack Constantine D. Polychronopoulos Professor, ECE.
3.7 String Instructions Specifying the Operands’ Size and Address and the String Direction STRING = a data collection in memory. String ELEMENTS can be:
11.1/36 Repeat: From Bits and Pieces Till Strings.
Types of Registers (8086 Microprocessor Based)
INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
ICS312 Lecture13 String Instructions.
Addressing Modes of 8086 Processor Ammar Anwar Khan Electrical Engineer King Saud University Riyadh Saudi Arabia.
Click to add Title Comunicación y Gerencia Click To add Subtitle Click to add Text Fundamentals of Assembly Language.
String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures.
String Processing Chapter 10 S. Dandamudi To be used with S. Dandamudi, “Introduction to Assembly Language Programming,” Second Edition, Springer,
Khaled A. Al-Utaibi  I/O Ports  I/O Space VS Memory Space  80x86 I/O Instructions − Direct I/O Instructions − Indirect I/O Instructions.
String Instructions String instructions were designed to operate on large data structures. The SI and DI registers are used as pointers to the data structures.
MODULE 5 INTEL TODAY WE ARE GOING TO DISCUSS ABOUT, FEATURES OF 8086 LOGICAL PIN DIAGRAM INTERNAL ARCHITECTURE REGISTERS AND FLAGS OPERATING MODES.
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
Lecture 6 Presented By Dr. Shazzad Hosain Asst. Prof. EECS, NSU.
Microprocessors CSE- 341 Dr. Jia Uddin Assistant Professor, CSE, BRAC University Dr. Jia Uddin, CSE, BRAC University.
Intel MP Organization. Registers - storage locations found inside the processor for temporary storage of data 1- Data Registers (16-bit) AX, BX, CX, DX.
I NTEL 8086 M icroprocessor بسم الله الرحمن الرحيم 1.
Microprocessors CSE- 341 Dr. Jia Uddin Assistant Professor, CSE, BRAC University Dr. Jia Uddin, CSE, BRAC University.
Instruction set Architecture
Chapter Nov-2010
Assembly 07 String Processing.
Introduction to 8086 Microprocessor
8086 Microprocessor.
COURSE OUTCOMES OF MICROPROCESSOR AND PROGRAMMING
ADDRESSING MODES.
Chapter 4 Data Movement Instructions
Intel 8086 MICROPROCESSOR Architecture.
EE3541 Introduction to Microprocessors
INSTRUCTION SET.
ADDRESSING MODES.
Intel 8088 (8086) Microprocessor Structure
Chapter 3 Addressing Modes
Defining Types of data expression Dn [name] expression Dn [name]
Symbolic Instruction and Addressing
Data Addressing Modes • MOV AX,BX; This instruction transfers the word contents of the source-register(BX) into the destination register(AX). • The source.
8086 MICROPROCESSOR PROGRAMMING – INTEGER INSTRUCTIONS AND COMPUTATIONS Amar Saraswat.
Chapter 4 Data Movement Instructions
Intel 8088 (8086) Microprocessor Structure
8086 Registers Module M14.2 Sections 9.2, 10.1.
Morgan Kaufmann Publishers Computer Organization and Assembly Language
32-bit instruction mode(80386-Pentium 4 only)
Symbolic Instruction and Addressing
Symbolic Instruction and Addressing
3.6 Data transfer Instructions
Lecture 06 Programming language.
Computer Architecture CST 250
Data Movement Instructions
Unit-I 80386DX Architecture
Chapter 6 –Symbolic Instruction and Addressing
Presentation transcript:

Khaled A. Al-Utaibi

 Introduction  The MOV Instruction  The LEA Instruction  The Stack Instructions  The String Data Transfer Instructions  The I/O Instructions

 The data movement instructions that is covered in these slides are listed below: − MOV − LEA − PUSH − POP − MOVSB / MOVSW − LODSB / LODSW − STOSB / STOSW − IN − OUT

 The general format of a MOV instruction is − MOV destination, source  The MOV instruction copies the contents of the source operand into the destination operand.  All allowed combinations of the two operands are listed below: − Register, Memory(e.g., MOV AX, LIST) − Memory, Register(e.g., MOV LIST, AX) − Register, Register(e.g., MOV AX, BX) − Memory, Immediate(e.g., MOV LIST, 4) − Register, Immediate(e.g., MOV AX, 4) − Segment Register, Memory(e.g., MOV ES, LIST) − Memory, Segment Register(e.g., MOV LIST, ES) − Register, Segment Register(e.g., MOV AX, DS) − Segment Register, Register(e.g., MOV DS, AX)

 The following actions are not allowed with the MOV instruction: − Set the value of the code segment register (CS).  MOV CS, 1000H(Not Allowed) − Copy the value of one segment register to another segment register (should copy to a general register first).  MOV ES, DS(Not allowed)  MOV AX, DS(Use a general register, e.g., AX)  MOV ES, AX − Copy an immediate value to a segment register (should copy to a general register first).  MOV DS, 1000H(Not allowed)  MOV AX, 1000H (Use a general register, e.g., AX)  MOV DS, AX

 The general format of a LEA instruction is − LEA destination, source − Where:  destination is a 16-bit general-purpose register, and  source is a memory reference  The LEA instruction is not, strictly speaking, a data transfer instruction.  It transfers the offset of a datum, not its contents, a destination operand.  Example: LEA AX, VarName

 The stack instructions are important instructions that store and retrieve data from the LIFO (last- in, first-out) stack memory.  The 8086 processor supports 4 stack instructions: − PUSH − POP − PUSF (Push Flag Register) − POPF (Pop Flag Register)

 The general format of a PUSH instruction is − PUSH operand  The PUSH instruction stores the contents of the operand (16-bits) on the stack.  Allowed operands of the PUSH instruction are listed below: − Register(e.g., PUSH AX) − Segment Register(e.g., PUSH DS) − Memory (Word-Sized)(e.g., PUSH MyData)

 When an operand (2-bytes) is pushed in the stack the following steps occur: − The first (most-significant) data byte moves to the stack segment memory location addressed by (SP-1) − The second (least-significant) data byte moves into the stack segment memory location addressed by (SP-2) − After the data are stored by a PUSH, the contents of the SP register decrement by 2.  Figure 1 shows the operation of the PUSH AX instruction.  This instruction copies the contents of AX onto the stack where address SS:[SP-1]=AH and SS:[SP-2]=AL, and afterwards (SP-2)

Figure 1: The effect of the PUSH AX instruction on ESP and stack memory locations 37FFH and 37FEH. This instruction is shown at the point after execution.

 The general format of a POP instruction is − POP operand  The POP instruction removes 2 bytes from the top of the stack and stores them into the operand (16-bits).  Allowed operands of the POP instruction are listed below: − Register(e.g., POP AX) − Segment Register(e.g., POP DS) − Memory (Word-Sized)(e.g., POP MyData)

 When data (2-bytes) are popped from the stack the following steps occur: − The first byte of data removed from the stack memory location addressed pointed by SP and is placed into the lower portion of the operand (e.g. BL) − The second byte is removed from stack segment memory location (SP+1) and is placed into upper portion of the operand (e.g. BH) − After removing the 2 bytes from the stack, the contents of the SP register incremented by 2.  Figure 2 shows how the POP BX instruction removes data from the stack and places them into register BX.

Figure 2: The POP BX instruction, showing how data are removed from the stack. This instruction is shown after execution.

 There are 6 string data transfer instructions in 8086 processor: − MOVSB / MOVSW − LODSB / LODSW − STOSB / STOSW.  Each string instruction allows data transfers that are either a single byte or a word.  Before the string instructions are presented, the operation of the direction flag-bit (DF), DI, and SI must be understood as they apply to the string instructions.

 The direction flag (DF, located in the flag register) selects the auto-increment (DF = 0) or the auto- decrement operation (DF = 1) for the DI (Destination Index) and SI (Source Index) registers during string operations.  The direction flag is used only with the string instructions (i.e., MOVSB, MOVSW, LODSB, LODSW, STOSB, STOSW).  The CLD instruction clears the DF (DF = 0) flag and the STD instruction sets it (DF = 1).  Therefore, the CLD instruction selects the auto- increment mode and STD selects the auto- decrement mode.

 Whenever a string instruction (e.g. MOVSTB, LODSB, STOSB) transfers a byte, the contents of DI and/or SI are incremented or decremented by 1.  If a word is transferred using a string instruction (e.g. MOVSW, LODSW, STOSW), the contents of DI and/or SI are incremented or decremented by 2.  Only the actual registers used by the string instruction are incremented or decremented.  For example, the STOSB instruction uses the DI register to address a memory location.  When STOSB executes, only the DI register is incremented or decremented without affecting SI.  The same is true of the LODSB instruction, which uses the SI register to address memory data.  A LODSB instruction will only increment or decrement SI without affecting DI.

 During the execution of a string instruction, memory accesses occur through either or both of the DI and SI registers.  The DI offset address accesses data in the extra segment for all string instructions that use it.  The SI offset address accesses data, by default, in the data segment.

 The general format of a MOVSB (Move String of Bytes) instruction is − MOVSB  The MOVSB copies the contents of the byte of memory at DS:[SI] into the byte of memory at ES:[DI].  It also automatically increments/decrements the contents of both SI and DI registers.  The MOVSB instruction works as follows: − byte(ES:[DI]) = byte(DS:[SI]) − if (DF = 0) then − SI = SI + 1 − DI = DI + 1 − else − SI = SI - 1 − DI = DI - 1

 The general format of a MOVSW (Move String of Words) instruction is − MOVSW  The MOVSW copies the contents of the word of memory at DS:[SI] into the word of memory at ES:[DI].  It also automatically increments/decrements the contents of both SI and DI registers by 2.  The MOVSW instruction works as follows: − word(ES:[DI]) = word(DS:[SI]) − if (DF = 0) then − SI = SI + 2 − DI = DI + 2 − else − SI = SI - 2 − DI = DI - 2

 The general format of a LODSB (Load String of Bytes) instruction is − LODSB  The LODSB copies the contents of the byte of memory at DS:[SI] into the AL register.  It also automatically increments/decrements the contents of the SI register.  The LODSB instruction works as follows: − AL = byte(DS:[SI]) − if (DF = 0) then − SI = SI + 1 − else − SI = SI - 1

 The general format of a LODSW (Load String of Words) instruction is − LODSW  The LODSW copies the contents of the word of memory at DS:[SI] into the AX register.  It also automatically increments/decrements the contents of the SI register AX by 2.  The LODSW instruction works as follows: − AX = word(DS:[SI]) − if (DF = 0) then − SI = SI + 2 − else − SI = SI - 2

 The general format of a STOSB(Store String of Bytes) instruction is − STOSB  The STOSB copies the contents of the AL register into the byte of memory at ES:[DI].  It also automatically increments/decrements the contents of the DI register.  The STOSB instruction works as follows: − byte(ES:[DI]) = AL − if (DF = 0) then − DI = DI + 1 − else − DI = DI - 1

 The general format of a STOSW(Store String of Words) instruction is − STOSW  The STOSW copies the contents of the AX register into the word of memory at ES:[DI].  It also automatically increments/decrements the contents of the DI register by 2.  The STOSW instruction works as follows: − word(ES:[DI]) = AX − if (DF = 0) then − DI = DI + 2 − else − DI = DI - 2

 The IN and OUT instructions are used for information transfer through the I/O ports.  The 8086 processor supports 2 16 = 65,536 ports.  The ports are numbered from 0000-FFFFH.  Each I/O port can transfer 1 byte of data.  The I/O ports are usually connected to peripheral devices such as the keyboard, video controller, and disk drives.

 The IN (Input) instruction has 4 forms: − IN AL, immediate − IN AL, DX − IN AX, immediate − IN AX, DX  If the source operand is an immediate value, it identifies a port whose number must be in the range 00-FFH.  If the source operand is the DX register, the contents of the DX register identify a port whose number can be in the range 0000-FFFFH.

 If the destination operand of an IN instruction is the AL register, the contents of the AL register are set to the contents of the datum present at the specified port.  If the destination operand is the AX register, the contents of the AL register are the contents of the datum present at the specified port, and the contents of the AH register are set to the contents of the datum present at the port of the next higher number.

 The operation of the Instruction IN AL, 4 is as follows: − AL = byte(Input Port # 4)  The operation of the Instruction IN AX, 4 is as follows: − AL = byte(Input Port # 4) − AH = byte(Input Port # 5)

 The OUT(Output) instruction has 4 forms: − OUT immediate, AL − OUT DX, AL − OUT immediate, AX − OUT DX, AX  The OUT instructions specify ports as destination operands and the AL and AX registers as source operands in a manner altogether analogous to that used by the IN instruction.  The only difference between IN and OUT is that the former transfers data from a register to a port while the latter transfer data from a port to a register.

 The operation of the Instruction OUT 4, AL is as follows: − byte(Input Port # 4) = AL  The operation of the Instruction OUT 4, AX is as follows: − byte(Input Port # 4) = AL − byte(Input Port # 5) = AH