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

  • Home
  • SEARCH
  • 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 8661585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:31:52+00:00 2026-06-12T16:31:52+00:00

The Background I am currently working on small MIPS program for a homework assignment,

  • 0

The Background

I am currently working on small MIPS program for a homework assignment, and in the process learning some of the language. I am extremely new to this, and as such I am very unsure of myself when it comes to even the most basic aspects of the operations that I’m performing. Furthermore, my instructor insists on not using pseudocode in our assignments, which is leading to a lot of difficulty in understanding how to accomplish certain tasks.

The Assignment

My assignment question is this: Suppose you want to compute iteratively (in a loop) the first 20 Biggie numbers, B(i) = 2i + 17i and store them sequentially in an array B whose base address in MIPS memory is stored in register $s0. Please write the MIPS code (fully commented) to compute B(i), 1 < i < 20.

My Solution

What I currently have:

.globl main
main:

.data
BiggieArray:
    .space 80                   #4 bytes per word * 20 biggie numbers = 80 bytes reserved
.text
addi    $s1, $zero, 1           #$s1 tracks i, initialize i with value of 1
addi    $s2, $zero, 21      #$s2 holds 21, for use in comparing with the value of i
addi    $s3, $zero, 2           #$s3 holds the value for the first mult
addi    $s4, $zero, 17      #$s4 holds the value for the second mult

STARTLOOP:
beq     $s1, $s2, ENDLOOP       #compares i ($s1) with $s2.  If they are equal, i > 20, so branch to the end of the loop.

add     $t0, $s1, $s1        #find 2i
add     $t0, $t0, $t0        #find 4i, use as offset for BiggieArray
addi    $t0, $t0, -4            #adjusts to start from index 0 instead of index 1

mult    $s1, $s3                #Calculates 2i
mflo    $s5                #$s5 holds 2i
mult    $s1, $s4                #Calculates 17i
mflo    $s6                #$s6 holds 17i

add     $s7, $s5, $s6        #$s7 holds 2i+17i

add     $t1, $s0, $t0        #$t1 holds the current address of BiggieArray[i]

sw      $t1, 0($s7)         #stores the value 2i+17i into RAM ?????

addi    $s1, $s1, 1         #increment i

j   STARTLOOP

ENDLOOP:

My Question

I realize that I don’t currently have $s0 initialized to anything, but that’s not what’s giving me issues. What I’m confused about is how I would store that value of 2i+17i back into BiggieArray. Any help or very simple explanation of how sw works would be greatly appreciated.

  • 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-12T16:31:55+00:00Added an answer on June 12, 2026 at 4:31 pm

    In your example, you have the registers reversed. It should be:

    sw $s7, 0($t1) # since s7 holds the value you want to store, and t1 holds the mem address where you want to store it

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

Sidebar

Related Questions

Some background I'm currently working on a mobile site so I keep switching user
Some historic background: I'm currently working with Wowza and attempting to decode the AMFPackets
Some background info: I am currently writing a bootloader in protected mode while learning
BACKGROUND: I'm currently working on building a photography gallery where I release a new
First some background, I am currently working on a relatively large Asp.Net MVC application
Some background. I am currently working on a distributed system in Java. The code
Hopefully this isn't too difficult to follow. I'm currently working on a small timelogging
Background Currently, I am working on a Rails application. I have different products that
Background : I'm currently, for my University, creating some simple apps showcasing the possible
Some background I'm currently building a predominantly classic web app (rather than a single

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.