1. 8 BIT DATA ADDITION
AIM:To write an assembly language program to add two 8 bit numbers with carry. APPARATUS REQUIRED
1. 8085 Microprocessor kit. 2. Power chord.
ALGORITHM:
1. Clear C-register for carry.
2. Move the first data from memory to accumulator and move it to B-register.
3. Move the second data from memory to accumulator. 4. Add the content of B-register with Accumulator.
5. Check for carry. If carry=’1’ then go to step 6 else go to step 7. 6. Increment the C-register.
7. Store the sum in memory.
8. Move the carry to accumulator and store in memory. 9. Stop.
FLOW CHART: NO YES START [HL] 2000H [A] [M] [A] [A]+[M] [HL] [HL]+1 STOP [HL] [HL]+1 [M] [A] [C] 00H [M] [C] [HL] [HL]+1 Is there a Carry ? [C] [C]+1
PROGRAM:
OBSERVATION:
RESULT
Thus the assembly language program to add the two 8-bit numbers was written and executed successfully
MEMORY
ADDRESS
LABEL
MNEMONICS
OP CODE
2100 LDA 2200 3A 00 22 2103 MOV B,A 47 2104 LDA 2201 3A 01 22 2107 MVI C,00 0E 00 2109 ADD B 80 210A JNC LOOP D2 0E 21 210D INR C 0C
210E LOOP STA 2202 32 02 22
2111 MOV A,B 79
2112 STA 2203 32 03 22
2115 HLT 76
INPUT
OUTPUT
Address
Data
Address
Data
2200
02H
2202
07H(sum)
2. SUBTRACTION OF TWO 8-BIT NUMBERS WITH BORROW USING 8085
AIM
To write an assembly language program to subtract the two 8-bit numbers with BORROW.
APPARATUS REQUIRED
1. 8085 Microprocessor kit. 2. Power chord.
ALGORITHM:
1. Clear C-register for sign.
2. Move the subtrahend from memory to accumulator and move it to B-register.
3. Move the minuend from memory to accumulator. 4. Subtract the content of B-register with Accumulator.
5. Check for carry. If carry=’1’ then go to step 6 else go to step 7. 6. Increment the C-register. Complement the accumulator and add 01H. 7. Store the Difference in memory.
8. Move the sign to accumulator and store in memory. 9. Stop.
FLOW CHART: NO YES START [HL] 2500H [A] [M] Is there a Borrow ? [A] [A]-[M] [HL] [HL]+1 [C] 00H [C] [C]+1 STOP [HL] [HL]+1 [M] [A] [M] [C] [HL] [HL]+1 Complement [A] Add 01H to [A]
PROGRAM:
OBSERVATION:
RESULT
Thus the assembly language program to subtract the two 8-bit numbers was written and executed successfully.
MEMORY
ADDRESS
LABEL
MNEMONICS
OP CODE
2100 LDA 2201 3A 00 22 2103 MOV B,A 47 2104 LDA 2200 3A 01 22 2107 MVI C,00 0E 00 2109 SUB B 90 210A JNC LOOP D2 11 21 210D INR C 0C 210E CMA 2F 210F ADI 01H C6 01 2111 LOOP STA 2202 32 03 22 2114 MOV A,C 79 2115 STA 2203 32 03 22 2118 HLT 76
INPUT
OUTPUT
Address
Data
Address
Data
2200
04H
2202
02H(Difference)
2201
02H
2203
00H(Sign)
3.
MULTIPLICATION OF TWO 8-BIT NUMBERS USING 8085AIM
To write an assembly language program to multiply the two 8-bit numbers.
APPARATUS REQUIRED
1. 8085 Microprocessor kit. 2. Power chord.
ALGORITHM:
1. Load the address of the first data in HL pair (pointer). 2. Clear C-register for overflow (carry).
3. Clear the accumulator.
4. Move the first data to B-register. 5. Increment the pointer.
6. Move the second data to D-register from memory (multiplicand). 7. Add the content of D-register to accumulator.
8. Check for carry, if carry=1, go to step 9, or carry = 0, go to step 10. 9. Increment the C-register.
10. Decrement B-registers (count).
11. Check whether count has reached zero. If ZF=0, repeat step 7 through 11, or if ZF=1 go to next step.
12. Increment the pointer and store LSB of the product in memory. 13. Increment the pointer and store MSB of the product in memory. 14. Stop.
FLOW CHART: NO YES NO YES [HL] 2500 B M A 00 C 00 Is there any carry C C+1 B B-1 [A] [A] +[M] [HL] [HL]+1 IS B=0 A START
A STOP [HL] [HL]+1 [M] [A] [M] [C] [HL] [HL]+1
PROGRAM:
OBSERVATION:
INPUT OUTPUT
Address Data Address Data
2200 02H 2202 08(LSB 0f product)
2201 04H 2203 00H(MSB of product)
RESULT
Thus the assembly language program to multiply the two 8-bit numbers was written and executed successfully
MEMORY ADDRESS
LABEL MNEMONICS OP CODE
2100 LXI H,2200 21 00 22 2103 MVI C,00 0E,00 2105 XRA A AF 2106 MOV B,M 46 2107 INX H 23 2108 MOV D,M 56 2109 REPT ADD D 82 210A JNC AHEAD D2 0E 21 210D INR C 0C 210E AHEAD DCR B 05 210F JNZ REPT C2 09 21 2112 INX H 23 2113 MOV M,A 77 2114 INX H 23 2115 MOV M,C 71 2116 HLT 76
4. DIVISON OF TWO 8-BIT NUMBERS WITH BORROW
AIM
To write an assembly language program to divide the two 8-bit numbers with remainder.
APPARATUS REQUIRED
1. 8085 Microprocessor kit. 2. Power chord.
ALGOROTHIM
1. Load the divisor in accumulator and move it to B-register. 2. Load the dividend in accumulator.
3. Clear C-register to account for quotient.
4. Check whether divisor is less than dividend, If divisor is less than dividend, go to step 8, otherwise go to next step.
5. Subtract the content of B-register form accumulator. 6. Increment the content of C-register (quotient). 7. Go to step 4.
8. Store the content of accumulator (remainder) in memory.
9. Move the content of C-register (quotient) to accumulator and store in memory.
FLOWCHART: NO YES B 00 M A-M [B] [B] +1 IS A<0 A A+ M B B-1 [HL] 2500 A M [HL] [HL]+1 START STOP [HL] [HL]+1 [M] [A] [M] [B] [HL] [HL]+1
PROGRAM:
OBSERVATION:
INPUT OUTPUT
Address Data Address Data
2200 02H 2202 08(LSB 0f product)
2201 04H 2203 00H(MSB of product)
RESULT
Thus the assembly language program to divide the two 8-bit numbers was written and executed successfully.
MEMORY ADDRESS
LABEL MNEMONICS OP CODE
2100 LDA,2201 3A 01 22 2103 MOV B,A 47 2104 LDA 2200 3A 00 22 2107 MVI C,00 0E 00 2109 AGAIN CMP B B8 210A JC STORE DA 12 21 210D SUB B 90 210E INR C 0C 210F JNC AGAIN C3 09 21 2112 STORE STA 2203 32 03 42 2115 MOV A,C 79 2116 STA 2202 32 02 22 2119 HLT 76
5. 16 BIT DATA ADDITION
AIM:To add two 16-bit numbers stored at consecutive memory locations APPARATUS REQUIRED
1. 8085 Microprocessor kit. Power chord..
ALGORITHM:
1. Initialize memory pointer to data location.
2. Get the first number from memory and store in Register pair. 3. Get the second number in memory and add it to the Register pair. 4. Store the sum & carry in separate memory locations.
FLOW CHART: NO YES START [DE] [HL] [L] [2052H] [H] [2053H] [A] 00H [HL] [HL]+[DE] [L] [2050 H] [H] [2051 H] Is there a Carry? STOP [2054] [ L] [2055] [H] [A] [A]+1 [2056] [A]
PROGRAM:
ADDRESS LABEL MNEMONICS OPCODE
2100 MVI C,00 0E,00 2102 LXI H,2200 21,00,22 2105 MOV E,M 5E 2106 INX H 23 2107 MOV D,M 56 2108 INX H 23 2109 MOV A,M 7E 210A ADD E 83 210B STA 2204 32,04,22 210E INX H 23 210F MOV A,M 7E 2110 ADC D 8A 2111 JC LABEL1 D2,15,21 2114 INR C 79 2115 LABEL1 STA 2205 32,06,22 2118 MOV A,C 79 2119 STA 2206 32,06,22 211C HLT 76 OBSERVATION: WITHOUT CARRY CARRY WITH INPUT INPUT 2200:65 2200:BC 2201:78 2201:FA 2202:21 2202:76 2203:43 2203:98 OUTPUT: OUTPUT 2204:86 2204:32 2205:BB 2205:93 2206:00 2206:01 RESULT
Thus the assembly language program to add the two 16-bit numbers was written and executed successfully
6. 16 BIT DATA SUBTRACTION
AIM:To subtract two 16-bit numbers stored at consecutive memory locations. APPARATUS REQUIRED
1. 8085 Microprocessor kit. 2. Power chord.
ALGORITHM:
1. Initialize memory pointer to data location.
2. Get the subtrahend from memory and transfer it to register pair. 3. Get the minuend from memory and store it in another register pair. 4. Subtract subtrahend from minuend.
5. Store the difference and borrow in different memory locations.
FLOW CHART: NO YES START [DE] [HL] [L] [2052H] [H] [2053H] [HL] [HL]-[DE] [L] [2050 H] [H] [2051 H] Is there a borrow? STOP [2054] [ L] [2055] [H] [C] [C]+1 [2056] [C]
PROGRAM:
OBSERVATION:
WITHOUT CARRY WITHCARRY
INPUT INPUT 2200:65 2200:BC 2201:78 2201:FA 2202:21 2202:76 2203:43 2203:98 OUTPUT: OUTPUT 2204:86 2204:32 2205:BB 2205:93 2206:00 2206:01 RESULT
Thus the assembly language program to subtract the two 8-bit numbers was written and executed successfully
ADDRESS LABEL MNEMONICS OPCODE
2100 MVI C,00 0E,00 2102 LXI H,2200 21,00,22 2105 MOV E,M 5E 2106 INX H 23 2107 MOV D,M 56 2108 INX H 23 2109 MOV A,M 7E 210A SUB E 93 210B STA 2204 32,04,22 210E INX H 23 210F MOV A,M 7E 2110 SBB D 9A 2111 JNC LABEL1 D2,15,21 2114 INR C 0C 2115 LABEL1 STA 2205 32,06,22 2118 MOV A,C 79 2119 STA 2206 32,06,22 211C HLT 76
7. 16 BIT MULTIPLICATION
AIM:To multiply two 16 bit numbers and store the result in memory. APPARATUS REQUIRED
1. 8085 Microprocessor kit. 2. Power chord.
ALGORITHM:
1. Get the multiplier and multiplicand. 2. Initialize a register to store partial product. 3. Add multiplicand, multiplier times.
4. Store the result in consecutive memory locations. .
FLOWCHART: NO YES NO YES START L [2050] H [2051] L [2052] H [2053] SP HL DE HL HL 0000 BC 0000 HL HL+SP Is Carry flag set? BC BC+1 DE DE+1 Is Zero flag set? A
A [2054] L [2055] H [2056] C [2057] B STOP
PROGRAM:
OBSERVATION:
INPUT (Before sorting) OUTPUT (After sorting)
2001 04H 3001 08H(multiply)
2002 02H 2202 08H(Multiply)
2003 02H 3002 00H(Carry)
RESULT
Thus the assembly language program to multiply the two 8-bit numbers was written and executed successfully.
MEMORY ADDRESS
LABEL MNEMONICS OPCODE
2100 START LHLD 2000H 2A 00 20 2103 SPHL F9 2104 LHLD 2002 2A 02 20 2107 LOOP2 XCHG EB 2108 LXI H,0000H 21 00 00 210B LXI B,0000H 01 00 00 210E DAD SP 39 210F LOOP1 JNC NEXT D2 00 01 2112 INX B 03 2013 NEXT DCX D 1B 2014 MOV A,E 7B 2015 ORA D B2 2016 JNZ LOOP C2 0E 10 2019 SHLD 3000H 22 00 30 201C MOV A,C 79 201D STA 3001H 32 01 30
2020 AHEAD MOV A,B 78
2021 STA 3002H 32 02 30
8. 16- BIT DIVISION
AIM:To divide two 16-bit numbers and store the result in memory using 8085 nemonics.
APPARATUS REQUIRED
1. 8085 Microprocessor kit. Power chord
ALGORITHM:
1. Get the dividend and divisor. 2. Initialize the register for quotient.
3. Repeatedly subtract divisor from dividend till dividend becomes less than divisor.
4. Count the number of subtraction which equals the quotient. 5. Store the result in memory.
FLOWCHART: NO YES START L [2051] H [2052] HL DE L [2050] H [2051] BC 0000H A L; A A- E L A A H A A- H- Borrow H A BC BC+ 1 Is Carry flag set ? A
A BC BC- 1 HL HL+DE L [2054] H [2055] A C [2056] A A B [2057] A STOP
PROGRAM: MEMORY LOCATION
LABEL MNEMONICS HEX CODE
2500 LXI B,0000 0 00 00
2503 LHLD 2802 2A 02 28
2506 XCHG EB
2507 LHLD 2800 2A 00 28
250A LOOP 2 MOV A,L 7D
250B SUB E 93 250C MOV L,A 6F 250D MOV A,H 7C 250E SUB D 9A 250F MOV H,A 67 2510 JC LOOP 1 DA 17 25 2513 INX B 03 2514 JMP LOOP 2 C3 0A 25 2517 LOOP 1 DAD D 19 2518 SHLD 2806 22 06 28 251B MOV L,C 69 251C MOV H,B 60 251D SHLD 2804 22 04 28 2520 HLT 76 OBSERVATION: INPUT
INPUT ADDRESS VALUE
2800 04
2801 00
2802 02
2803 00
OUTPUT
OUTPUT ADDRESS VALUE
2804 02
2805 00
2806 FE
2807 FF
RESULT
Thus the assembly language program to divide the two 16-bit numbers was written and executed successfully
9.MAXIMUM OF NUMBER IN THE ARRAY USING 8085
AIM
To write an assembly language program to search the maximum of number data in the array.
APPARATUS REQUIRED 1. 8085 Microprocessor kit 2. Power chord.
ALGOROTHIM
1. Load the address of the first element of the array in HL register pair. 2. Move the count to B-register.
3. Increment the pointer.
4. Get the first data in accumulator. 5. Decrement the count.
6. Increment the pointer.
7. Compare the content of memory addressed by HL pair with that of accumulator.
8. If carry = 0, go to step 10, or if carry =1, go to step 9. 9. Move the content memory addressed HL to accumulator. 10. Decrement the count.
11. Check for zero of the count. If ZF=0, go to step 6, or if ZF=1, go to next step. 12. Store the smallest data in memory.
PROGRAM: MEMORY ADDRESS
LABEL MNEMONICS OP CODE
2100 LXI H, 2200 21 00 22 2103 MOV B,M 46 2104 INX H 23 2105 MOV A,M 7E 2106 DCR B 05 2107 LOOP INX H 23 2108 CMP M BE 2109 JNC AHEAD D2 OD 21 210C MOV A,M 7E 210D AHEAD DCR B 05 210E JNZ LOOP C2 07 21 2111 STA 2300 32 00 23 2114 HLT 76 OBSERVATION: INPUT OUTPUT
Address Data Address Data
2200 05H 2300 0CH 2201 0AH 2202 03H 2203 08H 2204 06H 2205 0CH RESULT
Thus the assembly language program to search the largest data in an array was written and executed successfully.
10.MINIMUM OF NUMBER IN THE ARRAY USING 8085
AIM
To write an assembly language program to search the minimum of number data in the array.
APPARATUS REQUIRED 1.8085 Microprocessor kit 2. Power chord.
ALGOROTHIM
1. Load the address of the first element of the array in HL register pair. 2. Move the count to B-register.
3. Increment the pointer.
4. Get the first data in accumulator. 5. Decrement the count.
6. Increment the pointer.
7. Compare the content of memory addressed by HL pair with that of accumulator.
8. If carry = 1, go to step 10, or if carry =0, go to step 9. 9. Move the content memory addressed HL to accumulator. 10. Decrement the count.
11. Check for zero of the count. If ZF=0, go to step 6, or if ZF=1, go to next step. 12. Store the smallest data in memory.
13. Stop.
PROGRAM
MEMORY ADDRESSLABEL MNEMONICS OP CODE
2100 LXI H, 2200 21 00 22 2103 MOV B,M 46 2104 INX H 23 2105 MOV A,M 7E 2106 DCR B 05 2107 LOOP INX H 23 2108 CMP M BE 2109 JC AHEAD DA OD 21 210C MOV A,M 7E 210D AHEAD DCR B 05 210E JNZ LOOP C2 07 21 2111 STA 6300 32 00 23 2114 HLT 76
OBSERVATION:
INPUT OUTPUTAddress Data Address Data
2200 05H 2300 03H 2201 0AH 2202 03H 2203 08H RESULT
Thus the assembly language program to search the smallest data in an array was written and executed successfully.
11.ARRANGE THE GIVEN NUMBER IN ASCENDING ORDER USING 8085
AIM
To write an assembly language program to sort an array of data in ascending order.
ALGOROTHIM
1. Load the count value from memory to A-register and store it in B-register. 2. Decrement B-register (B is a count for (N-1) repetitions).
3. Set HL pairs as data address pointer.
4. Set C-register has counter for (N-1) comparisons.
5. Load a data of the array in accumulator using the data address pointer. 6. Increment the HL pair (data address pointer).
7. Compare the data pointed by HL with accumulator.
8. If carry flag is set (if the content of accumulator is smaller than memory) the go to step 10, otherwise, go to next step.
9. Exchange the content of memory pointed by HL and the accumulator. 10. Decrement C-register. If zero flag is reset go to step 6, otherwise go to next
step.
11. Decrement B-register. If zero flag is reset go to step 3, otherwise, go to next step.
PROGRAM
MEMORYADDRESS
LABEL MNEMONICS OPCODE
2100 LDA, 2200 3A 00 22 2103 MOV B,A 47 2104 DCR B 05 2105 LOOP2 LXI H,2200 21 00 22 2108 MOV C,M 4E 2109 DCR C 0D 210A INX H 23
210B LOOP1 MOV A,M 7E
211C INX H 23 210D CMP M BE 210E JC AHEAD DA 16 21 2111 MOV D,M 56 2112 MOV M,A 77 2113 DCX H 2B 2114 MOV M,D 72 2115 INX H 23 2116 AHEAD DCR C 0D 2117 JNZ LOOP1 C2 0B 21 211A DCR B 05 211B JNZ LOOP2 C2 05 21 211E HLT 76
OBSERVATION:
INPUT (Before sorting) OUTPUT (After sorting)
2200 04H 2200 04H 2201 0AH 2201 03H 2202 0CH 2202 06H 2203 06H 2203 0AH 2204 03H 2204 0CH RESULT
Thus the assembly language program to sort an array of data in ascending order was written and executed successfully.
12.ARRANGE THE GIVEN NUMBER IN DESCENDING ORDER USING 8085
AIM
To write an assembly language program to sort an array of data in descending order.
ALGOROTHIM
1. Load the count value from memory to A-register and store it in B-register. 2. Decrement B-register (B is a count for (N-1) repetitions).
3. Set HL pairs as data address pointer.
4. Set C-register has counter for (N-1) comparisons.
5. Load a data of the array in accumulator using the data address pointer. 6. Increment the HL pair (data address pointer).
7. Compare the data pointed by HL with accumulator.
8. If carry flag is reset set (if the content of accumulator is larger than memory) the go to step 10, otherwise, go to next step.
9. Exchange the content of memory pointed by HL and the accumulator. 10. Decrement C-register. If zero flag is reset go to step 6, otherwise go to next
step.
11. Decrement B-register. If zero flag is reset go to step 3, otherwise, go to next step.
PROGRAM
OBSERVATION:
INPUT (Before sorting) OUTPUT (After sorting)
2200 04H 2200 04H 2201 0AH 2201 0CH 2202 0CH 2202 0AH 2203 06H 2203 06H 2204 03H 2204 03H RESULT
Thus the assembly language program to sort an array of data in descending order was written and executed successfully.
MEMORY ADDRESS
LABEL MNEMONICS OPCODE
2100 LDA 2200 3A 00 22 2103 MOV B,A 47 2104 DCR B 05 2105 LOOP2 LXI H,2200 21 00 22 2108 MOV C,M 4E 2109 DCR C 0D 210A INX H 23
210B LOOP1 MOV A,M 7E
210C INX H 23 210D CMP M BE 210E JNC AHEAD D2 16 21 2111 MOV D,M 56 2112 MOV M,A 77 2113 DCX H 2B 2114 MOV M,D 72 2115 INX H 23 2116 AHEAD DCR C 0D 2117 JNZ LOOP1 C2 0B 21 211A DCR B 05 211B JNZ LOOP2 C2 05 21 211E HLT 76