CSE 410 22wi Homework 0
Out: Monday, 3 January
Due: Friday, 7 January
Turnin: Nothing
Homework Goals
This homework primarily verifies that you can connect to klaatu.cs.washington.edu, use an
editor there, and that you have properly set up your account for cse410.
There is nothing to turn in. If you run into problems, though, contact the course staff.
Do not not do this assignment. We'll assume you and your account are ready
to go in the next assignment.
Prerequisites
- You should have received email with your login name and password for
klaatu.cs.washington.edu
. If you have not, send email from your UW account to cse410-staff@cs.washington.edu.
- Unless you are already familiar with Linux/bash and a text editor, at least skim
the Linux overview document so that you know what is there in case you need to look at it again
for details.
- You will need to be able to use an editor in this course. The Linux overview document will give you some leads on editors on Linux. hw0 will ask you to use one.
Steps
- ssh into klaatu. (
This document might help do that if you're not sure how.)
- Optionally change your password. Enter the passwd command. (To obtain information about any command, type man command-name, for example, man passwd.)
- Create a new directory (mkdir) named cse410 in your home directory.
- Display the names (ls) of the non-dot files in the current working directory,
which is your home directory. You should see cse410.
- Display the names of all files in your home directory (ls -a).
You should see additional
files, including .bash_profile and .bash_rc.
- Display the contents of (cat or less)
.bashrc. This is a "bash script," a file with
bash commands. It is executed each time a bash shell is started.
- Edit .bashrc so that the end of the file looks like this:
# User specific aliases and functions
export CSE410ROOT="/courses/cse410/22wi"
export PATH="$CSE410ROOT/tools-distributable/bin:/opt/riscv/bin:$PATH"
alias riscv-asm='/opt/riscv/bin/riscv64-unknown-linux-gnu-as -march=rv32i -mabi=ilp32'
alias riscv-gcc='/opt/riscv/bin/riscv64-unknown-linux-gnu-gcc -march=rv32i -mabi=ilp32 -O0'
alias riscv-objdump='/opt/riscv/bin/riscv64-unknown-linux-gnu-objdump'
Make sure to save your changes. Exit the editor.
- Display the contents of .bashrc and check that it was successfully edited.
- Issue the command source .bashrc to inform the current shell of your updates.
(This is the only time you'll have to do this.)
- cd into cse410 and then create a directory named hw0.
- cd into hw0.
- Copy the hw0 test file to the current directory:
cp /courses/cse410/22wi/hw0.asm .
(Don't overlook the dot at the end of that command.)
- The command Sim hw0.asm will run the CSE 410 RISC-V simulator on the code in file
hw0.asm. We simply want to verify that it runs.
You're not expected to understand what the code nor the output of the simulator means.
$ Sim hw0.asm
6
Cycle: 7
7 instructions executed
PC = 7
[reg:x0] 0
...
[reg:x2] 524288
[reg:x3] 0
...
[reg:x5] 6
[reg:x6] 3
[reg:x7] 0
...
[reg:x31] 0
[mem:0] 1
[mem:1] 2
[mem:2] 3
- Command Sim -h displays help information for Sim. It won't be helpful right
now, but it might be later in the course. Try it.
- Command Sim -d hw0.asm will run the RISC-V simulator and put you in a debugger.
The command ? will display
a list of commands supported by the debugger.
Commands like help run will give very short information about each command.
If you issue the command run the simulation will execute the code, printing each
instruction executed as it does so.
(Again, they won't and don't need to make sense.) You can exit the debugger by typing
ctrl-d (hold down control and type d simultaneously).
- Command Sim -t hw0.asm will run the hw0.asm code to completion, printing
a line about each instruction executed. Again, just observe this so maybe it'll come to mind
later when it might be more useful.
- Linux usage note: In some circumstances hitting the tab key will cause the system to do command or file name completion.
For instance, instead of typing Sim hw0.asm you could type S<tab> h<tab> (or even
S<tab> <tab>). The debugger in the simulator
supports tab completion as well.
- Linux usage note: To kill a runaway program (e.g., if the simulator is given an assembly program that goes into a loop,
or if the simulator itself goes into a loop), typing ctrl-C (hold down control and type c simultaneously) will most often
kill the executing program and return you to the shell.
- To log off from klaatu, type ctrl-d in the window(s) in which you ssh'ed to it.
(You can ssh into klaatu many times at once. That gives you multiple windows on klaatu.)