Documente Academic
Documente Profesional
Documente Cultură
LAB : EC 1307
Sl. No
Name of Experiment
Date of Doing
Date of Sign
Mark
Sign
8085 PROGRAMS 1 2 3 4 5 6 7 8 9 8-BIT ARITHMETIC OPERATIONS 16-BIT ARITHMETIC OPERATIONS SUM OF SERIES OF NUMBERS ARRANGE NUMBERS IN ASCENDING AND DECENDING ORDER NUMBER CONVERSION LARGEST AND SMALLEST NUMBERS ADDITION NUMBERS OF TWO MULTIBYTE
10 11
12 13 14
ARITHMETIC OPERATIONS STRING MANIPULATION LARGEST AND SMALLEST NUMBERS 8051 PROGRAMS
15 16
8085 PROGRAMS
INPUT
OUTPUT
Ex: No:01 Date : Aim: To write and execute programs for 8-bit arithmetic operation using 8085. Apparatus Required: 1. Program : I 8-BIT ADDITION Algorithm: 1. 2. 3. 4. 5. 6. Start the operation. Move the first data to accumulator. Move the second data to B-register. Add the content of B-register to accumulator. Store the result in desired memory location. Stop the operation. 8085 Microprocessor Kit.
Program: ADDRESS 4100 4102 4104 4105 4108 MNEMONICS MVI A, 07 MVI B, 06 ADD B STA 4200 HLT 3E 06 80 32 76 00 42 07 06 OPCODE
8-BIT ADDITION WITH CARRY Algorithm: 1. 2. 3. 4. 5. 6. Start the operation. Move the first data to accumulator. Move the second data to B-register. Initialize the C-register to 00. Add the content of B-register to accumulator. If there is no carry go to step 8.
INPUT
OUTPUT
8. Store the accumulator contents to the desired memory location. 9. Transfer the C-register content to accumulator. 10. Store the accumulator content at the desired memory location. 11. Stop the operation. Program: ADDRESS 4100 4102 4104 4106 4107 410A 410B 410E 410F 4112 Program : II 8-BIT SUBTRACTION Algorithm: 1. 2. 3. 4. 5. 6. Start the operation. Move the first data to accumulator. Move the second data to B-register. Subtract the content of B-register to accumulator. Store the result in desired memory location. Stop the operation. LOOP LABEL MNEMONICS MVI A, 95 MVI B, 89 MVI C,00 ADD B JNC LOOP [410B] INR C STA 4200 MOV A,C STA 4201 HLT 3E 06 0E 80 D2 0C 32 79 32 76 01 42 00 42 0B 41 95 89 00 OPCODE
INPUT
OUTPUT
Program:
10
OPCODE
42
Program : III 8-BIT MULTIPLICATION Algorithm: 1. Start the operation. 2. Load the multiplier from the desired memory location to accumulator. 3. Move the accumulator value to E-register. 4. Initialize the D-register to 00. 5. Load the multiplicand from the desired memory location to accumulator. 6. Move the accumulator value to C-register. 7. Load immediately HL register pair 0000. 8. Add the content of DE-register to HL register pair. 9. Decrement the C-register. 10. If there is no zero go to step 8. 11. Store the result in desired memory location. 12. Stop the operation.
11
INPUT
OUTPUT
Program:
12
ADDRESS 4100 4103 4104 4106 4109 410A 410D 410E 410F 4112 4115
LABEL
MNEMONICS LDA 4200 MOV E,A MVI D,00 LDA 4201 MOV C,A LXI H,0000 3A 5F 16 3A 4F 21 19 0D C2 22 76
OPCODE 00 42
00 01 42
00
00
LOOP
0D 00
41 43
Program : IV 8-BIT DIVISION Algorithm: 1. Start the operation. 2. Load the first data from the desired memory location to accumulator. 3. Move the accumulator value to B-register. 4. Load the second data from the desired memory location to accumulator. 5. Initialize the C-register to 00. 6. Compare B-register value with accumulator. 7. If there is carry go to step 11. 8. Subtract B-register value with accumulator. 9. Increment the C-register by 1. 10. Go to step 6. 11. Store the remainder in desired memory location. 12. Move C-register value to accumulator. 13. Store the quotient in desired memory location. 14. Stop the operation.
13
INPUT
OUTPUT
Program:
14
ADDRESS 4100 4103 4104 4107 4109 410A 410D 410E 410F 4112 4115 4116 4119
LABEL
OPCODE 00 42
01 00
42
LOOP1
12
41
09 00
41 43
LOOP
01
43
Result: Thus the programs for 8-bit arithmetic operations were written and the outputs were verified.
15
16
Aim: To write and execute programs for arranging numbers in ascending and descending order using 8085. Apparatus Required: 1. 8085 Microprocessor Kit. Program : I ARRANGING IN ASCENDING ORDER Algorithm: 1. 2. 3. 4. Start the operation. Move the number of datas immediately to B-register. Initialize the E-register value by total number of datas. Load immediately the datas to HL-register pair from successive memory location. 5. Move the H-register value to accumulator. 6. Increment the HL-register pair value by 1. 7. Decrement the E-register value by 1. 8. If there is zero then go to step 17. 9. Compare the value of accumulator with H-register. 10. If there is carry then go to step 5. 11. Move the value of H-register to D-register. 12. Decrement HL-register pair value by 1. 13. Move D-register value to H-register. 14. Increment HL-register pair value by 1. 15. Move the accumulator content to H-register. 16. Jump to step 5. 17. Decrement B-register value by1. 18. If there is no zero go to step 3. 19. Stop the operation.
INPUT
17
OUTPUT
ADDRESS
LABEL
MNEMONICS
OPCODE
18
4100 4102 4104 4107 4108 4109 410A 410D 410E 4111 4112 4113 4114 4115 4116 4119 411A 411D Program : II LOOP 1 LOOP 2 LOOP 3
MVI B,05 MVI E,05 LXI H,4200 MOV A,M INX H DCR E JZ LOOP 1 CMP M JC LOOP 2 MOV D,M DCX H MOV M,D INX H MOV M,A JMP LOOP 2 DCR B JNZ LOOP 3 HLT [4102] [4107] [4107] [4119]
06 1E 21 7E 23 1D CA BE DA 56 2B 72 23 77 C3 05 C2 76
05 05 00 42
19
41
07
41
07
41
02
41
ARRANGING IN DECENDING ORDER Algorithm: 1. Start the operation. 2. Move the number of datas immediately to B-register. 3. Initialize the E-register value by total number of datas. INPUT
19
OUTPUT
4. Load immediately the datas to HL-register pair from successive memory location. 5. Move the H-register value to accumulator. 6. Increment the HL-register pair value by 1. 20
7. Decrement the E-register value by 1. 8. If there is zero then go to step 17. 9. Compare the value of accumulator with H-register. 10. If there is no carry then go to step 5. 11. Move the value of H-register to D-register. 12. Decrement HL-register pair value by 1. 13. Move D-register value to H-register. 14. Increment HL-register pair value by 1. 15. Move the accumulator content to H-register. 16. Jump to step 5. 17. Decrement B-register value by1. 18. If there is no zero go to step 3. 19. Stop the operation. ADDRESS 4100 4102 4104 4107 4108 4109 410A 410D 410E 4111 4112 4113 4114 4115 LOOP 2 LOOP 3 LABEL MVI B,05 MVI E,05 LXI H,4200 MOV A,M INX H DCR E JZ LOOP 1 CMP M JNC LOOP 2 MOV D,M DCX H MOV M,D INX H MOV M,A [4107] [4119] MNEMONICS 06 1E 21 7E 23 1D CA BE D2 56 2B 72 23 77 07 41 19 41 OPCODE 05 05 00 42
21
[4107]
C3 05
07
41
22
411A 411D
[4102]
C2 76
02
41
Result: Thus the programs for arranging numbers in ascending and descending order were written and the outputs were verified.
23
24
Aim: To write and execute programs for number conversion using 8085. Apparatus Required: 1. 8085 Microprocessor Kit. Program : I HEXADECIMAL TO BINARY Algorithm: 1. Start the operation. 2. Load the hexadecimal data immediately to H-register from the desired memory location. 3. Initialize the B-register by 08. 4. Initialize the accumulator by 5A. 5. Rotate right with carry. 6. If there is carry go to step 9. 7. Initialize the H-register by 00. 8. Jump to step 10. 9. Initialize the H-register by 01. 10. Increment the HL-register pair by 1. 11. Decrement B-register by 1. 12. If there is no zero go to step 5. 13. Stop the operation.
INPUT
25
OUTPUT
ADDRESS 4100
LABEL
OPCODE 00 42
26
4103 4105 4107 4108 410B 410D 4110 4112 4113 4114 4117 Program : II LOOP 1 LOOP 2 LOOP 3
MVI B,08 MVI A,5A RRC JC LOOP 1 MVI M,00 JMP LOOP 2 MVI M,01 INX H DCR B JNZ LOOP 3 HLT [4107] [4112] [4110]
06 3E 0F DA 36 C3 36 23 05 C2 76
08 5A
10 00 12 01
41
41
07
41
BCD TO HEXADECIMAL Algorithm: 1. Start the operation. 2. Load the 16-bit BCD number immediately to HL-register pair from the desired memory location. 3. Move the L-register value to accumulator. 4. Add the value of accumulator value with accumulator. 5. Move the accumulator value to B-register. 6. Twice add accumulator value with accumulator value. 7. Add accumulator value with B-register. 8. Increment HL-register pair by 1. 9. Add the value of H-register value with accumulator. 10. Increment HL-register pair by 1. 11. Move the value of accumulator to H-register. 12. Stop the operation.
27
INPUT
OUTPUT
OPCODE 00 42
28
4104 4105 4106 4107 4108 4109 410A 410B 410C 410D
ADD A MOV B,A ADD A ADD A ADD B INX H ADD M INX H MOV M,A HLT
87 47 87 87 80 23 86 23 77 76
Result: Thus the programs for number conversion were written and the outputs were verified.
INPUT
29
OUTPUT
LARGEST AND SMALLEST NUMBERS Ex: No:06 Date : Aim: To write and execute programs to find largest and smallest numbers using 8085.
30
Apparatus Required: 1. 8085 Microprocessor Kit. Program : I LARGEST NUMBER Algorithm: 1. Start the operation. 2. Load the total numbers of data immediately to H-register from the desired memory location. 3. Move the H-register value to B-register. 4. Increment the HL-register pair value by 1. 5. Move the H-register value to accumulator. 6. Decrement the B-register value by 1. 7. Increment the HL-register pair by 1. 8. Compare the value of H-register with accumulator value. 9. If there is no carry go to step 11. 10. Move the H-register value to accumulator. 11. Decrement B-register value by 1. 12. If there is no zero go to step 7. 13. Store the result in the desired memory location. 14. Stop the operation. ADDRESS 4100 4103 4104 4105 4106 4107 4108 LOOP 2 LABEL MNEMONICS LXI H,4200 MOV B,M INX H MOV A,M DCR B INX H CMP M 21 46 23 7E 05 23 BE OPCODE 00 42
31
D2 7E 05 C2
0D
41
07
41
32
32 76
00
43
SMALLEST NUMBER Algorithm: 1. Start the operation. 2. Load the total numbers of data immediately to H-register from the desired memory location. 3. Move the H-register value to B-register. 4. Increment the HL-register pair value by 1. 5. Move the H-register value to accumulator. 6. Decrement the B-register value by 1. 7. Increment the HL-register pair by 1. 8. Compare the value of H-register with accumulator value. 9. If there is carry go to step 11. 10. Move the H-register value to accumulator. 11. Decrement B-register value by 1. 12. If there is no zero go to step 7. 13. Store the result in the desired memory location. 14. Stop the operation.
INPUT
33
OUTPUT
LABEL
OPCODE 00 42
34
4104 4105 4106 4107 4108 4109 410C 410D 410E 4111 4114 LOOP 1 LOOP 2
INX H MOV A,M DCR B INX H CMP M JC LOOP 1 [410D] MOV A,M DCR B JNZ LOOP 2 [4107] STA 4300 HLT
23 7E 05 23 BE DA 7E 05 C2 32 76 07 00 41 43 0D 41
Result: Thus the programs for finding largest and smallest number from a set of numbers were written and the outputs were verified.
INPUT [AUGEND]
35
INPUT [ADDEND]
CODE CONVERSION Ex: No:09 Date : Aim: To write and execute programs for code conversion using 8085. Apparatus Required:
36
1. 8085 Microprocessor Kit. Program: I 8-BIT BINARY TO ASCII Algorithm: 1. 2. 3. 4. Start the operation. Load the given data in A- register and move it to B-register. Mask the upper nibble of the binary data in A register. Call subroutine code to get ASCII code for the lower nibble and store in memory. 5. Move B-register to A-register and mask the lower nibble. 6. Rotate the upper nibble to lower nibble position. 7. Call subroutine code to get the ASCII code of upper nibble and store in memory location. Algorithm for subroutine code: 1. 2. 3. 4. 5. ADDRESS 4100 4103 4104 4106 4109 410C Compare the content of A-register with 0A H. If CY = 1 go to step 4, if CY=0 go to next step. Add 0F H to A-register. Add 30 H to A-register. Return to the main program. LABEL LDA 4200 MOV B,A ANI OF CALL CODE [411A] STA 4201 MOV A,B MNEMONICS 3A 47 E6 CD 32 78 0F 1A 01 41 42 OPCODE 00 42
INPUT
37
OUTPUT
E6 07 07 07
F0
38
4112 4113 4116 4119 411A 411C 411F 4121 4123 LOOP 1 CODE
RLC CALL CODE STA 4202 HLT CPI 0A JC LOOP 1 ADI 07 ADI 30 RET [4121] [411A]
07 CD 32 76 FE DA C6 C6 C9 0A 21 07 30 41 1A 02 41 42
Program: II 8-BIT BINARY TO HEXADECIMAL Algorithm: 1. 2. 3. 4. 5. 6. 7. 8. 9. Start the operation. Clear D-register and move to B-register. Get count for HL-register pair. Move the content of memory to accumulator and contents of Bregister and C-register. Rotate A-register through carry in right. Decrement B-register, if not jump to step 5. Else logically OR the D-register with A-register then increment. Store the result in the desired memory location. Stop the operation.
INPUT
39
OUTPUT
MNEMONICS 16 06 21
OPCODE 00 08 00 42
LXI H,4200
40
4107 4108 4109 410A 410B 410E 410F 4110 4111 4112 4115 4118
LOOP 2
7E 48 0F 0D [4109] C2 B2 57 23 05 [4107] C2 32 76 07 00 41 43 09 41
LOOP 1
RRC DCR C JNZ LOOP 1 ORA D MOV D,A INX H DCR B JNZ LOOP 2 STA 4300 HLT
Result: Thus the programs for code conversion were written and the outputs were verified.
41
42
43
OUTPUT
INTERFACING OF STEPPER MOTOR Ex: No:10 Date : Aim: To write and execute programs to run a stepper motor at different speeds in two directions using 8085. Apparatus Required:
44
1. 8085 Microprocessor Kit. 2. Stepper motor Algorithm: 1. Start the operation. 2. Load the datas immediately to H-register from the desired memory location. 3. Initialize the B-register value by 04. 4. Move the H-register value to accumulator. 5. Initialize the C-register using OUT instructions by 00. 6. Load the DE-register pair immediately from the desired memory location. 7. No operation. 8. Decrement DE-register pair by 1. 9. Move the E-register value to accumulator. 10. Logically OR D-register value with accumulator. 11. If there is no zero go to step 7. 12. Increment HL-register pair by1. 13. Decrement B-register value by 1. 14. If there is no zero go to step 4. 15. Jump to step 2. 16. Stop the operation. ADDRESS 4100 4103 4105 4106 4108 410B LOOP 1 LOOP 2 LABEL LOOP 3 MNEMONICS LXI H,4200 MVI B,04 MOV A,M OUT C,00 LXI D,0303 NOP 21 06 7E D3 11 00 C0 03 03 OPCODE 00 04 42
45
OUTPUT
1B 7B B2 C2 23 0B 41
46
05 C2 C3 05 00 41 41
Result: Thus the program to run a stepper motor at different speeds in two directions was written and the outputs were verified.
INPUT
47
OUTPUT
INTERFACING OF KEYBOARD AND DISPLAY Ex: No:11 Date : Aim: To write and execute program for performing keyboard and display interfacing using 8085. Apparatus Required: 1. 8085 Microprocessor Kit. Algorithm: 1. Start the operation.
48
2. Enter the necessary digit values for showing the required string. 3. Obtain the string in the keyboard of display. 4. Stop the operation. ADDRESS 4100 4102 4104 4106 4108 410A 410C 410F 4110 4111 4112 4114 4115 4118 Result: Thus the program for performing the keyboard and display was written and the outputs were verified. LOOP 1 LABEL MVI A,00 OUT 01 MVI A,CC OUT 01 MVI A,90 OUT 01 LXI H,4200 MOV C,M INX H MOV A,M OUT 00 DCR C JNZ LOOP 1 HLT [4110] MNEMONICS 3E D3 3E D3 3E D3 21 4E 23 7E D3 0D C2 76 10 41 00 OPCODE 00 01 CC 01 90 01 00 42
49
50
8051 PROGRAMS
ADDITION INPUT
51
OUTPUT
ARITHMETIC OPERATIONS Ex: No:15 Date : Aim: To write and execute programs for arithmetic operation using 8051. Apparatus Required: 1. 8051 Microcontroller Kit. Program : I 8-BIT ADDITION Algorithm:
52
1. 2. 3. 4. 5. 6.
Start the operation. Clear the carry flag. Get the first operand in accumulator. Add the second operand to accumulator. Store the result in the desired memory location. Stop the operation. MNEMONICS CLR C MOV A,20 ADDC A,05 MOV DPTR,#4500 MOVX @DPTR,A HERE : SJMP HERE C3 74 24 90 F0 80 FE 20 05 45 00 OPCODE
8-BIT SUBTRACTION Algorithm: 1. 2. 3. 4. 5. 6. Start the operation. Clear the carry flag. Get the first operand in accumulator. Subtract the second operand to accumulator. Store the result in the desired memory location. Stop the operation. SUBTRACTION INPUT
53
OUTPUT
MULTIPLICATION INPUT
OUTPUT
MNEMONICS CLR C MOV A,20 SUBB A,05 MOV DPTR,#4500 MOVX @DPTR,A HERE : SJMP HERE C3 74 94 90 F0 80 20 05 45
OPCODE
00
FE
54
Program : III 8-BIT MULTIPLICATION Algorithm: 1. 2. 3. 4. 5. 6. Start the operation. Get the multiplier in accumulator. Get the multiplicand in B-register. Multiply accumulator content with B-register content. Store the result in the desired memory location. Stop the operation.
Program: ADDRESS 4100 4102 4105 4106 4109 410A 410B 410D 410E MNEMONICS MOV A,0A MOV B,88 MUL AB MOV DPTR,#4500 MOVX @DPTR,A INC DPTR MOV A,B MOVX @DPTR,A HERE : SJMP HERE 74 75 A4 90 F0 A3 E5 F0 80 FE F0 45 00 OPCODE 0A F0 88
DIVISION INPUT
55
OUTPUT
Program : IV 8-BIT DIVISION Algorithm: 1. 2. 3. 4. 5. 6. Start the operation. Get the dividend in accumulator. Get the divider in B-register. Divide accumulator content by B-register content. Store the result in the desired memory location. Stop the operation.
56
MOV A,65 MOV B,08 DIV AB MOV DPTR,#4500 MOVX @DPTR,A INC DPTR MOV A,B MOVX @DPTR,A HERE : SJMP HERE
74 75 84 90 F0 A3 E5 F0 80
65 F0 08
45
00
F0
FE
Result: Thus the programs for arithmetic operations were written and the outputs were verified.
INPUT
57
OUTPUT
LOGICAL AND BIT MANIPULATION OPERATIONS Ex: No:16 Date : Aim: To write and execute programs for logical and bit manipulation operations using 8051. Apparatus Required: 1. 8051 Microcontroller Kit. Program : I LOGICAL OPERATION Algorithm: 1. Start the operation.
58
2. Get the input data in the specified memory locations. 3. Perform the logical operations such as AND,OR,EX-OR and COMPLEMENT among the inputs. 4. Store the result in the desired memory location. 5. Stop the operation. ADDRESS 4100 4102 4103 4106 4107 4108 4109 410A MNEMONICS MOVA,03 CPL A MOV DPTR,#4200 MOVX @DPTR,A INC INC DPTR MOVX @DPTR,A HERE : SJMP HERE 74 F4 90 F0 04 A3 F0 80 FE 42 00 03 OPCODE
INPUT
59
OUTPUT
Program : II ADDRESS 4100 4102 4104 4107 4108 410A 410B MNEMONICS MOVA,03 ORL A,02 MOV DPTR,#4500 MOV @DPTR,A ANL A,06 INC DPTR MOVX @DPTR,A 74 44 90 F0 54 A3 F0 06 03 02 45 00 OPCODE
60
64 A3 F0 80
01
FE
Program : III BIT MANIPULATION OPERATION Algorithm: 1. 2. 3. 4. 5. Start the operation. Obtain the input data from the user. Perform the bit manipulation. Store the result in the desired memory location. Stop the operation.
INPUT
OUTPUT
61
ADDRESS 4100 4103 4105 4107 410A 410B 410C 410E 4110
MNEMONICS MOVB,FF MOV A,0F SET B MOV DPTR,#4500 MOVX @DPTR,A INC DPTR CLR F3 MOV A,B MOVX @DPTR,A 75 74 D2 90 F0 A3 C2 E5 F0
OPCODE F0 0F E7 45 00 FF
F3 F0
62
C4 A3 F0 80 FE
Result: Thus the programs for logical and bit manipulation operations were written and the outputs were verified.
63