Programming With 8085
Programming With 8085
.1 AIM: To write an assembly language program to add two 8 bit data using 8085 microprocessor. APPARATUS REQUIRED: 8085 Microprocessor kit 1 no. ALGORITHM: Step 1 : Step 2 : Step 3 : Step 4 : Step 5 : Step 6 : Step 7 : Step 8 : Step 9 : Program: Address
4100 4101 4102 4103 4104 4105 4106 4107 4108 4109
Date:
Initialize C register with 00 H Load the accumulator with the data from the address Copy the content of the accumulator to B register Load the accumulator with the data from the address Add the content of accumulator with the content in B register and store it in accumulator If there is carry, increment C register else store the content of the accumulator in the address given Move the content of C register to accumulator Store the content of the accumulator in the given address Stop
Label
Mnemonic
MVI C, 00H LDA 4500H MOV B, A LDA 4501H ADD B
Opcodes
0E 00 3A 00 45 47 3A 01 45 80
Comments
Initialize C Register with the data 00H Load accumulator with The content from 4500 Move the content of A to B Load A with the Content of the Address 4501 Add the contents of A & B
410A 410B 410C 410D 410E 410F 4110 4111 4112 4113 4114 4115
LAST
D2 0E 41 OC 32 00 42 79 32 01 42 76
Jump on NO carry To 410E Increment C register Store the accumulator Content in 4200 Move the content of C to A stores the accumulator Content in 4200 STOP
: :
FFH 06H
: :
05H 01H
RESULT: Thus the assembly language program to add two 8 bit data was written and verified.
8 BIT SUBTRACTION Exp.No. AIM: To write an assembly language program to subtract a 8 bit from another 8 bit data using 8085 microprocessor kit. APPARATUS REQUIRED: 8085 Microprocessor kit 1 no. ALGORITHM: Step 1 Step 2 Step 3 Step 4 Step 5 Step 6 Step 7 Step 8 Step 9 Program: Address Label
4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 410A 410B 410C 410D 410E
Date:
: : : : : : : : :
Initialize the C register with 00 H Load the accumulator with data from the memory Copy the content of the accumulator to the B register. Load the accumulator with data from memory Subtract the content of the register B with the accumulator and store in it If there is borrow, increment C Store the accumulator content in the given address Copy the content of the C register to the accumulator Store the accumulator content in the given address Stop. Opcodes
0E 00 3A 00 45 47 3A 01 45 80 D2 0E 41 OC 32
Mnemonic
MVI C, 00H LDA 4500H MOV B, A LDA 4501H SUB B INC LAST INR C STA 4200 H
Comments
Initialize C Register with the data 00H Load accumulator with The content of the address 4500 Move the content of A to B Load A with the accumulator With the content of the Address 4501H [A] [B] A Jump on NO carry To 410E Increment C register Store the accumulator
LAST
00 42 79 32 01 42 76
Content in the address 4200 Move the content of C to A stores the accumulator Content in 4201 STOP
: :
06H ABH
: :
A5H 00H
RESULT: Thus the assembly language program to subtract a 8 bit data from another 8 bit data was written and verified.
8 BIT MULTIPLICATION
Exp.No. AIM: To write an assembly language program to multiply two 8 bit data. APPARATUS REQUIRED: 8085 Microprocessor kit 1 no. ALGORITHM: Step 1 Step 2 Step 3 Step 4 Step 5 Step 6 Step 7 Step 8 Step 9 Step 10: Step 11: Step 12: Step 13: Program: Address
4100 4101 4102 4103 4104 4105 4106 4107
Date:
: : : : : : : : :
Initialize the C register with 00 H Load the accumulator from memory location with the Multiplicand Copy the accumulator content to B register Load the accumulator with the multiplier from the memory Location Copy the accumulator content to D register Initialize the accumulator with 00H Add the content of B register with accumulator If there is carry, increment C register Decrement the content of D register Content in memory location
If there is no zero, jump to step 7, else store the accumulator Copy the content of C register to accumulator Store the accumulator content in memory location Stop
Label
Mnemonic
MV1 C, 00H LDA, 5000H MOV B, A LDA, 5001H 0E 00 3A 00 50 47 3A 01
Opcodes
Comments
Initialize C register With 00H Load the accumulator With the content of 5000 Move the content of A to B Load the accumulator With the content of
4108 4109 410A 410B 410C 410D 410E 410F 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 411A 411B 411C
MOV D, A MVI A, 00H ADD B JNC loop INR C DCR D INZ loop1 STA, 5002H MOV, A, C STA, 5003H HLT
50 57 3E 00 80 D2 11 41 OC 15 C2 0C 41 32 02 50 79 32 03 50 76
The address 5001 Move the content of A to D Initialize the Accumulator with 00H [A] + [B] A Jump on No carry To 4111 Increment C register Decrement D register Jump on NO Zero to 410C Store the accumulator Content in the Address 5002 Move the content of C to A Store the accumulator Content in the address 5003 Stop
: :
FBH 3AH
: :
DEH 38H
RESULT: Thus the assembly language program to multiply two 8 bit data was written and verified.
8 BIT DIVISION
Exp.No. AIM:
Date:
To write an assembly language program to perform division using two 8 bit data. APPARATUS REQUIRED: 8085 Microprocessor kit 1 no. ALGORITHM: Step 1 Step 2 Step 3 Step 4 Step 5 Step 6 Step 7 Step 8 Step 9 Step 10: Step 11: Step 12: Program: Address
4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 410A 410B 410C 410D 410E 410F 4110 4111 4112 4113 4114
: : : :
Initialize the C register with 00H Load the accumulator with divisor form the memory location Copy the accumulator content to B register Load the accumulator with dividend from the memory Location : Subtract the content of B register from A : Increment the content of C register by 1 : Compare B registers content with accumulator : If there is no carry, jump to step 5 : Store the accumulator content in a memory location Copy the content of C register to accumulator Store the accumulator content in a memory address Stop
Label
Mnemonic
LDA, 4200 MOV C, A LDA, 4201 MV1 D, 00H
Opcodes
3A 00 42 4F 3A 01 42 16 00 B9 DA 12 41 91 14 C3 09 41 32 00 46
Comments
Load the accumulator With the divisor From the address Move the contents of A to C Load the accumulator With the dividend From the address Initialize the D Register with 00H Compare C with A Jump on carry To 4112 [A] [C] A Increment D register Jump to 4109 Store the accumulator Content in the address
Loop1
Loop2
STA, 4600
7A 32 01 46 76
Move the content of D to A Store the accumulator Content in the address Stop the program
: :
05H FFH
: :
00H 33H
RESULT: Thus the assembly language program to perform 8 bit division was written and verified.
16 BIT ADDITION
Exp.No. AIM: To write an assembly language program to add two 16-bit data. APPARATUS REQUIRED: 8085 Microprocessor kit ALGORITHM: Step 1 Step 2 Step 3 Step 4 Step 5 Step 6 Step 7 Step 8 Step 9 Step 10: Step 11: Step 12: Step 13: Program: Address
4100 4101 4102 4103 4104 4105 4106 4107
Date:
: : : : : : : : :
Initialize the C register with 00H. Load the HL register pair with the data from the memory location Get the second data in the DE register pair. Move the content of E register to accumulator Add the content of L register with accumulator Store the accumulator content in a memory location Move the content of D register to accumulator Add the content of H register with accumulator with carry Store the result in the accumulator in a address
If carry is generated, increment the C register Move the content of C register to accumulator Store the accumulator content in a memory location Stop
Label
Mnemonic
MVI C, 004 LHLD 4500 LDA 4502
Opcodes
OE 00 2A 00 45 3A 02 45
Comments
Initialize the C Reg with 00H Load HL reg pair With the data from The address Load the accumulator With the content of The address
4108 4109 410A 410B 410C 410D 410E 410F 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 411A 411B 411C 411D 411E 411F
MOV D, A LDA, 4503 MOV E, A MOV A, L ADD E STA, 4505 MOV A, H ADC D INC loop1 INR C STA, 4506 MOV A, C STA, 4507 HLT
Loop1
57 3A 03 45 5F 7D 83 32 05 45 7C 8A D2 18 41 OC 32 06 45 79 32 07 45 76
Move the content A to D Load the accumulator With the content of The address Move the content of A to E Move the content of L to A [A]+[E]A Store the accumulator Content in the Given address Move the content of H to A [A]+[D]+CYA Jump on No Carry to 4118 Increment C register Store the accumulator Content in given Address Move the content of C to A Store the accumulator Content in the given Address Terminate the programme
OUTPUT: INPUT: Address 4500 4501 4502 4503 OUTPUT : : : : : Data 80H 0FH 50H 03H 4505 4506 : : D0H 12H
RESULT: Thus the assembly language program to add two 16 bit datas was written and verified.
FLOW CHART
If carry
Increment C
STOP
16 BIT SUBTRACTION
Exp.No. AIM: To write an assembly language program to perform 16-bit subtraction. APPARATUS REQUIRED: 8085 Microprocessor kit ALGORITHM: Step 1 Step 2 Step 3 Step 4 Step 5 Step 6 Step 7 Step 8 Step 9 Step 10: Step 11: Step 12: Step 13: Program: Address
4100 4101 4102 4103 4104 4105 4106 4107 4108
Date:
: : : : : : : : :
Initialize the C register with 00h Get the first data in H L register pair Get the second data in the DE register pair. Move the content of L register to accumulator Subtract the content of E register with accumulator Store the accumulator content in a memory location Move the content of H register to accumulator Subtract the content of D register with accumulator with Borrow Store the result in the accumulator in a memory location
If borrow is generated, increment the C register Move the content of C register to A Store the accumulator content in a memory location Stop
Label
Mnemonic
MVI C, 004 LHLD 4500 LDA 4502 MOV D, A
Opcodes
OE 00 2A 00 45 3A 02 45 57
Comments
Initialize the C reg with 00H Load H L reg pair With the content of the address Load the accumulator with data in the address Move the content A to D
4109 410A 410B 410C 410D 410E 410F 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 411A 411B 411C 411D 411E 411F
LDA, 4503 MOV E, A MOV A, L SUB E STA, 4505 MOV A, H SBB D INC loop1 INR C STA, 4506 MOV A, C STA, 4507 HLT
Loop1
3A 03 45 5F 7D 83 32 05 45 7C 8A D2 18 41 OC 32 06 45 79 32 07 45 76
Load the accumulator with data in the address Move the content of A to E Move the content of L to A [A]-[E]A Store the data in accumulator in the given address Move the content of H to A [A]-[D]+BrA Jump on No Carry (or) borrow to 4118 Increment C Store the accumulator Content in the given address Move the content of C to A Store the accumulator Content in the given Address Terminate the programme
OUTPUT: INPUT: Address 4500 4501 4502 4503 OUTPUT : : : : : Data DAH ABH 58H 62H 4505 4506 4507 : : : 79H 53H 00H
RESULT: Thus the assembly language program to perform 16 bit subtraction was written and verified.
FLOW CHART
YES
Increment C
STOP
16 BIT MULTIPLICATION
Exp.No. AIM:
Date:
To write an assembly language program to perform 16-bit multiplication using 8085 microprocessor. APPARATUS REQUIRED: 8085 Microprocessor kit 1 no. ALGORITHM: Step 1 Step 2 Step 3 Step 4 Step 5 Step 6 Step 7 Step 8 Step 9 Step 10: Step 11: Step 12: Step 13: Step 14: Program: Address
4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 410A 410B 410C 410D 410E 410F
Load the HL register pair with the multiplicand from the memory : Move the content of HL to stack pointer : Load the HL register pair with the multiplier from the memory location : Exchange the content of HL register pair with DE : Initialize the HL register pair with 0000H : Initialize the BC register pair with 0000H : Add the content of Sp with HL : If there is carry, increment BC register pair : Decrement DE register pair by 1 If there is no zero, jump on to Step 7 Store the content of HL register pair in memory location Exchange the content of DE register pair with HL Store the content of HL register pair in memory location Stop
Label
Mnemonic
LHLD 4200 SPHL LHLD 4202 XCHG LXI H, 0000H LXI B, 0000H
Opcodes
2A 00 42 F9 DA 02 42 EB 21 00 00 01 00 00 39 D2
Comments
Load the HL register pair With the content of The addresses Move the content of HL to SP Load the HL register pair With the content of The addresses Move the content of HL to DE Initialize the HL Reg pair with 0000H Initialize the BC Reg pair with 0000H [HL] + [SP] HL Jump on NO carry
Loop1
4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 411A 411B 411C 411D 411E 411F 4120 4121
Loop
INX B DCX D MOV A , E (OR)A D JNZ L1 SHLD, 4600 MOV L , C MOV H, B SHLD 4602 HLT
13 41 03 1B 7B B2 C2 0E 41 22 00 46 69 60 22 02 46 76
To 4113 Increment BC register Decrement DE register Move the content of E to A Or A and D Jump on No zero To 410E Store the content of HL In the given address And next address Move the content C to L Move the content B to H Store the content HL In the given address And next address Terminate the program
: : : :
: : : :
RESULT: Thus the assembly language program to multiply two 16 bit numbers is executed using 8085 and output was verified.
16 / 8 BIT DIVISION
Exp.No. AIM:
Date:
To write an assembly language program to perform 16 / 8 bit division using 8085 microprocessor. APPARATUS REQUIRED: 8085 Microprocessor kit 1 no. ALGORITHM: Step 1 Step 2 Step 3 Step 4 Step 5 Step 6 Step 7 Step 8 Step 9 Step 10: Step 11: Step 12: Step 13: Program: Address
4100 4101 4102 4103 4104 4105 4106
: : : : : : : : :
Load the HL register with the dividend from the address given Get the divisor in the C register Initialize D register with 0000H Move the content of L register to accumulator Subtract the content of C from accumulator Move the content of A to L If there is borrow, decrement the content of H register else jump on steps 8 Increment D register Compare the content of H register with 00H
If it is not zero, jump on to step 4 and be carry out step 11 Compare the content of L and C register If there is no carry, jump on to step 4 else store reminder and quotient in given addresses Stop
Label
Mnemonic
LHLD 4200 LDA 4202 MOV C, A
Opcodes
2A 00 42 3A 02 42 LF
Comments
Load the HL register pair With the content of the Address Load the accumulator With the content of the Address Move the content of A to C
4107 4108 4109 410A 410B 410C 410D 410E 410F 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 411A 411B 411C 411D 411E 411F 4120 4121 4122 4123 4124
LX 1 D, 0000H Loop2 MOV A, L SUB C MOV L , A JNC Loop1 DCX H INX D MOV A, H CPI, 00H JNZ loop2 MOV A, L CMP C JNC Loop2 SHLD 4600 XCHG SHLD 4602 HLT
Loop1
11 00 00 7D 91 6F D2 11 41 25 13 7C FE 00 C2 0A 41 7D B9 D2 0A 41 22 00 46 EB 22 01 46 76
Initialize the DE Register with 0000H Move the content of L to A [A] [C] A Move the content of A to L Jump on NO Carry to 4111 Decrement HL register Increment DE register Move the content of H to A Compare Accumulator With 00H Jump on No zero To 410A Move the content of L to A Compare A & C Jump on No Carry to 410A Store the content of HL in the given address And next address Move the De to HL Store the content of HL in the given address And next address Terminate the program
OUTPUT: INPUT: Address 4600 4601 4602 OUTPUT : : : : Data 08H 00H 02H 4600 4601 4602 4603 : : : : 00H 00H 04H 00H
RESULT: Thus the assembly language program to perform division was written and verified.
Exp.No. AIM:
Date:
To write an assembly language program to sort the given data in ascending order in an array. COMPONENT REQUIRED: 8085 Microprocessor kit ALGORITHM: Step 1 : Step 2 : Step 3 : Step 4 : Step 5 : Step 6 : Step 7 : Step 8 : Step 9 : Step 10: Step 11: Step 12: Program: Address
4100 4101 4102 4103 4104 4105 4106 4107 4108
Get the number of data in B register Get the count in C register Get the immediate data 5000H in the HL register pair Get the first data in the accumulator from memory Get the next data in the memory Compare the contents of accumulator and memory If there is no carry, swap the numbers in memory and decrement the count in register C If there is carry, decrement the count in C If the count is zero, decrement B register else jump on to step 6 with another two datas in accumulator and memory. If the content in B register is not zero, jump on t step 2 and proceed Repeat the process till the content in B becomes zero Stop.
Label
Mnemonic
LDA, 4000 MOV B, A LDA, 4001 MOV L, A LX1 H, 5000H
Opcodes
3A 00 40 47 3A 01 40 4F 21
Comments
Load the accumulator With the content Of the address Move the content A to B Load the accumulator With the content of the Address Move the content of A to C Load the HL reg pair
Loop2
4109 410A 410B 410C 410D 410E 410F 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 411A 411B 411C 411D 411E 411F
Loop1
MOV A, M INX H CMP M JC loop MOV D, A MOV A, M MOV M, D DCX H MoV M, A INX H DCR C JNZ loop1 DCR B JNZ loop2 HLT
Loop
00 50 7E 23 BE DA 17 41 57 7E 72 25 77 23 OD C2 OB 41 05 C2 04 41 76
With the immediate Data 5000H Move the content of memeory to A Increment HL register Compare A and memory Jump on carry To 4117 Move the content of A to F Move the content of M to A Move the content of D to M Decrement HL register Move the content of A to M Increment HL reg pair Decrement C register Jump on NO zero To 410B Decrement B register Jump on No Zero to 4104 Terminate the program
OUTPUT: INPUT: Address 4000 4001 5000 5001 5002 5003 5004 OUTPUT : : : : : : : : Data 05H 04H 20H 21H 25H 26H 19H 5000 5001 5002 5003 5004 : : : : : 19H 20H 21H 25H 26H
RESULT: Thus the assembly language program to sort the given data in an array in ascending order was written and verified.
Exp.No. AIM:
Date:
To write an assembly language program to sort the given data in descending order in an array. COMPONENT REQUIRED: 8085 Microprocessor kit ALGORITHM: Step 1 : Step 2 : Step 3 : Step 4 : Step 5 : Step 6 : Step 7 : Step 8 : Step 9 : Step 10: Step 11: Step 12: Program: Address
4100 4101 4102 4103 4104 4105 4106 4107 4108
Get the number of data in B register Get the count in C register Load the HL register pair with the data 5000H Get the data in the accumulator from memory Get the next data in the memory Compare the contents of accumulator and memory If there is carry, swap the two data in the memory and decrement HL register pair Decrement the count in C register If there is no zero, jump on to step 4 else decrement the conent of B register If the content in B register is not zero, jump on t step 2 and proceed Repeat the process till the content in B becomes zero Stop.
Label
Mnemonic
LDA, 4000 MOV B, A LDA, 4001H MOV C, A LX1 H, 5000H
Opcodes
3A 00 40 47 3A 01 40 4F 21
Comments
Load the accumulator With the content Of the address Move the content A to B Load the accumulator With the content of the Address Move the content of A to C Load the HL reg pair
Loop2
4109 410A 410B 410C 410D 410E 410F 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 411A 411B 411C 411D 411E 411F
Loop1
MOV A, M INX H CMP M JNC loop MOV D, A MOV A, M MOV M, D DCX H MOV M, A INX H DCR C JNZ loop1 DCR B JNZ loop2 HLT
Loop
00 50 7E 23 BE D2 17 41 57 7E 72 25 77 23 OD C2 OB 41 05 C2 04 41 76
With the immediate Data 5000H Move the content of memory to A Increment HL register Compare the data in M and A Jump on No carry To 4117 Move the content of A to D Move the content of M to A Move the content of D to M Decrement HL register Move the content of A to M Increment HL reg pair Decrement C register Jump on NO zero To 410B Decrement B register Jump on No Zero to 4104 Terminate the program
OUTPUT: INPUT: Address 4000 4001 5000 5001 5002 5003 5004 OUTPUT : : : : : : : : Data 05H 04H EDH FAH CFH ABH FFH 5000 5001 5002 5003 5004 : : : : : FFH FAH EDH CFH ABH
RESULT: Thus the assembly language program to sort the given data in an array in descending order was written and verified.
Exp.No. AIM:
Date:
To write an assembly language program to count the number of even number in an array using 8085 microprocessor. COMPONENT REQUIRED: 8085 Microprocessor kit ALGORITHM: Step 1 : Step 2 : Step 3 : Step 4 : Step 5 : Step 6 : Step 7 : Step 8 : Step 9 : Step 10: Step 11: Step 12: Step 13: Step 14: Program: Address
4100 4101 4102 4103 4104 4105 4106
Initialize the D register with 00H Get the number of data in C register Load the HL register pair with the immediate data 4600H Move the content of memory to accumulator Increment HL register pair Subtract the data 02H from accumulator content If there is carry, decrement the count in C in step 10 If there is no zero, jump on to step 6 Increment the content in D register Decrement the count in C register If the count becomes zero, jump on to step 12 else jump on to step 4 Move the content of D to accumulator Store the accumulator content in a memory location Stop.
Label
Mnemonic
MV1 D, 00H LDA, 5001 MOV C, A LX1 H, 4600H
Opcodes
16 00 3A 01 50 4F 21
Comments
Initialize D register With 00H Load the accumulator With the content of the Address Move the content A to C Load the HL register
4107 4108 4109 410A 410B 410C 410D 410E 410F 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 411A 411B 411C 411D 411E 411F
Loop3 Loop
Loop1
Loop2
00 46 7E 23 D6 02 DA 14 41 C2 OB 41 14 OD CA 1B 41 C3 09 41 7A 32 02 50 76
With immediate data 4600H Move the content of M to A Increment HL register Subtract the data 02H from accumulator Jump on Carry to 4114 Jump on No zero To 410B Increment D register Decrement C register Jump on zero to 411B Jump to 4109 Move the content of D to A Store the content of A In the given Address Terminate the program
OUTPUT: INPUT: Address 450 4501 4502 4503 4504 4505 OUTPUT : : : : : : : Data 05H 12H 42H 31H 71H 32H 4550 : 03H
RESULT: Thus the assembly language program to count the no. of even numbers in an array was written and verified.