Welcome to the Lab
CMPUT 229
University of Alberta
Winter 2021
CMPUT 229 (University of Alberta) Welcome to the Lab Winter 2021 1 / 10
Outline
1 About the Lab
2 SPIM and QTSPIM
3 Using QTSPIM
4 Using SPIM
5 Assignment Tips
6 Questions?
CMPUT 229 (University of Alberta) Welcome to the Lab Winter 2021 2 / 10
About the Lab
The Lab
Attendance is not mandatory.
TAs will use Lab time as office hours. Ask us questions if you have them!
Presentations will be pre-recorded. They will be made available according to the course schedule.
Lab Solution videos will be posted after the submission deadlines.
CMPUT 229 (University of Alberta) Welcome to the Lab Winter 2021 3 / 10
About the Lab
What Will We Be Doing?
In short: assembly language programming for the MIPS architecture. But writing assembly for real hardware is hard:
You have to interface with the operating system, or write lots of low-level code to manage the hardware yourself.
Testing and debugging requires special equipment and is difficult.
So we use a simulator: SPIM.
CMPUT 229 (University of Alberta) Welcome to the Lab Winter 2021 4 / 10
SPIM and QTSPIM
What is SPIM?
SPIM is MIPS backwards! It¡¯s a MIPS simulator.
It gives you an easy environment in which to run and debug your MIPS code.
QTSPIM is a graphical interface to SPIM.
CMPUT 229 (University of Alberta) Welcome to the Lab Winter 2021 5 / 10
SPIM and QTSPIM
What is SPIM?
SPIM is MIPS backwards! It¡¯s a MIPS simulator.
It gives you an easy environment in which to run and debug your MIPS code.
QTSPIM is a graphical interface to SPIM. Some things to remember:
SPIM uses the endianness of the host machine.
SPIM is not a cycle-accurate simulator: it doesn¡¯t accurately simulate cache, memory latency, floating-point operations, etc. You can¡¯t tell how efficient your MIPS code is by running it in SPIM.
CMPUT 229 (University of Alberta) Welcome to the Lab Winter 2021 5 / 10
SPIM and QTSPIM
Pseudo-Instructions
SPIM implements some pseudo-instructions that expand into real instructions. When you run code, you might see instructions you didn¡¯t write. For example:
What you wrote What you see in SPIM
li $t0, 10 ori $8, $0, 10 move $v0, $t0 addu $2, $0, $8
Pseudo-instructions will do what you intend, so they¡¯re nothing to worry about. Just be aware that they may expand to multiple instructions, and don¡¯t be surprised when you see them.
CMPUT 229 (University of Alberta) Welcome to the Lab Winter 2021 6 / 10
Using QTSPIM
Basic QTSPIM Usage
Run qtspim from a terminal.
Click ¡°File¡± and select ¡°Load File¡±. Choose the file to load.
Press the ¡°Clear Registers¡± button before running your program.
Press the ¡°run¡± button to run your program.
If your program needs input or prints output, QTSPIM will pop up a terminal.
CMPUT 229 (University of Alberta) Welcome to the Lab Winter 2021 7 / 10
Using SPIM
Basic SPIM Usage
Start spim in a terminal.
Type load ¡®¡®file.s¡¯¡¯ to load your program.
Type run to run your program.
If your program needs input or prints output, it will appear in the terminal.
Type exit to quit.
You can always type ? to get help!
CMPUT 229 (University of Alberta) Welcome to the Lab Winter 2021 8 / 10
Assignment Tips
Assignment Tips for CMPUT 229
Read specifications very carefully. Pay special attention to what you are to include – sometimes we don¡¯t want a main method.
Even if you don¡¯t finish an assignment, make sure you submit something that loads and runs.
Test your assignments on the lab machines before you submit. That¡¯s where we¡¯ll be marking them.
For most assignments, the marksheet will be posted in advance. Look at it to get an idea of what¡¯s important.
Style marks are easy marks. Format your code like the example.s file we provide, and write good comments.
With moodle (eClass) you can submit as many times as you like. Submit early and often (e.g. every time you get part of the assignment working). We don¡¯t accept any late submissions!
CMPUT 229 (University of Alberta) Welcome to the Lab Winter 2021 9 / 10
Questions?
Questions?
CMPUT 229 (University of Alberta) Welcome to the Lab Winter 2021 10 / 10