Assembly Language Data Movement Instructions. MOV Instruction Move source operand to destination mov destination, source The source and destination are.

Slides:



Advertisements
Similar presentations
Chapter 2 (cont.) An Introduction to the 80x86 Microprocessor Family Objectives: The different addressing modes and instruction types available The usefulness.
Advertisements

There are two types of addressing schemes:
COMP 2003: Assembly Language and Digital Logic
Chapter four – The 80x86 Instruction Set Principles of Microcomputers 2015年5月14日 2015年5月14日 2015年5月14日 2015年5月14日 2015年5月14日 2015年5月14日 1 Chapter Four.
16.317: Microprocessor System Design I Instructor: Dr. Michael Geiger Spring 2012 Lecture 8: Data Transfer Instructions.
Chapter 3 Addressing Modes
Lect 3: Instruction Set and Addressing Modes. 386 Instruction Set (3.4) –Basic Instruction Set : 8086/8088 instruction set –Extended Instruction Set :
Data Movement Instructions
Computer Organization And Assembly Language
Assembly Language for Intel-Based Computers Chapter 5: Procedures Kip R. Irvine.
Practical Session 3. The Stack The stack is an area in memory that its purpose is to provide a space for temporary storage of addresses and data items.
8-1 ECE 424 Design of Microprocessor-Based Systems Haibo Wang ECE Department Southern Illinois University Carbondale, IL x86 Instructions Part.
© 2006 Pearson Education, Upper Saddle River, NJ All Rights Reserved.Brey: The Intel Microprocessors, 7e Chapter 4 Data Movement Instructions by.
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.
Microprocessor Systems Design I
Microprocessor Systems Design I Instructor: Dr. Michael Geiger Spring 2014 Lecture 4: x86 memory.
© 2006 Pearson Education, Upper Saddle River, NJ All Rights Reserved.Brey: The Intel Microprocessors, 7e Chapter 2 The Microprocessor and its Architecture.
Chapter 3: Addressing Modes. Copyright ©2009 by Pearson Education, Inc. Upper Saddle River, New Jersey All rights reserved. The Intel Microprocessors:
Lect 4: Instruction Set and Addressing Modes. 386 Instruction Set (3.4)  Basic Instruction Set : 8086/8088 instruction set  Extended Instruction Set.
CSC 221 Computer Organization and Assembly Language
CEG 320/520: Computer Organization and Assembly Language ProgrammingIntel Assembly 1 Intel IA-32 vs Motorola
CDP ECE Spring 2000 ECE 291 Spring 2000 Lecture 7: More on Addressing Modes, Structures, and Stack Constantine D. Polychronopoulos Professor, ECE.
The x86 Architecture Lecture 15 Fri, Mar 4, 2005.
ECE291 Computer Engineering II Lecture 3 Josh Potts University of Illinois at Urbana- Champaign.
UHD:CS2401: A. Berrached1 The Intel x86 Hardware Organization.
Addressing Modes of 8086 Processor Ammar Anwar Khan Electrical Engineer King Saud University Riyadh Saudi Arabia.
(-133)*33+44* *33+44*14 Input device memory calculator Output device controller Control bus data bus memory.
Chapter 2 Parts of a Computer System. 2.1 PC Hardware: Memory.
ECE291 Computer Engineering II Lecture 3 Josh Potts University of Illinois at Urbana- Champaign.
Computers organization & Assembly Language Chapter 1 THE 80x86 MICROPROCESSOR.
ECE291 Computer Engineering II Lecture 3 Dr. Zbigniew Kalbarczyk University of Illinois at Urbana- Champaign.
University of Tehran 1 Microprocessor System Design Omid Fatemi Machine Language Programming
MOV Instruction MOV destination,source  MOV AX,BX  MOV SUM,EAX  MOV EDX,ARRAY[EBX][ESI]  MOV CL,5  MOV DL,[BX]
Khaled A. Al-Utaibi  Introduction  The MOV Instruction  The LEA Instruction  The Stack Instructions  The String Data Transfer.
CSC 221 Computer Organization and Assembly Language Lecture 15: STACK Related Instructions.
Internal Programming Architecture or Model
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.
Microprocessors CSE- 341 Dr. Jia Uddin Assistant Professor, CSE, BRAC University Dr. Jia Uddin, CSE, BRAC University.
Data Movement Instructions A Course in Microprocessor Electrical Engineering Department Universitas 17 Agustus 1945 Jakarta.
Stack Operations Dr. Hadi AL Saadi.
Instruction set Architecture
Microprocessor Systems Design I
COURSE OUTCOMES OF MICROPROCESSOR AND PROGRAMMING
Microprocessor Systems Design I
Microprocessor and Assembly Language
Chapter 4 Data Movement Instructions
EE3541 Introduction to Microprocessors
Basic Microprocessor Architecture
Assembly IA-32.
ADDRESSING MODES.
Chapter 3 Addressing Modes
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 Registers Module M14.2 Sections 9.2, 10.1.
CS-401 Computer Architecture & Assembly Language Programming
Morgan Kaufmann Publishers Computer Organization and Assembly Language
32-bit instruction mode(80386-Pentium 4 only)
Symbolic Instruction and Addressing
CS 301 Fall 2002 Computer Organization
Chapter 3: Addressing Modes
Practical Session 4.
The Microprocessor & Its Architecture
Symbolic Instruction and Addressing
3.6 Data transfer Instructions
Lecture 06 Programming language.
Computer Architecture CST 250
EECE.3170 Microprocessor Systems Design I
Chapter 6 –Symbolic Instruction and Addressing
CSC 497/583 Advanced Topics in Computer Security
Presentation transcript:

Assembly Language Data Movement Instructions

