A few days ago
sudhanshu I

Need help with 8085 µP ALP …?

I have to count the number of odd as well as even bytes occuring in a block of data (say from 3001H to 3005H) length of block is at 3000H. have to store the result at 300AH and 300BH respectively …

I have tried this but there is something wrong and its not working right .. :

LXI H,3000H

MOV C,M

MVI B,00H

MVI D,00H

label1:INX H

MOV A,M

RRC

JNC label

INR D

DCR C

JNZ label1

label:INR B

DCR C

JNZ label1

LXI H,300AH

MOV M,D

INX H

MOV M,B

HLT

Top 1 Answers
A few days ago
Truly W

Favorite Answer

The problem seems to be in this block:

RRC

JNC label

INR D

DCR C

JNZ label1

*******

If the last intended byte resulted in a D increment and C decrement, the code flows through, increments B as well, decrements C again which goes negative and does the JNZ back to label1 because C is no longer zero.

You need a JMP to the LXI statement here

*******

label:INR B

DCR C

JNZ label1

LXI H,300AH

0