| | |
i'm a rookie, please help with MIPS
![]() |
•
•
Join Date: Oct 2004
Posts: 1
Reputation:
Solved Threads: 0
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!
thanks in advance
to the admin: see i have put a HONEST effort...so can i now get help? /lol
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)
add $t1, $s0, $s0 # $t1 = 2*a add $t1, $t1, $t1 # $t1 = 4*a add $t2, $s1, $s1 # $t1 = 2*b add $t2, $t2, $t2 # $t1 = 4*b sub $t3, $t1, $t2 # $t3 = A[a] – A[b] (or A[a-b] add $t3, $t3, $t0 # $t3 = address of A[a-b] lw $t3, 0($t0) # $t3 = A[c-b] add $t4, $t3, $s2 # $t4 = A[a-b] + d add $t5, $t1, $t2 # $t5 = A[a] + A[b] add $t5, $t5, $t0 # $t5 = address of A[a+b] lw $t5, 0($t0) # $t5 = A[a+b] sw $t5, 0($t0) # A[a+b] = $t3
to the admin: see i have put a HONEST effort...so can i now get help? /lol
•
•
•
•
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!
thanks in advanceAssembly Syntax (Toggle Plain Text)
add $t1, $s0, $s0 # $t1 = 2*a add $t1, $t1, $t1 # $t1 = 4*a add $t2, $s1, $s1 # $t1 = 2*b add $t2, $t2, $t2 # $t1 = 4*b sub $t3, $t1, $t2 # $t3 = A[a] – A[b] (or A[a-b] add $t3, $t3, $t0 # $t3 = address of A[a-b] lw $t3, 0($t0) # $t3 = A[c-b] add $t4, $t3, $s2 # $t4 = A[a-b] + d add $t5, $t1, $t2 # $t5 = A[a] + A[b] add $t5, $t5, $t0 # $t5 = address of A[a+b] lw $t5, 0($t0) # $t5 = A[a+b] sw $t5, 0($t0) # A[a+b] = $t3
![]() |
Similar Threads
- Rookie in game development. Where should I start? (Game Development)
- Hello everybody! I'm a forum rookie (Community Introductions)
- Looking for a tutor for MIPS programming (Assembly)
- Mips Assembly porting from C (Assembly)
- Easy (I hope) MIPS (SPIM) Question (Assembly)
Other Threads in the Assembly Forum
- Previous Thread: Need code to interface RTC with 8051
- Next Thread: MIPS Question
| Thread Tools | Search this Thread |






