MPMC Lab Manual - Reference
MPMC Lab Manual - Reference
INSTITUTE OF TECHNOLOGY
(Approved by AICTE, New Delhi & Affiliated to Anna University, Chennai)
BONAFIDE CERTIFICATE
Department of Electrical and Electronics Engineering
certified that this is a bonafide record of work done by
Mr. / Ms. ……………………………………………… of the ………………………………… B.E. / B.Tech. /
M.E. / M.Tech. in the year EC8681 – MICROPROCESSORS AND MICROCONTROLLERS
Laboratory conducted in this institution, as prescribed by Anna University – Chennai, for
the ............. semester, during the academic year 2019 / 2020.
Date:
…………………………………………………………………………………
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
1
Ex. No: 1a BASIC ARITHMETIC OPERATIONS
AIM:
To write and execute an assembly language program for add, subtract, multiply and divide two
16 bit unsigned numbers in 8086 kit and MASM.
APPARATUS:
1. 8086 microprocessor kit/MASM ----1
2. Power card ----1
3. Keyboard ----1
4. PC with Intel/AMD Processor----1
16-BIT ADDITION:
ALGORITHM:
1. Load the First Data in AX-register.
2. Load the First Data in BX-register.
2. Add the two data and get the sum in AX-register.
3. Store the sum in memory location.
4. Stop the program.
PROGRAM:
i) By Using Masm:
CODE SEGMENT
ASSUME CS: CODE, DS: CODE
ORG 1000H
MOV AX, 1234H
MOV BX, 1234H
ADD AX, BX
MOV SI, 1200H
MOV [SI], AX
MOV AH, 4CH
INT 21H
CODE ENDS
END
ii) By using 8086 kit:
OUTPUT:
INPUT OUTPUT
Register Data Address Data
AX 1234H 1200H 68
BX 1234H 1201H 24
2
16-BIT SUBTRACTION:
ALGORITHM:
1. Load the First Data in AX-register.
2. Load the First Data in BX-register.
3. Subtract the content of BX-reg from AX-register.
4. Store the result in memory location.
5. Stop the program.
PROGRAM:
i) BY USING MASM:
CODE SEGMENT
ASSUME CS: CODE, DS: CODE
ORG 1000H
MOV AX, 0FFFFH
MOV BX, 0EEEEH
SUB AX, BX
MOV SI, 1200H
MOV [SI], AX
MOV AH, 4CH
INT 21H
CODE ENDS
END
OUTPUT:
INPUT OUTPUT
Register Data Address Data
AX FFFFH 1200H 11
BX EEEEH 1201H 11
16-BIT MULTIPLICATION
ALGORITHM:
3
4. Store the result in memory location.
5. Stop the program.
PROGRAM:
i) By using MASM:
CODE SEGMENT
ASSUME CS: CODE, DS: CODE
ORG 1000H
MOV AX, 4444H
MOV BX, 4444H
MUL BX
MOV SI, 1200H
MOV [SI], DX
MOV SI, 1202H
MOV [SI], AX
MOV AH, 4CH
INT 21H
CODE ENDS
END
1000 C7,C0, 4444 MOV AX,4444H Load AX-register with 1st data
1004 C7, C3, 4444 MOV BX,4444H Load BX-register with 2nd data
1008 F7, E3 MUL BX Multiply the contents of AX with
BX-register
100a C7, C6, MOV SI,1200H Assign SI-reg to 1200H
00,12
100e 89, 14 MOV [SI],DX Store the result
OUTPUT:
INPUT OUTPUT
Register Data Address Data
AX 4444H 1200H 34
BX 4444H 1201H 12
1202H 10
1203H 32
ALGORITHM:
1. Load the First Data in AX-register.
2. Load the First Data in BX-register.
3. Subtract the content of BX-reg from AX-register.
4. Store the result in memory location.
5. Stop the program.
4
PROGRAM:
i) By using MASM:
CODE SEGMENT
ASSUME CS: CODE, DS: CODE
ORG 1000H
MOV DX, 0000H
MOV AX, 8888H
MOV CX, 4444H
DIV CX
MOV SI, 1200H
MOV [SI], AX
MOV SI, 1202H
MOV [SI], DX
MOV AH, 4CH
INT 21H
CODE ENDS
END
OUTPUT:
INPUT OUTPUT
Register Data Address Data
DX 0000H 1200H 00(quotient)
AX 8888H 1202H 02(quotient)
CX 4444H 1203H 00(remainder)
1204H 00(remainder)
RESULT:
Thus an assembly language program for add, subtract, multiply and divide two 16 bit
unsigned numbers was executed using MASM and 8086 kit.
5
Ex. No: 1B LOGICAL OPERATION
AIM:
To write and execute an assembly language program for performing logical OR, AND,
NAND operation in 8086 kit and MASM.
APPARATUS:
1. 8086 microprocessor kit/MASM ----1
2. Power card ----1
3. Keyboard ----1
4. PC with Intel/AMD Processor----1
LOGICAL OR OPERATION
ALGORITHM:
1. Load the First Data in AL-register.
2. Load the Second Data in BL-register.
3. Logically OR the content of AL with BL-register.
4. Store the result in memory location.
5. Stop the program
PROGRAM:
i) By using MASM:
CODE SEGMENT
ASSUME CS: CODE
START: MOV AL, 85H
MOV BL, 99H
OR AL, BL
INT 3H
CODE ENDS
END START
OUTPUT:
INPUT OUTPUT
Register Data Address Data
AL 85H 1200H 9D
BL 95H
6
LOGICAL AND OPERATION
ALGORITHM:
1. Load the First Data in AL-register.
2. Load the Second Data in BL-register.
3. Logically AND the content of AL with BL-register.
4. Store the result in memory location.
5. Stop the program
PROGRAM:
i) By using MASM:
CODE SEGMENT
ASSUME CS: CODE
START: MOV AL, 85H
MOV BL, 99H
AND AL, BL
INT 3H
CODE ENDS
END START
OUTPUT:
INPUT OUTPUT
Register Data Address Data
AL 85H 1200H 81H
BL 95H
ALGORITHM:
1. Load the First Data in AL-register.
2. Load the Second Data in BX-register.
3. Logically AND the content of AX with BX-register.
4. Logically the content of AX register is complemented.
5. Store the result in memory location.
6. Stop the program
7
PROGRAM:
i) By using MASM:
CODE SEGMENT
ASSUME CS: CODE
START: MOV AL, 85H
MOV BL, 99H
ADD AL, BL
NOT AL
INT 3H
CODE ENDS
END START
OUTPUT:
INPUT OUTPUT
Register Data Address Data
AL 85H 1200H 7EH
BL 95H
VIVA QUESTIONS:
1. What is a Microprocessor?
2. What is the need for timing diagram?
3. Define mnemonics.
4. What is the difference between min mode and max mode of 8086?
5. What is flag?
6. What is stack?
7. What is interrupt?
8. What are the various interrupts in 8086?
9. What is the difference between compiler and assembler?
10. Which interrupts are generally used for critical events?
RESULT:
Thus an assembly language program for performing logical OR, AND, NAND operation was
executed using MASM and 8086 kit.
8
Ex. No: 2 MOVE A DATA BLOCK WITHOUT OVERLAP
AIM:
To write and execute an assembly language program for transferring data from one block to
another block without overlapping using 8086 kit and MASM.
APPARATUS:
1. 8086 microprocessor kit/MASM ----1
2. Power card ----1
3. Keyboard ----1
4. PC with Intel/AMD Processor----1
ALGORITHM:
1. Initialize counter.
2. Initialize source block pointer.
3. Initialize destination block pointer.
4. Get the byte from source block.
5. Store the byte in destination block.
6. Increment source, destination pointers and decrement counter.
7. Repeat steps 4, 5 and 6 until counter equal to zero.
8. Stop.
PROGRAM:
i) By using MASM:
DATA SEGMENT
ARRAY1 DW 1111H,2222H,3333H,4444H,5555H
ARRAY2 DW 5 DUP (0)
COUNT DW 0005H
CODE SEGMENT
MOV AX,@DATA
MOV DS, AX
LEA SI, ARRAY1
LEA DI, ARRAY2
MOV CX, COUNT
NEXT: MOV AX,[SI]
MOV DI, 1200H
MOV [DI], AX
INC SI
INC SI
INC DI
INC DI
LOOP NEXT
MOV AH, 4Ch
INT 21h
END
9
100C 88,25 Move content of AH to DI-
MOV [DI], AH
register.
100F FC REPEAT: CLD Clear the direction flag.
1010 A4 MOVSB Move the string byte.
1011 E2,F3 Unconditional loop to address
LOOP: REPEAT
specified by the label REPEAT.
1013 F4 HLT Stop the program
OUTPUT:
INPUT OUTPUT
Address Data Address Data
1200 55 1300 55
1201 65 1301 65
1202 75 1302 75
1203 85 1303 85
1204 95 1304 95
1205 A5 1305 A5
VIVA QUESTIONS:
RESULT:
Thus an assembly language program for transferring data from one block to another block
without overlapping was executed using 8086 kit and MASM.
10
Ex. No: 3A CODE CONVERSION
AIM:
To write and execute an assembly language program for converting BCD to Binary data,
packed to unpacked BCD code using 8086 kit and MASM.
APPARATUS:
1. 8086 microprocessor kit/MASM ----1
2. Power card ----1
3. Keyboard ----1
4. PC with Intel/AMD Processor----1
ALGORITHM:
1. Load the address of BCD data in SI-register.
2. Copy the BCD data to BL-register
3. Get the BCD data in AL-register.
4. Copy the BCD data in DL-register from AL-register.
5. Logically AND DL with 0Fh to mask upper nibble and get unit’s digit in DL-reg.
6. Move the count value for rotation in CL-register.
7. Rotate the content of AL to move the upper nibble to lower nibble position.
8. Move 0Ah to DH-register.
9. Multiply AL with DH-register. The product will be in AL-register.
10. Add the unit’s digit in DL-register to product in AL-register.
11. Save the binary data (AL) in memory.
12. Stop.
PROGRAM:
i) By using MASM:
CODE SEGMENT
ASSUME CS: CODE, DS: CODE
MOV BL, 75
MOV AL, BL
MOV DL, AL
AND DL, 0FH
AND AL, 0F0H
MOV CL, 4
ROR AL, CL
MOV DH, 0AH
MUL DH
ADD AL, DL
MOV [BX+1], AL
MOV SI, 1200H
MOV [SI], BX
MOV AH, 4CH
INT 21H
CODE ENDS
END
11
1007 80 E2 0F AND DL, 0Fh Logically AND the content of DL-
reg with 0Fh and store the
resultant data in DL-register.
100A 80 E0 F0 AND AL, 0F0h Logically AND the content of DL-
reg with F0h and store the
resultant data in AL-register
100D C6 C1 04 MOV CL, 4 Copy the data 4 to CL-reg.
OUTPUT:
INPUT OUTPUT
Register Data Address Data
BL 7410 1200 4Bh
ALGORITHM:
1. Load number into AL-register with packed BCD data.
2. Mask the lower nibble.
3. Rotate 4 times to right to make MSB=LSB.
4. Display the digit.
5. Load number into AL-register with upper nibble.
6. Mask upper nibble.
7. Display the result in memory location.
8. Stop.
PROGRAM:
i) By using MASM:
CODE SEGMENT
ASSUME CS: CODE, DS: CODE
MOV AX, 45h
12
MOV AH, AL
MOV CL, 4h
SHR AH, CL
AND AX, 0F0FH
MOV SI, 1200H
MOV [SI], AX
INT 3H
CODE ENDS
END
OUTPUT:
INPUT OUTPUT
Register Data Address Data
AX 45H 1200 05
1201 04
RESULT:
Thus an assembly language program for converting BCD to Binary data, packed to unpacked
BCD code using 8086 kit and MASM was implemented and its output was verified.
13
Ex. No: 3B DECIMAL OPERATIONS
AIM:
To write and execute an assembly language program to add, subtract, multiply and divide
two 8-bit BCD data using 8086 kit and MASM.
APPARATUS:
1. 8086 microprocessor kit/MASM ----1
2. Power card ----1
3. Keyboard ----1
4. PC with Intel/AMD Processor----1
ALGORITHM:
1. Get the 1st BCD number.
2. Get the 2nd BCD number.
3. Add two BCD numbers.
4. Adjust result to valid BCD numbers.
5. Display the result.
PROGRAM:
i) By using MASM:
CODE SEGMENT
ASSUME CS: CODE
MOV AL, 09H
MOV BL, 02H
ADD AL, BL
DAA
MOV CH, 02H
MOV SI, 1400H
MOV [SI], AL
MOV CL, 04H
MOV BH, AL
L2: ROL BH, CL
MOV DL, BH
AND DL, 0FH
CMP DL, 09
JBE L4
ADD DL, 07
L4: ADD DL, 30H
MOV AH, 02
INT 21H
DEC CH
JNZ L2
MOV AH, 4CH
INT 21H
CODE ENDS
END
14
1006 00 D8 ADD AL, BL Add the contents of AL-reg with
BL-register and the result will be
stored in AL-register.
1008 27 DAA Adjust result to valid BCD number.
OUTPUT:
INPUT OUTPUT
Register Data Address Data
AL 09 1400 11
BL 02
BCD SUBTRACTION
ALGORITHM:
1. Get the 1st BCD number.
2. Get the 2nd BCD number.
3. Subtract two BCD numbers.
4. Adjust result to valid BCD numbers.
5. Display the result.
PROGRAM:
i) By using MASM:
CODE SEGMENT
ASSUME CS: CODE
MOV AL, 32H
MOV BL, 17H
15
SUB AL, BL
DAS
MOV CH, 02H
MOV SI, 1400H
MOV [SI], AL
MOV CL, 04H
MOV BH, AL
L2: ROL BH, CL
MOV DL, BH
AND DL, 0FH
CMP DL, 09
JBE L4
ADD DL, 07
L4: ADD DL, 30H
MOV AH, 02
INT 21H
DEC CH
JNZ L2
MOV AH, 4CH
INT 21H
CODE ENDS
END
16
102B 75 EA JNZ L2 If count is not zero then goto label
L2
102D F4 HLT Stop the program
OUTPUT:
INPUT OUTPUT
Register Data Address Data
AL 32 1400 15
BL 17
BCD MULTIPLICATION
ALGORITHM:
PROGRAM:
ii) By using MASM:
CODE SEGMENT
ASSUME CS: CODE
MOV AL, 04H
MOV BL, 06H
MUL BL
AAM
MOV CH, 04H
MOV SI, 1400H
MOV [SI], AX
MOV CL, 04H
MOV BH, AL
L2: ROL BH, CL
MOV DL, BH
AND DL, 0FH
CMP DL, 09
JBE L4
ADD DL, 07
L4: ADD DL, 30H
MOV AH, 02
INT 21H
DEC CH
JNZ L2
MOV AH, 4CH
INT 21H
CODE ENDS
END
17
1003 C6 C3 04 MOV BL, 04H Load BL-reg with data 06h.
OUTPUT:
INPUT OUTPUT
Register Data Address Data
AL 04 1400 04
BL 06 1401 02
BCD DIVISION
ALGORITHM:
1. Get the 1st BCD number.
2. Get the 2nd BCD number.
3. Multiply two BCD numbers.
4. Adjust result to valid BCD numbers.
5. Display the result.
PROGRAM:
i). By using MASM:
CODE SEGMENT
ASSUME CS: CODE
MOVAL, 000FH
18
MOV BL, 08H
DIV BL
MOV CH, 04H
MOV SI, 1400H
MOV [SI], AX
MOV SI, 1402H
MOV [SI], BL
MOV CL, 04H
MOV BH, AL
L2: ROL BH, CL
MOV DL, BH
AND DL, 0FH
CMP DL, 09
JBE L4
ADD DL, 07
L4: ADD DL, 30H
MOV AH, 02
INT 21H
DEC CH
JNZ L2
MOV AH, 4CH
INT 21H
CODE ENDS
END
1003 C6,C3,08 MOV BL, 08H Load BL-reg with data 08h.
1006 F6,F3 DIV BL Divide the contents of AL-reg with
BL-register and the result will be
stored in AL-register.
1008 C6,C5,04 MOV CH, 04H Count of digits to be displayed
100b C7,C6,00,14 MOV SI, 1400H Load SI-reg with address 1400.
1011 C7,C6,02,14 MOV SI, 1402H Load SI-reg with address 1402.
19
1026 76,03 JBE L4 If byte jump to label L4
1028 80,C2,07 ADD DL, 07 If letter add 37H
102b 80,C2,30 L4: ADD DL, 30H Else only add 30H
102e FE,CD DEC CH Decrement Count
1030 75,EA JNZ L2 If count is not zero then goto label
L2
1032 F4 HLT Stop the program
OUTPUT:
INPUT OUTPUT
Register Data Address Data
AL F(Dividend) 1400 01(Quotient)
BL 08(Divisor) 1401 07(Remainder)
RESULT:
Thus an assembly language program for performing addition, subtraction,
multiplication and division of two 8-bit BCD numbers was performed and its output was verified.
20
Ex. No: 3C MATRIX ADDITION
AIM:
To write and execute an assembly language program for performing addition of two matrices
using 8086 kit and MASM.
APPARATUS:
1. 8086 microprocessor kit/MASM ----1
2. Power card ----1
3. Keyboard ----1
4. PC with Intel/AMD Processor----1
ALGORITHM:
1. Get the 1st BCD number.
2. Get the 2nd BCD number.
3. Multiply two BCD numbers.
4. Adjust result to valid BCD numbers.
5. Display the result.
PROGRAM:
i). By using MASM:
.MODEL SMALL
.DATA
M1 DB 00H,01H,10H,12H,02H,03H,0F0H,0C0H,04H
M2 DB 00H,05H,01H,02H,50H,90H,03H,04H,0AAH
.CODE
.STARTUP
MOV BX, OFFSET M1
MOV BP, OFFSET M2
MOV SI, 0001H
MOV CL, 09H
REPEAT: MOV AL,[BX+SI]
ADD AL, [BP+SI]
MOV [DI], AL
INC SI
INC DI
LOOP REPEAT
MOV AH, 4CH
INT 21H
END
21
AL.
1015 02,02 MOV AL,[BP+SI] Add corresponding element of
2nd matrix to AL.
1017 88,05 MOV [DI],AL Store the sum of an element in
memory.
1019 46 INC SI Increment the pointers.
OUTPUT:
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA Address Data
1300 00H 1400 00H 1501 00
1301 01H 1401 05H 1502 06
1302 10H 1402 01H 1503 11
1303 12H 1403 02H 1504 14
1304 02H 1404 50H 1505 52
1305 03H 1405 90H 1506 93
1306 0F0H 1406 03H 1507 F3H
1307 0C0H 1407 04H 1508 C4H
1308 04H 1408 0AAH 1509 AEH
VIVA QUESTIONS:
RESULT:
Thus an assembly language program for performing addition of two matrices numbers was
performed and its output was verified.
22
Ex. No: 4A STRING OPERATIONS
AIM:
To write and execute an assembly language program to find the length and copying string,
using 8086 kit and MASM.
APPARATUS:
1. 8086 microprocessor kit/MASM ----1
2. Power card ----1
3. Keyboard ----1
4. PC with Intel/AMD Processor----1
ALGORITHM:
1. Load the source and destination index register with starting and the ending address
respectively.
2. Load the terminate data value as “FF”.
3. Load the content of source index to the AL register.
4. Increment SI register and compare with register AH.
5. If it is non- zero value, increment the memory location by using the control instruction to
store the data.
6. Compare the string byte with FF, if it is not equal, repeat.
7. Count the string byte till zero flag is set. If zero flag is set then store the count value to the
memory.
8. Terminate the program when FF is matched.
9. Stop
PROGRAM:
i) By using MASM:
23
100C 8A,04 MOV AL,[SI] AL [SI]
100E 46 INC SI Increment the SI reg. by 1
INPUT:
OUTPUT:
STRING COPYING
ALGORITHM:
1. Load the source and destination index register with starting and the ending address
respectively.
2. Initialize the counter with the total number of words to be copied.
3. Clear the direction flag for auto incrementing mode of transfer.
4. Use the string manipulation instruction MOVSW with the prefix REP to copy a string from
source to destination.
5. Stop
PROGRAM:
i) By using MASM:
.MODEL SMALL
DATA SEGMENT
SRC DB ‘MICROPROCESSOR’
DB 10 DUP (?)
DST DB 20 DUP (0)
DATA ENDS
CODE SEGMENT
ASSUME CS: CODE, DS: DATA, ES: DATA
START: MOV AX, DATA
MOV DS, AX
MOV ES, AX
24
LEA SI, SRC
LEA DI, DST
MOV CX, 20
CLD
REP MOVSB
INT 3H
CODE ENDS
END START
OUTPUT:
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
2000 55 2100 55
2001 55 2101 55
2002 55 2102 55
2003 55 2103 55
2004 55 2104 55
2005 55 2105 55
RESULT:
Thus an assembly language program for copying, finding the length of a string was
implemented and its output was verified.
25
Ex. No: 4B SORTING (ASCENDING AND DESCENDING ORDER)
AIM:
To write and execute an assembly language program to sort an array of numbers in ascending
and descending order.
APPARATUS:
1. 8086 microprocessor kit/MASM ----1
2. Power card ----1
3. Keyboard ----1
4. PC with Intel/AMD Processor----1
ALGORITHM:
PROGRAM:
i) By using MASM:
.MODEL SMALL
.STACK 100
.DATA
NUM DB 12H, 45H, 79H, 66H
.CODE
START: MOV AX,@DATA
MOV DS, AX
MOV BX, 3
LOOP2: MOV CX, BX
MOV DI, 0
MOV AL, NUM [DI]
MOV DX, DI
LOOP1: INC DI
CMP AL, NUM [DI]
JNB NEXT
MOV AL, NUM [DI]
MOV DX, DI
NEXT: LOOP LOOP1
XCHG AL, NUM [DI]
26
MOV SI, DX
MOV NUM [SI], AL
DEC BX
JNZ LOOP2
MOV AH, 4CH
INT 21H
END START
DESCENDING ORDER:
ii) By using MASM:
.MODEL SMALL
.STACK 100
.DATA
NUM DB 12H, 45H, 79H, 66H
.CODE
START: MOV AX,@DATA
MOV DS, AX
MOV BX, 3
LOOP2: MOV CX, BX
MOV DI, 0
MOV AL, NUM [DI]
MOV DX, DI
LOOP1: INC DI
CMP AL, NUM [DI]
JB NEXT
MOV AL, NUM [DI]
MOV DX, DI
NEXT: LOOP LOOP1
XCHG AL, NUM [DI]
MOV SI, DX
MOV NUM [SI], AL
DEC BX
JNZ LOOP2
MOV AH, 4CH
INT 21H
END START
ASCENDING ORDER:
iii) By using 8086 kit:
ADDRESS OPCODE LABEL MNEMONICS COMMENTS
1000 MOV SI, 2000 Initialize the memory pointer.
C7,C6,00,20
1004 8A,0C MOV CL,[SI] Move the content SI to CL.
1006 FE,C9 DEC CL Decrement the count value
1008 C7,C6,00,20 REPEAT: MOV SI,2000 Move 2000 to SI.
100c 8A,2C MOV CH,[SI] Move the content of to CH.
100e FE,CD DEC CH Decrement the CH by one.
1010 46 INC SI Increment the memory
pointer
1011 8A,04 RECMP: MOV AL,[SI] Move the content of SI to
AL.
1013 46 INC SI increment the memory
27
pointer
1014 Compare the content of AL
3A,04 CMP AL,[SI] and content of address hold
by SI.
1016 If carry occur jump to the
72,05 JC :AHEAD address specify by the label
AHEAD.
1018 Exchange the content of AL
86,04 XCHG AL,[SI] and the content hold by the
address specify in SI.
101a Exchange the content of AL
86,44,FF XCHG AL,[SI-1] and the content hold by the
address specify in
SI-1.
101d FE,CD AHEAD: DEC CH Decrement the CH register by
1.
101f 75,F0 In the count value not reach
JNZ :RECMP to zero jumps to address
specify by RECMP.
1021 FE,C9 DEC CL Decrement the content of CL.
1023 75,E3 In the count value not reach
JNZ: REPEAT to zero jump to address
specify by REPEAT.
1025 F4 HLT Stop the program
OUTPUT:
INPUT OUTPUT
Address Data Address Data
2000 05 2001 01
2001 05 2002 02
2002 04 2003 03
2003 03 2004 04
2004 02 2005 05
2005 01
DESCENDING ORDER:
iv) By using 8086 kit:
ADDRESS OPCODE LABEL MNEMONICS COMMENTS
1000 C7,C6,00,20 MOV SI, 2000 Initialize the memory pointer.
1004 8A,0C MOV CL,[SI] Move the content SI to CL.
1006 FE,C9 DEC CL Decrement the count value
1008 C7,C6,00,20 REPEAT: MOV SI,2000 Move 2000 to SI.
100C 8A,2C MOV CH,[SI] Move the content of to CH.
100E FE,CD DEC CH Decrement the CH by one.
1010 46 INC SI Increment the memory pointer
1011 8A,04 RECMP: MOV AL,[SI] Move the content of SI to AL.
1013 46 INC SI increment the memory pointer
1014 3A,04 CMP AL,[SI] Compare the content of AL
and content of address hold by
28
SI.
1016 If carry occur jump to the
73,05 JNC :AHEAD address specify by the label
AHEAD.
1018 Exchange the content of AL
86,04 XCHG AL,[SI] and the content hold by the
address specify in SI.
101a Exchange the content of AL
86,44,FF XCHG AL,[SI-1] and the content hold by the
address specify in
SI-1.
101d FE,CD AHEAD: DEC CH Decrement the CH register by
1.
101f 75,F0 In the count value not reach to
JNZ :RECMP zero jumps to address specify
by RECMP.
1021 FE,C9 DEC CL Decrement the content of CL.
1023 75,E3 In the count value not reach to
JNZ: REPEAT zero jump to address specify
by REPEAT.
1025 F4 HLT Stop the program
OUTPUT:
INPUT OUTPUT
Address Data Address Data
2000 05 2001 05
2001 05 2002 04
2002 04 2003 03
2003 03 2004 02
2004 02 2005 01
2005 01
RESULT:
Thus an assembly language program for sorting an array of number in ascending and
descending order was performed and its output was verified.
29
Ex. No:4C SEARCHING A NUMBER
AIM:
To write and execute an assembly language program for searching a number using 8086 kit
and MASM.
APPARATUS:
1. 8086 microprocessor kit/MASM ----1
2. Power card ----1
3. Keyboard ----1
4. PC with Intel/AMD Processor----1
ALGORITHM:
1. Get the count in register for number of data.
2. Initialize the array address.
3. Compare the selected two numbers and check carry.
4. If bigger, store the largest value in accumulator.
5. Otherwise interchange the contents with register.
6. Decrement the count.
7. Continue the same operation till the count becomes zero.
8. Store the result in memory locations.
PROGRAM:
LARGEST:
(i) By using MASM:
DATA SEGMENT
X DW 0060H, 0020H, 0030H, 0040H, 0050H
MES DB 10, 13,'LARGEST NUMBER AMONG THE SERIES IS $'
DATA ENDS
CODE SEGMENT
ASSUME CS: CODE, DS: DATA
START: MOV AX, DATA
MOV DS, AX
MOV CX, 05H
LEA SI, X
MOV AX, [SI]
DEC CX
UP: CMP AX, [SI+2]
JNB CONTINUE
MOV AX, [SI+2]
CONTINUE: ADD SI, 2
DEC CX
JNZ UP
AAM
ADD AX, 3030H
MOV BX, AX
MOV AH, 09H
LEA DX, MES
INT 21H
MOV DL, BH
MOV AH, 02H
INT 21H
MOV DL, BL
INT 21H
MOV AH, 4CH
INT 21H
30
CODE ENDS
END START
OUTPUT:
INPUT OUTPUT
Address Data Address Data
2000 05 (COUNT) 2100 19
2001 15
2002 19
2003 02
2004 01
2005 06
SMALLEST:
31
MOV DS, AX
MOV CX, 05H
LEA SI, X
MOV AX, [SI]
DEC CX
UP: CMP AX, [SI+2]
JB CONTINUE
MOV AX, [SI+2]
CONTINUE: ADD SI, 2
DEC CX
JNZ UP
AAM
ADD AX, 3030H
MOV BX, AX
MOV AH, 09H
LEA DX, MES
INT 21H
MOV DL, BH
MOV AH, 02H
INT 21H
MOV DL, BL
INT 21H
MOV AH, 4CH
INT 21H
CODE ENDS
END START
32
OUTPUT:
INPUT OUTPUT
Address Data Address Data
2000 05 (COUNT) 2100 01
2001 15
2002 19
2003 02
2004 01
2005 06
VIVA QUESTIONS:
RESULT:
Thus an assembly language program for searching a smallest and largest was
performed and its output was verified.
33
Ex. No:5A PASSWORD CHECKING
AIM:
To write and execute an assembly language program for password checking using 8086 kit
and MASM.
APPARATUS:
1. 8086 microprocessor kit/MASM ----1
2. Power card ----1
3. Keyboard ----1
4. PC with Intel/AMD Processor----1
PROGRAM:
i) By using MASM
.MODEL SMALL
.DATA
NAM DB ’KRISHNA$’
PASS DB 50
DB?
DB 10 DUP (?)
MSG1 DB 10, 13,"ENTER THE PASSWORD: $", 10, 13
MSG2 DB 10, 13,"PASSWORD VALID: CONGRATS!!!! $", 10, 13
MSG3 DB 10, 13,"PASSWORD INVALID, SORRY TRY AGAIN ## $", 10, 13
PRINT MACRO MSG; MACRO DEFINITION TO PRINT A STRING ON SCREEN
LEA DX, MSG
MOV AH, 09
INT 21H
ENDM
.CODE
START: MOV AX,@DATA
MOV DS, AX
MOV ES, AX
XOR AX, AX
PRINT MSG1
LEA DX, PASS
MOV AH, 0AH; READ PASSWORD FROM KEYBOARD
INT 21H
MOV DI, DX
INC DI
MOV CL, BYTE PTR [DI]; LENGTH OF THE STRING IN CL REGISTER
MOV CH, 00
INC DI
LEA SI, NAM
CLD
BACK: CMPSB
JNE XX
LOOP BACK
PRINT MSG2
JMP XXY
XX: PRINT MSG3
XXY: MOV AH, 4CH
INT 21H
END START
34
(ii) By using 8086 kit:
ADDRESS OPCODE LABEL MNEMONICS COMMENTS
0000 E8,00,79 AGAIN: CALL CLRS Assign ASCII value for carriage
return
0003 E8,00,6F CALL POS Position The Cursor
0006 8C, C8 MOV AX,CS Initialize DS To Code Segment
0008 8E, D8 MOV DS,AX Copy The Content Of AX To
DS-Register
000A B4, 09 MOV AH,09H Load The Function Code IN
AH-register
000C BA, 04,50 MOV DX,450H Load address of string to display
in DX-register
000F CD, 21 INT 21H Call DOS service for display
0011 BE, 04,00 MOV SI,400H Initialize the pointer
0014 B9, 00,00 MOV CX,0000H Initialize count in CX-register as
zero.
0017 B4, 00 L1: MOV AH,00H Load the function code in AH.
0019 CD, 16 INT 16H Call BIOS to get keyboard
character in AL.
001B 3C,0D CMP AL,CR Compare the key code with
carriage return
001D 74,0C JE CHECK If equal go to CHECK
001F 88,04 MOV [SI],AL Store the keyboard character in
memory
0021 B4,02 MOV AH,02H Load the function code in AH.
0023 B2, 2A MOV DL, ‘*’ Load the ASCII value of ‘*’ in
DL
0025 CD,21 INT 21H Call DOS service for display
0027 46 INC SI Increment Pointer
0028 41 INC CX Increment the count
0029 EB,EC JMP L1 Jump to L1 to get next character
002B 83,F9,07 CHECK: CMP CX,0007H Compare count with 07H
002E 75,20 JNE REPEAT If count not equal to 07H then
goto repeat
0030 BE,04,00 MOV SI, 400H Initialize the pointers
0033 BF,05,00 MOV DI,500H Copy the value 500H to DI-reg
0036 8A,04 L2: MOV AL, [SI] Get a character of entered
password in AL-register
0038 3A,05 CMP AL,[DI] Compare entered character with
corresponding character of
stored password
003A 75,14 JNE REPEAT If not equal jump to repeat
003C 46 INC SI Increment the pointer
003D 47 INC DI Increment the DI-register
003E E2,F6 LOOP L2 Repeat comparison until counter
expires
0040 E8,00,79 CALL CLRS Clear the screen
0043 E8,00,6F CALL POS Position the cursor
0046 B4,09 MOV AX,09H Load the function code in AH-
register
004A BA,06,00 MOV DX,600H Load the address of String to
display in DX-register
004B CD,21 INT 21H Call DOS service for display
004D E9,06,0F JMP EXIT GO to EXIT.
35
0050 E8,00,79 REPEAT CALL CLRS Clear the screen
0053 E8,00,6F CALL POS Position the cursor
0056 B4,09 MOV AH,09H Load the function code in AH
0058 BA,05,50 MOV DX,550H Load the address of string to
display in DX-register
005B CD,21 INT 21H Call DOS service for display
005D B4,09 MOV AH,09H Load the function code in AH
005F BA,05,80 MOV DX,580H Load address of string to display
in DX
0062 CD,21 INT 21H Call DOS service for display
0064 B4,00 MOV AH,00H Load the function code in AH
0066 CD,16 INT 16H Call Bios service to get
keyboard
0068 3C,1B CMP AL,1BH Check for Esc key
006A 75,94 JNE AGAIN If key pressed is not esc, then go
to again
006C E9,06,0F JMP EXIT If key pressed is not esc, then go
to exit
006F B4,02 MOV AH,02H Load the function code in AH
0071 B7,00 MOV BH,00H Load the video page in BH
0073 BA,00,00 MOV DX,0000H Load the X and Y coordinate in
DL and DH.
0076 CD ,10 INT 10H Call Bios service for cursor
positioning
0078 C3 RET Return to main program
0079 POS ENDP End of procedure to position the
cursor
0079 CLRS PROC NEAR Start of procedure to clear the
screen.
0079 B4,07 MOV AH,07H Load the function code in AH
007B B0,00 MOV AL,00H Load number of lines to scroll
down in AL
007D B7 07 MOV BH,07H Load the blanked area attribute
in BL
007F B9 0000 MOV CX, 0000H Load the X and Y coordinates of
upper left corner in CL and CH
0082 BA 184F MOV DX,184FH Load the X and Y coordinates
of lower right corner in DL and
DH
0085 CD 10 INT 10H Call BIOS video service for
clearing screen.
0087 C3 RET Return to main program
0088 CLRS ENDP End of procedure to clear the
screen.
0450 ORG 450H
0450 45 4E 54 45 DB ‘ENTER THE
52 20 54 48 PASSWORD : ‘,’$’
45 20 50 41
53 53 57 4F
52 44 20
3A 20 24
0500 ORG 500H
0500 57 45 4C 43 DB ‘WELCOME’,’$’
4F 4D 45
24
36
0500 ORG 550H
0550 49 4E 43 4F DB ‘INCORRECT
52 52 45 43 PASSWORD. ‘,’$.
54 20 50 41
53 53 57 4F
52 44 2E 20
20 24
0580 ORG 580H
0580 50 52 45 53 DB ‘ PRESS ANY KEY
53 20 41 4E TO TRY AGAIN OR
59 20 4B 45 PRESS ESC TO EXIT
59 20 54 4F ‘,’$’
20 54 52 59
20 41 41 41
49 4E 20 4F
52 20 50 52
45 53 53 20
45 53 43 20
54 4F 20 45
58 49 54 20
24
0600 ORG 600H
0600 45 4E 54 52 DB ‘ENTRY
59 20 41 43 ACCEPTED’ ,’$’.
43 45 50 54
45 44 24
060F B4 4C EXIT MOV AH,4CH Load the function in AH
0611 CD 21 INT 21H Call DOS service to return to
command prompt.
0613 CODE ENDS Ends of code segment
END Assembly end
OUTPUT:
RESULT:
Thus an assembly language program for password checking using 8086 was implemented
and its output was verified.
37
Ex. No:5B PRINT RAM SIZE
AIM:
To write and execute an assembly language program to print the size of the file in RAM using
8086kit and MASM.
APPARATUS:
1. 8086 microprocessor kit/MASM ----1
2. Power card ----1
3. Keyboard ----1
4. PC with Intel/AMD Processor----1
PROGRAM:
i) By using MASM
PROMPT MACRO MESSAGE
PUSH AX
MOV AH, 09H
LEA DX, MESSAGE
INT 21H
POP AX
ENDM
DATA SEGMENT
MES DB 10, 13, 'THE SIZE OF CONVENTIONAL RAM MEMORY IS: $'
MES1 DB 'KBYTES$'
DATA ENDS
CODE SEGMENT
ASSUME CS: CODE
LEA DX, MES
INT 12H
CALL D_BCD
LEA DX, MES1
MOV AH, 4CH
INT 21H
D_BCD PROC NEAR
MOV CX, 00H
MOV BX, 10H
BACK1: MOV DX, 00H
DIV BX
PUSH DX
INC CX
OR AX, AX
JNZ BACK1
MOV AH, 02H
DISP: POP DX
ADD DL, 30H
INT 21H
LOOP DISP
RET
ENDP
CODE ENDS
END
RESULT:
Thus an assembly language program to print the size of the file in RAM using 8086 was
implemented and its output was verified.
38
Ex. No:5C SYSTEM DATE
AIM:
To write and execute an assembly language program for reading system date using 8086kit
and MASM.
APPARATUS:
1. 8086 microprocessor kit/MASM ----1
2. Power card ----1
3. Keyboard ----1
4. PC with Intel/AMD Processor----1
PROGRAM:
i) By using MASM
.MODEL SMALL
.DATA
.CODE
START: MOV AX,@DATA
MOV DS, AX
; Day Part
DAY: MOV AH, 2AH ; To get System Date
INT 21H
MOV AL, DL ; Day is in DL
AAM
MOV BX, AX
CALL DISP
MOV DL,'/'
MOV AH, 02H ; To Print / in DOS
INT 21H
; Month Part
MONTH: MOV AH, 2AH ; To get System Date
INT 21H
MOV AL, DH ; Month is in DH
AAM
MOV BX, AX
CALL DISP
MOV DL,'/' ; To Print / in DOS
MOV AH, 02H
INT 21H
; Year Part
YEAR: MOV AH, 2AH ; To get System Date
INT 21H
ADD CX, 0F830H; To negate the effects of 16bit value,
MOV AX, CX ; since AAM is applicable only for AL (YYYY -> YY)
AAM
MOV BX, AX
CALL DISP
39
; Display Part
DISP PROC
MOV DL, BH ; since the values are in BX, BH Part
ADD DL, 30H ; ASCII Adjustment
MOV AH, 02H ; To Print in DOS
INT 21H
MOV DL, BL ; BL Part
ADD DL, 30H ; ASCII Adjustment
MOV AH, 02H ; To Print in DOS
INT 21H
RET
DISP ENDP ; End Disp Procedure
END START ; End of MAIN
PROGRAM:
ADDRESS OPCODE LABEL MNEMONICS COMMENTS
1000 CALL CONVERT Call subroutine for conversion
1003 CALL DISPLAY Call subroutine for Display
1006 DELAY: MOV AL,0B0H Copy the data 0B0H to AL-reg
1009 OUT 16H,AL Configure output port
100B MOV CL,07H Copy the data 07H to AL-reg
100E S2: MOV AL,88H Copy 88H to AL-register
1011 OUT 14H,AL Configure output port
1013 MOV AL,80H Copy the data 80H to AL-reg
1016 OUT 14H,AL Configure output port
1018 S1: NOP No operation
1019 NOP No operation
101A NOP No operation
101B NOP No operation
101C IN AL,14H Copy 14H to AL-reg
101E MOV DL,AL Copy the Content of AL reg to
DL-reg.
1020 IN AL,14H Copy 14H to AL-reg
1022 OR AL,DL OR the contents of AL with DL
1024 JNZ S1 Jump on no zero to S1
1026 DEC CL Decrement CL-register
1028 JNZ S2 Jump on no zero to S2
102A MOV SI,1500H Copy SI-reg with data 1500H
102E MOV AL,[SI] Copy the content of SI-reg to AL
1030 INC AL Increment AL-register
1032 MOV [SI],AL Copy the content of AL reg to SI-
reg
1034 CMP AL,3CH Compare AL with 3CH
1037 JNZ START Jump on no zero to start
1039 MOV AL,00H Copy AL with data 00H
103C MOV [SI],AL Copy the content of Al to SI-reg
103E INC SI Increment SI-register
103F MOV AL,[SI] Copy the content of SI-reg to AL
1041 INC AL Increment AL-register
1043 MOV [SI],AL Copy the content of AL reg to SI-
40
reg
1045 CMP AL,3CH Compare AL with 3CH
1048 JNZ START Jump on no zero to start
104A MOV AL,0 Copy AL with data 00H
104D MOV [SI],AL Copy the content of AL reg to SI-
reg
104F INC SI Increment SI-register
1050 MOV AL,[SI] Copy the content of SI-reg to AL
1052 INC AL Increment AL-register
1054 MOV [SI],AL Copy the content of AL reg to SI-
reg
1056 CMP AL,18H Compare AL with 18H
1059 JNZ START Jump on no zero to start
105B MOV AL,0 Copy AL with data 00H
105E MOV [SI],AL Copy the content of AL reg to SI-
reg
1060 JMP START Jump to start
1063 DISPLAY: MOV AH,06H Copy 06H to AH-register
1066 MOV DX,1600H Copy 1600H to DX-register
106A MOV CH,01H Copy 01H to CH-register
106D MOV CL,0H Copy 00H to CL-register
1070 INT 5 Call Interrupt
1072 RET Return from subroutine
1073 CONVERT: MOV SI,1500H Copy 1500H to SI-register
1077 MOV BX,1608H Copy 1608H to BX-register
107B MOV AL,24H Copy 24H to AL-register
107E MOV [BX],AL Copy the content of AL-reg to BX
1080 MOV AL,[SI] Copy the content of SI-reg to AL
1082 MOV AH,0 Copy AL with data 00H
1085 MOV DH,0AH Copy the data 0AH to DH-register
1088 DIV DH Divide DH-reg by AH reg
108A ADD AH,30H Add the data 30H with AH-reg
108D DEC BX Decrement BX-register
108E MOV [BX],AH Copy the data from AH to DH-
reg
1090 DEC BX Decrement BX-register
1091 ADD AL,30H Add the data 30H with AL-reg
1094 MOV [BX],AL Copy the data from AL to BX-reg
1096 DEC BX Decrement BX-register
1097 MOV AL,3AH Copy the 3AH to AL-reg
109A MOV [BX],AL Copy the data from AL to BX-reg
109C DEC BX Decrement BX-register
109D INC SI Increment SI-register
109E MOV AL,[SI] Copy the content of SI-reg to AL
10A0 MOV AH,0 Copy the data 0 to AH-reg
10A3 MOV DH,0AH Copy the data 0AH to DH-register
10A6 DIV DH Divide DH-reg by AH reg
10A8 ADD AH,30H Add the data 30H with AH-reg
41
10AB MOV [BX],AH Copy the data from AH to BX-
reg
10AD DEC BX Decrement BX-register
10AE ADD AL,30H Add the data 30H with AL-reg
10B1 MOV [BX],AL Copy the data from AL to BX-reg
10B3 DEC BX Decrement BX-register
10B4 MOV AL,3AH Copy the 3AH to AL-reg
10B7 MOV [BX],AL Copy the data from AL to BX-reg
10B9 DEC BX Decrement BX-register
10BA INC SI Increment SI-register
10BB MOV AL,[SI] Copy the content of SI-reg to AL
10BD MOV AH,0 Copy the data 0 to AH-reg
10C0 MOV DH,0AH Copy the data 0AH to DH-register
10C3 DIV DH Divide DH-reg by AH reg
10C5 ADD AH,30H Add the data 30H with AH-reg
10C8 MOV [BX],AH Copy the data from AH to BX-
reg
10CA DEC BX Decrement BX-register
10CB ADD AL,30H Add the data 30H with AL-reg
10CE MOV [BX],AL Copy the data from AL to BX-reg
10D0 RET Return from subroutine
10D1 GETC: IN AL,02H Copy 02H to AL-reg
10D3 AND AL,0FFH AND data AL with 0FFH
10D6 CMP AL,0F0H Compare AL with 0F0H
10D9 JNE GETC If no zero jump to getc
OUTPUT:
1500- 99 YEAR
1501- 09 MONTH
1502- 09 DATE
VIVA QUESTIONS:
RESULT:
Thus an assembly language program for reading system date using 8086 was implemented
and its output was verified.
42
Ex. No:6 COUNTERS AND TIME DELAY
AIM:
To write and execute an assembly language program for creating time delay using counters in
8086kit and MASM.
APPARATUS:
1. 8086 microprocessor kit/MASM ----1
2. Power card ----1
3. Keyboard ----1
4. PC with Intel/AMD Processor----1
PROGRAM:
i) By using MASM
.MODEL SMALL
.DATA
MSGIN DB 'Enter delay duration (0-50): $'
MSG1 DB 'This is Microprocessor!$'
DELAYTIME DW 0000H
.CODE
MOV DX,@DATA
MOV DS, DX
LEA DX, MSGIN
MOV AH, 09H
INT 21H
IN1: MOV AH, 01H
INT 21H
CMP AL, 0DH ;
JE NXT
SUB AL, 30H
MOV DL, AL
MOV AX, BX
MOV CL, 0AH
MUL CL
MOV BX, AX
AND DX, 00FFH
ADD BX, DX
MOV DELAYTIME, BX
LOOP IN1
NXT: MOV CX, DELAYTIME
MOV DL, 10
MOV AH, 02H
INT 21H
LEA SI, MSG1
LP: PUSH DX
MOV DL, [SI]
CMP DL,'$'
JE NXT2
MOV AH, 02H
INT 21H
ADD SI, 1
POP DX
MOV DI, DELAYTIME
MOV AH, 0
INT 1Ah
43
MOV BX, DX
Delay: MOV AH, 0
INT 1Ah
SUB DX, BX
CMP DI, DX
JA Delay
LOOP LP
NXT2: MOV AH, 4CH
INT 21H
END
OUTPUT:
WAVEFORM GENERATION
WAVEFORMS AMPLITUDE TIME PERIOD
Square wave 10v 1ms
VIVA QUESTIONS:
RESULT:
Thus an assembly language program for creating time delay using counters in 8086 was
implemented and its output was verified.
44
INTERFACING EXPERIMENTS
45
Ex. No: 7 TRAFFIC LIGHT CONTROL
AIM:
To write and execute an assembly language Program for interfacing the Traffic Light
Controller in 8086 kit.
APPARATUS:
1. 8086 microprocessor kit/MASM ----1
2. Traffic Light Controller Interface board ----1
3. Power card ----1
4. Keyboard ----1
5. PC with Intel/AMD Processor----1
PROGRAM:
ADDRESS OPCODE LABEL MNEMONICS COMMENTS
1000 B0,80 START: MOV AL,80H Move 80 to AL-register
1002 E6,26 OUT CONTROL,AL Copy the AL-reg content to
output port.
1004 BB 6B 10 REPEAT: MOV BX, LOOKUP Copy the lookup data value
to BX-register
1007 BE 77 10 MOV SI, LABEL Copy the direction of rotation
value to SI-reg.
100A E8 32 00 CALL OUT Call to OUT port
100D 8A 04 MOV AL, [SI] Copy the contents of SI-reg
to Al-register
100F E6 20 OUT PORTA, AL Move the AL-reg value to
PORTA
1011 E8 4A 00 CALL DELAY1 Call Delay program
1014 46 INC SI Increment SI-register
1015 43 INC BX Increment BX-register
1016 E8 26 00 CALL OUT Call to OUT port
1019 8A 04 MOV AL, [SI] Copy the contents of SI-reg
to Al-register
101B E6 22 OUT PORTB, AL Move the AL-reg value to
PORTB
101D E8 3E 00 CALL DELAY1 Call Delay program
1020 46 INC SI Increment SI-register
1021 43 INC BX Increment BX-register
1022 E8 1A 00 CALL OUT Call to OUT port
1025 8A 04 MOV AL, [SI] Copy the contents of SI-reg
to Al-register
1027 E6 24 OUT PORTC, AL Move the AL-reg value to
PORTC
1029 E8 32 00 CALL DELAY1 Call Delay program
102C 46 INC SI Increment SI-register
102D 43 INC BX Increment BX-register
102E E8 0E 00 CALL OUT Call to OUT port
1031 8A 04 MOV AL, [SI] Copy the contents of SI-reg
to Al-register
1033 E6 24 OUT PORTC, AL Move the AL-reg value to
PORTC
1035 46 INC SI Increment SI-register
1036 8A 04 MOV AL, [SI] Copy the contents of SI-reg
to Al-register
1038 E6 20 OUT PORTC, AL Move the AL-reg value to
46
PORTC
103A E8 21 00 CALL DELAY1 Call Delay program
103D EB C5 JMP REPEAT Jump to label REPEAT
103F 8A 07 OUT: MOV AL, [BX] Copy the content of BX to
AL-register
1041 E6 24 OUT PORTC, AL Move the AL-reg value to
PORTC
1043 43 INC BX Increment BX-register
1044 8A 07 MOV AL, [BX] Copy the content of BX to
AL-register
1046 E6 22 OUT PORTB, AL Move the AL-reg value to
PORTB
1048 43 INC BX Increment BX-register
1049 8A 07 MOV AL, [BX] Copy the content of BX to
AL-register
104B E6 20 OUT PORTA, AL Move the AL-reg value to
PORTA
104D E8 01 00 CALL DELAY Call Delay program
1050 C3 RET Return from subroutine
1051 BF 40 00 DELAY: MOV DI, 00040H Move 40h to DI-register
1054 BA FF FF A: MOV DX, 0FFFFH Move 0FFFFh to DX-register
1057 4A A1: DEC DX Decrement DX-register
1058 75 FD JNZ A1 Jump on no zero to A1.
105A 4F DEC D1 Decrement D1-register
105B 75 F6 JNZ A Jump on no zero to A
105D C3 RET
105E BF 15 00 DELAY1: MOV DI, 00015H Move 15h to DI-register
1061 BA FF FF B: MOV DX, 0FFFH Move 0FFFh to DX-register
1064 4A B1: DEC DX Decrement DX-register
1065 75 FD JNZ B1 Jump on no zero to B1
1067 4F DEC D1 Decrement D1-register
1068 75 F6 JNZ B Jump on no zero to B
106A C3 RET
106B 12 27 44 10 LOOKUP: DB 12H,27H,44H,10H
106F 2B 92 109D 2BH,92H,10H,9DH
1073 84 48 2E 84 84H,48H,2EH,84H
1077 48 4B 20 49 LABEL: DB 48H,4BH,20H,49H
107B 04 04H For traffic light control.
107C END
VIVA QUESTIONS:
1. Which Segment is used to store interrupt and subroutine return address registers?
2. What is the difference between instructions RET & IRET?
3. What .model small means?
4. Difference between small, medium, tiny, huge?
5. What is dd, dw, db?
6. What is the function of 01h of Int 21h?
7. What is the function of 02h of Int 21h?
8. What is the function of 09h of Int 21h?
9. What is the function of 0Ah of Int 21h?
10. What is the function of 4ch of Int 21h?
RESULT:
Thus the assembly language program for interfacing the traffic light controller was
implemented in 8086 kit.
47
Ex. No:8 STEPPER MOTOR INTERFACING
AIM:
To write and execute an assembly language Program to run a stepper motor at different
speed, and to control its speed of direction.
APPARATUS:
1. 8086 microprocessor kit/MASM ----1
2. Stepper Motor ----1
3. Stepper Motor Interface board ----1
4. Power card ----1
5. Keyboard ----1
6. PC with Intel/AMD Processor----1
PROGRAM:
1000 C7,C7,18,10 Ahead MOV DI, 1018 Copy the data 1018 to DI-reg
1007 8A, 05 Loop1 MOV AL, [DI] Copy the content of DI-reg to
AL-register
1009 E6 , C0 OUT C0, AL The content of AL is moved to
Out port
100B C7,C2,10,10 MOV DX, 1010 Copy the data 1010 to DX-reg
100F 4A loop DEC DX Decrement DX-register
1010 75,FD JNZ loop Jump on no zero to loop
1012 47 INC DI Increment DI-register
1013 E2,F2 LOOP loop1 Loop to label loop1
1015 E9,E8, FF JMP Ahead Jump to ahead
1018 09,05,06,0A TABLE 09 05 06 0A
HLT Stop the program.
PROGRAM:
ADDRESS OPCODE LABEL MNEMONICS COMMENTS
1003 C7,C7,3F,10 MOV DI, 103F Copy the data 103F to DI-reg
48
1018 E8 0A 00 CALL 1025 Call subroutine program
101B FE CB DEC BL Decrement BL-register
101D 75 75 JNZ 1014 Jump on no zero to 1014
101F E8 19 00 CALL 103B Call subroutine program
1022 E9 DB FF JMP 1000 Jump to label 1000
1025 C6 C1 04 MOV CL, 04 Copy the data 04 to CL-register
1028 8A 05 MOV AL, [DI] Copy the content of DI to AL-
register
102A E6 C0 OUT C0, AL Assign the content of AL to
Output
102C C7 C2 10 MOV DX, 1010 Copy the content 1010 to Dx-
10 register
1030 4A DEC DX Decrement DX-register
1031 75 FD JNZ 1030 Jump on no zero to label 1030
1033 47 INC DI Increment DI-register
1034 E2 F2 LOOP 1028 Loop to label 1028
1036 C3 RET Return from subroutine
1037 C7,C2,FF,FF MOV DX, 0FFFF Copy FFFF in DX-register
103B 4A DEC DX Decrement DX-register
103C 75 FD JNZ 103B Jump on no zero 103B
103E C3 RET Return from subroutine
103F 09,05,06,0A FORWARD DATA To rotate in forward direction
1043 0A,06,05, 09 REVERSE DATA To rotate in Reverse direction
VIVA QUESTIONS:
RESULT:
Thus an assembly language Program to run the stepper motor in both forward and reverse
direction with delay was executed and its output was verified.
49
Ex. No: 9 DIGITAL CLOCK
AIM:
To write and execute an assembly language Program for digital clock in 8086 kit.
APPARATUS:
1. 8086 microprocessor kit/MASM ----1
2. Traffic Light Controller Interface board ----1
3. Power card ----1
4. Keyboard ----1
5. PC with Intel/AMD Processor----1
PROGRAM:
ADDRESS OPCODE LABEL MNEMONICS COMMENTS
1000 CALL CONVERT Call subroutine for conversion
1003 CALL DISPLAY Call subroutine for Display
1006 DELAY: MOV AL,0B0H Copy the data 0B0H to AL-reg
1009 OUT 16H,AL Configure output port
100B MOV CL,07H Copy the data 07H to AL-reg
100E S2: MOV AL,88H Copy 88H to AL-register
1011 OUT 14H,AL Configure output port
1013 MOV AL,80H Copy the data 80H to AL-reg
1016 OUT 14H,AL Configure output port
1018 S1: NOP No operation
1019 NOP No operation
101A NOP No operation
101B NOP No operation
101C IN AL,14H Copy 14H to AL-reg
101E MOV DL,AL Copy the Content of AL reg to
DL-reg.
1020 IN AL,14H Copy 14H to AL-reg
1022 OR AL,DL OR the contents of AL with DL
1024 JNZ S1 Jump on no zero to S1
1026 DEC CL Decrement CL-register
1028 JNZ S2 Jump on no zero to S2
102A MOV SI,1500H Copy SI-reg with data 1500H
102E MOV AL,[SI] Copy the content of SI-reg to AL
1030 INC AL Increment AL-register
1032 MOV [SI],AL Copy the content of AL reg to SI-
reg
1034 CMP AL,3CH Compare AL with 3CH
1037 JNZ START Jump on no zero to start
1039 MOV AL,00H Copy AL with data 00H
103C MOV [SI],AL Copy the content of Al to SI-reg
103E INC SI Increment SI-register
103F MOV AL,[SI] Copy the content of SI-reg to AL
1041 INC AL Increment AL-register
1043 MOV [SI],AL Copy the content of AL reg to SI-
reg
1045 CMP AL,3CH Compare AL with 3CH
50
1048 JNZ START Jump on no zero to start
104A MOV AL,0 Copy AL with data 00H
104D MOV [SI],AL Copy the content of AL reg to SI-
reg
104F INC SI Increment SI-register
1050 MOV AL,[SI] Copy the content of SI-reg to AL
1052 INC AL Increment AL-register
1054 MOV [SI],AL Copy the content of AL reg to SI-
reg
1056 CMP AL,18H Compare AL with 18H
1059 JNZ START Jump on no zero to start
105B MOV AL,0 Copy AL with data 00H
105E MOV [SI],AL Copy the content of AL reg to SI-
reg
1060 JMP START Jump to start
1063 DISPLAY: MOV AH,06H Copy 06H to AH-register
1066 MOV DX,1600H Copy 1600H to DX-register
106A MOV CH,01H Copy 01H to CH-register
106D MOV CL,0H Copy 00H to CL-register
1070 INT 5 Call Interrupt
1072 RET Return from subroutine
1073 CONVERT: MOV SI,1500H Copy 1500H to SI-register
1077 MOV BX,1608H Copy 1608H to BX-register
107B MOV AL,24H Copy 24H to AL-register
107E MOV [BX],AL Copy the content of AL-reg to BX
1080 MOV AL,[SI] Copy the content of SI-reg to AL
1082 MOV AH,0 Copy AL with data 00H
1085 MOV DH,0AH Copy the data 0AH to DH-register
1088 DIV DH Divide DH-reg by AH reg
108A ADD AH,30H Add the data 30H with AH-reg
108D DEC BX Decrement BX-register
108E MOV [BX],AH Copy the data from AH to DH-
reg
1090 DEC BX Decrement BX-register
1091 ADD AL,30H Add the data 30H with AL-reg
1094 MOV [BX],AL Copy the data from AL to BX-reg
1096 DEC BX Decrement BX-register
1097 MOV AL,3AH Copy the 3AH to AL-reg
109A MOV [BX],AL Copy the data from AL to BX-reg
109C DEC BX Decrement BX-register
109D INC SI Increment SI-register
109E MOV AL,[SI] Copy the content of SI-reg to AL
10A0 MOV AH,0 Copy the data 0 to AH-reg
10A3 MOV DH,0AH Copy the data 0AH to DH-register
10A6 DIV DH Divide DH-reg by AH reg
10A8 ADD AH,30H Add the data 30H with AH-reg
10AB MOV [BX],AH Copy the data from AH to BX-
reg
51
10AD DEC BX Decrement BX-register
10AE ADD AL,30H Add the data 30H with AL-reg
10B1 MOV [BX],AL Copy the data from AL to BX-reg
10B3 DEC BX Decrement BX-register
10B4 MOV AL,3AH Copy the 3AH to AL-reg
10B7 MOV [BX],AL Copy the data from AL to BX-reg
10B9 DEC BX Decrement BX-register
10BA INC SI Increment SI-register
10BB MOV AL,[SI] Copy the content of SI-reg to AL
10BD MOV AH,0 Copy the data 0 to AH-reg
10C0 MOV DH,0AH Copy the data 0AH to DH-register
10C3 DIV DH Divide DH-reg by AH reg
10C5 ADD AH,30H Add the data 30H with AH-reg
10C8 MOV [BX],AH Copy the data from AH to BX-
reg
10CA DEC BX Decrement BX-register
10CB ADD AL,30H Add the data 30H with AL-reg
10CE MOV [BX],AL Copy the data from AL to BX-reg
10D0 RET Return from subroutine
10D1 GETC: IN AL,02H Copy 02H to AL-reg
10D3 AND AL,0FFH AND data AL with 0FFH
10D6 CMP AL,0F0H Compare AL with 0F0H
10D9 JNE GETC If no zero jump to getc
OUTPUT:
1500- 00 SECONDS
1501- 00 MINUTES
1502- 09 HOURS
VIVA QUESTIONS:
RESULT:
Thus an assembly language Program for digital clock in 8086 kit was written and executed.
52
Ex. No:10 KEYBOARD AND DISPLAY
AIM:
To write and execute an assembly language Program to display the rolling message “HELP
US “in the display.
APPARATUS:
1. 8086 microprocessor kit/MASM ----1
2. 8279 Interface board ----1
4. Power card ----1
5. Keyboard ----1
6. PC with Intel/AMD Processor----1
ALGORITHM:
Display of rolling message “HELP US “
1. Initialize the counter
2. Set 8279 for 8 digit character display, right entry
3. Set 8279 for clearing the display
4. Write the command to display
5. Load the character into accumulator and display it
6. Introduce the delay
7. Repeat from step 1.
53
LOOK-UP TABLE:
1200 98 68 7C C8
1204 FF 1C 29 FF
OUTPUT:
VIVA QUESTIONS:
RESULT:
Thus the rolling message “HELP US” is displayed using 8279 interface kit.
54
Ex. No:11 PRINTER INTERFACE
AIM:
To write and execute an assembly language program for printer interface with
microprocessor 8086 kit and to print a single character “A”.
APPARATUS REQUIRED:
PROGRAM:
00C8 DATA EQU 00C8H
00D0 CONTL EQU 00D0H
00C0 STUS EQU 00C0H
VIVA QUESTIONS:
RESULT:
Thus an assembly language program for printer interface to print a single character “A”
was performed and its output was verified.
55
Ex. No:12A SERIAL INTERFACE
AIM:
To write and execute assembly language program to establish serial communication
between two 8086 kits.
APPARATUS REQUIRED:
1. 8086 microprocessor kit/MASM ----2
2. Power card ----1
3. Keyboard ----1
4. PC with Intel/AMD Processor----1
ALGORITHM:
1. Initialize 8253 and 8251 to check the transmission and reception of a character
2. Initialize8253 to give an output of 150 KHz at channel 0 which will give a 9600 baud rate
of 8251.
3. The command word and mode word is written to the 8251 to set up for subsequent operations
4. The status word is read from the 8251 on completion of a serial I/O operation, or when the
host CPU is checking the status of the device before starting the next I/O operation
PROGRAM:
TRANSMITTER END:
56
ADDRESS OPCODE LABEL MNEMONICS COMMENTS
1000 C7,C6,00,1 MOV SI,1500H Initialize Si-register with address 1500H
5
1004 C6,C0,36 MOV AL,36H Copy 36H data to AL-register
1007 E6,16 OUT 16H,AL Configure output port
1009 C6,C0,40 MOV AL,40H Copy the data 40H to AL-register
100C E6,10 OUT 10H,AL Configure output port
100E C6,C0,01 MOV AL,01H Copy 01H data to AL-register
1011 E6,10 OUT 10H,AL Configure output port
1013 C6,C1,05 RELOAD: MOV CL,05H Count value for number of data’s
1016 E4,0A CHECK: IN AL,0AH Configure input port to transmit data
1018 80,E0,02 AND AL,02H AND the contents of AL-reg with 02H
101B 74,F9 JZ CHECK If zero Jump to Label Check
101D E4,08 MOV AL,[SI] Copy the content of SI-reg to AL-register
101F 88,04 OUT 08H,AL Configure output port
1021 46 INC SI Increment SI-register
1022 80,F8,3F CMP AL,3FH Compare AL-reg with 3FH data
1025 75,EC JNZ RELOAD If no zero jump to label reload
1027 FE,C9 DEC CL Decrement CL-register
1029 75,EB JNZ CHECK If CL not zero jump to label Check
102B CD,02 INT 02 Call interrupt routine
RECEIVER END:
OUTPUT:
RESULT:
Thus an assembly language program to establish a serial communication between two 8086
kits was implemented and its output was verified.
57
Ex. No: 12B PARALLEL INTERFACE
AIM:
To write and execute assembly language program to establish parallel communication
between two 8086 kits.
APPARATUS REQUIRED:
1. 8086 microprocessor kit/MASM ----1
2. Power card ----1
3. Keyboard ----1
4. PC with Intel/AMD Processor----1
ALGORITHM:
1. Initialize accumulator to hold control word
2. store control word in control word register
3. Read data port A.
4. Store data from port A in memory
5. Place contents in port B
PROGRAM:
TRANSMITTER:
ADDRESS OPCODE LABEL PROGRAM COMMENTS
1000 C6, C0,82 MOV AL,82H Copy 82H to AL-register
1003 E6,26 OUT 26H,AL Configure output port
1005 C6,C0,3F MOV AL,3FH Copy 3F to AL-register
1008 E6,20 OUT 20H,AL Configure output port
100a E4,22 Loop: IN AL,22H Configure AL-register
100c 80,E8,3f SUB AL,3FH Subtract 3F from AL-register
100f 75,F9 JNZ LOOP Jump on no zero to loop
1011 C6,C0,24 MOV AL,24H Copy 24H to AL-register
1014 E6,20 OUT 20H,AL Configure output port
1016 E8,02,00 CALL DELAY Call delay program
1019 CD,02 INT 02 Call interrupt routine
101b C6,C3,05 Delay: MOV BL,05H Copy 05H to BL-register
101e C6,C2,FF Lion: MOV DL,0FFH Copy FFH to DL-register
1021 FE,CA L2: DEC DL Decrement DL-register
1023 75,F9 JNZ L2 Jump on no zero to Label L2
1025 FE,CB DEC BL Decrement BL-register
1027 75,F5 JNZ LION Jump on no zero to lion
1029 C3 RET Return from subroutine
RECEIVER:
ADDRESS OPCODE LABEL PROGRAM COMMENTS
1000 C6 C0 90 MOV AL,90H Copy 90H to AL-register
1003 E6 26 OUT 26H,AL Configure output port
58
100C C6 C0 3F MOV AL,3FH Copy 3FH to AL-register
OUTPUT:
VIVA QUESTIONS:
1. What is Baud rate?
2. What is the difference between synchronous and asynchronous communication?
3. What is the expansion of RS?
4. What is the expansion of USART?
5. What is the role of RS-232?
6. What type of interface is 8255?
7. What are the different types of modes in 8255?
8. What are the features of mode 0 in 8255?
9. What are the features of mode 1 in 8255?
10. What are the features of mode 2 in 8255?
RESULT:
59
Ex. No: 13A INTERFACING ANALOG TO DIGITAL CONVERTER
AIM:
To write and execute an assembly language program to convert an analog signal into a digital
signal using an ADC interfacing.
APPARATUS REQUIRED:
1. 8086 microprocessor kit/MASM ----1
2. ADC Interface board ----1
4. Power card ----1
5. Keyboard ----1
6. PC with Intel/AMD Processor----1
ALGORITHM:
(i) Select the channel and latch the address.
(ii) Send the start conversion pulse.
(iii) Read EOC signal.
(iv) If EOC = 1 continue else go to step (iii)
(v) Read the digital output.
(vi) Store it in a memory location.
PROGRAM:
ADDRESS OPCODE LABEL PROGRAM COMMENTS
60
1024 F4 HLT Stop
OUTPUT:
RESULT:
Thus the ADC was interfaced with 8086 and the given analog inputs were converted
into its digital equivalent.
61
Ex. No: 13B INTERFACING DIGITAL TO ANALOG CONVERTER
AIM:
To write and execute an assembly language program for digital to analog conversion.
APPARATUS REQUIRED:
1. 8086 microprocessor kit/MASM ----1
2. DAC Interface board ----1
3. Power card ----1
4. Keyboard ----1
5. PC with Intel/AMD Processor----1
ALGORITHM:
Square Waveform:
(i) Send low value (00) to the DAC.
(ii) Introduce suitable delay.
(iii) Send high value to DAC.
(iv) Introduce delay.
(v) Repeat the above procedure.
Saw-tooth waveform:
(i) Load low value (00) to accumulator.
(ii) Send this value to DAC.
(iii) Increment the accumulator.
(iv) Repeat step (ii) and (iii) until accumulator value reaches FF.
(v) Repeat the above procedure from step 1.
Triangular waveform:
(i) Load the low value (00) in accumulator.
(ii) Send this accumulator content to DAC.
(iii) Increment the accumulator.
(iv) Repeat step 2 and 3 until the accumulator reaches FF, decrement the
accumulator and send the accumulator contents to DAC.
(v) Decrementing and sending the accumulator contents to DAC.
(vi) The above procedure is repeated from step (i)
62
PROGRAM: SAWTOOTH WAVE
ADDRESS OPCODE LABEL PROGRAM COMMENTS
1000 B0 00 L2 MOV AL,00H Load 00 in accumulator
1002 E6 C0 L1 OUT C0,AL Send through output port
1004 FE C0 INC AL Increment contents of
accumulator
1006 75 FA JNZ L1 Send through output port
until it reaches FF
1008 EB F6 JMP L2 Go to starting location
OUTPUT:
WAVEFORM GENERATION
WAVEFORMS AMPLITUDE TIME PERIOD
Square wave 10v 1ms
Saw-tooth wave 10v 1.4ms
Triangular wave 10v 3.2ms
VIVA QUESTIONS:
1. What are the different types of ADC?
2. What is meant by conversion time?
3. What are the different types of ADC techniques available?
4. Name the ADC IC available using serial interface technique?
5. Name the ADC IC available using parallel interface technique?
6. What are the different types of DAC techniques available?
7. Name the DAC IC available
8. What is resolution?
9. What is settling time?
10. What is range of operation in DAC?
RESULT:
Thus the DAC was interfaced with 8086 and different waveforms have been generated.
63
8051 MICROCONTROLLER
64
Ex. No: 14A ARITHMETIC OPERATIONS USING 8051
AIM:
To write and execute an assembly language program for Add, subtract, multiply and division of
two 8-bit numbers using 8051.
APPARATUS:
1. 8051 microcontroller kit ----1
2. Power card ----1
3. Keyboard ----1
4. PC with Intel/AMD Processor----1
ALGORITHM:
1. Load the First Data in A-register.
2. Load the Second Data in B-register.
3. Add the two data with carry.
4. Store the sum in memory location.
5. Stop the program.
PROGRAM:
ADDRESS OPCODE LABEL PROGRAM COMMENTS
4100 74,05 MOV A,#data Load data 1 in accumulator.
4102 75,F0,05 MOV B,#data Load data 2 in B-register
4105 35,F0 ADDC A,B Add the contents of
accumulator and B-reg with
carry.
4107 90,45,00 MOV DPTR,#4500H Initialize DPTR with
address 4500H
410A F0 MOVX @ DPTR,A Store the result in 4500H
410B 80, FE STOP: SJMP STOP Stop the program
OUTPUT:
INPUT OUTPUT
Register Data Address Data
A-register 02H 4500 06H
B-register 04H
SUBTRACTION
ALGORITHM:
1. Load the First Data in A-register.
2. Load the Second Data in B-register.
3. Subtract the two data with borrow.
4. Store the sum in memory location.
5. Stop the program.
PROGRAM:
ADDRESS OPCODE LABEL PROGRAM COMMENTS
4100 74,05 MOV A,#data Load data 1 in accumulator.
4102 75,F0,04 MOV B,#data Load data 2 in B-register
4105 95,F0 SUBB A,B Subtract the contents of B-
65
reg from accumulator with
borrow.
4107 90 45 00 MOV DPTR,#4500H Initialize DPTR with
address 4500H
410A F0 MOVX @ DPTR,A Store the result in 4500H
410B 80, FE STOP: SJMP STOP Stop the program
OUTPUT:
INPUT OUTPUT
Register Data Address Data
A-register 05H 4500 04H
B-register 01H
MULTIPLICATION
ALGORITHM:
1. Get the multiplier in the accumulator.
2. Get the multiplicand in the B register.
3. Multiply A with B.
4. Store the product in memory location.
5. Stop the program.
PROGRAM:
OUTPUT:
INPUT OUTPUT
REGISTER DATA ADDRESS DATA
A 5 4500 19H
B 5
66
DIVISION
ALGORITHM:
1. Get the Dividend in the accumulator.
2. Get the Divisor in the B register.
3. Divide A by B.
4. Store the Quotient and Remainder in memory.
5. Stop the program.
PROGRAM:
ADDRESS OPCODE LABEL PROGRAM COMMENTS
OUTPUT:
INPUT OUTPUT
REGISTER DATA ADDRESS DATA
A-Register 05 4500 01(quotient)
B-Register 03 4501 02(remainder)
RESULT:
Thus an assembly language program for Division of two 8-bit numbers and 16-bit numbers
using 8051 was performed and its output was verified.
67
Ex. No: 14B LOGICAL OPERATIONS USING 8051
AIM:
To write and execute an assembly language program to perform logical operations using 8051.
APPARATUS:
1. 8051 microcontroller kit ----1
2. Power card ----1
3. Keyboard ----1
4. PC with Intel/AMD Processor----1
ALGORITHM:
1. Get the Data 1 in the R0-register.
2. Get the Data 2 in the A register.
3. Logical AND, OR, XOR A with R0.
4. Store the result in memory.
5. Stop the program.
OUTPUT:
INPUT OUTPUT
REGISTER DATA ADDRESS DATA
R0-Register 14 4500 10
A-Register 12
PROGRAM: OR OPERATION
68
OUTPUT:
INPUT OUTPUT
REGISTER DATA ADDRESS DATA
R0-Register 14 4500 16
A-Register 12
OUTPUT:
INPUT OUTPUT
REGISTER DATA ADDRESS DATA
R0-Register 14 4500 06
A-Register 12
VIVA QUESTIONS:
RESULT:
Thus an assembly language program for logical operations using 8051 was performed and its
output was verified.
69
Ex. No: 15 SQUARE OF A NUMBER USING 8051
AIM:
To write and execute an assembly language program to find the square, cube and 2’s
complement of a number using 8051.
APPARATUS:
1. 8051 microcontroller kit ----1
2. Power card ----1
3. Keyboard ----1
4. PC with Intel/AMD Processor----1
ALGORITHM:
1. Get the Data in the R0-register.
2. Get the same Data in the B register.
3. Multiply A and B.
4. Store the result in memory.
5. Stop the program.
PROGRAM:
ADDRESS OPCODE LABEL PROGRAM COMMENTS
OUTPUT:
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
4200 FF 4201 01
4202 FE
70
CUBE OF A NUMBER USING 8051
ALGORITHM:
1. Get the Data in the R0-register.
2. Get the same Data in the B register.
3. Multiply A and B.
4. Store the result in memory.
5. Stop the program.
PROGRAM:
ADDRESS OPCODE LABEL PROGRAM COMMENTS
4100 90 42 00 MOV DPTR,#4200H Initialize data pointer with
address 4200H
4103 E0 MOVX A,@DPTR Copy the content of data from
address 4200H to accumulator
4104 F8 MOV R0,A Copy the content of data from
A-reg to R0-register.
4105 F5,F0 MOV B,A Copy the content of data from
A-reg to B-register.
4107 A4 MUL AB Multiply AB
4108 C0,F0 PUSH B Store the content of B-reg in
stack
410A F5,F0 MOV B,A Copy the content of data from
A-reg to B-register.
410C E8 MOV A,R0 Copy the content of data from
R0-reg to accumulator
410D A4 MUL AB Multiply AB
410E A3 INC DPTR Increment data pointer to store
the result
410F F0 MOVX @DPTR,A Copy the content of data from
address 4201H to accumulator
4110 AA,F0 MOV R2,B Copy the content of data from
R2-reg to B-register
4112 D0,F0 POP B Retrieve the data from stack
4114 E8 MOV A,R0 Copy the content of data from
R0-reg to accumulator
4115 A4 MUL AB Multiply AB
4116 2A ADD A,R2 Add the contents of A and R2
register and store the data in
A-reg.
4117 A3 INC DPTR Increment data pointer to store
the result
4118 F0 MOVX @ DPTR,A Store the result in 4500H
4119 E5,F0 MOV A,B Copy the content of data from
B-reg to A-register.
411B A3 INC DPTR Increment data pointer to store
the result
71
411C F0 MOVX @DPTR,A Copy the content of data from
address 4202H to accumulator
411D 80, FE STOP: SJMP STOP Stop the program
OUTPUT:
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
4200 56 4201 98
4202 B4
4203 09
PROGRAM:
OUTPUT:
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
4200 05 4201 0BH
72
VIVA QUESTIONS:
RESULT:
Thus an assembly language program to find square, cube and 2’s complement of a number
using 8051 was performed and its output was verified.
73
EXP. NO: 16 UNPACKED BCD TO ASCII USING 8051
AIM:
To write and execute an assembly language program to convert unpacked BCD to ASCII using
8051.
APPARATUS:
1. 8051 microcontroller kit ----1
2. Power card ----1
3. Keyboard ----1
4. PC with Intel/AMD Processor----1
ALGORITHM:
1. Get the Data in the R0-register.
2. Get the same Data in the B register.
3. Multiply A and B.
4. Store the result in memory.
5. Stop the program.
PROGRAM:
ADDRESS OPCODE LABEL PROGRAM COMMENTS
4100 90 42 00 MOV DPTR,#4200H Initialize data pointer with
address 4200H
4103 E0 MOVX A,@DPTR Copy the content of data from
address 4200H to accumulator
4104 F5,F0 MOV B,A Copy the content of data from
A-reg to B-register.
4106 55,0F ANL A, 0FH AND the contents of A-reg
with 0F and store the data in A-
register.
4108 44,30 ORL A,#30H Add the contents of
Accumulator and 30 data and
store the data in A-reg.
410A A3 INC DPTR Increment data pointer to store
the result
410B F0 MOVX @DPTR,A Copy the content of data from
address 4201H to accumulator
410C E5,F0 MOV A,B Copy the content of data from
B-reg to A-register.
410E 55,F0 ANL A,F0H AND the contents of A-reg
with F0 and store the data in A-
register
4110 03 RR A Rotate right accumulator
4111 03 RR A Rotate right accumulator
4112 03 RR A Rotate right accumulator
4113 03 RR A Rotate right accumulator
4114 44,30 ORL A,#30H Add the contents of
Accumulator and 30 data and
store the data in A-reg.
74
4116 A3 INC DPTR Increment data pointer to store
the result
4117 F0 MOVX @DPTR,A Copy the content of data from
address 4201H to accumulator
4118 80, FE STOP: SJMP STOP Stop the program
OUTPUT:
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
4200 29 4201 39
4202 32
VIVA QUESTIONS:
RESULT:
Thus an assembly language program for conversion of Unpacked BCD to ASCII number
using 8051 was performed and its output was verified.
75