13
1 1 2102440 Introduction to 2102440 Introduction to Microprocessors Microprocessors Suree Suree Pumrin Pumrin , Ph.D. , Ph.D. Chapter 1 Chapter 1 Intro to 80x86 Intro to 80x86 2102440 Introduction to Microprocessors 2102440 Introduction to Microprocessors 2 2 Topics Topics Introduction Introduction Goals Goals Brief History of Microprocessors Brief History of Microprocessors Microprocessor Systems Overview Microprocessor Systems Overview Microprocessor Data Types Microprocessor Data Types Intro to 80x86 Intro to 80x86 2102440 Introduction to Microprocessors 2102440 Introduction to Microprocessors 3 3 Topics (cont.) Topics (cont.) Inside the computer Inside the computer Inside the 8086 Inside the 8086 Physical address calculation examples Physical address calculation examples Segments in the 8086 Segments in the 8086 2102440 Introduction to Microprocessors 2102440 Introduction to Microprocessors 4 4 Goals Goals Goals Goals Understanding what make microprocessors work Understanding what make microprocessors work Assembly programming Assembly programming Design, implementation, and integration experience Design, implementation, and integration experience on microprocessor board and microcomputer on microprocessor board and microcomputer Basic Input/output interfacing microprocessors with Basic Input/output interfacing microprocessors with memory system, serial and parallel ports memory system, serial and parallel ports Debugging HW/SW Debugging HW/SW Interrupt and DMA Interrupt and DMA

Topics (cont.) Goals - Chula · Topics ¾Introduction ¾ ... Pentium 4 processor 2000 42,000,000 Pentium III processor 1999 24,000,000 Pentium II processor 1997 7,500,000 Pentium®

  • Upload
    others

  • View
    12

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Topics (cont.) Goals - Chula · Topics ¾Introduction ¾ ... Pentium 4 processor 2000 42,000,000 Pentium III processor 1999 24,000,000 Pentium II processor 1997 7,500,000 Pentium®

11

2102440 Introduction to 2102440 Introduction to Microprocessors Microprocessors

Suree Suree PumrinPumrin, Ph.D., Ph.D.

Chapter 1Chapter 1Intro to 80x86Intro to 80x86

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 22

TopicsTopics

IntroductionIntroductionGoalsGoalsBrief History of MicroprocessorsBrief History of MicroprocessorsMicroprocessor Systems OverviewMicroprocessor Systems OverviewMicroprocessor Data TypesMicroprocessor Data TypesIntro to 80x86Intro to 80x86

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 33

Topics (cont.)Topics (cont.)

Inside the computerInside the computerInside the 8086Inside the 8086Physical address calculation examplesPhysical address calculation examplesSegments in the 8086Segments in the 8086

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 44

GoalsGoals

GoalsGoalsUnderstanding what make microprocessors workUnderstanding what make microprocessors workAssembly programmingAssembly programmingDesign, implementation, and integration experience Design, implementation, and integration experience on microprocessor board and microcomputeron microprocessor board and microcomputerBasic Input/output interfacing microprocessors with Basic Input/output interfacing microprocessors with memory system, serial and parallel portsmemory system, serial and parallel portsDebugging HW/SW Debugging HW/SW Interrupt and DMAInterrupt and DMA

Page 2: Topics (cont.) Goals - Chula · Topics ¾Introduction ¾ ... Pentium 4 processor 2000 42,000,000 Pentium III processor 1999 24,000,000 Pentium II processor 1997 7,500,000 Pentium®

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 55

Brief History of MicroprocessorsBrief History of Microprocessors

The mechanical ageThe mechanical ageThe electrical ageThe electrical ageThe microprocessor ageThe microprocessor ageThe modern microprocessorThe modern microprocessor

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 66

The Mechanical Age (I)The Mechanical Age (I)500 B.C. 500 B.C.

Chinese : Abacus Chinese : Abacus –– a a wooden rack holding two wooden rack holding two horizontal wires with bead horizontal wires with bead stung on themstung on them

