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 8776709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:07:13+00:00 2026-06-13T19:07:13+00:00

I have a segment of C++ code that I need to convert to mips

  • 0

I have a segment of C++ code that I need to convert to mips using direct translation. I have most of it done, its a do while loop. I just don’t understand this one line in MIPS.

x[i] = y[i];

I don’t understand how to convert this into mips and I’ve been searching endlessly online. Could I get any help?

EDIT

This is what I had but was told it was incorrect:

la $6, y
Li $7, $1
Add $7, $7, $7
Add $7, $7, $7
Add $8, $6, $7
Lw $6, 0($8)
La $7, x
Li $8, $1
Add $8, $8, $8
Add $8, $8, $8
Add $7, $7, $8
Sw $6, 0($7)

I used this online site as reference:

http://www.cs.pitt.edu/~xujie/cs447/AccessingArray.htm

SECOND EDIT

C++ Coding

i=0;
do {
    x[i]=y[i];
    i++;
}
while (i!=j);

MIPS Direct translation

Addi $1, $1, 0
Loop:   la $6, y
    Li $7, $1
    Add $7, $7, $7
    Add $7, $7, $7
    Add $8, $6, $7
    Lw $6, 0($8)
    La $7, x
    Li $8, $1
    Add $8, $8, $8
    Add $8, $8, $8
    Add $7, $7, $8
    Sw $6, 0($7)
    Addi $1, $1, 1
    Bne $1, $2, loop 

And here are all my registers I can use to avoid confusion to you:

Variables   i   j   x   y   4 (constant)    Free
Registers   $1  $2   $3   $4    $5               $6, $7, $8
  • 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-13T19:07:14+00:00Added an answer on June 13, 2026 at 7:07 pm

    This should get you into the right direction. Since this is a homework question, I’m not going to give you a complete solution.

    Quick Reference (MIPS instructions, calling convention, etc):

    http://www.mips.com/media/files/MD00565-2B-MIPS32-QRC-01.01.pdf

    An example assembly function that computes the dot product of a 32-bit and a 16-bit vector in a little-Endian environment:

    http://code.google.com/p/mips32-asm/source/browse/dot32x16.S

    Here you can see how the elements of arrays are accessed.

    Note that “.set reorder” makes the assembler reorder the instructions and/or include NOPs to deal with the so-called delay slot. In case your professor wants to see that you understood the delay slot issue, you should order the instructions yourself properly and/or write your own NOP after a branch/jump.

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

Sidebar

Related Questions

I have some C++ code (segment seen below), I need to convert this to
I have a code segment that generates a dynamic 3D array of random numbers
I have a ray, I need to find the closest line segment that it
I have segment of code that I'd like run as non-root. If the program
So basically the problem is that I have segment of code that needs to
I have this segment of code: - (void)setTableView:(UITableView *)tableView { tableView = tableView; }
I have an code segment of view .cshtml page like : @Html.ActionLink(Add Charts of
I have a JavaScript code segment for loading server's data items, and insert them
I have a controller class as in the following code segment: @Controller public class
I have two identical byte arrays in the following segment of code: /// <summary>

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.