Computer Architecture 1 ح 303

Similar documents
Chapter Three Addressing Mode MOV AX, BX

3- ADDRESSING MODES in 8086: In this section we use the MOV instruction to describe the data-addressing modes. Figure 3-1 shows the MOV instruction.

Code segment Stack segment

4- MACHINE LANGUAGE CODING 4-1THE INSTRUCTION SET:

INSTRUCTOR: ABDULMUTTALIB A. H. ALDOURI

8088/8086 Programming Integer Instructions and Computations

EC 333 Microprocessor and Interfacing Techniques (3+1)

VARDHAMAN COLLEGE OF ENGINEERING (AUTONOMOUS) Shamshabad, Hyderabad

Intel 8086: Instruction Set

Assembly Language Each statement in an assembly language program consists of four parts or fields.

Introduction to Microprocessor

Chapter 4: Data Movement Instructions. 4 1 MOV Revisited

Addressing Modes on the x86

MICROPROCESSOR TECHNOLOGY

Basic characteristics & features of 8086 Microprocessor Dr. M. Hebaishy

Week /8086 Microprocessor Programming I

EEM336 Microprocessors I. Data Movement Instructions

Assembling, Linking and Executing 1) Assembling: .obj obj .obj.lst .crf Assembler Types: a) One pass assembler:

Microprocessor. By Mrs. R.P.Chaudhari Mrs.P.S.Patil

Module 3 Instruction Set Architecture (ISA)

Data Movement Instructions

ASSEMBLY LANGUAGE PROGRAMMING OF THE MICROCOMPUTER

CS401 Assembly Language Solved MCQS From Midterm Papers

The Instruction Set. Chapter 5

ORG ; TWO. Assembly Language Programming

UMBC. A register, an immediate or a memory address holding the values on. Stores a symbolic name for the memory location that it represents.

Intel 8086 MICROPROCESSOR ARCHITECTURE

8086 INTERNAL ARCHITECTURE

Intel 8086 MICROPROCESSOR. By Y V S Murthy

CC411: Introduction To Microprocessors

EXPERIMENT WRITE UP. LEARNING OBJECTIVES: 1. Get hands on experience with Assembly Language Programming 2. Write and debug programs in TASM/MASM

Microprocessor and Assembly Language Week-5. System Programming, BCS 6th, IBMS (2017)

Chapter 3: Addressing Modes

Arithmetic Instructions

6/20/2011. Introduction. Chapter Objectives Upon completion of this chapter, you will be able to:

Computer Organization & Assembly Language Programming. CSE 2312 Lecture 15 Addressing and Subroutine

Program controlled semiconductor device (IC) which fetches (from memory), decodes and executes instructions.

SRI VENKATESWARA COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF ECE EC6504 MICROPROCESSOR AND MICROCONTROLLER (REGULATION 2013)

Lecture 5: Computer Organization Instruction Execution. Computer Organization Block Diagram. Components. General Purpose Registers.

Microcomputer Architecture..Second Year (Sem.2).Lecture(2) مدرس المادة : م. سندس العزاوي... قسم / الحاسبات


CS401 - Computer Architecture and Assembly Language Programming Glossary By

icroprocessor istory of Microprocessor ntel 8086:

1. Introduction to Assembly Language

ADVANCE MICROPROCESSOR & INTERFACING

3.1 DATA MOVEMENT INSTRUCTIONS 45

UNIT 2 PROCESSORS ORGANIZATION CONT.

Marking Scheme. Examination Paper Department of CE. Module: Microprocessors (630313)

EEM336 Microprocessors I. Addressing Modes

EC-333 Microprocessor and Interfacing Techniques

Ex: Write a piece of code that transfers a block of 256 bytes stored at locations starting at 34000H to locations starting at 36000H. Ans.

Lecture 5:8086 Outline: 1. introduction 2. execution unit 3. bus interface unit

Chapter 02: Computer Organization. Lesson 02: Functional units and components in a computer organization- Part 1: Processor

Mr. Sapan Naik 1. Babu Madhav Institute of Information Technology, UTU

Q1: Multiple choice / 20 Q2: Memory addressing / 40 Q3: Assembly language / 40 TOTAL SCORE / 100

COMPUTER ORGANIZATION & ARCHITECTURE

The Microprocessor and its Architecture

A4 Sample Solution Ch3

Assignment no:4 on chapter no :3 : Instruction set of 8086

Assembly Language. Dr. Esam Al_Qaralleh CE Department Princess Sumaya University for Technology. Overview of Assembly Language

MICROPROCESSOR PROGRAMMING AND SYSTEM DESIGN

9/25/ Software & Hardware Architecture

MODE (mod) FIELD CODES. mod MEMORY MODE: 8-BIT DISPLACEMENT MEMORY MODE: 16- OR 32- BIT DISPLACEMENT REGISTER MODE

Babu Madhav Institute of Information Technology, UTU

Computer Processors. Part 2. Components of a Processor. Execution Unit The ALU. Execution Unit. The Brains of the Box. Processors. Execution Unit (EU)

Signed number Arithmetic. Negative number is represented as

