Sei sulla pagina 1di 166

EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR

AGNI COLLEGE OF TECHNOLOGY, CHENNAI

SYLLABUS

8086 Programs using kits and MASM

1. Basic arithmetic and Logical operations


2. Move a data block without overlap
3. Code conversion, decimal arithmetic and Matrix operations.
4. Floating point operations, string manipulations, sorting and searching
5. Password checking, Print RAM size and system date
6. Counters and Time Delay

Peripherals and Interfacing Experiments

7. Traffic light control


8. Stepper motor control
9. Digital clock
10. Key board and Display
11. Printer status
12. Serial interface and Parallel interface
13. A/D and D/A interface and Waveform Generation

8051 Experiments using kits and MASM

14. Basic arithmetic and Logical operations


15. Square and Cube program, Find 2‟s complement of a number
16. Unpacked BCD to ASCII

DEPARTMENT OF ECE, ACT Page 1


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

LAB OBJECTIVES

The student should be made to:

• Introduce ALP concepts and features

• Write ALP for arithmetic and logical operations in 8086 and 8051

• Differentiate Serial and Parallel Interface

• Interface different I/Os with Microprocessors

• Be familiar with MASM

LAB OUTCOMES

At the end of the course, the student should be able to:

• Write ALP Program for fixed and Floating Point and Arithmetic
• Interface different I/Os with processor
• Generate waveforms using Microprocessors
• Execute Programs in 8051
• Explain the difference between simulator and Emulator

DEPARTMENT OF ECE, ACT Page 2


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

LIST OF EXPERIMENTS

Page
S.No Date Experiment Title Signature
No
16-BIT ARITHMETIC OPERATION USING 8086 & MASM
1. Addition of two 16-bit number
2. Subtraction of two 16-bit number
3. Multiplication of two 16-bit number
4. Division of two 16-bit number
16-BIT LOGICAL OPERATION USING 8086 & MASM
5. Logical AND of two 16-bit number
6. Logical OR of two 16-bit number
7. Logical XOR of two 16-bit number
DATA BLOCK TRANSFER USING 8086 & MASM
8. Data Block Transfer
CODE CONVERSION USING 8086 & MASM
9. Hexadecimal to ASCII conversion
10. ASCII to Hexadecimal conversion
DECIMAL ARITHMETIC OPERATION USING 8086 & MASM
11. Addition of two 8-bit number
12. Subtraction of two 8-bit number
MATRIX OPERATION USING 8086 & MASM
13. Addition of two n x n matrix
14. Subtraction of two n x n matrix
STRING MANIPULATION OPERATION USING 8086 & MASM
15. Store operation
16. Find and replace data
SORTING USING 8086 & MASM
17. Ascending order
18. Descending order
SEARCHING USING 8086 & MASM
19. Smallest number
20. Largest number
PASSWORD CHECKING USING MASM
DEPARTMENT OF ECE, ACT Page 3
EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

21. Password Checking


ANALOG TO DIGITAL CONVERTOR INTERFACING USING 8086
22. ADC using 8086
DIGITAL TO ANALOG CONVERTOR INTERFACING USING 8086
23. Square Waveform Generation
24. Saw-Tooth Waveform Generation
25. Triangular Waveform Generation
KEYBOARD AND DISPLAY INTERFACING USING 8086
26. Rolling Display using 8279
STEPPER MOTOR CONTROL USING 8086
27. Stepper motor
PARALLEL INTERFACING USING 8086
28. Parallel Communication
TRAFFIC LIGHT CONTROLLER INTERFACING USING 8086
29. Traffic Light control
8-BIT ARITHMETIC OPERATION USING 8051
30. Addition of two 8-bit number
31. Subtraction of two 8-bit number
32. Multiplication of two 8-bit number
33. Division of two 8-bit number
8-BIT LOGICAL OPERATION USING 8051
34. Logical AND of two 8-bit number
35. Logical OR of two 8-bit number
36. Logical XOR of two 8-bit number
37. 2’s Complement of two 8-bit number
SQUARE OPERATION USING 8051
38. Square of an 8-bit number
CUBE OPERATION USING 8051
39. Cube of an 8-bit number
CODE CONVERSION USING 8051
40. UNPACKED BCD TO ASCII
ADDITIONAL EXPERIMENTS BEYOND THE SYLLABUS
41. Palindrome Checking using TASM

DEPARTMENT OF ECE, ACT Page 4


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

16-BIT ARITHMETIC OPERATION


USING 8086 & MASM

DEPARTMENT OF ECE, ACT Page 5


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

EX NO: 1
ADDITION OF TWO 16-BIT NUMBER
DATE:
AIM:

To write an assembly language program to add two 16 bit numbers by using 8086
Microprocessor and MASM software.

APPARATUS REQUIRED:

S.NO COMPONENTS QUANTITY

1. 8086 kit 1

2. Power Card 1

3. Keyboard 1

4. PC with MASM 1

ALGORITHM:

1. Start the program

2. Get the first data in AX register pair

3. Get the second data in BX register pair

4. Initialize the CL register

5. Add the first data & second data

6. Store the sum in the specified location

7. If no carry flag mean jump to step 9

8. Increment the CL register

9. Store the carry in the specified location

10. Stop the program

DEPARTMENT OF ECE, ACT Page 6


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM: (Using 8086)

HEXA DECIMAL

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


Move data from memory
1000 MOV AX,[1100H]
to AX register

Move data from memory


1004 MOV BX,[1102H]
to BX register

1008 MOV CL,00H Initialize the C register

Add the first data &


100B ADD AX,BX
second data

Store the sum in the


100D MOV [1200H],AX
specified location

if no carry flag mean


1011 JNC LOOP1
jump to loop label

1013 INC CL Increment the C register

Store the carry in the


1015 LOOP1 MOV [1202H],CL
specified location

1019 HLT Stop the program

OBSERVATION:

BEFORE EXECUTION AFTER EXECUTION

ADDRESS DATA ADDRESS DATA

1100 1200

1102 1202

DEPARTMENT OF ECE, ACT Page 7


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM: (Using MASM)

ASSUME CS: CODE, DS: CODE, SS: CODE


CODE SEGMENT
ORG 1000H
MOV SI, 1200H
MOV DI, 1300H
MOV AX, [SI]
MOV BX, [SI+02]
MOV CL, 00H
ADD AX, BX
MOV [DI], AX
JNC LOOP1
INC CL
LOOP1: MOV [DI+02], CL
INT 03H
CODE ENDS
END

RESULT:

Thus an assembly language program for addition of two 16-bit numbers was written using
8086 microprocessor. The program was executed using both MASM and 8086 kit and the output was
verified.

VIVA QUESTIONS:

1. Define microprocessor.
2. Name any three microprocessor manufacturing company.
3. What are the basic blocks of a microprocessor?
4. Define nibble, byte and word.
5. List the various buses of microprocessor.

DEPARTMENT OF ECE, ACT Page 8


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

EX NO: 2
SUBTRACTION OF TWO 16-BIT NUMBER
DATE:
AIM:

To write an assembly language program to subtraction of two 16 bit numbers by using 8086
microprocessor and MASM software.

APPARATUS REQUIRED:

S.NO COMPONENTS QUANTITY

1. 8086 kit 1

2. Power Card 1

3. Keyboard 1

4. PC with MASM 1

ALGORITHM:

1. Start the program

2. Get the first data in AX register pair

3. Get the second data in BX register pair

4. Initialize the CL register

5. Subtract the second data from first data

6. Store the subtraction result in the specified location

7. If no carry flag mean jump to step 9

8. Increment the CL register

9. Store the carry in the specified location

10. Stop the program

DEPARTMENT OF ECE, ACT Page 9


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM: (Using 8086)

HEXA DECIMAL

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


Move data from memory
1000 MOV AX,[1100H]
to AX register

Move data from memory


1004 MOV BX,[1102H]
to BX register

1008 MOV CL,00H Initialize the C register

Subtract the second data


100B SUB AX,BX
from first data

Store the subtraction in


100D MOV [1200H],AX
the specified location

if no carry flag mean


1011 JNC LOOP1
jump to loop label

1013 INC CL Increment the C register

Store the carry in the


1015 LOOP1 MOV [1202H],CL
specified location

1019 HLT Stop the program

OBSERVATION:

BEFORE EXECUTION AFTER EXECUTION

ADDRESS DATA ADDRESS DATA

1100 1200

1102 1202

DEPARTMENT OF ECE, ACT Page 10


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM: (Using MASM)

ASSUME CS: CODE, DS: CODE, SS: CODE


CODE SEGMENT
ORG 1000H
MOV SI, 1200H
MOV DI, 1300H
MOV AX, [SI]
MOV BX, [SI+02]
MOV CL, 00H
SUB AX, BX
MOV [DI], AX
JNC LOOP1
INC CL
LOOP1: MOV [DI+02], CL
INT 03H
CODE ENDS
END

RESULT:

Thus an assembly language program for subtraction of two 16-bit numbers was written
using 8086 microprocessor. The program was executed using both MASM and 8086 kit and the
output was verified.

VIVA QUESTIONS:

1. Give examples for 8/16 bit microprocessor.


2. Name any three registers of 8086 microprocessor.
3. Define addressing mode.
4. What is flag?
5. Compare carry flag and auxiliary carry flag

DEPARTMENT OF ECE, ACT Page 11


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

EX NO: 3
MULTIPLICATION OF TWO 16-BIT DATA
DATE:
AIM:

To write an assembly language program to perform a multiplication of two 16-bit


numbers using 8086 & MASM software.

APPARATUS REQUIRED:

S.NO COMPONENTS QUANTITY

1. 8086 kit 1

2. Power Card 1

3. Keyboard 1

4. PC with MASM 1

ALGORITHM:

1. Start the program

2. Get the first data in AX register pair

3. Get the second data in BX register pair

4. Multiply first data & second data

5. Store the lower order multiplication result in the specified location

7. Store the higher order multiplication result in the specified location

8. Stop the program

DEPARTMENT OF ECE, ACT Page 12


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM: (USING 8086)

HEXA DECIMAL

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


Move data from memory
1000 MOV AX,[1100H]
to AX register

Move data from memory


1004 MOV BX,[1102H]
to BX register

Multiply the first data &


1008 MUL BX
second data

Store the lower order


100A MOV [1200H],AX result in the specified
location

Store the higher order


100E MOV [1202H],DX result in the specified
location

1012 HLT Stop the program

OBSERVATION:

BEFORE EXECUTION AFTER EXECUTION

ADDRESS DATA ADDRESS DATA

1100 1200

1102 1202

DEPARTMENT OF ECE, ACT Page 13


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM: (Using MASM)

ASSUME CS: CODE, DS: CODE, SS: CODE


CODE SEGMENT
ORG 1000H
MOV SI, 1200H
MOV DI, 1300H
MOV AX, [SI]
MOV BX, [SI+02]
MUL BX
MOV [DI], AX
MOV [DI+02], DX
INT 03H
CODE ENDS
END

RESULT:

Thus an assembly language program for multiplication of two 16-bit numbers was
written using 8086 microprocessor. The program was executed using both MASM and 8086 kit
and the output was verified.

VIVA QUESTIONS:

1. List the flag in 8086.


2. Name the two functional units of 8086.
3. What is interrupt?
4. Define tri state logic.
5. What is the clock frequency of 8086?

DEPARTMENT OF ECE, ACT Page 14


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

EX NO: 4
DIVISION OF TWO 16-BIT DATA
DATE:
AIM:

To write an assembly language program to perform a division of two 16-bit numbers


using 8086 & MASM software.

APPARATUS REQUIRED:

S.NO COMPONENTS QUANTITY

1. 8086 kit 1

2. Power Card 1

3. Keyboard 1

4. PC with MASM 1

ALGORITHM:

1. Start the program

2. Get the first data in AX register pair

3. Get the second data in BX register pair

4. Division of first data & second data

5. Store the lower order division result in the specified location

7. Store the higher order division result in the specified location

8. Stop the program

DEPARTMENT OF ECE, ACT Page 15


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM: (USING 8086)

HEXA DECIMAL

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


Move data from memory
1000 MOV AX,[1100H]
to AX register

Move data from memory


1004 MOV BX,[1102H]
to BX register

Divide the first data &


1008 DIV BX
second data

Store the lower order


100A MOV [1200H],AX result in the specified
location

Store the higher order


100E MOV [1202H],DX result in the specified
location

1012 HLT Stop the program

OBSERVATION:

BEFORE EXECUTION AFTER EXECUTION

ADDRESS DATA ADDRESS DATA

1100 1200

1102 1202

DEPARTMENT OF ECE, ACT Page 16


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM: (Using MASM)

ASSUME CS: CODE, DS: CODE, SS: CODE


CODE SEGMENT
ORG 1000H
MOV SI, 1200H
MOV DI, 1300H
MOV AX, [SI]
MOV BX, [SI+02]
DIV BX
MOV [DI], AX
MOV [DI+02], DX
INT 03H
CODE ENDS
END

RESULT:

Thus an assembly language program for division of two 16-bit numbers was written using
8086 microprocessor. The program was executed using both MASM and 8086 kit and the output was
verified.

VIVA QUESTIONS:

1. How many address lines in 8086?


2. Mention the types of instructions of 8086.
3. Compare CMP-SUB instructions
4. List the features of 8086.
5. What are the various segments registers of 8086.

DEPARTMENT OF ECE, ACT Page 17


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

16-BIT LOGICAL OPERATION


USING 8086 & MASM

DEPARTMENT OF ECE, ACT Page 18


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

EX NO: 5
Logical AND of two 16-bit
DATE:
AIM:

To write an assembly language program to logical AND of two 16 bit numbers by using 8086
Microprocessor & MASM software.

