Microprocessor 8085 programming (Memory Location) part 2 || Microprocessor || Bcis Notes

Microprocessor 8085 programming (Memory Location) part 2 || Microprocessor || Bcis Notes

Microprocessor 8085 programming (Memory Location)

1. Six bytes are stored in memory location starting at 2050H. Add all the data bytes, save any carry generated while adding the data bytes. Display the 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

2. 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

3. We have a list of data stored at a memory location starting at 2050H. The end of the data array is indicated by data byte 00H. Add the set of readings. Display the sum at Port 1 and total carry at Port 2.

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

4. There are two tables holding twenty data whose starting address is 3000H and 3020H respectively. WAP to add the content of the first table with the content of the second table having the same array index. Store sum and carry into the third and fourth table indexing from 3040H and 3060H respectively.

LXI B, 3000H
LXI H, 3020H
LXI D, 3040H
NEXT:      LDAX B

ADD M
STAX D
PUSH H
PUSH D
JNC L1
MVI E, 01H
JMP CSTORE
L1:             MVI E, 00H
CSTORE: LXI H, 3060H
MOV A, L
ADD C
MOV L, A
MOV M, E
POP H
POP D
INX B
INX D
INX H

MOV A, C
CPI 14H
JNZ NEXT
HLT

5. For ten bytes data starting from 1120H, write a program to sort the reading in ascending and in descending order. (Note: For descending, do self)

START: LXI H, 1120H
MVI D, 00H
MVI C, 0AH
L2:         MOV A, M
INX H
CMP M
JC L1
MOV B, M
MOV M, A
DCX H
MOV M, B
INX H
MVI D, 01H
L1:         DCR C
JNZ L2
MOV A, D
RRC
JC START
HLT

6. 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

7. A set of six data bytes is stored starting from memory location 2050H. The set includes some blank spaces (bytes with zero values). WAP to eliminate the blanks from the block.

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

8. 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 the 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

9. WAP to read BCD number stored at memory location 2020H and converts it into binary equivalent and finally stores that binary pattern into memory location 2030H. [Note: BCD number is the combination from 0 to 9]

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

10. 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 a memory location from 2030H.

LXI SP, 2000H
LXI H, 2020HMOV 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
HLT

You may also like Microprocessor 8085 programming

Be the first to comment

Leave a Reply

Your email address will not be published.


*