Write an MIPS assembly program to do the following. You are required to provide
ID: 3706779 • Letter: W
Question
Write an MIPS assembly program to do the following. You are required to provide the source code, as well as the screenshots of the running of the programming in QtSpim.
a. Display “Hello World!”
b. Prompt the user to enter an integer.
c. Display “The integer you entered is: (the integer the user entered in step b.)”
d. Prompt the user to enter a float number.
e. Display “The float number you entered is: (the float number the user entered in step d.)”
f. Prompt the user to enter a character.
g. Display “The character you entered is: (the character the user entered in step f.)”
h. Prompt the user to enter a string
i. Display “The string you entered is: (the string the user entered in step h.)”
j. Display “Good bye!”
k. Exit the program
Explanation / Answer
Given below is the code for the question.
Please do rate the answer if it was helpful. Thank you
.data
hello: .asciiz "Hello World "
intPrompt: .asciiz "Enter an integer: "
intDisp: .asciiz "The integer you entered is: "
floatPrompt: .asciiz " Enter a float number: "
floatDisp: .asciiz "The float number you entered is: "
charPrompt: .asciiz " Enter a char: "
charDisp: .asciiz " The character you entered is: "
strPrompt: .asciiz " Enter a string: "
strDisp: .asciiz "The string you entered is: "
str: .space 50
.text
#display hello world msg
li $v0, 4
la $a0, hello
syscall
#------------------------------------
#prompt and read int
li $v0, 4
la $a0, intPrompt
syscall
#read int and store in $t0
li $v0, 5
syscall
move $t0, $v0
li $v0, 4
la $a0, intDisp
syscall
#print the int from $t0
li $v0, 1
move $a0, $t0
syscall
#------------------------------------
#prompt and read float
li $v0, 4
la $a0, floatPrompt
syscall
#read float and store in $2
li $v0, 6
syscall
mov.s $f2, $f0
li $v0, 4
la $a0, floatDisp
syscall
li $v0, 2
mov.s $f12, $f2
syscall
#------------------------------------
#prompt and char
li $v0, 4
la $a0, charPrompt
syscall
#read char and save in $t1
li $v0, 12
move $t1, $v0
syscall
li $v0, 4
la $a0, charDisp
syscall
#print the char from $t1
li $v0, 11
move $a0, $t1
syscall
#------------------------------------
#prompt and read string
li $v0, 4
la $a0, strPrompt
syscall
#read string
li $v0, 8
la $a0, str
li $a1, 50
syscall
li $v0, 4
la $a0, strDisp
syscall
#print a string
li $v0, 4
la $a0, str
syscall
#------------------------------------
#exit
li $v0, 10
syscall
output
---------
Hello World
Enter an integer: 5
The integer you entered is: 5
Enter a float number: 2.5
The float number you entered is: 2.5
Enter a char: p
The character you entered is:
Enter a string: hi there
The string you entered is: hi there
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.