APPARATUS REQUIRED:

S.NO COMPONENTS QUANTITY

1. 8086 kit 1

2. Power Card 1

3. Keyboard 1

4. PC with MASM 1

ALGORITHM:

1. Start the program


2. Get the first data in AX register pair
3. Get the second data in BX register pair
4. Logical AND of first data & second data
5. Store the result in the specified location
6. Stop the program

DEPARTMENT OF ECE, ACT Page 19


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM: (USING 8086)

HEXA DECIMAL

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


Move data from memory
1000 MOV AX,[1100H]
to AX register

Move data from memory


1004 MOV BX,[1102H]
to BX register

Logical AND of the first


1008 AND AX,BX
data & second data

Store the result in the


100A MOV [1200H],AX
specified location

100E HLT Stop the program

OBSERVATION:

BEFORE EXECUTION AFTER EXECUTION

ADDRESS DATA ADDRESS DATA

1100 1200

1102

DEPARTMENT OF ECE, ACT Page 20


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM: (Using MASM)

ASSUME CS: CODE, DS: CODE, SS: CODE


CODE SEGMENT
ORG 1000H
MOV SI, 1200H
MOV DI, 1300H
MOV AX, [SI]
MOV BX, [SI+02]
AND AX, BX
MOV [DI], AX
INT 03H
CODE ENDS
END

RESULT:

Thus an assembly language program for logical AND of two 16-bit numbers was written
using 8086 microprocessor. The program was executed using both MASM and 8086 kit and the
output was verified.

VIVA QUESTIONS:

1. What are the bit manipulation instructions present in 8086?


2. What is the truth table of AND operation?
3. What are instructions used in logical operation?
4. What are the rotate instructions present in 8086?
5. What are the shift instructions present in 8086?

DEPARTMENT OF ECE, ACT Page 21


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

EX NO: 6
Logical OR of two 16-bit
DATE:
AIM:

To write an assembly language program to logical OR of two 16 bit numbers by using 8086
Microprocessor & MASM software.

APPARATUS REQUIRED:

S.NO COMPONENTS QUANTITY

1. 8086 kit 1

2. Power Card 1

3. Keyboard 1

4. PC with MASM 1

ALGORITHM:

1. Start the program


2. Get the first data in AX register pair
3. Get the second data in BX register pair
4. Logical OR of first data & second data
5. Store the result in the specified location
6. Stop the program

DEPARTMENT OF ECE, ACT Page 22


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM: (USING 8086)

HEXA DECIMAL

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


Move data from memory
1000 MOV AX,[1100H]
to AX register

Move data from memory


1004 MOV BX,[1102H]
to BX register

Logical OR of the first


1008 OR AX,BX
data & second data

Store the result in the


100A MOV [1200H],AX
specified location

100E HLT Stop the program

OBSERVATION:

BEFORE EXECUTION AFTER EXECUTION

ADDRESS DATA ADDRESS DATA

1100 1200

1102

DEPARTMENT OF ECE, ACT Page 23


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM: (Using MASM)

ASSUME CS: CODE, DS: CODE, SS: CODE


CODE SEGMENT
ORG 1000H
MOV SI, 1200H
MOV DI, 1300H
MOV AX, [SI]
MOV BX, [SI+02]
OR AX, BX
MOV [DI], AX
INT 03H
CODE ENDS
END

RESULT:

Thus an assembly language program for logical OR of two 16-bit numbers was written using
8086 microprocessor. The program was executed using both MASM and 8086 kit and the output was
verified.

VIVA QUESTIONS:

1. What is the truth table of OR operation?


2. Difference between ROL and ROR.
3. Difference between RCL and RCR.
4. Difference between SAL and SAR.
5. Difference between SHL and SHR.

DEPARTMENT OF ECE, ACT Page 24


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

EX NO: 7
Logical XOR of two 16-bit
DATE:
AIM:

To write an assembly language program to logical XOR of two 16 bit numbers by using 8086
microprocessor & MASM software.

APPARATUS REQUIRED:

S.NO COMPONENTS QUANTITY

1. 8086 kit 1

2. Power Card 1

3. Keyboard 1

4. PC with MASM 1

ALGORITHM:

1. Start the program


2. Get the first data in AX register pair
3. Get the second data in BX register pair
4. Logical XOR of first data & second data
5. Store the result in the specified location
6. Stop the program

DEPARTMENT OF ECE, ACT Page 25


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM: (USING 8086)

HEXA DECIMAL

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


Move data from memory
1000 MOV AX,[1100H]
to AX register

Move data from memory


1004 MOV BX,[1102H]
to BX register

Logical XOR of the first


1008 XOR AX,BX
data & second data

Store the result in the


100A MOV [1200H],AX
specified location

100E HLT Stop the program

OBSERVATION:

BEFORE EXECUTION AFTER EXECUTION

ADDRESS DATA ADDRESS DATA

1100 1200

1102

DEPARTMENT OF ECE, ACT Page 26


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM: (Using MASM)

ASSUME CS: CODE, DS: CODE, SS: CODE


CODE SEGMENT
ORG 1000H
MOV SI, 1200H
MOV DI, 1300H
MOV AX, [SI]
MOV BX, [SI+02]
XOR AX, BX
MOV [DI], AX
INT 03H
CODE ENDS
END

RESULT:

Thus an assembly language program for logical XOR of two 16-bit numbers was written
using 8086 microprocessor. The program was executed using both MASM and 8086 kit and the
output was verified.

VIVA QUESTIONS:

1. What is the truth table of XOR operation?


2. What is the operating frequency of 8086?
3. What is the expansion of USART?
4. Define complement.
5. Define 2’s complement.

DEPARTMENT OF ECE, ACT Page 27


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

DATA BLOCK TRANSFER


USING 8086 & MASAM

DEPARTMENT OF ECE, ACT Page 28


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

EX NO: 8
DATA BLOCK TRANSFER
DATE:
AIM:

To write an assembly language program to transfer a block of data from one memory location
to another using 8086 and MASM software.

APPARATUS REQUIRED:

S.NO COMPONENTS QUANTITY

1. 8086 kit 1

2. Power Card 1

3. Keyboard 1

4. PC with MASM 1

ALGORITHM:

1. Initialize source address in SI register


2. Initialize destination address in DI registers
3. Initialize the count in CX register.
4. Clear the direction flag
5. Transfer the data using string instruction until counter reaches zero
6. Stop the execution.

DEPARTMENT OF ECE, ACT Page 29


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM: (By using 8086)

HEXA DECIMAL

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


1000 MOV SI,2000H Point SI at source array

Point DI at destination
1004 MOV DI,2100H
array

Number of array
1008 MOV CX,00FFH
elements in CX

100C CLD DF cleared

100D LOOP1 MOVSB Move string byte

Subtract 1 from CX, if


100E LOOP LOOP1 CX>0 mean go to
LOOP1

1010 HLT Stop the program

OBSERVATION:

BEFORE EXECUTION AFTER EXECUTION

ADDRESS DATA ADDRESS DATA

2000 2100

2001 2101

2002 2102

2003 2103

2004 2104

DEPARTMENT OF ECE, ACT Page 30


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM: (By using MASM)

ASSUME CS: CODE, DS: CODE, SS: CODE


CODE SEGMENT
ORG 1000H
MOV SI, 2000H
MOV DI, 2100H
MOV CX, 00FFH
CLD
LOOP1: MOVSB
LOOP LOOP1
INT 03H
CODE ENDS
END

RESULT:

Thus an assembly language program for transferring a block of data from one memory
location to another was written using 8086 microprocessor. The program was executed using MASM
and the output was verified.

VIVA QUESTIONS:

1. Give any three examples for data transfer instructions of 8086?


2. What is meant by maskable interrupt?
3. Compare JMP and CALL instructions.
4. List any five assembler directives.
5. What is the use of directional flag?

DEPARTMENT OF ECE, ACT Page 31


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

CODE CONVERSION
USING 8086 & MASM

DEPARTMENT OF ECE, ACT Page 32


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

EX NO: 9
HEXADECIMAL TO ASCII CONVERSION
DATE:
AIM:

To write an assembly language program to convert Hexadecimal to ASCII Conversion by


using 8086 Microprocessor & MASM software.

APPARATUS REQUIRED:

S.NO COMPONENTS QUANTITY

1. 8086 kit 1

2. Power Card 1

3. Keyboard 1

4. PC with MASM 1

ALGORITHM:

1. Start the program


2. Get the data in AL register
3. Subtract 30H from AL register
4. Compare 09H to AL register if equal go L1
5. checks carry, if carry flag is set got to L1
6. Subtract 07H to AL register
7. Store the result in the specified location
8. Stop the program

DEPARTMENT OF ECE, ACT Page 33


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM: (USING 8086)

HEXA DECIMAL

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


Move data from memory
1000 MOV AL,[1100H]
to AL register

Subtract 30H from AL


1004 SUB AL,30H
register

Compare 09H to AL
1007 CMP AL,09H
register

Compare 09H to AL
100A JE LOOP1 register if equal go
LOOP1

checks carry, if carry flag


100C JC LOOP1
is set got to LOOP1

Subtract 07H from AL


100E SUB AL, 07H
register

Store the result in the


1011 LOOP1 MOV [1200H], AL
specified location

1015 HLT Stop the program

OBSERVATION:

BEFORE EXECUTION AFTER EXECUTION

ADDRESS DATA ADDRESS DATA

1100 1200

DEPARTMENT OF ECE, ACT Page 34


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM: (Using MASM)

ASSUME CS: CODE, DS: CODE, SS: CODE


CODE SEGMENT
ORG 1000H
MOV SI, 1200H
MOV DI, 1300H
MOV AL, [SI]
SUB AL, 30H
CMP AL, 09H
JE LOOP1
JC LOOP1
SUB AL, 07H
LOOP1: MOV [DI], AL
INT 03H
CODE ENDS
END

RESULT:

Thus an assembly language program for to convert Hexadecimal to ASCII Conversion was
written using 8086 microprocessor. The program was executed using both MASM and 8086 kit and
the output was verified.

VIVA QUESTIONS:

1. How many data lines in 8086?


2. List the different addressing modes of 8086.
3. List the string instructions in 8086.
4. Define segmentation.
5. Define 2’s complement.

DEPARTMENT OF ECE, ACT Page 35


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

EX NO: 10
ASCII TO HEXADECIMAL CONVERSION
DATE:
AIM:

To write an assembly language program to convert ASCII to Hexadecimal conversion by


using 8086 Microprocessor & MASM software.

APPARATUS REQUIRED:

S.NO COMPONENTS QUANTITY

1. 8086 kit 1

2. Power Card 1

3. Keyboard 1

4. Pc with MASM 1

ALGORITHM:

1. Start the program


2. Get the data in AL register
3. Compare AL with 09H.
4. If it is equal go to step L1, otherwise go to step 3.
5. Check carry flag, if carry flag is set, go to step L1
6. Add 07H from AL register.
7. Add 30H from AL register.
8. Store the result in the specified location
9. Stop the program

DEPARTMENT OF ECE, ACT Page 36


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM: (USING 8086)

HEXA DECIMAL

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


Get the data in AL
1000 MOV AL,[1100H]
register

1004 CMP AL, 09H Compare AL with 09H

If it is equal go to step
1007 JE LOOP1
LOOP1

Check carry flag, if carry


1009 JC LOOP1 flag is set, go to step
LOOP1

Add 07H from AL


100B ADD AL, 07H
register

Add 30H from AL


100E LOOP1 ADD AL, 30H
register

Store the result in the


1011 MOV [1200H], AL
specified location

1015 HLT Stop the program

OBSERVATION:

BEFORE EXECUTION AFTER EXECUTION

ADDRESS DATA ADDRESS DATA

1100 1200

DEPARTMENT OF ECE, ACT Page 37


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM: (Using MASM)

ASSUME CS: CODE, DS: CODE, SS: CODE


CODE SEGMENT
ORG 1000H
MOV SI, 1200H
MOV DI, 1300H
MOV AL, [SI]
CMP AL, 09H
JE LOOP1
JC LOOP1
ADD AL, 07H
LOOP1: ADD AL, 30H
MOV [DI], AL
INT 03H
CODE ENDS
END

RESULT:

Thus an assembly language program for to convert ASCII to Hexadecimal conversion was
written using 8086 microprocessor. The program was executed using both MASM and 8086 kit and
the output was verified.

VIVA QUESTIONS:

1. Difference between jump and call.


2. Give some 16 bit registers of 8086.
3. Specify addressing modes for MOV AX, [1000] instruction.
4. What is the use of CX register?
5. Specify the function of flag register.

DEPARTMENT OF ECE, ACT Page 38


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

DECIMAL ARITHMETIC OPERATION


USING 8086 & MASM

DEPARTMENT OF ECE, ACT Page 39


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

EX NO: 11
ADDITION OF TWO 8-BIT NUMBER
DATE:
AIM:

To write an assembly language program to decimal addition of two 8-bit data using 8086 and
MASM software.

APPARATUS REQUIRED:

S.NO COMPONENTS QUANTITY

1. 8086 kit 1

2. Power Card 1

3. Keyboard 1

4. PC with MASM 1

ALGORITHM:

1. Start the program


2. Move data from memory to AL register
3. Move data from memory to BL register
4. Initialize the CL register
5. Add the first data & second data
6. Decimal adjust for addition for correction
7. If Cy = 0 mean go to LOOP1 label (step 9)
8. Increment the CL register
9. Store the LSB value in the specified location
10. Store the MSB value in the specified location
11. Stop the execution.

DEPARTMENT OF ECE, ACT Page 40


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM: (By using 8086)

HEXA DECIMAL

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


Move data from
1000 MOV AL,[1100H]
memory to AL register

Move data from


