jfountain02 0 Newbie Poster

The problem is I need to check A set of sign numbers and add the positive numbers, and reject the negative numbers. But the problem is I don't have an assembler to check my program, so I am just doing this program in my head, and I was seeing if somebody could tell me if this program would work properly.

First data Set: 20, 87,F2,37,79,17
Second data set: A2, 15, 3F, B7, 47, 9A

MVI B, 00H ; Clear(B) to save results
MVI C, 06H ; Set up register C to count six numbers
LXI H, 2060H ; SET up HL PAIR as a memory pointer
Next: MOV A,M ; Get a Byte
RAL ; Place D7 in CY flag
JC REJECT ; IF D7=1, reject thebyte
RAR ; Restore the byte
ADD B ; Add the previos sum
MOV B,A ;Save the sum
REJECT:INX H ;Next location
DCR C ; Update the byte counter
JNZ NEXT ; Go back to get the next byte
STA 2070H ;Save the result
HLT

Will this program work to add all positive numbers for each data set.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.