UNIVERSITY OF CALIFORNIA, DAVIS Department of Electrical and Computer Engineering
EEC 170 Introduction to Computer Architecture Winter 2021
Project 1
Due: 11:59 pm Tuesday 2 February.
Write functions in RISC-V assembly for the following problems and simulate in RARS:
Refer Getting started with RARS for tips/suggestions. You can find the recorded lab tutorial at here.
RARS simulator has separate 32bit instructions and separate 64bit instructions depending on what you are doing. This assignment is to be done with 32bit instructions. You can find on RARS wiki page the separate set of instructions. (link)
Given a year find if it is a leap year or not
Your program should expect register x10 to hold the year (signed 32-bit integer). Your program should compute whether the year is a leap year or not. If it is a leap year store the value 1 in the x10 register. If the year is not a leap year store the value 0 in the x10 register. If the input is not a positive integer, your program should return the value 1 in register x10.
Calculating Greatest Common Divisor
Calculate the Greatest Common Divisor of two 32 bit unsigned integers. Your program should expect registers x10 and x11 to hold the first and second input respectively. Your program should compute the result and store it in register x10. If either of the two inputs is zero, your program should return the value 1 in register x10.
Finding the Nth prime number
Given an unsigned 32-bit number N, the task is to find the Nth prime number. Your program should expect register x10 to hold the number N. After finding the Nth prime number, return its value back in x10. If the input N is zero, your program should return the value -1 in register x10.
Finding palindrome number
Your program should expect register x10 to hold the input number. If the number is a palindrome, store the value 1 in the x10 register, and if
not store the value 0 in the x10 register. If the input is zero, your program should return the value 1 in register x10.
Given an unsigned 32-bit number, write a function that returns 1 if the given number is a
palindrome when expressed as a hexadecimal number, else 0 if it is not. For example, 0x12321
is a palindrome, but 0x1451 is not a palindrome.
Project Submission format
Make sure to update your stack pointer in all your function files as done so in the average example. Your program should be able to run from the main.asm (without any modification to main.asm, you can try different inputs) and all your functions should be in separate files and named as below.
Assembly files for each of the above problems should be named as below.
Problem 1 as lpyear.asm Problem 2 as gcd.asm Problem 3 as npnum.asm Problem 4 as palin.asm
All four assembly files must be stored in a folder, compressed, and submitted through canvas.
Reviews
There are no reviews yet.