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

Similar documents
The Microprocessor and its Architecture

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

EEM336 Microprocessors I. The Microprocessor and Its Architecture

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

Chapter 2: The Microprocessor and its Architecture

Basic Execution Environment

8086 INTERNAL ARCHITECTURE

EC-333 Microprocessor and Interfacing Techniques

Intel 8086 MICROPROCESSOR ARCHITECTURE

Intel 8086 MICROPROCESSOR. By Y V S Murthy

Internal architecture of 8086

Hardware and Software Architecture. Chapter 2

9/25/ Software & Hardware Architecture

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

MICROPROCESSOR PROGRAMMING AND SYSTEM DESIGN

Assembler Programming. Lecture 2

CC411: Introduction To Microprocessors

UNIT 2 PROCESSORS ORGANIZATION CONT.

Microprocessor (COM 9323)

Module 3 Instruction Set Architecture (ISA)

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

icroprocessor istory of Microprocessor ntel 8086:

Dr. Ramesh K. Karne Department of Computer and Information Sciences, Towson University, Towson, MD /12/2014 Slide 1

Introduction to 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

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

Introduction to IA-32. Jo, Heeseung

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

INTRODUCTION TO IA-32. Jo, Heeseung

Architecture of 8086 Microprocessor

The x86 Architecture

Code segment Stack segment

16-Bit Intel Processor Architecture

INTRODUCTION TO MICROPROCESSORS

MICROPROCESSOR MICROPROCESSOR ARCHITECTURE. Prof. P. C. Patil UOP S.E.COMP (SEM-II)

IA32 Intel 32-bit Architecture

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

SPRING TERM BM 310E MICROPROCESSORS LABORATORY PRELIMINARY STUDY

Complex Instruction Set Computer (CISC)

UMBC. contain new IP while 4th and 5th bytes contain CS. CALL BX and CALL [BX] versions also exist. contain displacement added to IP.

Addressing Modes on the x86

Unit 08 Advanced Microprocessor

Scott M. Lewandowski CS295-2: Advanced Topics in Debugging September 21, 1998

Advanced Microprocessors

The Instruction Set. Chapter 5

Chapter Three Addressing Mode MOV AX, BX

Processor Structure and Function

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

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

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

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

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

ADVANCE MICROPROCESSOR & INTERFACING

Chapter 3: Addressing Modes

VARDHAMAN COLLEGE OF ENGINEERING (AUTONOMOUS) Shamshabad, Hyderabad

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

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

Buffer Overflow Attack

Memory Models. Registers

MICROPROCESSOR MICROPROCESSOR ARCHITECTURE. Prof. P. C. Patil UOP S.E.COMP (SEM-II)

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

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

Assembly Language Lab # 9

Low Level Programming Lecture 2. International Faculty of Engineerig, Technical University of Łódź

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

Reverse Engineering II: Basics. Gergely Erdélyi Senior Antivirus Researcher

MICROPROCESSOR ALL IN ONE. Prof. P. C. Patil UOP S.E.COMP (SEM-II)

Practical Malware Analysis

Inline Assembler. Willi-Hans Steeb and Yorick Hardy. International School for Scientific Computing

Reverse Engineering II: The Basics

ADVANCED PROCESSOR ARCHITECTURES AND MEMORY ORGANISATION Lesson-11: 80x86 Architecture

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

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

EEM336 Microprocessors I. Addressing Modes

Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 2: IA-32 Processor Architecture Included elements of the IA-64 bit

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

Real instruction set architectures. Part 2: a representative sample



Computer System Architecture

IA-32 Architecture COE 205. Computer Organization and Assembly Language. Computer Engineering Department

Microprocessors ( ) Fall 2010/2011 Lecture Notes # 15. Stack Operations. 10 top

Arithmetic Instructions

MICROPROCESSOR TECHNOLOGY

CNIT 127: Exploit Development. Ch 1: Before you begin. Updated

iapx Systems Electronic Computers M

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

x86 Assembly Tutorial COS 318: Fall 2017

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

BASIC INTERRUPT PROCESSING

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

Week 2 The 80x86 Microprocessor Architecture

Marking Scheme. Examination Paper. Module: Microprocessors (630313)

The Pentium Processor

Q1: Multiple choice / 20 Q2: Protected mode memory accesses

CS 16: Assembly Language Programming for the IBM PC and Compatibles

EC 333 Microprocessor and Interfacing Techniques (3+1)

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

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

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

