Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 03: 80X86 Microprocessor. The 80x86 IBM PC and Compatible Computers Chapter 1 80X86 Microprocessor Chapter 9.1 8088 Microprocessor.

Similar presentations


Presentation on theme: "Lecture 03: 80X86 Microprocessor. The 80x86 IBM PC and Compatible Computers Chapter 1 80X86 Microprocessor Chapter 9.1 8088 Microprocessor."— Presentation transcript:

1 Lecture 03: 80X86 Microprocessor

2 The 80x86 IBM PC and Compatible Computers Chapter 1 80X86 Microprocessor Chapter Microprocessor

3 Evolution of 80X86 Family z8086, born in 1978 yFirst 16-bit microprocessor y20-bit address data bus, i.e = 1MB memroy yFirst pipelined microprocessor z8088 yData bus: 16-bit internal, 8-bit external yFit in the 8-bit world, e.g., motherboard, peripherals yAdopted in the IBM PC + MS-DOS open system z80286, 80386, yReal/protected modes yVirtual memory

4 Internal Structure of 8086 zTwo sections yBus interface unit (BIU): accesses memory and peripherals yExecution unit (EU): executes instructions previously fetched yWork simultaneously

5 Internal Structure of 8086

6 Bus Interface Unit zTake in charge of data transfer between CPU and memory and I/O devices as well yInstruction fetch, instruction queuing, operand fetch and storage, address relocation and Bus control zConsists of : yfour 16-bit segment registers: CS, DS, ES, SS yOne 16-bit instruction pointer: IP yOne 20-bit address adder: e.g., CS left-shifted by 4 bits + IP (CS*16+IP) yA 6-byte instruction queue zWhile the EU is executing an instruction, the BIU will fetch the next one or several instructions from the memory and put in the queue

7 Execution Unit zTake in charge of instruction execution zConsists of: yFour 16-bit general registers: Accumulator (AX), Base (BX), Count (CX) and Data (DX) yTwo 16-bit pointer registers: Stack Pointer (SP), Base Pointer (BP) yTwo 16-bit index registers: Source Index (SI) and Destination Index (DI) yOne 16-bit flag register: 9 of the 16 bits are used yALU

8 Registers zOn-chip storage: super fast & expensive zStore information temporarily zSix groups

9 Pipelining in 8086 zBIU fetches and stores instructions once the queue has more than 2 empty bytes zEU consumes instructions pre-fetched and stored in the queue at the same time zIncreases the efficiency of CPU zWhen it works? ySequential instruction execution yBranch penalty: when jump instruction executed, all pre-fetched instructions are discarded

10 8086/8088 Pins (Compare them and tell the difference)

11 Minimum Mode Configuration 8086/88’s two work modes: Minimum mode : =1 Single CPU; Control signals from the CPU Maximum mode : =0 Multiple CPUs( ) 8288 control chip supports

12 Control Signals zMN/~MX: Minimum mode (high level), Maximum mode (low level) z~RD: output, CPU is reading from memory or IO z~WR: output, CPU is writing to memory or IO zM/~IO: output, CPU is accessing memory (high level) or IO (low level) zREADY: input, memory/IO is ready for data transfer z~DEN: output, used to enable the data transceivers zDT/~R: output, used to inform the data transceivers the direction of data transfer, i.e., sending data (high level) or receiving data (low level) z~BHE: output, ~BHE=0, AD8-AD15; ~BHE=1, AD0-AD7 zALE: output, used as the latch enable signal of the address latch

13 Control Signals zHOLD: input signal, hold the bus request zHLDA: output signal, hold request ack zINTR: input, interrupt request from 8259 interrupt controller, maskable by clearing the IF in the flag register zINTA: output, interrupt ack zNMI: input, non-maskable interrupt, CPU is interrupted after finishing the current instruction; cannot be masked by software zRESET: input signal, reset the CPU yIP, DS, SS, ES and the instruction queue are cleared yCS = FFFFH yWhat is the address of the first instruction that the CPU will execute after reset?

14 Remember CMOS Gates?

15 Memory/IO Control Signals

16 Address/Data Demultiplexing & Address latching

17 Data Bus Transceiver

18 8086/88 Bus Cycle (for data transfers) At least 4 clock cycles

19 8086 Programming zA typical program on 8086 consists of at least three segments ycode segment: contains instructions that accomplish certain tasks ydata segment: stores information to be processed ystack segment: store information temporarily zWhat is a segment? yA memory block includes up to 64KB. Why? yBegins on an address evenly divisible by 16, i.e., an address looks like in XXXX0H. Why?

20 Logical & Physical Address zPhysical address y20-bit address that is actually put on the address bus yA range of 1MB from 00000H to FFFFFH yActual physical location in memory zLogical address yConsists of a segment value (determines the beginning of a segment) and an offset address (a relative location within a 64KB segment) yE.g., an instruction in the code segment has a logical address in the form of CS (code segment register):IP (instruction pointer)

21 Logical & Physical Address zlogical address -> physical address yShift the segment value left one hex digit (or 4 bits) yThen adding the above value to the offset address yOne logical -> only one physical zSegment range representation yMaximum 64KB ylogical 2500:0000 – 2500:FFFF yPhysical 25000H – 34FFFH ( FFFF)

22 Physical Address Wrap-around zWhen adding the offset to the shifted segment value results in an address beyond the maximum value FFFFFH zE.g., what is the range of physical addresses if CS=FF59H? ySolution: The low range is FF590H, and the range goes to FFFFFH and wraps around from 00000H to 0F58FH (FF590+FFFF).

23 Logical & Physical Address zPhysical address -> logical address ? yOne physical address can be derived from different logical addresses yE.g.,

24 Segment Overlapping zTwo segments can overlap yDynamic behaviour of the segment and offset concept yMay be desirable in some circumstances

