MP 8086 Lab Manual Trainer Kit
MP 8086 Lab Manual Trainer Kit
Erode-638 052
PREPARED BY:
S.KAVITHA – AP/CSE
E.PADMA – AP/CSE
(AUTONOMOUS)
BONAFIDE CERTIFICATE
Register Number:
the Third Semester B.E COMPUTER SCIENCE AND ENGINEERING branch during the Academic Year
Held on…………………………………………….
SYLLABUS
1. Study Experiments
i) Study of 8086 Architecture ii) Study of 8255 – PPI
iii) Study of 8253 – PIT iv)Study of 8279 – PKI v)Study of 8259 – PIC
2. Write an ALP to find out factorial of a given hexadecimal number using 8086 MP
Data: OAH, OFH, 1OH
3. Write an ALP to perform 16 bit arithmetic operations (ADD, SUB, MUL, and DIV)
4. Write an ALP to generate the sum of first ‘N’ natural numbers using 8086 MP
5. Write an ALP to convert given hexadecimal number to binary using 8086 MP Data: ABH,
CDH, 101H
6. Write an ALP to convert given binary number to hexadecimal number using 8086MP
Data: 101010102, 111111112, 11002, 11112(Represent as ASCII)
7. Write an ALP to order given set of hexadecimal numbers in ascending and descending
order
Data: 0AH, 0FH, 0DH, 10H, 02H
8. Write an ALP to move block of data from locations 1200H-1205H to 2200H –
2205H
9. Write an ALP to reverse the given string
Data: WELCOME
INDEX
PAGE
Ex. No. DATE NAME OF THE EXPERIMENTS MARKS SIGN
NO.
Study Experiments
i) Study of 8086 Architecture
1. ii) Study of 8255 – PPI
iii) Study of 8253 – PIT
iv) Study of 8279 – PKI
v) Study of 8259 – PIC
2. Factorial of a given hexadecimal number
using 8086 MP
3. 16 bit arithmetic operations
sum of first ‘N’ natural numbers using 8086
4.
MP
Ex.No.:
STUDY EXPERIMENTS
DATE:
AIM:
To Study the Architecture of 8086 , Study of 8255 – PPI, Study of 8253 – PIT, Study of
8279 – PKI and Study of 8259 – PIC.
Introduction:
Before getting into 8086 lets 1st define microprocessor. in simple words, a microporcessor is an
electronic device which computes on the given input similar to CPU of a computer. it is made by
fabricating millions(or billions) of transistors on a single chip.
Intel 8086:
The 8086 is a 16-bit microprocessor chip designed by Intel corporation in between early 1976 and
mid-1978.pin configuration:- picture below shows the 8086 pin-assignments in min and max mode:
Features of 8086 :-
Background
The 8255 PPI chip is a general purpose programmable I/O device which is designed for use
with all Intel and most other microprocessors. The 8255 has 24 I/O pins divided into 3 groups of 8
pins each. The groups are denoted by port A, port B and port C respectively. Every one of the ports
can be configured as either an input port or an output port.
computer. The modified programs, when they are run in the 8051 evaluation board, should be able
to program port A and port B of the 8255 in the 8255 evaluation board to operate in one of their
operation modes. You can assemble and link your program modules with the provided cross-
assembler and linker to generate executable files. Executable files can then be loaded to the 8051
evaluation board via the printer port of the computer to program the on-board AT89S8252. The
AT89S8252 is a low-power, high -performance CMOS 8-bit microcomputer with 8K bytes of
Downloadable Flash programmable and erasable read only memory and 2K bytes of EEPROM.
The device is manufactured by Atmel and is compatible with the industry standard 80C51
instruction set and pinout.
printer
After programming the AT89S8252, the AT89S8252 executes the loaded program to
configure the 8255 and the ports of the 8255 should operate in the desired modes.
As there are 3 ports in 8255 and each one of them can be programmed as an input or output
port, there are a number of possible configurations. In this lab, four configurations given in Table 1
will be studied.
The Intel 8253 is a programmable counter/timer chip designed for use as an Intel
microcomputer peripheral.• It is packaged in a 24-pin plastic DIP.• Six programmable timer modes
allow the 8253 to be used as an event counter, elapsed time indicator, programmable one-shot, and
in many other applications e.g., to create different intervals.
• It has 3 counters: Counters 0, 1, 2
•Each counter in the block diagram has 3 lines connected to it. Two of these lines,clock and gate,
are inputs. The third, labeled OUT is an output. The function of these lines changes and
depends on how the device is initialized or programmed.
• Mode 2: Rate Generator. The counter will continually count down, when the count
reaches zero, the output will pulse low and the counter will be reloaded.
8259 PIC
The 8259 Programmable Interrupt Controller (PIC) is one of the most important chips
making up the x86 architecture. Without it, the x86 architecture would not be an interrupt driven
architecture. The function of the 8259A is to manage hardware interrupts and send them to the
appropriate system interrupt. This allows the system to respond to devices needs without loss of
time (from polling the device, for instance).
It is important to note that APIC has replaced the 8259 PIC in more modern systems,
especially those with multiple cores/processors. The 8259 PIC controls the CPU's interrupt
mechanism, by accepting several interrupt requests and feeding them to the processor in order. For
instance, when a keyboard registers a keyhit, it sends a pulse along it's interrupt line (IRQ 1) to the
PIC chip, which then translates the IRQ into a system interrupt, and sends a message to interrupt
the CPU from whatever it is doing. Part of the kernel's job is to either handle these IRQs and
perform the necessary procedures (poll the keyboard for the scancode) or alert a userspace program
to the interrupt (send a message to the keyboard driver).
Without a PIC, you would have to poll all the devices in the system to see if they want to do
anything (signal an event), but with a PIC, your system can run along nicely until such time that a
device wants to signal an event, which means you don't waste time going to the devices, you let the
devices come to you when they are ready.
VIVA QUESTION:
5. What is handshaking?
MARK ALLOCATION
Preparation & 50
conduct of experiment
Record 10
Viva voce 10
Total 100
RESULT:
Thus the 8086 Architecture, 8255 – PPI, 8253 – PIT, 8279 – PKI and 8259 – PIC
has been studied.
ADDITIONAL PROGRAM:
Ex.No.:
FACTORIAL OF A GIVEN HEXA DECIMAL NUMBER
DATE:
AIM:
To write an assembly language program to calculate factorial of a given numbers.
ALGORITHM:
1. Start the program.
2. Move immediately the number 0000H to AX register.
3. Copy the contents of the memory 3000 to CX register.
4. Move immediately the number 0001H to AX register.
5. Multiply the content of the CX register with the content of accumulator.
6. Decrement the content of CX register once.
7. Jump to specified memory location if there is no zero in CX register.
8. Copy the content to AX register to two memories from 2000.
9. End
PROGRAM:
PROGRAM COMMENTS
HLT Halt
OUTPUT:
VIVA QUESTIONS:
3. What is buffer?
4. What is Opcode?
5. What is Operand?
MARK ALLOCATION:
Preparation & 50
conduct of experiment
Record 10
Viva voce 10
Total 100
RESULT:
Thus the program for performing factorial of a given numbers is executed and verified.
ADDITIONAL PROGRAM:
1. Write an ALP to generate Fibonacci number using 8086 MP.
Ex.No.:
16 BIT ARITHMETIC OPERATION
DATE:
AIM:
To write an assembly language program for doing arithmetic operations like addition,
subtraction, multiplication and division operation of two numbers.
ALGORITHM:
(i) 16-bit addition
1. Initialize the MSBs of sum to 0
2. Get the first number.
3. Add the second number to the first number.
4. If there is any carry, increment MSBs of sum by 1.
5. Store LSBs of sum.
6. Store MSBs of sum.
(ii) 16-bit subtraction
1. Initialize the MSBs of difference to 0
2. Get the first number
3. Subtract the second number from the first number.
4. If there is any borrow, increment MSBs of difference by 1.
5. Store LSBs of difference
6. Store MSBs of difference.
(iii) 16-bit addition multiplication
1. Get the multiplier.
2. Get the multiplicand
3. Initialize the product to 0.
4. Product = product + multiplicand
5. Decrement the multiplier by 1
6. If multiplicand is not equal to 0, repeat from step (d) otherwise store the product.
(iv) 16-bit addition division
1. Get the dividend
2. Get the divisor
3. Initialize the quotient to 0.
4. Dividend = dividend –divisor
5. If the divisor is greater, store the quotient. Go to step g.
6. If dividend is greater, quotient = quotient + 1. Repeat from step (d)
7. Store the dividend value as remainder.
PROGRAM
1. Addition:
PROGRAM COMMENTS
2. Subtraction:
PROGRAM COMMENTS
3. Multiplication:
PROGRAM COMMENTS
4. Division:
PROGRAM COMMENTS
OUTPUT:
VIVA QUESTION:
1. What are the operations can be performed by logical operators?
MARK ALLOCATION:
Preparation & 50
conduct of experiment
Record 10
Viva voce 10
Total 100
RESULT:
Thus the program for 16 bit arithmetic operation is executed and verified.
ADDITIONAL PROGRAM:
1. Write an ALP to search a numbers in a sequence using 8086 MP
Ex.No.:
SUM OF ‘N’ NATURAL NUMBERS
DATE:
AIM:
To write an assembly language program for performing the sum of ‘N’ natural numbers.
ALGORITHM:
PROGRAM:
PROGRAM COMMENTS
MOV SI, 2000 Set source index as 2000
MOV CL, [SI] Move content of address pointed by source index to CL
MOV AL, 00 Clear AL to store sum
MOV BL, 01 Move '1' to BL , as it’s the first number
LOOP:ADD AL, BL Add content of BL to AL
INC BL increment BL
DEC CL Decrement the count
JNZ LOOP Jump if not zero to Loop
MOV DI, 2002 Set Destination index as memory address 2002
MOV [DI], AX Move content of Register A to destination, which is the total sum
HLT Stop the program
OUTPUT:
VIVA QUESTION:
1. What are the modes in which 8086 can operate?
MARK ALLOCATION:
Preparation & 50
conduct of experiment
Record 10
Viva voce 10
Total 100
RESULT:
Thus the program for performing the sum of ‘N’ natural numbers is executed and
verified.
ADDITIONAL PROGRAM:
1. Write an ALP to search a string using 8086 MP
Ex.No.:
CONVERSION OF HEXADECIMAL TO BINARY
DATE:
AIM:
To write an assembly language program to convert hexadecimal to binary.
ALGORITHM:
PROGRAM:
PROGRAM COMMENT
MOV A L,0A LOAD REGISTER AL WITH THE DATA 10
CMP AL,09 IF DATA LESS THAN 9 ADD 30 TO THE DATA
JZ 110A IF C OUNT I S ZER O TH E N G O TO 110A
st nd
OUTPUT:
VIVA QUESTION:
1. What is meant by interrupt?
MARK ALLOCATION
Preparation & 50
conduct of experiment
Record 10
Viva voce 10
Total 100
RESULT:
Thus the program for conversion of hexadecimal to binary (ASCII value) is executed and
verified.
ADDITIONAL PROGRAM:
1. Write an ALP to find and replace a string using 8086 MP.
Ex.No.:
CONVERSION OF BINARY TO HEXADECIMAL
DATE:
AIM:
To write an assembly language program to convert binary to hexadecimal.
ALGORITHM:
1. Load the input data in AL register.
2. Subtract 30 from AL register value.
3. If data is less than or equal to 16 terminate the program.
4. Else subtract 7 from AL register value.
5. Result stored in AL register
PROGRAM:
PROGRAM COMMENTS
MOV AL,31 Get data 31 into AL
SUB AL,30 Subtract 30 with the AL
CMP AL,10 If data is less than or equal to 16 go to 110C
JB 110C If 1st operand is below the 2nd operand then short jump into 110C
JZ 110C If count zero then jump into to 110C
SUB AL,07 Else subtract 7 from AL register value
HLT Break point
OUTPUT:
VIVA QUESTION:
1. What is register addressing?
MARK ALLOCATION:
Preparation & 50
conduct of experiment
Record 10
Viva voce 10
Total 100
RESULT:
Thus the program for conversion of binary (Represented in ASCII value) to hexadecimal
is executed and verified.
ADDITIONAL PROGRAM:
1. Write an ALP to generate the largest and smallest number using 8086 MP.
Ex.No.:
ASCENDING AND DESCENDING ORDER
DATE:
AIM:
To write an Assembly Language Program to sort a given array in ascending and
descending order.
ALGORITHM:
(i) Sorting in ascending order:
1. Load the array count in two registers C1 and C2.
2. Get the first two numbers.
3. Compare the numbers and exchange if necessary so that the two numbers are in
ascending order.
4. Decrement C2.
5. Get the third number from the array and repeat the process until C2 is 0.
6. Decrement C1 and repeat the process until C1 is 0.
(ii) Sorting in descending order:
1. Load the array count in two registers C1 and C2.
2. Get the first two numbers.
3. Compare the numbers and exchange if necessary so that the two numbers are in
descending order.
4. Decrement C2.
5. Get the third number from the array and repeat the process until C2 is 0.
6. Decrement C1 and repeat the process until C1 is 0.
PROGRAM:
1. ASCENDING
PROGRAM COMMENTS
JNB L1 If AL < BL go to L1
JMP L2 Jump to L2
HLT Stop
2. DESCENDING
PROGRAM COMMENTS
JB L1 If AL > BL go to L1
JMP L2 Jump to L2
HLT Stop
OUTPUT:
VIVA QUESTION:
MARK ALLOCATION:
Preparation & 50
conduct of experiment
Record 10
Viva voce 10
Total 100
RESULT:
Thus the program for sorting a given array in ascending and descending order is executed
and verified.
ADDITIONAL PROGRAM:
1. Write an ALP to separate odd and even numbers using 8086 MP
AIM:
To write an Assembly Language Program to moving data from source location to
destination location (1200H-1205H to 2200H – 2205H).
ALGORITHM:
1. Move the count value in the source index register.
PROGRAM:
PROGRAM COMMENTS
LEA SI,[2000] Move the count value in the source index register.
LEA DI,[2200] Move the count value to CL register.
MOV CL,[CL]
Move contents
INC SI Increment source index register.
L1:MOV AL,[SI] Move the contents of source index to AL.
MOV [DI],AL Move the contents of AL to destination index.
INC DI Increment the destination index.
INC SI Increment the source index.
DEC CL Decrement the contents of CL register
JNZ L1 If no zero jump to the loop.
HLT Stop
OUTPUT:
VIVA QUESTION:
1. What are data copy/transfer instructions?
MARK ALLOCATION:
Preparation & 50
conduct of experiment
Record 10
Viva voce 10
Total 100
RESULT:
Thus the program for moving data from source location to destination location is
executed and verified.
ADDITIONAL PROGRAM:
1. Write an ALP to convert BCD to hexadecimal using 8086 MP.
Ex.No.:
REVERSING THE STRING
DATE:
AIM:
To write an Assembly Language Program for reversing the given string.
ALGORITHM:
1. AX is initialized with data & AX is moved into DS
2. Initialize CX to 5
4. Move SI to AL
PROGRAM:
PROGRAM COMMENTS
MOV SI,2000 Move value of address 2000 to source index
OUTPUT
VIVA QUESTION:
1. Differentiate “shift” and “rotate”?
5. What is the maximum memory addressing and I/O addresing capabilities of 8086?
MARK ALLOCATION:
Preparation & 50
conduct of experiment
Record 10
Viva voce 10
Total 100
RESULT:
Thus the program for reversing the string is executed and verified
ADDITIONAL PROGRAM:
1. Write an ALP to find square root of a given numbers using 8086 MP.
Ex.No.:
GENERATING THE SERIES
DATE:
AIM:
To write an Assembly Language Program for generating the series.
.
ALGORITHM:
PROGRAM:
OUTPUT:
VIVA QUESTION:
MARK ALLOCATION:
Preparation & 50
conduct of experiment
Record 10
Viva voce 10
Total 100
RESULT:
Thus the program for generating the series is executed and verified.
ADDITIONAL PROGRAM:
1. Write an ALP to convert BCD to decimal numbers using 8086 MP.
Ex.No.:
GENERATING SQUARE WAVE USING 8255 PPI
DATE:
AIM:
To write an Assembly Language Program for generating square wave using 8255 PPI.
ALGORITHM:
1. Initialize channel 0 in mode 3
2. Initialize the LSB of the count.
3. Initialize the MSB of the count.
4. Trigger the count
5. Read the corresponding output in CRO.
PROGRAM:
PROGRAM COMMENTS
MOV AL, 36H Store the control word in accumulator
OUT 0BH Send through output port
MOV AL, 0AH Copy lower order count value in accumulator
OUT 08H Send through output port
MOV AL, 00H Copy higher order count value in accumulator
OUT 08H Send through output port
HLT Stop
OUTPUT:
VIVA QUESTION:
MARK ALLOCATION:
Preparation & 50
conduct of experiment
Record 10
Viva voce 10
Total 100
RESULT:
Thus the program for generating the square wave is executed and verified.
ADDITIONAL PROGRAM:
1. Write an ALP to generate sine wave using 8086 MP.
Ex.No.:
GENERATING RATE GENERATOR USING 8253 PIT
DATE:
AIM:
To write an assembly language program for generating rate generator using 8253 PIT.
ALGORITHM
PROGRAM:
PROGRAM COMMENTS
MOV AL, 34H Store the control word in accumulator
OUT 0BH Send through output port
MOV AL, 0AH Copy lower order count value in accumulator
OUT 08H Send through output port
MOV AL, 00H Copy higher order count value in accumulator
OUT 08H Send through output port
HLT Stop
OUTPUT:
VIVA QUESTION:
1. What is minimum mode?
MARK ALLOCATION:
Preparation & 50
conduct of experiment
Record 10
Viva voce 10
Total 100
RESULT:
Thus the program for generating the rate generator is executed and verified.
ADDITIONAL PROGRAM:
1. Write an ALP to generate triangular wave using 8086 MP.
Ex.No.:
INTERFACE KEYBOARD WITH 8086 USING 8279 PKI
DATE:
AIM:
To write an assembly language program for interfacing keyboard with 8086 using 8279 PKI.
ALGORITHM:
PROGRAM:
PROGRAM COMMENTS
START : MOV SI,1200H Initialize array
MOV CX,000FH Initialize array size
MOV AL,10 Store the control word for display mode
OUT C2,AL Send through output port
MOV AL,CC Store the control word to clear display
OUT C2,AL Send through output port
MOV AL,90 Store the control word to write display
OUT C2,AL Send through output port
L1 : MOV AL,[SI] Get the first data
OUT C0,AL Send through output port
CALL DELAY Give delay
INC SI Go & get next data
LOOP L1 Loop until all the data’s have been taken
JMP START Go to starting location
DELAY : MOV DX,0A0FFH Store 16bit count value
LOOP1 : DEC DX Decrement count value
OUTPUT:
VIVA QUESTION:
1. List the functions performed by 8279.
MARK ALLOCATION:
Preparation & 50
conduct of experiment
Record 10
Viva voce 10
Total 100
RESULT:
Thus the program for interface keyboard with 8086 using 8279 PKI is executed and verified
ADDITIONAL PROGRAM:
1. Write an ALP to display “HELP US” using 8086 MP.
Ex.No.:
INTERFACE ANALOG TO DIGITAL CONVERTER
DATE:
AIM:
ALGORITHM:
PROGRAM:
PROGRAM COMMENTS
MOV AL,01 STORE THE VALUE TO MAKE SOC HIGH IN THE ACCUMULATOR
MOV AL,00
MOV AL,00
MOV AL,00 STORE THE VALUE TO MAKE SOC LOW THE ACCUMULATOR
L1 : IN AL, 0D8H
AND AL,01 READ THE EOC SIGNAL FROM PORT & CHECK FOR END OF
CONVERSION
CMP AL,01
HLT STOP
OUTPUT:
VIVA QUESTIONS:
1. What is port?
4. What is exception?
MARK ALLOCATION:
Preparation & 50
conduct of experiment
Record 10
Viva voce 10
Total 100
RESULT:
Thus the program for interfacing analog to digital converter is executed and verified.
ADDITIONAL PROGRAM:
1. Write an ALP by interfacing 8255 with 8086 in mode 0, mode 1.