1004 MOV BL,[1101H]
memory to BL register

Initialize the CL
1008 MOV CL,00H
register

Add the first data &


100B ADD AL,BL
second data

Decimal adjust for


100D DAA
addition for correction

If Cy = 0 mean go to
100E JNC LOOP1
LOOP1

Increment the CL
1010 INC CL
register

Store the LSB value in


1012 LOOP1 MOV [1200H],AL
the specified location

Store the MSB value in


1016 MOV [1201H],CL
the specified location

101A HLT Stop the program

OBSERVATION:

BEFORE EXECUTION AFTER EXECUTION

ADDRESS DATA ADDRESS DATA

1100 1200

1101 1201

DEPARTMENT OF ECE, ACT Page 41


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM: (By using MASM)

ASSUME CS: CODE, DS: CODE, SS: CODE


CODE SEGMENT
ORG 1000H
MOV SI, 1200H
MOV DI, 1300H
MOV AL, [SI]
MOV BL, [SI+01]
MOV CL, 00H
ADD AL, BL
DAA
JNC LOOP1
INC CL
LOOP1: MOV [DI], AL
MOV [DI+01], CL
INT 03H
CODE ENDS
END

RESULT:

Thus an assembly language program to decimal addition of two 8-bit data using 8086 was written
using 8086 microprocessor. The program was executed using MASM and the output was verified.

VIVA QUESTIONS:

1. What is immediate addressing?


2. List any two string manipulation instructions of 8086.
3. What is the size of vector interrupt table?
4. List minimum mode signals used in 8086.
5. State about INTR pin in 8086.

DEPARTMENT OF ECE, ACT Page 42


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

EX NO: 12
SUBTRACTION OF TWO 8-BIT NUMBER
DATE:
AIM:

To write an assembly language program to decimal subtraction of two 8-bit data using 8086 and MASM
software.

APPARATUS REQUIRED:

S.NO COMPONENTS QUANTITY

1. 8086 kit 1

2. Power Card 1

3. Keyboard 1

4. PC with MASM 1

ALGORITHM:

1. Start the program


2. Move data from memory to AL register
3. Move data from memory to BL register
4. Initialize the CL register
5. Subtract the first data & second data
6. Decimal adjust for subtraction
7. If Cy = 0 mean go to LOOP1 label (step 9)
8. Increment the CL register
9. Store the LSB value in the specified location
10. Store the MSB value in the specified location
11. Stop the execution.

DEPARTMENT OF ECE, ACT Page 43


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM: (By using 8086)

HEXA DECIMAL

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


Move data from
1000 MOV AL,[1100H]
memory to AL register

Move data from


1004 MOV BL,[1101H]
memory to BL register

Initialize the CL
1008 MOV CL,00H
register

Subtract the first data &


100B SUB AL,BL
second data

Decimal adjust for


100D DAS subtraction for
correction

If Cy = 0 mean go to
100E JNC LOOP1
LOOP1

Increment the CL
1010 INC CL
register

Store the LSB value in


1012 LOOP1 MOV [1200H],AL
the specified location

Store the MSB value in


1016 MOV [1201H],CL
the specified location

101A HLT Stop the program

OBSERVATION:

BEFORE EXECUTION AFTER EXECUTION

ADDRESS DATA ADDRESS DATA

1100 1200

1101 1201

DEPARTMENT OF ECE, ACT Page 44


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM: (By using MASM)

ASSUME CS: CODE, DS: CODE, SS: CODE


CODE SEGMENT
ORG 1000H
MOV SI, 1200H
MOV DI, 1300H
MOV AL, [SI]
MOV BL, [SI+01]
MOV CL, 00H
SUB AL, BL
DAS
JNC LOOP1
INC CL
LOOP1: MOV [DI], AL
MOV [DI+01], CL
INT 03H
CODE ENDS
END

RESULT:

Thus an assembly language program to decimal subtraction of two 8-bit data using 8086 was
written using 8086 microprocessor. The program was executed using MASM and the output was
verified.

VIVA QUESTIONS:

1. How do you calculate the effective address?


2. Define pipelining.
3. Give examples for register addressing mode.
4. List any four logical instructions of 8086.
5. How much memory can be interfaced with 8086?

DEPARTMENT OF ECE, ACT Page 45


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

MATRIX OPERATION
USING 8086 & MASM

DEPARTMENT OF ECE, ACT Page 46


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

EX NO: 13
ADDITION OF TWO n x n MATRIX
DATE:
AIM:
To write an assembly language program to perform addition two n x n matrices using
8086 microprocessor and MASM.

APPARATUS REQUIRED:

S.NO COMPONENTS QUANTITY

1. 8086 kit 1

2. Power Card 1

3. Keyboard 1

4. PC with MASM 1

ALGORITHM

1. Set the Count Value as 04H


2. Set SI register as Pointer for array for 1st Matrix
3. Set DI register as Pointer for array for 2nd Matrix
4. Move Contents of SI register to AL
5. Move contents of DI register to BL
6. Add the contents of AL and BL
7. Move the result from AL register to Memory
8. Increment SI and DI register.
9. Decrement Count Value
10. If Count Value becomes zero, stop the program

DEPARTMENT OF ECE, ACT Page 47


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM: (By using 8086)

HEXA DECIMAL

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


1000 MOV SI, 1100H Set source index
address as 1100H
Set destination index
1004 MOV DI, 1200H
address as 1200H

Set the count value in


1008 MOV CL, 04H
CL register

Move the data from SI


100B LOOP1 MOV AL, [SI]
Address to AL

100D MOV BL, [DI] Move the data from


DI Address to BL
Add the data BL from
100F ADD AL, BL
AL register

Move the data from AL


1011 MOV [DI], AL
Address to DI address

Increment the SI
1013 INC SI
address value

Increment the DI
1014 INC DI
address value

1015 DEC CL Decrement CL register

If check CL#0 go to
1017 JNZ LOOP1
Loop1 label

1019 HLT Stop the program

DEPARTMENT OF ECE, ACT Page 48


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

OBSERVATION:

BEFORE EXECUTION AFTER EXECUTION

ADDRESS DATA ADDRESS DATA

1100 1200

1101 1201

1102 1202

1103 1203

1200

1201

1202

1203

DEPARTMENT OF ECE, ACT Page 49


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM: (By using MASM)

ASSUME CS: CODE, DS: CODE, SS: CODE


CODE SEGMENT
ORG 1000H
MOV SI, 1200H
MOV DI, 1300H
MOV CL, 04H
LOOP1: MOV AL, [SI]
MOV BL, [DI]
ADD AL, BL
MOV [DI], AL
INC SI
INC DI
DEC CL
JNZ LOOP1
INT 03H
CODE ENDS
END

RESULT:

Thus an assembly language program to perform the addition of two n x n matrices was
written using 8086 microprocessor. The program was executed using MASM and the output
was verified.

VIVA QUESTIONS:

1. Define coprocessor.
2. Name any two coprocessors.
3. Mention the operating modes of 8086,
4. List any four arithmetic instructions of 8086.
5. What is the size of instruction queue in 8086?

DEPARTMENT OF ECE, ACT Page 50


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

EX NO: 14
SUBTRACTION OF TWO n x n MATRIX
DATE:
AIM:
To write an assembly language program to perform subtraction two n x n matrices using
8086 microprocessor and MASM.

APPARATUS REQUIRED:

S.NO COMPONENTS QUANTITY

1. 8086 kit 1

2. Power Card 1

3. Keyboard 1

4. PC with MASM 1

ALGORITHM

1. Set the Count Value as 04H


2. Set SI register as Pointer for array for 1st Matrix
3. Set DI register as Pointer for array for 2nd Matrix
4. Move Contents of SI register to AL
5. Move contents of DI register to BL
6. Subtract the contents of AL and BL
7. Move the result from AL register to Memory
8. Increment SI and DI register.
9. Decrement Count Value
10. If Count Value becomes zero, stop the program

DEPARTMENT OF ECE, ACT Page 51


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM: (By using 8086)

HEXA DECIMAL

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


1000 MOV SI, 1100H Set source index
address as 1100H
Set destination index
1004 MOV DI, 1200H
address as 1200H

Set the count value in


1008 MOV CL, 04H
CL register

Move the data from SI


100B LOOP1 MOV AL, [SI]
Address to AL

100D MOV BL, [DI] Move the data from


DI Address to BL
Subtract the data BL
100F SUB AL, BL
from AL register

Move the data from AL


1011 MOV [DI], AL
Address to DI address

Increment the SI
1013 INC SI
address value

Increment the DI
1014 INC DI
address value

1015 DEC CL Decrement CL register

If check CL#0 go to
1017 JNZ LOOP1
Loop1 label

1019 HLT Stop the program

DEPARTMENT OF ECE, ACT Page 52


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

OBSERVATION:

BEFORE EXECUTION AFTER EXECUTION

ADDRESS DATA ADDRESS DATA

1100 1200

1101 1201

1102 1202

1103 1203

1200

1201

1202

1203

DEPARTMENT OF ECE, ACT Page 53


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM: (By using MASM)

ASSUME CS: CODE, DS: CODE, SS: CODE


CODE SEGMENT
ORG 1000H
MOV SI, 1200H
MOV DI, 1300H
MOV CL, 04H
LOOP1: MOV AL, [SI]
MOV BL, [DI]
SUB AL, BL
MOV [DI], AL
INC SI
INC DI
DEC CL
JNZ LOOP1
INT 03H
CODE ENDS
END

RESULT:

Thus an assembly language program to perform the subtraction of two n x n matrices


was written using 8086 microprocessor. The program was executed using MASM and the
output was verified.

VIVA QUESTIONS:

1. What is the operating frequency of 8086?


2. Difference between timer and counter.
3. Difference between synchronous and asynchronous?
4. Difference between serial and parallel communication
5. Why 8086 microprocessor is called as 8-bit microprocessor?

DEPARTMENT OF ECE, ACT Page 54


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

STRING MANIPULATION OPERATION


USING 8086 & MASM

DEPARTMENT OF ECE, ACT Page 55


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

EX NO: 15
STORE DATA
DATE:
AIM:
To write an assembly language program to move a byte of string length 0100 from
accumulator to destination using 8086 & MASM.

APPARATUS REQUIRED:

S.NO COMPONENTS QUANTITY

1. 8086 kit 1

2. Power Card 1

3. Keyboard 1

4. PC with MASM 1

ALGORITHM:

1. Start the program

2. Move count value in CX reg

3. Point DI at destination array.

4. Move data to AL reg

5. Direction Flag is cleared to SI and DI will auto increment after the loop

6. Store string byte from accumulator to destination

7. Subtract 1 from CX, if CX>0 mean go to step 6

8. Stop the program.

DEPARTMENT OF ECE, ACT Page 56


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM: (By using 8086)

HEXA DECIMAL

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


Move count value in
1000 MOV CX,0100H
CX reg

Point DI at destination
1004 MOV DI,1100H
array

1008 MOV AL, data Move data to AL reg

100B CLD DF cleared

Store string byte from


100C LOOP1 STOSB accumulator to
destination

Subtract 1 from CX, if


100D LOOP LOOP1 CX>0 mean go to
LOOP1

100F HLT Stop the program

OBSERVATION:

BEFORE EXECUTION AFTER EXECUTION

ADDRESS DATA ADDRESS DATA

100A 1100

1101

11FF

DEPARTMENT OF ECE, ACT Page 57


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM: (By using MASM)

ASSUME CS: CODE, DS: CODE, SS: CODE


CODE SEGMENT
ORG 1000H
MOV CX, 0100H
MOV DI, 1200H
MOV AL, data
CLD
LOOP1: STOSB
LOOP LOOP1
INT 03H
CODE ENDS
END

RESULT:

Thus an assembly language program to perform the store string operation was written
using 8086 microprocessor. The program was executed using MASM and the output was
verified.

VIVA QUESTIONS:

1. What is the function of LOOP instruction?


2. Which instruction is used to enable directional flag?
3. Which instruction is used to disable directional flag?
4. How to calculate source address in string addressing mode?
5. How to calculate destination address in string addressing mode?

DEPARTMENT OF ECE, ACT Page 58


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

EX NO: 16
FIND AND REPLACE DATA
DATE:
AIM:
To write an assembly language program to find the given data in the array and
replace it with other data using 8086 and MASM.

APPARATUS REQUIRED:

S.NO COMPONENTS QUANTITY

1. 8086 kit 1

2. Power Card 1

3. Keyboard 1

4. PC with MASM 1

ALGORITHM:

1. Initialize memory pointer for string.


2. Move the data to be found in AL register and the data to be replaced in BL register
3. Use string instruction to find the data in an array and replace it with the content of BL
register.
4. Stop the execution

DEPARTMENT OF ECE, ACT Page 59


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM: (By using 8086)

HEXA DECIMAL

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


1000 MOV CX, 0005H Move count value in CX reg

1004 MOV DI, 1200H Point DI at destination array

1008 MOV AL, 45H Move data to AL reg

100B MOV BL, 57H Move data to BL reg

100E CLD DF cleared

Repeat till ZF = 0. Scan


value from [DI] and
100F REPNE SCASB
compare with AL, Increment
DI

1011 DEC DI Decrement the DI register

The content BL register


1012 MOV [DI], BL
given memory to GS

1014 HLT Stop the program

OBSERVATION:

BEFORE EXECUTION AFTER EXECUTION

ADDRESS DATA ADDRESS DATA

1200 1200

1201 1201

1202 1202

1203 1203

1204 1204

DEPARTMENT OF ECE, ACT Page 60


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM: (By using MASM)

ASSUME CS: CODE, DS: CODE, SS: CODE


