MP LAB Cse Manual
MP LAB Cse Manual
MP LAB Cse Manual
MICROPROCESSOR
16-BITADDITION & SUBTRACTION
EX NO:
DATE:
AIM:
To write an Assembly Language Program (ALP) to perform16-bit addition and
subtraction using 8086 microprocessor.
APPARATUS REQUIRED:
ALGORI THM:
Page 1 of 136
FLOW CHART:
I6-BIT ADDITION
Page 2 of 136
PROGRAM:
MNEMONICS HEX
ADDRESS LABEL COMMENTS
OPCODE OPERAND CODE
1000 MOV BX,2000 BB
Initialize the memory
1001 00
pointer
1002 20 Clear DL register
1003 MOV AX,[BX] 8B Move the first data from
1004 07 memory to AX
1005 INC BX 43 Increment memory
1006 INC BX 43 Increment memory
1007 MOV CX,[BX] 8B Move the second data
1008 0F from memory to CX
1009 MOV DL,00 B2
100A 00
100B ADD AX,CX 01
Add AX with CX
100C C8
100D JNB 1011(XXX) 73
Jump if no carry occurs
100E 02
10 INC DL FE
Increment carry
1010 C2
1011 XXX INC BX 43 Increment memory
1012 INC BX 43 Increment memory
1013 MOV [BX],AX 89 Store sum in memory
1014 07 location
1015 INC BX 43 Increment memory
1016 INC BX 43 Increment memory
1017 MOV [BX],DL 88 Store carry in memory
1018 17 location
1019 HLT F4 Stop the program
Page 3 of 136
SAMPLE INPUT AND OUTPUT
16-BIT ADDITION
WITHOUT CARRY
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
2000 2004
2001 2005
2002 2006
2003
WITH CARRY
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
2000 2004
2001 2005
2002 2006
2003
Page 4 of 136
FLOW CHART:
I6-BIT SUBTRACTION
Page 5 of 136
PROGRAM:
MNEMONICS HEX
ADDRESS LABEL COMMENTS
OPCODE OPERAND CODE
1000 MOV BX,2000 BB
Initialize the memory
1001
1009
MOV CL,00 00BL
pointer
1002 20
1003 MOV AX,[BX] 8B Move the first data from
1004 07 memory to AX
1005 INC BX 43 Increment memory
1006 INC BX 43 Increment memory
1007 MOV DX,[BX] 8B Move the second data
1008 0F from memory to DX
Clear CL register
100A 00
Page 6 of 136
SAMPLE INPUT AND OUTPUT
16-BIT SUBTRACTION
WITHOUT BORROW
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
2000 2004
2001 2005
2002 2006
2003
WITH BORROW
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
2000 2004
2001 2005
2002 2006
2003
RESULT:
Thus the assembly language program for 16-bit addition and subtraction
was performed and the output was verified.
Page 7 of 136
16-BIT MULTIPLICATION & DIVISION
EX NO:
DATE:
AIM:
To write an Assembly Language Program (ALP) to perform16-bit
multiplication and division using 8086 microprocessor.
APPARATUS REQUIRED:
ALGORITHM:
16-BIT MULTIPLICATION
Page 9 of 136
PROGRAM:
MNEMONICS HEX
ADDRESS LABEL COMMENTS
OPCODE OPERAND CODE
1000 MOV BX,2000 BB
Initialize the memory
1001 00
pointer
1002 20
1003 MOV AX,[BX] 8B Move the first data
1004 07 from memory to AX
1005 INC BX 43 Increment memory
1006 INC BX 43 Increment memory
1007 MOV CX,[BX] 8B Move the second data
1008 0F from memory to CX
1009 MOV DX,00 BL
Clear DX register
100A 00
100B MUL CX 29
1011 INCBX 43
Multiply AX with CX
Increment memo ry
100C D0
100D INC BX 73 Increment memory
100E INC BX 02 Increment memory
10 MOV [BX],AX FE Store product in
1010 C1 memory
Page 10 of 136
SAMPLE INPUT AND OUTPUT
16-BIT MULTIPLICATION
WITHOUT CARRY
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
2000 2004
2001 2005
2002 2006
2003 2007
WITH CARRY
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
2000 2004
2001 2005
2002 2006
2003 2007
Page 11 of 136
FLOW CHART:
16-BIT DIVISION
Page 12 of 136
PROGRAM:
MNEMONICS HEX
ADDRESS LABEL COMMENTS
OPCODE OPERAND CODE
1000 MOV BX,2000 BB
Initialize the memory
1001 00
pointer
1002 20
1003 MOV AX,[BX] 8B Move the first data from
1004 07 memory to AX
1005 INC BX 43 Increment memory
1006 INC BX 43 Increment memory
1007 MOV CX,[BX] 8B Move the second data
1008 0F from memory to CX
1009 MOV DX,00 BL
Clear DX register
100A 00
100B DIV CX 29
Divide AX with CX
100C D0
100D INC BX 73 Increment memory
100E INC BX 02 Increment memory
10 MOV [BX],AX FE
Store quotient in memory
1010 C1
1011 INC BX 43 Increment memory
1012 INC BX 43 Increment memory
1013 MOV [BX],DX 89 Store remainder in
1014 07 memory
1015 HLT 43 Stop the program
Page 13 of 136
SAMPLE INPUT AND OUTPUT
16-BIT DIVISION
WITHOUT REMAINDER
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
2000 2004
2001 2005
2002 2006
2003 2007
WITH REMAINDER
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
2000 2004
2001 2005
2002 2006
2003 2007
RESULT:
Thus the assembly language program for 16-bit multiplication and division was
performed and the output was verified.
Page 14 of 136
ASCENDING AND DESCENDING ORDER
EX NO:
DATE:
AIM:
To write an Assembly Language Program (ALP) to perform ascending and
descending order using 8086 microprocessor.
APPARATUS REQUIRED:
ALGORITHM:
STEP 4: Compare the numbers and exchange if nssary so that the two numbers are in
ascending order/descending order.
STEP 6: Get the third number from the array and repeat step no:4 until CX is 0.
Page 15 of 136
FLOW CHART: ASCENDING
Page 16 of 136
PROGRAM:
MNEMONICS HEX
ADDRESS LABEL COMMENTS
OPCODE OPERAND CODE
1000 MOV DX,0005 BA
Move count value into DX
1001 05
register
1002 00
1003 DEC DX 4A Decrement count value
1004 ZZZ MOV CX,DX 89
Move DX to CX
1005 D1
1006 MOV SI,3000 BE
1007 00 Initialize the memory
1008 30
1009 YYY MOV AX,[SI] 8B Move first data into
100A 04 accumulator
100B CMP AX,[SI+02] 3B Compare values of
and memory
100C 44 Accumulator and next value
100D 02 in the memory
100E JB 1015(XXX) 72
Jump if borrow occurs
10 05
1010 XCHG [SI+02],AX 87
Exchange the values of AX
1011 44
1012 02
1013 XCHG {SI],AX 87 Exchange the values of AX
1014 04 and memory
1015 XXX ADD SI,0002 83
Increment the memory
1016 C6
location address
1017 02
1018 LOOP 1009(YYY) E2 Unconditional jump to
1019 EF 1009
101A DEC DX 4A Decrement the count
101B JNE 1004(ZZZ) 75
Jump if not zero(or) equal
101C E7
101D HLT F4 Stop the program
Page 17 of 136
SAMPLE INPUT AND OUTPUT
ASCENDING ORDER
INPUT OUTPUT
3000 3000
3001 3001
3002 3002
3003 3003
3004 3004
3005
3005
3006 3006
3007 3007
3008 3008
3009
3009
Page 18 of 136
FLOW CHART: DESCENDING
Page 19 of 136
PROGRAM:
MNEMONICS HEX
ADDRESS LABEL COMMENTS
OPCODE OPERAND CODE
1000 MOV DX,0005 BA
Move count value into DX
1001 05
register
1002 00
1003 DEC DX 4A Decrement count value
1004 ZZZ MOV CX,DX 89
Move DX to CX
1005 D1
1006 MOV SI,3000 BE
1007 00 Initialize the memory
1008 30
1009 YYY MOV AX,[SI] 8B Move first data into
100A 04 accumulator
100B CMP AX,[SI+02] 3B Compare values of
100C 44 Accumulator and next value in
100D 02 the memory
100E JNB 1015(XXX) 73
Jump if not borrow occurs
10 05
1010 XCHG [SI+02],AX 87
Exchange the values of AX and
1011 44
memory
1012 02
1013 XCHG {SI],AX 87 Exchange the values of AX and
1014 04 memory
1015 XXX ADD SI,0002 83
Increment the memory location
1016 C6
address
1017 02
1018 LOOP 1009(YYY) E2
Unconditional jump to 1009
1019 EF
101A DEC DX 4A Decrement the count
101B JNE 1004(ZZZ) 75
Jump if not zero(or) equal
101C E7
101D HLT F4 Stop the program
Page 20 of 136
DESCENDING ORDER
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
3000 3000
3001 3001
3002
3002
3003
3003
3004
3004
3005
3005
3006
3006 3007
3008
3007
3008 3009
3009
RESULT:
Thus the assembly language program for ascending and descending order was
performed and the output was verified.
Page 21 of 136
LARGEST AND SMALLEST NUMBER
EX NO:
DATE:
AIM:
To write an Assembly Language Program (ALP) to perform largest and smallest
number among N numbers using 8086 microprocessor.
APPARATUS REQUIRED:
ALGORITHM:
STEP 1: Start the program.
STEP 6: Get the third number from the array and repeat step no:4 until CX is 0.
Page 22 of 136
FLOW CHART: LARGEST
Page 23 of 136
PROGRAM:
MNEMONICS HEX
ADDRESS LABEL COMMENTS
OPCODE OPERAND CODE
1000 MOV AX,6000 B8,00,60 Move data segment value
1003 MOV DS,AX 8E,D8 Move AX to DS
1005 CLD FC Clear directional flag
1006 MOV CX,0005 B9
1007 05 Give count value to CX
1008 00
1009 MOV SI,4000 BE
100A 00 Initialize the input address
100B 40
100C MOV DI,5000 BF
100D 00 Initialize the output address
100E 50
100F MOV AX,[SI] 8B
Get the first data
1010 04
1011 YYY CMP AX,[SI+02] 3B
1012 44 Compare the two data
1013 02
1014 JNB 1019(XXX) 73
Jump if no borrow
1015 03
1016 XCHG [SI+02],AX 87
1017 44 Exchange the values
1018 02
1019 XXX INC SI 46 Increment memory
101A INC SI 46 Increment memory
101B LOOP 1011(YYY) E2
Unconditional jump to 1011
101C F4
101D MOV [DI],AX 89,05 Store the result
101F HLT F4 Stop the program
Page 24 of 136
SAMPLE INPUT AND OUTPUT
LARGEST NUMBER
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
4000 5000
4001 5001
4002
4003
4004
4005
4006
4007
4008
4009
Page 25 of 136
FLOW CHART: SMALLEST
Page 26 of 136
PROGRAM:
SMALLEST NUMBER
MNEMONICS HEX
ADDRESS LABEL COMMENTS
OPCODE OPERAND CODE
1000 MOV AX,6000 B8,00,60 Move data segment value
1003 MOV DS,AX 8E,D8 Move AX to DS
1005 CLD FC Clear directional flag
1006 MOV CX,0005 B9
1007 05 Give count value to CX
1008 00
1009 MOV SI,4000 BE
100A 00 nitialize the input address
100B 40
100C MOV DI,5000 BF
100D 00 Initialize the output address
100E 50
100F MOV AX,[SI] 8B
Get the first data
1010 04
1011 YYY CMP AX,[SI+02] 3B
1012 44 Compare the two data‟s
1013 02
1014 JB 1019(XXX) 72 Jump if no borrow go to
1015 03 1019
1016 XCHG[SI+02],AX 87
1017 44 Exchange the values
1018 02
1019 XXX INC SI 46 Increment memory
101A INC SI 46 Increment memory
101B LOOP 1011(YYY) E2
Unconditional jump to 1011
101C F4
101D MOV [DI],AX 89,05 Store the result
101F HLT F4 Stop the program
Page 27 of 136
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
4000 5000
4001 5001
4002
4003
4004
4005
4006
4007
4008
4009
RESULT:
Thus the assembly language program to find largest and smallest
number among N numbers was performed and the output was verified.
Page 28 of 136
COPY OPERATION
EX NO:
DATE:
AIM:
To write an Assembly Language Program (ALP) to perform copy operation using
8086 microprocessor.
APPARATUS REQUIRED:
ALGORITHM:
STEP 1: Start the program.
Page 29 of 136
FLOW CHART:
Page 30 of 136
PROGRAM:
MNEMONICS HEX
ADDRESS LABEL COMMENTS
OPCODE OPERAND CODE
1000 MOV AX,5000 B8
1001 00 Get the segment values
1002 50
1003 MOV DS,AX 8E Move AX values into data
1004 D8 segment
1005 MOV DX,0005 B9
Move count value in to DX
1006 05
register
1007 00
1008 MOV SI,2000 BE
Move source address into
1009 00
SI register
100A 20
100B MOV DI,3000 BE
Move destination address
100C 00
into DI register
100D 30
100E KKK MOV BL,[SI] 8A
Move SI to BL register
10 1C
1010 MOV [DI],BL 88
Move BL to DI
1011 1D
1012 INC SI 46 Increment SI
1013 INC DI 47 Increment DI
1014 DEC DX 4A Decrease the count value
1015 LOOP 100E(KKK) E2 Unconditional jump to
1016 F7 100E
1017 HLT F4 Stop the program
Page 31 of 136
SAMPLE INPUT AND OUTPUT
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
2000 3000
2001 3001
3002
2002
3003
2003
3004
2004
RESULT:
Thus the assembly language program to performing copy operation was
performed and the output was verified.
INFERENCE:
Page 32 of 136
STRING MANIPULATION
EX NO:
DATE:
AIM:
To write an Assembly Language Program (ALP) for string manipulation
using 8086 microprocessor.
ALGORITHM:
APPARATUS REQUIRED:
STEP 2: Set the SI to point the source array and DI at destination location.
STEP 3: Move the string size to CX register
STEP 4: Direction flag is cleared so that SI & DI will auto increment after each loop.
Page 33 of 136
FLOW CHART:
Page 34 of 136
PROGRAM:
MNEMONICS HEX
ADDRESS LABEL COMMENTS
OPCODE OPERAND CODE
1000 MOV SI,1100
Move the source address to
1001
SI
1002
1003 MOV DI,1200
Move the destination
1004
address to DI register
1005
1006 MOV CX,00FF
Set the length of array
1007
element
1008
1009 CLD Clear the direction flag
100A XXX MOVSB Move the string byte
100B LOOP 100A(XXX)
Unconditional loop
100C
100D HLT Stop the program
INPUT
OUTPUT
ADDRESS DATA ADDRESS DATA
1100 1200
TO TO
11FF 12FF
RESULT:
Thus the assembly language program for string manipulation was performed
and output was verified.
Page 35 of 136
CONVERSION BCD TO BINARY AND VICEVERSA
EX NO:
DATE:
AIM:
To write an Assembly Language Program (ALP) to convert BCD to BINARY
and vice versa using 8086 microprocessor.
APPARATUS REQUIRED:
ALGORITHM:
BCD TO BINARY
STEP 1: Start the program.
STEP 2: Get the input data.
STEP 3: performing AND operation between input and F0.
STEP 4: Rotate right AL with CL.
STEP 5: performing multiplication operation between DH and 0A.
STEP 6: Store the result in memory.
STEP 7: Stop the program.
BINARY TO BCD
STEP 1: Start the program.
STEP 2: Get the input data.
STEP 3: compare and then subtract the value 100 from the input.
STEP 4: compare and then subtract the value 10 from the input.
STEP 5: performing rotate left operation with AL by 04.
STEP 6: Store the result in memory.
STEP 7: Stop the program.
Page 36 of 136
FLOW CHART:
Page 37 of 136
PROGRAM:
BCD TO BINARY
MNEMONICS HEX
ADDRESS LABEL COMMENTS
OPCODE OPERAND CODE
3000 MOV BX,1100 BB
3001 00 Initialize the memory pointer
3002 11
3003 MOV AL,[BX] 8A Move the data from memory
3004 07 to AL register
3005 MOV DL,AL 88
Move the data from AL to DL
3006 C2
3007 AND DL,0F 80 Logical AND between DL
3008 0F and data 0F
3009 AND AL,F0 24 Logical AND between AL
300A F0 and data F0
300B MOV CL,04 B1
Move data 04 to CL
300C 04
300D ROR AL,CL D2
Rotate right AL with CL
300E C8
300F MOV DH,0A B6
Move data 0A to DH
3010 0A
3011 MUL DH,0A F6
Multiply DH with data 0A
3012 E6
3013 ADD AL,DL 00 Add the content of AL with
3014 D0 DL
3015 MOV [BX+1],AL 88
Store the result in memory
3016 47 location
3017 01
3018 HLT F4 Stop the program
1100 1101
Page 38 of 136
BINARY TO BCD
MNEMONICS HEX
ADDRESS LABEL COMMENTS
OPCODE OPERAND CODE
1000 MOV CL,00 B1
Move the data 00 to CL
1001 00
1002 MOV BL,CL 88 Move the content of CL to
1003 CB BL
1004 MOV SI,2000 BE
Initialize the memory
1005 00
pointer
1006 20
1007 MOV AL,[SI] 8A Get the input data from
1008 04 memory location
1009 RRR CMP AL,64 3C Compare AL with
100A 64 immediate data 64
100B JB 1013(KKK) 72
Jump if borrow
100C 06
100D SUB AL,64 2C Subtract AL with
100E 64 immediate data 64
100F INC AL FE
Increment AL
1010 C1
1011 JMP 1009(RRR) EB
Jump the program to 1009
1012 F6
1013 KKK CMP AL,0A 3C Compare AL with
1014 0A immediate data 0A
1015 JB 101D(SSS) 72
Jump if borrow
1016 06
1017 SUB AL,0A 2C Subtract AL with
1018 0A immediate data 0A
1019 INC BL FE
Increment BL
101A C3
Page 39 of 136
MNEMONICS HEX
ADDRESS LABEL COMMENTS
OPCODE OPERAND CODE
101B JMP 1013(KKK) EB
Jump the program to 1013
101C F6
101D SSS MOV DL,AL 88
Move data from AL to DL
101E C2
101F MOV AL,BL 88
Move data from BL to AL
1020 D8
1021 ROL AL,01 D0
Rotate left AL by 01
1022 C0
1023 ROL AL,01 D0
1024 C0 Rotate left AL by 01
1025 ROL AL,01 D0
Rotate left AL by 01
1026 C0
1027 ROL AL,01 D0
Rotate left AL by 01
1028 C0
1029 ADD AL,DL 00
Add AL with DL
102A D0
102B MOV [SI+01],AL 88
Move the lower byte result in
102C 44
memory location
102D 01
102E MOV [SI+02],CL 88
Move the higher byte result
102F 44
in memory location
1030 02
1031 HLT F4 Stop the program
Page 40 of 136
BINARY TO BCD
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
2001
2000
2002
RESULT:
Thus the assembly language program for conversion of BCD to BINARY and
vice versa was performed and the output was verified.
Page 41 of 136
CONVERSION BINARY TO ASCII AND VICEVERSA
EX NO:
DATE:
AIM:
To write an Assembly Language Program (ALP) to convert BINARY TO ASCII
and vice versa using 8086 microprocessor.
APPARATUS REQUIRED:
ALGORITHM:
BINARYTO ASCII
STEP 1: Start the program.
STEP 3: If the input data is greater than thedata 0A add 37 from input otherwise add
30 from the input.
STEP 3: If the input data is greater than the data 0Asubtract 37 from input
otherwise subtract 30 from the input.
Page 42 of 136
FLOWCHART: BINARY TO ASCII
Page 43 of 136
PROGRAM: BINARY TO ASCII
MNEMONICS HEX
ADDRESS LABEL COMMENTS
OPCODE OPERAND CODE
8400 MOV BX,2000 BB
Initialize the memory
8401 00
location
8402 20
8403 MOV AL,[BX] 8A Move the data from
8404 07 memory to AL register
8405 CMP AL,OA 3C
Compare AL with data 0A
8406 0A
8407 JB 840B(XXX) 72
Jump if borrow occurs
8408 02
8409 ADD AL,07 04
Add AL with data 07
840A 07
840B XXX ADD AL,30 04
Add AL with data 30
840C 30
840D INC BX 43 Increment BX
840E MOV [BX],AL 88
Store the result
840F 07
8410 HLT F4 Stop the program
2000 2001
Page 44 of 136
FLOWCHART: ASCII TO BINARY
Page 45 of 136
PROGRAM: ASCII TO BINARY
ASCII TO BINARY
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
2000 2001
RESULT:
Thus the assembly language program for conversion of BINARY to ASCII and
vice versa was performed and the output was verified.
Page 46 of 136
CONVERSION BINARY TO GRAY
EX NO:
DATE:
AIM:
To write an Assembly Language Program (ALP) to convert BINARY TO
GRAY.
APPARATUS REQUIRED:
ALGORITHM:
Page 47 of 136
FLOW CHART:
Page 48 of 136
PROGRAM:
MNEMONICS HEX
ADDRESS LABEL COMMENTS
OPCODE OPERAND CODE
6000 MOV SI,8200 BE
Initialize the memory
6001 00
pointer
6002 82
6003 MOV BL,[SI] 8A Move the input data from
6004 1C memory to BL register
6005 MOV AL,BL 88 Move the data from BL to
6006 D8 AL
6007 SHR AL,01 D0
Shift right AL by 01
6008 C8
6009 XOR AL,BL 30 Perform EX-OR operation
600A D8 between Al and BL
600B INC SI 46 Increment SI
SAMPLEI NPUT AND OUTPUT
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
8200 8201
RESULT:
Thus the assembly language program for conversion of BINARY to GRAY
was performed and the output was verified.
Page 49 of 136
FIND AND REPLACE DATA
EX NO:
DATE:
AIM:
To write an Assembly Language Program (ALP) to find the given element in set
of element and replace it with new value.
APPARATUS REQUIRED:
ALGORITHM:
Page 50 of 136
FLOW CHART:
Page 51 of 136
PROGRAM:
MNEMONICS HEX
ADDRESS LABEL COMMENTS
OPCODE OPERAND CODE
1000 MOV AX,5000 B8,00,50 Move data segment value
1003 MOV DS,AX 8E,D8 Move AX to DS
1005 CLD FC Clear directional flag
1006 MOV SI,3000 BE
Move the memory address
1007 00
to SI
1008 30
1009 MOV CX,[SI] 8B
Count value move to CX
100A 0C
100B INC SI 46 Increment memory location
100C MOV BL,[SI] 8A Move the data from [SI] to
100D 1C BL
100E MOV DI,2000 BF
Get the input memory
100F 00
address to DI
1010 20
1011 SSS CMP [DI],BL 38
Compare the data
1012 1D
1013 JE 101C(KKK) 74
Jump if equal go to 101C
1014 07
1015 INC DI 47 Increment DI
1016 LOOP1011(SSS) E2
Jump the address 1011
1017 F9
1018 MOV [DI],0005 C6,05,00 Move count value to DI
101B HLT F4 Stop the program
101C KKK INC SI 46 Increment SI
101D MOV BL,[SI] 8A Move the data from [SI] to
101E 1C BL register
Move the data from BL to
101F MOV [DI],BL 88,1D
[DI]
1021 RET C3 Return the main program
Page 52 of 136
SAMPLE INPUT AND OUTPUT
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
2000
2000
2001
2002 2001
2003
2002
2004
2003
3000
3001 2004
3002
RESULT:
Thus the assembly language program for find and replace was performed and
the output was verified.
Page 53 of 136
ADDITION TWO 3X3 MATRIX
EX NO:
DATE:
AIM:
To write an Assembly Language Program (ALP) to add two 3x3 matrix using
8086 microprocessor.
APPARATUS REQUIRED:
ALGORITHM:
Page 54 of 136
FLOW CHART:
Page 55 of 136
PROGRAM:
MNEMONICS HEX
ADDRESS LABEL COMMENTS
OPCODE OPERAND CODE
3000 MOV BX,1300 BB
Move the address of matrix
3001 00
one to BX register
3002 13
3003 MOV BP,1400 BD Move the address of
3004 00 second matrix to BP
3005 14 register
3006 MOV SI,0000 BE
Move the data 0000 to SI
3007 00
register
3008 00
3009 MOV DI,1501 BF
Move the output address to
300A 01
DI register
300B 15
300C MOV CL,09 B1 Move count value to CL
300D 09 register
300E XXX MOV AL,[BX+SI] 8A Move the content of
300F 00 [ BX+SI] to AL register
3010 ADD AL,[BP+SI] 02 Add the content of [BP+SI]
3011 02 with AL register
3012 MOV [DI],AL 88
Store the result in memory
3013 05
3014 INC SI 46 Increment SI
3015 INC DI 47 Increment DI
3016 LOOP 300E(XXX) E2
Go to loop 300E
3017 F6
3018 HLT F4 Stop the program
Page 56 of 136
SAMPLE INPUT AND OUTPUT
INPUT
MATRIX A MATRIX B
ADDRESS DATA ADDRESS DATA
1300
1400
1303
1403
1306
1406
OUTPUT
MATRIX C
1501
ADDRESS
DATA
1504
1507
RESULT:
Thus the assembly language program to add two 3x3 matrix was performed
and the output was verified.
Page 57 of 136
8051
MICROCONTROLLER
8-BIT AND 16-BIT ADDITION
EX NO:
DATE:
AIM:
To write an Assembly Language Program (ALP) to perform 8-bit and 16-bit
addition using 8051 micro controller.
APPARATUS REQUIRED:
ALGORITHM:
STEP 1: Start the program.
Page 58 of 136
FLOW CHART:
Page 59 of 136
PROGRAM:
8-BIT ADDITION (INTERNAL MEMORY)
MNEMONICS HEX
ADDRESS LABEL COMMENTS
OPCODE OPERAND CODE
A100 MOV R0,#40 78 Move data 40 to R0
A101 40 register
A102 MOV R1,#41 79 Move data 40 to R0
A103 41 register
A104 MOV A,@R0 E6 Move R0 t0 accumulator
A105 ADD A,@R1 27 Add accumulator with R1
register
A106 INC R1 09 ncrement R1
A107 MOV @R1,A E7 Move A to memory
A108 LCALL 00BB 12 Call subroutine to the
A109 00 address 00BB
A10A BB
INPUT OUTPUT
40
42
41
Page 60 of 136
8-BIT ADDITION (EXTERNAL MEMORY)
MNEMONICS HEX
ADDRESS LABEL COMMENTS
OPCODE OPERAND CODE
9000 MOV R4,#00 7C Move the data 00 to R4
9001 00
9002 MOV DPTR,#8100 90 Initialize the memory
9003 00 pointer to DPTR
9004 81
9005 MOVX A,@DPTR E0 Move DPTR to A
9006 INC DPTR A3 Increment DPTR
9007 MOV R0,A F8 Move A to R0
9008 MOVX A,@DPTR E0 Move DPTR to A
9009 ADD A,R0 28 Add A and R0
900A JNC 900D(AA) 05 Jump to 900D if no carry
900B 80 occurs
900C INC R4 0C Increment R4
9012 SJ M P9000 80 Short ju mp to 9000
9013 EC
8101 8103
Page 61 of 136
16-BIT ADDITION
MNEMONICS HEX
ADDRESS LABEL COMMENTS
OPCODE OPERAND CODE
9500 MOV A,#2F 74 Move the data to
9501 2F accumulator
9502 MOV R1,#2F 79
Move the data to R1
9503 2F
9504 MOV R2,#02 7A
Move the data to R2
9505 02
9506 MOV R3,#12 7B
Move the data to R3
9507 12
9508 ADD A,R2 2A Add A and R2
9509 MOV DPTR,#8500 90
Initialized memory pointer
950A 00
by data pointer
950B 85
950C MOVX @DPTR,A E0 Move A t0 DPTR
9512 ED 9500
INPUT OUTPUT
IMMEDIATE DATA ADDRESS DATA
D TA 1 8500
DATA2 8501
RESULT:
Thus the assembly language program for 8-bit and 16-bit addition using
8051 microcontroller was performed and the output was verified.
Page 62 of 136
8-BIT AND 16-BIT SUBTRACTION
EX NO:
DATE:
AIM:
To write an Assembly Language Program (ALP) to perform 8-bit and 16-bit
subtraction using 8051 micro controller.
APPARATUS REQUIRED:
ALGORITHM:
Page 63 of 136
FLOW CHART:
Page 64 of 136
PROGRAM: 8-BIT SUBTRACTION (INTERNAL MEMORY)
MNEMONICS HEX
ADDRESS LABEL COMMENTS
OPCODE OPERAND CODE
8000 MOV A,#55 74 Move the data to
8001 55 accumulator
8002 MOV B,#22 75
Move the data to B
8003 F0
register
8004 22
8005 SUBB A,B 95 Subtract B from the
8006 F0 content of accumulator
8007 MOV 40,A F5
Move A content to 40
8008 42
8009 LCALL 00BB 12
Call subroutine to the
800A 00
address 00BB
BB
SAMPLE INPUT/OUTPUT
DATA 1
40
DATA 2
Page 65 of 136
8-BIT SUBTRACTION (EXTERNAL MEMORY)
MNEMONICS HEX
ADDRESS LABEL COMMENTS
OPCODE OPERAND CODE
A300 MOV A,#24 74 Move the data to
A301 24 accumulator
A302 MOV R3,#02 7B Move the data to R3
A303 02 register
SUBB A,R3 9B Subtract R3 from the
A304
content of accumulator
A305 MOV DPTR,#8100 90
nitialized memory pointer
A306 00
by data pointer
A307 81
A308 MOVX @DPTR,A F0 Move A to DPTR
A309 SJMP A300 80
Short jump to A300
A30A F5
SAMPLE INPUT/OUTPUT
INPUT OUTPUT
IMMEDIATE DATA ADDRESS DATA
DATA 1
8100
DATA 2
Page 66 of 136
16-BIT ADDITION:
MNEMONICS HEX
ADDRESS LABEL COMMENTS
OPCODE OPERAND CODE
A900 MOV A,#2F 74 Move the data to
A901 2F accumulator
A902 MOV R1,#2F 79
Move the data to R1 register
A903 2F
A904 MOV R2,#02 7A Move the data to R2
A905 02 register
A906 MOV R3,#12 7B Move the data to R3
A907 12 register
A908 SUBB A,R2 9A Subtract A and R2 register
A909 MOV DPTR,#9300 90
Initialized memory pointer
A90A 00
by data pointer
A90B 93
A90C MOVX @DPTR,A 0 Move A to DPTR
A90D MOV A,R1 E9 Move R1 to Accumulator
A90E SUBB A,R3 9B Subtract A and R3
A90F INC DPTR A3 Increment DPTR
A910 MOVX @DPTR,A E0 Move A t0 DPTR
A911 SJMP A900 80 Short jump to the address
A912 ED 9500
16-BIT SUBTRACTION
INPUT OUTPUT
IMMEDIATE DATA ADDRESS DATA
DATA 1 9300
DATA 2 9301
RESULT:
Thus the assembly language program for 8-bit and 16-bit subtraction using 8051
microcontroller was performed and the output was verified.
Page 67 of 136
8-BIT MULTIPLICATION
EX NO:
DATE:
AIM:
To write an Assembly Language Program (ALP) to perform 8-bit multiplication
using 8051 micro controller.
APPARATUS REQUIRED:
ALGORITHM:
Page 68 of 136
FLOW CHART:
Page 69 of 136
8-BIT MULTIPLICATION (INTERNAL MEMORY)
MNEMONICS HEX
ADDRESS LABEL COMMENTS
OPCODE OPERAND CODE
9000 MOV R0,#40 78
Move the data to R0
9001 40
9002 MOV R1,#41 79
Move the data to R1
9003 41
9004 MOV A,@R0 E6 Move R0 to Accumulator
9005 MOV B,@R1 87
Move R1 to B
9006 F0
9007 MUL AB A4 Multiply A and B
9008 INC R1 09 Increment R1
9009 MOV @R1,A F7 Move A to memory
900A INC R1 09 Increment R1
900B MOV @R1,B A7
Move B to memory
900C F0
900D LCALL 00BB 12
Long call to the address
900E 00
00BB
900F BB
41 43
Page 70 of 136
8-BIT MULTIPLICATION (EXTERNAL MEMORY)
MNEMONICS HEX
ADDRESS LABEL COMMENTS
OPCODE OPERAND CODE
8000 MOV A,#55 74 Move the data to
8001 55 accumulator
8002 MOV B,#04 75
8003 04 Move the data to B
8004 0B
8005 MUL AB A4 Multiply A and B
8006 MOV DPTR,#8100 90
nitialized memory pointer
8007 00
by data pointer
8008 81
8009 MOVX @DPTR,A F0 Move A t0 DPTR
800A INC DPTR A3 Increment DPTR
800B MOV A,B E5
Move B to A
800C F0
800D MOVX @DPTR,A E0 Move A t0 DPTR
800E SJMP 8000 80 Short jump to the address
800F F0 8000
D TA 2 8101
RESULT:
Thus the assembly language program for 8-bit multiplication using
8051 microcontroller was performed and the output was verified.
Page 71 of 136
8-BIT DIVISION
EX NO:
DATE:
AIM:
To write an Assembly Language Program (ALP) to perform 8-bit division using
8051 micro controller.
APPARATUS REQUIRED:
ALGORITHM:
Page 72 of 136
FLOW CHART:
Page 73 of 136
8-BIT DIVISION (INTERNAL MEMORY)
MNEMONICS HEX
ADDRESS LABEL COMMENTS
OPCODE OPERAND CODE
9000 MOV R0,#40 78
Move the data to R0
9001 40
9002 MOV R1,#41 79
Move the data to R1
9003 41
9004 MOV A,@R0 E6 Move R0 to Accumulator
9005 MOV B,@R1 87
Move R1 to B
9006 F0
9007 DIV AB 84 Divide A and B
9008 INC R1 09 Increment R1
9009 MOV @R1,A F7 Move A to memory
900A INC R1 09 Increment R1
900B MOV @R1,B A7
Move B to memory
900C F0
900D LCALL 00BB 12
Long call to the address
900E 00
00BB
900F BB
41 43
Page 74 of 136
8-BIT DIVISION (EXTERNAL MEMORY)
MNEMONICS HEX
ADDRESS LABEL COMMENTS
OPCODE OPERAND CODE
8000 MOV A,#55 74 Move the data to
8001 55 accumulator
8002 MOV B,#04 75
8003 04 Move the data to B
8004 0B
8005 DIV AB 84 Divide A and B
8006 MOV DPTR,#8100 90
nitialized memory pointer
8007 00
by data pointer
8008 81
8009 MOVX @DPTR,A F0 Move A t0 DPTR
800A INC DPTR A3 Increment DPTR
800B MOV A,B E5
8-BI TDI VI SI ON-EXTERNAL MEMORY
Move B to A
800C F0
800D MOVX @DPTR,A E0Move A t0 DPTR
800E SJMP 8000 80 Short jump to the address
800F F0 8000
INPUT OUTPUT
IMMEDIATE DATA ADDRESS DATA
DATA 1 8100
D TA 2 8101
RESULT:
Thus the assembly language program for 8-bit division using 8051 microcontroller was
performed and the output was verified.
Page 75 of 136
FIND TWO’S COMPLEMENT A NUMBER
EX NO:
DATE:
AIM:
To write an Assembly Language Program (ALP) to perform two‟s complement
of a number using 8051 micro controller.
APPARATUS REQUIRED:
ALGORITHM:
STEP 1: Start the program.
STEP 3: Complement the input data and then add with 01.
Page 76 of 136
FLOW CHART:
Page 77 of 136
PROGRAM:
MNEMONICS HEX
ADDRESS LABEL COMMENTS
OPCODE OPERAND CODE
8000 MOV A,#03 74 Move immediate data to
8001 03 Accumulator
CPL A F4 Complement
8002
Accumulator
8003 ADD A,#01 24 Add with A and
8004 01 immediate data 01
8005 MOV DPTR,#8100 90 Move the result address
8006 00 to DPTR
8007 81
MOVX @DPTR,A F0 Store the result in
8008
memory location
INPUT OUTPUT
IMMEDIATE
ADDRESS DATA
DATA
8100
RESULT:
Thus the assembly language program for two‟s complement of a number
using 8051 microcontroller was performed and the output was verified.
Page 78 of 136
FIND SQUARE A NUMBER
EX NO:
DATE:
AIM:
To write an Assembly Language Program (ALP) to find square of a
number using 8051 microcontroller.
ALGORITHM:
APPARATUS REQUIRED:
Page 79 of 136
FLOWCHART:
Page 80 of 136
LABE MNEMONICS HEX
ADDRESS L COMMENTS
OPCODE OPERAND CODE
8000 MOV DPTR,#8100 Get the input from
8001 memory location
8002
MOVX A,@DPTR Move data from
8003
memory to A
8004 MOV B,A Move the content of A to B
MOV R0,A Move the content of
8005
A to R0
8006 MOV A,#00 Move the immediate data
8007 00 to Accumulator
8008 XXX ADD A,B Add the content of A with B
8100 8101
RESULT:
Thus the assembly language program to find square of a number using
8051 microcontroller was verified successfully.
Page 81 of 136
FIND CUBE A NUMBER
EX NO:
DATE:
AIM:
To write an Assembly Language Program (ALP) to find cube of a number
using 8051 microcontroller.
APPARATUS REQUIRED:
ALGORITHM:
STEP 1: Start the program.
Page 82 of 136
FLOWCHART:
Page 83 of 136
PROGRAM:
MNEMONICS HEX
ADDRESS LABEL COMMENTS
OPCODE OPERAND CODE
8000 MOV A,#00 Clear the accumulator
8001 content
8002 MOV B,#03 Move the input to
8003 B register
8004 XXX ADD A,#03 Add accumulator content
8005 with immediate data
8006 DEC B Decrement count value
8007 JNZ 8004(XXX) Jump if no zero
8008
8009 MOV R0,A Move data from A to R0
800A MOV B,#02 Move the data to B register
800C
800B
YYY ADD A,R0 Add the content of A
with R0
800D DEC B Decrement B register
800E JNZ 800C(YYY) Jump if no zero to
800F mentioned address
8010 MOV DPTR,#8100 Initialize the output
8011 memory address
8012
8013 MOVX @DPTR,A Store the result
8014 SJMP 8000 Short jump to address
8015
Page 84 of 136
SAMPLE INPUT AND OUTPUT
INPUT OUTPUT
IMMEDIATE DATA ADDRESS DATA
DATA 8100
RESULT:
Thus the assembly language program to find a cube of a number using 8051
microcontroller was verified successfully.
Page 85 of 136
8086 INTERFACING
STEPPER MOTOR INTERFACING
EX NO:
DATE:
AIM:
To write an Assembly Language Program (ALP) for interfacing stepper motor
Using 8086 microprocessor.
APPARATUS REQUIRED:
supply
ALGORITHM:
Page 87 of 136
90° PHASE SHIFT:
Page 88 of 136
PROGRAM:
MNEMONICS HEX
ADDRESS LABEL COMMENTS
OPCODE OPERAND CODE
CLOCKWISE DIRECTION
5000 MOV DX,00C0 BA
Move the port address to
5001 C0
DX register
5002 00
5003 MOV AL,66 B0 Store data to energise
5004 66 phase2 and phase3
Data moved into port
5005 SSS OUT DX,AL EE
address
5006 CALL 500D(XXX) E8
5007 04 Delay between two steps
5008 00
5009 ROR AL,1 D0 Rotate right the content of
500A C8 the accumulator
500B JMP 5005(SSS)E8 Repeat the above process
500C F8 for ever
DELAY PROGRAM
500D XXX M V CX,0500 B9
Move the count value to
500E 00
CX register
500F 05
5010 GGG DEC CX 49 Decrement CX value
5011 JNE 5010(GGG) 75 Jump if the value of CX is
5012 FD not equal (or)zero
5013 RET C3 Return
Page 89 of 136
MNEMONICS HEX
ADDRESS LABEL COMMENTS
OPCODE OPERAND CODE
ANTI-CLOCKWISE DIRECTION
5050 MOV DX,00C0 BA
Move the port address to
5051 C0
DX register
5052 00
5053 MOV AL,66 B0 Store data to energise
5054 66 phase2 and phase3
Data moved into port
5055 KKK OUT DX,AL EE
address
5056 CALL 500D(XXX) E8
5057 04 Delay between two steps
5058 00
5059 ROL AL,1 D0 Rotate left the content of
505A C8 the accumulator
505B JMP 5055(KKK) E8 Repeat the above process
505C F8 for ever
90° PHASE SHIFT
5100 MOV AH,32 B4 Move count value 32 to
5101 32 AH register
5102 MOV DX,00C0 B4
Move the port address to
5103 C0
DX register
5104 00
5105 MOV AL,66 B0 Store data to energise
5106 66 phase2 and phase3
5107 DDD OUT DX,AL EE The value sent to port
5108 CALL 5108 E8
Delay between two steps
5109 02
Page 90 of 136
MNEMONICS HEX
ADDRESS LABEL COMMENTS
OPCODE OPERAND CODE
510A FF
510B ROL AL,1 D0 Rotate left the value
510C C0 of AL
510D DEC AH FE Decrement the count
510E CC value
510F JNE 5107(DDD) 75
Jump if not equal
5110 F6
5111 RRR NOP 90 No operation
5112 JMP 5111(RRR) EB
Jump program to 5111
5113 FD
RESU T:
Thus the assembly language program for interfacing stepper motor using
8086 microprocessor has been executed successfully.
Page 91 of 136
8255 INTERFACING
EX NO:
DATE:
AIM:
To write an Assembly Language Program (ALP) for interfacing of 8255
Using 8086 microprocessor.
APPARATUS REQUIRED:
S.NO COMPONENTS SPECIFICATION QUANTITY
1. Microprocessor kit 8086 kit 1
2. Power Supply +5 V dc 1
3. Key board - 1
4. 8255interface card - 1
ALGORITHM:
STEP 2: Initialize the 8255 ports by sending the control word 82.
JUMPER SETTINGS:
1. Short the pins P2 and P11 0f J1 and short pins P3 and P10, so that port B input buffer
is enabled.
2. Short the pins P1 and P12 of J2 and short pins P4 and P9, so that Port A output buffer
is enabled.
Page 92 of 136
FLOW CHART:
Page 93 of 136
PROGRAM:
MNEMONICS HEX
ADDRESS LABEL COMMENTS
OPCODE OPERAND CODE
5000 XXX MOV DX,00C6 BA
Move the control word
5001 C6
address to DX register
5002 00
5003 MOV AL,82 B0 Move the count value 82
5004 82 to the accumulator
5005 OUT DX,AL EE Count value sent to port
5006 MOV DX,00C2 BA
5007 C2 Set port B as input port
5008 00
Input port value to
5009 IN AL,DX EC
accumulator
JMP5000(XXX) EB Jump the program to 5000
500A MOV DX,00C0 BA
500B C0 Set port A as output port
500C 00
Accumulator value to
500D OUT DX,AL EE
output port
500E
RESULT:
Thus the assembly language program for interfacing 8255 using 8086
microprocessor has been executed successfully.
Page 94 of 136
DAC INTERFACING
EX NO:
DATE:
AIM:
To write an Assembly Language Program (ALP) for interfacing of
DAC Using 8086 microprocessor.
APPARATUS REQUIRED:
ALGORITHM:
SQUARE WAVE:
STEP 1: Start the program.
Page 95 of 136
TRIANGULAR WAVE:
STEP 1: Start the program.
SAWTOOTH WAVE:
Page 96 of 136
FLOW CHART:
SQUARE WAVE
SAWTOOTH WAVE:
Page 97 of 136
TRIANGULAR WAVE:
Page 98 of 136
PROGRAM:
Page 99 of 136
MNEMONICS HEX
ADDRESS LABEL COMMENTS
OPCODE OPERAND CODE
TRIANGULAR WAVE GENERATION
5150 MOV AX,0000 B8
Move the value 0000 to AX
5151 00
register
5152 00
5153 MOV DS,AX 8E Move the value from Ax to
5154 D8 DS
5155 MOV DX,00C0 BA
Move the port address to
5156 C0
DX register
5157 00
5158 DDD MOV AL,00 B0
Start DAC output from 0V
5159 00
515A SSS OUT DX,AL EE Send data to DAC
515B INC AL FE
Increment AL
515C C0
515D JNE 515A(SSS) 75
Repeat until AL becomes 0
515E FB
515F MOV AL, B0 Move the value FF to AL
5160 FF register
5161 KKK OUT DX,AL EE Send data to DAC
5162 DEC AL FE
Decrement AL value
5163 C8
5164 JNE 5161(KKK) 75
Repeat until AL becomes 0
5165 FB
5166 JMP 5158(DDD) EB
Repeat process
5167 F3
MNEMONICS HEX
ADDRESS LABEL COMMENTS
OPCODE OPERAND CODE
SAW TOOTH WAVE GENERATION
5200 MOV AX,0000 B8
Move the value 0000 to AX
5201 00
register
5202 00
OBSERVATION
S.No TIME PERIOD(m sec) AMPLITUDE (volts)
RESULT:
Thus the assembly language program for interfacing of DAC using 8086
microprocessor has been executed successfully.
DATE:
AIM:
To write an Assembly Language Program (ALP) for interfacing of counter
using 8086 microprocessor.
APPARATUS REQUIRED:
ALGORITHM:
STEP 2: Set a control word for counter 2 in mode -3(Square wave generation).
FLOW CHART:
MNEMONICS HEX
ADDRESSLABEL COMMENTS
OPCODE OPERAND CODE
5050 MOV DX,00C6 BA
Move the port address to
5051 C6
DX register
5052 00
5053 MOV AL,B6 B0 Move count value to AL
5054 B6 register
5055 OUT DX,AL EE Move AL value to DX
5056 MOV DX,00C4 BA
Move the port address to
5057 C4
DX register
5058 00
5059 MOV AL,E8 B0 Move lower byte of count
505A 8 value to AL register
505B OUT DX,AL EE Move AL value to DX
505C MOV AL,03 B0 Move higher byte of count
505D 03 value to AL register
505E OUT DX,AL EE Move AL value to DX
505F XXX NOP 90 No operation
5060 JMP 505F(XXX) EB
Jump program
5061 FD
RESULT:
Thus the assembly language program for interfacing of counter using
8086 microprocessor has been executed successfully.
DATE:
AIM:
To write an Assembly Language Program (ALP) for interfacing of keyboard and
display Using 8086 Microprocessor.
APPARATUS REQUIRED:
ALGORITHM:
STEP 3: Locate the first digit address with auto increment mode by sending command
(90) to port.
STEP 4: Send seven- segment code (3F) for”0”.
RESULT:
Thus the assembly language program for interfacing of keyboard and display
using8086 Microprocessor has been executed successfully.
DATE:
AIM:
To write an Assembly Language Program (ALP) for interfacing of traffic light
controller using 8086 Microprocessor.
APPARATUS REQUIRED:
ALGORITHM:
STEP 1: Start the program.
STEP 7: Turn on READY signal in road 3 and STOP signal in all other roads.
STEP 9: Turn on READY signal in road 4 and STOP signal in all other roads
MNEMONICS HEX
ADDRESS LABEL COMMENTS
OPCODE OPERAND CODE
5000 MOV BX,5029 BB
Initialize BX with BIT
5001 29
PATTERNS
5002 50
5003 MOV CX,09 B9
5004 09 Move the count value
5005 00
5006 MOV AL,80 B0
nitialize all ports
5007 80
5008 MOV DX,0046 BA
5051 DAA 27
BIT PATTERNS
5029 B4 60 09 20
502
D 9C 40 0B 05
5031 96 40 0B 20
5035 E4 40 0B 05
5039
5045
A4
3112
41 0B
23
20
10
503
D B4 40 0E 05
5041 B4 40 1A 20
5049 B4 C0 09 05
RESULT:
Thus the assembly language program (ALP) for interfacing of traffic light
controller using 8086 Microprocessor was performed and verified successfully
DATE:
AIM:
To write an Assembly Language Program (ALP) for interfacing stepper motor
Using 8051 Microcontroller.
APPARATUS REQUIRED:
supply
ALGORITHM:
MNEMONICS HEX
ADDRESS LABEL COMMENTS
OPCODE OPERAND CODE
CLOCKWISE DIRECTION
8000 MOV DPTR,#FFC0 90
Move port address to DX
8001 FF
register
8002 C0
8003 MOV A,#66 74 Store data to energise
8004 66 phase2 and phase3
Move Accumulator value
8005 AAA MOVX @DPTR,A F0
to DPTR
8006 ACALL 800B(XXX) 11
Delay between two steps
8007 0B
8008 RR A 03 Rotate right “A”
8009 SJMP 8005(AAA) 80 Repeat the above process
800A FA for ever
DELAY PROGRAM
800B XXX MOV R0,#0A 78 Move immediate data 0A
800C 0A to R0 register
800D MOV R1,#FF 79 Move immediate data FF
800E FF to R1 register
800F JNZ R1,800F D9 Decrement Jump if not
8010 FE zero to 800F
8011 DJNZ R0,800D D8 Decrement Jump if not
8012 FA zero to 800D
8013 RET 22 Return
RESULT:
Thus the assembly language program for interfacing stepper motor using
8051 Microcontroller has been executed successfully.
DATE:
AIM:
4. To write an Assembly Language Program (ALP) for interfacing of 8255
8255interface card - 1
APPARATUS REQUIRED:
S.NO COMPONENTS SPECIFICATION QUANTITY
1. Microcontroller kit 8051 kit 1
2. Power Supply +5 V dc 1
3. Key board - 1
ALGORITHM:
STEP 1: Start the program.
STEP 2: Initialize the 8255 ports by sending the control word 82.
STEP 3: Set port B as input port by proper jumpersettings.
STEP 4: Set port A as output port by proper jumper settings.
STEP 5: Read the switches at port B.
STEP 6: Display the reading port A.
JUMPER SETTINGS:
1. Short the pins P2 and P11 0f J1 and short pins P3 and P10, so that port B input
buffer is enabled.
2. Short the pins P1 and P12 of J2 and short pins P4 and P9, so that Port A output buffer
is enabled.
MNEMONICS HEX
ADDRESS LABEL COMMENTS
OPCODE OPERAND CODE
8000 MOV A,#82 74 Move the control word
8001 82 to accumulator
8002 MOV DPTR,#FFC6 90
Move the port address
8003 FF
to the DPTR
8004 C6
8005 MOVX @DPTR,A F0 Move A to DPTR
8006 MOV DPTR,#FFC2 90
Move port B address to
8007 FF
DPTR
8008 C2
8009 MOVX A,@DPTR F0 Set port B as input
800A MOV DPTR,#FFC0 90
Move port A address to
800B FF
DPTR
800C C0
800D MOVX @DPTR,A F0 Set port A as output
800E SJMP 800E 80 Short jump to address
800F FE 800E
RESULT:
Thus the assembly language program for interfacing 8255 using 8051
Microcontroller has been executed successfully.
DATE:
AIM:
To write an Assembly Language Program (ALP) for interfacing of DAC
Using 8051 Microcontroller.
4. DAC interface card - 1
APPARATUS REQUIRED:
5. CRO - 1
ALGORITHM:
SQUARE WAVE:
TRIANGULAR WAVE:
STEP 1: Start the program.
STEP 2: oad accumulator with 00 and send it to the D/A convertor.
STEP 3: Increment the data and send it to the accumulator.
STEP 4: Repeat the loop until Accumulator reaches 00.
STEP 5: Load accumulator with FF and send it to the D/A convertor.
STEP 6: Decrement the data and send it to the accumulator.
STEP 7: Repeat the loop until Accumulator reaches 00.
STEP 8: Repeat the process again and again.
SAWTOOTH WAVE:
STEP 1: Start the program.
STEP 2: Load accumulator with 00 and send it to the D/A convertor.
STEP 3: Increment the data and send it to the accumulator.
STEP 4: Repeat the process unconditionally
SAWTOOTH WAVE:
MNEMONICS HEX
ADDRESS LABEL COMMENTS
OPCODE OPERAND CODE
SQUARE WAVE GENERATION
8200 MOV DPTR,#FFC0 90
Move port address to data
8201 FF
pointer
8202 C0
8203 MOV A,#00 74 Data to set DAC output
8204 00 to 0 level
8205 MOVX @DPTR,A F0 Move data from A to port
8206 MOV R0,#FF 78
Off time delay
8207 FF
8208 DJNZ R0,8208 D8 Decrement and jump
8209 FE not zero
820A MOV A,#FF 74 Data to set DAC output to
820B FF 1 level
820C MOVX @DPTR,AF0 Move data from A to port
820D MOV R0,# 78
On time delay
820E FF
820F DJNZ R0,820F D8 Decrement and jump
8210 FE not zero
8211 SJMP 8203 80
Repeat process
8212 F0
TRIANGULAR WAVE GENERATION
8240 MOV DPTR,#FFC0 90
Move port address to data
8241 FF
pointer
8242 C0
RESULT:
Thus the assembly language program for interfacing of DAC using 8051
Microcontroller has been executed successfully.
DATE:
AIM:
To write an Assembly Language Program (ALP) for interfacing of counter using
8051 Microcontroller.
APPARATUS REQUIRED:
ALGORITHM:
STEP 1: Start the program.
STEP 2: Set a control word for counter 2 in mode -3(Square wave generation).
FLOW CHART:
MNEMONICS HEX
ADDRESS LABEL COMMENTS
OPCODE OPERAND CODE
8000 MOV A,#B6 74 Move control word
8001 B6 value to A register
8002 MOV DPTR,#FFC6 90
Move the port address
8003 FF
to DPTR
8004 C6
Move the content of A
8005 MOVX @DPTR,A F0
to DPTR
8006 MOV DPTR,#FFC4 90
Move the port address
8007 FF
to DPTR
8008 C4
800A 8
RESULT:
Thus the assembly language program for interfacing of counter using
8051 Microcontroller has been executed successfully.
DATE:
AIM:
To write an Assembly Language Program (ALP) for interfacing of keyboard and
display using 8051 Microcontroller.
4. 8279 interface card - 1
APPARATUS REQUIRED:
ALGORITHM:
STEP 1: Start the program.
STEP 2: Initialize 8279 with 8 digits of display by sending command (00) to port.
STEP 3: Locate the first digit address with auto increment mode by sending
command (90) to port.
STEP 4: Send seven- segment code (3F) for ”0”.
STEP 5: Send seven- segment code (06) for 1”.
STEP 6: Send seven- segment code (5B) for”2”.
STEP 7: Send seven- segment code (4F) for 3”.
STEP 8: stop the program.
MNEMONICS HEX
ADDRESS LABEL COMMENTS
OPCODE OPERAND CODE
8000 MOV A,#00 74 Move data 00 to
8001 00 accumulator
8002 MOV DPTR,#FFC2 90
Move port address to
8003 FF
data pointer
8004 01
8005 MOVX @DPTR,A F0 Move data from A to port
8006 MOV A,#90 74 Move data 90 to
8007 90 accumulator
8008 MOVX @DPTR,A F0 Move data from A to port
8009 MOV DPTR,#FFC0 90
Move port address to data
800A FF
pointer
800B 00
800C MOV A,#3F 74 Move data 3F to
800D 3F accumulator
800E MOVX @DPTR,A F0 Move data from A to port
800F M V A,#06 74 Move data 06 to
8010 06 accumulator
8011 MOVX @DPTR,A F0 Move data from A to port
Move data 5B to
8012 MOV A,#5B 74,5B
accumulator
8014 MOVX @DPTR,A F0 Move data from A to port
Move data 4F to
8015 MOV A,#4F 74,4F
accumulator
8017 MOVX @DPTR,A F0 Move data from A to port
8018 SJMP 8000 80,FE Short jump to address
RESULT:
Thus the assembly language program for interfacing of keyboard and display
using 8051 Microcontroller has been executed successfully.