首页 > > 详细

讲解Database|辅导R语言程序|讲解Processing|调试Matlab程序

项目预算:   开发周期:  发布时间:   要求地区:
Lab 5: Functions and Graphics
Due Friday 11 December 2020, 11:59 PM
Minimum Submission Requirements
● Ensure that your Lab5 folder contains the following files (note the
capitalization convention):
○ Lab5.asm
○ README.txt
○ It is ok if you also have lab5_f20_test.asm, but we will not require or
check it.
● Commit and push your repository
● Complete the Google Form with the correct commit ID of your final submission
Lab Objective
In this lab, you will implement functions that perform some primitive graphics
operations on a small simulated display. These functions will clear the entire
display to a color, display rectangular and diamond shapes using a memory-mapped
bitmap graphics display tool in MARS. To do this you will utilize:
1. Arrays
2. Memory-mapped Input/Output (IO)
3. Subroutines (a.k.a. Functions or Procedures)
4. Macros
5. The MIPS Stack (for arguments and subroutine call state)
Lab Preparation
1. Read some background on Raster graphics
2. Introduction To MIPS Assembly Language Programming
chapters 5, 6; sections 8.1, 8.2
3. Macros
4. Procedures
watch videos 2.7 - 2.12
5. Functions
watch video tutorials 15 – 18
Specification
You will need to implement a set of specific subroutines indicated in these lab
instructions. You are required to start with the skeleton code provided
1
© 2020, Computer Engineering Department, University of California - Santa Cruz
Lab 5 Page 1 of 12 Fall 2020
(lab5_f20_template.asm) and may not change the function names or arguments
at all. Please rename the file to Lab5.asm and start with it. To receive any credit
for your subroutines, Lab5.asm must assemble both on its own and with the
test file. On its own, the template file shouldn’t print or draw anything -- it is
just a set of subroutines.
A test file (lab5_f20_test.asm) tests each one of your subroutines and includes (at
the very end) your subroutines from Lab5.asm (based on the above template file). You
should modify the test to include Lab5.asm instead of lab5_f20_template.asm. Don’t
modify the test file -- we will not use your test file during grading. In order for
your subroutines to function properly, you must use the instructions JAL and JR to
enter and exit subroutines. You must save and restore registers as required in MIPS.
Our test file will look very much like this one, so you should ensure that your
functions work with it!
Bitmap Display Tool
To visualize what you’re doing, you can use the bitmap display tool (Tools->Bitmap
Display).
Functionality
The functionality of your program will support the following:
1. All pixels should be in the range x in [0,128) and y in [0,128) (the
parenthesis means not including 128).
2. Pixels start from (0,0) in the upper left to (127,127) in the lower right.
3. Pixel values are referenced in a single word using the upper and lower half of
the word. So, for example, 0x00XX00YY) where XX and YY can be 0x00 to 0x7F.
4. All colors should be RGB using a single 32-bit word where the top byte is
zero. So, for example, 0x00RRGGBB where RR, GG, and BB can be 0x00 to 0xFF.
5. Clear the entire bitmap display to a color c.
6. Draw a rectangle with center at (xc, yc) and width and height, (w, h), filled
of a given color, c.
7. Draw a diamond of height h whose upper tip is at (x, y), filled with a given
color, c
© 2020, Computer Engineering Department, University of California - Santa Cruz
Lab 5 Page 2 of 12 Fall 2020
Macro Descriptions
push(%reg): Macro that stores the value in %reg on the stack and moves the stack
pointer. The only register that is altered in this macro is $sp. This is already
implemented for you in the test file.
pop(%reg): Macro takes the value on the top of the stack and loads it into %reg then
moves the stack pointer. The only registers altered are %reg and $sp. This is
already implemented for you in the test file.
You are required to implement and use the following macro definitions. Make sure not
to alter their signatures as they may be called by a grading script. These macros
should be in the Lab5.asm file. You may use additional macros if you like but be sure
to include them in Lab5.asm.
getCoordinates(%input %x %y): Macro that takes as input coordinates in the format
(0x00XX00YY) and returns 0x000000XX in %x and returns 0x000000YY in %y. Do not use
any registers other than the input registers to write this macro.
formatCoordinates(%output %x %y): Macro that takes Coordinates in (%x,%y) where %x =
0x000000XX and %y= 0x000000YY and returns %output = (0x00XX00YY). Do not use any
registers other than the input registers to write this macro.
Subroutine Descriptions
These subroutines should be in the Lab5.asm file. You may use additional functions if
you like, but they should be included in Lab5.asm as well. These procedures will be
called by the grading script, so make sure not to alter their signatures.
It is important that these subroutines do NOT display any text to the screen using
syscalls. If so, this will interfere with the grading script and result in point
deductions. You may print strings and characters in the
lab5_f20_test.asm file, but not in Lab5.asm!
We recommend that you try to implement these functions in roughly the given order.
This order “builds up” so you get an understanding of memory-mapped IO, the bitmap
display, and how functions work.
clear_bitmap: Given a color, this function will fill the bitmap display with that
color. It is not required that this call any other functions, but you may want to use
draw_pixel.
Inputs:
$a0 = Color
Outputs:
No register outputs
Side-Effects:
Colors the Bitmap display (all RGB pixels from 0xFFFF0000 to 0xFFFFFFFC) all
the same color. (Question for yourself, why 0xFFFFFFFC and not 0xFFFFFFFF?)
© 2020, Computer Engineering Department, University of California - Santa Cruz
Lab 5 Page 3 of 12 Fall 2020
draw_pixel: Given a coordinate in $a0, this function will color a pixel in the image
according to the RGB value given by register $a1. This works by storing the RGB value
in the appropriate location of the row-major bitmap array starting at address
0xFFFF0000.
You should do some error checking to ensure the pixel is within range. If the XX or
YY values “overflow” and are more than 8-bits, you could have segmentation fault
errors when storing to the memory-map. We will not be grading this error checking,
but it will save you time debugging!
Inputs:
$a0 = coordinates of pixel in format (0x00XX00YY)
$a1 = color of bitmap in format (0x00RRGGBB)
Outputs:
No register outputs
Side-effects:
Draws a pixel in the Bitmap Display
get_pixel: Given a coordinate, returns the color of that pixel. This is used for some
“spot checks” in our test code.
Inputs:
$a0 = coordinates of pixel in format (0x00XX00YY)
Outputs:
$v0 = color of the pixel at that coordinate in format (0x00RRGGBB)
Side-effects:
None
draw_rect: Draws a rectangle on the bitmap display.
Inputs:
$a0 = coordinates of top left pixel in format (0x00XX00YY)
$a1 = width and height of rectangle in format (0x00WW00HH)
$a2 = color in format (0x00RRGGBB)
Outputs:
No register outputs
draw_diamond: Draw diamond of given odd integer height peaking at given point.
Inputs:
$a0 = coordinates of top point of diamond in format (0x00XX00YY)
$a1 = height of the diamond (must be odd integer)
$a2 = color in format (0x00RRGGBB)
Outputs:
No register outputs
Pseudocode:
raw_diamond(height, base_point_x, base_point_y)
for (dy = 0; dy <= h; dy++)
y = base_point_y + dy
if dy <= h/2
x_min = base_point_x - dy
x_max = base_point_x + dy
else
x_min = base_point_x - h + dy
© 2020, Computer Engineering Department, University of California - Santa Cruz
Lab 5 Page 4 of 12 Fall 2020
x_max = base_point_x + h - dy
for (x=x_min; x<=x_max; x++)
draw_diamond_pixels(x, y)
Test Output
The test output for this lab is visual and requires you to use the MARS Bitmap
Display tool (in Mars select Bitmap Display from the Tools menu). You should modify
the settings of the bitmap display to be 128 x 128 pixels and to have a base address
of the memory map (0xffff_0000) as shown here:
Press “Connect to MIPS” to use this in your program.
© 2020, Computer Engineering Department, University of California - Santa Cruz
Lab 5 Page 5 of 12 Fall 2020
The bitmap display is a grid of 128 x 128 pixels that displays a color based off the
value written to the address corresponding to that pixel. In the example above, you
can see how the coordinates of the pixel relate to the array in memory for a 4 x 4
pixel bitmap. For example if you wanted to color the pixel at row 2, column 3 (2,3)
you would take the base address of the of the first pixel and offset that by +11
which is (2 * row_size) + 3 to locate the correct pixel to color.
We will be grading your solution by dumping the memory-mapped IO segment as
hexadecimal ASCII and comparing with the correct results. You will miss all the
points if you do not use the above size and base address
configuration! In addition, your Lab5.asm should not display any text
using syscalls as this will interfere with the grading output. If you
want, you can also display the memory-mapped segment using a command line argument
like this:
java -jar Mars4_5.jar nc 0xffff0000-0xfffffffc lab5_f20_test.asm
Sample Input/Outputs
You are expected to read through and understand how the provided lab5_f20_test.asm
file works. The test file will print to the console the state of the S registers
before and after calling a subroutine, provide inputs, and test certain pixels to
make sure that it’s drawn in the correct place. This is what the output of your
completed lab should look like:
© 2020, Computer Engineering Department, University of California - Santa Cruz
Lab 5 Page 6 of 12 Fall 2020
The entire bitmap display tool will look like this:
© 2020, Computer Engineering Department, University of California - Santa Cruz
Lab 5 Page 7 of 12 Fall 2020
Zoomed into the bitmap (the gray outer border not included):
This output of the tests are available in this file if you wish to compare. You can
compare files online using a “diff” utility like Diffchecker or the bash “diff”
command.
For full credit, your output should match ours exactly.
© 2020, Computer Engineering Department, University of California - Santa Cruz
Lab 5 Page 8 of 12 Fall 2020
Pseudocode
You should write pseudocode that outlines each function. Your pseudocode will appear
at the start of each function in Lab5.asm. Guidelines on developing pseudocode can be
found here: https://www.geeksforgeeks.org/how-to-write-a-pseudo-code/
You may modify your pseudocode as you develop your program. Your pseudocode
must also be present in your final submission.
Automation
Note that part of 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.
You should not use a label called “main” anywhere in Lab5.asm. If you
do, it will fail to work with our test cases and your assignment will not be graded.
Files
You do not need to include lab5_f20_test.asm in your repo, but you may if you like.
We will be using our own version.
Lab5.asm
This file contains your pseudocode and assembly code for all of the functions and
macros. It should use the template with the prototype definitions of the functions
given. It should assemble on its own and with the test file that we gave you. Do not
modify these! Follow the code documentation guidelines here. By itself, this file
should not actually do anything but define the functions.
README.txt
This file must be a plain text (.txt) file. It should contain your first and last
name (as it appears on Canvas) and your CruzID. Instructions for the README can be
found here.
Google Form
You are required to answer questions about the lab in this Google Form. Answers,
excluding the ones asking about resources used and collaboration should total at the
very least 150 words.
Syscalls
You may use syscalls in the lab5_f20_test.asm file, but you should not use any
syscalls in Lab5.asm. We inserted an exit syscall in the template to prevent it from
running on its own and you can leave that there, but do not add any more.
Note
It is important that you do not hard-code the values for any of the
addresses in your program -- except for the memory-mapped IO segment at
© 2020, Computer Engineering Department, University of California - Santa Cruz
Lab 5 Page 9 of 12 Fall 2020
0xFFFF0000. We will be testing the functions with different values than those
provided in lab5_f20_test.asm, so do not hard code the output!
keep scrolling ...
Other Requirements
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 unpredictable 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:
© 2020, Computer Engineering Department, University of California - Santa Cruz
LI $t1 2
LOOP: NOP
ADDI $t0 $t0 1
BLT $t0 $t1 LOOP
NOP # nop added after the branch instruction
ADD $t3 $t5 $t6
Lab 5 Page 10 of 12 Fall 2020
MIPS Memory Configuration
To find the program arguments more easily in memory, you may choose to develop your
program using a compact memory configuration (Settings -> Memory Configuration).
However, your program MUST function properly using the Default memory
configuration. You should not run into issues as long as you do not hard-code
any memory addresses in your program. Make sure to test your program
thoroughly using the Default memory configuration.
A Note About Academic Integrity
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 yourself!
Grading Rubric (100 points total)
12 pt assembles without errors
80 pt output matches the specification
15 pt draw_pixel, get_pixel, clear_bitmap
25 pt draws rectangles correctly
25 pt draws diamonds correctly
15 pt caller save registers saved/restored
© 2020, Computer Engineering Department, University of California - Santa Cruz
Lab 5 Page 11 of 12 Fall 2020
Note: credit for this section only if program assembles without errors
8 pt documentation
4 pt README file complete
4 pt Google form complete with at least 150 words
-50 pt if program only runs in a specific memory configuration or memory addresses
are hard coded
-25 pt incorrect naming convention
-100 pt no Google form submitted or incorrect commit ID
© 2020, Computer Engineering Department, University of California - Santa Cruz
Lab 5 Page 12 of 12 Fall 2020

软件开发、广告设计客服
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 9951568
© 2021 www.rj363.com
软件定制开发网!