首页 > 解决方案 > 我如何让这个程序显示而不是三个?

问题描述

我在 MIPS 中创建了一个数组,这种语言对我来说很新。我想在位置一显示数字,而不是我得到位置 2,即 3

            #create a simple idea of an array

    .data
num1:   .word 1, 2, 3  #allows input for slot one in array

    
label1: .asciiz "Input the first number:"
label2: .asciiz "Input the second number:"
label3: .asciiz "Input the third number:"
label4: .asciiz "The number in slot 1 of the array is:"

    .text
main:
    #intiate the first label
    li $v0, 4
    la $a0, label1
    syscall
    #input first number into the array
    li $v0, 5
    syscall
    sw $v0, num1
    #initiate the second label
    li $v0,4
    la $a0, label2
    syscall
    #input second number into the array
    li $v0, 5
    syscall
    sw $v0, num1
    #initiate the third label
    li $v0, 4
    la $a0, label3
    syscall
    #input third number into the array
    li $v0, 5
    syscall
    sw $v0, num1
    #intiate the fourth label
    li $v0, 4
    la $a0, label4
    syscall
    #output position 1
    li $v0, 1
    lw $a0, num1
    syscall
    #end program
    li $v0,10
    syscall

标签: mipsspim

解决方案


推荐阅读