25.12.2012 Views

MIPS and SPIM tutorial

MIPS and SPIM tutorial

MIPS and SPIM tutorial

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

loop.s<br />

.text<br />

.globl main<br />

main: add $t0, $zero, $zero # loop-counter i<br />

addi $s0 ,$zero, 5 # loop limit N<br />

loop: beq $t0, $s0, done # for i = 0...(N-1)<br />

add $a0, $zero, $t0 # print i<br />

# system call code for print_int<br />

li $v0, 1<br />

syscall<br />

addi $t0, $t0, 1 # i ++<br />

j loop # loop again<br />

done: jr $ra # return to caller

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!