16421642BlaiseBlaise Pascal: Calculator Pascal: Calculator ––mechanical adder and mechanical adder and subtractersubtracter using of gears using of gears and wheelsand wheels

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 77

The Mechanical Age (II)The Mechanical Age (II)

18231823Charles Babbage: Charles Babbage:

•• Difference engine Difference engine ––mechanize the mechanize the calculation of calculation of polynomial functions polynomial functions

•• Analytical engine Analytical engine ––perform any perform any mathematical operation mathematical operation automaticallyautomatically

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 88

The Electrical Age (I)The Electrical Age (I)

18891889HollerithHollerith: The punched : The punched card card –– counted, sorted, counted, sorted, and collated and collated informationinformation

Page 3: Topics (cont.) Goals - Chula · Topics ¾Introduction ¾ ... Pentium 4 processor 2000 42,000,000 Pentium III processor 1999 24,000,000 Pentium II processor 1997 7,500,000 Pentium®

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 99

The Electrical Age (II)The Electrical Age (II)

19431943Turing: The first Turing: The first special purpose special purpose computer (Colossus) computer (Colossus) ––a fixed program a fixed program computer system computer system

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 1010

The Electrical Age (III)The Electrical Age (III)

19461946The University of The University of Pennsylvania: the first Pennsylvania: the first general purpose general purpose computer computer –– ENIAC ENIAC (Electronics Numerical (Electronics Numerical Integrator and Integrator and Calculator)Calculator)

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 1111

The Microprocessor AgeThe Microprocessor Age

19451945von Neumann: von Neumann machines von Neumann: von Neumann machines ––revolutionizes the way people think about revolutionizes the way people think about computer designcomputer design

1950s1950sTransistor and magnetic core memoryTransistor and magnetic core memory

1960s1960sDigital integrated circuits, VLSIDigital integrated circuits, VLSI

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 1212

The Modern Microprocessor (I)The Modern Microprocessor (I)1970s1970s

71: Intel 4004 71: Intel 4004 –– 44--bit microprocessor bit microprocessor (the first microprocessor)(the first microprocessor)72: Intel 8008 72: Intel 8008 –– the first 8the first 8--bit bit microprocessormicroprocessor74: Motorola MC6800 74: Motorola MC6800 –– 88--bit bit microprocessormicroprocessor76: 76: ZilogZilog ZZ--80 80 –– 88--bit bit microprocessormicroprocessor78: Intel 8086 78: Intel 8086 –– 1616--bit bit microprocessormicroprocessor79: Motorola MC68000 79: Motorola MC68000 –– 1616--bit bit microprocessor microprocessor

Page 4: Topics (cont.) Goals - Chula · Topics ¾Introduction ¾ ... Pentium 4 processor 2000 42,000,000 Pentium III processor 1999 24,000,000 Pentium II processor 1997 7,500,000 Pentium®

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 1313

The Modern Microprocessor (II)The Modern Microprocessor (II)1980s1980s

85: Intel 386 85: Intel 386 –– 3232--bit microprocessorbit microprocessor86: 86: AcronAcron RISC RISC ––3232--bit processorbit processor87: 87: ZilogZilog ZZ--280 280 –– 1616--bit machinebit machine

1990s1990s91: MIPS Computer Systems 91: MIPS Computer Systems –– 6464--bit R4000 RISC bit R4000 RISC machinemachine92: Digital92: Digital’’s Alpha 21064 s Alpha 21064 –– 6464--bit at 300 MHzbit at 300 MHz95: Intel Pentium at 133 MHz95: Intel Pentium at 133 MHz97: Intel Pentium II97: Intel Pentium II99: Intel Pentium III at 500 MHz99: Intel Pentium III at 500 MHz

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 1414

The Modern Microprocessor (III)The Modern Microprocessor (III)

