PA1 answer key ----------------------------------------------------------------------- 1. Are you doing your assignments on the school machines or at home? If at school what is the name of the machine you are using to answer these questions? (5 points) They just need to answer the question. ----------------------------------------------------------------------- 2. Type gcc --version on the command line. What is the output? (5 points) It should look something like the following: i686-apple-darwin9-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5484) Copyright (C) 2005 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ----------------------------------------------------------------------- 3. Does the machine you are on use the little endian or big endian representation? How did you determine that? (5 points) They should use the endian.c program you gave them in recitation to figure out endianness of their machine. You can roughly see if it matches. i686 should always be little endian. If in doubt give them the points. ----------------------------------------------------------------------- 4. Is the machine you are using 64 bit or 32 bit? How did you determine that? (5 points) I actually can't figure out how to do this. I want to see what they come up with. Give them 5 points if they at least try. They can do sizeof(long), but that is not guaranteed to always match the machine. ----------------------------------------------------------------------- 5. What are the ASCII codes for the characters in your family name? (5 points) Will be specific per person. ----------------------------------------------------------------------- 6. Show the representation of -305 (base 10) in the following representation schemes (assume 16-bit words): (a) sign magnitude, (b) one's complement, and (c) two's complement (5 points) - 1 0011 0001 (check: 1 + 16 + 32 + 256 = 305 (a) 1000 0001 0011 0001 (2 points) (b) 1111 1110 1100 1110 (1 point) (c) 1111 1110 1100 1111 (2 points) (-1 point) Did not use 16 bits. ----------------------------------------------------------------------- 7. Show the representation of 284 (base 10) in the following representation schemes (assume 16-bit words): (a) two's complement and (b) hexadecimal. (5 points) 1 0001 1100 (check: 256 + 16 + 8 + 4 = 284) (a) 0000 0001 0001 1100 (3 points) (b) 0x011C (2 points) (-1 point) Did not use 16 bits. ----------------------------------------------------------------------- 8. Show the representation of 101.5 (base 10) in the following representation schemes (assume 32-bit words): (a) binary float and (b) hexadecimal float. (5 points) 1100101.1 (check: 64 + 32 + 4 + 1 = 101) 1.1001011 x 2^6 6+127 = 133 = 128 + 4 + 1 = 1000 0101 (a) 0 10000101 10010110000000000000000 (3 points) (b) 0x42CB0000 (2 points) ----------------------------------------------------------------------- 9. What is the range of base 10 integers that can be represented with 8 bits for each of the following representations? (a) sign magnitude, (b) one's complement, and (c) two's complement. (5 points) (a) -2^(8-1)-1 <= i <= 2^(8-1)-1 -127 <= i <= 127 (1 point) (b) -2^(8-1)-1 <= i <= 2^(8-1)-1 -127 <= i <= 127 (2 points) (b) -2^(8-1) <= i <= 2^(8-1)-1 -128 <= i <= 127 (2 points)