Mid Semester Test November PDF

Title Mid Semester Test November
Author Polar VX
Course Introduction To Computer Science
Institution Monash University
Pages 5
File Size 147.7 KB
File Type PDF
Total Downloads 504
Total Views 604

Summary

Mid Semester Test NovemberInstructionsGeneral The MST is on ed only. For each (sub-)question or part you are required to submit your answer. Once you have submitted an answer, it can be changed and submitted again. This test lasts 50 minutes and is open book. However, it has been designed to only le...


Description

Mid Semester Test November Instructions General 1. The MST is on ed only. For each (sub-)question or part you are required to submit your answer. Once you have submitted an answer, it can be changed and submitted again. 2. This test lasts 50 minutes and is open book. However, it has been designed to only leave ~5-10 minutes of slack time, so don't spend too much time looking information up. Consider skipping questions instead.

MIPS questions 1. All translations must be faithful, unless speci�ed otherwise. 2. The only instructions and directives allowed are in the MIPS reference sheet

MIPS Decision Making Translate the following MIPS code (mips.asm) to commented Python code (python.py). TEXT

1 2 i: 3 nl: 4 5 6 label: 7 8 9 10 11 12 13 14

.word .asciiz

10 "\n"

.text lw $t0, i addi $t1, $0, 2 slt $t0, $t1, $t0 beq $t0, $0, label2 lw $t0, i sra $t0, $t0, 1 sw $t0, i

MIPS Architecture and Arrays There are two questions on this page. No explanation, no marks.

Question 1

At the end of the fetch-execute cycle, we add 4 to the PC. Explain why this is the case.

Question 2

Given a faithful translation of the following code. Identify any errors in the translation. You can assume the array_list has been initialised and the variable i contains a valid index. Ensure you identify and explain each error and the line number it occurs in. Provide a correct de�nition of the translation. array_list[i] = 4

TEXT

1 2 3 4 5 6

addi $t0, $t0, 4 lw $t1, array_list lw $t2, i sla $t2, $t2, 4 add $t0, $t1, $t2 sw $t0, 4($t1)

MIPS Functions and Local variables Consider the following Python code Run

PYTHON

1 def addition(num1: int, num2: int) -> int: 2 return num1 + num2 3 4 print(addition(1, 2)) Faithfully translate all the above code into a properly commented MIPS program using the �le provided (addition.asm).

Mystery Function Consider the following Python code to answer the following questions.

Question

What does the above function do? What is the best and worst case time complexity? No explanation, no marks....


Similar Free PDFs