Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Due February 1 5 th , 1 2 : 4 0 PM ET Description: Assume your Howard ID as a decimal integer is X .
Due February th:PM ET
Description:
Assume your Howard ID as a decimal integer is X Let N X where is the modulo
operation, and M N
You will write a MIPS program that reads a string of up to characters excluding the trailing
carriage return and null character from user input.
With single slash as the delimiter, split the input string into multiple substrings with the
slash removed If there is no slash in the input, the whole input string is considered a
substring referred to below.
For each substring,
o Pick the characters from to and from a to beta and from A to Delta beta stands for the Mth lower case letter and Delta stands for the Mth upper case letter in the English alphabet,
where M is as defined at the beginning of the description. Consider each such character
as a baseN digit and calculate the sum. The sum is if there are no such characters.
In a baseN number, both a and A correspond to the decimal integer of both b
and B to and so on and both beta and Delta correspond to N
o Output the calculated sum.
If there are multiple substrings, the output for the substrings should be separated by two
spaces with a single slash in between, for example,
The program must exit after processing one single user input.
The processing of the whole input string must be done in a subprogram labelled as
processwholestring. The main program must call processwholestring and pass the string
address into it via the register $a The subprogram parses the string and prints the output
as described above. No return value is necessary from the subprogram.
When processing each substring, processwholestring must call another subprogram
labelled as processsubstring, where the substring address is passed into processsubstring
via the stack, and the sum of the substring isreturned to Subprogram A via the register $v
Sample test cases assuming the Howard ID is :
therefore the base is beta is t and Delta is T
Input: C
Output:
Input: AbTtZ
Output:
Input: aAb
Output:
Input: xyz @A t$
Output: this is what i have so far #program howard id
data
prompt: asciiz "Enter your howard ID:
prompt: asciiz "Enter charactersserperate the substring with :
Char: asciiz "Enter character code:
Capalp: asciiz "abcdefghijklmnopqrstuvwxyz"
Low: asciiz "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
text
main:
# Prompt for user to enter Howard ID
li $v # syscall code for printstr
la $a prompt # load address of the prompt string
syscall
# Read an integer from the user and store the value
li $v # syscall code for readint
syscall
move $s $v
li $t # load divisor
div $s $t # divide Howard ID by
mfhi $s # get the remainder modulo and store in $s
# Add to the remainder
li $t
add $s $s $t
li $t
sub $s $s $t
# Print the character at index
li $v # system call code for printing a character
la $t Capalp
li $t
sub $s $s $t # load the address of the string
add $t $t $s # move to the character at index
lb $t$t # load the character
syscall
# Print the ASCII value of t
li $v # syscall code for printint
move $a $t # load the ASCII value of t
syscall
li $v # syscall code for printstr
la $a prompt # load address of the prompt string
syscall
# Read an integer from the user and store the value
li $v # syscall code for readint
syscall
move $s $v
li $s # delimiter
addi $sp $sp
loop:
lb $t$s
beq $t $ exit
beq $t $s print
addi $s $s
j loop
li $v # syscall code for exit
syscall
# t T
#First check if its in the paramiders
#second if it is we want to take the ascii code
#third sub tract the ascii code by as ascii code to and add to get true value
#add every number in the substring and return the value
# tu $sp
# T hex
# print the hex
# u thex
# print
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started