CODE SEGMENT
ORG 1000H
MOV CX, 0005H
MOV DI, 1200H
MOV AL, BEH
MOV BL, ECH
CLD
REPNE SCASB
DEC DI
MOV [DI], BL
INT 03H
CODE ENDS
END

RESULT:

Thus an assembly language program to perform find and replace string operation was
written using 8086 microprocessor. The program was executed using MASM and the output
was verified.

VIVA QUESTIONS:

1. How to identify the given instruction is miscellaneous instruction?


2. Why 10H is multiply with segment in physical memory calculation?
3. What are the index register present in 8086?
4. What are the base registers present in 8086?
5. List the interrupt types in 8086?

DEPARTMENT OF ECE, ACT Page 61


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

SORTING
USING 8086 & MASM

DEPARTMENT OF ECE, ACT Page 62


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

EX NO: 17
ASCENDING ORDER
DATE:
AIM:

To write an assembly language program for the sorting in ascending order using 8086
microprocessor & MASM.

APPARATUS REQUIRED:

S.NO COMPONENTS QUANTITY

1. 8086 kit 1

2. Power Card 1

3. Keyboard 1

4. PC with MASM 1
ALGORITHM:

1. Start the program

2. Move data to CX register

3. Move CX data to D1 register

4. Move 1100H to the BX register

5. Move the content of 1100H to memory of AX

6. Compare the content of AX with 1102H

7. Jump on borrow mean go to step 9

8. Move the data in memory to AX and move Data from AX to pointer address of BX

9. Add Data to BX register

10. Subtract one from CX, if CX>0 mean go to step 5

11. Perform no operation and move data & DI to CX

12. Subtract one from CX, if CX>0 mean Go to the step 3

13. Stop the program

DEPARTMENT OF ECE, ACT Page 63


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM: (By using 8086)

HEXA DECIMAL

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


1000 MOV CX,03H Move data to CX reg

1004 LOOP1 MOV DI,CX Move CX data to DI

Move 1100H to the


1006 MOV BX,1100H
BX reg

Move the content of


100A LOOP2 MOV AX,[BX] 1100H to memory of
AX

Compare the content


100C CMP AX,[BX+02H]
of AX with 1102H

100F JB REP Jump on borrow to rep

Exchange the data in


1011 XCHG AX,[BX+02H]
memory & AX

Move data from AX to


1014 MOV [BX],AX
pointer address of BX

Add data to BX
1016 REP ADD BX,02H
register

Subtract one from CX


101A LOOP LOOP2 ,if CX>0 mean go to
LOOP2

101C NOP No operation

Move data of DI to
101D MOV CX,DI
CX

101F LOOP LOOP1 Subtract one from CX


,if CX>0 mean go to

DEPARTMENT OF ECE, ACT Page 64


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

LOOP1

1021 HLT Stop the process

OBSERVATION:

BEFORE EXECUTION AFTER EXECUTION

ADDRESS DATA ADDRESS DATA

1100 1100

1102 1102

1104 1104

1106 1106

DEPARTMENT OF ECE, ACT Page 65


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM: (By using MASM)

ASSUME CS: CODE, DS: CODE, SS: CODE


CODE SEGMENT
ORG 1000H
MOV CX, 03H
LOOP1: MOV DI, CX
MOV BX, 1200H
LOOP2: MOV AX, [BX]
CMP AX, [BX+02H]
JB REP
XCHG AX, [BX+02H]
MOV [BX], AX
REP: ADD BX, 02H
LOOP LOOP2
NOP
MOV CX, DI
LOOP LOOP1
INT 03H
CODE ENDS
END

RESULT:

Thus an assembly language program to sort the given data in an array in ascending order was
written using 8086 microprocessor. The program was executed using MASM and the output
was verified.

VIVA QUESTIONS:

1. How minimum mode and maximum mode is selected?


2. Explain the function of MOVSB instruction.
3. Give examples for immediate addressing.
4. What is the basic difference between 8085 and 8086?
5. Why data bus is bi directional?

DEPARTMENT OF ECE, ACT Page 66


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

EX NO: 18
DESCENDING ORDER
DATE:
AIM:

To write an assembly language program for the sorting in Descending order using 8086
microprocessor & MASM.

APPARATUS REQUIRED:

S.NO COMPONENTS QUANTITY

1. 8086 kit 1

2. Power Card 1

3. Keyboard 1

4. PC with MASM 1
ALGORITHM:

1. Start the program

2. Move data to CX register

3. Move CX data to D1 register

4. Move 1100H to the BX register

5. Move the content of 1100H to memory of AX

6. Compare the content of AX with 1102H

7. Jump on no borrow mean go to step 9

8. Move the data in memory to AX and move Data from AX to pointer address of BX

9. Add Data to BX register

10. Subtract one from CX, if CX>0 mean go to step 5

11. Perform no operation and move data & DI to CX

11. Subtract one from CX, if CX>0 mean Go to the step 3

12. Stop the program

DEPARTMENT OF ECE, ACT Page 67


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM: (By using 8086)

HEXA DECIMAL

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


1000 MOV CX,03H Move data to CX reg

1004 LOOP1 MOV DI,CX Move CX data to DI

Move 1100H to the


1006 MOV BX,1100H
BX reg

Move the content of


100A LOOP2 MOV AX,[BX] 1100H to memory of
AX

Compare the content


100C CMP AX,[BX+02H]
of AX with 1102H

Jump on no borrow to
100F JNB REP
rep

Exchange the data in


1011 XCHG AX,[BX+02H]
memory & AX

Move data from AX to


1014 MOV [BX],AX
pointer address of BX

Add data to BX
1016 REP ADD BX,02H
register

Subtract one from CX


101A LOOP LOOP2 ,if CX>0 mean go to
LOOP2

101C NOP No operation

Move data of DI to
101D MOV CX,DI
CX

Subtract one from CX


101F LOOP LOOP1 ,if CX>0 mean go to
LOOP1

DEPARTMENT OF ECE, ACT Page 68


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

1021 HLT Stop the process

OBSERVATION:

BEFORE EXECUTION AFTER EXECUTION

ADDRESS DATA ADDRESS DATA

1100 1100

1102 1102

1104 1104

1106 1106

DEPARTMENT OF ECE, ACT Page 69


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM: (By using MASM)

ASSUME CS: CODE, DS: CODE, SS: CODE


CODE SEGMENT
ORG 1000H
MOV CX, 03H
LOOP1: MOV DI, CX
MOV BX, 1200H
LOOP2: MOV AX, [BX]
CMP AX, [BX+02H]
JNB REP
XCHG AX, [BX+02H]
MOV [BX], AX
REP: ADD BX, 02H
LOOP LOOP2
NOP
MOV CX, DI
LOOP LOOP1
INT 03H
CODE ENDS
END

RESULT:

Thus an assembly language program to sort the given data in an array in Descending order was
written using 8086 microprocessor. The program was executed using MASM and the output
was verified.

VIVA QUESTIONS:

1. What are different parts for 8086 architecture?


2. What is Non-Maskable interrupts?
3. What is meant by Maskable interrupts?
4. What is a SIM and RIM instruction?
5. Define DUP.

DEPARTMENT OF ECE, ACT Page 70


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

SEARCHING
USING 8086 & MASM

DEPARTMENT OF ECE, ACT Page 71


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

EX NO: 19
SMALLEST NUMBER
DATE:
AIM:

To write an assembly language program for the searching smallest number in an array
using 8086microprocessor & MASM.

APPARATUS REQUIRED:

S.NO COMPONENTS QUANTITY

1. 8086 kit 1

2. Power Card 1

3. Keyboard 1

4. PC with MASM 1
ALGORITHM:

1. Start the program

2. Move data to CX register

3. Move CX data to D1 register

4. Move 1100H to the BX register

5. Move the content of 1100H to memory of AX

6. Compare the content of AX with 1102H

7. Jump on borrow mean go to step 9

8. Move the data in memory to AX and move Data from AX to pointer address of BX

9. Add Data to BX register

10. Subtract one from CX, if CX>0 mean go to step 5

11. Perform no operation and move data & DI to CX

11. Subtract one from CX, if CX>0 mean Go to the step 3

12. Stop the program

DEPARTMENT OF ECE, ACT Page 72


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

13. Move the content of 1100H to BX reg

14. Move the content of BX is moved into specified location

15. Stop the program

PROGRAM: (By using 8086)

HEXA DECIMAL

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


1000 MOV CX,03H Move data to CX reg

1004 LOOP1 MOV DI,CX Move CX data to DI

Move 1100H to the


1006 MOV BX,1100H
BX reg

Move the content of


100A LOOP2 MOV AX,[BX] 1100H to memory of
AX

Compare the content


100C CMP AX,[BX+02H]
of AX with 1102H

100F JB REP Jump on borrow to rep

Exchange the data in


1011 XCHG AX,[BX+02H]
memory & AX

Move data from AX to


1014 MOV [BX],AX
pointer address of BX

Add data to BX
1016 REP ADD BX,02H
register

Subtract one from CX


101A LOOP LOOP2 ,if CX>0 mean go to
LOOP2

101C NOP No operation

DEPARTMENT OF ECE, ACT Page 73


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

Move data of DI to
101D MOV CX,DI
CX

Subtract one from CX


101F LOOP LOOP1 ,if CX>0 mean go to
LOOP1

Move the content of


1021 MOV BX,[1100H]
1100 to BX reg

Move the content of


1025 MOV [1200H],BX BX is moved into
specified location

1029 HLT Stop the process

OBSERVATION:

BEFORE EXECUTION AFTER EXECUTION

ADDRESS DATA ADDRESS DATA

1100 1200

1102

1104

1106

DEPARTMENT OF ECE, ACT Page 74


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM: (By using MASM)

ASSUME CS: CODE, DS: CODE, SS: CODE


CODE SEGMENT
ORG 1000H
MOV CX, 03H
LOOP1: MOV DI, CX
MOV BX, 1200H
LOOP2: MOV AX, [BX]
CMP AX, [BX+02H]
JB REP
XCHG AX, [BX+02H]
MOV [BX], AX
REP: ADD BX, 02H
LOOP LOOP2
NOP
MOV CX, DI
LOOP LOOP1
MOV BX, [1200H]
MOV [1300H], BX
INT 03H
CODE ENDS
END

RESULT:

Thus an assembly language program to searching smallest number in an array was written
using 8086 microprocessor. The program was executed using MASM and the output was
verified.

VIVA QUESTIONS:

1. What is the need of LOCK signal?


2. Compare closely coupled and loosely coupled configurations.
3. Differentiate external verses internal bus.
4. Define a multiprocessor system.
5. Give the features of Pentium processor.

DEPARTMENT OF ECE, ACT Page 75


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

EX NO: 20
LARGEST NUMBER
DATE:
AIM:

To write an assembly language program for the searching largest number in an array
using 8086 microprocessor & MASM.

APPARATUS REQUIRED:

S.NO COMPONENTS QUANTITY

1. 8086 kit 1

2. Power Card 1

3. Keyboard 1

4. PC with MASM 1
ALGORITHM:

1. Start the program

2. Move data to CX register

3. Move CX data to D1 register

4. Move 1100H to the BX register

5. Move the content of 1100H to memory of AX

6. Compare the content of AX with 1102H

7. Jump on no borrow mean go to step 9

8. Move the data in memory to AX and move Data from AX to pointer address of BX

9. Add Data to BX register

10. Subtract one from CX, if CX>0 mean go to step 5

11. Perform no operation and move data & DI to CX

11. Subtract one from CX, if CX>0 mean Go to the step 3

12. Stop the program

DEPARTMENT OF ECE, ACT Page 76


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

13. Move the content of 1100H to BX reg

14. Move the content of BX is moved into specified location

15. Stop the program

PROGRAM: (By using 8086)

HEXA DECIMAL

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


1000 MOV CX,03H Move data to CX reg

1004 LOOP1 MOV DI,CX Move CX data to DI

Move 1100H to the


1006 MOV BX,1100H
BX reg

Move the content of


100A LOOP2 MOV AX,[BX] 1100H to memory of
AX

Compare the content


100C CMP AX,[BX+02H]
of AX with 1102H

Jump on no borrow to
100F JNB REP
rep

Exchange the data in


1011 XCHG AX,[BX+02H]
memory & AX

Move data from AX to


1014 MOV [BX],AX
pointer address of BX

Add data to BX
1016 REP ADD BX,02H
register

Subtract one from CX


101A LOOP LOOP2 ,if CX>0 mean go to
LOOP2

101C NOP No operation

DEPARTMENT OF ECE, ACT Page 77


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

Move data of DI to
101D MOV CX,DI
CX

Subtract one from CX


101F LOOP LOOP1 ,if CX>0 mean go to
LOOP1

Move the content of


1021 MOV BX,[1100H]
1100 to BX reg

Move the content of


1025 MOV [1200H],BX BX is moved into
specified location

1029 HLT Stop the process

OBSERVATION:

BEFORE EXECUTION AFTER EXECUTION

ADDRESS DATA ADDRESS DATA

1100 1200

1102

1104

1106

DEPARTMENT OF ECE, ACT Page 78


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM: (By using MASM)

ASSUME CS: CODE, DS: CODE, SS: CODE


CODE SEGMENT
ORG 1000H
MOV CX, 03H
LOOP1: MOV DI, CX
MOV BX, 1200H
LOOP2: MOV AX, [BX]
CMP AX, [BX+02H]
JNB REP
XCHG AX, [BX+02H]
MOV [BX], AX
REP: ADD BX, 02H
LOOP LOOP2
NOP
MOV CX, DI
LOOP LOOP1
MOV BX, [1200H]
MOV [1300H], BX
INT 03H
CODE ENDS
END

RESULT:

Thus an assembly language program to searching largest number in an array was written using
8086 microprocessor. The program was executed using MASM and the output was verified.

