[SOLVED] 代写 C MIPS assembly ECS 50: Program #2

30 $

File Name: 代写_C_MIPS_assembly_ECS_50:_Program_#2.zip
File Size: 386.22 KB

SKU: 1990523330 Category: Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Or Upload Your Assignment Here:


ECS 50: Program #2
Prof. Joël Porquet
UC Davis, Fall Quarter 2019
•1 Changelog
•2 General information
•3 Programs
•4 Submission
•5 Academic integrity
1 Changelog
Note that the specifications for this project are subject to change at anytime for additional clarification. Make sure to always refer to the latest version.
•v3: Refine constraints for temperature conversion
•v2: Fixed coin change’s output
•v1: First publication
2 General information
•Due before 11:59 PM, Friday, November 1st, 2019
•You are to work alone for this programming assignment
•The reference work environment is the CSIF, and the MIPS simulator spim
2.1 Objectives of the assignment
The objectives of this programming assignment are:
•Writing three high-quality assembly programs.
•Using some of the most essential ALU instructions.
•Learning how to use the floating-point coprocessor available in the MIPS32 processors.
•Using some of the control flow constructs, such as if-then, and while loops.
2.2 Assessment
Your grade for this assignment will be broken down in several scores:
•Auto-grading: ~75% of grade
Running an auto-grading script that tests your program and checks the output against various inputs
•Manual review: ~25% of grade
The manual review is itself broken down into different rubrics:
◦Quality of implementation: ~20%
◦Coding style: ~5%
3 Programs
3.1 Additional information and constraints for all the programs
•Your programs should use named constants when possible, instead of hardcoded numerical values directly in the code.
•For returning from the main function, at the end of your code, use instruction jr $31.
•For all three programs, compiled C references runnable on Linux are available on CSIF in directory /home/cs50jp/public/p2. They should show what is the expected output for different inputs, so that you can compare with your assembly implementations.
3.2 Coin change
3.2.1 Introduction
The Coffee House at UC Davis is looking for a way to help cashiers give back students their change when they buy food at the different venues.
Figuring out which coins correspond to a certain amount of cents is a tedious task that could be easily computed by a program. For example, if 42 cents have to be given back, the customer should receive one quarter (25¢), one dime (10¢), one nickel (5¢) and two pennies (2 x 1¢).
3.2.2 Program
Write assembly program coin_change.s that converts an amount of cents into the appropriate coins, as illustrated in the following example.
$ echo 42 | spim -f coin_change.s
Amount of cents to change: 42
Number of quarters: 1
Number of dimes: 1
Number of nickels: 1
Number of pennies: 2
$ echo 99 | spim -f coin_change.s
Amount of cents to change: 99
Number of quarters: 3
Number of dimes: 2
Number of nickels: 0
Number of pennies: 4
$ echo 0 | spim -f coin_change.s
Amount of cents to change: 0
Number of quarters: 0
Number of dimes: 0
Number of nickels: 0
Number of pennies: 0
$
3.2.3 Additional information and constraints
•It is assumed that the user input should always be correct (for example, the inputted amount of money can never be a negative number) and that the program should always succeed.
3.3 Fahrenheit to Celsius
3.3.1 Introduction
I grew up using the Celsius scale for temperature and although I am slowly getting used to the Fahrenheit scale, it remains difficult sometimes. I thought it would be great to have a program that converts Fahrenheit temperatures into Celsius temperatures. The exact conversion formula is as follows:

