0% found this document useful (0 votes)
194 views17 pages

8085 Ultimate Simulator Kit All Codes of Examples

The document describes 23 different programs involving arithmetic and logical operations on 8-bit and 16-bit numbers. The programs include operations like addition, subtraction, comparison, shifting, masking, sorting, finding largest/smallest values in arrays, and more.

Uploaded by

ROMAN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
194 views17 pages

8085 Ultimate Simulator Kit All Codes of Examples

The document describes 23 different programs involving arithmetic and logical operations on 8-bit and 16-bit numbers. The programs include operations like addition, subtraction, comparison, shifting, masking, sorting, finding largest/smallest values in arrays, and more.

Uploaded by

ROMAN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

1.

1's Complement of 16 bit

1. LHLD 8100 //Load HL pair with


2. located data.
3. MOV A,L //Move L to Acc.
4. CMA //Complement cmd.
5. MOV L,A //Move Acc to L.
6. MOV A,H //Move H to Acc.
7. CMA
8. MOV H,A
9. SHLD 8100 //Store HL pair to
10. located address.
11. HLT //Halt.

2. 1's Complement of 8 bit

1. LDA 8100 //Load data to Acc.


2. CMA //Complement Acc.
3. STA 8100 //Store data.
4. HLT

3. 2's Complement of 16 bit

1. LHLD 8100H //Load H-L pair with operand from 8100H.


2. MOV A, L //Move the lower-order from reg. L to reg. A.
3. CMA //Complement accumulator.
4. MOV L, A //Move the result from reg. A to reg. L.
5. MOV A, H //Move the higher-order from reg. H to reg. A.
6. CMA //Complement accumulator.
7. MOV H, A // Move the result from reg. A to reg. H.
8. INX H //Increment H-L pair to find 2’s complement.
9. SHLD 3002H //Store the result.
10. HLT //Halt.

4. 2's Complement of 8 bit

1. LDA 8100 //Load data to Acc.


2. CMA //Complement.
3. INR A //Increment Acc.
4. STA 8100 //Store data.
5. HLT //Halt

5. Add Two 16 bit numbers with Carry

1. LHLD 8100H //Load H-L pair with data from 8100H


2. XCHG //Exchange H-L pair with D-E pair
3. LHLD 8102H //Load H-L pair with data from 8102H
4. MVI C, 00H //Move 0 to C
5. DAD D //Add D-E pair with H-L pair
6. JNC SKIP //Jump to location 200E H if no carry
7. INR C //Increment C
8. SKIP: SHLD 8104H //Store the result at location 8104 H
9. MOV A, C //Move carry from C to A
10. STA 8106H //Store the carry at location 8106 H
11. HLT //Halt

6. Add Two 16 bit numbers without Carry

1. LHLD 8100H //Load H-L pair with 1st operand from 8100H.
2. XCHG //Exchange H-L pair with D-E pair.
3. LHLD 8102H //Load H-L pair with 2nd operand from 3002H.
4. DAD D //Add D-E pair with H-L pair.
5. SHLD 8104H //Store the result at address 3004H.
6. HLT //Halt.

7. Add Two 8 bit numbers without Carry

1. LXI H, 8100H //Load H-L pair with address 8100H.


2. MOV A, M //Move the 1st operand from memory to reg. A.
3. INX H //Increment H-L pair.
4. MOV B, M //Move the 2nd operand from memory to reg. B.
5. ADD B //Add B with A.
6. INX H //Increment H-L pair.
7. MOV M, A //Move the result from reg. A to memory.
8. HLT //Halt.

8. Add Two 8 bit numbers with Carry

1. LXI HL,8100H //Load H-L pair with address 3000H.


2. MOV A,M //Move data addressed by H-L pair to reg. A.
3. INX H //Increase H-L pair.
4. MOV B,M //Move data addressed by H-L pair.
5. MVI C,00H //Immediate move 00H to reg.C.
6. ADD B //Add B with A
7. JNC SKIP //Jump to 'SKIP' if there is no Carry.
8. INR C //Increase reg.C
9. SKIP: INX H //Increase H-L pair.
10. MOV M,A //Move data from Acc to memory Addressed
by H-L pair.
11. INX HL //Increase H-L pair.
12. MOV M,C //Move carry from reg.C to memory.
13. HLT //Halt.

9. Add Two 8 bit numbers and show the result in


decimal form

1. LXI H, 8100H //Load H-L pair with address 8100H.


