## $t0-$t9  temporary registers
## $s0-$s7  saved values
## $a0-$a3  function arguments
## $v0-$v1  return values
## $ra      return address
## $sp      stack pointer
## $fp      frame pointer

#include    <xc.h>
            .equ       aSize,100
## Data is defined here
            .data
i:          .long      0
j:          .long      0
V:          .fill      aSize,4
x:          .long      0
y:          .long      0
z:          .long      0
vSize:      .long      aSize

## Code is defined here
            .global    main
            .text
            .set       noreorder
            .ent       main
main:
            addi       $sp, $sp, -4
            sw         $ra, 0($sp)

## initialize V to the first 100 square numbers
            lw         $t0,vSize        ## 100, 99, 98, 97, 
            la         $t1,V            ## &V[0], &V[1], &V[2], 
            add        $t2,$0,$0        ## 0, 1, 4, 9, 16, ...
            addi       $t3,$0,1         ## 1, 3, 5, 7, 9, ...
initloop:
            sw         $t2,0($t1)
            add        $t2,$t2,$t3
            addi       $t3,$t3,2
            addi       $t1,$t1,4
            addi       $t0,$t0,-1
            bne        $t0,$0,initloop
            nop

## Your answers should work for these 10 sections of code
## regardless of the initial values of i and j

## sect 0
## x = V[15] ;

## sect 1
## V[17] = -17 ;

## sect 2
## y = V[i] ;

## sect 3
## V[j] = -19 ;

## sect 4
## x = V[i+5] ;

## sect 5
## V[i+j] = -23 ;

## sect 6
## i = (i+j)/2 ;

## sect 7
## V[i] = V[j] ;

## sect 8
## V[16] = V[24] ;

## sect 9
## V[++i] = V[j+=5] ;


            lw      $ra, 0($sp)
            addi    $sp, $sp, 4
            jr      $ra
            nop

            .end    main



