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.
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
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!
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.
To interact with the input file, you can use the global labels
defined in input.S
. For example, you can get the
str1
with the following code:
, str1 la a7
Handwritten assembly are postfixed with extension .S
to distinguish from compiler generated assembly .s
While being a strong proponent for python's cult of
space
, I suggest you indent using tab
s. Set
your editor's tabwidth to 8 for best visual experience.
Learn recursive functions
Learn save and load from memory using RISC-V
It is helpful writing in C first
Write comments
The test cases are very friendly! Don't focus too much on the edge cases, focus on the correctness on the common cases.
We will test your program using RISC-V emulator venus. You probably want to read this before you started.
#
.main.S
. Any other file found will result in a score of
zero.Last Modified: Fri Mar 4 22:29:34 CST 2022