CIT 593 – Module 07 Assignment
CIT 593 – Module 07 Assignment Instructions
Operating System, IO Assembly Instructions
Contents
Assignment Overview 3 Learning Objectives 3 Advice 3 Getting Started 4
Codio Setup 4 Run user_echo.asm in PennSim 4
Starter Code 6 Requirements 7
General Requirements 7
Part 1: Echo with TRAP_GETC/TRAP_PUTC 7
Part 3: Get Strings with TRAP_GETS
Part 2: Print Strings with TRAP_PUTS 8
Part 4: Draw Rectangles with TRAP_DRAW_RECT 10
Extra Credit: Get a Character Within a Time Limit with TRAP_GETC_TIMER 11
Extra Credit: Reset Starting Coordinates When Out of Bounds 11
Extra Credit: Wrap the Rectangle Horizontally 11 Suggested Approach 12 High Level Overview 12 Great High Level Overview, but I really need a Slightly More Detailed Overview 13 Part 1: Echo with TRAP_GETC/TRAP_PUTC 13
Submission 22 Where to put the files 22 Pre-Submission Test 22 The Actual Submission 22
Codio Submission 22 Gradescope Submission 22 Academic Integrity Agreement: 22
Grading 23 Main Assignment 23
Part 2: Print Strings with TRAP_PUTS 14
Part 3: Get Strings with TRAP_GETS 16
Part 4: Draw Rectangles with TRAP_DRAW_RECT 18
Extra Credit: Get a Character in a Time Limit with TRAP_GETC_TIMER 20
Extra Credit: Reset Starting Coordinates When Out of Bounds 21
Extra Credit: Wrap the Rectangle Horizontally 21
Page 1 of 24
9
Extra Credit 23 An Important Note of Plagiarism 23
FAQ
Quick Hints
Resources
CIT 593 – Module 07 Assignment Instructions
Page 2 of 24
Assignment Overview
CIT 593 – Module 07 Assignment Instructions
In this assignment, you will continue programming in LC4 Assembly. We will be working in the
Operating System portion of memory, so you will learn about TRAPs and memory-mapped
devices.
Learning Objectives
This assignment will cover the following topics:
-
● Work with TRAPS and the Operating System
-
● Implement an Operating System
-
● Work with the Keyboard, Display, and Video devices
-
● (optional) Work with the Timer device
Advice
-
● Start early
-
● Ask for help early
● Donottrytodoitallinoneday
Page 3 of 24
Getting Started
Codio Setup
Be sure to open Codio from the Codio Assignment page in Canvas. Refer to the Module 06 Instructions for details about how Codio works.
Run user_echo.asm in PennSim
1. From the File Tree, click on os.asm. This will open a new Codio tab named os.asm
containing the contents of the file.
a. Review the contents of the file. This is the basic framework for the operating system, which you will be writing for this assignment.
b. Look in the TRAP vector table for the line JMP TRAP_PUTC
Notice how this is the second instructions is after the .ADDR x8000 directive.
CIT 593 – Module 07 Assignment Instructions
● When loaded into PennSim, this instruction will be placed at address x8001.
● We can call TRAP_PUTC by using the TRAP instruction with offset x01. This will be
done later in user_echo.asm.
c. Scroll down (approximately 115 lines or so) until you reach the lines that read:
.CODE TRAP_PUTC
This label marks the start of the PUTC TRAP (an OS subroutine)
-
When Penn Sim executes JMP TRAP_PUTC instruction from the vector table, the
program counter will be advanced to the address labeled by TRAP_PUTC
-
Further examine the code that follows; this is the operating system subroutine (a TRAP) called TRAP_PUTC.
2. From
f. Notice that this is the program we created in lecture to write one character to the
ASCII display device on the LC4.
the File Tree, click on user_echo.asm. CONST R0, x54
TRAP x01
c. The CONST instruction places the number 0x54 (which represents the letter 'T' in ASCII code) into R0. This serves as the argument to the TRAP_PUTC trap. You can look up the ASCII code mappings in the Resources section.
-
The TRAP x01 instruction sets PC to x8001, and also sets PSR[15]=1 (OS mode). TRAP x01 is TRAP_PUTC, so this TRAP call will have the effect of outputting a 'T' to the LC4’s ASCII display.
-
Examine the rest of this program, you’ll see that its purpose is to output Type Here> on the LC4 ASCII display.
a. This file is a program to test some of the operating systems TRAPs in os.asm
b. Scroll down to about the 24th line, look for the lines that read:
Page 4 of 24
-
From the File Tree, click on user_echo_script.txt. This opens a new Codio tab displaying the script contents.
-
This file is the PennSim script that assembles and loads os.asm and
user_echo.asm
-
Look carefully at the contents and compare how it differs from your last HW. Notice how it assembles and loads both os.asm and user_echo.asm
-
-
Open a PennSim Window and launch PennSim from the Codio command line. Refer to the Module 6 instructions if you need a refresher on how to do this.
-
Go to the command line in the Controls section and enter
script user_echo_script.txt
-
Press the Step button and carefully go line by line until you see the letter 'T'
output to the screen.
a. Carefully watch how you start in user_echo.asm’s code (in user
program memory) and then with the call to TRAP, you enter into OS
b. Understanding this process is crucial to understanding, writing, and
debugging this assignment.
7. Finally, press the Continue button to see PennSim run the program until itassignment.program memory.
encounters the END label.
8. Make certain you understand how these files work together before beginning the
CIT 593 – Module 07 Assignment Instructions
Page 5 of 24
Starter Code
We have provided some starter files. You will need to modify some files and generate
completely new files to succeed in this assignment.
CIT 593 – Module 07 Assignment Instructions
os.asm |
- contains the operating system framework, and the TRAP_PUTC example from lecture. Your will write the remaining TRAPs. |
user_echo.asm
|
- demo program from lecture |
user_echo_script.txt
|
- demo script file for user_echo example |
PennSim.jar |
- Runs your programs, debugging, etc. |
Page 6 of 24
Requirements
CIT 593 – Module 07 Assignment Instructions
General Requirements
-
● Your script files MUST contain all the necessary commands to assemble and load your programs, as shown in lecture and the multiply example from Module 6.
-
● Your programs MUST complete the requirements of the problem when loaded into PennSim and clicking the Continue button.
-
● Your programs MUST NOT throw any Exception unless otherwise noted.
-
● Your programs MUST be written in LC4 Assembly.
-
● You MUST comment critical sections your code so we can grade it. This will also help with partial credit.
-
● You MUST use END as the label that indicates the end of the program.
-
● You MUST submit to Codio and Gradescope as outlined in the Submission section.
● You SHOULD do all the work in Codio. Do not attempt to run these programs locally.
TAs will not assist you if you are trying to do the projects outside of Codio.
o Codio provides a standard environment to ensure consistent functionality.
o Codio backs up your code. You can restore deleted/modified files by going to
Tools->Code Playback.
o TAs can login and view your code for asynchronous debugging.
o Different operating systems handle endianness differently. Your submission
MUST work in the Codio environment, which is where we will be performing all
tests.
Part 1: Echo with TRAP_GETC/TRAP_PUTC
● You MUST use the traps TRAP_GETC and TRAP_PUTC.
● You MUST implement the traps in os.asm, write the test program in user_echo.asm,
and provide a working script user_echo_script.txt.
-
● TRAP_GETCMUSTtakenoargumentsasinputandreturntheread-incharacterinR0.
-
● TRAP_PUTCMUSTtakeasingleargumentinR0(thecharactertodisplay)asinputand not return any value.
-
● Your test program MUST call these two traps in a loop, to echo the user keystrokes to the display.
○ It MUST break out of the loop when the user presses the enter key.
Page 7 of 24
Part 2: Print Strings with TRAP_PUTS
-
● You MUST implement and use the trap TRAP_PUTS.
-
● You MUST implement the traps in os.asm, write the test program in user_string.asm,
and provide a working script user_string_script.txt. ● TRAP_PUTSMUST:
-
○ take a single argument in R0 (the address of the start of the string to display) as input and not return any value.
-
○ check that the provided argument is a valid User Data Memory address.
○ If the address is not valid, immediately return without attempting to print the string.
○ print the entire string to the display; that is each character from the starting address through the entire array up to but not including the NULL terminator.
● Your test program MUST:
○ use .FILL to pre-load the NULL-terminated string
I love CIT 593
CIT 593 – Module 07 Assignment Instructions
into User Data Memory, starting at address x4000.
○ print this string to the display by populating R0 with the starting address and then calling TRAP_PUTS with the appropriate Trap Number from the Trap Vector Table
Page 8 of 24
Part 3: Get Strings with TRAP_GETS
● You MUST implement the trap TRAP_GETS and use the traps TRAP_GETS and TRAP_PUTC.
● You MUST implement the traps in os.asm, write the test program in user_string2.asm, and provide a working script user_string2_script.txt.
● TRAP_GETSMUST:
-
○ take a single argument in R0 (the address to start storing the string) as input and
return the length of the string (not including the NULL terminator) in R1.
-
○ check that the provided argument is a valid User Data Memory address.
○ If the address is not valid, immediately return without attempting to get a string.
○ continue to read characters entered by the user until the user presses the enter
CIT 593 – Module 07 Assignment Instructions
key.
○ store each character typed by the user up to but not including the enter key and add the NULL terminator at the end of the string.
● Your test program MUST:
-
○ read the arbitrary user string and store it into Data Memory.
-
○ Print the text:
Length = X
using TRAP_PUTS for the Length= portion and TRAP_PUTC for X, where X is the length of the ring.
You MAY assume that the strings will be less than 10.
○ Call TRAP_PUTS with address x2020 to print the string previously entered by the user.
Page 9 of 24
Part 4: Draw Rectangles with TRAP_DRAW_RECT
-
● You MUST implement and use the trap TRAP_DRAW_RECT.
-
● You MUST implement the traps in os.asm, write the test program in user_draw.asm,
and provide a working script user_draw_script.txt. ● TRAP_DRAWMUST:
-
○ take five arguments:
○ R0-x-coordinateoftheupper-leftcorneroftherectangle,thehorizontaldistance from (0,0)
○ R1-y-coordinateoftheupper-leftcorneroftherectangle,theverticaldistance from (0,0)
○ R2-thehorizontallengthoftherectangle
○ R3-theverticalwidthoftherectangle
○ R4-thecoloroftherectangle
○ check the bounds of the rectangle compared to the video display
CIT 593 – Module 07 Assignment Instructions
○ ○
○ draw the rectangle with the appropriate color, filling all interior pixels ● Your test program MUST call TRAP_DRAW_RECT for the following rectangles:
-
○ a red rectangle with starting coordinates (50,5), length 10, and width 5
-
○ a green rectangle with starting coordinates (10, 10), length 50, and width 40
-
○ a yellow rectangle with starting coordinates (120, 100), length 27, and width
10
if the starting coordinates are outside the video display, immediately
return without attempting to draw any part of the rectangle.
if the starting coordinates are inside the video display, but the values for
length or width would cause the rectangle to be drawn outside the video
display, immediately return without attempting to draw any part of the
rectangle.
Page 10 of 24
Extra Credit: Get a Character Within a Time Limit with
TRAP_GETC_TIMER
-
● You MUST implement and use the traps TRAP_GETC_TIMER and TRAP_PUTC.
-
● You MUST implement the trap in os.asm, write the test program in
user_string_ec.asm, and provide a working script user_string_ec_script.txt.
-
● TRAP_GETC_TIMERMUST
-
○ take a single argument in R0 (the desired time to wait for a character) as input.
-
○ if a key is pressed within the time limit, return the entered character in R1.
-
○ if a key is not pressed within the time limit, return NULL in R1.
-
-
● Your test program MUST:
-
○ use a time limit of two seconds.
-
○ print the key that was entered within the time limit using TRAP_PUTC, or print
nothing if a key was not entered.
-
Extra Credit: Reset Starting Coordinates When Out of Bounds
● You SHOULD make a copy of your TRAP_DRAW_RECT trap before working on this extra credit, in case you don't get it working before the submission deadline.
-
● You MUST modify TRAP_DRAW_RECT. It MUST follow the original requirements, except:
○ If the starting coordinates are outside the video display, it MUST reset the starting coordinates to (0,0) and draw the rectangle starting here instead, using the original length/width values.
○ It MUST follow the Wrap the Rectangle Horizontally extra credit exception if
attempting both extra credit options.
Extra Credit: Wrap the Rectangle Horizontally
-
● You SHOULD make a copy of your TRAP_DRAW_RECT trap before working on this extra credit, in case you don't get it working before the submission deadline.
-
● You MUST modify TRAP_DRAW_RECT. It MUST follow the original requirements, except:
-
○ If the rectangle's horizontal length would take it outside the video display, it MUST wrap around the display and continue drawing the rectangle from the left side of the display at the same vertical width. Do not wrap rectangles if they go outside video memory vertically.
-
○ It MUST follow the Reset Starting Coordinates When Out of Bounds extra credit exception if attempting both extra credit options.
-
Page 11 of 24
Suggested Approach
5. Complete the TRAP_GETS implementation in os.asm.
6. Implement user_string2.asm using TRAP_GETS, TRAP_PUTS, and TRAP_PUTC.
7. Review the implementation of TRAP_DRAW_PIXEL.
8. Complete the TRAP_DRAW_RECT implementation in os.asm.
-
Implement user_draw.asm using TRAP_DRAW_RECT.
-
(optional) Attempt the extra credits.
CIT 593 – Module 07 Assignment Instructions
This is a suggested approach. You are not required to follow this approach as long as you
follow all of the other requirements.
High Level Overview
Work on one problem at a time.
-
Review the starter code to see how the different files work together. This is critical for succeeding in this assignment. TRAP_PUTC is already written for you and you need to understand how it works.
-
Implement user_echo.asm, using TRAP_GETC and TRAP_PUTC.
-
Complete the TRAP_PUTS implementation in os.asm.
-
Implement user_string.asm using TRAP_PUTS.
Page 12 of 24
Great High Level Overview, but I really need a Slightly More
Detailed Overview
CIT 593 – Module 07 Assignment Instructions
Okay, I guess we can give some more details.
Part 1: Echo with TRAP_GETC/TRAP_PUTC File Setup
You only need to modify user_echo.asm for this part. You do not need to create any additional files.
Your Task
Use the two provided TRAPs to "echo" the user's keystrokes to the display.
Extend the user_echo.asm code to read an ASCII character from the Keyboard (using
TRAP_GETC) and print it to the ASCII Display (using TRAP_PUTC) in a loop. Repeat this
process until the user presses the Enter key. Consider which type of loop is appropriate (for,
while, do-while).
You may have noticed the hint to use .STRINGZ. This is optional and requires reading the textbook or do some outside research. This will likely be time consuming and more trouble than it is worth. Additionally, the TAs will not support you if you run into problems using .STRINGZ since this is 100% completely optional.
Page 13 of 24
Part 2: Print Strings with TRAP_PUTS
File Setup
For this problem, you will create a new trap TRAP_PUTS and add it to the operating system file os.asm. You’ll also create a new file called user_string.asm to test your new trap, similar to how user_echo.asm tested the TRAP_GETC and TRAP_PUTC traps in the last problem. This new trap will print (or "put") a string to the screen ASCII Display. Then create user_string_script.txt with the appropriate contents.
What is a String?
A string is simply an array, or consecutive sequence, of individual ASCII characters.
To be considered a string an ASCII character array must end with the NULL character. ANULLcharacterisanon-printablecharacter. Typically,thenumber0isused.Itis never printed; it is just to mark the end of the string.
Example Address
x4000
x4001
x4002
x4003
x004D
x0000
'M'
NULL
First, create TRAP_PUTS. Open up the file os.asm and find where TRAP_PUTS is located in the vector table. Then scroll down to the label TRAP_PUTS to see the trap’s implementation. You’ll
notice it’s empty, but this is where you will be working.
This purpose of this function is to output a NULL terminated string to the ASCII display. We can’t pass the entire "string" to a trap because we’d run out of registers quickly if we had strings with more than 8 characters. Instead, we will pass the address of the first character of a string to the trap using R0.
When TRAP_PUTS is called, register R0 must contain the address of the first character of the string where the caller has stored the string in Data Memory. Therefore, R0 is considered the argumenttothetrap. Usingtheexamplestringabove,R0wouldbesettox4000when calling the trap.
The last character in the string must be zero, which is the null terminator, to give us a null-terminated string.
This trap does not return anything to the caller
CIT 593 – Module 07 Assignment Instructions
Consider this hypothetical example of a string containing: "Tom" in data memory. It
starts at x4000 and uses four rows of Data Memory to hold each character, including
the NULL terminator.
hexadecimal translation
Contents in ASCII
x0054 |
'T' |
Your Task
x004F 'O'
Page 14 of 24
We have provided pseudocode for this TRAP:
TRAP_PUTS (R0) {
check the value of R0, is it a valid address in User Data memory?
if it is, continue, if not, return to caller
load the ASCII character from the address held in R0 while (ASCII
character != NULL) {
check status register for ASCII Display
if it’s free, continue, if not, keep checking until its free
write ASCII character to ASCII Display’s data register
load the next ASCII character from data memory
}
return to caller
copy user_string.asm. Open up user_string.asm and perform the following tasks:
1. Using the .FILL directive, populate User Data Memory starting at address x4000 with the hexadecimal code for the string:
I love CIT 593
Look at the back cover of your book to find the hexadecimal code for each character.
Don’t forget to also set the value of the last address after your string with NULL. You
may label address x4000 if you’d like, but its not required.
-
Populate R0 with the address of the first character in your string.
-
Call TRAP_PUTS using the appropriate TRAP number from the TRAP Vector Table
shown at the top of os.asm.
4. Create user_string_script.txt by copying user_echo_script.txt and modifying
it.
-
Test our your work, if it’s not working, debug by going Step by Step.
-
Do not move on to the next part until this one is working correctly.
CIT 593 – Module 07 Assignment Instructions
}
Once you have implemented the trap, it is time to test it. Copy user_echo.asm, and call the
Page 15 of 24
Part 3: Get Strings with TRAP_GETS
File setup
For this problem, you will create a new trap TRAP_GETS and add it to the operating system file os.asm. You’ll also create a new file called user_string2.asm to test your new trap. This new trap will get a string from the user. Create user_string2_script.txt with the appropriate contents.
Your Task
Back in os.asm, scroll down to the label TRAP_GETS. You’ll notice under the label is where you will be working. The purpose of this function is to continually read characters from the keyboard until the enter key is pressed, storing each character into user specified location in User Data Memory as a string, then return the length of the string to the caller.
When the program calls the trap, the caller must pass the desired starting address as an
argument in R0. R0 will be the address in User Data Memory where the string that will be read from the keyboard will be stored.
The trap needs to check to ensure R0 contains a valid address in User Data Memory. If not, return immediately without attempting to read anything from the keyboard..
Otherwise, the trap must then read in characters one by one. As it reads in each character, it
must store them in data memory consecutively starting from the address passed in by the
caller. Once the enter key is pressed (which is hexadecimal x0D or x0A depending on your
machine) the trap must "NULL terminate" the string in data memory and finally return the length
of the string (without including the NULL or enter) to the caller in R1. As an example, let’s say a program called the TRAP as follows:
; program sets R0=x2000
; program calls TRAP_GETS(R0)
; R1 contain the length of the string after the TRAP returns
For a more concrete example, let’s say that, when the program calls the TRAP, the user types in Hello on the console, followed by an enter. User Data Memory would contain the following after the TRAP returns:
Example Address |
Contents in hexadecimal |
ASCII translation |
x2000 |
x0048 |
'H' |
x2001 |
x0065 |
'e' |
x2002 |
x006C |
'l' |
x2003 |
x006C |
'l' |
x2004 |
X006F |
'o' |
x2005 |
x0000 |
NULL |
Page 16 of 24
And R1 would contain the number 5 when the trap returns. The above is just an example; any valid address in data memory can be passed in by the caller and any string could be entered by the caller on the keyboard.
After you complete testing the trap, do the following in user_string2.asm:
-
Call TRAP_GETS with address: x2020 in R0. This will allow a string to be entered by the user and it will be stored in address R0
-
Using TRAP_PUTS and TRAP_PUTC, print Length = X
where X is the length of the read-in string from step 1 (you can assume length will be
less than 10)
3. Call TRAP_PUTS with address: x2020 in R0. This will output the same string that was read in from step 1 to the Display.
CIT 593 – Module 07 Assignment Instructions
Page 17 of 24
Part 4: Draw Rectangles with TRAP_DRAW_RECT
When the TRAP is called the following registers must contain the following:
R0 – "x coordinate" of upper-left corner of the rectangle.
R1 – "y coordinate" of upper-left corner of the rectangle.
R2 – horizontal length of the rectangle (in number of pixels across the display).
R3 – vertical width of the side of the rectangle (in number of pixels down the display). R4 – the color of the rectangle. Read the PennSim manual for how to generate colors.
The TRAP needs to do basic boundary Checking. The TRAP checks to see if the length and
width are valid from the starting location of the rectangle. If the rectangle would start outside or
go outside the video display, return without attempting to draw the rectangle.
Make certain to comment the TRAP’s inputs and outputs as well as key components
of your code so we can understand your work.
Also make certain to comment the trap “test” program you write.
As an example of using the TRAP, suppose the user calls the TRAP with the values of:
R0=#2, R1=#1, R2=#5, R3=#2, R4=x7C00 (red). The TRAP would then draw a red box to
the video display and like this:
CIT 593 – Module 07 Assignment Instructions
File setup
For this problem, you create a new trap TRAP_DRAW_RECT and add it to the operating system file os.asm. You’ll also create a new file called user_draw.asm to test your new trap. This new trap will get the rectangle parameters (starting location, size, color) from the user. Finally, create a script file user_draw_script.txt with the appropriate contents.
Your Task
Review the TRAP_DRAW_PIXEL to see how to interact with the video display.
Implement TRAP_DRAW_RECT. This trap will draw a rectangle whose location and dimensions will be set by the user. The color of the rectangle will also be an argument passed in by the caller.
Page 18 of 24
CIT 593 – Module 07 Assignment Instructions Demonstrate your mastery of this TRAP in user_draw.asm which draws the following
rectangles (coordinates are given in (x, y) order):
-
● A red rectangle, upper left coordinates: (50, 5), length = 10 and width 5
-
● A green ectangle, upper left coordinates: (10, 10), length = 50, width 40
-
● A yellow rectangle, upper left coordinates: (120, 100), length = 27, width 10
These are some edge cases that students ask about all the time. Now they are in the instructions!
-
For R0=127, R1=123, R2=R3=1 only draw 1 pixel at (127,123) (the bottom right pixel).
-
If the starting y-coordinate R1 plus vertical width R3 would go out of bounds, then do not
draw the rectangle ever.
-
If the starting x- or y-coordinate is out of bounds, do not draw the rectangle, unless you
are attempting the Reset Starting Coordinates extra credit.
-
If the starting x-coordinate R0 plus length R2 would go out of bounds, then do not draw
the rectangle, unless attempting be Wrapped the Rectangle Horizontally extra credit.
Page 19 of 24
Extra Credit: Get a Character in a Time Limit with TRAP_GETC_TIMER
CIT 593 – Module 07 Assignment Instructions
We recommend attempting this optional extra credit after you have Part 3 working successfully. You will need to read up on the Timer Device in the PennSim manual on your own. Since this is a challenge problem, the TAs will not be able to help much.
Create a new trap called TRAP_GETC_TIMER in os.asm and create two new files:
user_string_ec.asm and user_string_ec_script.txt.
Your new TRAP_GETC_TIMER must do everything that TRAP_GETC used to do, except now it
must "time out" if a user doesn’t enter a key in 2 seconds.
How to do this? Recall that TRAP_GETC checks the status register in a loop. Before entering
that loop, set a timer for 2 seconds. Once you are inside the loop that checks the status
register, you could also check the timer too. If the user doesn’t press a key in 2 seconds,
return back to the caller without checking the data register.
We've included a TRAP called TRAP_TIMER to give you an example of how to work with the
timer I/O device.
Your user_string_ec.asm file must call TRAP_GETC_TIMER to get a character from the
keyboard if it is entered within 2 seconds. If the user types a character within 2 seconds, print
it to the ASCII display. Otherwise, your program must end gracefully without printing anything.
Page 20 of 24
Extra Credit: Reset Starting Coordinates When Out of Bounds
To implement the extra credit, you will be modifying the behavior of TRAP_DRAW_RECT. Once you get the TRAP working, we encourage you to make a backup of your code in case your extra credit implementation is not functional in time for submission.
The original implementation does not draw a rectangle if the rectangle would start outside the
Video Display. In this extra credit implementation, reset the starting coordinates to (0,0) and
draw the rectangle starting here instead, using the original length/width values. If the reset
rectangle would still go outside the Video Memory bounds with the original length/width values,
do not draw the rectangle.
If you are attempting both TRAP_DRAW_RECT extra credits, you should do both this extra credit and the following extra credit in the same TRAP.
Extra Credit: Wrap the Rectangle Horizontally
To implement the extra credit, you will be modifying the behavior of TRAP_DRAW_RECT. Once
you get the TRAP working, we encourage you to make a backup of your code in case your
extra credit implementation is not functional in time for submission.
The original implementation does not draw a rectangle if the rectangle would go outside the horizontal limit of the video display. In this extra credit, if the box would go outside of Video Memory horizontally, correct the rectangle and make it "wrap around" the display (see diagram below). Do not wrap rectangles if they go outside video memory vertically.
If you are attempting both TRAP_DRAW_RECT extra credits, you should do both this extra
credit and the previous extra credit in the same TRAP.
Page 21 of 24
Submission
When you are ready (before the deadline), go to Education -> Mark Complete.
Gradescope Submission
CIT 593 – Module 07 Assignment Instructions
Where to put the files
Leave all the files in the working directory where the starter code started.
Pre-Submission Test
There are no pre-submission tests.
The Actual Submission
There are two parts to submit this assignment: Codio and Gradescope.
Codio Submission
You will need to create a single page PDF and upload it to Gradescope.
Match every question to this single page.
Do not submit a copy of your code in the PDF.
This PDF requires two things:
1. Academic Integrity statement and signature. You can use this as a template (an entire word document template is available on Canvas):
Academic Integrity Agreement:
By submitting this agreement I certify that I have completed this homework
assignment on my own (without collaboration with another student or
unauthorized outside source) and have not plagiarized on this assignment (in accordance with Penn’s Code of Academic Integrity).
___________________ (your name, just type it in)
2. A screenshot of your Completed Codio workspace. It must show:
-
your Codio username
-
the Module number for this assignment (do not reuse the screenshot between assignments; you will get a 0)
-
A screenshot of an indication that the workspace is complete:
-
The Warning that pops up after Marking Complete and typing "yes", OR
-
The Education dropdown menu showing that Mark as Completed is inactive (greyed out)
-
Page 22 of 24
Grading
This assignment is worth 220 points, which will be normalized to 100% for gradebook purposes.
All problems have partial credit.
10 points for script file correctness
10 points for comments
10 points for Part 1: Echo with TRAP_GETC/TRAP_PUTC
50 points for Part 2: Print Strings with TRAP_PUTS
50 points for Part 3: Get Strings with TRAP_GETS
90 points for Part 4: Draw Rectangles with TRAP_DRAW_RECT
Do note that we are only grading for correctness, not efficiency.
Extra Credit
Main Assignment
The extra credits are worth a total of 10 percentage points. The maximum score on this assignment is 110%.
5 percentage points for correctly implementing TRAP_GETC_TIMER.
1 percentage point for correctly implementing TRAP_DRAW_RECT to reset the coordinates.
An Important Note of Plagiarism
ual, the extra credit do
● We will scan your assignment files for plagiarism using an automatic plagiarism detection tool.
● If you are unaware of the plagiarism policy, make certain to check the syllabus to
see the possible repercussions of submitting plagiarized work (or letting someone
submit yours).
CIT 593 – Module 07 Assignment Instructions es not have partial credit.
Page 23 of 24
FAQ
Quick Hints
These are some hints provided by TAs.
Resources
● ASCII table
https://www.asciitable.com/
CIT 593 – Module 07 Assignment Instructions