汇编语言(l2200mips),编码混乱



如果我要使用循环将$a0从0增加到10。然后,使用循环将内存地址0从0增加到10…

代码大致看起来像

Loop:
addi $a0,1

下面是在MIPS Assembly中实现循环的方法:

.globl main
main:
# start of the loop
loop:
    bgt $a0,10,exit # checks if $a0 is greater than 10 loop ending condition
    addi $a0,$a0,1  # adds one to the $a0 the loop variable
    j loop          # jumps to continue loop
exit:
    li $v0,10       # sets the value of $v0 to 10 to terminate the program
    syscall         # terminate

如果你想了解更多关于MIPS Assembly中的循环,请点击此链接

最新更新