Buses: Transfer Bits Between Microprocessor and Other Components
Buses: Transfer Bits Between Microprocessor and Other Components
22
Prepared by Mehdi Hasan Chowdhury, EEE, CUET
Microcontroller
• A device/microcomputer that includes microprocessor,
memory, several signal lines on a single chip fabricated
using VLSI technology. A single chip microcomputer is called
a microcontroller.
• The microcontroller on single chip, which typically includes a
microprocessor, 64 byte RAM, 1-2 kilo byte ROM and
several signal lines to connect I/O devices.
• Microcontroller are used for such as controlling appliances,
traffic lights etc.
23
Prepared by Mehdi Hasan Chowdhury, EEE, CUET
some Important Terms
• Bit (b) - a binary digit, 0 or 1.
• Byte (B) - a group of 08 bits. (1 byte = 8 bits)
• Instruction - a command in binary, recognized & executed
by the computer.
24
Prepared by Mehdi Hasan Chowdhury, EEE, CUET
The Microprocessor
& its architecture
25
Prepared by Mehdi Hasan Chowdhury, EEE, CUET
8, 16, 32 & 64-bit MP
26
Prepared by Mehdi Hasan Chowdhury, EEE, CUET
Register
A register is one of a small set of data holding places that
are part of a computer processor.
Registers are two types:
1. General-purpose or multipurpose Registers
these registers hold various data sizes and used for
almost any purpose
2. Special purpose Registers
used in special purposes
27
Prepared by Mehdi Hasan Chowdhury, EEE, CUET
General-purpose or multipurpose Registers
Bit position 15 8 7 0
AX AH AL Accumulator
BX BH BL Base index
CX CH CL Count
DX DH DL Data
BP Base pointer
SI Source index
DI Destination index
• The MP has 07 general purpose registers.
• Each registers are 16-bit in size, while some registers can be
divided into two 8-bit register.
• The acceptable 8-bit register pairs are AH-AL, BH-BL, CH-CL, DH-
DL. These pairs forms AX, BX, CX, DX registers respectively.
28
Prepared by Mehdi Hasan Chowdhury, EEE, CUET
General-purpose Registers…
1. AX register
Called 16-bit accumulator while AH/AL is 8-bit accumulator
Used for instructions such as Multiplication & division
2. BX register
16-bit Base index register while BH/BL is 8-bits
sometimes holds offset address
3. CX register
16-bit Count register while CH/CL is 8-bits
Holds the count for various instructions such as SHIFT,
ROTATE, LOOP, etc
4. DX register
16-bit Data register while DH/DL is 8-bits
Holds a part of the result from multiplication or part of the
dividend before a division.
Need for I/O devices 29
Prepared by Mehdi Hasan Chowdhury, EEE, CUET
General-purpose Registers…
5. BP register
16-bit Base Pointer register
Points to a memory location
6. SI register
16-bit Source Index register
Addresses source string data for the string instructions
7. DI register
16-bit Destination Index register
Addresses string destination data for the string instructions
30
Prepared by Mehdi Hasan Chowdhury, EEE, CUET
Special-purpose Registers
Special-purpose registers include IP, SP, FLAGS
1. IP register
Called 16-bit Instruction Pointer.
The Instruction pointer, which points to the next instruction in a
program, is used by the microprocessor to find the next
sequential instruction in a program located within the code
segment.
2. SP register
16-bit Stack Pointer, addresses an area of memory called the
stack.
The stack memory stores data through this pointer.
3. FLAGS register
A flag resister (F or FL) is a 16-bit registers which indicates
some condition produced by the execution of an instruction and
controls certain operation of the MP.
31
Prepared by Mehdi Hasan Chowdhury, EEE, CUET
Special-purpose Registers…
FLAGS register
Flag resister contains 09 active flags. Among them 06 are
status flags (indicate some condition produced by an
instruction) and 03 are control flags (control certain operation of
processor).
The flags are -
Carry (C)
Parity (P)
Auxiliary carry (A)
Zero (Z)
Sign (S)
Trap (T)
Interrupt (I)
Direction (D)
Overflow (O) 32
Prepared by Mehdi Hasan Chowdhury, EEE, CUET
Special-purpose Registers (FLAGS register…)
Undefined/unused flags
33
Prepared by Mehdi Hasan Chowdhury, EEE, CUET
Special-purpose Registers (FLAGS register…)
1) C (Carry) Flag
It holds the carry after addition or the borrow after
subtraction.
34
Prepared by Mehdi Hasan Chowdhury, EEE, CUET
Special-purpose Registers (FLAGS register…)
2) P (Parity) Flag
Parity is the count of ones in register.
expressed as even or odd.
Logic 0 for odd parity; logic 1 for even parity.
if a number contains no one bits, it has even parity
37
Prepared by Mehdi Hasan Chowdhury, EEE, CUET
Special-purpose Registers (FLAGS register…)
5) S (Sign) Flag
The sign flag holds the arithmetic sign after an arithmetic or
a logical operation.
If S =1 the sign bit is set and the result is negative (-ve).
If S = 0, the sign bit is not set and the result is positive (+ve).
Usually sign bit is the leftmost bit.
6) T (Trap/Trace) Flag
It enables trapping through an on-chip debugging
(checking error) facility.
T =1, Debugging enable
T = 0, Debugging disable
38
Prepared by Mehdi Hasan Chowdhury, EEE, CUET
Special-purpose Registers (FLAGS register…)
7) I (Interrupt) Flag
The interrupt flag controls the operations of the INTR
(Interrupt request) input pin.
If I =1, the INTR pin is enabled;
if I =0, the INTR pin is disabled.
8) D (Direction) Flag
The D flag selects either the increment or decrement mode
for DI and/or SI registers during string instructions.
If D=1 the registers are automatically decremented;
if D=0 the registers are automatically incremented.
Decrement mode indicates Set direction and write with STD
(set direction) instruction.
Increment mode indicates Clear direction and write with
cleared with the CLD (clear direction) instruction. 39
Prepared by Mehdi Hasan Chowdhury, EEE, CUET
Special-purpose Registers (FLAGS register…)
9) O (Overflow) Flag
An overflow indicates that the result has exceeded the
capacity of the machine.
Overflow occurs when signed numbers are added or
subtracted.
Mainly occurs during multiplication operation.
If O=1, Overflow occurs;
if O=0, No overflow.
40
Prepared by Mehdi Hasan Chowdhury, EEE, CUET
Segment Registers
Segment Registers are additional registers, generate memory
addresses when combined with other registers in the
microprocessor.
In a word, segment registers are section of memory.
CS CODE Segment
DS DATA Segment
ES EXTRA Segment
SS STACK Segment
41
Prepared by Mehdi Hasan Chowdhury, EEE, CUET
Segment Registers…
1) Code segment (CS)
The code segment is a section of memory that holds the
code (programs and procedures) used by the
microprocessor.
The code segment (CS) register defines the starting
address of the section of memory holding code.
The code segment size is limited to max 64KB.
44
Prepared by Mehdi Hasan Chowdhury, EEE, CUET
Segment and Offset address
45
Prepared by Mehdi Hasan Chowdhury, EEE, CUET
Segment and Offset address…
Combination of a segment address and an offset
address access a memory location.
The segment address located within one of the
segment registers, defines the beginning address of
any 64K-byte memory segment.
The offset address is also held in a register and selects
any location within the 64K byte memory segment. An
offset address is also sometimes referred to as
displacement or logical address.
A memory location pointed by a segment address of
1000H and offset address of 2000H is written as
1000:2000.
What is the actual/physical memory location for
1000:2000?
46
Prepared by Mehdi Hasan Chowdhury, EEE, CUET
Segment and Offset address…
Calculation of physical address from segment : offset
pair 1000:2000
47
Prepared by Mehdi Hasan Chowdhury, EEE, CUET
Default Segment and Offset Registers
8086 has a set of rules that apply to segments whenever
memory is addressed. These rules define the segment and
offset register combination
String destination
ES DI ES:DI
address
48
Prepared by Mehdi Hasan Chowdhury, EEE, CUET
49
Prepared by Mehdi Hasan Chowdhury, EEE, CUET
50
Prepared by Mehdi Hasan Chowdhury, EEE, CUET
8086 Internal Architecture
8086 MP is internally divided into two separate
functional units:
1. Bus Interface Unit (BIU)
2. Execution Unit (EU)
51
Prepared by Mehdi Hasan Chowdhury, EEE, CUET
8086 Internal Architecture…
Bus Interface Unit (BIU) Functions:
To fetch instruction from memory or I/O devices
To generate physical address
Supply information to EU
52
Prepared by Mehdi Hasan Chowdhury, EEE, CUET
53
Prepared by Mehdi Hasan Chowdhury, EEE, CUET
8086 Internal Architecture…
Instruction Queue:
• To increase the execution speed, BIU fetches as
many as six instruction bytes ahead to time from
memory.
• All six bytes are then held in first in first out 6 byte
register called instruction queue.
• Then all bytes have to be given to EU one by one.
• This pre fetching operation of BIU may be in
parallel with execution operation of EU, which
improves the speed execution of the instruction.
• Fetching the next instruction while the current
instruction executes is called pipelining.
54
Prepared by Mehdi Hasan Chowdhury, EEE, CUET
Prepared by Mehdi Hasan Chowdhury, EEE, CUET