Adding the sum of elements in a 2-dimensional array

Discussion in 'Assembly Language Programming (ALP) Forum' started by husslela2, Mar 23, 2007.

  1. husslela2

    husslela2 New Member

    Joined:
    Mar 23, 2007
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    How do I add the elements in a two-dimensional array and return the sum into register $v0?

    Thanks,
    Husslela
     
  2. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    http://www.daweidesigns.com
    Here's the general procedure. A true array is contiguous in memory. Set the accumulator value ($v0, in this instance) to zero. Set an index register to the first element, add that element to the accumulator, increment the index, repeat for the entire length of the array (nRows * nColumns).
     
  3. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    This may also help you to some extent. [thread=302]8085 Assembly language programming code for beginners[/thread].
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice