首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
ECS 50编程设计辅导、Python编程讲解、辅导Java,c/c++程序 讲解留学生Processing|讲解留学生Prolog
项目预算:
开发周期:
发布时间:
要求地区:
ECS 50: Programming Assignment #5
Spring 2021
Contents
1 Changelog 1
2 General Submission Details 1
3 Grading Breakdown 1
4 Submitting on Gradescope 1
5 Programming Problems 2
5.1 General Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
5.2 Tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
5.3 Part #1: Get Max . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
5.4 Part #2: Sum Other . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
5.5 Part #3: Transpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1 Changelog
You should always refer to the latest version of this document.
• v.1: Initial version.
2 General Submission Details
Partnering on this assignment is prohibited. If you have not already, you should read the section on
academic misconduct in the syllabus.
This assignment is due the night of Tuesday, 05/25. Gradescope will say 12:30 AM on Wednesday, 05/26, due to the
“grace period” (as described in the syllabus). Be careful about relying on the grace period for extra time; this could be risky.
3 Grading Breakdown
As stated in the updated syllabus, this assignment is worth 9% of your final grade (which is pretty inflated, but I don’t
want there to be too much weight at the very end of the course). Each of the three parts is worth 3%.
4 Submitting on Gradescope
Files to submit:
• max.s
• sum_other.s
• transpose.s
∗This content is protected and may not be shared, uploaded, or distributed.
1
Do not submit the input code files, e.g. call_max.s. You may be penalized for submitting unnecessary files.
There is no autograder for this assignment, at least not one that you get to interact with before the
deadline. You must simply submit your code to Gradescope, and – after the deadline – I will use a script to grade the
submissions. (Make sure your file names are correct!) I will do this on the CSIF, so the CSIF is still the reference environment.
Your output must match mine exactly.
5 Programming Problems
For this assignment, you will implement three functions using the 64-bit RISC-V assembly language, i.e. the one that
we have talked about during lecture. There are hardly any RISC-V computers out there now, so I don’t expect any of you
to have any. The CSIF computers have x64 (i.e. x86-64) chips. Instead, we will use a simulator and associated compilation
tools that are already installed on the CSIF. In case you are curious, the tools are listed below; you do not need to install
these tools yourself, since they are already on most of the computers on the CSIF. (If you do install them on your
end, just know that the process may take a few hours and is a bit complicated.) You can find a list of the CSIF computers
that have the tools installed here.
• The RISC-V GNU toolchain here. I did the Newlib installation (riscv64-unknown-elf-gcc), not the Linux one, because
spike requires the former.
• The Spike RISC-V ISA simulator here.
• RISC-V Proxy Kernel and Boot loader here.
In the examples below, I show how to use the RISC-V GNU toolchain on the CSIF to compile code.
5.1 General Requirements
The requirements mentioned here apply to all three parts.
In this assignment, all code that you write must be RISC-V assembly code. You must write this assembly
code yourself. As an example of what you cannot do, you cannot write C++ code (or code in any other
high-level language) and then use some tool to compile that C++ code into assembly code to submit; we will
not accept that, and we will easily be able to tell if you submitted compiler-generated assembly code.
Each of the three required functions that you write for this assignment must preserve the value of any register that it
uses except for:
• The registers used for the arguments required by the function. (For example, since the function max() that you will
write for part #1 takes two arguments, the registers a0 and a1 need not be preserved.)
• a0, if it is used for a return value.
In real-world RISC-V assembly code, you would of course obey the appropriate calling convention and not preserve the
values of volatile registers. Here, to give you practice preserving registers, we disregard this common calling convention.
5.2 Tips
Note that you have access to common library functions such as printf(), due to the way in which you will compile your
code. This may be helpful as you debug your code.
If you call printf() in any of your functions, make sure to preserve the values of any volatile registers that you are using
first, including – most notably – the ra register.
5.3 Part #1: Get Max
In this part, you will write a function called max() that takes two arguments in the a0 and a1 registers – both 32-bit integers
– and returns (in the a0 register) whichever of the two arguments is higher.
Below is an example of how your code should behave. You can find call_max.s on Canvas. I intentionally show a few
lines of max.s, in order to help you get started1
. Note that if you copy from this PDF directly, spaces may be inserted in
unexpected locations; keep that in mind if you copy the commands in order to paste them into a terminal. Also note that
the bbl loader part of the output is always there, no matter what you do; that is from the Spike emulator.
1You must make max a global symbol with the .global directive, so that the symbol can be seen from within call_max.s. (I think that .globl
and .global are exactly the same.)
2
1 $ cat call_max . s
2 . data
3
4 format_str : . string " Max : %d\ n"
5
6 . text
7 . globl main
8 main :
9 li a0 , 5
10 li a1 , 13
11 jal max
12 mv a1 , a0
13 lui a0 , % hi ( format_str )
14 addi a0 , a0 , % lo ( format_str )
15 call printf
16 # Perform exit () system call .
17 # Source : https :// www . robalni . org / riscv / linux - syscalls -64. html
18 li a7 , 93
19 li a0 , 0
20 ecall
21 $ cat max .s
22 . global max
23 max :
24 ... ( removed by Aaron ) ...
25 jalr x0 , 0( x1 )
26 $ / opt / riscv / bin / riscv64 - unknown - elf - gcc max .s call_max .s -o max
27 $ / opt / riscv / bin / spike / opt / riscv / riscv64 - unknown - elf / bin / pk max
28 bbl loader
29 Max : 13
5.4 Part #2: Sum Other
In this part, you will write a function called sum_other() that takes two arguments in the a0 and a1 registers:
1. First argument: the (potentially 64-bit) starting address of an array of 32-bit integers.
2. Second argument: length of this array (a 32-bit value).
The function should return (in a0) the sum of every other value in the array (i.e. the sum of the first value, third value,
fifth value, etc.).
Below is an example of how your code should behave.
1 $ cat call_sum_other .s
2 . data
3
4 format_str : . string " Sum : %d\ n"
5
6 arr :
7 . long 5
8 . long 20
9 . long 13
10 . long 18
11 . long 27
12 . long 42
13
14 . text
15 . globl main
16 main :
17 lui a0 , % hi ( arr )
18 addi a0 , a0 , % lo ( arr )
19 li a1 , 6
20 jal sum_other
21 mv a1 , a0
22 lui a0 , % hi ( format_str )
23 addi a0 , a0 , % lo ( format_str )
24 call printf
25 # Perform exit () system call .
26 li a7 , 93
27 li a0 , 0
28 ecall
29 $ cat sum_other .s
30 . global sum_other
31 sum_other :
3
32 ... ( removed by Aaron ) ...
33 jalr x0 , 0( x1 )
34 $ / opt / riscv / bin / riscv64 - unknown - elf - gcc sum_other .s call_sum_other . s -o sum_other
35 $ / opt / riscv / bin / spike / opt / riscv / riscv64 - unknown - elf / bin / pk sum_other
36 bbl loader
37 Sum : 45
5.5 Part #3: Transpose
In this part, you will implement the transpose() function that you previously implemented in part #5 of the previous
programming assignment. You should consult prog_hw4.pdf if you do not remember all of the details of that function. In the
version on the previous assignment, all four arguments were passed on the stack. For this current assignment, this will not
be the case; instead, the four arguments will be passed through the registers a0 through a3. This function does not return
any value, and it is not allowed to modify the original matrix. Note that both the input matrix and the output matrix are
two-dimensional arrays of 32-bit integers, and their dimensions are 32-bit values. However, the starting addresses of these
matrices are potentially 64-bit values.
Hint: Multiplication is supported by our tools. For instance, you can do mul a0, a1, a2 to store the product of a1 and a2
in a0. (There does not seem to be a version that has an immediate operand as the third operand.)
Below is an example of what calling the function would look like. You should yourself add a nested loop for printing out
the values of the output array.
1 $ cat call_transpose .s
2 . data
3
4 input :
5 . word 1
6 . word 2
7 . word 3
8 . word 4
9 . word 5
10 . word 6
11
12 output :
13 . rept 6
14 . word -1
15 . endr
16
17 . text
18 . globl main
19 main :
20 lui a0 , % hi ( input )
21 addi a0 , a0 , % lo ( input )
22 li a1 , 3
23 li a2 , 2
24 lui a3 , % hi ( output )
25 addi a3 , a3 , % lo ( output )
26 jal transpose
27 # Perform exit () system call .
28 li a7 , 93
29 li a0 , 0
30 ecall
31 $ cat transpose .s
32 . global transpose
33 transpose :
34 ... ( removed by Aaron ) ...
35 jalr x0 , 0( x1 )
4
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
代写dts207tc、sql编程语言代做
2024-12-25
cs209a代做、java程序设计代写
2024-12-25
cs305程序代做、代写python程序...
2024-12-25
代写csc1001、代做python设计程...
2024-12-24
代写practice test preparatio...
2024-12-24
代写bre2031 – environmental...
2024-12-24
代写ece5550: applied kalman ...
2024-12-24
代做conmgnt 7049 – measurem...
2024-12-24
代写ece3700j introduction to...
2024-12-24
代做adad9311 designing the e...
2024-12-24
代做comp5618 - applied cyber...
2024-12-24
代做ece5550: applied kalman ...
2024-12-24
代做cp1402 assignment - netw...
2024-12-24
热点标签
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
软件定制开发网!