i'm a rookie, please help with MIPS

Please support our Assembly advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Oct 2004
Posts: 1
Reputation: ulethgeek is an unknown quantity at this point 
Solved Threads: 0
ulethgeek ulethgeek is offline Offline
Newbie Poster

i'm a rookie, please help with MIPS

 
0
  #1
Oct 20th, 2004
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!
  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
Reply With Quote Quick reply to this message  
Join Date: Dec 2003
Posts: 2,414
Reputation: alc6379 has a spectacular aura about alc6379 has a spectacular aura about alc6379 has a spectacular aura about 
Solved Threads: 123
Team Colleague
alc6379's Avatar
alc6379 alc6379 is offline Offline
Cookie... That's it

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

 
0
  #2
Oct 20th, 2004
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
Alex Cavnar, aka alc6379
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 39
Reputation: MacGyver Orca is an unknown quantity at this point 
Solved Threads: 4
MacGyver Orca's Avatar
MacGyver Orca MacGyver Orca is offline Offline
Light Poster

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

 
0
  #3
Feb 8th, 2007
Originally Posted by ulethgeek View 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!
  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
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,484
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1478
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

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

 
0
  #4
Feb 8th, 2007
moved
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC