Lab02 - Introduction to RISC-V Assembly Programming¶
Code due Wed Sep 3rd by 11:59pm in your Lab02 GitHub repo¶
Links¶
Tests: https://github.com/USF-CS315-F25/tests
Autograder: https://github.com/phpeterson-usf/autograder
GDB Setup for Assembly Debugging¶
On the BeagleV machines, you can a gdbinit file to get a nice UI for assembly language debugging. The file should be in ~/.config/gdb/gdbinit. If you don't have a ~/.config you will have to create it. If you don't have ~/.config/gdb you will have to create it. You can use mkdir -p to create everything at once:
$ cd
$ mkdir -p ~/.config/gdb
$ cd .config/gdb
$ cat > gdbinit
set auto-load safe-path /
set debuginfod enabled off
tui new-layout asm {-horizontal src 1 regs 1} 2 status 0 cmd 1
tui enable
layout asm
^d
^d means type CTRL-d to close the file.
See GDB Usage for links to GDB tutorials.
Given¶
You will be given a Makefile, C files, and Assembly files (.s). We will use this given structure for most of our Assembly Language programming. For example, you are given:
The add2.c file is the main program for the add2 functions. The add2_c.c file is the C implementation and the add2_s.s is the Assembly implementation. These are all linked together with the Makefile. And when we run it, we get:
That is the add2 program calls the C version and the Assembly version with the same arguments and the goal is to get the same results.
You are also given a full implementation of mul2.
Requirements¶
- You will develop RISC-V assembly language implementations of the following arithmetic problems. You will be given the C implementations, you need to write the RISC-V implementations.
- Your executable must be compiled with a Makefile
- Before you add files to your repo, do a
$ make cleanso you don't add/commit build products like executables or .o files - We will test the labs using autograder
add4: Adds four 32-bit integers together and returns the result. Example:
$ ./add4 1 2 3 4
C: 10
Asm: 10
mul4: Multiplies four 32-bit integers together and returns the result. Example:
$ ./mul 1 2 3 4
C: 24
Asm: 24
Rubric¶
- Your lab will receive the score indicated by the autograder
- To get the test cases,
git pullin the tests repo