Thanks a lot once again, i hope i am not bugging you a lot but a have a few more questions

first another code translation attempt

c code

f = g- A[B[4]];

mips

//f->so g->s1 A base=s6 and B base - s7
lw t0, 16(s7)
sll t0, t0, 2
add t0, t0, s6
lw s0, 0(t0)
sub s0, s1, s0

Then i have something else troubling me . In my coursebook there are some translated programs but i dont understand why they do what follows

code 1

compare:
addi $sp, $sp, –4
sw $ra, 0($sp)
add $s0, $a0, $0 // whats the point of doing that
add $s1, $a1, $0 //and that ?
jal sub
addi $t1, $0, 1
beq $v0, $0, exit
slt $t2, $0, $v0
bne $t2, $0, exit
addi $t1, $0, $0
exit:
add $v0, $t1, $0
lw $ra, 0($sp)
addi $sp, $sp, 4
jr $ra
sub:
sub $v0, $a0, $a1
jr $ra

code 2 (another interpretation of the c code i tried on my last post)

fi:
addi $sp, $sp, –16
sw $ra, 12($sp)
sw $s0, 8($sp) // why he does all that instead of storing a0,a1,a2 ?
sw $s1, 4($sp) //
sw $s2, 0($sp) //
add $s0, $a0, $0 //
add $s1, $a1, $0 //
add $s2, $a2, $0 //
add $v0, $s1, $0,
bne $s2, $0, exit
add $a0, $s0, $s1
add $a1, $s0, $0
add $a2, $s2, –1
jal fi
exit:
lw $s2, 0($sp)
lw $s1, 4($sp)
lw $s0, 8($sp)
lw $ra, 12($sp)
addi $sp, $sp, 16
jr $ra

Thanks in advance, your help is very appreciated