我的程序应该读取一个整数并将其打印回给用户,但每次它都只打印 268501230,无论输入什么。我该如何修复它?
.data
prompt2: .asciiz "Please enter value: "
array1: .space 40
array2: .space 40
buffer: .space 4
.text
main:
# Prints the prompt2 string
li $v0, 4
la $a0, prompt2
syscall
# Reads one integer from user and saves in t0
li $v0, 5
la $t0, buffer
syscall
li $v0, 1
li $t0, 5 # $integer to print
syscall
exitProgram: li $v0, 10 # System call to terminate
syscall # the program
这就是我将编写一个程序来获取整数输入并将其打印出来的方式
.data
text: .asciiz "Enter a number: "
.text
main:
# Printing out the text
li $v0, 4
la $a0, text
syscall
# Getting user input
li $v0, 5
syscall
# Moving the integer input to another register
move $t0, $v0
# Printing out the number
li $v0, 1
move $a0, $t0
syscall
# End Program
li $v0, 10
syscall
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)