I need help creating a MIPS program to compute the sum of N
I need help creating a MIPS program to compute the sum of N numbers such that each sum skips over certain number. I need the program to also ask the user how many numbers to skip (give the option 1-4) and then proceed to compute the sum.
Sum(x1) = N1 + N2 + N3 + …
Sum(x2) = N1 + N3 + N5 + ….
Sum(x3) = N1 + N4 + N7 + ….
Sum(x4) = N1 + N5 + N9 + ….
Sum(x1) determines the sum of all numbers; Sum(x2) determines the sum of numbers skipped by 2, Sum(x3) determines the sum of numbers skipped by 3 and so on. Assume the numbers as given below where N1 = 100, N2 = -7, N3 = 11, N4 = 25 and so on. Below is the beginning implemantation of the program.
.data
 .strA: .asciiz “Please enter your choice to skip numbers (1-4)\ ”
 Numbers: .byte 100, -7, 11, 25, -66, 99, -1, 34, 12, 22, -2, -7, 100,
 11, 4, 67, 2, -90, 22, 2, 56, 3, -89, 12, -10, 21, 10, -25, -6, 9, 111,
 34, 12, 22, -2, -17, 100, 111, -4, 7, 14, -19, -2, 29, 36, 31, -79, 2
 .globl main
 .text
 main:
Solution
## data segment
 .data
 strAskN: .asciiz \"Enter a positive integer n:\"
 ans1: .asciiz \"SkipSum of \"
 ans2: .asciiz \" is \"
 endl: .asciiz \"\ \"
 
 ## text segment
 .text
 main:
 li $v0, 4   
 la $a0, strAskN   
 syscall
 
 li $v0,5
 syscall
 
 move $s1, $v0   
 move $a0, $s1   
 jal skipsum
 
 move $a0, $s1   
 move $a1, $v0
 jal print
 
 j finish
 
 SkipSum:
 addi $sp, $sp, -8 #using stack to store ra and a0(n)
 sw $ra, 4($sp) #store ra
 sw $a0, 0($sp)
 lw $a0, 0($sp)
 lw $ra, 4($sp)
 slti $t0, 0, $a0 #if n>0, set t0 to 1
 bne $t0, 0, recurs #if t0 !=0, (n>0) goto recurs
 li $v0, 0 #otherwise, set v0 = 0 (n<=0)
 addi $sp, $sp, 8   
 jr $ra
 recurs:
 addi $a0, $a0, -2 #calculate n=n-2
 jal SkipSum #call SkipSum(n-2)
 lw $a0, 0($sp) #get n
 lw $ra, 4($sp) #get ra
 add $v0, $v0, $a0 #SkipSum(n) = n + SkipSum(n-2)
 add $sp, $sp, 8
 jr $ra
 
 
 print:
 jr $ra
 
 finish: li $v0, 10
 syscall


