.data empty_QS: .text jal Main li $v0 10 syscall Main: sw $fp -8($sp) move $fp $sp subu $sp $sp 8 sw $ra -4($fp) li $a0 8 jal _heapAlloc move $t0 $v0 bgtz $t0 null1 la $a0 _str0 j _error null1: move $a0 $t0 li $a1 10 jal QS.Start move $t0 $v0 move $a0 $t0 jal _print lw $ra -4($fp) lw $fp -8($fp) addu $sp $sp 8 jr $ra QS.Start: sw $fp -8($sp) move $fp $sp subu $sp $sp 12 sw $ra -4($fp) sw $s0 -12($fp) move $s0 $a0 move $t0 $a1 move $a0 $s0 move $a1 $t0 jal QS.Init move $a0 $s0 jal QS.Print li $a0 9999 jal _print lw $t0 4($s0) move $a0 $t0 li $t9 1 subu $t0 $a0 $t9 move $a0 $s0 li $a1 0 move $a2 $t0 jal QS.Sort move $a0 $s0 jal QS.Print li $v0 0 lw $s0 -12($fp) lw $ra -4($fp) lw $fp -8($fp) addu $sp $sp 12 jr $ra QS.Sort: sw $fp -8($sp) move $fp $sp subu $sp $sp 20 sw $ra -4($fp) sw $s0 -12($fp) sw $s1 -16($fp) sw $s2 -20($fp) move $s0 $a0 move $t0 $a1 move $s1 $a2 li $t1 0 move $a0 $t0 move $t9 $s1 slt $t2 $a0 $t9 blez $t2 if1_else lw $t2 0($s0) bgtz $t2 null2 la $a0 _str0 j _error null2: lw $t3 0($t2) move $a0 $s1 move $t9 $t3 sltu $t3 $a0 $t9 bgtz $t3 bounds1 la $a0 _str0 j _error bounds1: move $a0 $s1 li $t9 4 mul $t3 $a0 $t9 move $a0 $t3 move $t9 $t2 addu $t3 $a0 $t9 lw $t3 4($t3) move $a0 $t0 li $t9 1 subu $s2 $a0 $t9 move $t2 $s1 li $t4 1 while1_top: blez $t4 while1_end li $t5 1 while2_top: blez $t5 while2_end move $a0 $s2 li $t9 1 addu $s2 $a0 $t9 lw $t6 0($s0) bgtz $t6 null3 la $a0 _str0 j _error null3: lw $t7 0($t6) move $a0 $s2 move $t9 $t7 sltu $t7 $a0 $t9 bgtz $t7 bounds2 la $a0 _str0 j _error bounds2: move $a0 $s2 li $t9 4 mul $t7 $a0 $t9 move $a0 $t7 move $t9 $t6 addu $t7 $a0 $t9 lw $t7 4($t7) move $a0 $t7 move $t9 $t3 slt $t6 $a0 $t9 bgtz $t6 if2_else li $t5 0 j if2_end if2_else: li $t5 1 if2_end: j while2_top while2_end: li $t5 1 while3_top: blez $t5 while3_end move $a0 $t2 li $t9 1 subu $t2 $a0 $t9 lw $t6 0($s0) bgtz $t6 null4 la $a0 _str0 j _error null4: lw $t8 0($t6) move $a0 $t2 move $t9 $t8 sltu $t8 $a0 $t9 bgtz $t8 bounds3 la $a0 _str0 j _error bounds3: move $a0 $t2 li $t9 4 mul $t8 $a0 $t9 move $a0 $t8 move $t9 $t6 addu $t8 $a0 $t9 lw $t7 4($t8) move $a0 $t3 move $t9 $t7 slt $t7 $a0 $t9 bgtz $t7 if3_else li $t5 0 j if3_end if3_else: li $t5 1 if3_end: j while3_top while3_end: lw $t5 0($s0) bgtz $t5 null5 la $a0 _str0 j _error null5: lw $t7 0($t5) move $a0 $s2 move $t9 $t7 sltu $t7 $a0 $t9 bgtz $t7 bounds4 la $a0 _str0 j _error bounds4: move $a0 $s2 li $t9 4 mul $t7 $a0 $t9 move $a0 $t7 move $t9 $t5 addu $t7 $a0 $t9 lw $t1 4($t7) lw $t7 0($s0) bgtz $t7 null6 la $a0 _str0 j _error null6: lw $t5 0($t7) move $a0 $s2 move $t9 $t5 sltu $t5 $a0 $t9 bgtz $t5 bounds5 la $a0 _str0 j _error bounds5: move $a0 $s2 li $t9 4 mul $t5 $a0 $t9 move $a0 $t5 move $t9 $t7 addu $t5 $a0 $t9 lw $t7 0($s0) bgtz $t7 null7 la $a0 _str0 j _error null7: lw $t8 0($t7) move $a0 $t2 move $t9 $t8 sltu $t8 $a0 $t9 bgtz $t8 bounds6 la $a0 _str0 j _error bounds6: move $a0 $t2 li $t9 4 mul $t8 $a0 $t9 move $a0 $t8 move $t9 $t7 addu $t8 $a0 $t9 lw $t8 4($t8) sw $t8 4($t5) lw $t8 0($s0) bgtz $t8 null8 la $a0 _str0 j _error null8: lw $t5 0($t8) move $a0 $t2 move $t9 $t5 sltu $t5 $a0 $t9 bgtz $t5 bounds7 la $a0 _str0 j _error bounds7: move $a0 $t2 li $t9 4 mul $t5 $a0 $t9 move $a0 $t5 move $t9 $t8 addu $t5 $a0 $t9 sw $t1 4($t5) move $a0 $s2 li $t9 1 addu $t5 $a0 $t9 move $a0 $t2 move $t9 $t5 slt $t5 $a0 $t9 blez $t5 if4_else li $t4 0 j if4_end if4_else: li $t4 1 if4_end: j while1_top while1_end: lw $t4 0($s0) bgtz $t4 null9 la $a0 _str0 j _error null9: lw $t3 0($t4) move $a0 $t2 move $t9 $t3 sltu $t3 $a0 $t9 bgtz $t3 bounds8 la $a0 _str0 j _error bounds8: move $a0 $t2 li $t9 4 mul $t3 $a0 $t9 move $a0 $t3 move $t9 $t4 addu $t3 $a0 $t9 lw $t4 0($s0) bgtz $t4 null10 la $a0 _str0 j _error null10: lw $t2 0($t4) move $a0 $s2 move $t9 $t2 sltu $t2 $a0 $t9 bgtz $t2 bounds9 la $a0 _str0 j _error bounds9: move $a0 $s2 li $t9 4 mul $t2 $a0 $t9 move $a0 $t2 move $t9 $t4 addu $t2 $a0 $t9 lw $t2 4($t2) sw $t2 4($t3) lw $t2 0($s0) bgtz $t2 null11 la $a0 _str0 j _error null11: lw $t3 0($t2) move $a0 $s2 move $t9 $t3 sltu $t3 $a0 $t9 bgtz $t3 bounds10 la $a0 _str0 j _error bounds10: move $a0 $s2 li $t9 4 mul $t3 $a0 $t9 move $a0 $t3 move $t9 $t2 addu $t3 $a0 $t9 lw $t2 0($s0) bgtz $t2 null12 la $a0 _str0 j _error null12: lw $t4 0($t2) move $a0 $s1 move $t9 $t4 sltu $t4 $a0 $t9 bgtz $t4 bounds11 la $a0 _str0 j _error bounds11: move $a0 $s1 li $t9 4 mul $t4 $a0 $t9 move $a0 $t4 move $t9 $t2 addu $t4 $a0 $t9 lw $t4 4($t4) sw $t4 4($t3) lw $t4 0($s0) bgtz $t4 null13 la $a0 _str0 j _error null13: lw $t3 0($t4) move $a0 $s1 move $t9 $t3 sltu $t3 $a0 $t9 bgtz $t3 bounds12 la $a0 _str0 j _error bounds12: move $a0 $s1 li $t9 4 mul $t3 $a0 $t9 move $a0 $t3 move $t9 $t4 addu $t3 $a0 $t9 sw $t1 4($t3) move $a0 $s2 li $t9 1 subu $t3 $a0 $t9 move $a0 $s0 move $a1 $t0 move $a2 $t3 jal QS.Sort move $a0 $s2 li $t9 1 addu $t3 $a0 $t9 move $a0 $s0 move $a1 $t3 move $a2 $s1 jal QS.Sort j if1_end if1_else: if1_end: li $v0 0 lw $s0 -12($fp) lw $s1 -16($fp) lw $s2 -20($fp) lw $ra -4($fp) lw $fp -8($fp) addu $sp $sp 20 jr $ra QS.Print: sw $fp -8($sp) move $fp $sp subu $sp $sp 8 sw $ra -4($fp) move $t0 $a0 li $t1 0 while4_top: lw $t2 4($t0) move $a0 $t1 move $t9 $t2 slt $t2 $a0 $t9 blez $t2 while4_end lw $t2 0($t0) bgtz $t2 null14 la $a0 _str0 j _error null14: lw $t3 0($t2) move $a0 $t1 move $t9 $t3 sltu $t3 $a0 $t9 bgtz $t3 bounds13 la $a0 _str0 j _error bounds13: move $a0 $t1 li $t9 4 mul $t3 $a0 $t9 move $a0 $t3 move $t9 $t2 addu $t3 $a0 $t9 lw $t3 4($t3) move $a0 $t3 jal _print move $a0 $t1 li $t9 1 addu $t1 $a0 $t9 j while4_top while4_end: li $v0 0 lw $ra -4($fp) lw $fp -8($fp) addu $sp $sp 8 jr $ra QS.Init: sw $fp -8($sp) move $fp $sp subu $sp $sp 12 sw $ra -4($fp) sw $s0 -12($fp) move $s0 $a0 move $t0 $a1 sw $t0 4($s0) move $a0 $t0 jal AllocArray move $t0 $v0 sw $t0 0($s0) lw $t0 0($s0) bgtz $t0 null15 la $a0 _str0 j _error null15: lw $t1 0($t0) li $a0 0 move $t9 $t1 sltu $t1 $a0 $t9 bgtz $t1 bounds14 la $a0 _str0 j _error bounds14: li $a0 0 li $t9 4 mul $t1 $a0 $t9 move $a0 $t1 move $t9 $t0 addu $t1 $a0 $t9 li $t9 20 sw $t9 4($t1) lw $t1 0($s0) bgtz $t1 null16 la $a0 _str0 j _error null16: lw $t0 0($t1) li $a0 1 move $t9 $t0 sltu $t0 $a0 $t9 bgtz $t0 bounds15 la $a0 _str0 j _error bounds15: li $a0 1 li $t9 4 mul $t0 $a0 $t9 move $a0 $t0 move $t9 $t1 addu $t0 $a0 $t9 li $t9 7 sw $t9 4($t0) lw $t0 0($s0) bgtz $t0 null17 la $a0 _str0 j _error null17: lw $t1 0($t0) li $a0 2 move $t9 $t1 sltu $t1 $a0 $t9 bgtz $t1 bounds16 la $a0 _str0 j _error bounds16: li $a0 2 li $t9 4 mul $t1 $a0 $t9 move $a0 $t1 move $t9 $t0 addu $t1 $a0 $t9 li $t9 12 sw $t9 4($t1) lw $t1 0($s0) bgtz $t1 null18 la $a0 _str0 j _error null18: lw $t0 0($t1) li $a0 3 move $t9 $t0 sltu $t0 $a0 $t9 bgtz $t0 bounds17 la $a0 _str0 j _error bounds17: li $a0 3 li $t9 4 mul $t0 $a0 $t9 move $a0 $t0 move $t9 $t1 addu $t0 $a0 $t9 li $t9 18 sw $t9 4($t0) lw $t0 0($s0) bgtz $t0 null19 la $a0 _str0 j _error null19: lw $t1 0($t0) li $a0 4 move $t9 $t1 sltu $t1 $a0 $t9 bgtz $t1 bounds18 la $a0 _str0 j _error bounds18: li $a0 4 li $t9 4 mul $t1 $a0 $t9 move $a0 $t1 move $t9 $t0 addu $t1 $a0 $t9 li $t9 2 sw $t9 4($t1) lw $t1 0($s0) bgtz $t1 null20 la $a0 _str0 j _error null20: lw $t0 0($t1) li $a0 5 move $t9 $t0 sltu $t0 $a0 $t9 bgtz $t0 bounds19 la $a0 _str0 j _error bounds19: li $a0 5 li $t9 4 mul $t0 $a0 $t9 move $a0 $t0 move $t9 $t1 addu $t0 $a0 $t9 li $t9 11 sw $t9 4($t0) lw $t0 0($s0) bgtz $t0 null21 la $a0 _str0 j _error null21: lw $t1 0($t0) li $a0 6 move $t9 $t1 sltu $t1 $a0 $t9 bgtz $t1 bounds20 la $a0 _str0 j _error bounds20: li $a0 6 li $t9 4 mul $t1 $a0 $t9 move $a0 $t1 move $t9 $t0 addu $t1 $a0 $t9 li $t9 6 sw $t9 4($t1) lw $t1 0($s0) bgtz $t1 null22 la $a0 _str0 j _error null22: lw $t0 0($t1) li $a0 7 move $t9 $t0 sltu $t0 $a0 $t9 bgtz $t0 bounds21 la $a0 _str0 j _error bounds21: li $a0 7 li $t9 4 mul $t0 $a0 $t9 move $a0 $t0 move $t9 $t1 addu $t0 $a0 $t9 li $t9 9 sw $t9 4($t0) lw $t0 0($s0) bgtz $t0 null23 la $a0 _str0 j _error null23: lw $t1 0($t0) li $a0 8 move $t9 $t1 sltu $t1 $a0 $t9 bgtz $t1 bounds22 la $a0 _str0 j _error bounds22: li $a0 8 li $t9 4 mul $t1 $a0 $t9 move $a0 $t1 move $t9 $t0 addu $t1 $a0 $t9 li $t9 19 sw $t9 4($t1) lw $t1 0($s0) bgtz $t1 null24 la $a0 _str0 j _error null24: lw $t0 0($t1) li $a0 9 move $t9 $t0 sltu $t0 $a0 $t9 bgtz $t0 bounds23 la $a0 _str0 j _error bounds23: li $a0 9 li $t9 4 mul $t0 $a0 $t9 move $a0 $t0 move $t9 $t1 addu $t0 $a0 $t9 li $t9 5 sw $t9 4($t0) li $v0 0 lw $s0 -12($fp) lw $ra -4($fp) lw $fp -8($fp) addu $sp $sp 12 jr $ra AllocArray: sw $fp -8($sp) move $fp $sp subu $sp $sp 8 sw $ra -4($fp) move $t0 $a0 move $a0 $t0 li $t9 4 mul $t1 $a0 $t9 move $a0 $t1 li $t9 4 addu $t1 $a0 $t9 move $a0 $t1 jal _heapAlloc move $t1 $v0 sw $t0 0($t1) move $v0 $t1 lw $ra -4($fp) lw $fp -8($fp) addu $sp $sp 8 jr $ra _print: li $v0 1 # syscall: print integer syscall la $a0 _newline li $v0 4 # syscall: print string syscall jr $ra _error: li $v0 4 # syscall: print string syscall li $v0 10 # syscall: exit syscall _heapAlloc: li $v0 9 # syscall: sbrk syscall jr $ra .data .align 0 _newline: .asciiz "\n" _str0: .asciiz "null pointer\n"