BEST代写-线上留学生作业代写 & 论文代写专家

成立于2015年的老牌留学生代写品牌-BEST代写提供超过百门冷热门留学学科的作业和论文代写服务。全网BEST原创,高质,准时的留学生代写。

汇编代写 | Assembly & C++ 代写

汇编代写 | Assembly & C++ 代写

本次汇编代写主要有4个部分包含了assembly和C++代码的编程实现

Files to submit: combs.s
Time it took Matthew to complete: 1.5 hours (Start early. This is a time consuming problem.)

  • All programs must compile without warnings when using the -Wall and -Werror options
  • Submit only the files requested

◦ Do NOT submit folders or compressed files such as .zip, .rar, .tar, .targz, etc • If submitting in a group on Grade Scope please make sure to mark your partner.

◦ Only one of you has to submit there

  • Your program must match the output exactly to receive credit.
    • Make sure that all prompts and output match mine exactly.
    • Easiest way to do this is to copy and paste them
  • All input will be valid unless stated otherwise
  • Print all real numbers to two decimal places unless otherwise stated
  • The examples provided in the prompts do not represent all possible input you can receive.
  • All inputs in the examples in the prompt are underlined

◦ You don’t have to make anything underlined it is just there to help you differentiate between what you are supposed to print and what is being given to your program

• If you have questions please post them on Piazza

Write a program called combs.s that generates all the possible combinations of a set of items of a given size.

  1. Your program should be callable from C and have the following signature1. int** get_combs(int* items, int k, int len)
  2. This function should generate all possible combinations of items taken k at a time and return a 2-D array where each row contains one combination
    1. The combinations should be added to the 2-D array in their natural order
    2. This 2-D array should be dynamically allocated
    3. As a hint you will probably need to develop a helper function that actually computes the combinations
  3. You have been given a file called main.c that will get the inputs and call your function
    1. Your function must be callable from this file
    2. You will also find some helpful functions in main.c that you can call from your program
  4. You have also been given a makefile that should compile your program. Your program MUST be able to be compiled by this makefile.
    1. For those of you running 64 bit versions of Linux you may need to install the 32 bit binaries.
    2. The command to install on Ubuntu is: apt-get -y install gcc-multilib

4. Examples

  1. How many items do you have: 5 Enter your items: 1 2 3 4 5 Enter k: 3
    1 231 24 1 25 1 34 1 35 1 45 2 34 2 35 2 45 3 45
  2. How many items do you have: 5 Enter your items: 1 2 3 4 5 Enter k: 4
    1 2341 235 1 245 1 345 2 345

 

Files to submit: MyFloat.cpp, MyFloat.h Time it took Matthew to complete: 1 hour

  • All programs must compile without warnings when using the -Wall and -Werror options
  • Submit only the files requested

◦ Do NOT submit folders or compressed files such as .zip, .rar, .tar, .targz, etc • If submitting in a group on Grade Scope please make sure to mark your partner.

◦ Only one of you has to submit there

  • Your program must match the output exactly to receive credit.
    • Make sure that all prompts and output match mine exactly.
    • Easiest way to do this is to copy and paste them
  • All input will be valid unless stated otherwise
  • Print all real numbers to two decimal places unless otherwise stated
  • The examples provided in the prompts do not represent all possible input you can receive.
  • All inputs in the examples in the prompt are underlined

◦ You don’t have to make anything underlined it is just there to help you differentiate between what you are supposed to print and what is being given to your program

• If you have questions please post them on Piazza

1. For this assignment you will be implementing floating point add and subtract without using the hardware’s floating point or double precision add. This will give you a better understanding of how difficult they are to work with and a higher appreciation of the hardware for doing this for you. You will be turning in a file called MyFloat.cpp and its associated header file, MyFloat.h, that implements your own floating point number. This object should support both + and -.

1. You may not use floating point or double precision add in your solution. This means that you should not have the following in your program:
1. float x,y;
2. x + y;

  1. MyFloat should represent a float using three unsigned integers: sign, exponent, and mantissa.
  2. MyFloat must have the following private methods defined on it. These functions must be implemented using inline assembly.

1. void unpackFloat(float f);
1. Given a float f this function should set sign, exponent, and mantissa to the appropriate values based on the value of f. 2. float packFloat() const;

1. This function should return the floating point representation of MyFloat
3. You may declare and initialize variables to a constant in C as well as return a value but you should do no other calculations.
4. MyFloat must have the following public functions defined on it

1. MyFloat operator+(const MyFloat& rhs) const;

  1. This function should add this to rhs and return the result of the addition
  2. When adding the two numbers, the maximum amount of precision must be maintained.
    1. Before doing the addition you should restore the leading 1. This means that the mantissa will end up taking 24 bits.
    2. Since you are adding two 24 bit numbers together the result could take up to 25 bits.
    3. Be careful when shifting. Since the numbers are 32 bits, the maximum amount you can shift either left or right is 31. If you try to shift by more than this,nothing happens.

3. After doing the addition the number should be returned to its normalized form.

1. When normalizing the number we will truncate it down to the 23 most significant bits.

2. MyFloat operator-(const MyFloat& rhs) const;

  1. This function return this – rhs.
  2. The maximum amount of precision must be maintained One thing to watch out for when subtracting (or adding numbers with different signs) is that you may need to borrow. A borrow would occur if the most significant bit that is right shifted out is a
  1. The number should be returned to normalized form after adding.
  2. I highly suggest you call + after slightly modifying rhs

3. bool operator==(const float rhs) const;

1. Returns true if this represents the float on the right hand side.

  1. You have been provided with a main.cpp that will read in arguments from the command line and then call your function. Your code must be callable from main.cpp
    1. Arg1 is a floating point number
    2. Arg2 is either + or –
    3. Arg3 is another floating point number
  2. You have also been provided with a header file for MyFloat and a partially completed MyFloat.cpp.

