Académique Documents
Professionnel Documents
Culture Documents
2.0 INTRODUCTION
A processor is the logic circuitry that responds to and processes the basic instructions
that drives a computer. The processor is the computer’s brain.
The processor (CPU) in a personal computer or embedded in small devices is often
called a microprocessor.
Microprocessor is a program-controlled device, which fetches the instructions from
memory, decodes and executes the instructions. Most microprocessors are single- chip
devices.
Microprocessor speed depends on the Data Bus width.
A common way of categorizing microprocessors is by the number of bits that ALU can
work with at a time.
The AX, BX, CX, and DX registers can be considered as two 8-bit registers, a High byte and
a Low byte. This allows byte operations and compatibility with the previous generation of 8-
bit processors, the 8080 and 8085.
Stack Pointer (SP) is a 16-bit register pointing to program stack, i.e. it is used to hold the
address of the top of stack. The stack is maintained as a LIFO with its bottom at the start of the
stack segment (specified by the SS segment register). Unlike the SP register, the BP can be
used to specify the offset of other program segments.
Base Pointer (BP) is a 16-bit register pointing to data in stack segment. It is usually used by
subroutines to locate variables that were passed on the stack by a calling program. BP register
is usually used for based, based indexed or register indirect addressing.
Source Index (SI) is a 16-bit register used for indexed, based indexed and register indirect
addressing, as well as a source data address in string manipulation instructions. Used in
conjunction with the DS register to point to data locations in the data segment.
Destination Index (DI) is a 16-bit register used in conjunction with the ES register in string
operations. DI is used for indexed, based indexed and register indirect addressing, as well as a
destination data address in string manipulation instructions. In short, Destination Index and SI
Source Index registers are used to hold address.
Instruction queue
A group of First-In-First-Out (FIFO) in which up to 6 bytes of instruction code are pre
fetched from the memory ahead of time.
This is done in order to speed up the execution by overlapping instruction fetch with
execution.
This mechanism is known as pipelining.
Flag Register
Flag register contains a group of status bits called flags that indicate the status of the
CPU or the result of arithmetic operations. There are two types of flags:
o Status flags which reflect the result of executing an instruction. The programmer
cannot set/reset these flags directly.
o Control flags enable or disable certain CPU operations. The programmer can
set/reset these bits to control the CPU's operation.
Nine individual bits of the flag register are used as control flags (3 of them) and status
flags (6 of them). The remaining 7 are not used.
A flag can only take on the values 0 and 1. We say a flag is set if it has the value 1.The
status flags are used to record specific characteristics of arithmetic and of logical
instructions.
Control Flags
There are three control flags
1. Direction Flag (D): Affects the direction of moving data blocks by such instructions
as MOVS, CMPS and SCAS. The flag values are 0 = up and 1 = down and can be
set/reset by the STD (set D) and CLD (clear D) instructions.
2. Interrupt Flag (I): Indicates whether or not system interrupts can occur. Interrupts are
actions initiated by hardware block such as input devices that will interrupt the normal
execution of programs. The flag values are 0 = disable interrupts or 1 = enable interrupts
and can be manipulated by the CLI (clear I) and STI (set I) instructions.
3. The Trap Flag (T): Determines whether or not the CPU is halted after the execution
of each instruction. When this flag is set (i.e. = 1), the programmer can single step
through his program to debug any errors. When this flag = 0 this feature is off. This
flag can be set by the INT 3 instruction.
Status Flags
There are six status flags
1. Carry Flag (C): This flag is set when there is an end carry in an addition operation or
there is an end borrows in a subtraction operation. A value of 1 = carry and 0 = no carry.
2. Overflow Flag (O): This flag is set when the result of a signed arithmetic operation is
too large to fit in the destination register (i.e. when an overflow occurs). Overflow can
occur when adding two numbers with the same sign. A value of 1 = overflow and 0 =
no overflow.
3. Sign Flag (S): This flag is set when the result of an arithmetic or logic operation is
negative. This flag is a copy of the MSB of the result (i.e. the sign bit). A value of 1 =
negative and 0 = positive.
4. Zero Flag (Z): This flag is set when the result of an arithmetic or logic operation is
equal to zero. A value of 1 means the result is zero and a value of 0 means the result is
not zero.
5. Auxiliary Carry Flag (A): This flag is set when an operation causes a carry from bit 3
to bit 4 (or a borrow from bit 4 to bit 3) of an operand. A value of 1 = carry and 0 = no
carry.
6. Parity Flag (P): This flags reflects the number of 1’s in the result of an operation. If
the number of 1’s is even its value = 1 and if the number of 1’s is odd then its value =
0.
The first are the signal having common functions in minimum as well as maximum
mode.
The second are the signals which have special functions for minimum mode
The third are the signals having special functions for maximum mode.
A19/S6-A16/S3 (address/status bus multiplexed): High order addresses bus. These are
multiplexed with status signals
RD (Read):
This signal on Active low indicates the processor is performing memory or I/O read
operation.
It is an output signal. It is active when low.
READY: This is the acknowledgement from the slow device or memory that they have
completed the data transfer.
μp enter into wait states and remain idle : READY = 0
no effect on the operation of μp : READY = 1
TEST:
This input is examined by a ‘WAIT’ instruction.
If the TEST pin goes low, execution continue, else the processor remains in an idle
state.
CLK- Clock Input: The clock input provides the basic timing for processor operation and bus
control activity. It’s an asymmetric square wave with 33% duty cycle.
The following pin functions are for the minimum mode operation of 8086.
In the minimum mode of operation the microprocessor does not associate with any
coprocessors and cannot be used for multiprocessor systems.
The following pin functions are applicable for maximum mode operation of 8086.
S2, S1, and S0 – Status Lines: These are the status lines which reflect the type of operation,
being carried out by the processor. These become active during T4 of the previous cycle and
active during T1 and T2 of the current bus cycles.
LOCK: This output pin indicates that other system bus master will be prevented from gaining
the system bus, while the LOCK signal is low. The LOCK signal is activated by the ‘LOCK’
prefix instruction and remains active until the completion of the next instruction. When the
CPU is executing a critical instruction which requires the system bus, the LOCK prefix
instruction ensures that other processors connected in the system will not gain the control of
the bus.
Figure 1.11: Map of the memory address space (MAS) of 8086 microprocessor.
Offset Registers for Various Segments: The following Table provides a summary of the
offset registers that can be used with the four segment registers of the 8086/8088:
Segment Register CS DS ES SS
Offset Register IP SI, DI, BX SI, DI, BX SP, BP
Operand defines the parameters of the action. Operands are manipulated by the opcode. It can
be data or a memory address. In this example, the operands are the register AX and the value
1000H.
Example:
MOV AX, 2550H ; move 2550H into AX
MOV CX, 625 ; load the decimal value 625 into CX
MOV BL, 40H ; load 40H into BL
The data must first be moved to a general-purpose register and then to the segment
register.
Example:
MOV AX, 2550H
MOV DS, AX
MOV DS, 0123H ; illegal instruction!
Example:
MOV AX, [2400] ; move contents of DS:2400H into AX
The physical address is calculated by combining the contents of offset location 2400
with DS
Example:
Find the physical address of the memory location and its contents after the execution of
the following, assuming that DS = 1512H.
MOV AL, 3BH
MOV [3518], AL
Solution:
First 3BH is copied into AL,
Then in line two, the contents of AL are moved to logical address DS:3518 which is
1512:3518.
Shifting DS left and adding it to the offset gives the physical address of 18638H
(15120H + 3518H = 18638H).
After the execution of the second instruction, the memory location with address 18638H
will contain the value 3BH.
They must be combined with DS in order to generate the 20-bit physical address.
Example:
MOV AX, [BX] ; moves into AX the contents of the memory location pointed to by
DS:BX, 1000:1234
Example:
MOV CL, [SI] ; move contents of DS:SI into CL
MOV [DI], AH ; move contents of AH into DS:DI
Example:
Assume that DS = 1120, SI = 2498, and AX = 17FE. Show the contents of memory
locations after the execution of
MOV [SI], AX ; move contents of AX into DS:SI
Solution:
The contents of AX are moved into memory locations with logical address DS:SI and
DS:SI + 1;
The physical address starts at DS (shifted left) + SI = 13698. According to the little
endian convention,
Low address 13698H contains FE, the low byte,
High address 13699H will contain 17, the high byte.
Example:
Assume that DS = 4500, SS = 2000, BX = 2100, SI = 1486, DI = 8500, BP= 7814, and
AX = 2512. Show the exact physical memory location where AX is stored in each of
the following. All values are in hex.
1- MOV [BX+20], AX
2- MOV [SI+10], AX
3- MOV [DI+4], AX
4- MOV [BP+12], AX
Solution:
Physical Address = segment reg. x 10 + (offset reg.) + displacement