CHETTINAD COLLEGE OF ENGINEERING AND TECHNOLOGY COMMUNICATION ENGINEERING REG 2008 TWO MARKS QUESTION AND ANSWERS

Northern India Engineering College, Delhi (GGSIP University) PAPER I

EE 314 Spring 2003 Microprocessor Systems

BAHAR DÖNEMİ MİKROİŞLEMCİLER LAB3 FÖYÜ

16-Bit Intel Processor Architecture

MPID MICROPROCESSOR AND ITS INTERFACING DEVICES EEE III II SEMESTER OBJECTIVE QUESTIONS

EC-333 Microprocessor and Interfacing Techniques

SPRING TERM BM 310E MICROPROCESSORS LABORATORY PRELIMINARY STUDY

SPRING TERM BM 310E MICROPROCESSORS LABORATORY PRELIMINARY STUDY

Real instruction set architectures. Part 2: a representative sample

16.317: Microprocessor Systems Design I Fall 2013

We can study computer architectures by starting with the basic building blocks. Adders, decoders, multiplexors, flip-flops, registers,...

Advanced Microprocessors

PESIT Bangalore South Campus

Experiment 3 3 Basic Input Output

Arithmetic and Logic Instructions And Programs

A Presentation created By Ramesh.K Press Ctrl+l for full screen view

CS-202 Microprocessor and Assembly Language

EC 333 Microprocessor and Interfacing Techniques (3+1)

16.317: Microprocessor Systems Design I Spring 2014

Chapter 11. Addressing Modes

Interfacing Compiler and Hardware. Computer Systems Architecture. Processor Types And Instruction Sets. What Instructions Should A Processor Offer?

CS401 Assembly Language Solved Subjective MAY 03,2012 From Midterm Papers. MC

Experiment 8 8 Subroutine Handling Instructions and Macros

Computer Organization CS 206 T Lec# 2: Instruction Sets

Homework 2. Lecture 6: Machine Code. Instruction Formats for HW2. Two parts: How to do Homework 2!!!!

Assembler Programming. Lecture 2

Hardware and Software Architecture. Chapter 2

Lecture 15 Intel Manual, Vol. 1, Chapter 3. Fri, Mar 6, Hampden-Sydney College. The x86 Architecture. Robb T. Koether. Overview of the x86

UNIT III MICROPROCESSORS AND MICROCONTROLLERS MATERIAL OVERVIEW: Addressing Modes of Assembler Directives. Procedures and Macros

Internal architecture of 8086

PHI Learning Private Limited

INTRODUCTION TO MICROPROCESSORS

Mnem. Meaning Format Operation Flags affected ADD Addition ADD D,S (D) (S)+(D) (CF) Carry ADC Add with ADC D,C (D) (S)+(D)+(CF) O,S,Z,A,P,C

Transcription:

Lecture 4 A. Addressing MODES 1. Introduction to assembly language programming: Program is a sequence of commands used to tell a microcomputer what to do. Each command in a program is an instruction Programs must always be coded in machine language before they can be executed by the microprocessor. A program written in machine language is often referred to as machine code. Machine code is encoded using 0s and 1s A single machine language instruction can take up one or more bytes of code In assembly language, each instruction is described with alphanumeric symbols instead of with 0s and 1s Instruction can be divided into two parts : its opcode and operands Opcode identify the operation that is to be performed. Each opcode is assigned a unique letter combination called a mnemonic. Operands describe the data that are to be processed as the microprocessor carried out the operation specified by the opcode. Instruction set includes 1. Data transfer instructions 2. Arithmetic instructions 3. Logic instructions 4. String manipulation instructions 5. control transfer instructions 6. Processor control instructions. As an example for instructions, next section discusses the MOV instruction. 2. The MOV instruction: The move instruction is one of the instructions in the data transfer group of the 8086 instruction set. Execution of this instruction transfers a byte or a word of data from a source location to a destination location. Fig 1 shows the general format of MOV instruction and the valid source and destination variations. 1

2 Fig 1 The MOV instruction and the valid source and destination variations 3. Addressing modes: An addressing mode is a method of specifying an operand. The 8086 addressing modes categorized into three types: 3.1 Register operand addressing mode With register operand addressing mode, the operand to be accessed is specified as residing in an internal register. MOV AX, BX 3.2 Immediate operand addressing mode With Immediate operand addressing mode, the operand is part of the instruction instead of the contents of a register of a memory location. MOV AL, 15H Operand is part of instruction Operand = address field e.g. ADD 5 o Add 5 to contents of accumulator o 5 is operand No memory reference to fetch data Fast Limited range 3.3 Memory Operand addressing modes: the 8086 use this mode to reference an operand in memory. The 8086 must calculate the physical address of the operand and then initiate a read of write operation of this storage location. The physical address of the operand is calculated from a segment base address (SBA) and an effective address (EA). This mode includes five types: 3.3.1 Direct addressing: the value of the effective address is encoded directly in the instruction. MOV CX, [1234H] Address field contains address of operand Effective address (EA) = address field (A) e.g. ADD A Add contents of cell A to accumulator Look in memory at address A for operand

