程序代写代做代考 mips C assembler 2020/7/11 COMP1521 20T2 ¡ª Week 05 Weekly Test Questions

2020/7/11 COMP1521 20T2 ¡ª Week 05 Weekly Test Questions
Week 05 Weekly Test Questions Test Conditions
These questions must be completed under self-administered exam-like conditions. You must time the test yourself and ensure you comply with the conditions below.
You may complete this test in CSE labs or elsewhere using your own machine.
You may complete this test at any time before Tuesday 14 July 21:00.
Weekly tests are designed to act like a past paper – to give you an idea of how well you are progressing in the course, and what you need to work on. Many of the questions in weekly tests are from past final exams.
Once the first hour has finished, you must submit all questions you’ve worked on.
You should then take note of how far you got, which parts you didn’t understand.
You may choose then to keep working and submit test question anytime up to Tuesday 14 July 21:00
However the maximum mark for any question you submit after the first hour will be 50%
You may access this language documentation while attempting this test: C quick reference
You may also access manual entries (the man command).
Any violation of the test conditions will results in a mark of zero for the entire weekly test component.
Set up for the test by creating a new directory called test05, changing to this directory, and fetching the provided code by running these commands:
Or, if you’re not working on CSE, you can download the provided code as a zip file or a tar file.
$ mkdir test05
$ cd test05
$ 1521 fetch test05
:
MIPS Minimum
In the files for this lab, you have been given min.s, a MIPS assembler program that reads 2 numbers and then prints 42. Add code to min.s to make it equivalent to this C program:
https://cgi.cse.unsw.edu.au/~cs1521/20T2/test/05/questions 1/5

2020/7/11 COMP1521 20T2 ¡ª Week 05 Weekly Test Questions
// print the minimum of two integers #include
int main(void) {
int x, y;
scanf(“%d”, &x);
scanf(“%d”, &y);
if (x < y) { printf("%d\n", x); } else { printf("%d\n", y); } return 0; } In other words it should read 2 numbers and print the smaller number. For example: $ 1521 spim -f min.s Loaded: /home/cs1521/share/spim/exceptions.s 5 8 5 $ 1521 spim -f min.s Loaded: /home/cs1521/share/spim/exceptions.s 118 26 26 $ 1521 spim -f min.s Loaded: /home/cs1521/share/spim/exceptions.s 42 42 42 When you think your program is working you can autotest to run some simple automated tests: When you are finished working on this exercise you must submit your work by running give: In the files for this lab, you have been given not13.s, a MIPS assembler program that reads 2 numbers and then prints 42. Add code to not13.s to make it equivalent to this C program: $ 1521 autotest min $ give cs1521 test05_min min.s : MIPS Counting (but not 13) https://cgi.cse.unsw.edu.au/~cs1521/20T2/test/05/questions 2/5 2020/7/11 COMP1521 20T2 ¡ª Week 05 Weekly Test Questions // print the integers between x and y except 13 #include
int main(void) {
In other words it should read 2 numbers and print the numbers between them, except it doesn’t print 13. For example:
$ 1521 spim -f not13.s
Loaded: /home/cs1521/share/spim/exceptions.s 5
8
6
7
$ 1521 spim -f not13.s
Loaded: /home/cs1521/share/spim/exceptions.s 10
15
11
12
14
$ 1521 spim -f not13.s
Loaded: /home/cs1521/share/spim/exceptions.s 5
14
6
7
8
9
10
11
12
Assumptions/Limitations/Clarifications
You can assume the first number read is not greater than the second number.
When you think your program is working you can autotest to run some simple automated tests:
When you are finished working on this exercise you must submit your work by running give:
In the files for this lab, you have been given square.s, a MIPS assembler program that reads a number and then prints 42. Add code to square.s to make it equivalent to this C program:
$ 1521 autotest not13
$ give cs1521 test05_not13 not13.s
:
MIPS Squares
int x, y;
scanf(“%d”, &x);
scanf(“%d”, &y);
Test Complete!
int i = x + 1;
Your time for this test has finished. You must submit your work now. You should reflect
while (i < y) { if (i != 13) { on how you went in this hour, and discuss with your tutor if you have concerns. You printf("%d\n", i); may}choose to keep working, but the maximum mark for any questions you submit i = i + 1; } return 0; } later will be 50%. https://cgi.cse.unsw.edu.au/~cs1521/20T2/test/05/questions 3/5 2020/7/11 COMP1521 20T2 ¡ª Week 05 Weekly Test Questions In other words it should read a numbers and print a square of asterisks of that size. For example: $ 1521 spim -f square.s Loaded: /home/cs1521/share/spim/exceptions.s 3 *** *** *** $ 1521 spim -f square.s Loaded: /home/cs1521/share/spim/exceptions.s 4 **** **** **** **** $ 1521 spim -f square.s Loaded: /home/cs1521/share/spim/exceptions.s 7 ******* ******* ******* ******* ******* ******* ******* Assumptions/Limitations/Clarifications You can assume the number read is positive (> 0).
When you think your program is working you can autotest to run some simple automated tests:
When you are finished working on this exercise you must submit your work by running give:
When you are finished each exercise make sure you submit your work by running give.
You can run give multiple times. Only your last submission will be marked.
Don’t submit any exercises you haven’t attempted.
If you are working at home, you may find it more convenient to upload your work via give’s web interface. Remember you have until Tuesday 14 July 21:00 to complete this test.
$ 1521 autotest square
$ give cs1521 test05_square square.s
Submission
// print a square of asterisks #include
int main(void) {
int x;
scanf(“%d”, &x);
int i = 0; while (i < x) { int j = 0; while (j < x) { printf("*"); j = j + 1; } i = i + 1; printf("\n"); } return 0; } https://cgi.cse.unsw.edu.au/~cs1521/20T2/test/05/questions 4/5 2020/7/11 COMP1521 20T2 ¡ª Week 05 Weekly Test Questions Automarking will be run by the lecturer several days after the submission deadline for the test, using test cases that you haven't seen: different to the test cases autotest runs for you. (Hint: do your own testing as well as running autotest ) Test Marks After automarking is run by the lecturer you can view it here the resulting mark will also be available via via give's web interface or by running this command on a CSE machine: The test exercises for each week are worth in total 1 marks. The best 6 of your 8 test marks for weeks 3-10 will be summed to give you a mark out of 9. COMP1521 20T2: Computer Systems Fundamentals is brought to you by the School of Computer Science and Engineering at the University of New South Wales, Sydney. For all enquiries, please email the class account at cs1521@cse.unsw.edu.au CRICOS Provider 00098G $ 1521 classrun -sturec https://cgi.cse.unsw.edu.au/~cs1521/20T2/test/05/questions 5/5