Question: 1 ) There are many algorithms presented in the text that would lend themselves to be included as subprograms in the utils.asm file. Implement the
There are many algorithms presented in the text that would lend themselves to be included as subprograms in the utils.asm file. Implement the following into the utils.asm file, properly documenting them, and include programs to test them.
Submit two files: utils.asm and testutils.asm. You can use the utils.asm source code file provided with the assignment and add to it
a Mult take an input parameter and return that parameter multiplied by using only shifts and one add operation.
b RightCircularShift take an input parameter and return two values. The first is the value that has been shifted bit using a right circular shift, and the second is the value of the bit which has been shifted.
c LeftCircularShift take an input parameter and return two values. The first is the value that has been shifted bit using a left circular shift, and the second is the value of the bit which has been shifted.
utils.asm
# File: utils.asm # Purpose: To define utilities which will be used in MIPS programs. # Author: Charles Kann # # Instructors are granted permission to make copies of this file # for use by # students in their courses. Title to and ownership # of all intellectual property rights # in this file are the exclusive property of # Charles W Kann, Gettysburg, Pa # # Subprograms Index: # Exit Call syscall with a server to exit the program # NewLine 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 the user to enter an integer, and return # it to the calling program. # # Modification History # Initial release # subprogram: PrintNewLine # author: Charles Kann # purpose: to output a new line to the user console # input: None # output: 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 # returns: 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: PromptInt # author: Charles W Kann # purpose: To print the user for an integer input, and # to return that input value to the caller. # input: $a The address of the string to print. # returns: $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 value. Note that at the end of the # syscall the value is already in $v so there is no # need to move it anywhere. 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. # returns: None # side effects: The String is printed to the console. text PrintString: addi $v $zero, syscall jr $ra # subprogram: Exit # author: Charles Kann # purpose: to use syscall service to exit a program # input: None # output: None # side effects: The program is exited text Exit: li $v syscall
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
