Question: Writing A Simple Program In this part of the assignment, you will write your first MIPS assembly program. Your program will perform endianness conversion, an

 Writing A Simple Program In this part of the assignment, you

Writing A Simple Program In this part of the assignment, you will write your first MIPS assembly program. Your program will perform endianness conversion, an operation that is commonly required when sending data over a computer network. Write a MIPS assembly program to read an integer from the terminal, invert the byte order of that integer, and then print out the new big-endian integer. For example, bytes 0 and 3 are swapped, and bytes 1 and 2 are swapped. Use any of the SPIM system calls you would like, though you may not read from or write to main memory. Refer to pages A-43 to A-45 (pages B-43 to B-45 of the 4th edition) in your textbook (System calls) for an explanation of how syscall functions work in SPIM. We suggest the following algorithm, though others are also correct: Read an integer into a register using the read_int syscall. Mask out the least significant byte, and shift it into its new position in a new register. Repeat the above step for the remaining 3 bytes, using or to keep the already calculated bytes. Print out the resulting number using the print_int syscall. You only need to handle a single integer. Your program must output only the converted integer, and no other unspecified characters (such as input prompts or newline characters). If your program fails to comply, the automated marking scripts will consider your output wrong. Question 10: While this program only read and flipped a single integer, usually endianness conversions need to be done over entire blocks of memory. In this question, you are not asked to write assembly code. Consider that you have to write a subroutine that converts the endianness of several integer numbers. For example, your subroutine could receive three parameters: the address of a source memory block that contains the integers to be converted, the address of a target memory block where the converted integers should be placed, and the number of integers to be converted (source and target could be the same address if the endianness conversion is to be done in place). What control structure in assembly would you need to convert an entire block of integers, given that the number of integers to be converted will only be known at runtime

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!