2000s2000s00: Intel 1 GHz00: Intel 1 GHz01: Intel Pentium 4 at 1.7 and 2 GHz01: Intel Pentium 4 at 1.7 and 2 GHz02: Intel Mobile Processor at 1 GHz (low 02: Intel Mobile Processor at 1 GHz (low power)power)05: 05: The Intel Itanium The Intel Itanium

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 1515

The Future of MicroprocessorsThe Future of Microprocessors

No one can accurately predict!No one can accurately predict!MulticoreMulticore processor processor –– multiple processor multiple processor cores on a single piece of siliconcores on a single piece of silicon????

The new challenge is functionalityThe new challenge is functionalityBalancing in clock frequency, design Balancing in clock frequency, design complexity, and power consumptioncomplexity, and power consumption

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 1616

MooreMoore’’s Laws Law

Page 5: Topics (cont.) Goals - Chula · Topics ¾Introduction ¾ ... Pentium 4 processor 2000 42,000,000 Pentium III processor 1999 24,000,000 Pentium II processor 1997 7,500,000 Pentium®

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 1717

The Intel MicroprocessorsThe Intel Microprocessors

42,000,0002000Pentium 4 processor

24,000,0001999Pentium III processor

7,500,0001997Pentium II processor

3,100,0001993Pentium® processor

1,180,0001989486™ DX processor

275,0001985386™ processor

120,0001982286

29,00019788086

5,00019748080

2,50019728008

2,25019714004

TransistorsYear of introduction

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 1818

Evolution of IntelEvolution of Intel’’s x86s x86

8, 16, 328, 16, 328, 16, 328, 16, 328, 168, 16Data type (bits)

363232322420Add. Bus

646432321616Ex. Data bus

323232321616In. data bus

64 T64 T64 T64 T1 GNoneVir. Mem

64 G4 G4 G4 G16 M1 MPhys. Mem

5.5 million3.1 million1.2 million275,000130,00029,000# trans.

3872731681326840# pins

15060, 6625-3316-3310-163-10Clock rate (MHz)

BICMOSBICMOSCMOSCMOSNMOSNMOSTechnology

199519921989198519821978Year

Pentium Pro

Pentium8048680386802868086Product

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 1919

Microprocessor Systems OverviewMicroprocessor Systems OverviewInstruction set Instruction set

Complex instruction set computers (CISC)Complex instruction set computers (CISC)Reduced instruction set computers (RISC)Reduced instruction set computers (RISC)

ArchitectureArchitecturevon Neumann architecture (a.k.a. Princeton architecture)von Neumann architecture (a.k.a. Princeton architecture)Harvard architectureHarvard architecture

Basic computer systemBasic computer systemCentral processing unit (CPU) Central processing unit (CPU) –– Registers, Arithmetic Logic Unit (ALU), Registers, Arithmetic Logic Unit (ALU), control unitcontrol unitMemory Memory –– program & dataprogram & dataInput and Output (I/O) systemInput and Output (I/O) systemPeripherals Peripherals –– Analog to digital converter, timer unit, serial Analog to digital converter, timer unit, serial communications interface, etc.communications interface, etc.Data path Data path –– address bus, data bus, control busaddress bus, data bus, control bus

WhatWhat’’s the difference in microprocessors, microcontrollers, and s the difference in microprocessors, microcontrollers, and microcomputers?microcomputers?

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 2020

CISC CISC vsvs RISCRISCComplex instruction set computer (CISC), e.g., Complex instruction set computer (CISC), e.g., x86, 680x0x86, 680x0

Typical PC architectureTypical PC architectureMany operations, some of them very complexMany operations, some of them very complex

Reduced instruction set computer (RISC), e.g., Reduced instruction set computer (RISC), e.g., PIC, ARM, SPARCPIC, ARM, SPARC

Simpler instructions can be executed at higher speedSimpler instructions can be executed at higher speedRISC is common used in workstations for higher RISC is common used in workstations for higher performanceperformancePentium is a combination of CISC and RISC.Pentium is a combination of CISC and RISC.

