Experiment No-01
Aim:- To study the architecture of 8086 microprocessor and 8086
microprocessor kit.
Architecture of 8086 Microprocessor:-
Introduction
8086 Microprocessor is an enhanced version of 8085Microprocessor that was
designed by Intel in 1976. It is a 16-bit Microprocessor having 20 address lines and16
data lines that provides up to 1MB storage. It consists of powerful instruction set, which
provides operations like multiplication and division easily.
It supports two modes of operation, i.e. Maximum mode and Minimum mode.
Maximum mode is suitable for system having multiple processors and Minimum
mode is suitable for system having a single processor.
Features of 8086 :-
The most prominent features of a 8086 microprocessor are as follows:-
o It has an instruction queue, which is capable of storing six instruction bytes
from the memory resulting in faster processing. It was the first 16-bit
processor having 16-bit ALU, 16-bit registers, internal data bus resulting in faster
processing.
✔ It is available in 3 versions based on the frequency of operation –
✔ 8086 → 5MHz
✔ o 8086-2 → 8MHz
✔ o (c)8086-1 → 10 MHz
✔ 8086 → 5MHz
✔ o 8086-2 → 8MHz
✔ o (c)8086-1 → 10 MHz
✔ 8086 → 5MHz
✔ o 8086-2 → 8MHz
✔ o (c)8086-1 → 10 MHz
o 8086 → 5MHz
o 8086-2 → 8MHz
o 8086-1 → 10 MHz
o It uses two stages of pipelining, i.e. Fetch Stage and Execute St
✔ It uses two stages of pipelining, i.e. Fetch Stage and Execute Stage,
which improves performance.
✔ Fetch stage can prefetch up to 6 bytes of instructions and stores them in
the queue.
✔ Execute stage executes these instructions.
✔ It has 256 vectored interrupts.
✔ It consists of 29,000 transistors.
Architecture of 8086 :-
The following diagram depicts the architecture of a 8086 Microprocessor-
Memory segmentation:
✔ To increase execution speed and fetching speed, 8086 segments the memory.
✔ It’s 20 bit address bus can address 1MB of memory, it segments it into 4 64kB
segments.
✔ 8086 works only with four 64KB segments within the whole 1MB memory.
The internal architecture of Intel 8086 is divided into 2 units: The Bus
Interface Unit (BIU), and The Execution Unit (EU). These are explained as
following below.
1. The Bus Interface Unit (BIU):
It provides the interface of 8086 to external memory and I/O devices via the
System Bus. It performs various machine cycles such as memory read, I/O
read etc. to transfer data between memory and I/O devices.
BIU performs the following functions-
o It generates the 20 bit physical address for memory access.
o It generates the 20 bit physical address for memory access.
o It transfers data to and from the memory and I/O.
o Maintains the 6 byte prefetch instruction queue(supports pipelining)
BIU mainly contains the 4 Segment registers, the Instruction Pointer, a prefetch queue
and an Address Generation Circuit. Instruction Pointer (IP):
o It is a 16 bit register. It holds offset of the next instructions in the Code segment.
IP is incremented after every instruction byte is fetched.
IP is incremented after every instruction byte is fetched.
IP is incremented after every instruction byte is fetched.
IP is incremented after every instruction byte is fetched.
IP is incremented after every instruction byte is fetched.
IP is incremented after every instruction byte is fetched. IP is incremented after every
instruction bIP gets a new value whenever a branch instruction occurs.
CS is multiplied by 10H to give the 20 bit physical address of the Code
Segment
o IP is incremented after every instruction byte is fetched.
o IP gets a new value whenever a branch instruction occurs.
o Address of the next instruction is calculated as CS x 10H + IP.
CS is multiplied by 10H to give the 20 bit physical address of the code segment. All
programs are stored in the Code Segment and accessed via the IP.
Data Segment register:-
DS holds the base address for the Data Segment.
Stack Segment register:-
SS holds the base address for the Stack Segment.
Extra Segment register:-
ES holds the base address for the Extra Segment.
2. The Execution Unit (EU):
The main components of the EU are General purpose registers, the ALU,
Special purpose registers, Instruction Register and Instruction Decoder and
the Flag/Status Register.
1. Fetches instructions from the Queue in BIU, decodes and executes
arithmetic and logic operations using the ALU.
2. Sends control signals for internal data transfer operations within the
Microprocessor.
3. Sends request signals to the BIU to access the external module.
4. It operates with respect to T-states (clock cycles) and not machine
cycles.
8086 has four 16 bit general purpose registers AX, BX, CX and DX. Store
intermediate values during execution. Each of these have two 8 bit parts
(higher and lower).
AX register:
AX register:
It holds operands and results during multiplication and division
operations. Also an accumulator during String operations.
∙ BX register:
BX register:
It holds the memory address (offset address) in indirect addressing
modes.
∙ CX register:
CX Resister:-
It holds count for instructions like loop, rotate, shift and string
Operations
DX Resistor:-
It is used with AX to hold 32 bit values during multiplication and
division.
Arithmetic Logic Unit (16 bit):
Performs 8 and 16 bit arithmetic and logic operations.
Special purpose registers (16-bit).
Stack Pointer:-
Points to Stack top. Stack is in Stack Segment, used during instructions like PUSH,
POP, CALL, RET etc.
Base Pointer:-
BP can hold offset address of any location in the stack segment. It is
used to access random locations of the stack.
∙ Source Index:
Source Index:-
It holds offset address in Data Segment during string operations.
∙ Destination Index:
Destination Index:-
It holds offset address in Extra Segment during string operations
Instruction Register and Instruction Decoder:
∙ Instruction Register and Instruction Decoder:
The EU fetches an opcode from the queue into the instruction
register. The instruction decoder decodes it and sends the the information to the control
circuit for execution.
Flag/Status register (16 bits):
It has 9 flags that help change or recognize the state of the microprocessor.
6 Status flags:
1. carry flag(CF)
2. parity flag(PF)
3. auxiliary carry flag(AF)
4. zero flag(Z)
5. sign flag(S)
6. overflow flag (O)
Status flags are updated after every arithmetic and logic operation.
3 Control flags:
1. trap flag(TF)
2. interrupt flag(IF)
3. direction flag(DF)
IP is incremented after every instruction byte is fetched.
∙ IP gets a new value whenever a branch instruction occurs.
∙ CS is multiplied by 10H to give the 20 bit physical address of the Code
∙ Address of the next instruction is calculated as CS x 10H + IP
Address of the next instruction is calculated as CS x 10H + IP. The most prominent
features of a 8086 microprocessor are as follows −
∙ It has an instruction queue, which is capable of storing six instruction
∙ Execute stage executes these instructions.
∙ It has 256 vectored interrupts.
∙ It consists of 29,000 transistors
Experiment No-02
Aim:- Write a program to add the contents of the memory location to the content of
other memory location and store the result in 3rd memory location
C:\Document and Settings\ECE\>cd\
C:\.>debug
---a
.MODEL SMALL
.STACK 100H
.DATA
; Define memory locations and initialize values
NUM1 DW 1234H ; First number (16-bit hexadecimal)
NUM2 DW 5678H ; Second number (16-bit hexadecimal)
RESULT DW ? ; Result placeholder (16-bit hexadecimal)
.CODE
MAIN PROC
MOV AX, @DATA ; Load the data segment address into AX
MOV DS, AX ; Initialize DS with the data segment address
; Load values from memory into registers
MOV AX, NUM1 ; Load the first number into AX
MOV BX, NUM2 ; Load the second number into BX
ADD AX, BX ; Add AX (NUM1) and BX (NUM2), result in AX
MOV RESULT, AX ; Store the result in the RESULT memory location
; Display the result
MOV AH, 02H ; Function to print character
MOV DL, 'R' ; Load 'R' into DL (for "Result")
INT 21H ; Print 'R'
MOV AX, RESULT ; Load the result into AX for printing
CALL PRINT_HEX ; Call a procedure to print the result in hexadecimal format
; Exit the program
MOV AH, 4CH ; Function to terminate the program
INT 21H ; Call DOS to terminate the program
MAIN ENDP
PRINT_HEX PROC
; Procedure to print a 16-bit hexadecimal number stored in AX
MOV CX, 4 ; Set loop counter for 4 hex digits
HEX_LOOP:
MOV DX, AX ; Move the number to DX for division
SHR DX, CL ; Shift right CL bits
AND DX, 0FH ; Mask lower 4 bits
CMP DX, 9 ; Check if digit is greater than 9
JBE DIGIT ; Jump if below or equal (to print digit)
ADD DL, 07H ; Adjust ASCII code for letters ('A' = 0AH)
DIGIT:
ADD DL, '0' ; Convert digit to ASCII character
MOV AH, 02H ; Function to print character
INT 21H ; Print the character
SHL AX, 4 ; Shift left AX by 4 bits for the next digit
LOOP HEX_LOOP ; Loop until all 4 digits are printed
RET ; Return from procedure
PRINT_HEX ENDP
END MAIN
Experiment No –03
Aim:- Write a program to add 16 bit number using 8086 instruction set.
C:\Document and Settings\ECE\>cd\
C:\.>debug
---a
0AFD:0100 mov ax,3527
0AFD:0103 mov cx,4752
0AFD:0106 add ax,cx,
0AFD:0108 hlt
0AFD:0109
--gcs:0108
AX =7C79 BX =0000 CX =4752 DX =0000 SP =FFEE BP =0000 SI =0000 DI =0000
DS =0AFD ES =0AFD SS =0AFD CS =0AFD IP =0108 NV UP EI PL NZ NA PO NC
0AFD:0108 F4 HLT
Result:- Addition of two 16-bit nos. in 8086 has been studied.
Experiment No – 04
Aim:- Write a multiplication of two 16 bit numbers using 8086 instruction
set.
C:\Document and Settings\ECE\>cd\
C:\.>debug
---a
0AFD:0100 mov ax,2536
0AFD:0103 mov cx,3535
0AFD:0106 mul cx
0AFD:0108 hlt
0AFD:0109
--gcs:108
AX =E22E BX =0000 CX =3535 DX =07BB SP =FFEE BP =0000 SI =0000 DI =0000
DS =0AFD ES =0AFD SS =0AFD CS =0AFD IP =0108 OB UP EI NG NZ NA PE CY
0AFD:0108 F4 HLT
-
Result:- Multiplication of two 16-bit nos. in 8086 has been studied.
Experiment No – 05
Aim:- Write a program for division of two 16 bit numbers using 8086 instruction set.
C:\Document and Settings\ECE\>cd\
C:\.>debug
---a
0AFD:0100 mov ax,3535
0AFD:0103 mov cl,55
0AFD:0105 div cl
0AFD:0107 hlt
0AFD:0108
-gcs107
^Error
--gcs:107
AX =15A0 BX =0000 CX =0055 DX =0000 SP =FFEE BP =0000 SI =0000 DI =0000
DS =0AFD ES =0AFD SS =0AFD CS =0AFD IP =0107 NB UP EI PL NZ NA PO NC
0AFD:0107 F4 HLT
Result:- Division of two 16-bit nos. in 8086 has been studied.
Experiment No – 06
Aim:- Program for block move in 8086
C:\Document and Settings\ECE\>cd\
C:\.>debug
---a
0AFD:0100 cld
0AFD:0101 mov si,0300
0AFD:0104 mov di,0400
0AFD:0107 mov cx,0005
0AFD:010A movsb
0AFD:010B Loopnz 010A
0AFD:010D hlt
0AFD:010E
--ecs:0300
0AFD:0300 F2. AE. 75. 0B. 01. E5.
--gcs: 0104
AX =0000 BX =0000 CX =0000 DX =0000 SP =FFEE BP =0000 SI =0305
DS =0AFD ES =0AFD SS =0AFD CS =0AFD IP =010D NU UP EI PL NZ NA POC
0AFD:010D F4
-ecs:0400
0AFD:0400 F2. AE. 75. 0B. 01. 26.
0AFD:0300
0AFD:0300 F2.4a AE.7b 75.ab 0B.c6 81.d7
ES
-a
0AFD:010E cld
0AFD:010F mov si,0300
0AFD:0112 di,0400
0AFD:0115 mov cx,0005
0AFD:0118 movsb
0AFD:0119 loopnz
0AFD:011B hlt
0AFD:011C
-ecs:0300
0AFD:0300 4A. 7B. AB. C6. D7. E5.
-gcs:011b
AX =0000 BX =0000 CX =0000 DX =0000 SP =FFEE BP =0000 SI =0305 DI =0405
DS =0AFD ES =0AFD SS =0AFD CS =0AFD IP =011B NU UP EI PL NZ NA PO NC
-ecs 0400
^Error
-ecs:0400
-ecs:0400 4A . 7B. AB. C6. D7. 26.
Result:- program for block move in 8086 has been studied.
Experiment No – 07
Aim:- Write a program using 8086 for arranging in array of numbers in
descending order.
C:\Document and Settings\ECE\>cd\
C:\> DEBUG
--A
0B21:0100 MOV SI, 0300
0B21: 0103 MOV BX, [SI]
0B21:0105 DEC BX
0B21:0106 MOV CX,[SI]
0B21:0108 DEC CX
0B21:0109 MOV SI,0302
0B21:010C MOV AL, [SI]
0B21:010E INC SI
0B21:010F CMP AL , [SI]
0B21:0111 JAE 0119
0B21:0113 XCHG AL,[SI]
0B21:0115 DEC BX
0B21:0118 MOV [SI]
0B21:0119 INC SI
0B21:011B LOOP 010C
0B21:011C DEC BX
0B21:011F MOV SI , 0300
0B21:0121 JNZ 0106
0B21:0122 HLT
0821:0122
-ECS:0300
0821:0300 3E.06 28.00 2E.20 C7.25 06.28 88.15 91.07 30.05
-GCS:0121
AX =0007 BX =0000 CX =0000 DX =0000 SP =FFEE BP =0000 SI =0300 DI =0000
DS =0821 ES =0821 SS =0821 CS =0821 IP =0121 NV UP E I PL ZR NA PE NC
-ECS:0300 F4
0821:0300 06 00 28 25 20 15 07 05
Experiment no – 08
Aim:- Write a program using 8086 for arranging an array of number in ascending order.
SOURCE CODE
C:\Document and Settings\ECE\>cd\
C:\> DEBUG
--A
0B21:0100 MOV SI, 0300
0B21:0103 MOV BX, [SI]
0B21:0105 DEC BX
0B21:0106 MOC CX, [SI]
0B21:0108 DEC CX
0B21:0109 MOV SI, 0302
0B21:010C MOV AL, [SI]
0B21:010E INC SI
0B21:010F CMP AL, [SI]
0B21:0111 JB 0119
0B21:0113 XCHG AL, [SI]
0B21:0115 DEC SI
0B21:0116 MOV [SI], AL
0B21:0118 INC SI
0B21:0119 LOOPNZ 010C
0B21:011B DEC BX
0B21:011C MOV SI , 0300
0B21:011F JNZ 0106
0B21:0121 HLT
0B21:0122
0B21:0122
-ECS:0300
0B21:0300 06.06 00.00 28.20 25.24 20.08 15.07 07.32
-GCS:0121
AX =0024 BX =0000 CX =0000 DX =0000 SP =FFEE BP =0000 SI = 0300 DI =0000
DS =0B21 ES =0B21 SS =0B21 CS =0B21 IP =0121 NV UP EI PL ZR NA PE CY
0B21:0121 F4 HLT
-ECS;0300
0B21:0300 06. 00. 05. 07. 08. 20. 24. 32.
Experiment No – 09
Aim:- Write a program using 8086 for:
a) Finding the largest number from and array.
b) Finding the smallest number from and array.
A) Source Code
C:\Document and Settings\ECE\>cd\
C:\> DEBUG
--A
0B21:0100 MOV SI , 0300
0B21:0103 MOV CX, 0008
0B21:0106 MOV AX, 0000
0B21:0109 CMP AX, [SI]
0B21:010B JAE 0111
0B21:010D MOV AX, [SI]
0B21:010F INC SI
0B21:0110 INC SI
-0B21:0111 LOOPNZ 0109
0B21:0113 MOV [SI], AX
0B21:0115 HLT
0B21:0116
-ECS:0300
0B21:0300 06.01 00.02 05.03 07.04 08.05 20.06 24.15 32.07
-
-
-CGS:0115
AX =E83B BX =0000 CX =0000 DX =0000 SP =FFEE BP =0000 SI = 0301 DI
=0000
DS =0B21 ES =0B21 SS =0B21 CS =0B21 IP =0115 NV UP EI NG NZ NA PE NC
0B21:0115 F4 HLT
-ECS:0300
0B21:0300 01 02 03 04 05 06 15 07
0B21:0308 3B E8 3B E8 73 13 B8 FF
VAISH COLLEGE OF ENGINEERING
ROHTAK
Practical file
Of
microcontroller
Submitted To – Submitted by:- Kuldeep
Mrs. Reetu yadav Prajapati
B.Tech (ECE) 4th sem
22/ECE/410