Transcription:

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

Topics/Reading SYSC3601 2 Microprocessor Systems 1. Registers and internal architecture (Ch 2) 2. Address generation (Ch 2)

8086 Registers and Internal Architecture There are two main functional logic blocks in the 8086/88 processors: EU Execution Unit - execution of program instructions BIU Bus Interface Unit - provides interface to memory and I/O 1. controls the address, data, and control busses. 2. handles instruction fetch and data read/write functions SYSC3601 3 Microprocessor Systems

8086 Registers and Internal Architecture SYSC3601 4 Microprocessor Systems EAX,EBX,EDI,etc A B

SYSC3601 5 Microprocessor Systems A Execution Unit Multipurpose Registers

SYSC3601 6 Microprocessor Systems Execution Unit Multipurpose Registers EAX Accumulator: used for arithmetic and logic operations. Destination for MUL and DIV. EBX Base Index: Typically used to hold offset addresses. ECX Count: Typically used to hold a count value for various instructions (repeated strings, LOOP/LOOPD, Shift/rotate). MOV CX,080H HERE... ; LOOP HERE ; Decrement CX, JNZ to label HERE EDX Data: temporary data storage for part of a result from a multiplication (Most significant result) or division (dividend, remainder).

SYSC3601 7 Microprocessor Systems Execution Unit Multipurpose Registers ESP Stack Pointer: Used to offset into the stack segment to address the stack. PUSH/POP, JSR EBP Base Pointer: Used to store a base memory location for data transfers. EDI Destination Index: Typically used as an offset for the destination memory location for string/byte transfers. ESI Source Index: Typically used as an offset for the source memory location for string/byte transfers. The use of the base and offset registers EBX, ESP, EBP, EDI and ESI will become clearer when addressing modes are covered.

SYSC3601 8 Microprocessor Systems B Execution Unit Flag Register Note: O,Z,A,P & C are changed by most arithmetic and logic instructions but are unchanged by data transfers. C Carry: Holds the carry after addition, or the borrow after subtraction. P Parity: 0 - odd parity. 1 - even parity. A Auxiliary carry: Holds the half-carry/borrow after addition/subtraction. (BCD operations on nibbles). Z Zero: 1 if the result of an arithmetic or logic operation is zero.

Execution Unit Flag Register SYSC3601 9 Microprocessor Systems S Sign: holds the sign of the result after a arithmetic or logical operation. This is the value of the sign bit of the result of the operation. T Trap: enables trapping if 1. Program flow is interrupted based on the values of the control and debug registers. I Interrupt: Controls the operation of the INTR (interrupt request) pin. If 1, interrupts from INTR are enabled. D Direction: Selects either increment or decrement for the SI and/or DI registers during string and loop functions. If 1, the registers are decremented. O Overflow: Indicates that a result has exceeded the capacity of a register during signed operations.

SYSC3601 10 Microprocessor Systems Execution Unit Extended Flag Register IOP (80286+) I/O Privilege level: Two bits correspond to privilege level for I/O operation. 00 is the highest, 11 is the lowest. NT (80286+) Nested task: Set when a task is nested within another task. RF (80386+) Resume Flag: Used during debugging. VM (80386+) Virtual Mode: Virtual mode execution (multiple 8086s running in protected mode). AC (80486SX+) Alignment Check: Non-aligned address (for co-processor). VIF (Pentium+) Virtual Interrupt Flag: A copy of the interrupt flag. VIP (Pentium+) Virtual Interrupt Pending: ID (Pentium+) ID: The CPUID instruction is supported.

Bus Interface Unit SYSC3601 11 Microprocessor Systems B C A

SYSC3601 12 Microprocessor Systems A The Bus Interface Unit (BIU) The BIU can operate in parallel with the EU The instruction queue One task of the BIU is instruction pre-fetch Whenever the external busses are idle, the BIU fetches the next instruction and places it in the instruction queue. The instruction queue is now replaced by L1/L2 cache. The 8086 can have up to 6 bytes of information in the instruction queue, the 8088 is limited to 4. The instruction queue must be flushed for some instructions (change of program flow, e.g., JMP) We will be spending more time later in the course on bus control. BIU computes the Physical Address (explained later)

Intel x86 cores SYSC3601 13 Microprocessor Systems CPU1 CPU2 CPU3 Copro 16K L1 Cache 256K L2 Cache Pentium Pro Pentium II, III, 4 same as Pentium Pro with increased L1 & L2 cache sizes.