Single memory reference to access data No additional calculations to work out effective address Limited address space 3.3.2 indirect addressing: this mode is similar to the direct addressing but the offset is specified in a base register (BX), base pointer (BP) or an index register (SI or DI) within the 8086. MOV AX, [SI] Memory cell pointed to by address field contains the address of (pointer to) the operand EA = (A) Look in A, find address (A) and look there for operand e.g. ADD (A) Add contents of cell pointed to by contents of A to accumulator Note that if BP is used instead of BX, the calculation of the physical address is performed using the contents of the stack segment (SS) register instead of DS. 3 3.3.3 Based addressing: this mode, the effective address is obtained by adding a direct or indirect displacement to the contents of either base register BX of Base pointer register BP. MOV [BX]+1234H, AL 3.3.4 Indexed addressing: this mode, work in similar manner to that of the based addressing mode but the effective address is obtained by adding the displacement to the value in an index register (SI or DI). MOV AL, [SI]+1234H Note that The displacement could be 8 bits or 16 bits 3.3.5 Based-Indexed addressing: this mode combines the based addressing mode and indexed addressing mode.

MOV AH, [BX][SI]+1234H Note that if BP is used instead of BX, the calculation of the physical address is performed using the contents of the stack segment (SS) register instead of DS. Note that The displacement could be 8 bits or 16 bits B. 8086 programming-integer instructions and computations 1. Data transfer instructions: (a)mov instruction (b)xchg Instruct Fig (a) XCHG data transfer instruction (b) Allowed operands Example 1: For the figure below. What is the result of executing the following instruction? XCHG AX, [0002] (c) XLAT: 4 Fig (a) XLAT data transfer instruction

Example 2: For the figure below, what is the result of executing the following instruction? XLAT (d)lea, LDS, and LES instructions: Fig (a) LEA, LDS and LES data transfer instruction Example 3: For the figure below, what is the result of executing the following instruction? LEA SI, [ DI + BX + 2H] SI= (DI) + ( BX) + 2H = 0062H Example 4: For the figure below, what is the result of executing the following instruction? LDS SI, [ DI + BX + 2H] SI= (DI) + (BX) + 2H = 0062H 5

Example 6:What is the result after executing each one of the next instructions? LEA BP, [F004] MOV BP, F004 MOV BP, [F004] The instruction LES is similar to the instruction LDS except that it load the Extra Segment Register instead of Data Segment Register 2. Arithmetic instruction: The 8086 microprocessor can perform addition operation between any two registers except segment register ( CS, DS, ES, and SS) and instruction pointer (IP). Addition must occur between similar sizes Addition can occur between register and memory Example 4: For the figure below, What is the result of executing the following instruction? What is the addressing mode for this instruction? What is the PA is BP register used instead of BX register? 6

ADD AX, [ DI + BX + 2H] EA= [ DI + BX + 2H] =[0020 + 0040 + 02H ]= 0062H PA = (DS 10H) + EA = 1000H +0062H= 1062H Memory word stored at location 1062H is 9067 AX = AX + 9067 The addressing mode for this instruction is Based Indexed mode. If BP used in the EA, then PA = (SS 10H) + 0062 = 2000H +0062H= 2062H (a) Addition instructions (b) Allowed operands for ADD and ADC. (c) Allowed operands for INC instruction The instruction add with carry (ADC) work similarly to ADD, but in this case the content of the carry flag is also added, that is (S) + (D) + (CF) (D) ADC is primarily used for multiword add operation. Example 8: let num1=11223344h and num2=55667788h are stored at memory locations 200 and 300 respectively in the current data segment. ADD num1 and num2 and store the result at memory location 400. 7

MOV AX, [0200] MOV BX, [0202] ADD AX, [0300] ADC BX, [0302] MOV [0400], AX MOV [0402], BX INC instruction add 1 to the specified operand Note that the INC instruction don t affect the carry flag Example 9: For the figure below, what is the result of executing the following instructions? INC WORD PTR [0040] INC BYTE PTR [0042] SI= (DI) + (BX) + 2H = 0062H AAA instruction specifically used to adjust the result after the operation of addition two binary numbers which represented in ASCII. AAA instruction should be executed immediately after the ADD instruction that adds ASCII data. Since AAA can adjust only data that are in AL, the destination register for ADD instructions that process ASCII numbers should be AL. Example 10: what is the result of executing the following instruction sequence? ADD AL, BL AAA Assume that AL contains 32H (the ASCII code for number 2), BL contain 34H (the ASCII code for number 4), and AH has been cleared. Solution : 8

DAA instruction used to perform an adjust operation similar to that performed by AAA but for the addition of packed BCD numbers. instead of ASCII numbers. Since DAA can adjust only data that are in AL, the destination register for ADD instructions that process BCD numbers should be AL. DAA must be invoked after the addition of two packed BCD numbers. Example 11: what is the result of executing the following instruction sequence? ADD AL, BL DAA Assume that AL contains 29H (the BCD code for decimal number 29), BL contain 13H (the BCD code for decimal number 13), and AH has been cleared. Solution : 9