Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MIPS气泡排序算法未打印_Mips_Bubble Sort - Fatal编程技术网

MIPS气泡排序算法未打印

MIPS气泡排序算法未打印,mips,bubble-sort,Mips,Bubble Sort,我目前正开始学习MIPS语言,并试图用MIPS编写一个冒泡排序代码,但我想我在某个地方犯了一个错误,似乎找不到它。我相信我正在正确地存储元素,但我不知道为什么它不工作。下面是我的代码的图片: .data array: .space 100 i: .word 0 j: .word 0 temp: .word .text la $s2, i la $s3, j la $s4, temp li $v0,5 syscall move $s0, $v0 #array size li $v0, 8 la

我目前正开始学习MIPS语言,并试图用MIPS编写一个冒泡排序代码,但我想我在某个地方犯了一个错误,似乎找不到它。我相信我正在正确地存储元素,但我不知道为什么它不工作。下面是我的代码的图片:

.data
array: .space 100
i: .word 0
j: .word 0
temp: .word 
.text
la $s2, i
la $s3, j
la $s4, temp
li $v0,5
syscall
move $s0, $v0 #array size
li $v0, 8
la $a0, array
li $a1, 100
move $s1, $a0 #actual array(with elements)
syscall
move $a0, $s0 #size becomes argument
move $a1, $s1 #array becomes argument
jal BubbleSort
li $v0, 4
move $a0, $v0
syscall
li $v0, 10
syscall
BubbleSort:
move $s0, $a0
move $s1, $a1
j ExternalLoop
ExternalLoop:
slt $t0,$s2, $s0 #for(i=0;I<N;i++)
beq $t0, $zero, ExitLoop
j InternalLoop
addi $s2, $s2,1 #i++
li $s3, 0 #reset j after every iteration
InternalLoop:
slt $t1, $s3, $s0 #for(j=0;J<N;j++)
beq $t1, $zero, ExitLoop
#array[j]=s1+4*j :
#sll $t2, $s3, 2
#add $s1, $s1, $t2
lb $t3, 0($s1) #array[j]
lb $t4, 4($s1) #array[j+1]
#swapping:
move $s4, $t3
move $t3, $t4
move $t4, $s4
sb $t5, 0($t3)
addi $s3, $s3, 1 #j++
j InternalLoop
move $v0, $t5
ExitLoop:
jr $ra
.data
数组:。空间为100
i:word 0
j:单词0
温度:。字
.文本
洛杉矶2美元,我
洛杉矶$s3,j
洛杉矶4美元,临时工
李$v0,5
系统调用
移动$s0、$v0#阵列大小
李$v0,8
la$a0,阵列
李:1100美元
移动$s1、$a0#实际数组(带元素)
系统调用
移动$a0,$s0#大小变为参数
移动$a1,$s1#数组变为参数
日航泡泡港
李$v0,4
移动$a0,$v0
系统调用
李$v0,10
系统调用
泡泡糖:
移动$s0,$a0
移动$s1,$a1
外环
外部环路:

slt$t0,$s2,$s0#for(i=0;i.只需复制并粘贴在此处,谢谢您的评论。