Midterm Discussion
Midterm Discussion
TRUE
Q1: True or False
2. One byte of memory is 8 bits of data
which is enough to store 2
hexadecimal digits.
TRUE
Definition of byte
A hexadecimal digit (0,1,2,…,A,B,..,E,F)
is represented by 4 bits
Q1: True or False
3. The largest unsigned integer value
in 16 bits is 65536.
FALSE
1111111111111111 binary
16
2 -1 = 65535
Q1: True or False
4. The value 1.0 can be represented
precisely in IEEE floating point
representations.
TRUE
sign = 0
exponent = 127 – 127
fraction = 00..00
Q1: True or False
5. The 64 bit IEEE double precision
floating point representation uses an
exponent bias value of 1023.
TRUE
64 bits = 1 Sign + 11 exponent + 52 fraction
11 - 1
Bias = 2 -1
Q1: True or False
6. The x86-64 CPU register %RIP is
used to hold the instruction currently
being executed.
FALSE
RIP: Register Instruction Pointer
Holds the memory address of the next
instruction to be executed
Q1: True or False
7. The x86-64 call and ret instructions use
%RSP as an implicit operand.
TRUE
%RSP: Register Stack Pointer
call: stores the return address on the stack
before transferring control to the beginning
of the callee
ret: pops the return address from the top of
stack into %RIP and transfers control to the
point of return in caller
Q1: True or False
8. If func() is a recursive function in a C
program then all of the recursive calls
made to func() will have the same
associated return address.
FALSE
There could be more than one
recursive call in the function
Example: Postorder traversal of binary
tree
Q1: True or False
8. If func() is a recursive function in a C
program then all of the recursive calls
made to func() will have the same
associated return address.
TRUE
6
Frequency = 200 x 10 cycles/second
Period = 1/frequency = 1/(200 x 106) sec
-8
= 0.5 x 10 sec
= 5 nsec
Q1: True or False
10. The mechanism of memory
employed in a DRAM cell is related to
the amount of charge stored in a
capacitor.
TRUE
DRAM cell is a capacitor
Q2: Multiple choice
1. Which of the following statements
can be used to print out and show the
IEEE floating point representation of
the float variable f?
A printf(“%x \n”, f);
B printf(“%x \n”, (unsigned int)f);
C printf(“%x \n”, *(unsigned int *)(&f));
D printf(“%x \n”, (unsigned int *)(&f));
QUESTION CANCELLED
Q2: Multiple choice
2. Which of the following are volatile
memory?
A Magnetic hard disk
B Solid state disk
C ROM
D SRAM
D
Q2: Multiple choice
3. Which of the following values cannot
be represented in 2s complement
representation using 5 bits?
A 16
B 15
C -15
D -16
A
Range of values from 10000 to 01111
i.e., -16 to +15
Q2: Multiple choice
4. Which of the following C statements
will zero out the least significant 28
bits of unsigned int X?
A X = (X<<28)>>28;
B X = X & (~0x0FFFFFFF);
C X = X & 0xF0000000;
D X = X && 0xF0000000;
B, C
Q2: Multiple choice
5. Which of the following C for loops will show the
best locality of reference for float A[1024][1024]?
A for (int i = 1023; i >= 0; i--)
for (int k = 1023; k >= 0; k--)
sum += A[i][k];
B for (int i = 0; i < 1024; i++)
for (int k = 0; k < 1024; k ++)
sum += A[k][i];
C for (int i = 0; i < 1024; i++)
for (k = 1023; k >= 0; k--)
sum += A[i][k];
D for (int i = 0; i < 1024; i++)
for (int k = 0; k < 1024; k++)
sum += A[i][k];
16|1234
16| 77 rem 2
16| 4 rem D
16| 0 rem 4
0x4D2
Q3: Base conversion
2. Convert 1234 into the base 13
number system.
13|1234
13| 94 rem C
13| 7 rem 3
13| 0 rem 7
73C13
Q3: Base conversion
3. Convert 0x1234 into the base 4
number system.
0x1234
= 0001 0010 0011 0100 in binary
= 00 01 00 10 00 11 01 00
= 0 1 0 2 0 3 1 0 in base 4
0x020314
Q4: Representation conversion
1. Represent -1234 in the 2s
complement representation. Show your
final answer in hexadecimal.
From Q3.1
1234 = 0x4D2
= 0100 1101 0010 in binary
Invert all bits and add 1 to get
-1234 = 1011 0010 1110 in 2s comp
0xB2E
Q4: Representation conversion
2. Represent the real number 5.5 in 32 bit IEEE
floating point representation. Show your final
answer in hexadecimal.
Convert to binary
2
5.510 = 101.12 = 1.011 x 2
Sign: 0 Exp: 127+2=12910 = 100000012
Fraction: 011 0..0
Combining these bit sequences,
0 10000001 0110000000000000000000
0100 0000 1011 0000 0000 .. 0000
0x40B00000
Q4: Representation conversion
3. Represent the real value represented in
32 bit IEEE floating point as 0xC1B60000 in
decimal.
Expand 0xC1B60000
1100 0001 1011 0110 0000 .. 0000
1 10000011 0110110..000
S=1 Exponent=131 Fraction=011011
131-127
Value = - 1.0110112 x 2
= - 10110.112
= - 22.7510
Q5: Assembly code fragments
%RDI=0x80 %RSI=3 %RAX=0 %RBP=88
MEM 104 112 120 128 136 144 152
500 1000 550 2500 6000 350 10
%RAX = 1000
%RAX = 3+1000 = 1003
%RAX = 350 + 1003 = 1353
Q5: Assembly code fragments
%RDI=0x80 %RSI=3 %RAX=0 %RBP=88
MEM 104 112 120 128 136 144 152
500 1000 550 2500 6000 350 10