Modern Modern CISCsCISCs implemented as implemented as RISCsRISCs internallyinternallyOnly the total system performance mattersOnly the total system performance matters

Page 6: Topics (cont.) Goals - Chula · Topics ¾Introduction ¾ ... Pentium 4 processor 2000 42,000,000 Pentium III processor 1999 24,000,000 Pentium II processor 1997 7,500,000 Pentium®

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 2121

von Neumann Architecture (I)von Neumann Architecture (I)

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 2222

von Neumann Architecture (II)von Neumann Architecture (II)

Memory stores programs and dataCentral processing unit (CPU) fetches and executeInput/output unit interface with input and output devices, e.g., printer, disk, CRT, keyboard

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 2323

Harvard ArchitectureHarvard Architecture

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 2424

von Neumann (Princeton) von Neumann (Princeton) vsvsHarvardHarvard

Data and instructions mixed in the same Data and instructions mixed in the same memory: Princeton architecturememory: Princeton architectureData and instructions in separate memory: Data and instructions in separate memory: Harvard architectureHarvard architecturePrinceton architecture simpler to Princeton architecture simpler to implementimplementMost Most DSPsDSPs use Harvard architecture for use Harvard architecture for streaming data streaming data

Page 7: Topics (cont.) Goals - Chula · Topics ¾Introduction ¾ ... Pentium 4 processor 2000 42,000,000 Pentium III processor 1999 24,000,000 Pentium II processor 1997 7,500,000 Pentium®

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 2525

MicroprocessorsMicroprocessors

Typically external program memoryTypically external program memoryRange from devices with few thousand Range from devices with few thousand transistors to 5transistors to 5--10 million transistors10 million transistorsTo implement complete computer must still To implement complete computer must still include input/output subsystems, memory, etc.include input/output subsystems, memory, etc.The components connected via system busThe components connected via system busIntel: x86 family, 8088, 80286, Intel: x86 family, 8088, 80286, ……, Pentium, PentiumZilogZilog: Z80: Z80Motorola: 680x0 familyMotorola: 680x0 family

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 2626

MicrocontrollersMicrocontrollersIncludes microprocessor, I/O subsystemsIncludes microprocessor, I/O subsystemsTypically include peripherals, e.g., timers, serial Typically include peripherals, e.g., timers, serial communications channels, Analog to digital conversion, communications channels, Analog to digital conversion, digital to analog conversion, direct memory access digital to analog conversion, direct memory access (DMA)(DMA)Memory subsystem may or may not be includedMemory subsystem may or may not be includedMicrocontroller Microcontroller = Microprocessor + = Microprocessor +

Memory + I/OMemory + I/O= Embedded microprocessor= Embedded microprocessor

MCSMCS--51 family (Intel, Dallas, 8032, 89C52, 8051,51 family (Intel, Dallas, 8032, 89C52, 8051,……), ), 68HC11 family (Motorola)68HC11 family (Motorola)

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 2727

MicrocomputersMicrocomputers

Similar to microcontroller but used as part of a Similar to microcontroller but used as part of a larger embedded systemlarger embedded systemComplete computerComplete computerImplemented using microprocessorImplemented using microprocessorTypically constructed utilizing numerous Typically constructed utilizing numerous integrated circuitsintegrated circuitsComplexity varies: simple microcomputer can be Complexity varies: simple microcomputer can be implemented on single chip with limited onboard implemented on single chip with limited onboard memory, simple I/O systemmemory, simple I/O system

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 2828

Microprocessor Data Types (I)Microprocessor Data Types (I)

Signed and unsigned binary integersSigned and unsigned binary integersBinary coded decimal (BCD)Binary coded decimal (BCD)American Standard Code for Information American Standard Code for Information Interchange (ASCII)Interchange (ASCII)FloatingFloating--point numbers point numbers

