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

Similar documents
Code segment Stack segment

8086 INTERNAL ARCHITECTURE

Intel 8086 MICROPROCESSOR ARCHITECTURE

9/25/ Software & Hardware Architecture

Intel 8086 MICROPROCESSOR. By Y V S Murthy

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

ELE 3230 Microprocessors and Computer Systems

MICROPROCESSOR PROGRAMMING AND SYSTEM DESIGN

EC-333 Microprocessor and Interfacing Techniques

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

icroprocessor istory of Microprocessor ntel 8086:

Introduction to Microprocessor

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

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

SPRING TERM BM 310E MICROPROCESSORS LABORATORY PRELIMINARY STUDY

UNIT 2 PROCESSORS ORGANIZATION CONT.

CC411: Introduction To Microprocessors

UNIT II OVERVIEW MICROPROCESSORS AND MICROCONTROLLERS MATERIAL. Introduction to 8086 microprocessors. Architecture of 8086 processors

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

Hardware and Software Architecture. Chapter 2

Internal architecture of 8086

VARDHAMAN COLLEGE OF ENGINEERING (AUTONOMOUS) Shamshabad, Hyderabad

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

Lecture (02) The Microprocessor and Its Architecture By: Dr. Ahmed ElShafee

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

EEM336 Microprocessors I. The Microprocessor and Its Architecture

The Microprocessor and its Architecture

Module 3 Instruction Set Architecture (ISA)

Chapter 2 COMPUTER SYSTEM HARDWARE

The 8086 Microprocessor

UNIT-I. 1.Draw and explain the Architecture of a 8085 Microprocessor?

ADVANCE MICROPROCESSOR & INTERFACING

Topic 2 :16 Bit Microprocessor: 8086 (24 Marks)

Addressing Modes on the x86

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

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

UNIT-1. It is a 16-bit Microprocessor (μp).it s ALU, internal registers works with 16bit binary word.

16-Bit Intel Processor Architecture

Architecture of 8086 Microprocessor

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

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

Introduction to IA-32. Jo, Heeseung

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

INTRODUCTION TO IA-32. Jo, Heeseung

Unit I Introduction. Department of Electronics and Communication Engineering VARDHAMAN COLLEGE OF ENGINEERING Shamshabad, Hyderabad , India.

8086 Hardware Specification

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

Chapter 2: The Microprocessor and its Architecture

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

Basic Execution Environment

The x86 Microprocessors. Introduction. The 80x86 Microprocessors. 1.1 Assembly Language

The x86 Architecture

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

WINTER 12 EXAMINATION Subject Code : Model Answer Page No : / N. a) Describe the function of SID and SOD pins of 8085 microprocessor



UNIT 1. Introduction to microprocessor. Block diagram of simple computer or microcomputer.

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

Arithmetic Instructions

Computer Architecture 1 ح 303

1. Introduction to Assembly Language

Complex Instruction Set Computer (CISC)

US06CCSC04: Introduction to Microprocessors and Assembly Language UNIT 1: Assembly Language Terms & Directives

Moodle WILLINGDON COLLEGE SANGLI (B. SC.-II) Digital Electronics

SYSC3601 Microprocessor Systems. Unit 2: The Intel 8086 Architecture and Programming Model

CS401 Assembly Language Solved MCQS From Midterm Papers

Assembler Programming. Lecture 2

Vidyalankar. Vidyalankar T.E. Sem. V [CMPN] Microprocessors Prelim Question Paper Solution. 1. (a)

Basics of Microprocessor

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

Processing Unit CS206T

EE2007 Microprocessor systems.

1. Internal Architecture of 8085 Microprocessor

An 8-Bit Scientific Calculator Based Intel 8086 Virtual Machine Emulator

INTRODUCTION TO MICROPROCESSORS

1-Operand instruction types 1 INC/ DEC/ NOT/NEG R/M. 2 PUSH/ POP R16/M16/SR/F 2 x ( ) = 74 opcodes 3 MUL/ IMUL/ DIV/ DIV R/M

Intel 8086: Instruction Set

