我需要将我的名字“ John Doe”显示为“ Doe John”,但是我遇到了一些麻烦。 系统将以正确的顺序显示我的名字,但是当我提示它以相反的顺序显示时,输出在“ reversed is”之后留一个空白。
.data
promptname: .asciiz "Please enter your name (FIRST LAST) "
yourname: .asciiz "Your name is: "
reverse: .asciiz "reversed is, "
fname: .space 8 //for first name
lname: .space 8 //for last name
.text
#system will prompt user to enter their name
li $v0, 4
la $a0, promptname
syscall
#system will now take in user input
li $v0, 8
la $a0, fname #for first name
la $a0, lname #for last name
li $a1, 16
syscall
#system will confirm you entered your name
li $v0, 4
la $a0, yourname
syscall
#call to addresses that contain user input
la $a0, fname
la $a0, lname
syscall
#print name in reverse order
li $v0, 4
la $a0, reverse
syscall
la $a0, lname
la $a0, fname
syscall
#End of main
li $v0 10
syscall
输出 请输入您的名字(姓氏在先) 用户输入:John Doe 你叫约翰·多伊 相反的是,空白 -程序完成-