Professional Documents
Culture Documents
Unit I
Unit I
3/23/2023 2
Microprocessor
3/23/2023 3
Microprocessor
3/23/2023 4
3/23/2023
Indira College of Engineering Management, Pune 5
Brief History of Intel Processors
3/23/2023
Indira College of Engineering Management, Pune 6
Intel
1971 - 4004
• First microprocessor
• All CPU components on a single chip
• 4 bit, Single Core
• Clock speed 740 KHz
• It had 2300 transistors
• Could execute 60,000 instructions per second
3/23/2023 7
Intel
1974 - 8080
• Intel’s first general purpose microprocessor (8 bit)
• It is faster with NMOS technology
• Clock speed was 2MHz
• It had 6,000 Transistors
• 10 times faster than 8008
• But it requires 3 Power Supplies
• Could execute 5,00,000 instructions per second
3/23/2023 9
x86 Evolution
• 8088
– Introduced in 1979
– 16 Bit Microprocessor
– It was created as cheaper version of 8086
– It could execute 2.5 million instructions in one second
– This chip became most popular when it was used in first IBM PC
3/23/2023 10
x86 Evolution
• 80286
– Introduced in 1982
– 16 bit
– Clock speed 8 MHz
– It could address 16MB memory
– It had 1,34,000 Transistors
– It could execute 4 Million instructions per second.
• 80386
– Introduced in 1986
– 32 bit
– It could address 4 GB of memory
– It had 1,75,000 transistors.
– Support for multitasking
– Clock speed varied from 16MHz, to 33 MHz depending on version
– It is best selling microprocessor in history
3/23/2023 11
x86 Evolution
• 80486
– Introduced in 1989
– sophisticated powerful cache and instruction pipelining
– built in maths co-processor
– It had 1.2 million transistors
– Clock speed is 16 MHz to 100 MHz
– 8KB Cache memory was introduced
3/23/2023 13
Family tree of 80386
Addres s
Chip Introduction Data bus Memory
Bus
4004 1971 4 8 256 Byte
256 Byte
8008 1972 8 8
8080 1974 8 16 64 KB
1M
8086/88 1978 16/8 20
1M
80186/188 1982 16/8 20
16M:Clock speed is
80286 1983 16 24
high
DX(1986:not
DX:4G (275,000
compatibility) SX(1988: mostly DX:32+132 pin 32
80386 transistor)
used, Not Co-Processor) SX:16+100 pin 24
SX:16MB
Memory Size:4G
80486 32 32
+16K cache
14
Difference between 80386 SX/DX
15
80386 DX Features and Architecture, Programmers
Model
3/23/2023
Indira College of Engineering Management, Pune 16
Features of 80386DX
• Flexible 32-bit Microprocessor
– 8, 16, 32-Bit Data Types • Hardware Debugging Support
– 8 General Purpose 32-Bit Registers
– 32 bit ALU • 3 stage Pipeline
– 32 bit Data Bus(4 memory Bank)
– 32 bit Address Bus( 4 GB Memory) • Multitasking
3/23/2023 17
80386DX Architecture
• A bus interface.
• offers address pipelining, dynamic data bus sizing, and direct Byte Enable signals for
each byte of the data bus
3/23/2023 19
Central Processing Unit
Central processing unit is further divided into Execution unit and
Instruction unit.
The Instruction unit decodes the opcode bytes received from the 16-
byte instruction code queue and arranges them in a 3- instruction
decoded instruction queue.
20
After decoding them pass it to the control section for deriving
the necessary control signals. The barrel shifter increases
the speed of all shift and rotate operations.
21
Memory Management Unit
The Memory management unit consists of a Segmentation unit
and a Paging unit.
22
The Paging unit organizes the physical memory in terms of
pages of 4 kbytes size each.
23
The Segmentation unit provides a 4 level protection mechanism for
protecting and isolating the system code and data from those of the
application program.
The control and attribute PLA checks the privileges at the page level.
Each of the pages maintains the paging information of the task.
The limit and attribute PLA checks segment limits and attributes at
segment level to avoid invalid accesses to code and data in the memory
segments.
24
Bus Interface Unit
The Bus control unit has a prioritizer to resolve the priority of the
various bus requests.
This controls the access of the bus. The address driver drives the bus
enable and address signal A0– A31.
The pipeline and dynamic bus sizing unit handle the related control
signals.
The data buffers interface the internal data bus with the system bus.
25
MEMORY ORGANIZATIONAND
SEGMENTATION
The physical memory of an 80386 system is organized as a sequence of 8-bit
bytes.
Each byte is assigned a unique address that ranges from
0 to a maximum of 232 -1.(4 Gigabytes).
The model of memory organization determined by systems-software
designers.
26
MEMORY ORGANIZATIONAND
SEGMENTATION
Segmented model: collection of up to 16,383 address spaces. linear
27
Programmers Model
• Intel386 DX base architecture registers:
Instruction pointer
Flags register
3/23/2023 28
Register Organization of 80386
3/23/2023 29
SEGMENT REGISTERS
o Six segments of memory may be immediately accessible to an executing 80386
program.
o The segment registers CS, DS, SS, ES, FS, and GS are used to identify these six
current segments.
o Each of these registers specifies a particular kind of segment, as characterized by the
associated mnemonics ("code," "data," or "stack").
3/23/2023 34
VM Bit - Virtual Mode Flag
3/23/2023
Indira College of Engineering Management, Pune 41
Processing Modes
• The Intel386 DX modes of operation: • Protected mode:
– Real Address Mode (Real Mode), and – Natural 32-bit environment, in which all
– Protected Virtual Address Mode instructions and features are available.
(Protected Mode). – It provides access to the sophisticated
– Virtual 8086 mode (V86 Mode). memory management, paging and privilege
capabilities of the processor
3/23/2023 42
Instruction Format
The information encoded in an 80386 instruction includes a
specification of ;
Operation to be performed (Opcode).
Type of the operands to be manipulated,
Location of these operands.
Opcode Source(M/ Reg) Destination(M/ Reg)
43
Operand Selection
In the instruction itself(immediate operand)
In a register
In memory
At an I/O port
Implicit operand
Explicit operand
Implicit and Explicit Operand
44
INSTRUCTION FORMAT
45
Immediate Operands
Register Operands
Memory Operands
Segment Selection
46
Effective Address Computation
47
Effective Address Computation…
Displacement: Indicates the offset of the operand . Used to
directly address a statically allocated scalar operand.
Base: Offset is specified indirectly in one of the general
registers, as for based variables.
Base+displacement:
To index into static array when element size is not 2,4,8 bytes.
Access item of record. Displacement component locates an item
within record.
(Index*scale) + displacement: Provides efficient indexing into a static
array when element size is 2,4,8 bytes.
48
Effective Address Computation…
Base + Index + Displacement: Two registers used together
support either a two dimensional array (where displacement
determine beginning of array) or one of several instances of an
array of records (where displacement indicates an item in the
record.)
Base + (Index * Scale) + displacement: This combination
provides efficient indexing of a two-dimensional array when
element of the array are 2,4,8 bytes wide.
49
80386 Addressing Modes
Addressing modes indicate a way of locating data or operands.
Describes the type of operands and the way they are accessed for executing an instruction.
The method by which address of source data and destination address of result is given in the
instruction is called as “ Addressing Modes”.
The 80386 Microprocessor Provide 11 addressing modes
• Register Indirect addressing Mode • Based Index addressing Mode with Displacement
50
Register Addressing Modes
• The data is stored in a register and it is referred using a particular register.
• The 8/16/32 bit data required to execute an instruction is present in 8/16/32 bit register is
given along with the instruction is called “Register addressing mode.”
3/23/2023 51
Immediate addressing mode
• In this addressing mode, immediate data is part of instruction.
• The 8/16/32 bit data required to execute an instruction is given directly along with the
instruction is called “Immediate addressing mode”.
3/23/2023 52
Direct and Register Indirect addressing
mode
• Direct addressing mode
The operand's offset is contained as part of the instruction as an 8-, 16- or 32-bit
displacement.
In Direct addressing mode the effective address of memory location where the operand
is present is written directly in the instruction.
Example: MOV AX, [5000H]
3/23/2023 53
Based and Index addressing mode
3/23/2023 54
Scaled Index & Based Index addressing mode
3/23/2023 55
Other addressing mode
• Based Scaled Index addressing mode: The contents of an INDEX register is multiplied by a
SCALING factor and the result is added to the contents of a BASE register to obtain the
operands offset.
• Based Index addressing Mode with Displacement: The contents of a BASE register is added
to the contents of an INDEX register to form the effective address of an operand.
• Based Scaled Index addressing Mode with Displacement: The contents of an INDEX register
are multiplied by a SCALING factor, the result is added to the contents of a BASE register and a
DISPLACEMENT to form the operand's offset.
3/23/2023 56
Data Types
Fundamental Data Types:
• Byte
• Word
• Doubleword
3/23/2023 57
Byte, word and doubleword in memory
3/23/2023 58
80386 Data Types
3/23/2023 59
80386 Instruction Set
3/23/2023
Indira College of Engineering Management, Pune 60
Agenda
• Data Movement Instructions
• Binary Arithmetic Instructions
• Decimal Arithmetic Instructions
• Logical Instructions
• Control Transfer Instructions
• String and Character translation Instructions
• Instructions for Block-Structured Languages
• Flag Control Instructions
• Coprocessor Interface Instructions
• Segment Register Instructions
• Miscellaneous Instructions
3/23/2023 61
Data Movement Instructions
• Provides convenient methods for moving bytes, words or
doublewords of data between memory and the register.
• Various Classes
o General purpose data movement instructions
o Stack manipulation instructions
o Type-conversion instructions
3/23/2023 62
General Purpose data movement instructions
• MOV (Move): Transfers a byte, word or doubleword from the source operand
to the destination operand
• Operand options
– To a register from memory
– To memory from a register
– Between general registers
– Immediate data to a register
– Immediate data to a memory
3/23/2023 63
General Purpose data movement instructions
• XCHG (Exchange): Swaps the contents of
two operands.
3/23/2023 64
Stack manipulation Instructions
• PUSH
• PUSHA
• POP
• POPA
3/23/2023 65
Stack Manipulation Instructions
• PUSH (Push)
• decrements the stack pointer (ESP), then transfers the source operand to the top
of stack indicated by ESP.
• PUSH is often used to place parameters on the stack before calling a procedure;
• It is also the basic means of storing temporary variables on the stack.
• The PUSH instruction operates on memory operands, immediate operands, and
register operands (including segment registers).
• PUSHA (Push All Registers) saves the contents of the eight
general registers on the stack.
•
• This instruction simplifies procedure calls by reducing the
number of instructions required to retain the contents of the
general registers for use in a procedure
3/23/2023 72
There are two classes of type conversion instructions:
• MOVZX EAX,BL
• This copies the contents of BL register to EAX register. Zero is
copied to the MSB of the EAX register as well as the AH
register.
Binary Arithmetic Instructions
• Addition and subtraction instructions
– ADD (Add integers)
– ADC (Add integers with carry)
– INC (Increment)
– SUB (Subtract integers)
– SBB (Subtract integers with borrow)
– DEC (Decrement)
3/23/2023 81
Binary Arithmetic Instructions
3/23/2023 82
Binary Arithmetic Instructions
• Multiplication Instructions: • Division Instructions:
• MUL (Unsigned Integer multiply) • DIV (Unsigned Integer division)
3/23/2023 84
Logical Instructions
The Boolean operation instructions
3/23/2023 85
Logical Instructions (Cont…)
The Boolean operation instructions Boolean operation instructions:
3/23/2023 86
Logical Instructions (Cont…)
The Boolean operation instructions
3/23/2023 87
Logical Instructions (Cont…)
Bit test and modify instructions: Bit Scan Instructions:
• Operates on single bit within the
operand (Register or Memory) • Scan a word or doubleword for a one-bit and
store the index of the first set bit into a register
• Bit location is specified as an offset
from low-order end of the operand • ZF is set if entire operand is zero
BSF (Bit Scan Forward)-Bsr locates the first
Instruction Effect on CF Effect on
set bit searching from the L.O. bit down to
Selected
Bit the H.O. bit.
3/23/2023 89
Logical Instructions (Cont…)
• Shift and Rotate Instructions: Byte set on Condition instructions:
– Shift instructions
• SAL (Shift Arithmetic Left) • Sets a byte to Zero or One depending on any
• SHL (Shift Logical Left) of the 16 conditions defined by the status
• SHR (Shift Logical Right) flags
• SAR (Shift Arithmetic Right)
SETcc (Set byte on condition cc)
– Double shift instructions
• SHLD (Shift Left Double) • Test Instructions:
• SHRD (Shift Right Double)
TEST (Test) performs the logical “and”
– Rotate instructions
• ROL, ROR, RCL, RCR
3/23/2023 90
SHL/SAL(Shift logical/arithmetic left byte or word or double
word)
• SAL/SHL destination , count
• Shifts all bits left , the bit that goes off is set to CF.
• Zero bit is inserted in the right most position
• Flags affected: OF,CF,AF,PF,SF
• Shr ( Shift logical right byte or word or double word)
SHR destination,count
Shifts all bits right the bit that goes off is set to CF.
Zero bit is inserted to the left most Position.
All Flags affected.
• shr ax, 1 ;Equivalent to AX/2
• shr ax, 2 ;Equivalent to AX/4
• shr ax, 3 ;Equivalent to AX/8
• shr ax, 4 ;Equivalent to AX/16
• shr ax, 5 ;Equivlaent to AX/32
• shr ax, 6 ;Equivalent to AX/64
• shr ax, 7 ;Equivalent to AX/128
• shr ax, 8 ;Equivalent to AX/256
• SAR ( Arithmetic Right Byte or Word or DD)
SAR destination, count
Shifts all bits right the bit that goes off is set to CF. The sign bit
that is inserted to the leftmost position has the same value as
before shift.
• Difference between Test and AND is that TEST does not alter the
destination operand
• Difference between Test an Bit Test is
• BT tests a single bit and
• TEST tests multiple bits in one operation.
Control Transfer Instructions
Unconditional Transfer
• JMP (Jump)- one way transfer of execution
Instructions
3/23/2023 109
Control Transfer Instructions
Conditional transfer instructions
• Conditional jump instructions
3/23/2023 110
Control Transfer Instructions
3/23/2023 111
Loop Instructions
• The loop instructions are conditional jumps that use a value placed in
ECX to specify the number of repetitions of a software loop.
• If the value of ECX is initially zero, then the LOOP executes 232
times.
• LOOPE (Loop While Equal) and LOOPZ (Loop While
Zero) are synonyms for the same instruction.
• If ECX is non-zero and ZF=1, the program branches to the target label
specified in the instruction.
• If ECX is non-zero and ZF=0, the program branches to the target label
specified in the instruction.
• JCXZ- (Jump if ECX Zero) JCXZ is useful in combination with the LOOP
instruction and with the string scan and compare instructions, all of which
decrement ECX.
• Sometimes, it is desirable to design a loop that executes zero times if the count
variable in ECX is initialized to zero.
• Because the LOOP instructions (and repeat prefixes) decrement ECX before they
test it, a loop will execute 232 times if the program enters the loop with a zero
value in ECX.
• A programmer may conveniently overcome this problem with JCXZ, which
enables the program to branch around the code within the loop if ECX is zero
when JCXZ executes.
Software-Generated Interrupts
• The INT n, INTO, and BOUND instructions allow the programmer to
specify a transfer to an interrupt service routine from within a
program.
• INT n (Software Interrupt 0-255) activates the interrupt service
routine that corresponds to the number coded within the instruction.
• The INT instruction may specify any interrupt type .
• Programmers may use this flexibility to implement multiple types of
internal interrupts or to test the operation of interrupt service routines.
(Interrupts 0-31 are reserved by Intel.)
• The interrupt service routine terminates with an IRET instruction that
returns control to the instruction that follows INT.
INTO (Interrupt on Overflow) invokes interrupt 4 if OF is set.
• Interrupt 4 is reserved for this purpose.
• OF is set by several arithmetic, logical, and string instructions.
BOUND (Detect Value Out of Range) verifies that the signed value
contained in the specified register lies within specified limits.
An interrupt (INT 5) occurs if the value contained in the register is less
than the lower bound or greater than the upper bound.
BOUND index,Range
Test the value of index register against predefined range of index if it is
out of range then INT 5 is generated.
String and Character translation instructions
3/23/2023 119
Instructions for Block-Structured Languages
3/23/2023 120
Flag Control Instructions
Carry and Direction Flag control instructions
Flag transfer instructions
3/23/2023 121
• Segment-register transfer instructions • Data pointer instructions
–MOV –LDS (Load pointer using DS)
–POP –LES (Load pointer using ES)
–PUSH –LFS (Load pointer using FS)
–LGS (Load pointer using GS)
–LSS (Load pointer using SS)
•Far control transfer instructions
–Direct far JMP
–Indirect far JMP
–Far CALL
–Far RET
3/23/2023 122
Miscellaneous Instructions
Address calculation instruction
• LEA (Load effective address)
No-operation instruction
• NOP (No operation)
Translate instruction
• XLAT
3/23/2023 123
Miscellaneous Instructions
• Address Calculation Instruction
LEA (Load Effective Address) LEA register,source
transfers the offset of the source operand (rather than its value) to the destination
operand.
• The source operand must be a memory operand, and the destination operand must be
a general register.
• This instruction is especially useful for initializing registers before the execution of
the string primitives (ESI, EDI) or the XLAT instruction (EBX).
• The LEA can perform any indexing or scaling that may be needed.
• Example: LEA EBX, EBCDIC_TABLE
Causes the processor to place the address of the starting location of the table labeled
EBCDIC_TABLE into EBX.
• No-Operation Instruction
• NOP (No Operation) occupies a byte of storage but affects nothing but
the instruction pointer, EIP.
• This instruction uses three clock cycles and increments the instruction
pointer (EIP) to point to the next instruction.
• It can be used to increase the delay of a delay loop.
• Translate Instruction
• XLAT (Translate) replaced a byte in the AL register with a byte from a
user-coded translation table.
• When XLAT is executed, AL should have the unsigned index to the table
addressed by EBX.
• XLAT changes the contents of AL from table index to table entry. EBX is
unchanged.
• The XLAT instruction is useful for translating from one coding system to
another such as from ASCII to EBCDIC.
• The translate table may be up to 256 bytes long.
• The value placed in the AL register serves as an index to the location of
the corresponding translation value.