SYSC3601 14 Microprocessor Systems B Bus Interface Unit Instruction Pointer The Instruction Pointer (IP) is updated by the BIU. EIP (32 bits) in 80386 and up IP contains the offset of the next instruction to be fetched from the beginning of the code segment. Whenever the instruction pointer is saved on the stack, it is automatically adjusted to point to the next instruction to be executed (as opposed to fetched). Can be modified with a JMP or CALL instruction. Used with CS (see next few slides ) Physical address of next instruction = CS:IP

SYSC3601 15 Microprocessor Systems C Bus Interface Unit Segment Registers Segment registers are combined with other registers to generate 20-bit addresses. 15

SYSC3601 16 Microprocessor Systems Bus Interface Unit Segment Registers CS Code Segment: Used to compute the starting address of the section of memory holding code (restricted to 64K in REAL mode). DS Data Segment: Used to compute the starting address of the section of memory holding data (restricted to 64K in REAL mode). SS Stack Segment: Used to compute the starting address of the section of memory holding the stack (restricted to 64K in REAL mode). ES Extra Segment: Additional data segment used by some string instructions. FS&GS Additional segment registers in the 80386 (and up) for program use.

Address Generation Two types of address generation: 1. Real Mode (the 8086/8088/186 can only operate in this mode) Allows the µp to address the first 1Mbyte of memory only. The first Mbyte of memory is called real or conventional memory. 2. Protected mode (80286...) This mode uses the segment register contents (called a selector) to access a descriptor from a descriptor table. The descriptor describes the memory segment s location, length and access rights. SYSC3601 17 Microprocessor Systems

Real Mode Address Generation Memory addresses consist of a segment address plus and offset address. The segment address defines the start of a 64K block of memory. The offset address selects a location within the 64K memory segment. Memory locations are often written as: segment:offset C000:04BA SYSC3601 18 Microprocessor Systems

Real Mode Address Generation SYSC3601 19 Microprocessor Systems Ex. If IP=1200H and CS=1400H then next instruction will be fetched from: 1400:1200 or 14000H +1200H ------ 15200H

SYSC3601 20 Microprocessor Systems Real Mode Address Generation Funky Rules The µp has a set of rules that apply whenever memory is addressed, which define the segment and offset register combination used by certain addressing modes. Segment Offset Special Purpose CS IP Instruction address SS SP or BP Stack address DS BX,DI,SI, 8bit # or 16bit # Data address ES DI (for string instruction) String destination

Notes: Real Mode Address Generation 1. Memory segments (i.e. the 64K blocks) may overlap if full 64K are not needed. 2. The segment-offset scheme allows programs to be relocated in memory (on 16 byte boundaries). Move the existing contents to the new physical location, then update the segment register. SYSC3601 21 Microprocessor Systems

Segment Resolution SYSC3601 22 Microprocessor Systems FE010H FE00:0010 FE01:0000 FE005H. FE00:0005 FE000H. FE00:0000. 16 bytes resolution FDFF0H FDFF:0000

SYSC3601 23 Microprocessor Systems Real Mode Address Generation - Examples Ex 1: MOV DL,[BP] Uses an absolute (i.e. physical) source address of: SS x 16 + BP Ex 2 (overlap): FE00:0005 FE000H +0005H ------ FE005H Same location in memory! FDFF:0015 FDFF0H +0015H ------ FE005H

Real Address Mode Generation SYSC3601 24 Microprocessor Systems Start of segment Start of segment Start of segment

SYSC3601 25 Microprocessor Systems Stack Operation The stack is a Last-In, First Out (LIFO) queue. The stack grows down in memory (i.e., towards 0). Only words (8086-80286) and double words (80386...) can be pushed/popped on/off the stack. POP CS is NOT allowed. Typically, initialize SP to 0H. Will decrement to 0FFFFH on first PUSH to point to top of segment.

Stack Operation Example SYSC3601 26 Microprocessor Systems 1 2 3 2a 2b 2c 3a 3b 3c MOV BX,1234H PUSH BX POP AX SS x 10H + SP - 1 12H SS x 10H + SP - 2 34H ; BX 1234H ; PUSH 1234H onto stack ; AX 1234H from stack SP SP - 2 High order Low order AL SS x 10H + SP (34H) AH SS x 10H + SP + 1 (12H) SP SP + 2 High byte transferred first so that value is LITTLE ENDIAN in memory.