Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8922335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:48:24+00:00 2026-06-15T06:48:24+00:00

Given: .data arr: .word 2,5,1,3,4 len: .word 5 sum: .word 0 How would I

  • 0

Given:

.data
arr: .word 2,5,1,3,4
len: .word 5
sum: .word 0

How would I access each word in “arr” such as 2, 3 and 4?

Eventually, what I would like to do is find a sum of all of the values in “arr”, but I’m having difficulty iterating through “arr”.

Thank you for your time!

Additional Info:

  1. I’m using eduMIPS64
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T06:48:25+00:00Added an answer on June 15, 2026 at 6:48 am

    First load the address of the array into a register, then you can access the items with a constant offset. (Your assembler might support constructs such as lw $t0, arr+12 as convenience shorthand for this. See your manual.) For iteration, either increment the address register, or add another register containing the offset. Be sure to account for item sizes. Folling example is for 32 bit mips, adjust as necessary for 64 bit:

    .data
    arr: .word 2,5,1,3,4
    len: .word 5
    sum: .word 0
    
    .text
    .globl main
    main:
        la $t0, arr
        lw $t1, 12($t0)     # load arr[3] using byte offset
        li $t1, 3           # index
        sll $t1, $t1, 2     # multiply by item size
        addu $t1, $t1, $t0  # add base address
        lw $t1, ($t1)       # load arr[3]
    
    # iteration type 1
    # for(i=len, ptr=arr; i != 0; i -= 1, ptr += 1)
    # ... use *ptr ...
        la $t0, arr
        lw $t1, len         # load length
    loop1:
        lw $t2, ($t0)       # load item
        # process item here
        addi $t0, $t0, 4    # add item size to pointer
        addi $t1, $t1, -1   # decrement counter
        bne $t1, $0, loop1  # if counter != 0, repeat
    
    # iteration type 2
    # for(i=0, i != len; i += 1)
    # ... use arr[i] ...
        la $t0, arr
        lw $t1, len         # load length
        li $t2, 0           # index
    loop2:
        sll $t3, $t2, 2     # multiply by item size
        addu $t3, $t3, $t0  # add base address
        lw $t3, ($t3)       # load item
        # process item here
        addi $t2, $t2, 1    # increment index
        bne $t2, $t1, loop2 # if index != len, repeat
    

    (note these sample loops do not handle zero length array, add check if necessary)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

for a given data frame I would like to multiply values of an array
Given data that looks like: library(data.table) DT <- data.table(x=rep(1:5, 2)) I would like to
Given data like this C1<-c(3,-999.000,4,4,5) C2<-c(3,7,3,4,5) C3<-c(5,4,3,6,-999.000) DF<-data.frame(ID=c(A,B,C,D,E),C1=C1,C2=C2,C3=C3) How do I go about removing
Given data frame values are Group year Value A 2010 17 A 2011 18
I am trying to sample a data frame from a given data frame such
Another stupid question here regarding a SQL scenario. Given data such as: FieldKey DocumentKey
Given a data set like this; +-----+---------------------+--------+ | id | date | result |
Given data such as Type Value A This A is B Will A a
Given data values of some real-time physical process (e.g. network traffic) it is to
Given data such as : user, library ID, book ID, year 1,10, 100,2000 2,10,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.