ECS 50 (Spring 2021) Quiz #1 Changelog
• v.1: Initial version.
Remarks
• Please don’t ask me questions along the lines of, “How much partial credit will I get if I answered in this way or that way?” You’ll find out once it’s all graded.
• There may be – and for some questions, definitely will be – different correct answers besides the ones shown below.
Solutions
Q1
• -5.5. Representation: 100010110
Q2
• 7. Representation: 0100111
• -0.625. Representation: 1011001
Q3
Were it not for the requirement that the number of bits be a multiple of 4, then the answer would be 7, since 2ˆ7 = 128, meaning that 7 bits would allow us to represent 128 unsigned integers. However, due to the requirement, the final answer is 8.
Q4
• EAX.
• RFLAGS. • IR.
Q5
Yes, because the following accesses to secondary storage occur when compiling a program:
• Reading the C++ source file and any dependencies (e.g. header files) of this file.
• Reading the compiler program and any files the compiler program depends on.
• Writing to the executable file.
1
• (I’m sure there are other examples I’m missing here.)
These accessed to secondary storage will have been sped up by the hardware changes.
Q6
011 and 110 will be added, producing 001 with a carry out of 1. This carry out bit will tell the hardware that an unsigned arithmetic overflow occurred.
Q7
As stated in the problem, the data is buffered in RAM, which is volatile. When the computer is shut off (for whatever reason), any data in volatile memory is lost, and this would include the buffered data.
Q8
Below is one solution.
.data
arr:
.rept 6
.long -1
.endr
.text
.globl _start
_start:
mov $0, %r12d
loop:
# loop counter
cmp $24, %r12d
jge end
read %eax
mov %eax, arr(%r12d)
add $4, %r12d
jmp loop end:
# End of program.
nop
Q9 Q9.1 116
2
Q9.2
992
Q9.3
104
Copyright Statement
This content is protected and may not be shared, uploaded, or distributed.
3