The Instruction Set. Chapter 5

CG2007 Microprocessor systems.

Advanced Parallel Architecture Lesson 3. Annalisa Massini /2015

The Pentium Processor

Real instruction set architectures. Part 2: a representative sample

The 80386SX Processor Bus and Real-Mode Instruction Set

8086 Microprocessors & Peripherals

Assembly Language Programming Introduction

Microprocessor (COM 9323)

EC 333 Microprocessor and Interfacing Techniques (3+1)

1 MALP ( ) Unit-1. (1) Draw and explain the internal architecture of 8085.

2. List the five interrupt pins available in INTR, TRAP, RST 7.5, RST 6.5, RST 5.5.

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

Assembly Language. Lecture 2 - x86 Processor Architecture. Ahmed Sallam

Signed number Arithmetic. Negative number is represented as

PESIT Bangalore South Campus

William Stallings Computer Organization and Architecture 10 th Edition Pearson Education, Inc., Hoboken, NJ. All rights reserved.

Class Notes. Dr.C.N.Zhang. Department of Computer Science. University of Regina. Regina, SK, Canada, S4S 0A2

The functional block diagram of 8085A is shown in fig.4.1.

Computer Organization II CMSC 3833 Lecture 33

Processor Structure and Function

Faculty of Engineering Computer Engineering Department Islamic University of Gaza Assembly Language Lab # 2 Assembly Language Fundamentals

Chapter 1: Basics of Microprocessor [08 M]

Transcription:

Lecture 5: Computer Organization Instruction Execution Computer Organization Addressing Buses Fetch-Execute Cycle Computer Organization CPU Control Unit U Input Output Memory Components Control Unit fetches instructions, decodes instructions, causes instructions to be carried out. Arithmetic logical unit (U) performs arithmetic operations (addition, etc.) on data. high speed memory cells (don t need to go through the bus to access). They vary in number and purpose on different machines. Buses communication pathways connecting different devices/components. +5V Clock Interrupt 8086 Block Diagram AX BX CX DX U BH CH DH SI DI BP SP BL CL DL Data Index Control Unit Flags R Instruction Data IP Control Bus Bus Interface Unit CS DS SS ES Address Bus Data Bus 8, 16, or 32 bit high-speed storage locations inside the CPU They can be accessed at a much higher speed than conventional memory. When optimizing for speed, use registers. Four types: general purpose, segment, index, status, and control General Purpose Data registers, also known as general purpose registers: AX, BX, CX, DX Used for arithmetic operations and data movement Can be addressed as 16 bit or 8 bit values. For AX, upper 8 bits are, lower 8 bits are. Remember: when when a 16 bit register is modified, so is the corresponding 8 bit registers! 1

Example 15 0 AX 7 0 7 0 AX 0000 0000 0000 0000 move 0001 1001 1110 0100 to AX AX 0001 1001 1110 0100 move 0011 1101 to AX Special Attributes of GP AX accumulator fastest for arithmetic operations. Some math instructions only use AX. BX base this register can hold an address of a procedure or variable. BX can also perform arithmetic and data movement. CX counter this register acts as a counter for repeating or looping instructions DX data this register has a special role in multiply and divide operations. In multiplication it holds the high 16 bits of the product. In division it holds the remainder. Segment Segment, cont. Segment registers are used as base locations for program instructions, data, and the stack. All references to memory involve a segment register as the base location. CS code segment this register holds the base location of all instructions in a program DS data segment this is the default base location for variables. It is used by the CPU to calculate the variable location. SS stack segment this register contains the base location of the stack. ES extra segment this is an additional base location for memory variables. Index Index registers contain the offsets of data and instructions. Offset refers to the distance of a variable, label, or instruction from its base segment. Index registers are used when processing strings, arrays, and other data structures. Index, cont. BP base pointer this register contains an offset from the SS register and is often used by subroutines to find the variables passed to it on the stack. SP stack pointer this register contains the offset from the top of the stack. The complete top of stack address is calculated using the SP and SS registers. SI source index used to point to data in memory. Named because this is the index register commonly used as the source in string operations (for example) DI - destination index index register commonly used as the destination in string operations 2

