Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

how can i write this code in MIPS

Posted on 2009-04-09
2
Medium Priority
?
310 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 200 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

[Webinar] Cloud Security

In this webinar you will learn:

-Why existing firewall and DMZ architectures are not suited for securing cloud applications
-How to make your enterprise “Cloud Ready”, and fix your aging DMZ architecture
-How to transform your enterprise and become a Cloud Enabler

Question has a verified solution.

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

High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
In this post, I will showcase the steps for how to create groups in Office 365. Office 365 groups allow for ease of flexibility and collaboration between staff members.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

916 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