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

  1. 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.
  2. 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.
  3. 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

  1. ssh into klaatu. ( This document might help do that if you're not sure how.)
  2. Optionally change your password. Enter the passwd command. (To obtain information about any command, type man command-name, for example, man passwd.)
  3. Create a new directory (mkdir) named cse410 in your home directory.
  4. Display the names (ls) of the non-dot files in the current working directory, which is your home directory. You should see cse410.
  5. Display the names of all files in your home directory (ls -a). You should see additional files, including .bash_profile and .bash_rc.
  6. 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.
  7. 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.
  8. Display the contents of .bashrc and check that it was successfully edited.
  9. Issue the command source .bashrc to inform the current shell of your updates. (This is the only time you'll have to do this.)
  10. cd into cse410 and then create a directory named hw0.
  11. cd into hw0.
  12. 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.)
  13. 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
    
  14. 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.
  15. 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).
  16. 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.
  17. 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.
  18. 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.
  19. 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.)