首页 > > 详细

辅导program程序、辅导C/C++编程

Lab 3: Assembly Programming
Due Sunday, 27th of February 2022, 11:59 PM
Minimum Submission Requirements
● Ensure that your lab3 folder contains ONLY the following files (note the
capitalization convention):
○ README.txt
○ a.hex
○ b.hex
○ c.hex
○ d.hex
○ e.hex
● Commit and push your repository
● Complete the Google Form with the correct commit ID of your final submission
before the due date.
Objective
The objective of this lab is to implement assembly code compliant with the RV32I
standard. You will achieve this objective using emulsiV, a visual simulator for a
simple RISC-V processor. This lab is divided into multiple parts. In each part, you
are provided a specification that you need to meet by writing said assembly code.
Breakdown
This lab is divided into FIVE parts
● a.hex : LOAD AND STORE DATA
● b.hex : LOAD, MODIFY, AND STORE DATA
● c.hex : SQUARE BY REPEATED IMMEDIATE ADDITION
● d.hex : SQUARE BY REPEATED ADDITION
● e.hex : JUMP AND LINK TO FUNCTIONS
Resources
● emulsiV: This is the simulator we will be using for this lab. This link
provides the GitHub link to the source code. You can follow the instructions
to install and run the server.
● The RISCV RV32I instruction set specifications are available in the class’
Google Drive.
● emulsiV Documentation: The documentation. This is a useful resource to go over
the capabilities of emulsiV.
Lab 3 Page 1 of 8 Winter 2022
© 2022, Computer Science and Engineering Department, University of California - Santa Cruz
Description
You are required to implement programs in emulsiV. The functionality of these
programs is described below.
● a.hex :
○ In this program, you are required to copy the first 5 characters of the
alphabet (“a”, “b”, “c”, “d”, “e”; (you need to represent them using
ASCII encoding)), from their source storage locations starting at the
address “0x00000600” to the destination storage location starting at the
address “0x00000500”. You are also required to print each character to
the “text output” (at address “0xC0000000”).
○ This program written in “C” is as follows:
○ The above code first assigns pointers to the required memory locations,
then stores the required data for the first five characters in the
source location. Then using a while loop, it loads and stores the data
from the source to the destination location.
○ You can follow a similar strategy when implementing this program using
assembly code but, you need to “store” the initial values to just as
shown when setting the array b.
○ You are to also print each character to the “text output” memory
location (“C0000000”) as you iterate through the data.
○ The text output is simply the first five characters of the alphabet as
shown below:
Lab 3 Page 2 of 8 Winter 2022
© 2022, Computer Science and Engineering Department, University of California - Santa Cruz
○ The source and destination memory locations behave in the following
manner:
Before running After running
○ Note that the values show up in hex.
● b.hex :
○ This program is similar to the program in “a.hex”. The only difference
is that you need to add the immediate value “5” to each character after
you load it from their source storage locations starting at the address
“0x00000600”. Then store the modified (value + 5) at the destination
storage location starting at the address “0x00000500”. You are also
required to print each character to the “text output” (at address
“0xC0000000”).
○ This program when written in “C” differs from the program “a.hex” as
follows:
○ The output of this program is the characters (“f”, “g”, “h”, “i”, “j”)
and the text output should look like:
Lab 3 Page 3 of 8 Winter 2022
© 2022, Computer Science and Engineering Department, University of California - Santa Cruz
○ The source and destination memory locations will exhibit the following
behavior:
Before running After running
● c.hex :
○ In this program, you are to find the square of a number by repeated
immediate addition using the “addi” instruction. The number to square is
determined by the last digit of your “studentID + 3”. For example, if
your studentID is “2345678”, the last digit is “8”. Hence you will be
squaring the number “8 + 3 = 11”. Store the result at address
“0x00000500”.
○ This program in “C” would look something like this:
Lab 3 Page 4 of 8 Winter 2022
© 2022, Computer Science and Engineering Department, University of California - Santa Cruz
○ For this particular example, the square of “11” is “121” which is
“0x79”. This is the expected value at address “0x00000500” as shown
below:
Before running After running
○ You are not required to display the result to the “text output”
(“C0000000”) for this part.
● d.hex :
○ This program is similar to the program in “c.hex”. The difference is
that instead of using the addi instruction, you will be storing the
number to square in a register and then use that to perform repeated
addition to get the result (square of the number). Once again, the
number to square is determined by the last digit of your studentID + 3.
For example, if your studentID is “2345678”, the last digit is “8”.
Hence you will be squaring the number “8 + 3 = 11”. Store the result at
address “0x00000500”.
○ The program implemented in “C” would look as follows:
○ For this particular example, the square of “11” is “121” which is
“0x79”. This is the expected value at address “0x00000500” as shown
below:
Before running After running
Lab 3 Page 5 of 8 Winter 2022
© 2022, Computer Science and Engineering Department, University of California - Santa Cruz
○ You are not required to display the result to the “text output”
(“C0000000”) for this part.
● e.hex :
○ In this program, you are to load two sequences of source data starting
at addresses “0x00000500” and “0x00000600”. There are a total of 10 data
elements (5 elements starting at each address mentioned above). These
will act as the source operands s1 and s2.
○ You are to iterate over the source data to either bitwise “XOR” or “AND”
s1 and s2 and store the result in the memory range starting at
“0x00000700”.
○ The “XOR” and “AND” will be implemented as separate functions in your
code. You will have to “JUMP AND LINK” to and “RETURN” from each of
these functions and the “main” part of your code.
○ The index of the data determines if you are to “XOR” or “AND” s1 and s2.
If the index has the Least Significant Bit “0” you need to “XOR” s1 and
s2 and if the index has the Least Significant Bit “1” you need to “AND”
s1 and s2. (In other words, if the index is even, perform “XOR”, and if
the index is odd perform “AND”. The index 0 is even, index 1 is odd, and
so on).
○ Store your source data starting at “0x00000500” : {123,165,218,97,44}.
○ Store your source data starting at “0x00000600” : {12,163,28,132,15}.
○ Store the result in the memory range starting at “0x00000700”.
○ Similar to previous parts, create pointers to the required memory
locations
○ The “C” code with equivalent functionality looks as follows:
○ Note that here, we use a call by reference to store the result.
Lab 3 Page 6 of 8 Winter 2022
© 2022, Computer Science and Engineering Department, University of California - Santa Cruz
○ You are to write the “XOR” and “AND” functionality separately and “JUMP
AND LINK” to those parts of the code and “RETURN” to the loop.
○ The “C” equivalent of the “XOR” function looks like:
○ The “C” equivalent of the “AND” function looks like:
○ Note that in the “C” code shown above, the store to the destination
memory address range (starting at “0x00000700”) is done in the function
call due to the call by reference.
○ The source and destination memory locations will exhibit the following
behavior before and after running:
Before running After running
○ You are not required to display the result to the “text output”
(“C0000000”) for this part.
Lab 3 Page 7 of 8 Winter 2022
© 2022, Computer Science and Engineering Department, University of California - Santa Cruz
For each of the aforementioned parts, you must write an RV32I compliant assembly
program to achieve the stated goal. You are required to submit the *.hex file in the
same format as downloaded using the download option in emulsiV.
Grading Rubric (total 100 points)
● 20 pt a.hex
● 10 pt b.hex
● 20 pt c.hex
● 10 pt d.hex
● 30 pt e.hex
● 10 pt README.txt in the lab3/ directory exists (empty file allowed)
● -5 pt for each file that doesn’t exactly match the file name as mentioned in
the minimum requirements (case sensitive). Do not submit unnecessary files
like readme.txt.txt or swap files.
● -5 pt for each program that is hardcoded to have the expected result at the
destination address, instead of writing code to implement the required
functionality.
Lab 3 Page 8 of 8 Winter 2022
© 2022, Computer Science and Engineering Department, University of California - Santa Cruz

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!