VIVA QUESTIONS:

1. List out the problems in multiprocessor system.


2. What is meant by numeric processor?
3. List the function of HOLD and HLDA in 8086.
4. What is the significance of MX/MN pin in 8086?
5. Name the three bus allocation scheme used in loosely coupled multiprocessor system.

DEPARTMENT OF ECE, ACT Page 79


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PASSWORD CHECKING
USING MASM

DEPARTMENT OF ECE, ACT Page 80


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

EX NO: 21
PASSWORD CHECKING
DATE:
AIM:

In a supermarket, there is a computer for staff who is working in stock verification. So


the access to the specific computer application should be restricted to selected people. Now you
are advised to write an assembly language program to verify the predefined password before the
user gaining access to that application using MASM.

APPARATUS REQUIRED:

S.NO COMPONENTS QUANTITY

1. PC with MASM 1

ALGORITHM

1. Initialize memory pointer for pre-defined password and user defined data.
2. Prompt the message to the user to enter the password
3. Verify the user entered password with pre-defined password
4. If zero flag is set then go to step 6
5. Prompt message to user to enter the password again and go to step 2
6. Prompt the message to the user “Authorized person”
7. Stop the execution.

DEPARTMENT OF ECE, ACT Page 81


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM: (By using MASM)


ASSUME CS: CODE, DS:CODE
DATA SEGMENT
PASSWORD DB 'MASM1234'
LEN EQU ($-PASSWORD)
MSG1 DB 10, 13,'ENTER YOUR PASSWORD: $'
MSG2 DB 10, 13, 'WELCOME TO ELECTRONICS WORLD!!$'
MSG3 DB 10, 13, 'INCORRECT PASSWORD!$'
NEW DB 10, 13,'$'
INST DB 10 DUP(0)
DATA ENDS

CODE SEGMENT
START: ORG 1000H
MOV AX, DATA
MOV DS, AX
LEA DX, MSG1
MOV AH, 09H
INT 21H
MOV SI, 00
UP1: MOV AH, 08H
INT 21H
CMP AL, 0DH
JE DOWN
MOV [INST+SI], AL
MOV DL,'*'
MOV AH, 02H
INT 21H
INC SI
JMP UP1
DOWN: MOV BX, 00
MOV CX, LEN
CHECK: MOV AL, [INST+BX]
MOV DL, [PASSWORD+BX]
CMP AL, DL
JNE FAIL
INC BX
LOOP CHECK
LEA DX, MSG2
MOV AH, 09H
INT 21H
JMP FINISH
FAIL: LEA DX, MSG3
MOV AH, 09H
INT 21H
FINISH: INT 3
CODE ENDS
END START
END

DEPARTMENT OF ECE, ACT Page 82


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

RESULT:

Thus the assembly language program to the pre-defined password was tested and verified.

VIVA QUESTIONS:

1. What is the function of ALE?


2. Give examples for indirect addressing mode.
3. Mention the pointers present in this 8086?
4. List any four logical instructions of 8086.
5. Why address bus is unidirectional?

DEPARTMENT OF ECE, ACT Page 83


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

ANALOG TO DIGITAL CONVERTOR INTERFACING


USING 8086

DEPARTMENT OF ECE, ACT Page 84


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

EX NO: 22
ADC USING 8086
DATE:
AIM:

To write an assembly language program to interface ADC with 8086 Microprocessor.

APPARATUS REQUIRED:

S.NO COMPONENTS QUANTITY

1. 8086 kit 1

2. Power Card 1

3. Keyboard 1

4. ADC Kit 1

5. Interface card 1

6. Multimeter 1

ALGORITHM:

1. Start the program

2. Place jumper J2 in A position.

3. Place jumper J5 in A position.

4. Enter & execute the program.

5. Vary the analog input (using Trim pot) & view the corresponding digital value in the
LED display.

6. Stop the program.

DEPARTMENT OF ECE, ACT Page 85


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM: (By using 8086)

HEXA DECIMAL

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


Select channel 0 &
1000 MOV AL,10H
ALE low

Content of AL is moved
1003 OUT C8,AL
to ALE port address

Select channel 0 &


1005 MOV AL,18H
ALE high

Content of AL is moved
1008 OUT C8,AL
to ALE port address

100A MOV AL,01H SOC signal high

Content of AL is moved
100D OUT D0,AL
to SOC port address

100F MOV AL,00H Initialize the AL reg

1012 MOV AL,00H Initialize the AL reg

1015 MOV AL,00H Initialize the AL reg

1018 MOV AL,00H Initialize the AL reg

Content of AL is moved
101B OUT D0,AL
to SOC port address

101D HLT Stop the program

DEPARTMENT OF ECE, ACT Page 86


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

OBSERVATION:

Vref=

Analog input Practical Digital Theoretical digital output


voltage output
ADC=(Analog voltage * 2^8)/(Vref)

The data to be outputted to port address c8 for channel 0 an channel 8

CH NO & CH NO &
EOC ALE LOW ALE HIGH
Channel
SI.No ADDRESS
number (Data (Data
(Hexa)
(Hexa)) (Hexa))

1 CHO D8 10 18

2 CH1 D8 11 19

3 CH2 D8 12 1A

4 CH3 D8 13 1B

5 CH4 D8 14 1C

6 CH5 D8 15 1D

7 CH6 D8 16 1E

8 CH7 D8 17 1F

Thus the buffer 74LS244 which transfers the converted data outputs to data bus is
selected when

DEPARTMENT OF ECE, ACT Page 87


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

A7 A6 A5 A4 A3 A2 A1 A0
=C0H
1 1 0 0 0 X X X

The I/O address for the latch 74LS174 which latches the data bus to ADD A, ADD B, ADD
C & ALE 1 & ALE 2 is

A7 A6 A5 A4 A3 A2 A1 A0
=C8H
1 1 0 0 1 X X X

The flip flop 74LS74 which transfers the D0 line status to the SOC pin of the ADC 0809 is
selected when

A7 A6 A5 A4 A3 A2 A1 A0
=D0H
1 1 0 1 0 X X X

The EOC 1 is selected when

A7 A6 A5 A4 A3 A2 A1 A0
=D8H
1 1 0 0 1 X X X

The EOC 2 is selected when

A7 A6 A5 A4 A3 A2 A1 A0
=E0H
1 1 1 0 0 X X X

DEPARTMENT OF ECE, ACT Page 88


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

JUMPER DETAILS:

J2: (SOC jumper selection for ch0 – ch7)

J3: (SOC jumper selection for ch8 – ch15)

J1: (Combined End of the Conversion to CPU interrupts)

DEPARTMENT OF ECE, ACT Page 89


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

J5: (Provision to connect the on board trim pot to any of the below mentioned
channels)

J6: (Provision to connect the on board trim pot to any of the below mentioned
channels)

DEPARTMENT OF ECE, ACT Page 90


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

P2:

RESULT:

Thus the program for converting an input analog signal into digital using 8086 was executed
and verified.

VIVA QUESTIONS:

1. Define Port.
2. List the types of ADC’s.
3. Give example of ADC IC.
4. What is resolution?
5. List any two machine control instructions of 8086.

DEPARTMENT OF ECE, ACT Page 91


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

DIGITAL TO ANALOG CONVERTOR INTERFACING


USING 8086

DEPARTMENT OF ECE, ACT Page 92


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

EX NO: 23
SQUARE WAVEFORM GENERATION
DATE:
AIM:

To write an assembly language program to perform a square waveform generation at


DAC 2 output using 8086.

APPARATUS REQUIRED:

S.NO COMPONENTS QUANTITY

1. 8086 kit 1

2. Power Card 1

3. Keyboard 1

4. DAC Kit 1

5. Interface card 1

6. Probe 1

7. CRO 1

ALGORITHM:

1. Start the program

2. Initialize the AL reg.

3. Content of AL is moved to DAC2 port address

4. Call the delay routine (go to step9)

5. Load the high value to AL reg.

6. Content of AL is moved to DAC2 port address

7. Call the delay routine (go to step9)

8. Repeat the program (go to step2).

DEPARTMENT OF ECE, ACT Page 93


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

9. Load the Count value to CX reg.

10. Subtract one from CX, if CX>0 mean go to step 10

11. Return to main program.

PROGRAM: (By using 8086)

HEXA DECIMAL

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


1000 START MOV AL,00H Initialize the AL reg

Content of AL is moved
1003 OUT C8,AL
to DAC2 port address

1005 CALL DELAY Call the delay routine

Load the higher value


1008 MOV AL,FFH
to AL reg

Content of AL is moved
100B OUT C8,AL
to DAC2 port address

100D CALL DELAY Call the delay routine

Jump to starting of the


1010 JMP START
program

Load the count value to


1013 DELAY MOV CX,05FFH
CX reg

Subtract 1 from CX, if


1017 LOOP2 LOOP LOOP2
CX>0 mean go to loop2

1019 RET Return to main program

DEPARTMENT OF ECE, ACT Page 94


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

DAC1 is selected

A7 A6 A5 A4 A3 A2 A1 A0
=C0H
1 1 0 0 0 X X X

DAC2 is selected

A7 A6 A5 A4 A3 A2 A1 A0

1 1 0 0 1 X X X =C8H

DEPARTMENT OF ECE, ACT Page 95


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

MODEL GRAPH:

OBSERVATION:

Amplitude (V) Time (ms)

RESULT:

Thus the assembly language program to perform a square waveform generation at


DAC 2 output using 8086 was executed and verified.

VIVA QUESTIONS:

1. Give examples for conditional jump instructions of 8086.


2. List the types of DAC’s.
3. Give any example for DAC IC.
4. Define duty cycle.
5. What is the function of IN instruction?

DEPARTMENT OF ECE, ACT Page 96


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

EX NO: 24
SAW-TOOTH WAVEFORM GENERATION
DATE:
AIM:

To write an assembly language program to perform a saw-tooth waveform generation at


DAC 1 output using 8086.

APPARATUS REQUIRED:

S.NO COMPONENTS QUANTITY

1. 8086 kit 1

2. Power Card 1

3. Keyboard 1

4. DAC Kit 1

5. Interface card 1

6. Probe 1

7. CRO 1

ALGORITHM:

1. Start the program

2. Initialize the AL reg.

3. Content of AL is moved to DAC1 port address

4. Increment AL reg.

5. If AL# 0 mean got to step 3.

6. Jump to starting of the program.

DEPARTMENT OF ECE, ACT Page 97


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM: (By using 8086)

HEXA DECIMAL

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


1000 START MOV AL,00H Initialize the AL reg

Content of AL is moved
1003 LOOP1 OUT C0,AL
to DAC1 port address

1005 INC AL Increment the AL reg

If AL#0 mean go to
1007 JNZ LOOP1
loop1 label

Jump to starting of the


1009 JMP START
program

DAC1 is selected

A7 A6 A5 A4 A3 A2 A1 A0
=C0H
1 1 0 0 0 X X X

DAC2 is selected

A7 A6 A5 A4 A3 A2 A1 A0
=C8H

1 1 0 0 1 X X X

DEPARTMENT OF ECE, ACT Page 98


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

MODEL GRAPH:

OBSERVATION:

Amplitude (V) Time (ms)

DEPARTMENT OF ECE, ACT Page 99


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

RESULT:

Thus the assembly language program to perform a saw-tooth waveform generation at


DAC 1 output using 8086 was executed and verified.

VIVA QUESTIONS:

1. How the DMA operation performed with 8086?


2. How DMA is initiated?
3. What is DMA? Why do we need DMA?
4. Give the operation modes of 8259A.
5. Name the modes of DMA operation

DEPARTMENT OF ECE, ACT Page 100


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

EX NO: 25
TRIANGULAR WAVEFORM GENERATION
DATE:
AIM:

To write an assembly language program to perform a triangular waveform generation at


DAC 2 output using 8086.

APPARATUS REQUIRED:

S.NO COMPONENTS QUANTITY

1. 8086 kit 1

2. Power Card 1

3. Keyboard 1

4. DAC Kit 1

5. Interface card 1

6. Probe 1

7. CRO 1

ALGORITHM:

1. Start the program

2. Initialize the BL reg.

3. Content of BL is moved to AL reg

4. Content of AL reg is moved to DAC2 port address

5. Increment the BL reg.

6. If BL# 0 mean got to step 3.

7. Load the higher value to BL reg.

8. Content of BL is moved to AL reg

DEPARTMENT OF ECE, ACT Page 101


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

9. Content of AL reg is moved to DAC2 port address

10. Decrement the BL reg.

11. If BL# 0 mean got to step 8.

12. Jump to starting of the program.

PROGRAM: (By using 8086)

HEXA DECIMAL

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


1000 START MOV BL,00H Initialize the BL reg

Content of BL moved
1003 LOOP1 MOV AL,BL
to AL reg

Content of AL is moved
1005 OUT C8,AL
to DAC2 port address

Increment the Content


1007 INC BL
of BL reg

If BL#0 mean got to


1009 JNZ LOOP1
loop1

Load the higher value


100B MOV BL,FFH
to BL reg

Content of BL moved
100E LOOP2 MOV AL,BL
to AL reg

Content of AL is moved
1010 OUT C8,AL
to DAC2 port address

Decrement the content


1012 DEC BL
of BL reg

If BL#0 mean got to


1014 JNZ LOOP2
loop2

Jump to start of the


1016 JMP START
program

DEPARTMENT OF ECE, ACT Page 102


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

DAC1 is selected

A7 A6 A5 A4 A3 A2 A1 A0 =C0H

1 1 0 0 0 X X X

DAC2 is selected

A7 A6 A5 A4 A3 A2 A1 A0
=C8H
1 1 0 0 1 X X X

DEPARTMENT OF ECE, ACT Page 103


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

