#Count from 0 to 9 (like for (i = 0; i < 10; i++)
#for (int i = 0; i < 10; i++) {
#    printf("%d\n", i);
#}

.data
newline: .asciiz "\n"

.text
.globl main
main:
#We use register $t0 to store the loop variable i.
#li means load immediate, i.e., set $t0 to 0.
    li $t0, 0          # i = 0

loop:
   li $t1, 10         # constant 10
    slt $t2, $t0, $t1  # $t2 = ($t0 < 10) ? 1 : 0
    beq $t2, $zero, end   # if $t0 >= 10, jump to end 
    #we can replace the slt and beq with
    # bge $t0, 10, end   # if i >= 10, exit loop
   

    # print i
    move $a0, $t0
    li $v0, 1          # syscall for print_int
    syscall
    
    #This block prints the value of i.
#In MIPS, to print an integer:

   # Place the number in $a0.

  #  Set $v0 to 1 (the print_int syscall)

    # print newline
    li $v0, 4
    la $a0, newline
    syscall

    addi $t0, $t0, 1   # i++

    j loop             # go back to top of loop
    #Increment i ($t0) by 1.
#Jump back to loop.

end:
    li $v0, 10         # exit
    syscall

