Question: MIPS ASSEMBLY PROGRAM: Write in MIPS Assembly language Take strings as input and calculate and print a simple checksum for each string. Make your string
MIPS ASSEMBLY PROGRAM:
Write in MIPS Assembly language
Take strings as input and calculate and print a simple checksum for each string. Make your string long enough to hold 50 characters. Don't forget to leave space for the null byte. Our checksum algorithm will produce a value which you can print with the syscall for printing a character. Stop reading strings when the user enters ".".
The syscall to read a string (sycall 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 you read, 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 give you 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.
- Look up the ASCII codes for blank, newline (also called line feed), and dot/period. The null byte is 0x0.
- Remember your comments should reflect the purpose of the statements. Write comments like "add char to checksum" not comments like "$f7 = $f7 + $f4".
- Don't be stubborn and wait to put in your comments till the end. And remember it's very important to comment your register usage.
Sample Execution
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
Get step-by-step solutions from verified subject matter experts
