Недавно я делал домашнюю работу и пытался напечатать переменную и строку в одной строке. Я хочу спросить, как напечатать их в одной строке в MIPS?
Мой текущий результат:
Please enter your nickname: Harry
Please enter your surname: Chan
Harry
Chan
How old are you? 20
You are 20
years old.
Что я хочу:
Please enter your nickname: Harry
Please enter your surname: Chan
Harry
Chan
How old are you? 20
You are 20 years old.
MIPS код :
.data
question1: .asciiz "Please enter your nickname: "
question2: .asciiz "Please enter your surname: "
question3: .asciiz "How old are you? "
buffer1: .space 60
buffer2: .space 60
buffer3: .space 60
str1: .asciiz "You are "
str2: .asciiz " years old."
#-----Text Segment-----------------
.text
.globl __start
__start:
# ----------------------
# Write your code here
li $v0, 4
la $a0, question1
syscall
li $v0,8 #take in input
la $a0, buffer1 #load byte space into address
li $a1, 60 # allot the byte space for string
move $t0,$a0 #save string to t0
syscall
li $v0, 4
la $a0, question2
syscall
li $v0,8 #take in input
la $a0, buffer2 #load byte space into address
li $a1, 60 # allot the byte space for string
move $t1,$a0 #save string to t1
syscall
la $a0, buffer1 #reload byte space to primary address
move $a0,$t0 # primary address = t0 address (load pointer)
li $v0,4 # print string
syscall
la $a0, buffer2 #reload byte space to primary address
move $a0,$t1 # primary address = t1 address (load pointer)
li $v0,4 # print string
syscall
li $v0, 4
la $a0, question3
syscall
li $v0,8 #take in input
la $a0, buffer2 #load byte space into address
li $a1, 60 # allot the byte space for string
move $t2,$a0 #save string to t2
syscall
li $v0, 4
la $a0, str1
syscall
la $a0, buffer1 #reload byte space to primary address
move $a0,$t2 # primary address = t2 address (load pointer)
li $v0,4 # print string
syscall
li $v0, 4
la $a0, str2
syscall
# ----------------------
# Terminate the program
li $v0, 10
syscall