0% found this document useful (0 votes)
11 views4 pages

Lab 1

Uploaded by

Hoang Khoa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views4 pages

Lab 1

Uploaded by

Hoang Khoa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Ho Chi Minh City University of Technology

Faculty of Computer Science and Engineering


Course: Computer Architecture Lab (CO2008)

Lab 1
Arithmetic instructions

Ho Chi Minh City, October 2024


Ho Chi Minh City University of Technology
Faculty of Computer Science and Engineering

Contents
1 Introduction 2

2 Exercises 2
2.1 Exercise 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2.2 Exercise 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2.3 Exercise 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.4 Exercise 4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

Exercise for Computer Architecture


Page 1/3
Academic year 2024 - 2025
Ho Chi Minh City University of Technology
Faculty of Computer Science and Engineering

1 Introduction
• To download the MARS MIPS simulator, the link from developers
(https://bit.ly/3lrKYmg) can be used. In case the previous link
couldn’t be used, this Google Drive link (https://bit.ly/3zdHclD)
can be used as an alternative.

• The MARS MIPS simulator requires JDK which is downloadable from


Oracle website to execute.

• To get a simple MARS MIPS tutorial, please check out this link (https:
//bit.ly/3lxjqMn) and this link (https://bit.ly/3zl35zc).

• Please note that the register $zero can be described as $0.

• The main purpose of this week is to get familiar with arith-


metic instructions. It is required that students ONLY use
arithmetic and data instructions..

• Students must submit their answers to the BKeL system no later than
the last period of the lab section. Then, the instructor will evaluate all
students’ work during the lab section’s final period.

2 Exercises
2.1 Exercise 1
Write a MIPS program that takes in a name as a string and print out a
”Hello <name>”.
For example, if the input is John, then the output should be Hello, John.

2.2 Exercise 2
Write a MIPS program to allow the user to first input an array with 5
elements. The prompts should be: ”Please input element 0:”, ”Please input
element 1:”, etc. Then print the value from the element chosen by the user
(Assume the user only input 0 to 4). The prompt for this is: ”Please enter
index:”.
For example, an array may have elements such as 5, 10, 15, 20, 25. If
the user input 1 the output shown on the terminal should be 10. If the user
input 4, the output should be 25.

Exercise for Computer Architecture


Page 2/3
Academic year 2024 - 2025
Ho Chi Minh City University of Technology
Faculty of Computer Science and Engineering

2.3 Exercise 3
Write a MIPS program to print out the result of F:
(a + 10) × (b − d) × (c − 2 × a)
F =
a+b+c
where a, b, c, and d are integers inserted by the user. Note that a, b, c,
and d are inserted in this exact order. Moreover, ”a+b+c” is assume to not
equal to 0. The output of division should print both the quotient and the
remainder.
The input prompts should be as such: ”Insert a: ”, ”Insert b: ”, etc.
For example, if the input is 3, 4, 5, 6 then the output should be: F = 2,
remainder 2.

2.4 Exercise 4
Write a MIPS program to print out the 4-bit binary value of a decimal
number. The number should be selected by the user.
The input shall be restricted only to a positive integer that is less than 16.
The input prompt should be: ”Please enter a positive integer less than 16:
”.
For example, if the decimal number is 10 then the output should be Its
binary form is: 1010.

Exercise for Computer Architecture


Page 3/3
Academic year 2024 - 2025

You might also like