2. MOV A, M //Move the 1st operand from memory to reg. A.
3. INX H //Increment H-L pair.
4. MOV B, M //Move the 2nd operand from memory to reg. B.
5. MVI C, 00H //Initialize reg. C with 00H.
6. ADD B //Add B with A.
7. DAA //Convert the result to decimal.
8. JNC SKIP //Jump to address 200EH if there is no carry.
9. INR C //Increment reg. C.
10. SKIP: INX H //Increment H-L pair.
11. MOV M, A //Move the result from reg. A to memory.
12. INX H //Increment H-L pair.
13. MOV M, C //Move carry from reg. C to memory.
14. HLT //Halt.

10. Find the square of a 8 bit number

1. LXI H, 8100H //Load H-L pair with address 8100H.


2. MOV B, M //Move the operand from memory to reg. B.
3. MOV C, M //Move the same number from reg. B to reg. C.
4. MVI A, 00H //Initialize accumulator with 00H.
5. START: ADD B //Add B with A.
6. DCR C //Decrement reg. C (counter).
7. JNZ START //Jump back to address START if C ≠ 0.
8. INX H //Increment H-L pair.
9. MOV M, A //Move the result from accumulator to memory.
10. HLT //Halt.

11. Generation of Fibonacci series

1. MVI D, 08H //Initialize counter to display numbers in series.


2. MVI B, 00H //Initialize reg. B to store previous number.
3. MVI C, 01H //Initialize reg. C to store current number.
4. LXI H, 8100H //Initialize H-L pair to point to memory.
5. MOV M, B //Move 00H from reg. B to memory.
6. INX H //Increment H-L pair.
7. MOV M, C //Move 01H from reg. C to memory.
8. START: MOV A, B //Move previous number from reg. B to
reg. A.
9. ADD C //Add the two numbers.
10. MOV B, C //Assign current number to previous number.
11. MOV C, A //Save result as new current number.
12. INX H //Increment H-L pair.
13. MOV M, A //Move number from reg. A to memory.
14. DCR D //Decrement counter.
15. JNZ START //Jump to 'START' if counter is not zero.
16. HLT //Halt.
12. Largest from an array

1. LXI H, 8100H //Load H-L pair with address 8100H.


2. MOV C, M //Move counter from memory to reg. C.
3. INX H //Increment H-L pair.
4. MOV A, M //Move the 1st number from memory to reg. A.
5. DCR C //Decrement counter.
6. START: INX H //Increment H-L pair.
7. MOV B, M //Move the next number from memory to reg. B.
8. CMP B //Compare B with A.
9. JNC SKIP//Jump to address 200EH if there is no carry.
10. MOV A, B //Move largest from reg. B to reg. A.
11. SKIP: DCR C //Decrement counter.
12. JNZ START //Jump to address 2007H if counter is not
zero.
13. INX H //Increment H-L pair.
14. MOV M, A //Move the result from reg. A to memory.
15. HLT //Halt.

13. Largest of two 8 bit

1. LXI H, 8100H //Load H-L pair with address 8100H.


2. MOV A, M //Move the 1st operand from memory to reg. A.
3. INX H //Increment H-L pair.
4. MOV B, M //Move the 2nd operand from memory to reg. B.
5. CMP B //Compare B with A.
6. JNC SKIP //Jump to address 200BH if there is no carry.
7. MOV A, B //Move largest from reg. B to reg. A.
8. SKIP: INX H //Increment H-L pair.
9. MOV M, A //Move the result from reg. A to memory.
10. HLT //Halt.

14. Mask the higher nibble of 8 bit number

1.
2. LDA 8100H //Load H-L pair with data from 8100H.
3. ANI 0FH //AND Immediate 0FH with reg. A.
4. STA 8101H //Store the result at memory location 8101H.
5. HLT //Halt.

15. Mask the lower nibble of 8 bit number

1. LDA 8100H //Load H-L pair with data from 8100H.


2. ANI F0H //AND Immediate F0H with reg. A.
3. STA 8101H //Store the result at memory location 8101H.
4. HLT //Halt.

16. Multiply two 8 bit number

1. LXI H, 8100H //Load H-L pair with address 8100H.


2. MOV B, M //Move the 1st operand from memory to reg. B.
3. INX H //Increment H-L pair.
4. MOV C, M //Move the 2nd operand from memory to reg. C.
5. MVI A, 00H //Initialize accumulator with 00H.
6. START: ADD B //Add B with A.
7. DCR C //Decrement reg. C (counter).
8. JNZ START //Jump back to address 2008H if C ≠ 0.
9. INX H //Increment H-L pair.
10. MOV M, A //Move the result from accumulator to
memory.
11. HLT //Halt.

17. Shift Left 8 bit Number by 2 bit

1. LDA 8100H //Load A with data from 8100H


2. RAL //Shift Left Accumulator
3. RAL //Shift Left Accumulator
4. STA 8101H //Store the result at location 8101H
5. HLT //Halt

