I need help with a MARS MIPS assignment. I need help prompting a user to input t
ID: 3822612 • Letter: I
Question
I need help with a MARS MIPS assignment. I need help prompting a user to input two strings (16 characters) and one integer (0-15) and then displaying what they just inputed using macros. This is what i have so far
.macro printString(%string)
la $a0, %string
li $v0, 4
syscall
.end_macro
.macro readInput
li $a1, 17
li $v0, 8
syscall
.end_macro
.macro printInteger
la $a0, thirdPrompt
li $v0, 4
syscall
.end_macro
.macro readInteger
li $v0, 5
syscall
.end_macro
.data
prompt: .asciiz "string 1"
secondPrompt: .asciiz "string 2"
thirdPrompt: .asciiz "integer"
input: .asciiz "you entered "
newLine: .asciiz " "
.text
############################ Get User's input ###############################
getInput:
printString(prompt)
readInput
printString(newLine)
printString(secondPrompt)
readInput
printString(newLine)
printString(thirdPrompt)
readInteger
printString(newLine)
########################## Printout User's input ############################
printInput:
printString(input)
Explanation / Answer
Hi,
I have edited the code and also given the program output below.
EDITED CODE
=================================================================================
macro printString(%string)
li $v0, 4
la $a0, string
syscall
.end_macro
.macro readInput
li $v0, 5
la $a1, inputstring
syscall
.end_macro
.macro readInputs
li $v0, 5
la $a1, inputstrings
syscall
.end_macro
.macro readInteger
li $v0, 5
la $a1, inputinteger
syscall
.end_macro
.macro printInteger(%inputinteger)
li $v0, 1
la $a0, inputinteger
syscall
.end_macro
.data
prompt: .asciiz "Enter the string 1:"
secondPrompt: .asciiz "Enter the string 2:"
thirdPrompt: .asciiz "Enter the integer:"
inputstring: .asciiz "The string1 entered is:"
inputstrings: .asciiz "The string2 entered is:"
inputinteger: .asciiz "The entered integer is :"
newLine: .asciiz " "
.text
################# Get User's input ########################
getInput:
printString(prompt)
readInput
printString(newLine)
printString(secondPrompt)
readInputs
printString(newLine)
printString(thirdPrompt)
readInteger
printString(newLine)
########### Printout User's input ############################
printInput:
printString(inpustring)
printString(newLine)
printString(inpustrings)
printString(newLine)
printInteger(inputinteger)
printString(newLine)
=========================================================================================
OUTPUT:-
Enter the string 1: abcdefg
Enter the string 2:hijklmn
Enter the integer: 12
The string1 entered is: abcdefg
The string2 entered is: hijklmn
The entered integer is: 12
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.