Get Instant Help From 5000+ Experts For
question

Writing: Get your essay and assignment written from scratch by PhD expert

Rewriting: Paraphrase or rewrite your friend's essay with similar meaning at reduced cost

Editing:Proofread your work by experts and improve grade at Lowest cost

And Improve Your Grades
myassignmenthelp.com
loader
Phone no. Missing!

Enter phone no. to receive critical updates and urgent messages !

Attach file

Error goes here

Files Missing!

Please upload all relevant files for quick & complete assistance.

Guaranteed Higher Grade!
Free Quote
wave
MIPS Assembler Exam: Tracing, Modifying and Shifting

Instructions for Submission

I Late submissions will incur penalty. No other means of submission (like email attachments) is acceptable. Allow enough time for submission as servers may be busy right at the deadline. You can only submit once: so be careful to submit the correct document to the correct link.

I You can refer to any textbooks, notes and online materials, but you must cite your sources, irrespective of their nature, except if you are using the lecture slides, course-notes, or the lab manuals of the module.

I You MUST complete the exam individually on your own, without consulting others. No collaboration is permitted. There is zero-tolerance policy on plagiarism.

I You must type your answers, then create a single PDF file. For this submission, no handwritten answers are accepted except with prior permission and with strong justification.

I In your submission, start answering each of the 3 questions on a new page (but continuing the parts of the same question on the same page is fine).

I In your submission, you MUST NOT repeat the statement of the question. Just clearly state the question number (e.g. Q1-a-i) and then only write down your answer. Similarly, you MUST NOT include this cover page in your answer file. Including the question statements or the cover page can lead to a high Turnitin similarity score.

I Try to write down your answers sequentially and well-marked, even if you wish to leave a question blank. Otherwise, you risk losing marks (e.g. if the grader cannot associate an answer to its question).

Question 1

A programme in 32-bit MIPS Assembler is shown in the following:

(a) Suppose when prompted at the console, we input numbers 27 and 4 . Provide the trace of the values in registers $t0, $t1 and $t3 (as a triple) when this code is executed until it Turn over finishes. That is, write down the values in all three of $t0, $t1 and $t3 each time any one of them changes as you step through the programme until the programme finishes execution. You can choose to present the values either in decimal, hex, or binary, as long as you clearly specify which. Your answer should have a correct sequence of changes. Suppose that initially, the value in these registers is unknown to us (which you can show by a question mark ?). Provide a very brief explanation along with your trace table.

(b) Explain what happens if one of the integers (or both of them) entered by the user is negative.

Question 1

(c) A close investigation of this code should reveal that this programme takes two positive integers from the user and computes the quotient (i.e., the integer part of division). Modify the programme such that both quotient and the remainder are printed.

Question 2

MIPS, memory access and Arrays

In all of the questions of this part, you are still only allowed to use beq or bne for branching, and slt for comparison. Also, try to reuse the given code as much as possible. In particular, try to keep the name of the variables and labels the same. For instance, use register $s0 to hold the value of the requested quantity.

(b) Modify the code so that it prints the maximum absolute value among the elements (the largest element in terms of just magnitude without considering sign). For instance, it should return 16.

(c) (i) Suppose there is an integer in register $t1. In one sentence, describe (along with a brief explanation) how the result of the following instruction can be used to determine whether the number is divisible by 8 or not.

Incidentally, this is a simple example of a technique called “masking”.

(ii) Now, using this observation, modify the code in part (a), to print how many of the numbers in the array are divisible by 8. So in our example, for instance, it should print 2, since both -16 and 0 are perfect multiples of 8.

Question 3

Simple arithmetic with bit shifting

(a) sll (shift left logical) is a MIPS instruction with the following description: syntax : sll $rd, $rt, h operation : Shifts the value in register rt left by the shift amount h (zeroes are shifted in for the new h rightmost bits) and places the result in register rd.

Suppose that $rt is a register that contains an integer (for the purposes of this question, you can take this to be unsigned, but it could also be signed). Describe the relation of the integer in $rd with respect to the integer $rt (in terms of h) after execution of instruction sll $rd, $rt, h. Support your answer with a brief explanation.

(b) Provide the 32-bit machine code of the instruction sll $t0, $t1, 2. Make sure to deconstruct and specify each component.

(c) The following examples show how to compute multiplications with some (small) constants using shifts and additions. Provide a short sequence of MIPS instructions that will implement the multiplication operation given. Note that you are allowed to use the add, sub and sll instructions, however, you must at most use as many instructions as requested (and of course, you are not allowed to use any “multiply” instructions.)

support
Whatsapp
callback
sales
sales chat
Whatsapp
callback
sales chat
close