18. Shift Right 8 bit Number by 2 bit

1. LDA 8100H //Load A with data from 8100H


2. RAR //Shift Right Accumulator
3. RAR //Shift Right Accumulator
4. STA 8101H //Store the result at location 8101H
5. HLT //Halt

19. Shift Left 8 bit Number by 1 bit

1. LDA 8100H //Load H-L pair with data from 8100H.


2. RAL //Shift left accumulator.
3. STA 8101H //Store the result at memory location 8101H.
4. HLT //Halt.
20. Shift Right 8 bit Number by 1 bit

1. LDA 8100H //Load H-L pair with data from 8100H.


2. RAR //Shift right accumulator.
3. STA 8101H //Store the result at memory location 8101H.
4. HLT //Halt.

21. Smallest from an array

1. LXI H, 8100H //Load H-L pair with address 8100H.


2. MOV C, M //Move counter from memory to reg. C.
3. INX H //Increment H-L pair.
4. MOV A, M //Move the 1st number from memory to reg. A.
5. DCR C //Decrement counter.
6. START: INX H //Increment H-L pair.
7. MOV B, M //Move the next number from memory to reg. B.
8. CMP B //Compare B with A.
9. JC SKIP//Jump to address 200EH if there is no carry.
10. MOV A, B //Move smallest from reg. B to reg. A.
11. SKIP: DCR C //Decrement counter.
12. JNZ START//Jump to address 2007H if counter is not
zero.
13. INX H //Increment H-L pair.
14. MOV M, A //Move the result from reg. A to memory.
15. HLT //Halt.
22. Smallest of two 8 bit numbers

1. LXI H, 8100H //Load H-L pair with address 8100H.


2. MOV A, M //Move the 1st operand from memory to reg. A.
3. INX H //Increment H-L pair.
4. MOV B, M //Move the 2nd operand from memory to reg. B.
5. CMP B //Compare B with A.
6. JC SKIP //Jump to address 200BH if there is no carry.
7. MOV A, B //Move smallest from reg. B to reg. A.
8. SKIP: INX H //Increment H-L pair.
9. MOV M, A //Move the result from reg. A to memory.
10. HLT //Halt.

23. Sort the array in ascending order.

1. MVI B, 05H //Initialize counter-1.


2. START: MVI C, 05H //Initialize counter-2.
3. LXI H, 8100H //Load H-L pair with address 8100H.
4. REPEAT: MOV A, M //Move the number from memory to
reg. A.
5. INX H //Increment H-L pair.
6. CMP M //Compare the number with next number.
7. JC SKIP //Don’t interchange if number less than next
number.
8. JZ SKIP //Don’t interchange if number = next number.
9. MOV D, M //Otherwise, swap the numbers. Move next
number from memory to D.
10. MOV M, A //Move first number from A to memory.
11. DCX H //Decrement H-L pair.
12. MOV M, D //Move next number from D to memory.
13. INX H //Increment H-L pair.
14. SKIP: DCR C //Decrement counter 2.
15. JNZ REPEAT //If counter-2 ≠ 0, repeat.
16. DCR B //Decrement counter-1.
17. JNZ START //If counter-1 ≠ 0, repeat.
18. HLT //Halt

24. Sort the array in descending order.

1. MVI B, 05H //Initialize counter-1.


2. START: MVI C, 05H //Initialize counter-2.
3. LXI H, 8100H //Load H-L pair with address 8100H.
4. REPEAT: MOV A, M //Move the number from memory to
reg. A.
5. INX H //Increment H-L pair.
6. CMP M //Compare the number with next number.
7. JNC SKIP //Don’t interchange if number > next number.
8. JZ SKIP //Don’t interchange if number = next number.
9. MOV D, M //Otherwise, swap the numbers. Move next
number from memory to D.
10. MOV M, A //Move first number from A to memory.
11. DCX H //Decrement H-L pair.
12. MOV M, D //Move next number from D to memory.
13. INX H //Increment H-L pair.
14. SKIP: DCR C //Decrement counter 2.
15. JNZ REPEAT //If counter-2 ≠ 0, repeat.
16. DCR B //Decrement counter-1.
17. JNZ START //If counter-1 ≠ 0, repeat.
18. HLT //Halt

25. Subtract two 16 bit numbers with borrow

1. LHLD 8100H //Load H-L pair with data from 8100H


