$\require{cancel}$
- add
- addi
- sub
- beq
- bne
- j
int i{0}; while (i < 10) { cout << i << endl; i++; } return 0;
.data LOOP_LIMIT: .word 10 ENDL: .asciiz "\n" .text .globl main main: # use $t0 as lcv # use $t1 to hold the loop limit # i =0 li $t0, 0 lw $t1, LOOP_LIMIT # while i < 10 TOP_OF_LOOP: beq $t0, $t1, PROGRAM_EXIT # cout << i li $v0,1 addi $a0, $t0, 0 syscall # cout << endl li $v0, 4 la $a0, ENDL syscall # i++ addi $t0, $t0, 1 j TOP_OF_LOOP PROGRAM_EXIT: # return 0 li $v0, 10 syscall