我必须从键盘输入输入(a)和(b)。而且我必须创建一个大小为b的数组。并从代码c打印嵌套循环的结果

时间:2019-07-19 09:32:44

标签: arrays assembly mips

我必须从键盘输入输入(a)和(b)。而且我必须创建一个大小为b的数组。并打印嵌套循环的结果以进行验证 循环包含此代码。

.text
.main
addi $t0, $zero, -1         #i = -1

for1loop:
addi $t0, $t0, 1            #i += 1
slt $t2, $t0, $s0           #i < a
beq $t2, $zero, exit        #if $t2 == 0, go to exit
and $t1, $t1, $zero         #j = 0

for2loop: slt $t2, $t1, $s1 #j < b
beq $t2, $zero, for1loop    #if $t2 == 0, branch to for1tst         
sll $t4, $t1, 4             #reg $t4 = 4 * j
add $t2, $t0, $t4           #reg $t2 = i + 4 * j
add $t3, $s2, $t1           #reg $t3 = &D[j]
sw $t2, 0($t3)              #store $s2 in address pointed by $t3
addi $t1, $t1, 1            #j += 1
j for2loop                  #jump to for2tst

li $v0,10 # code for exit
syscall # exit program

0 个答案:

没有答案