News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

sum values in arrays

Started by I_Hate_Assembly, April 20, 2010, 07:21:32 PM

Previous topic - Next topic

I_Hate_Assembly

Hello,

I am trying to summarize the values inside an array, but it did not work  :tdown



.MODEL SMALL
.STACK 64
.DATA
ARR     DB      2,3,5
RES     DB      ?
.CODE
MAIN    PROC    NEAR
        MOV     BX,@DATA
        MOV     DS,BX

        MOV     SI,1
        LEA     BX,ARR
        MOV     DL,ARR
        MOV     CX,2

XYZ:    MOV     AL,[BX+SI]
  CMP       DL,AL
          ADD    DL,AL
          JA      NEXT
   

NEXT:   INC     SI
           LOOP    XYZ

MOV     RES,DL
MOV     AH,4CH
INT     21CH

MAIN ENDP
END MAIN



any help would be great   :(
I am just trying to understand arrays in assembler

Thanks

dedndave

MAIN    PROC    NEAR

        MOV     BX,@DATA
        MOV     DS,BX

        MOV     SI,offset ARR
        MOV     CX,sizeof ARR-1
        MOV     AL,[SI]

XYZ:    INC     SI
        ADD     AL,[SI]
        LOOP    XYZ

        MOV     RES,AL

        MOV     AH,4Ch
        INT     21h

MAIN    ENDP