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 = 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!
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
thanks in advance
to the admin: see i have put a HONEST effort...so can i now get help? /lol