Can someone help me write a program that adds 3 consecutive numbers,
06H,2EH,36H,42H,00H 00H indicates the end. Place their sum in LRGST(largest) it should compare their sum and place the largest number in LRGST
2EH + 3CH = 34H
3CH + 1BH = 64H
1BH + 46H = 78H
I came up with this solution. could anyone check to if this is correct.
when the program adds the first 2 numbers their sum is placed in memory location LRGST.
If the new sum is larger than number in LRGST it will be replaced with new larger sum.
This is my solution. Need someone to check and let me know if I am correct.
0001 18A0
.ORG 18A0h
0002 18A0 06 2E
MVI B,002Eh
0003 18A2 16 3C
MVI D,003Ch
0004 18A4 1E 1B
MVI E,001Bh
0005 18A6 0E 46
MVI C,0046h
0006 18A8 21 A0 18
START: LXI H,18A0h
0007 18AB 7E
MOV A,M
0008 18AC 23
INX H
0009 18AD C3 B3 18
JMP ADD
0010 18B0 D2 B8 18
JNC FOUND
0011 18B3 23 ADD:
INX H
0012 18B4 86
ADD M
0013 18B5 32 C1 18
STA LRGST
0014 18B8 23 FOUND:
INX H
0015 18B9 C3 B3 18
JMP ADD
0016 18BC BE
CMP M
0017 18BD D2 C1 18
JNC LRGST
0018 18C0 76
HLT
0019 18C1
0020 18C1 00
LRGST: .db 00h
0021 18C2
0022 18C2
.end
0023 18C2
0024 18C2
0025 18C2
0026 18C2
0027 18C2
0028 18C2
0029 18C2
0030 18C2
tasm: Number of errors = 0