943,931 Members | Top Members by Rank

Ad:
  • Assembly Discussion Thread
  • Unsolved
  • Views: 6339
  • Assembly RSS
Oct 20th, 2004
0

i'm a rookie, please help with MIPS

Expand Post »
so i'm learning MIPS right now and i think i get the hang of things, mind you it's all relatively easy (so i've been told), but i can't seem to get around this one problem. i was given a C++ fragment and need to convert (translate) it directly to MIPS.

and that equation is array[a+b] = array[a-b]+d

intially i thought, this would be the same as array[a]+array[b] = array[a+b]...and of course i was wrong.

though wrong, i'd still like to post what i do have....and if someone can correct me and guide me to the right direction, that'll be great!
Assembly Syntax (Toggle Plain Text)
  1. add $t1, $s0, $s0 # $t1 = 2*a
  2. add $t1, $t1, $t1 # $t1 = 4*a
  3. add $t2, $s1, $s1 # $t1 = 2*b
  4. add $t2, $t2, $t2 # $t1 = 4*b
  5. sub $t3, $t1, $t2 # $t3 = A[a] – A[b] (or A[a-b]
  6. add $t3, $t3, $t0 # $t3 = address of A[a-b]
  7. lw $t3, 0($t0) # $t3 = A[c-b]
  8. add $t4, $t3, $s2 # $t4 = A[a-b] + d
  9. add $t5, $t1, $t2 # $t5 = A[a] + A[b]
  10. add $t5, $t5, $t0 # $t5 = address of A[a+b]
  11. lw $t5, 0($t0) # $t5 = A[a+b]
  12. sw $t5, 0($t0) # A[a+b] = $t3
thanks in advance
to the admin: see i have put a HONEST effort...so can i now get help? /lol
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ulethgeek is offline Offline
1 posts
since Oct 2004
Oct 20th, 2004
0

Re: i'm a rookie, please help with MIPS

Quote originally posted by ulethgeek ...
thanks in advance
to the admin: see i have put a HONEST effort...so can i now get help? /lol
That's all we ask
Team Colleague
Reputation Points: 186
Solved Threads: 147
Cookie... That's it
alc6379 is offline Offline
2,519 posts
since Dec 2003
Feb 8th, 2007
0

Re: i'm a rookie, please help with MIPS

Click to Expand / Collapse  Quote originally posted by ulethgeek ...
so i'm learning MIPS right now and i think i get the hang of things, mind you it's all relatively easy (so i've been told), but i can't seem to get around this one problem. i was given a C++ fragment and need to convert (translate) it directly to MIPS.

and that equation is array[a+b] = array[a-b]+d

intially i thought, this would be the same as array[a]+array[b] = array[a+b]...and of course i was wrong.

though wrong, i'd still like to post what i do have....and if someone can correct me and guide me to the right direction, that'll be great!
Assembly Syntax (Toggle Plain Text)
  1. add $t1, $s0, $s0 # $t1 = 2*a
  2. add $t1, $t1, $t1 # $t1 = 4*a
  3. add $t2, $s1, $s1 # $t1 = 2*b
  4. add $t2, $t2, $t2 # $t1 = 4*b
  5. sub $t3, $t1, $t2 # $t3 = A[a] – A[b] (or A[a-b]
  6. add $t3, $t3, $t0 # $t3 = address of A[a-b]
  7. lw $t3, 0($t0) # $t3 = A[c-b]
  8. add $t4, $t3, $s2 # $t4 = A[a-b] + d
  9. add $t5, $t1, $t2 # $t5 = A[a] + A[b]
  10. add $t5, $t5, $t0 # $t5 = address of A[a+b]
  11. lw $t5, 0($t0) # $t5 = A[a+b]
  12. sw $t5, 0($t0) # A[a+b] = $t3
thanks in advance
Unless you have some la and lw instructions that you're not putting here, then you are missing the actual putting of values into registers
Reputation Points: 19
Solved Threads: 4
Light Poster
MacGyver Orca is offline Offline
39 posts
since Jan 2007
Feb 8th, 2007
0

Re: i'm a rookie, please help with MIPS

moved
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,953 posts
since Aug 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Assembly Forum Timeline: Need code to interface RTC with 8051
Next Thread in Assembly Forum Timeline: MIPS Question





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC