Homework 3 - Computer Architecture I - ShanghaiTech University

Homework 3

Computer Architecture I ShanghaiTech University
HW2 HW3 HW4

Introduction

In this homework, you will be given two series of numbers. You need to find the longest common sub-series between the two series. Here is a simple template to begin with.

Here is a simple example:

Series 1: 0 1 2 3 4

Series 2: 2 3 4 5

The longest common sub-series should be 2 3 4, the length is 3.

The program has to use at least 2 functions where the function calls follow the standard RISC-V conventions.

Input

A reference input is already provided to you in the input.S file. Input is provided to you in binary format to alleviate the burden of parsing and dealing with Venus's expermintal file system.

.data

# Input string 1 (consisting of numbers)
# DO NOT MODIFY THIS VARIABLE
.globl str1
str1:
    .word 0 1 2 3 4

# Input string 2 (consisting of numbers)
# DO NOT MODIFY THIS VARIABLE
.globl str2
str2:
    .word 2 3 4 5

# Length of string 1
# DO NOT MODIFY THIS VARIABLE
.globl len1
len1:
    .word 5

# Length of string 2
# DO NOT MODIFY THIS VARIABLE
.globl len2
len2:
    .word 4

Output

You should output the length of the longest common sub-series. In the above example, the correct output should be 3

In the above case, no error occurs so the output would be

3

The command that we use to test your program’s correctness is

diff <your_output> <reference_output>

You can also test your result using this command. Be sure to calculate your reference_output correctly!

Running

Make sure that main.S and input.S reside in the same directory. To run your program locally

java -jar venus-jvm-latest.jar main.S

To debug your program, you might want to replace .import input.S in main.S with the content of input.S.

Tips

Execution

We will test your program using RISC-V emulator venus. You probably want to read this before you started.

Submission


Last Modified: Fri Mar 4 22:29:34 CST 2022