Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a MIPS assembly program in the MARS simulator that accepts an input string of size less than 40 characters, applies the following decompression algorithm

Write a MIPS assembly program in the MARS simulator that accepts an input string of size less than 40 characters, applies the following decompression algorithm to the string, and then prints the resulting decompressed string. In the input string, if a "#" is encountered, the next byte is interpreted as a number i between 0-255; the output string would then replace the # and its i with i-32 consecutive occurrences of the character "A" (see examples below). If i=32 , then the output string would replace the # and its i with one occurrence of "#". Similarly, "$" corresponds to multiple occurrences of the character "C"; "%" corresponds to multiple occurrences of the character "G"; "&" corresponds to multiple occurrences of the character "T". For all other encountered characters, the output string should simply reproduce that character. We will only test your code with valid inputs, i.e., strings of under 40 characters and i > 31. Keep an ASCII table handy. See the following examples:

Provide an input of less than 40 characters: 4A2#+96$(XY%"TV&&p$ d The decompressed string is: 4A2AAAAAAAAAAA96CCCCCCCCXYGGTVTTTTTTp$d Explanation: "#" is followed by "+", which is ASCII 43, so it was replaced by 11 A's. "$" is followed by "(", which is ASCII 40, so it was replaced by 8 C's. "%" is followed by double-quote, which is ASCII 34, so it was replaced by 2 G's. "&" is followed by "&", which is ASCII 38, so it was replaced by 6 T's. "$" is followed by " " (space), which is ASCII 32, so it was replaced by "$".

Provide an input of less than 40 characters: ab%%& G#)mn The decompressed string is: abGGGGG&GAAAAAAAAAmn

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_2

Step: 3

blur-text-image_3

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

Professional IPhone And IPad Database Application Programming

Authors: Patrick Alessi

1st Edition

0470636173, 978-0470636176

More Books

Students also viewed these Databases questions