Professional Documents
Culture Documents
Chapter 1 Introduction
Chapter 1 Introduction
INTRODUCTION TO
MICROPROCESSORS
Dr Manoj V.N.V.
TEXT BOOKS
Gilmore C., “Microprocessor – Principles
and Applications”, 2nd Edition, Tata
McGraw-Hill, 1994
Huang H., “PIC Microcontroller: An
Textbooks
Introduction to Software and Hardware
Interfacing”, Thomson Delmar Learning,
2005
Microprocessors”, McGraw-Hill 2
International, 1984
Dr. Manoj V.N.V.
MICROPROCESSOR
In the year 1969 the microprocessor was called the “Micro computer
chip” and this was named by Busicom. The term microprocessor was
developed until 1972.
Webster
Integrated circuit that contains the entire central processing unit of a computer
on a single chip.
Chambers
Microprocessor is a device that integrates the functions of the CPU in a
computer onto the IC or semiconductor chip
Oxford Dictionary
An integrated circuit that contains all the functions of a central processing unit of
a computer
Slide
3
Buses
Address bus
Data bus
Control bus
Slide
4
CPU
Arithmetic
Register
Logic
Arrays
Unit Microprocessor-based System
Control Unit
Slide
5
Slide
6
Control Unit
Slide
9
Slide
10
Slide
11
Slide
12
Slide
16
Pentium
Superscalar
Multiple instructions executed in parallel
Pentium Pro
Increased superscalar organization
Aggressive register renaming
branch prediction
data flow analysis
speculative execution Slide
18
Pentium III
Additional floating point instructions for 3D graphics
Pentium 4
Further floating point and multimedia enhancements
Itanium
64 bit
Itanium 2
Hardware enhancements to increase speed
Slide
19
Slide
21
Slide
22
Slide
23
Slide
24
Slide
25
Slide
26
Slide
27
Slide
28
Slide
29
Slide
30
Slide
31
Slide
32
Slide
33
Slide
34
Slide
35
Slide
36
Slide
37
Slide
38
Slide
39
Slide
41
Slide
42
Slide
43
Slide
44
Slide
45
Slide
46
G4:
Increases parallelism and internal speed
G5:
Improvements in parallelism and internal speed
64-bit organization
Slide
49
Slide
50
Slide
51
Slide
52
Slide
55
Slide
56
Slide
57
Slide
58
Slide
59
Slide
60
Slide
61
Slide
62
Slide
63
Slide
64
CS 3 4 8 A 0 DS 1 2 3 4 0
IP + 4 2 1 4 DI + 0 0 2 2
Instruction address 3 8 A B 4 Data address 1 2 3 6 2
SS 5 0 0 0 0
SP + F F E 0
Stack address 5 F F E 0
Physical Address is some times referred as Effective Address
Slide
65
Slide
66
Slide
67
Slide
68
Slide
69
Slide
70
Slide
71
Slide
73
Division Instructions:
DIV Divide unsigned word by byte or unsigned double word by word.
IDIV Divide signed word by byte or signed double word by word.
AAD ASCII adjust before division.
CBW Fill upper byte of word with copies of sign bit of lower byte.
CWD Fill upper word of double word with sign bit of lower word.
Slide
75
Slide
76
Shift Instructions:
SHL/SAL Shift bits of word or byte left, put zero(s) in LSB(s).
SHR Shift bits of word or byte right, put zero(s) in MSB(s).
SAR Shift bits of word or byte right, copy old MSB into new MSB
Rotate Instructions:
ROL Rotate bits of byte or word left, MSB to LSB and to CF.
ROR Rotate bits of byte or word right, LSB to MSB and to CF.
RCL Rotate bits of byte or word left, MSB to CF and CF to LSB.
RCR Rotate bits of byte or word right, LSB to CF and CF to MSB.
Slide
77
Note: A ‘B’ in a mnemonic is used to specifically indicate that a string of bytes is to be acted upon. A ‘W’ in
Slide
the mnemonic is used to indicate that a string of words is to be acted upon.
78
Slide
79
Interrupt Instructions:
INT Interrupt program execution, call service procedure (ISR-Interrupt Service Routine).
INTO Interrupt program execution if OF = 1.
IRET Return from interrupt service procedure to main program.
Slide
81
Slide
82
Slide
83
Slide
85
Slide
86
Slide
87
EXAMPLES:
Slide
88
The XLATB instruction can be used to convert any code of 8 bits or less to any other code of 8
bits or less.
Slide
89
For the variable-port-type IN instruction, the port address is loaded into the DX
register before the IN instruction. Since DX is a 16-bit register, the port address can
be any number between 0000H and FFFFH. Therefore, up to 65,536 ports are
addressable in this mode.
Slide
92
Slide
95
Slide
96
Slide
97
Slide
98
Slide
104
Slide
106
terminal, we can OR AL with 30H to produce the correct ASCII code for the result. 107
Since the remainder is greater than half of the divisor, the actual quotient is
closer to 5FH than to the 5EH produced. However, as indicated before, the
quotient is always truncated to the next lower integer rather than rounded to
the closest integer. Slide
113
Slide
114
NOTE: If an attempt is made to divide by 0, the 8086 will do a type 0 interrupt. 115
EXAMPLE:
AX = 00000000 10011011 155 decimal
CBW Convert signed byte in AL to signed word in AX
Result: AX = 11111111 10011011 155 decimal
Slide
116
EXAMPLES:
NOT BX Complement contents of BX register
NOT BYTE PTR [BX] Complement memory byte at offset IBXI in data
segment
Slide
118
BX = 10110011 01011110
AND BX, 00FFH Mask out upper 8 bits of BX
Result: BX = 00000000 01011110
CF, OF, PF, SF, ZF = 0
CF and OF are both 0 after AND. PF, SF, and ZF are updated by AND. AF Slide
is undefined. 119
Slide
121
TEST AL, BH AND BH with AL, no result stored. Update PF, SF, ZF
TEST CX, 0001 H AND CX with immediate number 0001H, no result stored.
Update PF, SF, ZF
TEST BP, [BX][DI] AND word at offset [BX][DI] in DS with word in BP. no result
stored. Update PF, SF, and ZF
Example of a polling sequence using TEST
AGAIN: IN AL, 2AH Read port with strobe connected to LSB
TEST AL, 01H AND immediate 01 H with AL to test if LSB of
AL is 1 or 0 ZF = 1 if LSB of result is 0 No result stored
JZ AGAIN Read port again if LSB = 0
AL = 01010001
TEST AL, 80H AND immediate 80H with AL to test if MSB of AL is 1 or 0
ZF = 1if MSB of AL = 0. AL = 01010001 (unchanged) Slide
SAL BYRE PTR [BX], 1 Shift byte In DS at offset [BX], 1 bit position left, 0 in LSB
IN AL, COUNTER_DIGIT
MOV CL, 04H Set count for 4 bit positions
SAL AL, CL Shift BCD to upper nibble, 0's in lower nibble.
Slide
124
Slide
126
ROL affects only CF and OF. After ROL, CF will contain the bit most recently rotated out of the MSB. OF
will be a1 after a single bit ROL if the MSB was changed by the rotate.
ROL AX, 1 Word in AX1bit position left, MSB to LSB and CF
MOV CL, 04H Load number of bits to rotate in CL
ROL BL, CL Rotate BL 4 bit positions (swap nibbles)
ROL FACTOMBXI, 1 MSB of word or byte in DS at EA = FACTOR[BXI]
1 bit position left into CF
JC ERROR Jump if CF =1to en-or routine
Slide
128
RCR affects only CF and OF. After RCR, CF will contain the bit most recently rotated out of the MSB.
OF will be a 1 after a single-bit RCR if the MSB was changed by the rotate.
OF will be undefined after multibit rotates.
RCR BX, 1 Word in BX right 1 bit CF to MSB, LSB to CF
MOV CL, 04H Load CL for rotating 4 bit positions
RCR BYTE PTR [BX] Rotate byte at offset [BX] in DS 4 bit positions right
CF = original bit 3. Bit 4 original CF
RCR BL, 1 CF = 1, BL = 001 1 1000
Result: BL = 10011100, CF = 0 OF = 1 because MSB changed to 1
CF = 0, WORD PTR [BX]= 0101111000001111
MOV CL, 02H Load CL for rotate 2 bit positions
RCR WORD PTR [BX], CL Rotate word in DS at offset [BX], 2 bits right
CF = original bit 1. Slide
130
Bit 14 = original CF,WORD PTR [BX] = 10010111 10000011
Dr. Manoj V.N.V.
MOVS/MOVSB/MOVSW -MOVE STRING BYTE OR STRING WORD
MOVS DESTINATION STRING-NAME, SOURCE STRING-NAME
This instruction copies a byte or a word from a location in the data segment to
a location in the extra segment.
The offset of the source byte or word in the data segment must be in the SI
register.
The offset of the destination in the extra segment must be contained in the DI
register.
For multiple-byte or multiple-word moves, the number of elements to be
moved is put in the CX register so that it can function as a counter.
After the byte or word is moved, SI and DI are automatically adjusted to point
to the next source and the next destination.
If the direction flag is 0, then SI and DI will be incremented by 1 after a byte
move and incremented by 2 after a word move.
If the DF is a 1, then SI and DI will be decremented by 1 after a byte move and
decremented by 2 after a word move.
Slide
MOVS affects no flags. 131
After the move, SI will be 1 greater than the offset of the last byte in the source string.
DI will be 1 greater than the offset of the last byte in the destination string.
CX will be 0.
Slide
132
Slide
133
Slide
137
Slide
139