Unit 1&3
Unit 1&3
Micro Processor:
The CPU inbuilt on a single si chip it execute the instructions step by step.
The processors are: 8085, 8086, 8088, 80186,80286,80386,80486,Pentium processor
Explain the architecture of 8086 Micro Processor?BIU,EU Units?
Feature of 8086 micro processor
It is a 16 bit p.
8086 has a 16 bit data bus. The data bus is bidirectional. The data range (D0-D15)
8086 has a 20 bit address bus can access up to 220 memory
locations ( 1 MB) .The address bus is unidirectional. address range (A0-A19)
It can support upto 64K I/O ports.
It provides 14, 16-bit registers.
It has multiplexed address and data bus AD0- AD15 and A16 A19It requires single phase clock with
33% duty cycle to provide internal timing.
8086 is designed to operate in two modes, Minimum and Maximum.
It can prefetches upto 6 instruction bytes from memory and
queues them in order to speed up instruction execution.
It requires +5V power supply.
A 40 pin dual in line package
BUS INTERFACE UNIT(BIU)
The bus interface unit(BIU) are divided into three main blocks are
1.Six Instruction byte queue
2. Segment register
3.Intruction pointer
EXECUTION UNIT(EU)
The Execution unit divided into three main blocks are
1.ALU
2.Registers
3.Control unit
6
5
4
3
2
1
2.Segment Register:
8086's BIU produces the 20-bit physical memory address by combining a 16-bit segment address
with a 16-bit offset address. There are four 16-bit segment registers, viz., the 1. code segment (CS), the
stack segment (SS), the extra segment (ES), and the data segment (DS). These segment registers hold the
corresponding 16-bit segment addresses. A segment address is the upper 16-bits of the starting address
of that segment. The lower 4-bits of the starting address of a segment is always zero. The offset address
is held by another 16-bit register. The physical 20-bit address is calculated by shifting the segment
address 4-bit left and then adding that to the offset address.
For Example:
Code Segment: It is a 16-bit registers stores starting address of codesegment.
Code
Instruction
segment
Register
pointer
IP
CS
holds
holds
the
the
segment
offset
address
address
which
which
is
is
4569
10A0
H
H
address
address
:
:+
45690H
10A0H
Physical address : 46730 H
3.Registers: the registers are temporary storage of data in 8086 have 14,16-bit registers.
AX:Accumulator
F:flag register
SI:source index
BX:base register
DI:destination index
CX:counter register
IP:instruction pointer
DX:data register
BP:base pointer
Sp;Stack pointer
Intel 8086 was the first 16-bit microprocessor introduced by Intel in 1978.
All the registers of 8086 are 16-bit registers. The general purpose registers can be used as either
8-bit registers or 16-bit registers.
The register set of 8086 can be categorized into 4 different groups. The register organization of
8086 is shown in the figure.
AH
AX
AL
BH
BX
BL
SS
CH
CX
CL
DS
DH
DX
DL
ES
BP
FLAGS/
PSW
SI
DI
IP
AL
CL
Extra Segment Register (ES) : also refers to a segment in the memory which is another data segment in
the memory.
Stack Segment Register (SS): is used fro addressing stack segment of the memory. The stack segment is
that segment of memory which is used to store stack data.
While addressing any location in the memory bank, the physical address is calculated from two parts:
-
The first is segment address, the segment registers contain 16-bit segment base addresses, related
to different segment.
The second part is the offset value in that segment.
The advantage of this scheme is that in place of maintaining a 20-bit register for a physical address, the
processor just maintains two 16-bit registers which is within the memory capacity of the machine.
Pointers and Index Registers.
The pointers contain offset within the particular segments.
-
The index registers are used as general purpose registers as well as for offset storage in case of indexed,
base indexed and relative base indexed addressing modes.
The register SI is used to store the offset of source data in data segment.
The register DI is used to store the offset of destination in data or extra segment.
The index registers are particularly useful for string manipulation.
Intruction pointer: It holds the next instruction address to be executed.
Flag Register(or)Program Status word
The 8086 flag register contents indicate the results of computation in the ALU. It also contains some flag
bits to control the CPU operations.
A 16 flag register is used in 8086. It is divided into two parts .
(a) Conditional flags :Trap,Interrupt,Direction flag
(b) status flags:carry ,parity,auxillary carry,zero,sign flags
The condition code flag register is the lower byte of the 16-bit flag register. The condition code flag
register is identical to 8085 flag register, with an additional overflow flag.
The control flag register is the higher byte of the flag register. It contains three flags namely direction
flag(D), interrupt flag (I) and trap flag (T).
D I
T S Z
4 3
X AC X P X CY
O-overflow flag
D-direction flag
I-Interrupt flag
T-Trap flag
S-sign flag
Z-zero flag
Ac-Auxillary carry flag
P-parity flag
Cy-carry flay
X-not used/unreserved
S- Sign Flag : This flag is set, when the result of any computation is negative.
10000110
00000111
10001101 s:set to 1
Z- Zero Flag: This flag is set, if the result of the computation or comparison performed by the previous
instruction is zero.
Ex:10000110
00000111
10001101 z:set to 1
P- Parity Flag: This flag is set to 1, if the lower byte of the result contains even number of 1s.
Ex:10000110
00000111
10001101 p:set to 1
C- Carry Flag: This flag is set, when there is a carry out of MSB in case of addition or a borrow in case
of subtraction.
Ex: 10000110
00000111
10001101 c:set to 0
T- Tarp Flag: If this flag is set, the processor enters the single step execution mode.
I- Interrupt Flag: If this flag is set, the maskable interrupt are recognized by the CPU, otherwise they
are ignored.
D- Direction Flag: This is used by string manipulation instructions. If this flag bit is 0, the string is
processed beginning from the lowest address to the highest address, i.e., auto incrementing mode.
Otherwise, the string is processed from the highest address towards the lowest address, i.e., auto
incrementing mode.
AC-Auxilary Carry Flag: This is set, if there is a carry from the lowest nibble, i.e, bit three during
addition, or borrow for the lowest nibble, i.e, bit three, during subtraction.
O- Over flow Flag: This flag is set, if an overflow occurs, i.e, if the result of a signed operation is large
enough to accommodate in a destination register. The result is of more than 7-bits in size in case of
8-bit signed operation and more than 15-bits in size in case of 16-bit sign operations, then the
overflow will be set.
Eg:8-bit range is-127 to +128
fig:Overlapping Segments
6.Register Relative :The Data Is Available At An Effective Address Formed By Adding An 8-Bit Or 16Bit Displacement.
Ex:Mov Ax,50h[Bx]
7.Based Indexed: The Effective Address Of Data Is Formed By Adding Base Register And Index
Register .
Ex:Mov Ax,[Bx][Si]
8.Relative Based Indexed:The Effective Address Is Formed By Adding An 8-Bit Or 16-Bit
Displacement And Base ,Index Registers.
Ex:Mov Ax,50h[Bx][Si]
9. Intra Segment Direct Mode:the address to which the control is to be transferred lies in same segment.
Ex:JMP SHORT LABLE (LABLE lies -128 to +127)
10. Intra Segment Indirect Mode: the address to which the control is to be transferred lies in same
segment but indirect wayEx:JMP [BX]
11. Inter Segment Direct :the address control is transfer in different segments in direct lacation
Ex:JMP 2000H:5000H
12. Inter Segment InDirect: the address control is transfer in different segments indirectly
Ex;jmp [Bx]
Assembler Directives
The main advantage of machine language programming is that the memory control is directly in
the hands of the programmer/user.
List out the assembler directives
1.DB:Define Byte the DB directive is used to reserve byte of memory location
Ex/stmt: rank DB 01H,02H,03H,04H
2.DW:Define Word the DW directive is used to reserve two byte of memory location
Ex:key DW 1234H,4567H,78ADH
3.DQ:Define Quadword the DQ directive is used to reserve 4 words of memory location
Ex:words DQ 1234H,4567H,78ADH
4.DT:Define ten bytes the DT directive is used to reserve 10-bytes of memory location
Ex:ten DT 1234H,4567H,78ADH
5.ASSUME:Assume logical segment Name
The Assume directive is used to names the different logical segments
Ex:ASSUME CS:CODE,DS:DATA,ES:EXTRA,SS:STACK
6.END:end of program
The end directive is used to the end of progatm
7.ENDP:end of procedure
The sub program ends with endp.
Ex:PROCEDURE STAR
------STAR ENDP
8.ENDS:end of segment
The segments are ends with ENDS
Ex:DATA SEGMENT
------DATE ENDS
9.EVEN:Align on even memory address
Even Alignment of available memory location.
Ex: EVEN
PROCEDURE ROOT
---ROOT ENDP
10.EQU:equate
The directive EQU is used to assign a lable with a value or symbol.
Ex: LABLE EQU 0500H
ADDITION EQU ADD
21.*GLOBAL
the labels variable constants or procedures declared global may be used by other modules of the
program.
Ex:ROUTINE PROC GLOBAL
22.SHORT
the short operator indicates to the short jump -128 to +127 bytes
ex:jmp short label
23.+&- OPERATORS :
These operators represents arithmetic addition and subtraction.
ex:Mov [si+2]
Mov dx,[bx-5]
24.FAR PTR:
This directive indicates far pointer .
Ex:JMP FAR PTR LABEL
25.NEAR PTR :
This directive indicates near pointer.
Ex:JMP NEAR PTR LABEL
Main program the set of instructions are repeated again and again the program is called macro.
The macro program occupies more memory space.
The macro ends with ENDM
Syntax: Display macro
Start:------------Display ENDM
End start
The macro program is fast execution than procedure.
Procedure
The sub program is called procedure
When the group of same instructions repeated again the program becomes lengthy and complex
to separate the program and store in other memory location called as subprogram or procedure.
The used instructions are CALL and RET .
Syntax:Display procedure
Start:------------- sub program
---------Display ENDP
The address is pushed into stack pointer and instruction pointer load with sub program address
after execution of sub program stack pointer address is reload with IPDifference between macro and
procedure:
Macro
1.Macros are used for short sequence of
instructions, preferably below 10 instructions
2.Macro does not requires CALL and RET
instructions
3.Macro execute faster when compare with
procedure
4.Parameter are passed as part of a statement
which calls macro
5.Macro eliminates the overhead time
requirement.
6.Macro ends with ENDM
7.Control of execution remains in the main
program
8.It occupies more memory space
Procedure
1.Sub program are used for long sequence of
instructions, preferably more than 10 instructions.
2.It requires CALL and RET instruction
3.IT is slower compare to macro
4.Parameter are passed in register, memory
locations or stack.
5.It require over head time
6.Procedure ends with ENDP
7.Control of execution is transferred to the
procedure
8.It occupies less memory space
Unit-III
PIN CONFIGURATION 8086
The 8086 is a 16-bit microprocessor. This microprocessor operate in single processor or multiprocessor
configurations to achieve high performance. The pin configuration of 8086 is shown in the figure. Some
of the pins serve a particular function in minimum mode (single processor mode) and others function in
maximum mode (multiprocessor mode).
interrupt flag bit. The S4 and S3 combinedly indicate which segment register is
presently being used for memory access.
S4
0
0
1
1
S3
0
1
0
1
Funtion
Extra segment
Stack segment
Code or no segment
Data Segment
BHE / S7 The bus high enable (BHE) signal is used to indicate the transfer of data over the higher order
D15 D8 data bus. It goes low for the data transfer over
A0
0
1
0
1
Indication
Whole word
Upper byte from or to odd address
Lower byte from or to even address
None
: Read : whenever the read signal is at logic 0, the data bus receives the data from the memory or
0 devices connected to the system
READY :This is the acknowledgement from the slow devices or memory that they have completed the
data transfer operation. This signal is active high.
INTR: Interrupt Request: Interrupt request is used to request a hardware interrupt of INTR is held high
when interrupt enable flag is set, the 8086 enters an interrupt acknowledgement cycle after the
current instruction has completed its execution.
TEST : This input is tested by WAIT instruction. If the TEST input goes low; execution will continue.
Else the processor remains in an idle state.
NMI- Non-maskable Interrupt: The non-maskable interrupt input is similar to INTR except that the NMI
interrupt does not check for interrupt enable flag is at logic 1, i.e, NMI is not maskable internally
by software. If NMI is activated, the interrupt input uses interrupt vector 2.
RESET: The reset input causes the microprocessor to reset itself. When 8086 reset, it restarts the
execution from memory location FFFF0H. The reset signal is active high and must be active for
at least four clock cycles.
CLK : Clock input: The clock input signal provides the basic timing input signal for processor and bus
control operation. It is asymmetric square wave with 33% duty cycle.
Vcc 5V power supply for the operation of the internal circuit
S1
0
0
1
1
0
0
S0
0
1
0
1
0
1
Function
Interrupt Acknowledge
Read i/o port
Write i/o port
Halt
Code Access
Read memory
1
1
1
1
0
1
Write memory
passive
LOCK : The lock output is used to lock peripherals off the system, ie, the other system bus masters will
be prevented from gaining the system bus.
QS1 and QS0 - Queue status: The queue status bits shows the status of the internal instruction queue. The
encoding of these signals is as follows
QS1
0
0
1
1
QS0
0
1
0
1
Function
No operation, queue is idle
First byte of opcode
Queue is empty
Subsequent byte of opcode
RQ / GT 1 and RQ / GT 0 - request/Grant: The request/grant pins are used by other local bus masters to
force the processor to release the local bus at the end of the processors current bus cycle. These
lines are bi-directional and are used to both request and grant a DMA operation. RQ / GT 0 is
having higher priority than RQ / GT 1
Physical Memory Organization
In an 8086 based system, the 1Mbyte memory is physically organized as odd bank and even bank, each
of 512kbytes, addressed in parallel by the processor.
Byte data with even address is transferred on D7 D0 and byte data with odd address is transferred on
D15 D8 .
The processor provides two enable signals, BHE and A0 for selecting of either even or odd or both the
banks.
BHE
0
0
1
1
FIG
Function
A0
0
Whole word
1
Upper byte/ odd address
0
Lower byte/even address
1
none