CS代写 COMP1047: Systems and Architecture (AE1SYS) Coursework (Assessment Weight:

University of Nottingham Ningbo China
School of Computer Science
A Level 1 Module, Spring Semester 2021–2022 COMP1047: Systems and Architecture (AE1SYS) Coursework (Assessment Weight: 50%) Submission deadline: Monday 25th April 2022, 23:59:59 GMT+8
1 Synopsis

Copyright By PowCoder代写 加微信 powcoder

This coursework is about MIPS programming implementation and testing. You will imple- ment and test your code which answers the THREE (3) questions below, before submitting them in Moodle. You should develop and test your code ONLY using the MIPS simulator adopted in the lab sessions in this course, which is QtSpim (v9.1.23). The total mark of this coursework is [50 MARKS].
2 Deliverable
Submit the following FOUR (4) uncompressed files to COMP1047 Moodle page, where you
will find a submission portal to be opened later.
1. COMP1047CW-‘YourName’-‘YourID’-Q1.s for the code corresponding to Question 1. Ex-
ample: COMP1047CW-JaneDoe-20219999-Q1.s.
2. COMP1047CW-‘YourName’-‘YourID’-Q2.s for the code corresponding to Question 2.
3. COMP1047CW-‘YourName’-‘YourID’-Q3.s for the code corresponding to Question 3.
4. COMP1047CW-‘YourName’-‘YourID’-readme.txt for whatever you would like to tell the evaluator. Word count limit is 500, including all components. This item is optional.
Unable to follow the code naming convention would lead to mark deduction. Late sub-
mission rules apply, as indicated in the accompanying coursework issue sheet.

3 Plagiarism
You are gently reminded that we are at liberty to use plagiarism detection tools on your submission. Plagiarism will absolutely not be tolerated, and academic offenses will be dealt with in accordance with UNNC policy and as detailed in the student handbook. This means you may informally discuss the coursework with your classmates, but you must implement your own code and provide your own answers. DO NOT copy and paste, or paraphrase from others.
4 Assessment
1. This coursework has a total of 50 marks, which constitutes 50% of the module weight. Individual marks are shown along each question.
2. We will assess your submissions largely based on your code execution results, among other criteria. Detailed evaluation rubrics for Questions 1 and 2 are provided in Appendices 1 and 2, respectively. Evaluation rubrics for Question 3 is provided in Question 3 problem description.

Question 1 [10 Marks]
Write a program in MIPS assembly language which reads a positive integer N and prints out the following:
1 2 3 4 5 … N
Question 2 [15 Marks]
Implement a MIPS program which prompts user to enter two integer inputs M and N from the console, and calculate the following expression in signed 32-bit arithmetic:
8M3 − 24M2N + 24MN2 − 72N3
Note that you are NOT allowed to use pseudo-instructions with overflow checking for the calculation (e.g. you cannot use mulo). If an overflow occurs during any step of the calcu- lation, you should print an error message instead, and stop the program.
Hint: You could simplify the expression before calculation. Remember to test your program with a range of different inputs, for example: M = 3, N = 1; M = 3, N = −1; M = 10000, y = 1000; etc.

Question 3 [25 Marks]
Implement a MIPS version of the C function strncpy(), which is specified in the IEEE 1003.1-2017 Standard.
Background
The format of strncpy() is defined below:
char *strncpy(char *s1, const char *s2, size_t n); Quoted from the ISO description:
“The strncpy() function shall copy not more than n bytes (bytes that follow a NULL character are not copied) from the array pointed to by s2 to the array pointed to by s1. If the array pointed to by s2 is a string that is shorter than n bytes, NULL characters shall be appended to the copy in the array pointed to by s1, until n bytes in all are written. The strncpy() function shall return s1.”
Given the following C code snippet:
1 #include
2 #include
4 int main() { 5
6 char s1[10] = STRING 1;
7 char s2[10] = STRING 2;
10 strncpy(s1, s2, n);
11 printf(“%s”, s1);
13 return 0;
Note: To execute the code snippet above, you may need to replace the RED colored content by syntactically correct C code. For example:

6 char s1[10] = “Together”;
7 char s2[10] = “Future”;
8 int n = 2;
Then the program should output
Your are required to implement the MIPS assembly code that returns EXACTLY the same result as effectively calling the strncpy() function in line 10 of the code snippet above. You should not change any parts in the above code snippet, except the red colored content. No mark is awarded to this question if this requirement is not followed.
Once you execute your MIPS code, by invoking the appropriate syscall, at the QtSpim console your program should intake a single string in the following format (Px indicates Parameter x):
P1:STRING 1;P2:STRING 2;P3:N;
where the RED colored content should be replaced in the same way as the above C snippet.
For example:
P1:”Together”;P2:”Future”;P3:2;
After your code is executed based on the above input, by invoking the appropriate syscall, at the QtSpim console, your program should output the corresponding strncpy result. For the example above, the output should be:
What happens if strncpy() returns an run-time error?
At the simulator console, your program should output the following message below. Note that: you do not have to specify the error, but make sure your program generates exactly this error message whenever strncpy() generates any error message.
An error has occurred.
What happens if strncpy() returns an compile-time error? 5

My test cases will not contain inputs that lead to a compile error (or even warning). It is the job of the compiler to examine the compile error or warning, and the aim of this coursework is not writing a compiler. In other words, you can ignore the cases that cause compiler errors and warnings. They will not appear in the test cases.
1. Use the built-in gcc compiler available in our cslinux server as the standard strncpy() behavior reference. You can copy and paste the C code into cslinux and run, to obtain the referential strncpy() result. In other words, your program should output exactly the same ‘s1’ value (except errors) as the C code outputs under gcc in cslinux.
2. To access cslinux and the gcc inside, refer back to your labs in the PGA module. A manual to access cslinux via X2Go is found here. Below is a snapshot that hopefully helps you recall the usage of gcc on cslinux.
Figure 1: Demonstration of compiling and running C code on cslinux.
3. For remote students, if cslinux is unavailable, please use the OnilneGDB C compiler as the reference, similar to your PGA module practice. Kindly note that this option is only for online students.
4. Click here to refer to the formal definition of strncpy() function.
5. Feel free to post questions in Moodle Discussion Forum, or email us regarding your doubts
for clarification. Especially, with doubts in this question, contact Dr. Heng directly. 6

Evaluation
1. Out of the 25 marks for this question, TEN (10) test cases will be employed to evaluate the functionality of your program. Example test case:
.
Each correct answer is rewarded 2.5 marks. Each incorrect answer is rewarded 0 mark. Your output answer should follow exactly the output requirement given in this question, otherwise it would be deemed incorrect.
2. Again, unless otherwise specified, we will use the gcc compiler currently available in cslinux and onlineGDB (only for online students) as the standard strncpy() behavior reference, to evaluate your program output.
3. Good luck! Enjoy MIPS Programming. Remember to submit your coursework on time.

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com