Computer Science > Final Exam Review > University of New South Wales COMP 1521 20T2. Computer Systems Fundamentals Final Exam. (All)

University of New South Wales COMP 1521 20T2. Computer Systems Fundamentals Final Exam.

Document Content and Description Below

University of New South Wales COMP 1521 20T2 Final Exam COMP1521 20T2 — Final Exam Language Documentation You may access this language documentation while attempting this test: C quick referenc... e MIPS Quick Reference Card MIPS Instruction Reference SPIM Documentation SPIM Alt. Documentation You may also access manual entries (the man command). Answer each question in a SEPARATE file. Each question specifies the name of the file to use. These are named after the corresponding question number, Make sure you use EXACTLY this file name. Submit these files using the give command as described in each question. You may submit your answers as many times as you like. The last submission ONLY will be marked. Ensure that you have submitted your files before the exam deadline. Running autotests does not automatically submit your code. Special Considerations If you experience a technical issue before or during the exam, you should follow the following instructions: Take screenshots of as many of the following as possible: error messages screen not loading timestamped speed tests power outage maps messages or information from your internet provider regarding the issues experienced You should then get in touch with us via Getting Started Set up for the exam by creating a new directory called exam_final, changing to this directory, and fetching the provided code by running these commands: This exam is covered by the Fit-to-Sit policy. That means that by sitting this exam, you are declaring yourself well enough to do so. You will be unable to apply for special consideration after the exam for circumstances affecting you before it began. If you have questions, or you feel unable to complete the exam, contact Question 1 (10 ೷೫೼೵೽) You have been given final_q1.s, a MIPS assembler program that reads one number and then prints it. Add code to final_q1.s to make it equivalent to this C program: In other words, it should read 2 numbers and print their sum. For example: No error checking is required. Your program can assume its input always contains two integers, and only two integers. You can assume the value of the expression can be represented as a signed 32 bit value. In other words, you can assume overflow/underflow does not occur. Your solution must be in MIPS assembler only. When you think your program is working you can run some simple automated tests: When you are finished working on this exercise you must submit your work by running give: Question 2 (9 ೷೫೼೵೽) Your task is to add code to this function in final_q2.c: Add code to the function final_q2 so that, given a uint32_t value, it returns 1 iff (if and only if) the least significant (bottom) byte of value is equal to the second least significant byte. final_q2 should return 0 otherwise. For example, given the hexadecimal value 0x12345678, final_q2 should return 0, because the least significant byte, 0x78, is not equal to the second least significant byte, 0x56. Similarly, given the hexadecimal value should return 1, because the least significant byte, 0x56, is equal to the second least significant byte, You must use bitwise operators to implement final_q2. You are not permitted to call any functions from the C standard library. You are not permitted to use division (/), multiplication (*), or modulus (%). You are not permitted to change the main function you have been given. You are not permitted to change final_q2's prototype (its return type and argument types). No error checking is necessary. You may define and call your own functions if you wish. When you think your program is working you can run some simple automated tests: When you are finished working on this exercise you must submit your work by running give: Question 3 (9 ೷೫೼೵೽) You have been given final_q3.s, a MIPS assembler program that reads an integer value and then prints it. Add code to the file final_q3.s so that it prints 1 iff the least significant (bottom) byte of value is equal to the second least significant byte, and prints 0 otherwise. For example, given the decimal value 305419896, which is hexadecimal, final_q3.s should print 0, because the least significant byte, 0x78, is not equal to the second least significant byte, 0x56. Similarly, given the decimal value 305419862, which is hexadecimal should print 1, because the least significant byte, 0x56, is equal to the second least significant byte, 0x56. For example: Your solution must be in MIPS assembler only. Your program can assume its input always contains one integer. No error checking is necessary. It is recommended, but not required, that you use bitwise operators. When you think your program is working you can run some simple automated tests: When you are finished working on this exercise you must submit your work by running give: Question 4 (9 ೷೫೼೵೽) You have been given final_q4.s, a MIPS assembler program that reads 1 number and then prints it. Add code to final_q4.s to make it equivalent to this C program: In other words, it should read numbers until their sum is ≥ 42 and then print their sum. For example: No error checking is required. Your program can assume its input contains only integers. Your program can assume these integers sum to ≥ 42. You can assume the value of the expression can be represented as a signed 32 bit value. In other words, you can assume overflow/underflow does not occur. Your solution must be in MIPS assembler only. When you think your program is working you can run some simple automated tests: When you are finished working on this exercise you must submit your work by running give: Question 5 Write a C program, final_q5.c, which takes two names of environment variables as arguments. It should print 1 iff both environment variables are set to the same value. Otherwise, if the environment variables differ in value, or either environment variable is not set, it should print 0. The shell command export sets an environment variable to a value; the shell command unset unsets an environment variable. In the following example, export is used to set the environment variables VAR1, VAR2 and VAR3, and unset is used to ensure environment variables VAR4 and VAR5 are unset. There is no supplied code for this question. Your program can assume it is always given 2 arguments. Your program should always print one line of output. The line of output should contain only 0 or 1. Your solution must be in C only. You are not permitted to run external programs. You are not permitted to use system, popen, posix_spawn, fork or exec. When you think your program is working you can run some simple automated tests: When you are finished working on this exercise you must submit your work by running give: Question 6 (9 ೷೫೼೵೽) We need to count the number of ASCII bytes in files. Write a C program, final_q6.c, which takes a single filename as its argument, counts the number of bytes in the named file which are valid ASCII, and prints one line of output containing that count. Assume a byte is valid ASCII iff it contains a value between 0 and 127 inclusive. - You must match the output format in the example below exactly. NOTE: There is no supplied code for this question There is no supplied code for this question. No error checking is required. Your program can assume it is always given the name of a file. Your solution must be in C only. You are not permitted to run external programs. You are not permitted to use system, popen, posix_spawn, fork or exec. When you think your program is working you can run some simple automated tests: When you are finished working on this exercise you must submit your work by running give: You have been given final_q7.s, a MIPS assembler program that reads 1 number and then prints it. [Show More]

Last updated: 1 year ago

Preview 1 out of 14 pages

Reviews( 0 )

$9.00

Add to cart

Instant download

Can't find what you want? Try our AI powered Search

OR

GET ASSIGNMENT HELP
80
0

Document information


Connected school, study & course


About the document


Uploaded On

Aug 11, 2022

Number of pages

14

Written in

Seller


seller-icon
QuizMaster

Member since 4 years

1086 Documents Sold


Additional information

This document has been written for:

Uploaded

Aug 11, 2022

Downloads

 0

Views

 80

Document Keyword Tags

Recommended For You

What is Browsegrades

In Browsegrades, a student can earn by offering help to other student. Students can help other students with materials by upploading their notes and earn money.

We are here to help

We're available through e-mail, Twitter, Facebook, and live chat.
 FAQ
 Questions? Leave a message!

Follow us on
 Twitter

Copyright © Browsegrades · High quality services·