3.3.2 Program
Write program f_to_c.s that converts Fahrenheit temperatures into Celsius temperatures, as illustrated in the following example.
$ echo 42 | spim -f f_to_c.s
Temperature in Fahrenheit is: 42
Temperature in Celsius is: 5.55555534
$ echo 99 | spim -f f_to_c.s
Temperature in Fahrenheit is: 99
Temperature in Celsius is: 37.22222137
$ echo 0 | spim -f f_to_c.s
Temperature in Fahrenheit is: 0
Temperature in Celsius is: -17.77777863
$ echo -20 | spim -f f_to_c.s
Temperature in Fahrenheit is: -20
Temperature in Celsius is: -28.88888931
$
3.3.3 Additional information and constraints
•The Fahrenheit temperature should be read as an integer value and the resulting Celsius temperature should be computed as a single precision value.
•Since floating point operations are significantly more expensive than integer operations (both in terms of time and power consumption), you should try to keep their number as small as possible.
•The entire conversion process has to be done at runtime. You cannot store some precalculated parts of the equation directly in memory.
•The MIPS offers a floating-point unit (in coprocessor 1) that operates on single precision and double precision floating-point numbers. We focus only on single precision here.
◦The FP coprocessor has its own set of 32 registers, numbered $f0 to $f31. Note that, unlike $0, $f0 has no peculiarity.
◦A single precision floating-point value can be loaded directly from memory using instruction l.s.
◦A word can be moved between a processor register and an FP register using instructions mtc1. Note that when using this instruction, the transferred word retains its exact bit representation, so if the word was an integer, it is not automatically converted to a floating-point representation.
◦If an FP register contains an integer value, it can be converted into a floating-point value (and vice-versa) using the family of instructions cvt.[sdw].[sdw].
◦When printing a float value with the corresponding syscall, the value to be printed must be located in FP register $f12.
•The constant values that you need for this program for converting the Fahrenheit temperature into a Celsius temperature must be allocated in memory within the data section, and loaded from memory dynamically upon using them.
3.4 Character binary representation
3.4.1 Introduction
You have been contracted to design a program that gives the description of a character supplied by the user. There are 4 properties to output:
1.Is the character an uppercase letter?
2.Is the character a lowercase letter?
3.Is the character a vowel?
4.Is the character an hexadecimal digit?
The description should be printed in binary format, each binary digit representing one of the four properties: 1 if the property is true and 0 if the property is false.
3.4.2 Program
Write program char_desc.s that prints the 4 properties of any inputted character, as illustrated in the following example.
$ echo a | spim -f char_desc.s
Description of character ‘a’ is 0b0111
$ echo J | spim -f char_desc.s
Description of character ‘J’ is 0b1000
$ echo 1 | spim -f char_desc.s
Description of character ‘1’ is 0b0001
$ echo + | spim -f char_desc.s
Description of character ‘+’ is 0b0000
$
3.4.3 Additional information and constraints
•The resulting string must be printed with only one syscall. This means that the string needs to be completed at runtime with the input character and each bit of the description. Here is the incomplete string you can start with in your data section:
result: .asciiz “Description of character ‘ ‘ is 0b

•

The string can be completed by making memory stores at the proper offset from the beginning of the string, located at label result.
•Determining the properties must be done in a distinct computational phase, such as shown in the C equivalent below.
#define UPPER_FLAG 0x8
•#define LOWER_FLAG 0x4
•…
•desc = 0;
•if (isupper(c))
•desc |= UPPER_FLAG;
•if (islower(c))
•desc |= LOWER_FLAG;
•…

•The conversion of the description word into the binary representation in ASCII must be done in a distinct conversion process, such as shown in the C equivalent below.
// N is the offset to the LSB in the result string
•for (int i = 0; i < 4; i++) {•result[N – i] = (desc & 1) + ‘0’;•desc >>= 1;
•}

4 Submission
Gradescope will be opened for submission on Wednesday, October 30st at 0:00. At that time, you will be able to submit your programs and have them be autograded.
5 Academic integrity
You are expected to write this project from scratch. Therefore, you cannot use any existing source code available on the Internet.
You are also expected to write this project yourself. Asking anyone someone else to write your code (e.g., a friend, or a “tutor” on a website such as Chegg.com) is not acceptable and will result in severe sanctions.
You must specify any sources that you have viewed to help you complete this assignment (e.g., at the end of your source code). All of the submissions will be compared with MOSS to determine if students have excessively collaborated, or have used the work of past students.
Any failure to respect the class rules, as explained above or in the syllabus, or the UC Davis Code of Conduct will automatically result in the matter being transferred to Student Judicial Affairs.

Copyright © 2019 Joël Porquet

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] 代写 C MIPS assembly ECS 50: Program #2
30 $