Klu 8086
Klu 8086
Klu 8086
8086
Microprocessor:
Introduction
to
Microprocessor, Intel Microprocessor families, 8086
Microprocessor architecture, Register Organization, Pin
Description, Physical Memory Organization, Modes of
operation.
8086 Instruction set & Assembly Language
programming: Addressing modes, Instruction set,
Assembler directives, simple Programs, Procedures and
Macros, 8086 Interrupts.
UNIT - I
Generation of Computers
First generation:
First computers were manufactured around 1946. Vacuum tubes were
used to build the various circuits required. Those computers were slow,
generated lot of heat & required large space.
Second generation:
Second generation computers used transistor as the basic switching
element in early 1950s. It improved speed, reduced power dissipation &
required less space.
Third generation
Third generation computers used Integrated circuits(ICs). Each IC had
hundreds of transistors. It was in early 1960s & up to mid 1970s.
Fourth generation
IC technology further improved & LSI(Large scale Integrated circuit) was
introduced during 1970s. LSIs had thousands of transistors in it. This
technology introduced Microprocessors & Microcontrollers.
Fifth generation
These computers use VLSIs(Very Large Scale Integrated circuits) which
contain lakhs of transistors in a single chip.
Classification of Computers
The digital computers are classified based on speed, storage capacity & word
length
Microcomputer: These computers have a word length of 8 to 16 bits. They
are slow & have less data storage capacity. These are used for dedicated
applications.
Minicomputer: These computers have a word length of 32 bits. The speed
& data storage capacity is moderate. These are used general purpose
systems in the field of data processing, process control & industrial
applications.
Mainframe Compute: These computers have a word length of 64 bits. The
speed is very high & data storage capacity is very large. These are used for
scientific applications, business data processing & military applications.
Super computer: These computers have a word length of 64 bits. The
speed is higher than main frame computers. They use artificial intelligence.
Objects are used as input/output.
Computer
The computer basically consists of three functional units namely
CPU-Central Processing Unit(uP), memory unit & input/output units.
The Microprocessor is defined as the central processing
unit of the Microcomputer
Memo
ry
Unit
Input
Unit
CPU
Output
Unit
Input
Unit
uP
Memor
y Unit
Output
Unit
Input
Unit
CP
U
Outpu
t Unit
Features of Microprocessor
The important features of a microprocessor are
1. Speed: Clock frequency or instructions per second.
2. Instruction set: Number of instructions it can handle.
3. Data bus: The number of data lines it can process at a time.
4. Address bus: The number of address lines which will
indicate the maximum memory it can have.
5. Control bus: the number of control lines to control various
functions.
6. Register array: The number of registers & their width.
7. Manufacturing technology: PMOS, NMOS & HMOS or CMOS
8. Design technology: CISC or RISC
9. Power: Voltage & current requirement
10. Packaging: Shape, Size & number of pins.
Features of 8086
1. The 8086 is a 16-bit processor. It means ALU, its internal registers
& most of its instructions are designed to work with 16-bit data.
2. The 8086 has a 16-bit data bus.
3. The 8086 has a 20-bit address bus so it can have a maximum
of 1MB of memory. It has 16-bit I/O address so it can access up to
64K I/O ports.
4. The data bus and 16-bit lower order address bus is multiplexed.
5. The 8086 has Fourteen 16-bit registers.
6. The 8086 requires a clock with 33% duty cycle for its internal
timing. Its clock speed is 5MHz, 8MHz or 10MHz.
7. The 8086 has a powerful instruction set with a range of
addressing modes. It can perform bit , byte , word & block
operations.
8. The 8086 has two mode of operations Minimum & Maximum. In
minimum mode it works as a single microprocessor. Where as in
maximum mode it work in Multiprocessor configuration.
8086 ARCHITECTURE
EXECUTION UNIT:
The EU is responsible for the instruction execution & has a control
circuit to direct its internal operations.
1. It picks up the instructions from the Queue of BIU.
2. It decodes the instructions & decides upon the various
operations it has to carry out. It then executes these
operations.
3. It uses ALU to perform 16-bit Arithmetic & logical operations
like ADD, SUBTRACT, AND, OR, XOR, INCREMENT, DECREMENT,
COMPLEMENT & SHIFT.
4. It updates the status of FLAG register (PSW Register).
5. It performs BIU from where the next instruction or data has to
be read.
AX
AH
AL
BX
BH
BL
CX
CH
CL
DX
DH
DL
The general purpose registers are used for temporary storage of data
& intermediate results.
AX: The register AX is called as Accumulator. During multiplication 8Bit x 8-Bit one
of the operand should be in AL and the result will store in AX
(AH+AL). In case
of 16-Bit x 16-Bit the result will store in DX:AX. In case of
Division by 8-Bit the
Quotient will be in AL & Remainder in AH , where as in case of
16-Bit Division
the Quotient will be in AX & Remainder in DX.
BX: It is used as a Base register. It contains the offset address of
the memory
location in some addressing modes.
CX: It is used as an implicit counter in loop & string instructions.
The register CL is
used as 8-bit counter in shift & rotate instructions.
DX: It is used to hold the 16-bit I/O address in I/O instructions.
Data segment
64KB
Code Segment
64KB
00000
FFFFF
= 1111
1111
1111
1111
111
= 0000
0000
0000
0000
000
1
00000
0
Default
Segment
Offset
Memory operation
CS
IP
Instruction fetch
SS
Stack operation
DS
DS
SI
ES
DI
512KB
512KB
00003H
00002H
[
BHE 00001H
A0
Higher
bank( odd
Odd
Bank)
8-bit
data transfer,
bank
selected
The pins & signals of 8086 can be classified as into five groups, they are as
follows:
1. Address / Data bus
2. Address / status bus
3. Control & status signals
4. Interrupts & externally initiated signals.
5. Power supply & clock frequency signals.
1. Address / Data bus [AD0-AD15 (input/Output): Pins 16 to 2 &
39]
These signals are bi-directional & time multiplexed. If a bus carries
different types of signals at different times then it is called time
multiplexed. During the first clock cycle, during ALE, they contain address
information (A0 to A15) & in the remaining clock cycles they contain data
(D0 to D15). During hold acknowledge they will be in high impedance state.
2. Address / status bus [A16/S3-A19/S6(Output/Tristate): Pins 38 to
35]
These signals are output & time multiplexed. During the first clock
cycle, during ALE, they contain address information (A16-A19). In the
remaining clock cycles they contain status information(S3-S6). During
HOLD acknowledge they will be high impedance a state.
S4
Segment Register
ES
SS
CS
(None in the case of I/O port
access)
QS0
Function
Queue is idle
Queue is empty
S2
S1
S0
Machine Cycle
Interrupt acknowledge
I/O Read
I/O Write
Halt
Instruction (Op-Code)
Fetch
Memory read
Memory write
Passive (Inactive)
A16/S3-A19/S6
&
BHE/S7.
Timing Diagram
END
OF
UNIT - I
UNIT - II
INSTRUCTIONS
CLASSIFICATION OF ASSEMBLER
DIRECTIVES
Example
1. NUM DB 55H: Reserve one memory location by
name NUM and initialize it to 55H
2. MES DB BE HAPPY: Reserve 8 bytes for ASCII codes
of characters used in BE HAPPY.
3. ARRAY DB 5,10,15,20,25: Reserve 5 memory
locations for ARRAY and initialize then with decimal
values 5,10,15,20 & 25.
2. DW: DEFINE WORD
Format: Variable name DW value1,value2,.
Operation: This directive is used to define a WORD type
variable. Single or multiple variables can be defined
Example
1. RES DW ?: Reserve one word (two bytes) memory for
variable named RES . No initialization is required.
2. NUM DW 35: Reserve one word memory for variable
named NUM and initialize with ASCII equivalent of 3
(33H) and 5 (35H). So word memory will be initialized
to 3335H
3. ARRAY DW 50H,2500H: Reserve two words memory for
variable array & initialize them with 0050H & 2500H.
3. DD: DEFINE DOUBLE WORD
Format : Variable name DD value1,value2,.
Operation : This directive is used to define a double word
type ( 4 bytes) variable. Single or multiple double word
variables can be defined.
Examples:
1. NUM DD 0: Reserve four bytes ( double word) for variable
NUM & initialize to Zero. All four bytes are Zero.
2. STRING DD 35: Reserve four bytes for variable STRING.
First two bytes will be initializes to 0s and next two bytes
with 33H & 35H.
Note:
DD cannot be used to define a variable with more than two
ASCII characters.
6. DUP: DUPLICATE
Format: Variable name Date type Num DUP(value)
Operation: This directive is used to initialize several memory
locations and assign values to these locations. Num is the
format indicates the number of memory locations to be
initialized.
Example:
1. LIST DW 8DUP(55AAH): This statement reserves 8 words
of memory . They are all initialized with value 55AAH.
2. LISTA DW 1234,55H,5DUP(5678): This statement reserves
7 words of memory. First word is initialized with 1234H,
next word with 0055H and next 5 words with 5678H.
3. TABLE DB 10 DUP(0), 35H: Reserve 11 bytes of memory.
First 10 locations are initialized with zero and 11 th location
with 35H.
7. END
Format: 1. END
2. END label.
Operation: This directive is used to inform the
assembler the end of a program. Hence this is the last
statement of every program. Any statements after this
will be ignored. Label field is optional. It is the label of
first instruction of program.
Example:
1. END
2. END START: This indicates the end of a program
whose execution began from the instruction whose
label was START.
8. ENDM : END OF MACRO
Format: ENDM
Operation: This directive informs the assembler the end
Example : ENDM
Note: ENDM is to be used with directive MACRO as a pair
12. ASSUME
Format: ASSUME Segment register: segment name , segment
register: segment name.
Where ASSUME is a assembler directive.
Segment register: One of four segment registers CS or DS or
SS or ES
Segment name : Name of logical segment as defined by user.
Operation: This directive is used to inform the assembler the
name of logical segment should use for a particular segment.
Example: ASSUME CS:CODE,DS:DATA,SS:STACK,ES:EXTRA
13. EVEN: ALIGN ON EVEN MEMORY ADDRESS
Format: EVEN
Operation: This directive is used to inform assembler to
increment location counter to next even memory address if it
is not already at an even address. This directive can be used
in both code & data seg.
Example:
DATA SEGMENT
NUM DB 55H
LIST DW 50 DUP(0H)
DATA SEGMENT
NUM DB 55H
EVEN
LIST DW 50 DUP(0H)
14 EXTRN: EXTERNAL
Format:
1. Format for Data segment
EXTRN variable1: data type1, variable 2: data type2,..
2. Format for Code segment
EXTRN address1: NEAR or FAR, address2: NEAR or
FAR,..
DATA ENDS
CODE SEGMENT
EXTRN KBRD:FAR
:
START: MOV AX,DATA
MOV DS,AX
:
MOV AL,NUM1; Get NUM1 byte from other program module
MOV BX,NUM2; Get NUM2 word from other program module
MOV DX,NUM3; Get NUM3 word from other program module
:
CALL KBRD
:
CODE ENDS
:
END START
2. CODE SEGMENT
:
MOV AX,CX
MOV BX,DX
ENTER LABEL FAR ; Assign value of current location to ENTER. Now you
MOV SI,DI
; can jump to this instruction from other code segment
NOTE: If ENTER is not defined as LABEL and instead ENTER is the name of
instruction as defined below
ENTER:MOV SI,DI
Then you cannot jump here from other code segment.
16. MACRO: MACRO
Format: Macro Name MACRO ( Argument1,Argument
N)
Operation: This directive indicates the start of a
MACRO. Arguments are dummy variables and are
optional. In the program it is called by its name and
actual argument. It is used with directive ENDM as a
Example:
DISP MACRO MSG
MOV AH,09
LEA DX,MSG
INT 21H
ENDM
17. OFFSET: OFFSET
Format: OFFSET variable name
Operation: This directive is an operation and informs
the assembler to determine the displacement of the
specified variable from the start of the segment. It is
used to load the offset address of a variable into the
register. Now, the variable can be accessed by indirect
or index addressing modes which use this register.
Example:
DATA SEGMENT
ARRAY DB 10,20,30,40,50 ; DEFINE ARRAY OF 5 NUMBERS
:
DATA ENDS
CODE SEGMENT
:
:
MOV BX,OFFSET ARRAY ; load offset address of ARRAY in register BX
MOV AL,[BX]
; Get the first element from array
MOV DL,[BX+2]
; Get the third element from array.
Note:
1. PROC and ENDP are used together as a pair.
2. The program code is enclosed with in the directives
PROC & ENDP.
MPY PROC NEAR
MOV AL,BL
:
RET
MPY ENDP
20. PTR: POINTER
Format: Date type PTR
Operation: This directive is used to specify the type of
memory access. This is done when the data type of
operand is not clear. For example, INC[DI] does not tell
you whether it is a byte increment or
NUM1 DB 55H
NUM2 DW 1234H
NUM3 EQU 6789H
DATA ENDS
TYPES OF PROCEDURES
1. Single procedure
2. Nested procedure
3. Re-entrant procedure
4. Recursive procedure
5. Single procedure
Main Program
Procedure
RET
CALL
2. Nested Procedure
CALL
Proc 1
CALL
Proc 2
RET
RET
Main Program
Procedure-1
Procedure-2
3. Re-Entrant Procedure
CALL Proc-1
RET
Main Program
Interrupt occurs
IRET
Proc-1
ISR
CALL Proc-1
4. Recursive Procedure
CALL
Proc-1
CALL
Proc-1
RET
MAIN Program
CALL
Proc-1
RET
Proc-1 Proc-1
CALL
Proc-1
RET
Proc-1
RET
Proc-1
Procedure
Macro
Interrupts of 8086:
Hardware interrupts:
NMI & INTR are hardware interrupts. NMI is non mask able
interrupt where as INTR is a mask able interrupt. The NMI has
higher priority than INTR. The NMI is edge-triggered on a low-tohigh transition. It is required to remain in high state for greater
than two clock cycles.
INTR is a level triggered input which is sampled during the last
clock cycle of each instruction. The signal is active high.
Software interrupt:
The
software interrupt is implemented using INT n
instruction. It may have any value from 0 to 255.
Interrupt Vector:
1KB of memory from 00000H to 003FFH is set aside to store
the starting address of interrupt service subroutines in an 8086
based system
END
OF
UNIT - II