Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.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_Computer Architecture - Fatal编程技术网

Mips 在循环中打印出值

Mips 在循环中打印出值,mips,computer-architecture,Mips,Computer Architecture,嘿,伙计们,我是科马克的新手。我正在写家庭作业。我的问题是,我的程序中有一个循环,它将用户的int输入除以10,我的循环将通过and除以,直到商为0。目前,它为我的商打印出0,但没有打印出余数的每个值。那么,我该如何修改代码以打印出除法后剩余的每一个余数呢 loop: li $s0, 10 #divisor div $t0,$s0 #divide input by 10 mflo $t0 #quotiant mfhi $t3 #rem

嘿,伙计们,我是科马克的新手。我正在写家庭作业。我的问题是,我的程序中有一个循环,它将用户的int输入除以10,我的循环将通过and除以,直到商为0。目前,它为我的商打印出0,但没有打印出余数的每个值。那么,我该如何修改代码以打印出除法后剩余的每一个余数呢

loop:
    li $s0, 10    #divisor

    div $t0,$s0 #divide input by 10
    mflo $t0    #quotiant 
    mfhi $t3        #remainder
    sw $t3, ($t1)   #stores emainder into address of int_a
    addi $t1,$t1,4  #increases the pointer
 bne  $t0,0,loop
您将在部分中找到如何打印值的详细信息

在循环中,您必须打印$t3


您必须执行一个系统调用来打印输出,在哪里会发生这种情况?在循环外?因为您要打印余数的每个值,所以它当然会在循环内。谢谢您,先生。非常有用的信息好的,谢谢。还有一件事。因为我只是把每个除法的余数都打印出来。哪些余数保存在我定义的数组的地址中?所有,第一个余数还是最后一个余数?@AbrahamCarmona$t3只保留循环完成后的最后一个余数。因此,只是为了获得一些方向。我必须创建一个新的循环,在其中,每个剩余部分都存储在某个地址中?对吗@vonC@AbrahamCarmona您可以将存储步骤包括在循环本身中,因为一旦循环完成,剩余部分就会丢失。明白了。非常非常有帮助。实际上比我的助教更有用。谢谢
li  $v0, 1          # load appropriate system call code into register $v0;
                    # code for printing integer is 1
move    $a0, $t3    # move integer to be printed into $a0:  $a0 = $t3
syscall             # call operating system to perform operation