MODEL GRAPH:

OBSERVATION:

Amplitude (V) Time (ms)

RESULT:

Thus the assembly language program to perform a triangular waveform generation at


DAC 2 output using 8086 was executed and verified.

VIVA QUESTIONS:

1. Mention the applications of 8253.


2. Compare memory mapped I/O and I/O mapped I/O
3. Why is memory interfacing required?
4. What are the differences between LED display and LCD Display?
5. Write 16-bit delay program in 8086.

DEPARTMENT OF ECE, ACT Page 104


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

KEYBOARD AND DISPLAY INTERFACING


USING 8086

DEPARTMENT OF ECE, ACT Page 105


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

EX NO: 26
ROLLING DISPLAY
DATE:
AIM:

To write an assembly language program to interface 8279 with 8086 Microprocessor.

APPARATUS REQUIRED:

S.NO COMPONENTS QUANTITY

1. 8086 kit 1

2. Power Card 1

3. Keyboard 1

8279
4. 1
Interfacing Kit

Interfacing
5. 1
card

ALGORITHM:

1. Start the program.

2. Move the look-up table address into SI reg.

3. Move the count value to the CX reg.

4. Set the display mode setup.

5. Content of AL reg is moved into command reg port address.

6. Clear the display.

7. Content of AL reg is moved into command reg port address.

8. Set up the write display RAM.

9. Content of AL reg is moved into command reg port address.

10. Content of look-up table address is moved into AL reg.

DEPARTMENT OF ECE, ACT Page 106


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

11. Content of AL reg is moved into data reg port address.

12. Call the delay label (go to step16)

13. Increment SI reg.

14. Subtract one from CX, if CX>0 mean go to step9.

15. Jump to step2.

16. Move the data to DX reg.

17. Decrement DX reg.

18. If DX#0 mean go to step17.

19. Return to Main program.

PROGRAM: (By using 8086)

HEXA DECIMAL

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


Move the look-up
1000 START MOV SI,1200H table address into SI
reg

Move the count value


1004 MOV CX,000FH
to the CX reg

1008 MOV AL,10H Set the display mode


setup.
Content of AL reg is
100B OUT C2,AL moved into command
reg port address

100D MOV AL,CCH Clear the display

Content of AL reg is
1010 OUT C2,AL moved into command
reg port address

DEPARTMENT OF ECE, ACT Page 107


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

Set up the write


1012 MOV AL,90H
display RAM

Content of AL reg is
1015 OUT C2,AL moved into command
reg port address

Content of look-up
1017 NEXT MOV AL,[SI] table address is moved
into AL reg.

Content of AL reg is
1019 OUT C0,AL moved into data reg
port address

101B CALL DELAY Call the delay label

101E INC SI Increment SI reg

Subtract one from CX,


101F LOOP NEXT if CX>0 mean go to
step9

Jump to starting of
1021 JMP START
program.

HEXA DECIMAL

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


Move the data to DX
1500 DELAY MOV DX,A0FFH
reg

1504 LOOP1 DEC DX Decrement DX reg

If DX#0 mean go to
1505 JNZ LOOP1
loop1 label

Return to main
1507 RET
program

DEPARTMENT OF ECE, ACT Page 108


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

LOOK-UP TABLE:

1200

1204

1208

120C

I/O DECODING:

Control / status register is selected

A7 A6 A5 A4 A3 A2 A1 A0
=C2H
1 1 0 0 0 X 1 X

Data register is selected

A7 A6 A5 A4 A3 A2 A1 A0
=C0H
1 1 0 0 0 X 0 X

SEGMENT DEFINITION:

Segment definitions of the seven segment display are shown below .The table shows the
correspondence between the data bus and output port bits of 8279.In order to light up a segment the
corresponding bit of data written into the display RAM should be “0”

DEPARTMENT OF ECE, ACT Page 109


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

Data Bus D7 D6 D5 D4 D3 D2 D1 D0

8279
A3 A2 A1 A0 B3 B2 B1 B0
output

Segments d c b a Dp g f e

DISPLAY MODE SETUP:

The control word for keyboard and display mode is

0 0 0 D D K K K

DD-DISPLAY MODE:

00 - 8 8-bit character display-Left Entry

01 - 16 8-bit character display –Left Entry

10 - 8 8-bit Character display-Right Entry

11 - 16 8-bit character display –Right Entry

KKK- KEYBOARD MODE:

000 - Encoded scan Keyboard-2 key lockout

001 - Decoded scan Keyboard-2 Key lockout

010 - Encoded scan keyboard –N key roll-over

011 - Decoded scan keyboard –N key roll-over

100 - Encoded scan sensor matrix

101 - Decoded scan sensor matrix

110 - Strobed input, encoded display scan

111 - Strobed input Decoded display scan

DEPARTMENT OF ECE, ACT Page 110


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

CLEAR DISPLAY:

The command word format for clear display is

1 1 0 CD CD CD CF CA

CD CD CD –The lower two CD bits specify the blanking code to be sent to the segments to turn them
off while the 8279 is switching from one digit to next.

CD CD

0 X A0-3 B0-3 =00H


1 0 A0-3 B0-3 =20H
1 1 A0-3 B0-3 =FFH

CD – Enables clear display when CD=1. The rows of display RAM are cleared by the code set by
lower two CD bits.

If CD = 0 then content of RAM will be displayed.

CF =1, FIFO status is cleared, interrupt output line is reset .Sensor RAM pointer is set to row 0

CA- Clear All bit has the combined effect of CD and CF .It uses CD clearing code on display RAM and
clears FIFO status. It also resynchronizes the internal timing chain

WRITE DISPLAY RAM:

The write display RAM command word format is

1 0 0 AI A A A A

This command is written with A0=1, all subsequent writes with A0=0 will be the display RAM.

AI- Auto Increment Flag if AI=1 the row address selected will be incremented after each following
read or write to the display RAM.

AAAA- Selects one of the 16 rows of the Display RAM.

DEPARTMENT OF ECE, ACT Page 111


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

OBSERVATION:

Hexa
Word d c b a dp g f e
Equivalent

RESULT:

Thus the assembly language program to interface 8279 with 8086 Microprocessor
was executed and verified.

VIVA QUESTIONS:

1. What is 8279?
2. Mention the display modes of 8279.
3. Explain the function of OUT instruction.
4. How do you program 8279 for a particular application?
5. Define 2 key lock out.

DEPARTMENT OF ECE, ACT Page 112


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

STEPPER MOTOR CONTROL


USING 8086

DEPARTMENT OF ECE, ACT Page 113


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

EX NO: 27
STEPPER MOTOR
DATE:
AIM:

To write an assembly language program to run the stepper motor in both forward and
reverse direction with delay using 8086 microprocessor.

APPARATUS REQUIRED:

S.NO COMPONENTS QUANTITY

1. 8086 kit 1

2. Power Card 1

3. Keyboard 1

4. Interfacing kit 1

5. Stepper Motor 1

ALGORITHM:

1. Start the program.

2. Set the no of step in forward direction

3. Move the forward direction address DI register

4. Call the rotate label (go to step 15)

5. Decrement the BL register

6. If ZF=1 mean go to step 3

7. Call the delay label (go to step 24)

8. Set the no of step in reverse direction

9. Move the reverse direction address DI register

10. Call the rotate label (go to step 15)

11. Decrement the BL register

DEPARTMENT OF ECE, ACT Page 114


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

12. If ZF=1 mean go to step 15

13. Call the delay label (go to step 24)

14. Jump to start of program (go to step 2)

15. Set count value to CL register

16. Move Look up table value to AL register

17. Move the content AL to port address IC 74175

18. Move data (1010H) to DX register

19. Decrement the DX register

20. If ZF=1 mean go to step 19

21. Increment the DI register

22. Subtract one from Cx , if CX>0 mean go to step 16

23. Return from the subroutine

24. Move data (FFFFH) to DX register

25. Decrement the DX register

26. If ZF=1 mean go to step 25

27. Return from the subroutine

PROGRAM: (By using 8086)

HEXA DECIMAL

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


Set the no of step in
1000 START MOV BL,20H
forward direction

Move the forward


1003 FORWD MOV DI,FORLOOK direction address DI
register

DEPARTMENT OF ECE, ACT Page 115


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

1007 CALL ROTATE Call the rotate label

Decrement the BL
100A DEC BL
register

If ZF=1 mean go to
100C JNZ FORWD
forwd label

100E CALL DELAY Call the delay label

Set the no of step in


1011 MOV BL,20H
reverse direction

Move the reverse


1014 REVES MOV DI,REVLOOK direction address DI
register
1018 CALL ROTATE Call the rotate label

Decrement the BL
101B DEC BL
register

If ZF=1 mean go to
101D JNZ REVES
REVES label

101F CALL DELAY Call the delay label

Jump to start of
1022 JMP START
program

Set count value to CL


1025 ROTATE MOV CL,04H
register

Move Look up table


1028 REPT MOV AL,[DI]
value to AL register

Move the content AL


102A OUT C0,AL to port address IC
74175

Move data (1010H) to


102C MOV DX,1010H
DX register

Decrement the DX
1030 LOOP1 DEC DX
register

DEPARTMENT OF ECE, ACT Page 116


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

If ZF=1 mean go to
1031 JNZ LOOP1
loop1 label

Increment the DI
1033 INC DI
register

Subtract one from Cx


1034 LOOP REPT , if CX>0 mean go to
REPT label

Return from the


1036 RET
subroutine

Move data (FFFFH)


1037 DELAY MOV DX,0FFFFH
to DX register

Decrement the DX
103B LOOP2 DEC DX
register

If ZF=1 mean go to
103C JNZ LOOP2
loop2 label

Return from the


103E RET
subroutine

LOOK UP TABLE:

FORLOOK 103F 09 05 06 0A

REVLLO 1043 0A 06 05 09

DEPARTMENT OF ECE, ACT Page 117


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

OBSERVATION:

CLOCKWISE DIRECTION ANTI CLOCKWISE DIRECTION

STEP A1 A2 B1 B2 DATA STEP A1 A2 B1 B2 DATA

1 1 0 0 1 09H 1 1 0 1 0 0AH

2 0 1 0 1 05H 2 0 1 1 0 06H

3 0 1 1 0 06H 3 0 1 0 1 05H

4 1 0 1 0 0AH 4 1 0 0 1 09H

IC 74175 is selected with the address

A7 A6 A5 A4 A3 A2 A1 A0
=C0H
1 1 0 0 0 X X X

RESULT:

Thus the assembly language program to run the stepper motor in both forward and
reverse direction with delay using 8086 microprocessor was executed and verified

VIVA QUESTIONS:

1. Mention the applications of stepper motor.


2. Mention the use of stepper motor.
3. List the modes of Timer in 8051.
4. When is an external memory access generated in 8051?
5. What are the types of sensors used for interfacing?

DEPARTMENT OF ECE, ACT Page 118


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PARALLEL INTERFACING
USING 8086

DEPARTMENT OF ECE, ACT Page 119


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

EX NO: 28
PARALLEL COMMUNICATION
DATE:
AIM:

To write an ALP to interface 8255 with 8086 and to initialize port a as input port A and
port B as output port in mode 0. The input is to be set by SPDT switches and output is to be
displayed by LED.

APPARATUS REQUIRED:

S.NO COMPONENTS QUANTITY

1. 8086 kit 1

2. Power Card 1

3. Keyboard 1

8255
4. 1
Interfacing kit

ALGORITHM:

1. Interface 8086 with PPI (8255)


2. Initialize control word to accumulator for port A to be input port and port B as output port in mode 0
3. Control word from accumulator is moved to control register
4. Set the input by using SPDT switches
5. Verify the output by LED
6. Stop the program

DEPARTMENT OF ECE, ACT Page 120


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM: (By using 8086)

HEXA DECIMAL

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


Memory location
1000 MOV SI, 1500 address is moved to
SI register

Initialize control word


to accumulator for port
1004 MOV AL, 90H A to be input port and
port B as output port in
mode 0
Control word from
1007 OUT C6, AL accumulator is moved
to control register
1009 IN AL, C0H Set the input by using
SPDT switches
100B MOV [SI], AL Verify the output by
LED
100D HLT Stop the program
OBSERVATION:

BEFORE EXECUTION AFTER EXECUTION

LED INPUT ADDRESS DATA

1500

RESULT:

Thus the assembly language program for interfacing 8086 with 8255 is performed and
output is verified.

VIVA QUESTIONS:

1. What is 8255?
2. List the ports of 8255.
3. Specify the operating modes of 8255.
4. Give the control word format of BSR mode.
5. Write the control word format of I/O mode.

DEPARTMENT OF ECE, ACT Page 121


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

TRAFFIC LIGHT CONTROLLER INTERFACING


USING 8086

DEPARTMENT OF ECE, ACT Page 122


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

EX NO: 29
TRAFFIC LIGHT CONTROL
DATE:

AIM:

To write an assembly language to design a traffic light system using 8086


microprocessor.

APPARATUS REQUIRED:

S.NO COMPONENTS QUANTITY

1. 8086 kit 1

2. Power Card 1

3. Keyboard 1

Traffic Light
4. 1
Control Kit

ALGORITHM:

1. Initialize DI register and counter.


2. Initialize port the port address
3. Move data to the port
4. Introduce delay
5. Repeat the steps for other conditions
6. Stop the execution

DEPARTMENT OF ECE, ACT Page 123


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM: (By using 8086)

1000 MOV AL, 80


