CSCI 237
Computer Organization
Home | Schedule | Assignments | Links | Slack | Williams CS
The table below lists practice problems that test topics we emphasized in class. We recommend completing these practice problems to reinforce the course material in prepration for exams. Some questions have answers in the textbook, but the TAs and instructors are available to answer any questions that you have about the material. You're encouraged to work together on these problems. You can also find some solutions for unanswered questions on Glow.
| Problem | Page | Topics Covered (Notes) |
|---|---|---|
| PP1 | PP1 | Practice Problems 1 |
| - | - | How do you include libraries in C? What is the return type of main? How do you compile a C program? |
| - | - | Write a C program that takes a positive integer as a command line argument and sums together that many numbers read from stdin before printing the sum to stdout. |
| - | - | Write a C program that declares an integer array of 10 elements, initializes the elements of that array to random values between 0 and 100 inclusive (see driver.c from lab 1 for help with random number generation), prints out the contents of the array, and prints out the median value in the array to stdout. |
| PP2 | PP2 | Practice Problems 2 |
| - | - | What is the 8 digit binary representation for 15? 16? 31? 32? 255? |
| 2.17 | 65 | Converting Hexadecimal to binary representations; unsigned vs. twos-complement. |
| -- | -- | Write the 16-bit twos-complement representation of the following numbers: -1, 2864, -1573 |
| - | - | If w bits are able to store the two's complement representation of a positive whole number, can the negation of that number also be stored in w bits using two's complement representation? If w bits are able to store the two's complement representation of a negative whole number, can the negation of that number also be stored in w bits using two's complement representation? |
| 2.61 (A, B) | 129 | C and bitwise representations of integers. |
| 2.22 | 79 | Sign extension. (Equation 2.3 is on page 64) |
| 2.23 | 80 | Arithmetic shifting. |
| 2.24 | 82 | Effect of truncating on signed/unsigned. |
| 2.29 | 93 | Signed addition; overflow. |
| 2.30 | 94 | Overflow. |
| - | - | How can overflow be detected when adding/subtracting 2 unsigned numbers? 2 signed numbers? |
| 2.68 | 132 | C and bitwise representations of integers. |
| PP3 | PP3 | Practice Problems 3 |
| - | - | Why does a machine's endianness (i.e. little endian vs. big endian) matter when dealing with ints but not with chars? |
| - | - |
Consider the following C code snippet. Draw a picture of each of the variables indicating what is stored in each.
int val = 4, val2 = 0, val3 = 12; int *ptr; ptr = &val; val2 = *ptr; int **ptr2 = &ptr; val3 = **ptr2; |
| - | - |
Consider the following C code snippet. Draw a picture of each of the variables indicating what is stored in each.
int arr[4]; arr[0] = arr[1] = arr[2] = arr[3] = 0; int *ptr; ptr = arr; *ptr = 7; *(ptr+1) = 5; ptr[2] = 10; ptr = &arr[3]; *ptr = 100; |
Consider the following C code snippet. Draw a picture of what the memory associated with argv looks like when the program is invoked with the command "./hello Donuts! Yum!". Indicate what is stored in each memory cell. What will be stored in the variables c and d?
int main(int argc, char *argv[])
{
if(argc == 3){
char c = argv[1][3];
char d = argv[2][4];
}
}
|
||
| 2.45 | 111 | Binary fractional values |
| 2.47 | 117 | IEEE Floating point encoding/decoding. |
| 2.48 | 119 | Bitwise representation of floating point numbers |
| - | - |
Consider the decimal value -718.40625.
|
| - | - |
Consider the hexadecimal value 0xC295D000.
|
| - | - | Write down the binary representation of the decimal number -316.5625 assuming IEEE single-precision floating point format. |
| - | - | Why did the IEEE floating point designers choose to use biased representation for the exponent field? What is the benefit of using a biased representation instead of two's complement representation? |
| - | - | In the IEEE floating point standard, representable numbers are denser closer to zero than they are at distant locations on the numberline of representable values. Why? |
| PP4 | PP4 | Practice Problems 4 |
| 3.1 | 182 | Addressing/Operand Forms |
| 3.2 | 185 | Operand sizes |
| 3.5 | 189 | Assembly -> C conversion |
| 3.6 | 192 | Load Effective Address |
| 3.7 | 193 | Assembly -> C conversion |
| 3.8 | 194 | Arithmetic Operations |
| 3.10 | 197 | Assembly -> C conversion |
| - | - | Suppose %rsp is storing 0x100. You then push the contents of %rbx onto the stack followed by pushing the contents of %r8 onto the stack. What memory addresses are the contents of %rbx stored at? What memory address are the contents of %r8 stored at? |
| 3.58 | 311 | Assembly -> C conversion |
| 3.11(A) | 197 | Assembly Tricks |