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 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.
1. Use https://www.programiz.com/c-programming/online-compiler/ as the standard strncpy() behavior reference. You can copy and past the C code snippet in page 4 into this online C gadget 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 in this online gadget.
2. Click here to refer to the formal definition of strncpy() function.
3. 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.
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 https://www.programiz.com/c-programming/ online-compiler/ as the standard strncpy() behavior reference, to evaluate your pro- gram output.
3. Good luck! Enjoy MIPS Programming. Remember to submit your coursework on time.
Rubrics Q1 Weight (100) Zero (0%) Poor (20%) Pass (40%) Good (60%) Excellent (80%) Outstanding (100%)
Basic Function
No answer or all normal test cases failed
Iterative implementation, errors in normal test cases
Iterative implementation, no error in normal test cases, errors in special test cases
Iterative implementation, no error in normal test cases, no error in special test cases, other MIPS usage errors
Iterative implementation, no error in normal test cases, no error in special test cases, no MIPS usage errors
Excellent level + special considerations in data/control hazards (Encourage self-explorations)
Basic prompt to allow user’s input
Advanced prompt to guide user’s input to ensure normal input cases
Advanced prompt to guide user’s input to ensure normal input cases and special input cases
Advanced prompt to guide user’s input and warn consequences of special input. Present informative message to let user know of special input results
Advanced prompt to guide user’s input and warn consequences of special input. Present informative message to let user know of special input results. Ensure service availability
Documentation
No comment. Very poor coding style
Few comments. Poor coding style
Insufficient comments. Good coding style
Comments on key instructions. Good coding style
Clear comments to explain the logic flow. Good coding style
Professional comments explaining program information, input/output, design considerations, etc. Good coding style
Input Test
No input test
Evidence of attempted input test, but failed
Attempted input test, only ensuring normal input
Identify one type of special input, reply with corresponding prompt
Identify and handle two types of special input, reply with corresponding prompt
Identify and handle more than two types of special input. Reply with excellent prompt for user’s next input. Exhibit intelligence
Rubrics Q2 Weight (100) Zero (0%) Poor (20%) Pass (40%) Good (60%) Excellent (80%) Outstanding (100%)
Basic Function
No answer or all normal test cases failed
There is answer, but errors in normal test cases
Iterative implementation, no error in normal test cases, errors in abnormal test cases
There is answer, no error in normal test cases, no error in abnormal test cases, other MIPS usage errors
There is answer, no error in normal test cases, no error in abnormal test cases, no MIPS usage errors
Excellent level + special considerations in data/control hazards (Encourage self-explorations)
Basic prompt to allow user’s input
Advanced prompt to guide user’s input to ensure normal input cases
Advanced prompt to guide user’s input to ensure normal input cases and abnormal input cases
Advanced prompt to guide user’s input and warn consequences of abnormal input. Present informative message to let user know of abnormal results
Advanced prompt to guide user’s input and warn consequences of abnormal input. Present informative message to let user know of abnormal results. Ensure service availability
Documentation
No comment. Very poor coding style
Few comments. Poor coding style
Insufficient comments. Good coding style
Comments on key instructions. Good coding style
Clear comments to explain the logic flow. Good coding style
Professional comments explaining program information, input/output, design considerations, etc. Good coding style
Input Test
No input test
Evidence of attempted input test, but failed
Attempted input test, only ensuring normal input
Identify one type of abnormal input, reply with corresponding prompt
Identify and handle two types of abnormal input, reply with corresponding prompt
Identify and handle more than two types of abnormal input. Reply with excellent prompt for user’s next input. Exhibit intelligence
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com