Question: PLEASE USE MIPS (MARS) TO WRITE AND COMPILE PROGRAM. ~~~ Calculate Checksums ~~~ Take strings as input and calculate + print a simple checksum for

PLEASE USE MIPS (MARS) TO WRITE AND COMPILE PROGRAM.

~~~ Calculate Checksums ~~~

Take strings as input and calculate + print a simple checksum for each string.

Make the string long enough to hold 50 characters.

Also, leave space for the null byte.

If the checksum is transmitted/stored with the block of data, then it can be compared with a recalculated checksum to determine whether an error has occurred.

The checksum algorithm will produce a value which can print with the syscall for printing a character.

Stop reading strings when the user enters ".".

The syscall to read a string (syscall code 8) adds a newline to the string (before the null byte) if the string is shorter than the maximum length specified.

If there is a newline in the string that read and replace it with a null byte. Do not use the newline when calculating the checksum.

To calculate our checksum, add up the ASCII codes for the characters in the string, then find the remainder after dividing by 64.

Finally, add the ASCII code for blank to the remainder. This gives the checksum.

Hints

*Use the lbu instruction to load one character of the string into a register. The lbu instruction loads one byte into the low order byte of the register and sets all the other bits to 0.

*Remember that what is stored in memory for a character is the ASCII code for that character.

*The ASCII codes for blank, newline (also called line feed), and dot/period are helpful. The null byte is 0x0.

*Write comments like "add char to checksum" not comments like "$f7 = $f7 + $f4".

*Please include comments to understand what the program is executing

Sample Output

Enter a string (. to end): Error Correction! The checksum is: C Enter a string (. to end): Java C C++ The checksum is: > Enter a string (. to end): UNIX Linux The checksum is: T Enter a string (. to end): macOS 10.12.2 The checksum is: % Enter a string (. to end): .

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!