**Computer Organizxation and Architecture (Stallings 10th edition) Write an MIPS
ID: 3705139 • Letter: #
Question
**Computer Organizxation and Architecture (Stallings 10th edition)
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
ScreenShot
-------------------------------------------------------------------------------------------------------------------------------
Program
#variable declaration
.data
Welcome: .asciiz "Hello World!"
integer: .asciiz " Enter an integer:"
integerDisplay: .asciiz "The integer you entered is:"
float: .asciiz " Enter a float number:"
floatDisplay: .asciiz "The float number you entered is:"
character: .asciiz " Enter a character:"
characterDisplay: .asciiz " The character you entered is:"
string: .asciiz " Enter a string:"
stringDisplay: .asciiz "The string you entered is:"
bye: .asciiz "Good bye!"
#main program
.text
.globl main
main:
#display hello world
la $a0,Welcome
li $v0,4
syscall
#Prompt user to enter an integer
la $a0,integer
li $v0,4
syscall
#read the user entered integer
li $v0,5
syscall
#move integer into t0
move $t0,$v0
#Display the integer
la $a0,integerDisplay
li $v0,4
syscall
#move integer into a0 for display
move $a0,$t0
li $v0,1
syscall
#Prompt user to enter an float
la $a0,float
li $v0,4
syscall
#read the user entered float value in f0
li $v0,6
syscall
#Display the integer
la $a0,floatDisplay
li $v0,4
syscall
#move float into f12 for display
mov.d $f12,$f0
li $v0,2
syscall
#Prompt user to enter a character
la $a0,character
li $v0,4
syscall
#read the user entered character
li $v0,12
syscall
#move charcter into t0
move $t0,$v0
#Display the character prompt
la $a0,characterDisplay
li $v0,4
syscall
#move character into a0 for display
move $a0,$t0
li $v0,11
syscall
#Prompt user to enter a string
la $a0,string
li $v0,4
syscall
#read the user entered string
li $a1,15
li $v0,8
syscall
#move charcter into t0
move $t0,$a0
#Display the string prompt
la $a0,stringDisplay
li $v0,4
syscall
#move string address into a0 for display
move $a0,$t0
li $v0,4
syscall
#Good bye message
la $a0,bye
li $v0,4
syscall
#Exit the program
li $v0,10
syscall
.end
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.