8085 Merged
8085 Merged
1. Write a program for 8085 to swap bit D3 and D6 of ten numbers stored in memory at
9650H if any number is greater than 70H and less than A0H. Otherwise set D3 and
reset D6 of the number stored. [2063 Ashad]
2. Seven status and one control signal of a single microprocessor based instrument are
read from data bus and are stored sequentially from memory location 6000H. Control
bit is represented by bit D4 and D4=1 represents valid data. Other bits are status
signals. Write an assembly language program for 8085 microprocessor which will check
control bit of each data and transfer the valid data to new memory location starting
from 7000H. The program should count and display the number of valid data and the
checking process should stop when all status signals are zero.
3. Write a program for 8085 to transfer data from a table to another if the number of ones
in the data is greater than four else store 00 to next table. [2065 Kartik]
(Assuming 10 data)
4. Write a program in 8085 to add all the numbers from a table of 8-bit numbers whose
higher nibble value is greater than 6 and store the 16-bit result just after the table.
[2067 Shrawan]
(Assuming 10 data)
5. There are two tables holding twenty data whose starting address is 3000H and 3020H
respectively. WAP to add the content of first table with the content of second table
having same array index. Store sum and carry into the third and fourth table indexing
from 3040H and 3060H respectively.
6. WAP in 8085 to calculate the sum of numbers stored in memory location from 7000H
to 700FH only if the number has higher nibble greater than lower nibble. Store the
sum at end of the table.
Label Instructions Comments
LXI H, 7000H ;source table
MVI B, 00H ;sum register
MVI C, 00H ;carry register
MVI D, 10H ;counter
UP: MOV A,M
ANI 0FH
MOV E,A
MOV A,M
ANI F0H
RLC
RLC
RLC
RLC
CMP E
JC PASS
MOV A,M
ADD B
MOV B,A
JNC PASS
INR C
PASS: INX H
DCR D
JNZ UP
MOV M,B
INX H
MOV M,C
HLT
7. WAP for 8085 to add corresponding data from two tables if the data from the first
table is smaller than the second table else subtract data of second table from the first
table. Store the result of each operation in the corresponding location of the third
table. Assume each has ten 8-bit data.
Label Instructions Comments
LXI B, 2000H ;first source table
LXI H, 3000H ;second source table
LXI D, 4000H ;destination table
UP: LDAX B
CMP M
JNC SUBTRACT
ADD M
JMP PASS
SUBTRACT: SUB M
PASS: STAX D
INX H
INX B
INX D
MOV A, L
CPI OAH
JNZ UP
HLT
8. Two tables with starting location 3000H and 4000H contains 50 bytes of data. WAP in
8085 to find sum of data from the tables and store the result in third table starting
from 5000H if the result is in between C0H and FFH, else store 00H to the
corresponding location.
9. Ten 8-bit data are stored in two tables starting at 5050H and 5060H. Transfer the data
of 1st table to third table starting at 5070H if data at 1st table is greater than data at 2nd
table, else store 00H at third table.
1. Add two numbers located at 3030H and 4040H. Display sum on Port 1. If carry is generated,
display it on Port 2. Store sum on 5050H.
LDA 3030H
MOV B, A
LDA 4040H
ADD B
STA 5050H
OUT PORT 1
JNC L1
MVI A, 01H
OUT PORT 2
L1: HLT
2. Write an Assembly Language Program that retrieves a data located at 2050H and it displays,
if it is even and stores FFH on that location if it is odd.
LDA 2050H
ANI 01H
JNZ L1
LDA 2050H
OUT PORT 1
HLT
L1: MVI A, FFH
STA 2050H
HLT
3. Sixteen bytes of data are stored in memory location at 1050H to 105FH. Replace each data
byte by FF.
LXI H, 1050H
MVI C, 10H
L1: MVI M, FFH
INX H
DCR C
JNZ L1
HLT
LXI H, 1050H
MVI C, 10H
LXI D, 1070H
L1: MOV A, M
STAX D
INX H
INX D
DCR C
JNZ L1
HLT
5. Six bytes are stored in memory locations starting at 2050H. Add all the data bytes, save any
carry generated while adding the data bytes. Display entire sum at two output ports and store
total carry in 2070H and sum in 2071H.
LXI H, 2050H
MVI C, 06H
MVI B, 00H
MVI D, 00H
L2: MOV A, M
ADD B
MOV B, A
JNC L1
INR D
L1: INX H
DCR C
JNZ L2
HLT
6. If the content of memory location 2050H is greater than or equal to 64H, display 0FH else
display FFH.
LDA 2050H
CPI 64H
JC L1
MOV A, 0FH
OUT PORT 1
HLT
L1: MOV A, FFH
OUT PORT 1
HLT
LXI H, 2050H
MVI B, 00H
MVI C, 00H
L3: MOV A, M
CPI 00H
JZ L1
ADD C
JNZ L2
INR B
L2: MOV C, A
INX H
JMP L3
L1: MOV A, C
OUT PORT 1
MOV A, B
OUT PORT 2
HLT
8. There are two tables holding twenty data whose starting address is 3000H and 3020H
respectively. WAP to add the content of first table with the content of second table having
same array index. Store sum and carry into the third and fourth table indexing from 3040H
and 3060H respectively.
10. A set of ten readings is stored in memory location starting at 1160H. The readings are
expected to be positive (<127). WAP to
- Check each reading to determine whether it is positive or negative.
- Reject all negative readings.
- Add all positive readings & display sum in Port 1 and carry in Port 2.
MVI B, 00H
MVI C, 00H
MVI D, 0AH
LXI H, 1160H
L2: MOV A, M
RAL
JC NEGLECT
RAR
ADD B
JC L1
MOV B, A
L1: INR D
NEGLECT: INX H
DCR D
JNZ L2
MOV A, B
OUT PORT 1
MOV A, D
OUT PORT 2
HLT
MVI C, 06H
LXI H, 2050H
LXI B, 2050H
L2: MOV A, M
CPI 00H
JZ L1
STAX B
INX B
L1: INX H
DCR C
JNZ L2
HLT
12. A set of eight data bytes (4 Pairs) are stored in memory locations starting from 1040H. WAP
to add two bytes at a time and store the sum in same memory location, sum replacing the first
byte and the carry replacing the second byte. If any pair does not generate a carry, the
memory location of the second byte should be cleared i.e. store 00H over there.
MVI C, 04H
LXI H, 1040H
L2: MOV A, M
INX H
ADD M
DCX H
MOV M, A
INX H
MVI M, 00H
JNC L1
MVI M, 01H
L1: INX H
DCR C
JNZ L2
HLT
MVI C, 0AH
LXI H, 2020H
MOV A, M
ANI F0H
RRC
RRC
RRC
RRC
MOV B, A
MOV A, 00H
L1: ADD B
DCR C
JNZ L1
MOV D, A
MOV A, M
ANI 0FH
ADD D
STA 2030H
HLT
14. A binary number (Suppose FF: 1111 11112) is stored in memory location 2020H. Convert the
number into BCD and store each BCD as two unpacked BCD digits in memory location from
2030H.
LXI SP, 2000H
LXI H, 2020H
MOV A, M
CALL PWRTEN
HLT
PWETEN: LXI H, 2030H
MVI B, 64H
CALL BINBCD
MOV M, D
INX H
MVI B, 0AH
CALL BINBCD
MOV M, D
INX H
MOV M, A
RET
BINBCD: MVI D, 00H
NEXT: INR D
SUB B
JNC NEXT
DCR D
ADD B
RET
16. WAP to convert ASCII at location 1040H to binary and store at location 1050H.
18. A multiplicand is stored in memory location 1150H and a multiplier is stored in location
1151H. WAP to multiply these numbers and store result from 1160H.
MVI B, 08H
MVI D, 00H
LXI H, 1150H
MOV A, M
MOV E, A
LXI H, 1151H
MOV A, M
L2: RAR
JNC L1
LXI H, 0000H
DAD D
L1: XCHG
DAD H
XCHG
DCR B
LNZ L2
HLT
ADD: ADD M
DAA
RNC
MOV D, A
MOV A, B
ADI 01H
DAA
MOV B, A
MOV A, D
RET
20. A dividend is stored in memory location 2020H and a divisor is stored in 2021H. WAP to
divide these numbers and store quotient and remainder from 2040H.
MVI C, 00H
LXI H, 2021H
MOV A, M
MOV D, A
DCX H
MOV B, M
L2: MOV A, B
SUB D
JC L1
MOV B, A
INR C
JMP L2
L1: MOV L, C
MOV H, B
SHLD 2040H
HLT
LXI H, 9050H
LXI D, 90A0H
MVI C, 32H
L2: MOV A, M
CPI 60H
JC L1
SUI 20H
L1: STAX D
DCR C
JNZ L2
HLT
22. Write a program for 8085 to add ten 16-bit BCD numbers from location 4050H and store 24-
bit BCD result at the end of the ten given numbers. [2062 Chaitra]
L2: LDAX B
ADD L
INX B
LDAX B
ADC H
JNC L1
INR E
L1: INX B
MOV A, C
CPI 0AH
JC L2
MOV A, L
STAX B
INX B
MOV A, H
STAX B
INX B
MOV A, E
STAX B
HLT
3
LXI SP, 2999H
LXI H, 2050H
MOV M, 3FH
INX H
MOV M, 06H
INX H
MOV M, 5BH
INX H
MOV M, 4FH
INX H
MOV M, 66H
INX H
MOV M, 6DH
INX H
MOV M, 7DH
INX H
MOV M, 07H
INX H
MOV M, 7FH
INX H
MOV M, 6FH
LXI B, 2060H
LXI H, 7600H
MVI C, 0AH
L2: MOV A, M
CPI 80H
JC L1
XRI 20H
MOV M, A
L1: INX H
DCR C
JNZ L2
25. Write a program for 8085 to find the smallest number among ten numbers stored at memory
location 4500H. [2060 Bhadra]
LXI H, 4500H
MVI C, 0AH
MOV A, M
L2: INX H
CMP M
JC L1
MOV B, A
MOV A, M
MOV M, B
L1: DCR C
JNZ L2
OUT PORT 1
HLT
LXI H, 4050H
MVI C, 64H
L1: MOV A, M
ANI 80H ; 10000000 B
RRC
RRC
MOV B, A
MOV A, M
ANI 20H ; 00100000 B
RLC
RLC
MOV C, A
MOV A, M
ANI 5FH ; 01011111 B
ORA B
ORA C
STAX H
INX H
DCR C
JNZ L1
HLT
28. Write a program to transfer eight-bit numbers from 9080H to 9090H if bit D5 is 1 and D3 is 0.
Otherwise transfer data by changing bit D2 and D6 from 1 to 0 or from 0 to 1. Assume there
are ten numbers. [2064 Shrawan]
LXI H, 9080H
LXI D, 9090H
MVI C, 0AH
L2: MOV A, M
ANI 28H
CPI 20H
JZ L1
MOV A, M
XRI 44H
MOV M, A
L1: MOV A, M
STAX D
INX H
INX D
DCR C
JNZ L2
HLT