Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

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

MongoDB Applied Design Patterns Practical Use Cases With The Leading NoSQL Database

Authors: Rick Copeland

1st Edition

1449340040, 978-1449340049

More Books

Students also viewed these Databases questions

Question

What are some of the dos and donts of being an expert witness?

Answered: 1 week ago

Question

Describe factors that influence training and development.

Answered: 1 week ago

Question

Explain the concept of shear force and bending moment in beams.

Answered: 1 week ago