Question: Using MArs 4 . 5 and please show the full code and output. Heres the file # File: utils.asm # Purpose: To define utilities which
Using MArs and please show the full code and output.
Heres the file
# File: utils.asm
# Purpose: To define utilities which will be used in MIPS programs.
# Author: Charles Kann
#
# Title to and ownership of all intellectual property rights
# in this file are the exclusive property of Charles W Kann.
#
# Subprograms Index:
# Exit Call syscall with a server to exit the program
# PrintNewLine Print a new line character
to the console
# PrintInt Print a string with an integer to the console
# PrintString Print a string to the console
# PromptInt Prompt for an int & return it to the calling program.
#
# Modification History
# Initial release
# Subprogram: Exit
# Author: Charles Kann
# Purpose: to use syscall service to exit a program
# InputOutput: None
# Side effects: The program is exited
text
Exit:
li $v
syscall
# Subprogram: PrintNewLine
# Author: Charles Kann
# Purpose: to output a new line to the user console
# InputOutput: None
# Side effects: A new line character is printed to the user's console
text
PrintNewLine:
li $v
la $aPNLnewline
syscall
jr $ra
data
PNLnewline: asciiz
# Subprogram: PrintInt
# Author: Charles W Kann
# Purpose: To print a string to the console
# Input: $a The address of the string to print.
# $a The value of the int to print
# Output: None
# Side effects: The String is printed followed by the integer value.
text
PrintInt:
# Print string. The string address is already in $a
li $v
syscall
# Print integer. The integer value is in $a and must
# be first moved to $a
move $a $a
li $v
syscall
#Return
jr $ra
# Subprogram: PrintString
# Author: Charles W Kann
# Purpose: To print a string to the console
# Input: $a The address of the string to print.
# Output: None
# Side effects: The String is printed to the console.
text
PrintString:
addi $v $zero,
syscall
jr $ra
# Subprogram: PromptInt
# Author: Charles W Kann
# Purpose: To prompt the user for an integer input, and
# to return that input value to the caller.
# Input: $a The address of the string to print.
# Output: $v The value the user entered
# Side effects: The String is printed followed by the integer value.
text
PromptInt:
# Print the prompt, which is already in $a
li $v
syscall
# Read the integer. Note: at the end of the syscall the value is
# already in $v so there is no need to move it anywhere.
li $v
syscall
#Return
jr $ra
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