Page 8: Topics (cont.) Goals - Chula · Topics ¾Introduction ¾ ... Pentium 4 processor 2000 42,000,000 Pentium III processor 1999 24,000,000 Pentium II processor 1997 7,500,000 Pentium®

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 2929

Microprocessor Data Types (II)Microprocessor Data Types (II)

Unsigned binary integersUnsigned binary integers88--bit unsigned binary integer : 00bit unsigned binary integer : 001616 –– FFFF1616 (0 (0 --255)255)

Signed binary integersSigned binary integersTwoTwo’’s complement forms complement form•• 88--bit signed number: FFbit signed number: FF16 16 = = --11•• 1616--bit signed number: bit 15 represents the sign bit signed number: bit 15 represents the sign

BCDBCD4 bits: 00004 bits: 00002 2 –– 100110012 2 (0 (0 –– 9)9)

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 3030

Microprocessor Data Types (III)Microprocessor Data Types (III)

ASCIIASCII77--bit code represents alphanumeric (alpha characters bit code represents alphanumeric (alpha characters and numbers) and special symbolsand numbers) and special symbols

FloatingFloating--point point Three components: sign, exponent, and mantissaThree components: sign, exponent, and mantissaExample: Example: --4.5x104.5x10--22

•• Sign = 1 (negative), Exponent = Sign = 1 (negative), Exponent = --2, and Significant 2, and Significant (mantissa) = 4.5(mantissa) = 4.5

Normalize: 1.XXXX x 2Normalize: 1.XXXX x 2nn : 10 = 1010: 10 = 101022•• sign = 0 (positive), normalize binary number = 1.010x sign = 0 (positive), normalize binary number = 1.010x 2233

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 3131

The 8086 Internal ArchitectureThe 8086 Internal Architecture

ALU

Operands

Flags

GeneralRegisters

Execution Unit (EU)Segment Registers

Instruction Pointer

Address generationand Bus control

InstructionQueue

Bus Interface Unit (BIU)

Multiplexed Bus

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 3232

8086 Registers8086 RegistersInstruction IP: Instruction Pointer

Segment CS: Code Segment

DS: Data Segment

SS: Stack Segment

ES: Extra Segment

General AX (AH:AL): Accumulator

BX (BH:BL): Base

CX (CH:CL): Count

DX (DH:DL): Data

Pointer SP: Stack

BP: Base

Index SI: Source

DI: Destination

Status FR: Flag

AHBHCHDH

ALBLCLDL

SPBPSIDI

FR

IP

CSDSSSES

AXBXCXDX

16 bits

Page 9: Topics (cont.) Goals - Chula · Topics ¾Introduction ¾ ... Pentium 4 processor 2000 42,000,000 Pentium III processor 1999 24,000,000 Pentium II processor 1997 7,500,000 Pentium®

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 3333

Software ModelSoftware Model

AHBHCHDH

ALBLCLDL

SPBPSIDI

FR

IP

CSDSSSES

AXBXCXDX

16 bits

Memory

Code segment(64 KB)

Data segment(64 KB)

Stack segment(64 KB)

Extra segment(64 KB)

0000016

FFFFF16

Input / outputaddress space

000016

FFFF16

Memory address space = 1 MB

I/O address space = 64 kB

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 3434

Program SegmentProgram Segment

Code segment Code segment –– CS:IPCS:IPContain assembly language instructionsContain assembly language instructions

Data segment Data segment –– DS:BX, SI, DIDS:BX, SI, DIStore information (data)Store information (data)

Stack segment Stack segment –– SS:SP, BPSS:SP, BPStore information temporarilyStore information temporarily

Extra segment Extra segment –– ES:BX, SI, DIES:BX, SI, DIExtra data segment Extra data segment Use for string operationsUse for string operations

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 3535

Memory AddressingMemory Addressing1 segment = 64 kB

Logical address segment : offset

Physical address segment 0 : offset

Segment

Offset

16 bit

16 bit

0 0 0 0

Physical address

20 bit

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 3636

Some Important TerminologySome Important Terminology

