MIPS以及如何存储正确数量的数字

时间:2016-09-27 02:01:29

标签: assembly architecture mips cpu-registers

.data
price:    .word   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
str1:   .asciiz   " Please enter the number of items you are entering:   "
str2:    .asciiz     " Please enter the price of each item : "
str3:    .asciiz     " The total is: "
.text


.main:
        li    $s0,0        #counter
        li    $s1,20        #20

        li    $v0,4        #print string
        la    $a0,str1    #load address
        syscall            #output


        li $v0,5
        syscall
        add    $s2,$0,$v0    # put the number of integers need to inputed to $v0

        ble    $s2, $s1,loop1    


        li    $v0,4        #print string
        la    $a0,str3    #load address
        syscall            #output


loop1:

        li    $v0,4        #print string
        la    $a0,str2    #load address
        syscall            #output

        li $v0,5
        syscall
        add    $s2,$0,$v0    # put the number of integers needed to inputed to  $s2

j loop1

我搞砸的是,它询问我输入的项目数量,例如我输入3,它只存储2个数字。我该怎么办,以便屏幕将所有数字输出到屏幕上?感谢。

0 个答案:

没有答案