2. XCHG //Exchange data from H-L pair with D-E
3. LHLD 8102H //Load H-L pair with data from 8102H
4. MVI B, 00H //Move 0 H to B
5. MVI C, 00H //Move 0 H to C
6. MOV A, E //Move lower order of 1st no. to A
7. SUB L //Subtract lower order L from A
8. JNC SKIP //Jump to2011 H if there is no borrow
9. INR C //If borrow, then increment C
10. SKIP: MOV E, A //Move lower order back to E
11. MOV A, D //Move higher order of 1st no. to A
12. SUB C //First, subtract borrow from A
13. SUB H //Now, subtract higher order from A
14. JNC NO_BORROW //Jump to 2019 H if there is no
borrow
15. INR B //If borrow, increment B
16. NO_BORROW: MOV D, A //Move higher order back to
D
17. XCHG //Exchange the result from D-E with H-L
18. SHLD 8104H //Store the result al location 8104H
19. MOV A, B //Move borrow to A
20. STA 8106H //Store borrow at location 8106H
21. HLT //Halt
26. Subtract two 16 bit numbers without borrow

1. LHLD 8100H //Load H-L pair with 1st operand from 8100H.
2. XCHG //Exchange H-L pair with D-E pair.
3. LHLD 8102H //Load H-L pair with 2nd operand from 8102H.
4. MOV A, E //Move the lower-order of 1st number from reg. E
to reg. A.
5. SUB L //Subtract the lower-order of 2nd number from lower-
order of 1st number.
6. MOV L, A //Move the result from reg. A to register L.
7. MOV A, D //Move the higher-order of 1st number from reg. D
to reg. A.
8. SBB H //Subtract the higher-order of 2nd number from
higher-order of 1st number with borrow from the previous
subtraction.
9. MOV H, A //Move the result from reg. A to reg. H.
10. SHLD 8104H //Store the 16-bit result from H-L pair to
memory.
11. HLT //Halt

27. Subtract two 8 bit numbers along with borrow

1. LXI H, 8100H //Load H-L pair with address 8100H.


2. MOV A, M //Move the 1st operand from memory to reg. A.
3. INX H //Increment H-L pair.
4. MOV B, M //Move the 2nd operand from memory to reg. B.
5. MVI C, 00H //Initialize reg. C with 00H.
6. SUB B //Subtract B from A.
7. JNC SKIP //Jump to address 200DH if there is no borrow.
8. INR C //Increment reg. C.
9. SKIP: INX H //Increment H-L pair.
10. MOV M, A //Move the result from reg. A to memory.
11. INX H //Increment H-L pair.
12. MOV M, C //Move borrow from reg. C to memory.
13. HLT //Halt
28. Subtract two 8 bit numbers without borrow

1. LXI H, 8100H //Load H-L pair with address 8100H.


2. MOV A, M //Move the 1st operand from memory to reg. A.
3. INX H //Increment H-L pair.
4. MOV B, M //Move the 2nd operand from memory to reg. B.
5. SUB B //Subtract B from A.
6. INX H //Increment H-L pair.
7. MOV M, A //Move the result from reg. A to memory.
8. HLT //Halt.

29. Sum of series of 8 bit numbers

1. LXI H, 8100H //Load H-L pair with address 8100H.


2. MOV C, M //Move counter from memory to reg. C.
3. MVI A, 00H //Initialize accumulator with 00H.
4. REPEAT: INX H //Increment H-L pair.
5. MOV B, M //Move next number from memory to reg. B.
6. ADD B //Add B with A.
7. DCR C //Decrement counter.
8. JNZ REPEAT//Jump to address 'REPEAT' if counter is not
zero.
9. INX H //Increment H-L pair.
10. MOV M, A //Move the result from reg. A to memory.
11. HLT //Halt.
30. Transfer Block of N bytes from source to
destination

1. MVI C, 05H //Initialize reg. C to 05H, i.e. number of bytes.


2. LXI H, 8100H //Initialize H-L pair to source memory location.
3. LXI D, 8200H //Initialize D-E pair to destination memory
location.
4. START: MOV A, M //Move the byte from source to
accumulator.
5. STAX D //Store the byte from accumulator to destination.
6. INX H //Increment the source pointer H-L pair.
7. INX D //Increment the destination pointer D-E pair.
8. DCR C //Decrement counter C.
9. JNZ START //Jump to address 'START' if counter is not
zero.
10. HLT //Halt.

31. Transfer Block of N bytes in reverse order from


source to destination

1. MVI C, 05H //Initialize reg. C to 05H, i.e. number of bytes.


2. LXI H, 8100H //Initialize H-L pair to source memory location.
3. LXI D, 8204H //Initialize D-E pair to destination memory
location.
4. START: MOV A, M //Move the byte from source to
accumulator.
5. STAX D //Store the byte from accumulator to destination.
6. INX H //Increment the source pointer H-L pair.
7. DCX D //Decrement the destination pointer D-E pair.
8. DCR C //Decrement counter C.
9. JNZ START //Jump to address 'START' if counter is not
zero.
10. HLT //Halt.

You might also like