Answered step by step
Verified Expert Solution
Link Copied!

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 15th,12:40PM ET
Description:
Assume your Howard ID as a decimal integer is X. Let N =26+(X %11) where % is the modulo
operation, and M = N 10.
You will write a MIPS program that reads a string of up to 1000 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 '0' to '9' and from 'a' to \beta and from 'A' to \Delta .\beta stands for the Mth lower case letter and \Delta stands for the M-th upper case letter in the English alphabet,
where M is as defined at the beginning of the description. Consider each such character
as a base-N digit and calculate the sum. The sum is "-" if there are no such characters.
In a base-N number, both 'a' and 'A' correspond to the decimal integer of 10, both 'b'
and 'B' to 11, and so on, and both \beta and \Delta correspond to N 1.
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, "2/3/4".
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
process_whole_string. The main program must call process_whole_string and pass the string
address into it via the register $a0. The subprogram parses the string and prints the output
as described above. No return value is necessary from the subprogram.
When processing each substring, process_whole_string must call another subprogram
labelled as process_substring, where the substring address is passed into process_substring
via the stack, and the sum of the substring isreturned to Subprogram A via the register $v0.
Sample test cases (assuming the Howard ID is 12345678):
12345678%11=4, therefore the base is 26+4=30,\beta is 't' and \Delta is 'T'.
Input: C
Output: 12
Input: 0/1/2/A/b/T/t/Z/?
Output: 0/1/2/10/11/29/29/-/-
Input: a0/123/0Ab9
Output: 10/6/30
Input: 10/ xyz!/2.3.4/ @!A t$ //
Output: 1/-/9/39/-/- this is what i have so far #program howard id
.data
prompt: .asciiz "Enter your howard ID: "
prompt2: .asciiz "Enter characters(serperate the substring with '/'): "
Char: .asciiz "Enter character code: "
Capalp: .asciiz "abcdefghijklmnopqrstuvwxyz"
Low: .asciiz "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
.text
main:
# Prompt for user to enter Howard ID
li $v0,4 # syscall code for print_str
la $a0, prompt # load address of the prompt string
syscall
# Read an integer from the user and store the value
li $v0,5 # syscall code for read_int
syscall
move $s0, $v0
li $t0,11 # load divisor (11)
div $s0, $t0 # divide Howard ID by 11
mfhi $s1 # get the remainder (modulo) and store in $s1
# Add 26 to the remainder
li $t2,26
add $s1, $s1, $t2
li $t3,10
sub $s1, $s1, $t3
# Print the character at index 19
li $v0,11 # system call code for printing a character
la $t2, Capalp
li $t4,1
sub $s1, $s1, $t4 # load the address of the string
add $t2, $t2, $s1 # move to the character at index 19
lb $t2,($t2) # load the character
syscall
# Print the ASCII value of 't'
li $v0,1 # syscall code for print_int
move $a0, $t2 # load the ASCII value of 't'
syscall
li $v0,4 # syscall code for print_str
la $a0, prompt2 # load address of the prompt string
syscall
# Read an integer from the user and store the value
li $v0,5 # syscall code for read_int
syscall
move $s0, $v0
li $s1,'/' # delimiter
addi $sp, $sp,-4
loop:
lb $t0,0($s0)
beq $t0, $0, exit
beq $t0, $s1, print
addi $s0, $s0,1
j loop
li $v0,10 # syscall code for exit
syscall
# 20= t +26= 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 a's ascii code to and add 10 to get true value
#add every number in the substring and return the value
# (0/2/t/u) $sp
# 0< T +1(hex)
# print the hex
# u< t+1(hex)
# print -

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

7th edition

978-1111825911, 1111825912, 978-1133684374, 1133684378, 978-111182591

More Books

Students also viewed these Databases questions