IT代写 CSCI-UA.0201-001

CSCI-UA.0201-001
Computer Systems Organization
Midterm Exam Fall 2016 (time: 60 minutes) Last name: First name:
 If you perceive any ambiguity in any of the questions, state your assumptions clearly.

Copyright By PowCoder代写 加微信 powcoder

 Questions vary in difficulty; it is strongly recommended that you do not spend too much time
on any one question.
1. (5 points) Circle the correct answer among the choices given. If you circle more than one answer, you will lose the grade of the corresponding question.
(A) The assembler is:
1. machine dependent 2. language dependent 3. both 4. none
(B) The following number: 0x1F000001 can be interpreted as: 1. signed int 2. unsigned int
3. single precision floating point 4. all of them
(C) The instruction leal (%eax), %ebx accesses the memory:
1. once 2.twice 3. 0 times 4. depends on whether 32-bit or 64-bit
(D) Regarding instruction set architecture, backward compatibility means 1. executing old instructions on new hardware
2. executing new instructions on old hardware
3. both 1 and 2
4. none of the above
(E) Which of the following pointers has a larger size (in terms of bytes)? 1. pointer in a 32-bit machine 2. pointer in a 64-bit machine
3. pointer in a 32-bit machine pointing to an array of 100 integers

2. (2 points) assign a value to x and a value to y (you can specify them in binary) such that
a. (x && y) is evaluated to true and (x & y) is evaluated to false
b. How about the other way around?
3. [2 points] In C, like in many other languages, we need to declare a variable before we can use it. For instance, we have to declare int x; before we can use x. Why is that (state two reasons)?
4. [2 points] Suppose we have the following decimal number: -10
a) Write that number in an 8-bit binary number. To get full credit, show all the steps.
b) Translate the number you calculated in a) above to hexadecimal.

5. [2 points] Suppose x is an integer. We want to test whether the two most significant bits of x are 1 or not (i.e. the two left most bits), so we wrote the C expression:
if( …. )
{ tests successful and the two bits are 1 }
{means at least one bit of the two most significant bits is 1}
What will you put between the parenthesizes in order to test that condition?
6. Suppose that we have the following number: 0xAA
a) [1 point] Write this number in binary:
b) [2 points] Suppose that this number is interpreted as unsigned number, what is the decimal equivalent (note: you don’t have to write a final decimal number, you can leave it in the format of 2x+2y+ …). To get full score, show all the steps.
c) [2 points] Suppose that this number is interpreted as signed number, what is the decimal equivalent (note: you don’t have to write a final decimal number, you can leave it in the format of 2x+2y+ …). To get full score, show all the steps.

7. [2 points] Suppose “a” is a pointer to unsigned integer
(i.e. it was declared as unsigned int * a; ) and points to the following array of unsigned integers: {1,1,2,2,3}.
How many times the body of the following loop will be executed? Justify
while( (*a++) & 0x1 ) { …. loop body …. }

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com