bitbit 00nibblenibble 00000000bytebyte 0000 0000 00000000wordword 0000 0000 00000000 00000000 00000000kilobyte kilobyte 2210 10 = 1024= 1024 bytesbytesmegabytemegabyte 2220 20 = 1,048,576= 1,048,576 bytesbytesgigabytegigabyte 2230 30 > 1 billion > 1 billion bytesbytesterabyte terabyte 2240 40 > 1 trillion> 1 trillion bytesbytes

Page 10: Topics (cont.) Goals - Chula · Topics ¾Introduction ¾ ... Pentium 4 processor 2000 42,000,000 Pentium III processor 1999 24,000,000 Pentium II processor 1997 7,500,000 Pentium®

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 3737

Internal Organization Internal Organization of Computers (I)of Computers (I)

CPU

Read/write

Memory(RAM, ROM)

I/O(monitor,

printer, etc.)

Address bus

Data bus

Control bus

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 3838

Internal Organization Internal Organization of Computers (II)of Computers (II)

CPU (central processing unit): Registers, CPU (central processing unit): Registers, Arithmetic Logic Unit (ALU), control unitArithmetic Logic Unit (ALU), control unit

Execute (process) information stored in memoryExecute (process) information stored in memoryMemoryMemory

Store program and dataStore program and dataI/O devicesI/O devices

Provide means of communicating with CPUProvide means of communicating with CPUData path (bus): address bus, data bus, control Data path (bus): address bus, data bus, control busbus

Carry information from place to placeCarry information from place to place

For a device (memory or I/O) to be recognized by the For a device (memory or I/O) to be recognized by the CPU, it must be assigned anCPU, it must be assigned an addressaddress..

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 3939

PipeliningPipelining

Pipelining: the CPU fetches and executes at Pipelining: the CPU fetches and executes at the same timethe same time

fetch 1 exec 1 fetch 2 exec 2non-pipelined

pipelined fetch 1 exec 1

fetch 2 exec 2

fetch 3 exec 3

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 4040

BusBus

Data bus: a pathway between the CPU Data bus: a pathway between the CPU and its external devicesand its external devices

Bidirectional: CPU uses data bus either to Bidirectional: CPU uses data bus either to receive or to send data.receive or to send data.

Address bus: identify the devices and Address bus: identify the devices and memory connected to the CPUmemory connected to the CPU

Unidirectional: CPU uses the address bus Unidirectional: CPU uses the address bus only to send out addresses.only to send out addresses.For x address lines, the number of locations, For x address lines, the number of locations, which CPU can communicate, = 2which CPU can communicate, = 2x x ..

Page 11: Topics (cont.) Goals - Chula · Topics ¾Introduction ¾ ... Pentium 4 processor 2000 42,000,000 Pentium III processor 1999 24,000,000 Pentium II processor 1997 7,500,000 Pentium®

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 4141

Memory MapMemory Map

Video RAM(128 k)

ROM(256k)

A0000

BFFFFC0000

FFFFF

BIOS (Basic Input Output System) (64k)

User RAM(640 k)

00000

9FFFF

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 4242

Generating a Memory AddressGenerating a Memory Address

Segment

Offset

0 0 0 0

20-bit Physical address

ADDER

19 0

15 0

19 0

4

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 4343

Boundaries of segmentBoundaries of segment

DS

BX

Memory

DS:FFFFH

Data segment

DS:0000H

DS:BX

8086

Highestaddressed byte

Lowestaddressed byte

Byte addressable CPU

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 4444

Physical Address Calculation (I)Physical Address Calculation (I)

2 5 0 0 9 5 F 3

CS IP

:Logical Address =

2 5 0 0

2 5 0 0 0

9 5 F 3

2 E 5 F 3

Start with CS.

Shift left CS.

Add IP.

Physical address =

Page 12: Topics (cont.) Goals - Chula · Topics ¾Introduction ¾ ... Pentium 4 processor 2000 42,000,000 Pentium III processor 1999 24,000,000 Pentium II processor 1997 7,500,000 Pentium®

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 4545