1002 MOV DX, 8006
1005 OUT DX, AX
START: 1006 MOV AL, 61
1008 MOV DX, 8000
100B OUT DX, AL
100C MOV AL, 68
100E MOV DX, 8002
1011 OUT DX, AL
1012 MOV AL, 86
1014 MOV DX, 8004
1017 OUT DX, AL
1018 MOV AL, 60
101A MOV DX, 8000
101D OUT DX, AL
101E MOV AL, 48
1020 MOV DX, 8002
1023 OUT DX, AL
1024 MOV AL, 64
1026 MOV DX, 8000
1029 OUT DX, AL
102A MOV AL, 58
102C MOV DX, 8002
102F OUT DX, AL
1030 CALL 025A
1033 MOV AL, 60
1035 MOV DX, 8000
1038 OUT DX, AL
1039 MOV AL, 48
103B MOV DX, 8002
103E OUT DX, AL
103F MOV AL, 62
1041 MOV DX, 8000
1044 OUT DX, AL
1045 CALL 0253
1048 MOV AL, 60
104A MOV DX, 8000
104D OUT DX, AL
104E MOV AL, 61
1050 MOV DX, 8000
1053 OUT DX, AL
1054 MOV AL, 68
1056 MOV DX, 8002
1059 OUT DX, AL

DEPARTMENT OF ECE, ACT Page 124


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

105A CALL 0253


105D MOV AL, 41
105F M OV DX, 8000
1062 OU T DX, AL
1063 MO V AL, 06
1065 MO V DX, 8004
1068 OUT DX, AL
1069 MOV AL, 49
106B MOV DX, 8000
106E OUT DX, AL
106F MOV AL, 26
1071 MOV DX, 8004
1074 OUT DX, AL
1075 CALL 025A
1078 MOV AL, 41
107A MOV DX, 8000
107D OUT DX, AL
107E MOV AL, 06
1080 MOV DX, 8004
1083 OUT DX, AL
1084 MOV AL, 51
1086 MOV DX, 8000
1089 OUT DX, AL
108A MOV AL, 46
108C MOV DX, 8004
108F OUT DX, AL
1090 CALL 0253
1093 MOV AL, 41
1095 MOV DX, 8000
1098 OUT DX, AL
1099 MOV AL, 06
109B MOV DX, 8004
109E OUT DX, AL
109F MOV AL, 61
10A1 MOV DX, 8000
10A4 OUT DX, AL
10A5 MOV AL, 86
10A7 MOV DX, 8004
10AA OUT DX, AL
10AB CALL 0253
10AE MOV AL, 60
10B0 MOV DX, 8002
10B3 OUT DX, AL
10B4 MOV AL, 82
10B6 MOV DX, 8004
10B9 OUT DX, AL

DEPARTMENT OF ECE, ACT Page 125


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

10BA MOV AL, 62


10BC MOV DX, 8002
10BF OUT DX, AL

RESULT:

Thus the traffic light system is designed and tested successfully using 8086 assembly
language programming.

VIVA QUESTIONS:

1. How do you configure 8086 in min mode and max mode?


2. What is maximum mode?
3. Compare Macro and procedure.
4. Explain the function of DAA.
5. Name any two I/O instructions.

DEPARTMENT OF ECE, ACT Page 126


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

8-BIT ARITHMETIC OPERATION


USING 8051

DEPARTMENT OF ECE, ACT Page 127


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

EX NO: 30
ADDITION OF TWO 8-BIT DATA
DATE:
AIM:

To write an assembly language program to perform addition of two 8-bit data using
8051

APPARATUS REQUIRED:

S.NO COMPONENTS QUANTITY

1. 8051 kit 1

2. Power Card 1

3. Keyboard 1

ALGORITHM:

1. Start the program


2. Initialize the external memory address in DPTR
3. Initialize R0 register for the carry.
4. Get the augend and store in register A
5. Get the addend and store in register B
6. Perform addition
7. If the carry flag is not set then go to step 9
8. Increment R0 register
9. Store the sum and carry in memory.
10. Stop the execution

DEPARTMENT OF ECE, ACT Page 128


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM:

HEXA DECIMAL

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


4100 CLR C Clear the carry flag
Load the result address
4101 MOV DPTR,#4200H to DPTR

4104 MOV R0, #00H Clear the R0 register

Move data1 to A
4106 MOV A,#data1
register

4108 ADD A,#data2 Add data1 & data2

If CY=0 mean go to
410A JNC LOOP1
Loop1 label

410C INC R0 Increment R0 register

Store addition result to


410D LOOP1 MOVX @DPTR,A
4200H

Move the content of


410E MOV A, R0
R0 to A register

Increment the Data


4110 INC DPTR
pointer

Store carry result to


4111 MOVX @DPTR,A
4201H

4112 LOOP2 SJMP LOOP2 Short jump

DEPARTMENT OF ECE, ACT Page 129


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

OBSERVATION:

BEFORE EXECUTION AFTER EXECUTION

ADDRESS DATA ADDRESS DATA

4105 4200

4107 4201

RESULT:

Thus the assembly language program for 8-bit addition using 8051 is performed and the output is
verified.

VIVA QUESTIONS:

1. List some of the 8051 microcontroller manufacturers.


2. What is difference between microprocessor and microcontroller?
3. List out some of the features of the 8051
4. Mention the applications of 8051.
5. What is the size of internal memory?

DEPARTMENT OF ECE, ACT Page 130


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

EX NO: 31
SUBTRACTION OF TWO 8-BIT DATA
DATE:
AIM:

To write an assembly language program to perform subtraction of two 8-bit data using
8051

APPARATUS REQUIRED:

S.NO COMPONENTS QUANTITY

1. 8051 kit 1

2. Power Card 1

3. Keyboard 1

ALGORITHM:

1. Start the program


2. Initialize the external memory address in DPTR
3. Initialize R0 register for the carry.
4. Get the minuend and store in register A
5. Get the subtrahend and store in register B
6. Perform subtraction
7. If the carry flag is not set then go to step 9
8. Increment R0 register
9. Store the subtraction and carry in memory.
10. Stop the execution

DEPARTMENT OF ECE, ACT Page 131


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM:

HEXA DECIMAL

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


4100 CLR C Clear the carry flag
Load the result address
4101 MOV DPTR,#4200H to DPTR

4104 MOV R0, #00H Clear the R0 register

Move data1 to A
4106 MOV A,#data1
register

Subtract data2 from


4108 SUBB A,#data2
data1

If CY=0 mean go to
410A JNC LOOP1
Loop1 label

410C INC R0 Increment R0 register

Store subtraction result


410D LOOP1 MOVX @DPTR,A
to 4200H

Move the content of


410E MOV A, R0
R0 to A register

Increment the Data


4110 INC DPTR
pointer

Store carry result to


4111 MOVX @DPTR,A
4201H

4112 LOOP2 SJMP LOOP2 Short jump

DEPARTMENT OF ECE, ACT Page 132


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

OBSERVATION:

BEFORE EXECUTION AFTER EXECUTION

ADDRESS DATA ADDRESS DATA

4105 4200

4107 4201

RESULT:

Thus the assembly language program for 8-bit subtraction using 8051 is performed and
the output is verified.

VIVA QUESTIONS:

1. What is the clock frequency of 8051?


2. Define SFR.
3. List any two arithmetic instructions of 8051.
4. Mention the various types of addressing modes of 8051.
5. What are the flags available in 8051?

DEPARTMENT OF ECE, ACT Page 133


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

EX NO: 32
MULTIPLICATION OF TWO 8-BIT DATA
DATE:
AIM:

To write an assembly language program to perform multiplication of two 8-bit data


using 8051

APPARATUS REQUIRED:

S.NO COMPONENTS QUANTITY

1. 8051 kit 1

2. Power Card 1

3. Keyboard 1

ALGORITHM:

1. Start the program

2. Clear the carry flag

3. Load the result address to DPTR

4. Move data1 to A reg

5. Multiply data1 & data2

6. Store content of A reg (LSB) result to 4200H

7. Increment data pointer

8. Move content of B reg (MSB) to A reg

9. Store content of A reg (MSB) to 4201H

10. Stop the program.

DEPARTMENT OF ECE, ACT Page 134


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM:

HEXA DECIMAL

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


Clear the carry flag
4100 CLR C

Load the result address


4101 MOV DPTR,#4200H to DPTR

4104 MOV A,#data1 Move data1 to A reg

4106 MOV B,#data2 Move data2 to B reg

Multiply content of A
4109 MUL AB
& B reg

Store result of LSB to


410A MOVX @DPTR,A
4200H

410B INC DPTR Increment data pointer

Move MSB of
410C MOV A,B multiply (B reg) result
to A reg

Store MSB result to


410E MOVX @DPTR,A
4201H

410F LOOP1 SJMP LOOP1 Short jump

OBSERVATION:

BEFORE EXECUTION AFTER EXECUTION

ADDRESS DATA ADDRESS DATA

4105 4200

4108 4201

DEPARTMENT OF ECE, ACT Page 135


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

RESULT:

Thus the assembly language program for 8-bit multiplication using 8051 is performed and the
output is verified.

VIVA QUESTIONS:

1. What are the ports of 8051?


2. Define PSW.
3. List the registers of 8051.
4. Mention any four logical instructions of 8051.
5. What is the function of DPTR?

DEPARTMENT OF ECE, ACT Page 136


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

EX NO: 33
DIVISION OF TWO 8-BIT DATA
DATE:
AIM:

To write an assembly language program to perform division of two 8-bit data using 8051

APPARATUS REQUIRED:

S.NO COMPONENTS QUANTITY

1. 8051 kit 1

2. Power Card 1

3. Keyboard 1

ALGORITHM:

1. Start the program

2. Clear the carry flag

3. Load the result address to DPTR

4. Move data1 to A reg

5. Divide data1 & data2

6. Store content of A reg (quotient) result to 4200H

7. Increment data pointer

8. Move content of B reg (reminder) to A reg

9. Store content of A reg (reminder) to 4201H

10. Stop the program.

DEPARTMENT OF ECE, ACT Page 137


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM:

HEXA DECIMAL

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


Clear the carry flag
4100 CLR C

Load the result address


4101 MOV DPTR,#4200H to DPTR

4104 MOV A,#data1 Move data1 to A reg

4106 MOV B,#data2 Move data2 to B reg

Divide content of A &


4109 DIV AB
B reg

Store result of quotient


410A MOVX @DPTR,A
to 4200H

410B INC DPTR Increment data pointer

Move reminder (B
410C MOV A,B
reg) result to A reg

Store reminder result


410E MOVX @DPTR,A
to 4201H

410F LOOP1 SJMP LOOP1 Short jump

OBSERVATION:

BEFORE EXECUTION AFTER EXECUTION

ADDRESS DATA ADDRESS DATA

4105 4200

4108 4201

DEPARTMENT OF ECE, ACT Page 138


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

RESULT:

Thus the assembly language program for 8-bit division using 8051 is performed and the output is
verified.

VIVA QUESTIONS:

1. List the alternate functions of port 3.


2. What is the use of PCON register?
3. How many timers are present in 8051?
4. Mention the interrupt sources in 8051.
5. What is the use of IE register?

DEPARTMENT OF ECE, ACT Page 139


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

8-BIT LOGICAL OPERATION


USING 8051

DEPARTMENT OF ECE, ACT Page 140


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

EX NO: 34
LOGICAL AND OF TWO 8-BIT DATA
DATE:
AIM:

To write an assembly language program to perform AND operation using 8051

APPARATUS REQUIRED:

S.NO COMPONENTS QUANTITY

1. 8051 kit 1

2. Power Card 1

3. Keyboard 1

ALGORITHM:

1. Start the program.

2. Get 1st operand in Accumulator.

3. Get 2nd operand and AND it with accumulator content.

4. Store the result in memory.

5. Stop the program.

DEPARTMENT OF ECE, ACT Page 141


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM:

HEXA DECIMAL

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


4100 MOV A,#DATA1 Move data1 to acc

AND with data1 &


4102 ANL A,#DATA2 data2

Move result address to


4104 MOV DPTR,#4200H
data pointer

Store AND result to


4107 MOVX @DPTR,A
4200H

4108 LOOP1 SJMP LOOP1 Short jump

OBSERVATION:

BEFORE EXECUTION AFTER EXECUTION

ADDRESS DATA ADDRESS DATA

4101

4103 4200

RESULT:

Thus an assembly language program to perform AND operation using 8051is written and
the output is verified successfully.

VIVA QUESTIONS:

1. What is masking?
2. How to set a lower nibble?
3. List any four logical instructions of 8051.
4. Mention the timer modes of 8051.
5. What is the memory size of 8051?

DEPARTMENT OF ECE, ACT Page 142


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

EX NO: 35
LOGICAL OR OF TWO 8-BIT DATA
DATE:
AIM:

To write an assembly language program to perform OR operation using 8051

APPARATUS REQUIRED:

S.NO COMPONENTS QUANTITY

1. 8051 kit 1

2. Power Card 1

3. Keyboard 1

ALGORITHM:

1. Start the program.

2. Get 1st operand in Accumulator.

3. Get 2nd operand and OR it with accumulator content.

4. Store the result in memory.

5. Stop the program.

DEPARTMENT OF ECE, ACT Page 143


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM:

HEXA DECIMAL

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


4100 MOV A,#DATA1 Move data1 to acc

4102 ORL A,#DATA2 OR with data1 & data2

Move result address to


4104 MOV DPTR,#4200H
data pointer

Store OR result to
4107 MOVX @DPTR,A
4200H

4108 LOOP1 SJMP LOOP1 Short jump

OBSERVATION:

BEFORE EXECUTION AFTER EXECUTION

ADDRESS DATA ADDRESS DATA

4101

4103 4200

RESULT:

Thus an assembly language program to perform OR operation using 8051is written and
the output is verified successfully.

VIVA QUESTIONS:

1. When is an external memory access generated in 8051?


2. What are the types of ADC?
3. What are the types of sensors used for interfacing?
4. Give the priority level of the interrupt sources in 8051.
5. Give examples of sensors and state its uses.

