Solved

how can i write this code in MIPS

Posted on 2009-04-09
2
301 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

What does UTC stand for?  “Coordinated Universal Time” – Think of this as the true time on Planet Earth that never changes with the exception of minor leap seconds here and there to account for the changes in the planet's rotation.   What does th…
This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

910 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now