MPMC Lab Manual Final Signed 210418104010
MPMC Lab Manual Final Signed 210418104010
MICROCONTROLLERS LABORATORY
1
Register No: 2 1 0 4 1 8 1 0 4 0 1 0
BONAFIDE CERTIFICATE
2
EC8681 MICROPROCESSORS AND MICROCONTROLLERS
LABORATORY
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
LIST OF EXPERIMENTS:
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
OUTCOMES:
At the end of the course, the student should be able to:
• Write ALP Programs 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
3
CONTENT
Signature
Date of the Date of
Ex. No. Title of the
Experiment Completion
Faculty
24.10.2020
10 24.10.2020 Matrix addition
24.10.2020
11 24.10.2020 Code conversion
4
Ex. No. 1
16-BIT ARITHMETIC OPERATIONS
Date:
19.9.2020
a) Aim: To write an 8086 assembly language program to perform 16-bit addition using MASM
assembler.
Algorithm
16-Bit Addition
Step 1: Get two 16-bit data from the input memory locations to AX and BX registers.
Step 2: Clear CX register to store the carry condition.
Step 3: Add the contents of BX to AX register and store the result in AX.
Step 4: Check carry flag, If CF = 0 then go to step 6.
Step 5: Increment CX register by 1.
Step 6: Store the contents of sum and carry to output memory locations.
Step 7: Stop the execution.
Program
ASSUME CS:CODE
0000 CODE SEGMENT
1000 ORG 1000H
1000 B8 FFFF MOV AX,0FFFFH
1003 BB FFFF MOV BX,0FFFFH
1006 B9 0000 MOV CX,0000H
1009 03 C3 ADD AX,BX
100B 73 01 JNC SKIP
100D 41 INC CX
100E BE 1200 SKIP: MOV SI,1200H
1011 89 04 MOV [SI],AX
1013 BE 1202 MOV SI,1202H
1016 89 0C MOV [SI],CX
1018 B4 4C MOV AH,4CH
101A CD 21 INT 21H
101C CODE ENDS
END
5
Procedure
C:EDIT FILENAME.ASM
C:LINK FILENAME.OBJ
C:DEBUG FILENAME.EXE
-G 1000
Output
b) Aim: To write an 8086 assembly language program to perform 16-bit subtraction using
MASM assembler
Algorithm
16-Bit Subtraction
Step 1: Get two 16-bit data from the input memory locations to AX and BX registers.
Step 2: Clear CL register to store the carry condition.
Step 3: Subtract the contents of AX from BX register and store the result in AX.
Step 4: Check carry flog, If CF = 0 then go to step 6.
Step 5: Increment CL register by 1.
Step 6: Store the contents of sum and carry to output memory locations.
Step 7: Stop the execution.
Program
ASSUME CS:CODE
0000 CODE SEGMENT
1000 ORG 1000H
1000 B8 0003 MOV AX,03H
1003 BB 0007 MOV BX,07H
1006 B9 0000 MOV CX,0000H
6
1009 2B C3 SUB AX,BX
100B 73 01 JNC SKIP
100D 41 INC CX
100E BE 1200 SKIP: MOV SI,1200H
1011 89 04 MOV [SI],AX
1013 BE 1202 MOV SI,1202H
1016 89 0C MOV [SI],CX
1018 B4 4C MOV AH,4CH
101A CD 21 INT 21H
101C CODE ENDS
END
Output
c) Aim: To write an 8086 assembly language program to perform 16-bit multiplication using
MASM assembler
Algorithm
16-Bit Multiplication
Step 1: Get two 16-bit data from the input memory locations to AX and BX registers.
Step 2: Clear DX register to store the higher order product.
Step 3: Multiply the contents of BX with AX register and store the product in DX and
AX.
Step 4: Store the contents of product to output memory locations.
Step 5: Stop the execution.
Program
ASSUME CS:CODE
0000 CODE SEGMENT
1000 ORG 1000H
1000 B8 3456 MOV AX,3456H
7
1003 BB 2345 MOV BX,2345H
1006 BA 0000 MOV DX,0000H
1009 F7 E3 MUL BX
100B BE 1200 MOV SI,1200H
100E 89 04 MOV [SI],AX
1010 46 INC SI
1011 46 INC SI
1012 89 14 MOV [SI],DX
1014 B4 4C MOV AH,4CH
1016 CD 21 INT 21H
1018 CODE ENDS
END
Output
d) Aim: To write an 8086 assembly language program to perform 16-bit division using
MASM assembler
Algorithm
16-Bit Division
Step 1: Get two 16-bit data from the input memory locations to AX and BX registers.
Step 2: Clear DX register to store the reminder.
Step 3: Divided the contents of BX from AX register and store the quotient in AX.
Step 4: Store the contents of reminder and quiescent to output memory locations.
Step 5: Stop the execution.
Program
ASSUME CS:CODE
0000 CODE SEGMENT
1000 ORG 1000H
1000 B8 0010 MOV AX,10H
1003 BB 0002 MOV BX,02H
8
1006 BA 0000 MOV DX,0000H
1009 F7 F3 DIV BX
100B BE 1200 MOV SI,1200H
100E 89 04 MOV [SI],AX
1010 46 INC SI
1011 46 INC SI
1012 89 14 MOV [SI],DX
1014 B4 4C MOV AH,4CH
1016 CD 21 INT 21H
1018 CODE ENDS
END
Output
Inference
The above experiment is performed to implement the Arithmetic operations such as addition,
subtraction, multiplication and division using the 8086 microprocessor. In the 8086 microprocessor
we use the Assembly language programming (ALP), which is designed with unique characteristics
suitable for the 8086 microprocessor. If the output is of 16 bits, it will be stored in the AX register,
else if the output is of 32 bits the DX stores the LSB and stores the MSB.
Result
Thus the 8086 assembly language programs for 16-bit Arithmetic Operations were
written and executed successfully.
9
Ex. No. 2
16-BIT LOGICAL OPERATIONS
Date:
26.9.2020
a) Aim: To write an 8086 assembly language program to perform 16-bit AND Operation using
MASM assembler.
Algorithm
16-Bit AND operation
Step 1: Get two 16-bit data from the input memory locations to AX and BX registers.
Step 2: The contents of BX is AND with AX register and store the result in AX.
Step 3: Store the contents of AX to output memory location.
Step 4: Stop the execution.
Program
ASSUME CS:CODE
0000 CODE SEGMENT
1000 ORG 1000H
1000 B8 0005 MOV AX,05H
1003 BB 0007 MOV BX,07H
1006 23 C3 AND AX,BX
1008 BE 1200 MOV SI,1200H
100B 89 04 MOV [SI],AX
100D B4 4C MOV AH,4CH
100F CD 21 INT 21H
1011 CODE ENDS
END
Procedure
C:EDIT FILENAME.ASM
C:LINK FILENAME.OBJ
C:DEBUG FILENAME.EXE
-G 1000
10
Output
b) Aim: To write an 8086 assembly language program to perform 16-bit OR Operation using
MASM assembler
Algorithm
16-Bit OR operation
Step 1: Get two 16-bit data from the input memory locations to AX and BX registers.
Step 2: The contents of BX is OR with AX register and store the result in AX.
Step 3: Store the contents of AX to output memory location.
Step 4: Stop the execution.
Program
ASSUME CS:CODE
0000 CODE SEGMENT
1000 ORG 1000H
1000 B8 0007 MOV AX,07H
1003 BB 0006 MOV BX,06H
1006 0B C3 OR AX,BX
1008 BE 1200 MOV SI,1200H
100B 89 04 MOV [SI],AX
100D B4 4C MOV AH,4CH
100F CD 21 INT 21H
1011 CODE ENDS
END
11
Output
c) Aim: To write an 8086 assembly language program to perform 16-bit XOR Operation
using MASM assembler
Algorithm
16-Bit XOR operation
Step 1: Get two 16-bit data from the input memory locations to AX and BX registers.
Step 2: The contents of BX is XOR with AX register and store the result in AX.
Step 3: Store the contents of AX to output memory location.
Step 4: Stop the execution.
Program
ASSUME CS:CODE
0000 CODE SEGMENT
1000 ORG 1000H
1000 B8 0004 MOV AX,0004H
1003 BB 0008 MOV BX,0008H
1006 33 C3 XOR AX,BX
1008 BE 1200 MOV SI,1200H
100B 89 04 MOV [SI],AX
100D B4 4C MOV AH,4CH
100F CD 21 INT 21H
1011 CODE ENDS
END
Output
12
d) Aim: To write an 8086 assembly language program to perform 16-bit NOT Operation
using MASM assembler
Algorithm
16-Bit NOT operation
Step 1: Get an 8-bit data from the input memory location to AX register.
Step 2: The content of AX is complimented with NOT operation and result is stored in
AX register.
Step 3: Store the contents of AX to output memory location.
Step 4: Stop the execution.
Program
ASSUME CS:CODE
0000 CODE SEGMENT
1000 ORG 1000H
1000 B8 1244 MOV AX,1244H
1003 F7 D0 NOT AX
1005 BE 1200 MOV SI,1200H
1008 89 04 MOV [SI],AX
100A B4 4C MOV AH,4CH
100C CD 21 INT 21H
100E CODE ENDS
END
Output
Inference
The above experiment has been taught to implement the Logical operations such as
AND,OR,XOR and NOT using the 8086 microprocessor. To perform the logical commands two
operands will be given as input to perform the AND,OR,XOR logic and one operand as input for
NOT logic implementation and their resultant is stored in the AX register.
Result
Thus the 8086 assembly language programs for 16-bit Logical Operations were
written and executed successfully.
13
Ex. No. 3
BCD ADDITION
Date:
26.9.2020
Aim: To write an 8086 assembly language program to perform BCD addition using MASM
assembler.
Algorithm
BCD Addition
Step 1: Get two data from the input memory locations to AL and BL registers.
Step 2: Clear CL register to store the carry condition.
Step 3: Add the contents of BL to AL, adjust the AL value to decimal value and store
the result in AL.
Step 4: Check carry flog, If CF = 0 then go to step 6.
Step 5: Increment CL register by 1.
Step 6: Store the contents of sum and carry to output memory locations.
Step 7: Stop the execution.
Program
ASSUME CS:CODE
0000 CODE SEGMENT
1000 ORG 1000H
1000 B8 0006 MOV AX,0006H
1003 BB 0007 MOV BX,0007H
1006 03 C3 ADD AX,BX
1008 27 DAA
1009 BE 1200 MOV SI,1200H
100C 89 04 MOV [SI],AX
100E B4 4C MOV AH,4CH
1010 CD 21 INT 21H
1012 CODE ENDS
END
Procedure
C:EDIT FILENAME.ASM
C:LINK FILENAME.OBJ
C:DEBUG FILENAME.EXE
-G 1000
14
Output
Inference
The result of the addition is a BCD-format 4-bit output word, representing the decimal sum
of the addend and augend, and a carry that is generated if this sum exceeds a decimal value of 9.
Here, the added value is converted into to decimal using the DAA command.
Result
Thus the 8086 assembly language program for BCD Addition was written and
executed successfully.
15
Ex. No. 4 SEARCHING THE LARGEST AND SMALLEST
Date: ELEMENT IN AN ARRAY
3.10.2020
a) Aim: To write an 8086 assembly language program to search the largest element in an array
using MASM assembler.
Algorithm
16-Bit largest Number
Program
ASSUME CS:CODE
0000 CODE SEGMENT
1000 ORG 1000H
1000 BE 1200 MOV SI,1200H
1003 B1 05 MOV CL,05H
1005 8A 04 MOV AX,[SI]
1007 46 AGAIN: INC SI
1008 3A 04 CMP AX,[SI]
100A 73 02 JNC SKIP
100C 8A 04 MOV AX,[SI]
100E FE C9 SKIP: DEC CL
1010 75 F5 JNZ AGAIN
1012 BF 1300 MOV DI,1300H
1015 88 05 MOV [DI],AX
1017 B4 4C MOV AH,4CH
1019 CD 21 INT 21H
101B CODE ENDS
END
Procedure
16
C:EDIT FILENAME.ASM
C:LINK FILENAME.OBJ
C:DEBUG FILENAME.EXE
-G 1000
Output
b) Aim: To write an 8086 assembly language program to search the smallest element in an array
using MASM assembler.
Algorithm
16-Bit smallest Number
Program
ASSUME CS:CODE
0000 CODE SEGMENT
1000 ORG 1000H
1000 BE 1200 MOV SI,1200H
1003 B1 05 MOV CL,05H
1005 8A 04 MOV AL,[SI]
1007 46 AGAIN: INC SI
1008 3A 04 CMP AL,[SI]
100A 72 02 JC SKIP
17
100C 8A 04 MOV AL,[SI]
100E FE C9 SKIP: DEC CL
1010 75 F5 JNZ AGAIN
1012 BF 1300 MOV DI,1300H
1015 88 05 MOV [DI],AL
1017 B4 4C MOV AH,4CH
1019 CD 21 INT 21H
101B CODE ENDS
END
Procedure
C:EDIT FILENAME.ASM
C:LINK FILENAME.OBJ
C:DEBUG FILENAME.EXE
-G 1000
Output
Inference
The above experiment is performed to compare two numbers in an array and give the largest
or the smallest of them as the result. In the 8086 microprocessor we use the Assembly language
programming (ALP), which is designed with unique characteristics suitable for the 8086
microprocessor. The output is of 16 bits, it will be stored in the AX register.
Result
Thus the 8086 assembly language programs for finding the largest and smallest
element in array were written and executed successfully.
18
Ex. No. 5 SORTING AN ARRAY IN ASCENDING AND
Date: DESCENDING ORDER
3.10.2020
a) Aim: To write an 8086 assembly language program to sort an array in ascending order using
MASM assembler.
Algorithm
16-Bit Ascending order
Program
ASSUME CS:CODE
0000 CODE SEGMENT
1000 ORG 1000H
1000 START:
1000 33 C0 XOR AX,AX
1002 8A D8 MOV BX,AX
1004 8A C8 MOV CX,AX
1006 BE 2000 MOV SI,2000H
1009 8A 1C MOV BX,[SI]
100B FE CB DEC BX
100D 8A CB L3: MOV CX,BX
100F BE 3000 MOV SI,3000H
1012 8A 04 L2: MOV AX,[SI]
1014 3A 44 01 CMP AX,[SI+1]
1017 7E 05 JLE L1
1019 86 44 01 XCHG AX,[SI+1]
101C 88 04 MOV [SI],AX
101E 46 L1: INC SI
101F E2 F1 LOOP L2
1021 FE CB DEC BX
19
1023 75 E8 JNZ L3
1025 CC INT 3
1026 B4 4C MOV AH,4CH
1028 CD 21 INT 21H
102A CODE ENDS
END
Procedure
C:EDIT FILENAME.ASM
C:LINK FILENAME.OBJ
C:DEBUG FILENAME.EXE
-G 1000
Output
20
b) Aim: To write an 8086 assembly language program to sort an array in descending order
MASM assembler.
Algorithm
Program16-Bit Descending order
Program
ASSUME CS:CODE
0000 CODE SEGMENT
1000 ORG 1000H
1000 START:
1000 33 C0 XOR AX,AX
1002 8A D8 MOV BX,AX
1004 8A C8 MOV CX,AX
1006 BE 2000 MOV SI,2000H
1009 8A 1C MOV BX,[SI]
100B FE CB DEC BX
100D 8A CB L3: MOV CX,BX
100F BE 3000 MOV SI,3000H
1012 8A 04 L2: MOV AX,[SI]
1014 3A 44 01 CMP AX,[SI+1]
1017 7D 05 JGE L1
1019 86 44 01 XCHG AX,[SI+1]
101C 88 04 MOV [SI],AX
101E 46 L1: INC SI
101F E2 F1 LOOP L2
1021 FE CB DEC BX
1023 75 E8 JNZ L3
1025 CC INT 3
21
1026 B4 4C MOV AH,4CH
1028 CD 21 INT 21H
102A CODE ENDS
END
Output
Inference
The above experiment is performed to compare two numbers in an array and arrange the
numbers in ascending/descending order as the result. In the 8086 microprocessor we use the
Assembly language programming (ALP), which is designed with unique characteristics suitable for
the 8086 microprocessor. The output is of 16 bits, it will be stored in the AX register.
Result
Thus the 8086 assembly language programs for sorting an array in ascending and
descending order were written and executed successfully.
22
Ex. No. 6
STRING COPY
Date:
10.10.2020
Aim: To write an 8086 assembly language program to copy a string from source to destination
using MASM assembler.
Algorithm
String Copy
Program
ASSUME CS:CODE
1000 ORG 1000H
0000 CODE SEGMENT
0000 BE 1200 MOV SI,1200H
0003 BF 1300 MOV DI,1300H
0006 B9 0005 MOV CX,0005H
0009 FC CLD
000A F3/ A4 REP MOVSB
000C B4 4C MOV AH,4CH
000E CD 21 INT 21H
0010 CODE ENDS
END
Procedure
C:EDIT FILENAME.ASM
C:LINK FILENAME.OBJ
C:DEBUG FILENAME.EXE
-G 1000
23
Output
Inference
This experiment copies the set of inputs stored in the consecutive memory location from the
initial location mentioned location. The number of consecutive memory locations to be copied is
mentioned in the CX register whose value is decremented after each copy and stored the values are
stored in the required memory location.
Result
Thus the 8086 assembly language program to copy a string from source to destination
was written and executed successfully.
24
Ex. No. 7
STRING REVERSE
Date:
10.10.2020
Aim: To write an 8086 assembly language program to reverse a string using MASM assembler.
Algorithm
8-Bit String Reverse
Program
ASSUME CS:CODE
0000 CODE SEGMENT
1000 ORG 1000H
1000 BE 1200 MOV SI,1200H
1003 BF 1300 MOV DI,1300H
1006 B9 0005 MOV CX,0005H
1009 83 C6 04 ADD SI,04H
100C 8A 04 L1: MOV AL,[SI]
100E 88 05 MOV [DI],AL
1010 4E DEC SI
1011 47 INC DI
1012 49 DEC CX
1013 75 F7 JNZ L1
1015 B4 4C MOV AH,4CH
1017 CD 21 INT 21H
1019 CODE ENDS
END
Procedure
C:EDIT FILENAME.ASM
C:LINK FILENAME.OBJ
C:DEBUG FILENAME.EXE
25
-G 1000
Output
Inference
This experiment reverses the set of inputs stored in the consecutive memory location from
the initial location mentioned location. The number of consecutive memory locations to be copied
and reserved is mentioned in the CX register whose value is decremented after each copy and
stored the values are stored in the required memory location.
Result
Thus the 8086 assembly language program to reverse a string was written and
executed successfully.
26
Ex. No. 8
SEARCHING A GIVEN ELEMENT IN AN ARRAY
Date:
17.10.2020
Aim: To write an 8086 assembly language program to search a given element in an array using
MASM assembler.
Algorithm
Search an element in an array
Program
ASSUME CS:CODE
1000 ORG 1000H
0000 CODE SEGMENT
0000 BF 1200 MOV DI,1200H
0003 B0 55 MOV AL,55H
0005 B3 00 MOV BL,00H
0007 B9 0005 MOV CX,0005H
000A F2/ AE REPNE SCASB
000C 75 02 JNZ SKIP
000E FE C3 INC BL
0010 BE 1300 SKIP: MOV SI,1300H
0013 88 1C MOV [SI],BL
0015 B4 4C MOV AH,4CH
0017 CD 21 INT 21H
0019 CODE ENDS
END
Procedure
C:EDIT FILENAME.ASM
C:LINK FILENAME.OBJ
27
C:DEBUG FILENAME.EXE
-G 1000
Output
Inference
The above experiment is performed to search for a number by taking each number from the
array and then comparing it with the number to be searched. If the numbers are the same, then the
address and index are returned. In the 8086 microprocessor we use the Assembly language programming
(ALP), which is designed with unique characteristics suitable for the 8086 microprocessor output is of
16 bits, it will be stored in the AX register.
Result
Thus the 8086 assembly language program to search a given element in an array was
written and executed successfully.
28
Ex. No. 9
COUNT THE GIVEN ELEMENT IN AN ARRAY
Date:
17.10.2020
Aim: To write an 8086 assembly language program to count the given element in an array
using MASM assembler.
Algorithm
Count the Given 8-Bit Number in an array
Program
ASSUME CS:CODE
1000 ORG 1000H
0000 CODE SEGMENT
0000 B4 FF MOV AH,0FFH
0002 B3 00 MOV BL,00H
0004 B1 05 MOV CL,05H
0006 BE 1200 MOV SI,1200H
0009 3A 24 L2:CMP AH,[SI]
000B 75 02 JNZ L1
000D FE C3 INC BL
000F 46 L1:INC SI
0010 FE C9 DEC CL
0012 75 F5 JNZ L2
0014 BF 1300 MOV DI,1300H
0017 88 1D MOV [DI],BL
0019 B4 4C MOV AH,4CH
001B CD 21 INT 21H
29
001D CODE ENDS
END
Procedure
C:EDIT FILENAME.ASM
C:LINK FILENAME.OBJ
C:DEBUG FILENAME.EXE
-G 1000
Output
Inference
The above experiment is performed to count the number of elements in the given array by
initializing the count register CX and counting the given inputs into A register and the final count is
updated as a result using Assembly language programming (ALP), which is designed with unique
characteristics suitable for the 8086 microprocessor.
Result
Thus the 8086 assembly language program to count the given element in an array was
written and executed successfully.
30
Ex. No. 10
MATRIX ADDITION
Date:
24.10.2020
Aim: To write an 8086 assembly language program to add two 3x3 matrices using MASM
assembler.
Algorithm
8-Bit 3x3 Matrix Addition
Program
ASSUME CS:CODE
0000 CODE SEGMENT
1000 ORG 1000H
1000 START:
1000 33 C0 XOR AX,AX
1002 8B DB MOV BX,BX
1004 8A C8 MOV CL,AL
1006 B1 09 MOV CL,09H
1008 BE 3000 MOV SI,3000H
100B BF 4000 MOV DI,4000H
100E BB 5000 MOV BX,5000H
1011 8A 04 L1: MOV AL,[SI]
1013 02 05 ADD AL,[DI]
1015 88 07 MOV [BX],AL
1017 46 INC SI
1018 47 INC DI
1019 43 INC BX
101A E2 F5 LOOP L1
31
101C CC INT 3
101D B4 4C MOV AH,4CH
101F CD 21 INT 21H
1021 CODE ENDS
END
Procedure
C:EDIT FILENAME.ASM
C:LINK FILENAME.OBJ
C:DEBUG FILENAME.EXE
-G 1000
Output
Inference
We imply the concept of matrix addition to the ALP for 8086 microprocessors, Two matrices
may be added or subtracted only if they have the same dimension; that is, they must have the same
number of rows and columns. Addition is accomplished by adding corresponding elements with the
same row and column values.
Result
Thus the 8086 assembly language program for adding two 3x3 matrices was written
and executed successfully.
32
Ex. No. 11
CODE CONVERSION (HEXADECIMAL TO ASCII)
Date:
24.10.2020
Aim: To write an 8086 assembly language program to convert Hexadecimal number to ASCII
number using MASM assembler.
Algorithm
Code Conversion (Hexadecimal to ASCII)
Program
ASSUME CS:CODE
0000 CODE SEGMENT
1000 ORG 1000H
1000 BE 1200 MOV SI,1200H
1003 BF 1300 MOV DI,1300H
1006 8A 04 MOV AL,[SI]
1008 3C 0A CMP AL,0AH
100A 7F 05 JG SUM
100C 04 30 ADD AL,30H
100E EB 06 90 JMP RES
1011 04 37 SUM: ADD AL,37H
1013 EB 01 90 JMP RES
1016 88 05 RES: MOV [DI],AL
1018 B4 4C MOV AH,4CH
101A CD 21 INT 21H
101C CODE ENDS
END
Procedure
C:EDIT FILENAME.ASM
C:LINK FILENAME.OBJ
C:DEBUG FILENAME.EXE
-G 1000
33
Output
Inference
We know that a hexadecimal number uses 16 symbols {0, 1, 2, 4, 5, 6, 7, 8, 9, A, B, C, D, E,
F} to represent all numbers. Here, (A, B, C, D, E, F) represents (10, 11, 12, 13, 14, 15). The idea is
to extract the digits of a given hexadecimal number starting from the rightmost digit and keep a
variable dec_value. At the time of extracting digits from the hexadecimal number, multiply the digit
with the proper base (Power of 16) and add it to the variable dec_value. At the end, the variable
dec_value will store the required decimal number.
Result
Thus the 8086 assembly language program for converting hexadecimal number to
ASCII number was written and executed successfully.
34
Programs Using 8051 Microcontroller
(KEIL)
35
Ex. No. 12
8-BIT ARITHMETIC OPERATIONS
Date:
31.10.2020
a) Aim: To write an 8051 assembly language program to perform 8-bit addition using KEIL
IDE.
Algorithm
8-Bit Addition
Program
36
Output
b) Aim: To write an 8051 assembly language program to perform 8-bit subtraction using KEIL
IDE.
Algorithm
8-Bit Subtraction
Step 1: Get two 8-bit numbers from the input memory locations to R0 and A registers.
Step 2: Clear R1 register to store the carry condition. Clear carry flag.
Step 3: Subtract the contents of R0 from A register and store the result in A.
Step 4: Check carry flog, If CF = 0 then go to step 6.
Step 5: Increment R1 register by 1.
Step 6: Store the contents of Difference and Borrow to output memory locations.
Step 7: Stop the execution.
Program
37
0000 7434 2 MOV A,#34H
0002 75F011 3 MOV B,#11H
0005 95F0 4 SUBB A,B
5 END
Output
c) Aim: To write an 8051 assembly language program to perform 8-bit multiplication using
KEIL IDE.
Algorithm
8-Bit Multiplication
Step 1: Get two 8-bit numbers from the input memory locations to B and A
registers.
Step 2: Multiply the contents of B with A register and store the product in A&B.
Step 3: Store the contents of product to output memory locations.
Step 4: Stop the execution.
Program
38
0000 7411 2 MOV A,#11H
0002 75F022 3 MOV B,#22H
0005 A4 4 MUL AB
5 END
Output
d) Aim: To write an 8051 assembly language program to perform 8-bit division using KEIL
IDE.
Algorithm
8-Bit Division
Step 1: Get two 8-bit numbers from the input memory locations to B and A
registers.
Step 2: Divide the contents of B with A register and store the results in A&B.
Step 3: Store the contents of quotient & remainder to output memory locations.
Step 4: Stop the execution.
Program
39
Output
Inference
The above experiment is performed to implement the Arithmetic operations such as addition,
subtraction, multiplication and division using the 8051 microcontroller. The two operands are given
in immediate addressing modes to 8 bit A and B register. In 8051 microcontroller we use Assembly
language programming (ALP), which is designed with unique characteristics suitable for the 8051
microcontroller.
Result
Thus the 8051 assembly language programs for 8-bit arithmetic operations were written and
executed successfully.
40
Ex. No. 13
8-BIT LOGICAL OPERATIONS
Date:
31.10.2020
a) Aim: To write an 8051 assembly language program to perform 8-bit Logical AND operation
using KEIL IDE.
Algorithm
8-Bit AND Operation
Step 1: Get two 8-bit numbers from the input memory locations to R0 and A
registers.
Step 2: Perform the AND operation between the contents of R0 with A registers and
stores the result in A register.
Step 3: Store the contents of result to output memory locations.
Step 4: Stop the execution.
Program
41
Output
b) Aim: To write an 8051 assembly language program to perform 8-bit Logical OR operation
using KEIL IDE.
Algorithm
8-Bit OR Operation
Step 1: Get two 8-bit numbers from the input memory locations to R0 and A
registers.
Step 2: Perform the OR operation between the contents of R0 with A registers and
stores the result in A register.
Step 3: Store the contents of result to output memory locations.
Step 4: Stop the execution.
Program
42
Output
c) Aim: To write an 8051 assembly language program to perform 8-bit Logical XOR operation
using KEIL IDE.
Algorithm
8-Bit EX-OR Operation
Step 1: Get two 8-bit numbers from the input memory locations to R0 and A
registers.
Step 2: Perform the EX-OR operation between the contents of R0 with A registers and
stores the result in A register.
Step 3: Store the contents of result to output memory locations.
Step 4: Stop the execution.
Program
43
Output
d) Aim: To write an 8051 assembly language program to perform 8-bit Logical NOT operation
using KEIL IDE.
Algorithm
8-Bit NOT Operation
Step 1: Get an 8-bit number from the input memory location to Aregister.
Step 2: Perform the NOT operation of on A register and store the result in A register.
Step 3: Store the contents of result to output memory location.
Step 4: Stop the execution.
Program
44
Output
Inference
The above experiment is performed to implement the Logical operations such as Logical
AND, OR, XOR, and NOT Operations using 8051 microcontroller. The operand is given in
immediate addressing modes to 8 bit A and B register in case of AND, OR, and XOR Operations
and only A register in case of NOT Operation.. In 8051 microcontroller we use Assembly language
programming (ALP), which is designed with unique characteristics suitable for 8051
microcontroller.
Result
Thus the 8051 assembly language programs for 8-bit logical operations were written and
executed successfully.
45
Ex. No. 14
8-BIT 1’S AND 2’S COMPLEMENT OF A NUMBER
Date:
7.11.2020
a) Aim: To write an 8051 assembly language program to find 8-bit 1’s complement of a number
using KEIL IDE.
Algorithm
8-Bit 1’s Complement Operation
Step 1: Get an 8-bit number from the input memory location to Aregister.
Step 2: Perform the complement operation of on A register and store 1’s
complimented result in A register.
Step 3: Store the contents of result to output memory location.
Program
Output
46
b) Aim: To write an 8051 assembly language program to find 8-bit 2’s complement of a
number using KEIL IDE.
Algorithm
8-Bit 2’s Complement Operation
Step 1: Get an 8-bit number from the input memory location to Aregister.
Step 2: Perform the complement operation of on A register, increment the A register
by 1 and store 2’s complimented result in A register.
Step 3: Store the contents of result to output memory location.
Program
Output
Inference
The above experiment is performed to find 1's and 2's complement of a number using 8051
microcontroller.The operand is given in immediate addressing mode to 8 bit A register.1's
complement is achieved by inverting the equivalent binary bits to their complement value. For
finding 2's complement, one is added to the LSB of 1's complement. In 8051 microcontroller we use
Assembly language programming (ALP), which is designed with unique characteristics suitable for
47
the 8051 microcontroller.
Result
Thus the 8051 assembly language programs for finding 8-bit 1’s and 2’s complement of number
were written and executed successfully.
48
Ex. No. 15 PROGRAM USING BIT MANIPULATION
Date: INSTRUCTIONS
7.11.2020
Aim: To write an 8051 assembly language program to implement Bit Manipulation Instructions
of 8051 Microcontroller using KEIL IDE.
Algorithm
Bit Manipulation
Step 1: Get an 8-bit number from the input memory locationto A register.
Step 2: Set a bit A3 and Clear bit A7 in A register and store the result in A.
Step 3: Store the contents of product to output memory location.
Step 4: Stop the execution.
Program
Output
49
Inference
The above experiment is performed to implement bit manipulation using 8051 microcontroller.
The operand is given in immediate addressing mode to 8 bit A register. The manipulated bit is
obtained by executing SETB command for the 3rd bit and executing CLR command for the 7th bit. In
the 8051 microcontroller we use Assembly language programming (ALP), which is designed with
unique characteristics suitable for 8051 microcontroller.
Result
Thus the 8051 assembly language program for implementing bit manipulation instructions of 8051
microcontroller was written and executed successfully.
50