Lab 3: ASCII-risks (Asterisks)
Due Wednesday, 19 February, 11:59 PM
Minimum Submission Requirements
● Ensure that your Lab3 folder contains the following files (note the
● Commit and push your repository
● Complete the Google Form with the correct commit ID of your final submission
This lab will introduce you to the MIPS ISA using MARS. You will write a program with
several nested loops to print variable sized ASCII diamond and a sequence of embedded
In addition, this lab will introduce you to several different syscalls to incorporate
I/O into your program.
Lecture will start covering MIPS after the midterm, but you can get started with
these videos and readings now.
Introduction To MIPS Assembly Language Programming
section 1.3, chapters 2, 3, and 7
Intro to MIPS
Registers and Memory
Intro to MARS
Getting User Input
This program will print out a triangle with numbers and stars (asterisks).
1. It will first prompt for the height of the triangle. Then use the height h to
print h rows. If the user enters an invalid input such as a negative number or zero,
an error message will be printed and the user will be prompted again.
2. At the start of each row, except the last row, print a number of tabs (not spaces)
as the indent to center the row. The number of tabs should appropriately align the
columns exactly as shown.
3. Then your program should print numbers and stars alternatively with a tab between
each number and star.
User inputs 0, -1, and then 5
For a triangle with height 4, see the figure below. Note that the ‘⊔’ character
indicates a tab. See that line 4 (last row) contains no tabs before the number, line
3 contains 1 tab, line 2 contains 2, etc. Also note that there is a newline after the
triangle is finished printing, before the program terminates.
Enter the height of the triangle (must be greater than 0): 4
— program is finished running —
To receive all possible points, the output should match the sample
You may use syscall 11 (print character), syscall 4 (print
string) and syscall 1 (print integer) to print the triangle, but you
must use syscall 4 (print string) to print the prompt message. You may
collect user input using syscall 5 (read integer). When finished, your
program should end by calling syscall 10 (exit). See below for a summary of
syscalls and their uses.
SYSCALL # FUNCTION PURPOSE
1 Print integer Prints an integer in ASCII
4 Print string Print prompt
5 Read integer Read user input
10 Exit Successfully end the program
11 Print character Prints an ASCII character
Table: Required Syscalls
Turn Off Delayed Branching
From the settings menu, make sure Delayed branching is unchecked
Checking this option will insert a “delay slot” which makes the next instruction
after a branch execute, no matter the outcome of the branch. To avoid having your
program behave in unintended ways, make sure “Delayed branching” is turned
OFF. In addition, add a NOP instruction after each branch instruction. The NOP
instruction guarantees that your program will function properly even if you forgot to
turn off delayed branching. For example:
LI $t1 2
ADDI $t0 $t0 1
BLT $t0 $t1 LOOP
NOP # nop added after the branch instruction
ADD $t3 $t5 $t6
Note that our grading script is automated, so it is imperative that your
program’s output matches the specification exactly. Output that
deviates from the spec will cause point deduction.
Instructions for the README can be found here.
This file contains your pseudocode and assembly code. Include a header comment as
indicated in the documentation guidelines here.
You are required to answer questions about the lab in this Google Form. Question
answers, excluding the ones asking about resources used and collaboration should
total at the very least 150 words.
A Note About Academic Integrity
This is the lab assignment where most students get flagged for cheating. Please
review the syllabus and look at the examples in the first lecture for acceptable and
unacceptable collaboration. You should be doing this assignment completely by
Grading Rubric (80 points total)
20 pt assembles without errors
50 pt output matches the specification
5 pt exact wording and spacing of prompt (space after colon) and error message
5 pt error check zero and negative heights
5 pt prompts user until a correct input is entered
5 pt correct line indentation (must use tabs)
5 pt number of levels matches user input
5 pt tabs between numbers and asterisks
5 pt correct asterisks and numbers on each line
15 pt uses correct syscalls
Note: credit for this section only if program assembles without errors
10 pt documentation
5 pt README file complete
5 pt Google form complete with at least 150 words
-15 pt for incorrect naming convention
本网站支持 Alipay WeChatPay PayPal等支付方式
E-mail: firstname.lastname@example.org 微信号:vipnxx