Homework 3

Computer Architecture I ShanghaiTech University

Introduction

In this homework, you need to write a RISC-V program to implement a simple algorithm. You need to find the longest palindromic substring of a given string. The tempalte can be found here

Here is a simple example:

String : abbsdcds

The longest palindromic substring should be sdcds, the length is 5.

The program has to use at least 1 function call which follows 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
.globl str
str:
    .string "abbbbb"
# the answer should be 5

Task

You should write a function called LPS in func.S, which returns the length of the longest palindromic substring. Our auto-grader will call this function to get answer.

# DO NOT REMOVE THIS LINE WHEN SUBMITTING
.globl LPS
LPS:
# YOUR CODE HERE

Arguments and return values

Running

Make sure that main.S,func.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 can modify the content of input.S to change the test case.

Test

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!

Calling Convention

Make sure that you strictly follow the calling convention defined in RISC-V Green Card. We will check this in EVERY test case.

Execution

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

Tips

Submission


Last Modified: 2023/3/2