首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
讲解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
热点项目
更多
代写math 1151, autumn 2024 w...
2024-11-14
代做comp4336/9336 mobile dat...
2024-11-14
代做eesa01 lab 2: weather an...
2024-11-14
代写comp1521 - 24t3 assignme...
2024-11-14
代写nbs8020 - dissertation s...
2024-11-14
代做fin b377f technical anal...
2024-11-14
代做ceic6714 mini design pro...
2024-11-14
代做introduction to computer...
2024-11-14
代做cs 353, fall 2024 introd...
2024-11-14
代做phy254 problem set #3 fa...
2024-11-14
代写n1569 financial risk man...
2024-11-14
代写csci-ua.0202 lab 3: enco...
2024-11-14
代写econ2226: chinese econom...
2024-11-14
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!