1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35

# primes.txt
# Written by Geckoo1337
# Computes the primes numbers until it reaches 1000
.data
.text
ori $t0, $t0, 1 # start with 2
ori $t3, $t3, 1000 # go up to 1000
ori $v0, $v0, 1 # integer print syscall
.main:
ori $t1, $zero, 0 # reset the divisor to start at 2
ori $t1, $t1, 2
addi $t0, $t0, 1 # ++
sub $t2, $t3, $t0 # check limit
blez $t2, .done # jump to the end
.loop:
sub $t2, $t0, $t1 # check if denominator >= divisor
blez $t2, .prime # this integer is a prime number
div $t0, $t1 # compute current integer by its denominator
mfhi $t2 # get the remainder
blez $t2, .main # if the remainder equals 0, not a prime
addi $t1, $t1, 1 # try the next divisor
j .loop
.prime: # this is a prime number
add $a0, $zero, $t0
syscall
j .main # run baby run
.done: # done  bye bye!
 