IN-CLASS ASSIGNMENT (to be done outside of class for missed 2

advertisement
IN-CLASS ASSIGNMENT
(to be done outside of class for missed 2/14 and 2/15 class days)
1. Using the decimal to binary file, add a #define statement (just for this problem)
#define two 2
and replace the constant value of 2 within the program with this symbolic constant.
What do the following commands do?
a. %gcc –E –P dec2bin.c –o dec2bin
b. %gcc –c dec2bin.c
c. %gcc –S dec2bin.c
2. Lookup (http://www.oreillynet.com/linux/cmd/cmd.csp?path=g/gcc) the –O (optimization) options for the gcc
command.
a. Using the decimal to binary file, run it with each of the (4) optimization options to see if there are any
differences in the assembly code generated.
b. Run the same file with the –m32 option and all 4 optimization options to see if there are any differences in
the assembly code generated.
Explain what you found.
3. Define the following by stating what the acronym stands for and a short description of each:
a. CPU
b. PC
c. ALU
d. ISA
4. Compile/Run the int2hex.c file in the slides. What does sprintf do? What is the output?
5. Using the decimal to binary file, compile and run it with the following input to determine the output:
a. 1
______________________
f.
32
______________________
b. 2
______________________
g. 64
______________________
c. 4
______________________
h. 128
______________________
d. 8
______________________
i.
1 with 15 zeroes _____________________
e. 16
______________________
j.
1 with 20 zeroes _____________________
6. Explain why the disassembled line (given below) on page 7 of the week 6 practice problems has the highlighted hex
values in a different order in the encoded instruction (left side) versus the assembly language instruction (right side).
80483bd:
c7 44 24 1c 87 d6 12 00
movl $0x12d687,0x1c(%esp)
*** Don’t forget to do the “secret message”; page 6 of the practice problems
Download