Status and Control IP instruction pointer always contains the offset of the next instruction. The IP and CS registers combine to form the complete address. Flags a special register with individual bit positions that give the status of the CPU (control flags) or results of arithmetic operations (status flags). Control Flags Direction flag (DF) affects block data transfer instructions. Indicates if you are moving up (0) or down (1) in memory. Interrupt flag (IF) indicates if system interrupts can occur. Interrupts will be disabled if a critical operation is being performed that can not be interrupted. Trap flag (TF) determines if the CPU is halted after each instruction. If it s set, a debugger will allow single stepping through the program. Status Flags Status Flags, cont. These indicate the status of arithmetic and logical operations. Carry flag (CF) set if the result of an unsigned operation is too big to fit into the destination. 1 = carry, 0 = no carry. Overflow flag (OF) set if the result of a signed operation is too wide to fit into the destination. 1 = overflow, 0 = no overflow. Sign flag (SF) set when the result of an operation is negative. 1 = negative, 0 = positive Zero flag (ZF) set when the result of an arithmetic operation is zero. Used by branch and loop instructions when comparing values. 1 = zero, 0 = not zero. Auxiliary Carry set when an operation causes a carry from bit 3 to bit 4 or a borrow from bit 4 to bit 3. 1= carry, 0 = no carry. Parity indicates if the result of an operation has an even or odd number of bits. Used to verify memory integrity or correct transmission of data. CPU: Instruction Cycle Addressing Three basic operations: Fetch: fetches the instruction, copying it from memory into the instruction queue, and increments the PC (program counter) Decode: control unit determines the type of the instruction. Retrieves any needed operands and sends them to the U. Also sends the U signals to indicate the type of operation. Execute: U executes the instruction, returns output to the destination, and update the status flags. Each step takes one click of the system clock: one clock cycle. Address: a number referring to an 8- bit memory location Logical addresses go from 0 to the highest location How these are translated into physical addresses varies. For Intel: 32-bit segment-offset address: combination of base location (segment) and offset to represent a logical location 20-bit absolute address, which refers to a physical memory location 3

Addressing, cont. Why Segment-Offset? Problem: how to address 1,048576 bytes of memory with a 16-bit wide address register (where the max is 65,535) Solution: combine segment and offset values to obtain the absolute address Example: 08F1:0100 1) convert segment to absolute by adding 4 zero bits: 08F10 2) add the offset: 0100 (hex) 0 8 F 1 0 -- segment value w/extra 4 0 bits + 0 1 0 0 -- add the offset 0 9 0 1 0 -- obtain the absolute address (effective address) You can load the program at any segment address and individual variable addresses to not need to be recalculated. Why? Variable locations are 16-bit offsets from the program s data area. This is known as being segment relocatable. Programs can access large data structures by modifying the segment portion of the data s address to point to new blocks of memory. FFFFF 00000 Data Segment addressable memory on 8086 Example: DS = 0100h data seg. start? data seg. end? If BX contains the offset: BX = 005Ah EA =? Segment Register Combinations Code Segment the CS register and IP (instruction pointer) are used to point to the next instruction. Stack the SS register is used with the SP (stack pointer) or BP (base pointer) Data Segment DS with BX, SI, or DI Extended Segment BX, SI, or DI More on Effective Addresses There s more than one way to get the same effective address! Example: CS = 147Bh IP = 131Ah EA = 147B0 + 131A = 15ACAh If CS = 147B, what range of effective addresses can be referenced without changing the value in CS? or CS = 15ACh IP = 000Ah EA = 15AC + 000A = 15ACAh 4

