Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

how can i write this code in MIPS

Posted on 2009-04-09
2
Medium Priority
?
308 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

If you’re involved with your company’s wide area network (WAN), you’ve probably heard about SD-WANs. They’re the “boy wonder” of networking, ostensibly allowing companies to replace expensive MPLS lines with low-cost Internet access. But, are they …
What we learned in Webroot's webinar on multi-vector protection.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

715 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