MOV Instruction Move source operand to destination mov destination, source The source and destination are often called operands MOV AX, BX instruction –transfers the word contents of the source register (BX) into the destination register (AX) –the leftmost 16 bits of register EAX does not affected –the source register’s contents BX do not change Source and destination operands can vary (Register, Memory, Immediate, …etc)

MOV Instruction..Rules Rules –Both operands must be of same size –No memory to memory moves –No segment to segment moves –EAX, EBX, ECX, EDX, ESP, EBP, EDI,ESI, CS, ES, DS, SS, FS, and GS registers can be used –Destination cannot be CS, EIP, or IP –No immediate to segment moves –MOV instructions not affect the flag bits.

Addressing modes Define how machine language instructions identify the operand(s) of each instruction Addressing Mode Type: –Register  MOV AX,BX –Immediate  MOV CH,3AH –Direct  MOV [1234H],AX –Register indirect  MOV [BX],CL –Base-plus-index  MOV [BX+SI],BP –Register relative  MOV CL,[BX+4] –Scaled index  MOV [EBX+2 × ESI],AX

Examples of register-addressed instructions

Examples of immediate addressing

Direct addressed instructions

Examples of register indirect addressing

Examples of base-plus-index addressing

Examples of register relative addressing

MOVZX Instruction MOVZX (move and zero-extend) –Fills (extends) the upper part of the destination with zeros –Used to copy a small source into a larger destination –Destination must be a register –movzx ax, cl

MOVSX Instruction MOVSX (move and sign-extend) –Fills (extends) the upper part of the destination register with a copy of the source operand's sign bit –Used to copy a small source into a larger destination – movsx ax, bl

XCHG Instruction XCHG exchanges the values of two operands xchg reg, reg xchg reg, mem xchg mem, reg xchg ah, al ; exchange 8-bit regs xchg ax, bx ; exchange 16-bit regs Rules Operands must be of the same size At least one operand must be a register No immediate operands are permitted

Load Effective Address Instructions There are several load-effective address instructions in the microprocessor instruction set ( LEF, LDS, LES,LFS,LSS,LGS) LEF : loads a 16- or 32-bit register with the offset address of the data specified by the operand –LEA BX,[DI] loads the offset address specified by [DI] (contents of DI) into the BX register BUT –MOV BX,[DI] loads the data stored at the memory location addressed by [DI] into register BX –LEA BX, 3[BX]  BX=BX+3 ; ADD Plus Move –LEA AX,NUMB Loads AX with the offset address of NUMB –The OFFSET directive performs the same function as an LEA instruction MOV BX,OFFSET LIST performs the same function as LEA BX,LIST

LDS, LES, LFS, LGS, and LSS The LDS, LES, LFS, LGS, and LSS instructions let you load a 16 bit general purpose register and segment register pair with a single instruction LxS dest, source lds reg16, mem32 Reg16 :is any general purpose 16 bit register and mem32: is a double word memory location reg16 = [mem32], ds = [mem32 + 2] The LDS and LES instructions are the only instructions that directly process values larger than 32 bits.

LDS Example

Assembly Example

The PUSH and POP instructions The PUSH and POP instructions are important instructions that store and retrieve data from the LIFO (last-in, first-out) stack memory The microprocessor has six forms of the PUSH and POP instructions –push reg 16 pop reg 16 –push reg 32 pop reg 32 –push segreg pop segreg (except CS) –push memory pop memory –push immediate_data –Pusha popa –Pushad popad –Pushf popf –Pushfd popfd The stack memory it is always in the stack segment (wherever ss points) The stack grows down in memory Stack pointer (ss:sp) always contains the address of the value on the top of the stack

Push instruction Push instructions (16 bits) –sp=sp-2 –store 16-bit register operand at location SS:SP –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 push instructions (32 bits) –SP := SP - 4 –[SS:SP] = 32 bit operand pop instructions (16 bits): –16-bit operand = [SS:SP] –SP = SP + 2 pop instructions (32 bits): –32 bit operand = [SS:SP] –SP = SP + 4

Push example Push AX Before execution the instruction

Push examples The word ptr operator force 16 bit operation or we can use PushD The dword ptr operator force 32 bit operation When push 32-bit immediate can use: –PUSH 0045H –PUSHD 0045H

POP Examples Suppose that a POP BX instruction executes –The first byte of data removed from the stack (the memory location addressed by SP in the stack segment) moves into register BL –The second byte is removed from stack segment memory location SP - 1and is placed into register BH –After both bytes are removed from the stack, the SP register is incremented by 2.

PUSHA Instruction PUSHA (push all) instruction copies the 16-bit registers to the stack in the following order: AX,CX, DX, BX, SP, BP, SI, and DI The value for SP that is pushed onto the stack is whatever it was before the PUSHA instruction executed The POPA (pop all) instruction removes 16 bytes of data from the stack and places them into the following registers, in the order shown: DI, SI, BP, SP, BX, DX, CX, and AX PUSHA instruction requires 16 bytes of stack memory space to store all eight 16-bit registers –Ex.: PUSHA (no operands) –After PUSHA instruction the sp=sp-16 The PUSHAD instruction places the 32-bit register set on the stack : EAX,ECX, EDX, EBX, ESP, EBP, ESI, and EDI PUSHAD requires 32 bytes of stack storage space.

PUSHF instruction The PUSHF and POPF instructions allow you to push/pop the processor status register (the flags register) into stack –The POPF (pop flags) instruction removes a 16-bit number from the stack and places it into the flag register The PUSHFD and POPFD instructions allow you to push/pop the EFLAG register into stack –The POPFD removes a 32-bit number from the stack and places it into the extended flag register