Lab 3: MIPS Looping ASCII Art
Due Friday 15 February 2018, 11:59 PM
Minimum Submission Requirements
Ensure that your Lab3 folder contains the following files (note the capitalization convention):
Lab3.asm
README.txt
Commit and push your repository
Lab Objective
This lab will introduce you to the MIPS ISA using MARS. You will write a program that draws triangles based on values specified by a user.
Lab Preparation
Read chapters 1 (section 1.3), 2, 3, and 7 from Introduction To MIPS Assembly Language Programming. In addition, watch videos 2-3 and 19 from this video playlist:
FuNa5A
Specification
You will write a program in the MIPS32 language using the MARS integrated development
environment to print triangles to the console.
Example Output
Enter the length of one of the triangle legs: 3 Enter the number of triangles to print: 3
/ /
/
/ /
/
/ /
/
program is finished running
Lab 3 Page 1 of 5 Winter 2019 2019, Computer Engineering Department, University of California Santa Cruz
For full credit, the output should match this format exactly. Note the exact wording of the prompts, the space after each colon, and the new line character after the prompts. For a triangle with leg size 3, see the figure below. Note that the character indicates a space. See that line 1 contains no spaces before the backslash, line two contains 1 space, line 3 contains 2, etc.
Figure: Triangle Format
Functionality
This program will prompt the user for two integers: the length of one of the legs of
a triangle and the number of triangles to print. Next, the program will print
triangles to the console based on the user input. After printing the specified number
of triangles, the program should quit. The ASCII values for the characters you will
be printing are here:
Table: ASCII Codes
You must use the following syscalls for their specified purposes as shown below:
1 2 3 4 / 5 / 6 /
CHARACTER
ASCII CODE (HEX)
ASCII CODE (DECIMAL)
0x5C
92
/
0x2F
47
(space)
0x20
32
Syscalls
SYSCALL #
FUNCTION
PURPOSE
4
Print string
Print prompts
5
Read integer
Read integer input
10
Exit
Exit your program cleanly
11
Print character
Print slashes and spaces
Table: Required Syscalls
Automation
Note that part of our grading script is automated, so it is imperative that your programs output matches the specification exactly. Output that deviates from the spec will cause point deduction.
Lab 3 Page 2 of 5 Winter 2019 2019, Computer Engineering Department, University of California Santa Cruz
Your code should end cleanly without error. Make sure to use the exit syscall (syscall 10). You may assume that the user inputs are positive integers i.e. no error handling is required.
Files
Lab3.asm
This file contains your code.
Comments
Your code should include a header comment with your name, CruzID, date, lab number,
course number, quarter, school, program description and notes. Every program you
write should include information like this. This is a good opportunity to start
developing effective code documentation skills. An example header comment is shown
below.
##########################################################################
# Created by: #
#
#
# Assignment: #
#
#
Last Name, First Name CruzID
7 August 2018
Lab 64: Hello World
CMPE 012, Computer Systems and Assembly Language UC Santa Cruz, Fall 2018
This program prints Hello world. to the screen. This program is intended to be run from the MARS IDE.
# Description: #
# Notes: ##########################################################################
Every block or section of code should have a comment describing what that block of
code is for. In-line comments should be lined up (using spaces) for ease of
readability.
Register Usage
You are permitted to use $zero, $v0, $a0 and the temporary ($t) registers for this
lab. Registers $v0 and $a0 should only be used for the syscalls. At the beginning of
your code, and optionally at the beginning of each block of code, indicate the
functionality of the registers used. For instance, if you are using $t0 and $t1 for
the user input and and loop counter, respectively, your comments should include
something like the following:
White Space
Line up instructions, operands, and comments to increase readability. Code should be
indented from labels. Notice how the instructions, operands and comments are all
lined up in columns in the good example.
Lab 3 Page 3 of 5 Winter 2019 2019, Computer Engineering Department, University of California Santa Cruz
# REGISTER USAGE
# $t0: user input # $t1: loop counter
Bad Example
Good Example
A Note About Tabs
It is preferable to line up comments using spaces as opposed to tabs. Text editors
can have different standards for the width of one tab character. For this reason, it
is preferable to line up comments using spaces, not tabs, so that the code appears
the same regardless of text editor.
README.txt
This file must be a plain text (.txt) file. For full credit, it should contain your
first and last name (as it appears on Canvas) and your CruzID. Your answers to the
questions should total at least 150 words. Your README should adhere to the following
template:
LOOP:
LI $t1 2 #initialize $t1
ADDI $t0 $t0 1 #increment $t0
BLT $t0 $t1 LOOP #determine if code should re-enter loop
LOOP:
LI $t1 2
ADDI $t0 $t0 1 BLT $t0 $t1 LOOP
# initialize $t1
# increment $t0
# determine if code should re-enter loop
Lab 3: MIPS Looping ASCII Art CMPE 012 Winter 2019
Last Name, First Name CruzID –
The text of your prompts are stored in the processors memory. After assembling your program, what is the range of addresses in which these strings are stored?
Write the answer here.
What were the learning objectives of this lab? Write the answer here.
Did you encounter any issues? Were there parts of this lab you found enjoyable?
Write the answer here.
How would you redesign this lab to make it better? Write the answer here.
Did you collaborate with anyone on this lab? Please list who you collaborated with and the nature of your collaboration.
Write the answer here.
Lab 3 Page 4 of 5 Winter 2019 2019, Computer Engineering Department, University of California Santa Cruz
Grading Rubric
6 pt assembles without errors
8 pt output matches the specification
1 ptformat of prompt 1
1 ptformat of prompt 2
4 pttriangle formatting: leg size, number of triangles, and spacing
Note: If spacing is incorrect, you may lose points for both spacing and
number of triangles printed.
1 ptprint character syscall (11)
1 ptexit syscall (10)
1 pt complete header comments in code and README
1 pt useful & sufficient comments
1 pt comment on register usage
1 pt clean visual structure / use of white space
Note: line up instructions, operands, and comments using spaces indent code from labels
2 pt readme file complete (should total at least 150 words)
Lab 3 Page 5 of 5 Winter 2019 2019, Computer Engineering Department, University of California Santa Cruz
Reviews
There are no reviews yet.