Buses System Buses Communication pathway connecting devices. Set of parallel wires (lines) connecting components. Serial over time, a sequence of binary digits can be passed along a single line. Parallel one line for each bit (8-bit unit of data can be transmitted over 8 bus lines). The number of bits is called the bus width Connects major components (CPU, memory, I/O) Data bus used for sending data between CPU/memory. Usually as many lines as bits in a word. Address bus when CPU wants to read/write memory, needs to tell memory which word it wants to access. Usually same number of lines as address size (20 bits for us) Control bus tells memory whether CPU wants to read or write. Transmits both commands (operation to be performed) and timing information. Control Lines Example: memory read memory write I/O read I/O write Intel CPU & Co-Processor Bus request use these to determine Bus grant who is master Transfer ACK Interrupt request Interrupt ACK Clock (syncronous operations) Reset (init. all modules) Operation of Bus One module wants to send data to another: 1. obtain use of bus 2. transfer data via the bus One module wishes to request data from another 1. obtain use of the bus 2. transfer request to the other module over appropriate address and control lines 3. wait for the other module to send data Shared transmission medium! Signal transmitted by one device is available to all Only one device at a time can successfully transmit or signals will be garbled. Example Pins on the 8086 GND 1 40 VCC Fetching an instruction: CPU puts the address of the instruction on the address pins Asserts memory read Memory replies by putting instruction on data pins Asserts a signal that it s done (READY) When CPU sees the signal, it accepts the word and carries out the instruction. D14/A14 D13/A13 D12/A12 D11/A11 D10/A10 D9/A9 D8/A8 D7/A7 D6/A6 D5/A5 D4/A4 D3/A3 D2/A2 D1/A1 D0/A0 NMI INTR CLK 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 8086 CPU 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 A15/D15 A16/S3 A17/S4 A18/S5 A19/S6 MN/MX RD RQ/GT0 R/GT1 LOCK S2 S1 S0 QS0 INTA TEST READY GND 20 21 RESET 5

Pin Explanations S0-S2 Bus Control INTA, I/O read, I/O write, HT, code access, memory read, memory write, release bus S3-S6, QS0-QS1 Status of internal state (not normally used) RD read cycle taking place LOCK leave bus alone (curing critical CPU instructions that require multiple bus cycles) READY when CPU asks for a byte from memory, memory is expected to deliver within 4 bus cycles. If memory is too slow, it negates Ready and keeps it negated until the byte is put on the bus. RQ/Grant bus arbitration (for example: between CPU and co-processor) A0-A19 address bus D0-D15 data bus Example Example: CPU executes instruction to fetch contents of word D0126 from memory CPU puts D0126 on address bus 1101 0000 0001 0010 0110 At the same time, asserts memory read on control bus (using pins 26-28 on diagram) Memory sends back contents of that word on the data bus. If contents of D0126 are 0003, then memory sends: 0000 0000 0000 0011 Inside the CPU to address bus (20 bits) to data bus (16 bits) MAR MBR CS DS SS ES IP SP SI D AX BX CX DX BP FlagsR IR U CPU with visible and invisible registers IP (PC) is invisible on some machines Memory access takes longer than the time to execute one microinstruction. Therefore the microprogram must have the correct values on the address bus and data bus through the execution of several microinstructions. MAR (contains address) and MBR (contains word to be written or word most recently read) drive the address bus and data bus IR contains the instruction most recently fetched. There are also CPU-internal buses that allow communication between MBR/IR, etc. data has to be passed back and forth between CPU components just as it has to be passed between system components. Fetch/Execute Cycle (Instruction Execution) Instruction cycle: fetch (get next instruction from memory to CPU) execute (interpret opcode and perform indicated operation) (interrupt (if enabled and one has occurred, save state and process interrupt)) Fetch: copy contents of 16 * contents of CS + Contents of (IP) into MAR assert memory read in control bus wait for memory to send back this 1 byte (or word) along data bus to MBR IP is incremented (to point to the next byte) Fetch/Execute (cont.) Execute: CPU copies MBR into IR (so MBR can be used for future memory accesses) CPU inspects opcode in IR and decodes. If other instruction bytes are needed, they are fetched as above (with IP incremented each time) any operands required from memory are fetched now (put address on MAR, wait for receipt in MBR) INSTRUCTION EXECUTES If instruction stores results back in memory, put result in MBR, put address in MAR, assert memory write. 6