25 Code Segment z8086 fetches instructions from the code segment yLogical address of an instruction: CS:IP yPhysical address is generated to retrieve this instruction from memory yWhat if desired instructions are physically located beyond the current code segment? Solution: Change the CS value so that those instructions can be located using new logical addresses

26 Data Segment zInformation to be processed is stored in the data segment yLogical address of a piece of data: DS:offset xOffset value: e.g., 0000H, 23FFH xOffset registers for data segment: BX, SI and DI yPhysical address is generated to retrieve data (8-bit or 16-bit) from memory yWhat if desired data are physically located beyond the current data segment? Solution: Change the DS value so that those data can be located using new logical addresses

27 Data Representation in Memory zMemory can be logically imagine as a consecutive block of bytes zHow to store data whose size is larger than a byte? yLittle endian: the low byte of the data goes to the low memory location yBig endian: the high byte of the data goes to the low memory location yE.g., 2738H

28 Stack Segment zA section of RAM memory used by the CPU to store information temporarily yLogical address of a piece of data: SS:SP (special applications with BP) yMost registers (except segment registers and SP) inside the CPU can be stored in the stack and brought back into the CPU from the stack using push and pop, respectively yGrows downward from upper addresses to lower addresses in the memory allocated for a program xWhy? To protect other programs from destruction xNote: Ensure that the code section and stack section would not write over each other

29 Push & Pop z16-bit operation Little endian or big endian?

30 Push & Pop

31 Extra Segment zAn extra data segment, essential for string operations yLogical address of a piece of data: ES:offset xOffset value: e.g., 0000H, 23FFH xOffset registers for data segment: BX, SI and DI zIn Summary,

32 Memory map of the IBM PC z1MB logical address space z640K max RAM yIn 1980s, 64kB-256KB yMS-DOS, application software yDOS does memory management; you do not set CS, DS and SS zVideo display RAM zROM y64KB BIOS yVarious adapter cards

33 BIOS Function zBasic input-output system (BIOS) yTests all devices connected to the PC when powered on and reports errors if any yLoad DOS from disk into RAM yHand over control of the PC to DOS zRecall that after CPU being reset, what is the first instruction that CPU will execute?

34 Flag Register z16-bit, status register, processor status word (PSW) z6 conditional flags yCF, PF, AF, ZF, SF, and OF z3 control flags yDF, IF, TF

35 Conditional Flags zCF (Carry Flag): set whenever there is a carry out, from d7 after a 8-bit op, from d15 after a 16-bit op zPF (Parity Flag): the parity of the op result’s low-order byte, set when the byte has an even number of 1s zAF (Auxiliary Carry Flag): set if there is a carry from d3 to d4, used by BCD-related arithmetic zZF (Zero Flag): set when the result is zero zSF (Sign Flag): copied from the sign bit (the most significant bit) after op zOF (Overflow Flag): set when the result of a signed number operation is too large, causing the sign bit error

36 More about Signed Number, CF&OF zThe most significant bit (MSB) as sign bit, the rest of bits as magnitude yFor negative numbers, D7 is 1, but the magnitude is represented in 2’s complement zCF is used to detect errors in unsigned arithmetic operations zOF is used to detect errors in signed arithmetic operations yE.g., for 8-bit ops, OF is set when there is a carry from d6 to d7 or from d7 out, but not both

37 Examples of Conditional Flags OF = 0 since there is no carry from d6 to d7 and no carry beyond d7 How can CPU know whether an operation is unsigned or signed?

38 Control Flags zIF (Interrupt Flag): set or cleared to enable or disable only the external maskable interrupt requests yAfter reset, all flags are cleared which means you (as a programmer) have to set IF in your program if allow INTR. zDF (Direction Flag): indicates the direction of string operations zTF (Trap Flag): when set it allows the program to single-step, meaning to execute one instruction at a time for debugging purposes

39 80X86 Addressing Modes zHow CPU can access operands (data) z80X86 has seven distinct addressing modes yRegister yImmediate yDirect yRegister indirect yBased relative yIndexed relative yBased indexed relative zTake the MOV instruction for example yMOV destination, source

40 Register Addressing Mode zData are held within registers yNo need to access memory yE.g.,

41 Immediate Addressing Mode zThe source operand is a constant yEmbedded in instructions yNo need to access memory yE.g.,

42 Direct Addressing Mode zData is stored in memory and the address is given in instructions yOffset address in the data segment (DS) by default yNeed to access memory to gain the data yE.g.,

43

44 Register Indirect Addressing Mode zData is stored in memory and the address is held by a register yOffset address in the data segment (DS) by default yRegisters for this purpose are SI, DI, and BX yNeed to access memory to gain the data yE.g.,

45

46 Based Relative Addressing Mode zData is stored in memory and the address can be calculated with base registers BX and BP as well as a displacement value yThe default segment is data segment (DS) for BX, stack segment (SS) for BP yNeed to access memory to gain the data yE.g.,

47

48 Indexed Relative Addressing Mode zData is stored in memory and the address can be calculated with index registers DI and SI as well as a displacement value yThe default segment is data segment (DS) yNeed to access memory to gain the data yE.g.,

49

50 Based Indexed Addressing Mode zCombines based and indexed addressing modes, one base register and one index register are used yThe default segment is data segment (DS) for BX, stack segment (SS) for BP yNeed to access memory to gain the data yE.g.,

51

52 Segment Overrides zOffset registers are used with default segment registers z80X86 allows the program to override the default segment registers ySpecify the segment register in the code


Download ppt "Lecture 03: 80X86 Microprocessor. The 80x86 IBM PC and Compatible Computers Chapter 1 80X86 Microprocessor Chapter 9.1 8088 Microprocessor."

Similar presentations


Ads by Google