CS计算机代考程序代写 mips assembly UCCD1133 INTRODUCTION TO COMPUTER ORGANISATION AND ARCHITECTURE

UCCD1133 INTRODUCTION TO COMPUTER ORGANISATION AND ARCHITECTURE
Name : Student ID : Programme (CS/CN/IA) :
Assignment 2 (21%)
This is an individual assignment. Answer all THREE (3) questions in this document. Please submit your assignment through WBLE by 16 August 2021 (Monday) before 11.59pm. Please save your assignment as PDF with the name Assignment 2 [Prog]_[YourID].pdf.
Questions
You are advised to load the MIPS assembly program problem1.asm into your simulator to answer the following questions.
# The program
.text
lw $s0, value move $t1,$s0
sll $s0, $s0, 2 add $s0, $s0, $t1 sw $s0, result
a. Using the Single Step operation, execute each instruction one by one, and record the state of the processor with respect to each instruction.
o o
Prior to executing each instruction, write down the value of the pc (program counter) for the instruction about to be executed in Table 1.
After executing each instruction, write down the registers $s0 and $t1 for the instruction just executed in Table 1.
value of
Instruction
lw $s0, value
move $t1, $s0
sll $s0, $s0, 2
add $s0, $s0, $t1
sw $s0, result
pc $s0 $t1
(3 points)
Table 1

b. Write the mathematical equation of the arithmetic operation for this program performs upon the initial value $s0 (For example, $s0 = $s0 + 2).
Ans:
c. If we want to change the arithmetic operation to $s0 = ($s0 x 8) – ($s0 + 2),
(2 points)
write your new assembly programme in the table below by modifying the code in problem1.asm.
Ans:
Question 2
The following is a snippet of the assembly program problem2.asm.
(3 points)
li $t0, 10
li $t4, 0
lw $s3, N
Loop:
beq $s3, $t4, Exit
addi $t0, $t0, 4
addi $s3, $s3, -1
j Loop
Exit:
sw $t0, f_N
# ‘N’ is a variable stored in memory
# ‘f_N’ is the result
a. How many times will the loop iterate if
i. N is 3? (i.e. how many times will the body of the loop — the
two addi instructions and the j instruction — be executed if N is 3?)?
ii. N is 6?
Ans:
i. ii.

(1 point) b. This program implements a mathematical function, f(N), that creates a number series.
Write the mathematical function f(N) in terms of any value of N. Ans:
Question 3
(2 points)
The assembly program problem3.asm execute an arithmetic operation of unknown equation. There are two user input values, M and N, whereby M and N are positive integer fall within a certain range.
a. State the valid range of M and N. Then, explain in detail how the program tests the validity of the input.
Ans:
b. Determine the equation of the assembly program. Ans:
(4 points)
(6 points)