1. Feel free to add additional methods but do not remove any.

  1. Finally you have been provided with a makefile to compile your submission. Your submission must be compilable by the given makefile.
  2. Your CPU may use a different rounding scheme than what we are using your floating point add/subtract may not match float a + b. You shouldn’t try to match the computer but should instead match my answers. If you do think I made a mistake though please let me know.

Examples

./fpArithmetic.out 10 +  7
My Add: 17
./fpArithmetic.out .5 +  .5
My Add: 1
./fpArithmetic.out 1736217621 + 0.5
My Add: 1.73622e+09
./fpArithmetic.out -5 + 5
My Add: 0
./fpArithmetic.out 100 - 50
My Subtraction: 50
./fpArithmetic.out 10.3 - 5.1
My Subtraction: 5.2

Files to submit: knapsack.s
Time it took Matthew to complete: 1.5 hours (This one is a pain in the butt to debug so start on it early)

  • All programs must compile without warnings when using the -Wall and -Werror options
  • Submit only the files requested

◦ Do NOT submit folders or compressed files such as .zip, .rar, .tar, .targz, etc • If submitting in a group on Grade Scope please make sure to mark your partner.

◦ Only one of you has to submit there

  • Your program must match the output exactly to receive credit.
    • Make sure that all prompts and output match mine exactly.
    • Easiest way to do this is to copy and paste them
  • All input will be valid unless stated otherwise
  • Print all real numbers to two decimal places unless otherwise stated
  • The examples provided in the prompts do not represent all possible input you can receive.
  • All inputs in the examples in the prompt are underlined

◦ You don’t have to make anything underlined it is just there to help you differentiate between what you are supposed to print and what is being given to your program

• If you have questions please post them on Piazza

1. Write a program called knapsack.s that solves the 0-1 knapsack problem recursively. In the knapsack problem you have a knapsack that can hold W weight. You also have a collection of items that each have their own weight wi and value vi . The goal is find the set of items that maximizes the amount of value in the knapsack but whose weight does not exceed W.

1. This program should be callable from C and have the following signature

  1. unsigned int knapsack(int* weights, unsigned int* values, unsigned int num_items, int capacity, unsigned int cur_value)
  2. This function should calculate and return the maximum value knapsack
  3. You may not have a data section
  4. This function must be implemented recursively
  5. Pay very careful attention to the types in this function as it will affect which machine instructions you should use. Hint: it will affect the jump instructions you use
  6. You have been provided with a C file called knapsack.c that implements this function and should give you a good starting point

1. If you want an extra challenge try solving the problem without looking at knapsack.c

as this problem boils down to just finding the optimal combination of items 7. You will find the leal instruction very helpful for this problem

  1. You have also been given a file called main.c that will take as a command line argument the name of a file containing a knapsack problem.
    1. Please see the comments in main.c to see how these files are structured
    2. Your function must be callable from this file
  2. You have also been given a makefile that should compile your program. Your program MUST be able to be compiled by this makefile.
    1. For those of you running 64 bit versions of Linux you may need to install the 32 bit binaries.
    2. The command to install on Ubuntu is: apt-get -y install gcc-multilib
  3. Example:

1. cat Tests/0-test.txt 100

        4
        43 43
        3 38
        5 17
        18 25
./knapsack.out Tests/0-test.txt
        123

Files to submit: matmult.s
Time it took Matthew to complete: 3.5 hours (you’ll likely be much faster. I tried using macros here and ran into a lot of problems with them)

  • All programs must compile without warnings when using the -Wall and -Werror options
  • Submit only the files requested

◦ Do NOT submit folders or compressed files such as .zip, .rar, .tar, .targz, etc • If submitting in a group on Grade Scope please make sure to mark your partner.

◦ Only one of you has to submit there

  • Your program must match the output exactly to receive credit.
    • Make sure that all prompts and output match mine exactly.
    • Easiest way to do this is to copy and paste them
  • All input will be valid unless stated otherwise
  • Print all real numbers to two decimal places unless otherwise stated
  • The examples provided in the prompts do not represent all possible input you can receive.
  • All inputs in the examples in the prompt are underlined

◦ You don’t have to make anything underlined it is just there to help you differentiate between what you are supposed to print and what is being given to your program

• If you have questions please post them on Piazza

1. Write a program called matmult.s that implements matrix multiplication in assembly. If you don’t know how to do matrix multiplication your can find a tutorial here.

  1. This program should be callable from C and have the following signature:
    1. int** matMult(int **a, int num_rows_a, int num_cols_a, int** b, int num_rows_b, int num_cols_b);
    2. This function should multiply matrices a and b together and return the result
    3. You cannot use the data section.
    4. You must allocate space for this new matrix by calling malloc
  2. You have been given a C file called main.c that accepts as command line arguments the names of two files that contain the matrices to be multiplied. main.c will read in these matrices, call your function, and then display the result. After it has displayed the result it will then free the space that has been malloced.

1. Your function must be callable by this file
3. You have also been given a makefile that should compile your program. Your program

MUST be able to be compiled by this makefile.

  1. For those of you running 64 bit versions of Linux you may need to install the 32 bit binaries.
  2. The command to install on Ubuntu is: apt-get -y install gcc-multilib

Example:

cat mata/0-test.txt
3
3
470 -192 -539
235 -814 -538
-503 -418 541
cat matb/0-test.txt
3
3
313 531 802
26 860 -767
543 870 822
./matmult.out mata/0-test.txt matb/0-test.txt
-150559 -384480 81146
-239743 -1043315 370572
125456 -155903 361902
bestdaixie

评论已关闭。