MIPS: Calculating Sigma Summation

Viewed 21

In MIPS assembler: Im trying to sum from i = 0 to i = 7 the parameters Ai, Bi, Ci. Each Ai is increased by multiples of 3 and each Bi increased by multiples of 4. The Ci switches from 1 to -1, beginning from positive for i = 0.

I tried to use the code below:

addi $t1, $0, 8     
addi $s0, $0, 1 

add $s2, $s0, $0    
add $s1, $s2, $0    
xor $t0, $t0, $t0   
xor $s3, $s3, $s3

for:
    beq $t0, $t1, exit
    mult $s0, $s2       
    mflo $t4        
    mult $s1, $t4       
    mflo $t4        
    add $s3, $s3, $t4   
    add $t2, $s0, $s0   
    add $s0, $t2, $s0   
    sll $s2, $s2, 2     
    nor $s1, $s1, $0    
    addi $s1, $s1, 1    
    addi $t0, $t0, 1
    j for
exit:
    add $s2, $s3, $0    

Mars assembler outputs all the registers as zeros. Got no idea what to do.

0 Answers
Related