a3 (1)

.pdf

School

University of Regina *

*We aren’t endorsed by this school

Course

201

Subject

Computer Science

Date

Jan 9, 2024

Type

pdf

Pages

1

Uploaded by DrBook9814

Report
CS 201-001 Assignment 3 Question 1. Write the machine code corresponding to the following MIPS assembly code in binary: (a). add $ t4, $ s2, $ t8 (b). addi $ s4, $ zero, 19 (c). jr $ s2 Question 2. Find the corresponding MIPS instruction to the following machine code. You are given that any immediate value is represented using 2’s complement. (a). 0011010101010111 1111111111111111 (b). 0001001000010001 0000000000000011, where: PC = 0x0000 0078, and there are three labels in the program that have address as follows: label1 = 0x0000 0084, label2 = 0x0000 0088, and label3 = 0x0000 008C Question 3. Translate the following code to MIPS. if $ s0 > 0 then $ s0 = $ s0 - 1 else $ s0 = $ s0 + 1 Question 4. There is a value stored in $ s0. Write a sequence of MIPS instructions that will place the absolute value of $ s0 into $ t0. Question 5. You are given a memory data segment labeled “cs201”. Write an assembly language program to find the sum of the first 100 words data in the memory data segment labeled cs201. Store the resulting sum in $ s0. Question 6. Write a function fact(n) to compute and return the factorial of n. The function must use recursion. The value of n is passed in $ a0 and the factorial is returned in $ v0. Don’t forget to save and restore any register that you might need before using it. 1
Discover more documents: Sign up today!
Unlock a world of knowledge! Explore tailored content for a richer learning experience. Here's what you'll get:
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help