Physical Address Calculation (II)Physical Address Calculation (II)

If DS = 7FA2H and the offset is 438EH,If DS = 7FA2H and the offset is 438EH,The logical address:The logical address:7FA2:438E7FA2:438E

The physical address: The physical address: 7FA20 + 438E = 83DAE7FA20 + 438E = 83DAE

The upper range of the data segment:The upper range of the data segment:7FA20 + FFFF = 8FA1F7FA20 + FFFF = 8FA1F

The lower range of the data segment:The lower range of the data segment:7FA20 + 0000 = 7FA207FA20 + 0000 = 7FA20

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 4646

Stack segment of MemoryStack segment of Memory

SS

SP

Memory(word-wide)

SS:FFFEH

Stack segment

SS:0000H

SS:SP

8086

Bottom of stack

End of stack

Top of stack

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 4747

Stack SegmentStack SegmentLogical addressLogical address SS:SPSS:SPSP = 1236SP = 1236AX = 24B6AX = 24B6

Pushing onto stack : Pushing onto stack : PUSH AXPUSH AXSP = 1234SP = 1234AX = 24B6AX = 24B6

Popping the stack :Popping the stack :POP CXPOP CXSP = 1236SP = 1236CX = 24B6CX = 24B6

TOP

2 Bytes

SS:1230SS:1232SS:1234SS:1236

B6 24

2 Bytes

SS:1230SS:1232SS:1234SS:1236

B6 24

2 Bytes

SS:1230SS:1232SS:1234SS:1236

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 4848

Status Register (Flag)Status Register (Flag)

C = Carry

P = Even parity

A = Auxiliary carry

Z = Zero

S = Sign

O = Overflow

D = Direction

I = Interrupt

T = Trap

Control Flags (before execution)

Condition Flags (after execution)

O D I T S Z A P C

015

Page 13: Topics (cont.) Goals - Chula · Topics ¾Introduction ¾ ... Pentium 4 processor 2000 42,000,000 Pentium III processor 1999 24,000,000 Pentium II processor 1997 7,500,000 Pentium®

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 4949

Machine Machine vsvs AssemblyAssembly

B059 MOV AL, 59

B685 MOV DH, 85

B421 MOV AH, 21

B270 MOV DL, 70

01D0 ADD AX,DX

05371F ADD AX,1F37

Machine code Assemblyprogram

Assembler

Disassembler

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 5050

Addressing ModesAddressing Modes1.1. Register Register MOV AX, BXMOV AX, BX2.2. Immediate Immediate ADD AL, 10HADD AL, 10H3.3. DirectDirect MOV CX, [1200H]MOV CX, [1200H]4.4. Register indirectRegister indirect MOV AL, [BX]MOV AL, [BX]

SI,DISI,DI

5.5. Based relativeBased relative MOV CX, [BX+10H]MOV CX, [BX+10H]BPBP

6.6. IndexedIndexed relativerelative MOV AX, [SI+15H]MOV AX, [SI+15H]DIDI

7.7. Based indexedBased indexed relativerelative MOV AH, [BX+DI+5H]MOV AH, [BX+DI+5H]BPBP SISI

2102440 Introduction to Microprocessors2102440 Introduction to Microprocessors 5151

Little Little EndianEndian Convention Convention

MOV AX, 35F3HMOV AX, 35F3H ; ; AL = F3 , AH = 35AL = F3 , AH = 35MOV [1500], AXMOV [1500], AX ; ; DS: 1500 F3DS: 1500 F3

DS: 1501 35DS: 1501 35

All Intel microprocessors and many All Intel microprocessors and many minicomputers use the little minicomputers use the little endianendian convention convention (high byte goes to high address).(high byte goes to high address).Motorola microprocessors and mainframes use Motorola microprocessors and mainframes use big big endianendian (high byte goes to low address).(high byte goes to low address).