- 8
- 0
- 约2.4千字
- 约 3页
- 2023-03-06 发布于湖北
- 举报
快速排序 (基于mips汇编语⾔)
实验要求:
输⼊n
接下来n⾏输⼊n个整数
利⽤快速排序算法 输出排序后的数列 (⽤逗号隔开)
.data
array: .space 4004
space: .asciiz
enter: .asciiz \n
.macro scanfint
li $v0, 5
syscall
.end_macro
.macro get_index (%ans, %i)
sll %ans, %i, 2
.end_macro
.macro done
li $v0,10
syscall
.end_macro
.text
scanfint
move $s0, $v0#n
li $t0, 0#i
for_scanf:
beq $t0, $s0, end_scanf
scanfint
get_index ($t 1, $t0)
sw $v0, array ($t 1)#a[i]
addi $t0, $t0, 1
j for_scanf
end_scanf:
li $a0, 0
addi $a1, $s0, - 1
j al
原创力文档

文档评论(0)