Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I\'ve written the program for part 1 but am unsure how to calculate 2 and 3. Tha

ID: 3744196 • Letter: I

Question

I've written the program for part 1 but am unsure how to calculate 2 and 3.

Thank you.

1. Imagine that you are targeting an instruction set architecture that does not have an integer division or modulus operation. 1. Write a function in C that takes two signed, 32-bit integers as arguments and returns a 2-element struct containing the quotient and remainder as 32-bit integer fields. For 2. Compile your function to a target machine of your choosing and use profiling or debugging tools of your choice to determine the number of instructions executed in a single call 3. If supporting a HW divider increased cycle time by 1%, CPI is exactly 1 for all non-DIV instructions, and DIV operations accounted for 5% of all instructions, how fast would a division by zero, return [0,0] to your function. HW divider have to be to offer a better total program execution time than your SW division?

Explanation / Answer

Answer:

2) Compilation of progarm depends on the type of machie you are using i.e. Windows, GNU/Linux or Mac because compilers depend on the underlying architecture. For compiling C programs , GCC (GNU Compiler Collection) is the most common and used compiler. Under this you can compile your programs on command line using gcc (for C programs) and g++ (for C++ programs) commands. These command provide many options to compile the program. Under these commands, type of machine can be specified by specifying -mtune and -march options. These options support many values to specify cpu-type i.e. generic, native, i386, i486, pentium, core2 etc. Specific values for these options can be accessed under GCC help.

Ex.: gcc -mtune = i386 -o example example.c

For profiling and debugging you can use grpof and gdb tools respectively.

Ex.: gprof example

Using gdb:

1. Compile program with -g option.

gcc -g -o example example.c

This will allow compiler to collect degugging information.

2. Launch gdb:

gdb example

3. Set breakpoint:

break <line_number>

4. Execute program in gdb:

run [args if any]

5. print variable values in gdb:

print {variables}

6. contine as required (use c to continue, n for next or s for step).

Hope this helps you.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote