How to sum up values of an array in assembly?

Posted by Pablo Fallas on Stack Overflow See other posts from Stack Overflow or by Pablo Fallas
Published on 2012-12-15T22:57:45Z Indexed on 2012/12/15 23:03 UTC
Read the original article Hit count: 266

Filed under:
|

I have been trying to create a program which can sum up all the values of an "array" in assembly, I have done the following:

ORG 1000H
TABLE DB DUP(2,4,6,8,10,12,14,16,18,20)
FIN DB ?
TOTAL DB ?
MAX DB 13
ORG 2000H
MOV AL, 0
MOV CL, OFFSET FIN-OFFSET TABLE
MOV BX, OFFSET TABLE
LOOP: ADD AL, [BX]
INC BX
DEC CL
JNZ LOOP
HLT
END

BTW I am using msx88 to compile this code. But I get an error saying that the code 0 has not been recognized.

Any advise?

© Stack Overflow or respective owner

Related posts about assembly

Related posts about low-level