8085 program to filter out positive numbers from a memory location

2.8k Views Asked by At

So i need to filter out the positive numbers and display the sum if it is less than FFH, if not display FFH. i typed the code in the simulator and use #DB to store the numbers in a particular memory location. but when i run it step by step the memory content register is displaying 00. how to resolve it?

      MVI B,00
      MVI C,0A
      LXI H,4000

NEXT:      MOV A,M
      RAL
      JC REJECT
      RAR
      ADD B
      JC OVR
      MOV B,A

REJECT:    INX H
      DCR C
      JNZ NEXT
      STA 8070

OVR:       MVI A,FF
      HLT
# ORIGIN 4000H
# DB 28H, D8H, C2H, 21H, 24H, 30H, 2FH, 19H, F2H, 9FH

GNUSim8085

1

There are 1 best solutions below

1
codeR On

What do you mean by 'memory content register'? If you are referring to M it is not an actual register, it denotes the contents at the memory location pointed by the HL register pair. At the end of your code HL will have 400AH and memory location 400AH can hold any garbage value.

Since you are using a simulator where memory cells are usually initialized to 0, your simulator shows contents of M is 0 which is perfectly normal. What you should look at is the contents of register A.