Solved

how can i write this code in MIPS

Posted on 2009-04-09
2
304 Views
Last Modified: 2012-05-06
$s0 = f, $s1 = g, $s2 = h, $s3 = i, $s4 = j.  
base address of array A and B stored in $s6 and $s7 respectively.

1) f = -g + h + B[1];

2) f = A[B[g] + 1];

I have this so far but i don't its right
1)
sub $t0, $s2, $s1
lw $t1, 4($s7)
add $s0, $t0, $t1

2)
sll $t0, $s1, 2
lw $t1, $t0($s7)    #not sure about this
addi $t2, $t1, 1
sll $t3, $t2, 2
lw $t4, $t3($s6)    #not sure about this
add $s0, $t4, $zero

0
Comment
Question by:emreayman
  • 2
2 Comments
 
LVL 53

Accepted Solution

by:
Infinity08 earned 50 total points
ID: 24136365
>> lw $t1, $t0($s7)    #not sure about this

You'll have to calculate the address ($s7+$t0), and then use that calculated address with the lw instruction. The offset for the address calculation can only be an immediate (constant) value.

Same for :

>> lw $t4, $t3($s6)    #not sure about this


The rest looks ok.
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 24136367
Sorry for the late reply btw (I just noticed this question now) - I hope it's not too late :)
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question