Microprocessor 8085 programming (Memory Location)
1. 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
2. Someone has damaged a program written at 4050H for 8085 microprocessor. The damaging
is done by changing the bit D7 and bit D5 of each byte. The size of the program is 100 bytes. Now write a program for 8085 to correct this damaged program. [2060 Chaitra]
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
3. The temperature of two furnaces being monitored by a microprocessor-based system. A set of readings of the first furnace recorded by thermal sensor is stored at memory locations starting at 4050H. Corresponding readings from the second furnace is stored at the memory location starting at 4070H. Each reading from the first furnace is expected to be higher than the corresponding reading from the second furnace. Among the eight-bit data bit, D7 is used to test the validity of the data. Write an 8085 program to compare valid data from the two tables, if data from the first table is larger than the corresponding data from the second table store 01H in the corresponding memory of the third location starting at 4090H and display 01H to indicate the normal operation else store FFH in the corresponding memory location and display FFH in the port to indicate the emergency. When the emergency condition is reached stop the operation. [2060 Jestha]
LXI B, 4050H
LXI H, 4070H
LXI D, 4090H
L2: LDAX B
CMP M
JC L1
JZ L1
MVI A, 01H
STAX D
OUT PORT
INX B
IND H
INX D
JMP L2
L1: MVI A, FFH
STAX D
OUT PORT
HLT
4. 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
5. There are two tables T1, T2 in memory having ten eight-bit data in each. Write a program for 8085 to find the difference of the corresponding element of these two tables. Store the result of each operation on the corresponding element of the third table. Remember that the result should not be negative; it should be |T1 – T2|. [2064 Poush]
LXI SP, 2999H
LXI H, 5000H; TABLE T1
LXI D, 6000H; TABLE T2
MVI C, 0AH; COUNTER FOR 10 DATA
L1: LDAX D
MOV B, A
MOV A, M
CMP B
JNC L2
MOV A, B
MOV B, M
L2: SUB B
PUSH D
MVI D, 70H; TABLE T3
STAX D
POP D
INX H
INX D
DCR C
JNZ L1
HLT
30. 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 in the next table. [2065 Kartik]
LXI H, 5000H; SOURCE TABLE
LXI D, 6000H; DESTINATION TABLE
ST: MVI C, 08H; NO OF BITS
MVI B, 00H; NO OF 1’S
MOV A, M
L1: RLC
JNC L2
INR B
L2: DCR C
JNZ L1
MOV A, B
CPI 04H
MVI A, 00H
JC L3
JZ L3
MOV A, M
L3: STAX D
INX H
INX D
MOV A, E
CPI 0AH; SUPPOSE TABLE FOR 10 DATA
JNZ ST
HLT
You may also Microprocessor 8085 programming (Memory Location) Part-3
Leave a Reply