mips - 我如何让这个程序显示而不是三个?
问题描述
我在 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
解决方案
推荐阅读
- php - 查询中的数组仅返回第一个值的结果
- c++ - cpp.sh 打开示例文件
- python - 选择 Conv2D 过滤器值开始
- bash - 获取特定星期的星期几;重击;Linux
- python - Pyspark SQL Pandas UDF:返回一个数组
- node.js - npm 错误!找不到模块“编码”
- go - Memcached Kubernetes 客户端 Golang
- arrays - 从 2 张纸填充一维数组(不循环)
- python - Deep get item from json with default value in python
- webpack - 在不重建的情况下更改 webpack 中的 PublicPath