我正在编写一个 MIPS 程序,其中用户输入他们的名字,然后是姓氏,然后系统打印出他们的全名。
我将这两个名称存储在单独的寄存器中,但在打印全名之前,我需要将它们合并为一个。
任何帮助,将不胜感激。代码如下:
.data
first:.asciiz "Please enter your first name: \n"
last:.asciiz "Please enter your last name: \n"
full:.asciiz "Your full name is: "
.text
main:
# First Name
li $v0, 4 # 4 prints a line
la $a0, first # Print first name text
syscall # Syscall
add $a1, $a1, 254 # Setting String length
li $v0, 8 # 8 will read string
syscall # calls the word
sw $v0, first
move $v0, $t1 # The name is now in $t1
# Last Name
li $v0, 4 # 4 prints a line
la $a0, last # Print last name text
syscall # Syscall
li $v0, 8 # 8 will read string
syscall # calls the word
sw $v0, last
move $v0, $t2 # The name is now in $t2
# Full Name
li $v0, 4 # 4 prints a line
la $a0, full # Print full name text
syscall
# Combine first and last name below