DEPARTMENT OF ECE, ACT Page 144


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

EX NO: 36
LOGICAL XOR OF TWO 8-BIT DATA
DATE:
AIM:

To write an assembly language program to perform EX-OR operation using 8051

APPARATUS REQUIRED:

S.NO COMPONENTS QUANTITY

1. 8051 kit 1

2. Power Card 1

3. Keyboard 1

ALGORITHM:

1. Start the program.

2. Get 1st operand in Accumulator.

3. Get 2nd operand and EX-OR it with accumulator content.

4. Store the result in memory.

5. Stop the program.

DEPARTMENT OF ECE, ACT Page 145


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM:

HEXA DECIMAL

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


4100 MOV A,#DATA1 Move data1 to acc

EX-OR with data1 &


4102 XRL A,#DATA2 data2

Move result address to


4104 MOV DPTR,#4200H
data pointer

Store EX-OR result to


4107 MOVX @DPTR,A
4200H

4108 LOOP1 SJMP LOOP1 Short jump

OBSERVATION:

BEFORE EXECUTION AFTER EXECUTION

ADDRESS DATA ADDRESS DATA

4101

4103 4200

RESULT:

Thus an assembly language program to perform XOR operation using 8051is written and
the output is verified successfully.

VIVA QUESTIONS:

1. Compare polling and interrupt.


2. Define baud rate of 8051.
3. What is the function of SM2 bit present in SCON register in8051?
4. How is A/D converter interfaced with 8051?
5. Give steps to program 8051for serial data transfer.

DEPARTMENT OF ECE, ACT Page 146


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

EX NO: 37
2’S COMPLEMENT OF TWO 8-BIT DATA
DATE:
AIM:

To write an assembly language program to perform 2’s complement operation using


8051

APPARATUS REQUIRED:

S.NO COMPONENTS QUANTITY

1. 8051 kit 1

2. Power Card 1

3. Keyboard 1

ALGORITHM:

1. Start the program.

2. Get data in Accumulator.

3. Take 1’s complement of data.

4. Move result address to Data Pointer.

5. Store 1’s Complement result to 4200H.

6. Increment the content of A & DPTR reg.

7. Store 2’s Complement result to 4201H.

8. Stop the program.

DEPARTMENT OF ECE, ACT Page 147


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM:

HEXA DECIMAL

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


4100 MOV A,#DATA Move data to acc

4102 CPL A Complement the data

Move result address


4103 MOV DPTR,#4200H
to data pointer

Store 1’s complement


4106
MOVX @DPTR,A result to 4200H

Increment the content


4107 INC A
of A reg

Increment the content


4108 INC DPTR
of DPTR reg

Store 2’s complement


4109 MOVX @DPTR,A
result to 4201H

410A LOOP1 SJMP LOOP1 Short jump

OBSERVATION:

BEFORE EXECUTION AFTER EXECUTION

ADDRESS DATA ADDRESS DATA

4101 4200

4201

DEPARTMENT OF ECE, ACT Page 148


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

RESULT:

Thus an assembly language program to perform 2’s complement operation using 8051is
written and the output is verified successfully.

VIVA QUESTIONS:

1. What is key denouncing?


2. What are the types of interrupt in 8051?
3. Differentiate between timer and counter.
4. Define interrupt.
5. State how baud rate is calculated for serial data transfer in mode 1

DEPARTMENT OF ECE, ACT Page 149


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

SQUARE OPERATION
USING 8051

DEPARTMENT OF ECE, ACT Page 150


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

EX NO: 38
SQUARE OF AN 8-BIT DATA
DATE:
AIM:

To write an assembly language program to perform square of an 8-bit data using 8051

APPARATUS REQUIRED:

S.NO COMPONENTS QUANTITY

1. 8051 kit 1

2. Power Card 1

3. Keyboard 1

ALGORITHM:

1. Load accumulator A with 8 bit data.


2. Move the 8 bit data to B register.
3. Multiply A and B to obtain square of a number.
4. Move the result to B register.
5. Move to the memory locations.
6. Stop the program

DEPARTMENT OF ECE, ACT Page 151


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM:

HEXA DECIMAL

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


Clear the carry flag
4100 CLR C

Load the result address


4101 MOV DPTR,#4200H to DPTR

4104 MOV A,#data1 Move data1 to A reg

4106 MOV B,A Move data1 to B reg

Multiply content of A
4108 MUL AB
& B reg

Store result of LSB to


4109 MOVX @DPTR,A
4200H

410A INC DPTR Increment data pointer

Move MSB of
410B MOV A,B multiply (B reg) result
to A reg

Store MSB result to


410D MOVX @DPTR,A
4201H

410E LOOP1 SJMP LOOP1 Short jump

OBSERVATION:

BEFORE EXECUTION AFTER EXECUTION

ADDRESS DATA ADDRESS DATA

4105 4200

DEPARTMENT OF ECE, ACT Page 152


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

RESULT:

Thus the assembly language program for square of an 8-bit 8051 is performed and the output is
verified.

VIVA QUESTIONS:

1. Define baudrate.
2. List any two data transfer instructions of 8051.
3. What is immediate addressing mode?
4. State the function of RS1 and RS0 bits in the flag register of 8051.
5. Draw the pin diagram of 8051.

DEPARTMENT OF ECE, ACT Page 153


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

CUBE OPERATION
USING 8051

DEPARTMENT OF ECE, ACT Page 154


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

EX NO: 39
CUBE OF AN 8-BIT NUMBER
DATE:
AIM:

To write an assembly language program to perform cube of an 8-bit data using 8051

APPARATUS REQUIRED:

S.NO COMPONENTS QUANTITY

1. 8051 kit 1

2. Power Card 1

3. Keyboard 1

ALGORITHM:

1. Load accumulator A with 8 bit data.


2. Move the 8 bit data to B register.
3. Multiply A and B to obtain cube of a number.
4. Move to the memory locations.
5. Stop the program

DEPARTMENT OF ECE, ACT Page 155


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM:

HEXA DECIMAL

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


Clear the carry flag
4100 CLR C

Load the result address


4101 MOV DPTR,#4200H to DPTR

4104 MOV A,#data1 Move data1 to A reg

4106 MOV R0,A Move data1 to R0 reg

4107 MOV B,A Move data1 to B reg

Multiply content of A
4109 MUL AB
& B reg

Load B reg value into


410A PUSH B
stack

Move A reg value to B


410C MOV B,A
reg

Move R0 reg value to


410E MOV A, R0
A reg

Multiply content of A
410F MUL AB
& B reg

Store result of A reg


4110 MOVX @DPTR,A
to 4200H

Move B reg value to A


4111 MOV A,B
reg

Move A reg value to


4113 MOV R1,A
R1 reg

Load Stack value into


4114 POP B
B reg

DEPARTMENT OF ECE, ACT Page 156


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

Move R0 reg value to


4116 MOV A, R0
A reg

Multiply content of A
4117 MUL AB
& B reg

Add the value of A reg


4118 ADD A, R1
& R1 reg

4119 INC DPTR Increment data pointer

Store result of A reg


411A MOVX @DPTR,A
to 4201H

Move B reg value to A


411B MOV A, B
reg

Add the value of A reg


411D ADDC A, #00H
& 00H data

411F INC DPTR Increment data pointer

Store result of A reg


4120 MOVX @DPTR,A
to 4202H

4121 LOOP1 SJMP LOOP1 Short jump

OBSERVATION:

BEFORE EXECUTION AFTER EXECUTION

ADDRESS DATA ADDRESS DATA

4105 4200

4201

4202

DEPARTMENT OF ECE, ACT Page 157


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

RESULT:

Thus the assembly language program for cube of an 8-bit 8051 is performed and the output is
verified.

VIVA QUESTIONS:

1. Draw the diagram of TCON in 8051.


2. Draw the diagram of TMOD in 8051.
3. Draw the diagram of SCON in 8051.
4. Write an 8051 ALP to toggle P1 a total of 200 times. Use RAM location 32H to hold
your counter.
5. Give the priority level of the interrupt sources in 8051.

DEPARTMENT OF ECE, ACT Page 158


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

CODE CONVERSION
USING 8051

DEPARTMENT OF ECE, ACT Page 159


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

EX NO: 40
UNPACKED BCD TO ASCII
DATE:
AIM:

To write an assembly language program to convert unpacked BCD to ASCII of an 8-bit


number using 8051 microcontroller.

APPARATUS REQUIRED:

S.NO COMPONENTS QUANTITY

1. 8051 kit 1

2. Power Card 1

3. Keyboard 1

ALGORITHM:

1. Load a 8 bit data into accumulator.

2. Move contents of A to R1 and Clear A register.

3. Add contents of A AND R1.

4. Increment DPTR register.

5. Add A and R1 contents.

6. Jump to loop if carry flag is set.

7. Add A contents and 07.

8. Increment DPTR register.

9. Stop the Program.

DEPARTMENT OF ECE, ACT Page 160


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM:

HEXA DECIMAL

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


Clear the carry flag
4100 CLR C

Load the result address


4101 MOV DPTR,#4200H to DPTR

4104 MOV A,#data1 Move data1 to A reg

4106 MOV B,A Move data1 to B reg

Logical AND with


4108 ANL A, #0FH
data1 & OFH

410A ADD A, #30H Add data 30H to A reg

Store result of A reg


410C MOVX @DPTR,A
to 4200H

Move B reg value to A


410D MOV A,B
reg

Logical AND with


410F ANL A, #F0H
data1 & F0H

Exchanges the low-


order and high-order
4111 SWAP A
nibbles within the
accumulator

4112 ADD A, #30H Add data 30H to A reg

4114 INC DPTR Increment data pointer

Store result of A reg


4115 MOVX @DPTR,A
to 4201H

4116 LOOP1 SJMP LOOP1 Short jump

DEPARTMENT OF ECE, ACT Page 161


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

OBSERVATION:

BEFORE EXECUTION AFTER EXECUTION

ADDRESS DATA ADDRESS DATA

4105 4200

4201

RESULT:

Thus the assembly language program for convert unpacked BCD to ASCII using 8051 is performed
and the output is verified.

VIVA QUESTIONS:

1. Define DPTR.
2. If a12Mhz crystal is connected with8051, how much is the time taken for the count in timer
0 to get incremented by one?
3. What is the use of TCON register?
4. What is the use of TMOD register?
5. Mention the serial communication modes of 8051.

DEPARTMENT OF ECE, ACT Page 162


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

ADDITIONAL EXPERIMENTS
BEYOND THE SYLLABUS

DEPARTMENT OF ECE, ACT Page 163


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

EX NO: 41
PALINDROME CHECKING USING TASM
DATE:

AIM:
To write an assembly language program get the string from user and check the string is
palindrome or not using TASM.

ALGORITHM:

1. Start the program


2. Prompt the message to the user to enter the string
3. Initialize the counter as zero as zero, get the string as the character one by one until user press the
enter key by incrementing counter
4. Initialize the counter as zero, get the string and reverse the given string
5. Compare the string and the reversed string
6. If zero flag = 0, prompt the given string is not palindrome else prompt the given string is palindrome
7. Stop the program

DEPARTMENT OF ECE, ACT Page 164


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

PROGRAM:

DISP MACRO
MSG LEA DX,
MSG MOV AH,
9H
INT
21H
ENDM
.MODEL SMALL
.STACK 100
.DATA
CR EQU
0DH LF
EQU 0AH
STRING DB 40 DUP
(?) RSTRING DB 40
DUP(?)
MSG DB CR, LF,’ ENTER THE STRING:$’
MSGR DB CR, LF, ‘REVERSE OF THE STRING:$’
MSGP DB CR, LF, ‘THE GIVEN STRING IS PALINDROME$’
MSGNP DB CR, LF, ‘THE GIVEN STRING IS NOT
PALINDROME$’ AGAIN DB CR, LF, ‘PRESS 1 TO TRY
AGAIN$’
THANKS DB 0AH, 10, 13, ‘THANKS FOR USING THIS PROGRAM$’, 13, 10,’$’
.CODE MAIN PROC
START: MOV AX, @DATA
MOV DS, AX
MOV ES, AX
DISP.MSG
LEA SI, STRING
CALL GETSTRING
NEXT: MOV AL,’$’
MOV [SI], AL
MOV BX,CX
LEA DI, RSTRING
CALL REVERSESTRING
MOV AL, ‘$’
MOV [DI], AL
DISP MSGR
DISP RSTRING
MOV CX, BX
LEA DI, STRING
LEA SI, STRING
REP CMPSB
JNE NOTPALINDROME

DEPARTMENT OF ECE, ACT Page 165


EC8681 - MICROPROCESSORS & MICROCONTROLLERS LABORATORY III YEAR
AGNI COLLEGE OF TECHNOLOGY, CHENNAI

DISP MSGP
JMP EXIT
NOTPALINDROME:DISP
MSGNP
EXIT: DISP AGAIN
MOV AH,
01H INT
21H
CMP
AL,31H JE
START
DISP
THANKS
MOV AH,
4CH INT
21H MAIN
ENDP
GETSTRING
PROC READCHAR:MOV
AH,01H
INT 21H
CMP
AL,CR JE
NEXT
MOV [SI],
AL INC SI
INC CX
JMP READCHAR
RET
GETSTRING ENDP
REVERSESTRING
PROC
REVERSE:DEC SI 3128 ACT
MOV DL,
[SI] MOV
[DI], DL
INC DI
LOOP REVERSE
RET
REVERSESTRING
ENDP END

RESULT:
Thus an ALP to get the string from user and checked the given string is palindrome or not
using TASM.

DEPARTMENT OF ECE, ACT Page 166

Potrebbero piacerti anche