```mips
add $t0, $s1, $s2  # g + h
add $t1, $s3, $s4  # i + j
sub $s0, $t0, $t1
```
## MIPS Arithmetic
- What if `g` and `j` are pointers?
    ```c
        f = (*g + h) - (i + *j);
    ```
  
     | Variable |  Register | 
     | f |  $s0 | 
     | g |  $s1 | 
     | h |  $s2 | 
     | i |  $s3 | 
     | j |  $s4 | 
  
 
```mips
lw $t2, 0($s1)     # loads g
add $t0, $t2, $s2  # *g + h
lw $t2, 0($s4)     # loads j
add $t1, $s3, $t2  # i + *j
sub $s0, $t0, $t1
```
## MIPS Arithmetic
- What if there are constants involved?
    ```c
    x = 1;
    x = x + 1;
    ```
    ```mips
    addi $s0, $zero, 1
    addi $s0, $s0, 1
    ```
    
## MIPS Arithmetic
- What if the variable `x` was an array?
```c
x[3] = 1;           // assume that x is an
x[3] = x[3] + 1;    // array of int values
```
```mips
addi $t0, $zero, 1
sw $t0, 12($s0)
lw $t1, 12($s0)
addi $t1, $t1, 1
sw $t1, 12($s0)
```
## What's in that register?
- Determine the final value of `$s1` 
  
     | Memory Address |  Memory Value | 
     | 140 |  11 | 
     | 136 |  109 | 
     | 132 |  -11 | 
     | 128 |  101 | 
     | 124 |  2 | 
     | 120 |  23 | 
     | 116 |  46 | 
     | 112 |  12 | 
     | 108 |  33 | 
     | 104 |  36 | 
     | 100 |  9 | 
  
 
```mips
addi $s0, $zero, 11
addi $s1, $zero, 108
addi $s2, $zero, 3
addi $s3, $zero, 100
addi $t0, $zero, 12
addi $t1, $zero, -22
addi $t2, $zero, 24
addi $t3, $zero, 13
lw $t0, 8($s3)
sub $t1, $t0, $t1
lw $t4, 4($s1)
add $t4, $t4, $t4
add $s1, $t1, $t4
```