CS计算机代考程序代写 c++ assembly 5/3/2021 Submit Quiz 1 | Gradescope

5/3/2021 Submit Quiz 1 | Gradescope
https://www.grade
1/8
0/11 Questions Answered
Quiz 1
STUDENT NAME
Q1 ECS 50 S21 Quiz 1 3.5 Points
Suppose that we represent real numbers with the following fixed- point format:
Sign: 1 bit.
Integer component: 6 bits. Fractional component: 2 bits.
Which of the following values can be represented by the above format? For each value that can be represented, give the representation (as 1s and 0s) in the below text box, using the above format.
Search students by name or email…

1.58
64
−5.5
−12.125
None of the above.
No file chosen
Choose Files
scope.com/courses/256462/assignments/1202768/submissions/new

5/3/2021
https://www.grade
Enter your answer here
7
9
Submit Quiz 1 | Gradescope
Save Answer
Q2
6.5 Points
Suppose that we represent real numbers with the following floating- point format:
Sign: 1 bit.
Exponent: 4 bits. (excess-7 format; the exponents that can be represented are −710 to 810 , so they would be stored as 010 through 1510)
Mantissa: 2 bits. (implicit leading 1)
Which of the following base 10 values can be perfectly/accurately represented by the above floating-point format? Select all that apply. For each value that can be represented, give the representation (as 1s and 0s) in the below text box, using the above format.
−0.625
32768
None of the above.
Enter your answer here
Choose Files
SA
courses/256462/assi
No file chosen
scope.com/gnments/1202768/submissions/new
2/8

5/3/2021
Save Answer
Enter your answer here
Submit Quiz 1 | Gradescope
apple
Save Answer
https://www.grade
mov $5, %eax
add %eax, (%ecx)
cmp %eax, %ebx
Choose Files
scope.com/courses/256462/assignments/1202768/submissions/new
Q3
3.5 Points
Suppose that the designers of the C programming language introduced an unsigned integer type called that supported values in the range 010 to 11810 . What would be the minimum number of bits that this type needs in order to support its range of values, assuming that the number of bits must be a multiple of 4? Justify your answer.
Q4
3.5 Points
Consider the below x86-64 assembly language code snippet.
add %ebx, %eax
Executing the above code would change the values of which of the following registers: (select all that apply)
No file chosen
3/8

5/3/2021
Submit Quiz 1 | Gradescope
https://www.grade
EAX.
EBX.
ECX.
RFLAGS.
IR.
None of the above.
Save Answer
Q5
5 Points
Suppose that you made a modification to your computer to increase the speed of its secondary storage. (For example, suppose you replaced the solid state drive with a faster one.) The effect of this change is that reads from / writes to secondary storage are faster. Would this change increase the speed of compiling a C++ program on your computer? Justify your answer. You should in your justification mention why secondary storage would even need to be accessed when compiling a program.
Save Answer
Q6
3.5 Points
Enter your answer here
Choose Files
No file chosen
scope.com/courses/256462/assignments/1202768/submissions/new
4/8

5/3/2021
Submit Quiz 1 | Gradescope
Enter your answer here
Enter your answer here
https://www.grade
Suppose that unsigned integers are represented by 3 bits, meaning that the range of unsigned integers that can be represented is 010 to
710 .
If 310 and 610 are added together, how will the hardware detect that
an overflow occurred? Be specific.
Save Answer
Q7
3.5 Points
When you repeatedly write to a file (e.g. using std::ofstream in a C++ program to write to a file line-by-line), the operating system buffers these writes (in main memory) until enough writes have been done. For example, if your program does 10 writes, then the operating system may buffer these 10 writes to do them all at the same time (as opposed to doing 10 separate writes). This minimizes accesses to secondary storage and increases the program speed. However, if your computer were to unexpectedly turn off (e.g. due to a power outage, assuming you had a desktop computer), then the buffered data would be lost. Explain why the buffered data would be lost in this scenario.
Save Answer
Q8
10 Points
Choose Files
No file chosen
scope.com/courses/256462/assignments/1202768/submissions/new
5/8

5/3/2021
Submit Quiz 1 | Gradescope
For this problem, you will write an x86-64 assembly language program using AT&T syntax.
Suppose that there exists an instruction called read that expects one operand (which must be a register). This instruction prompts the user to enter an integer and places the entered integer into the register. (Disregard the fact that such an instruction would be ridiculous.) Below is an example of the instruction in use; whatever value that is entered by the user will be placed into the %eax register. (Assume that the
read instruction takes care of different register sizes and that the user will always enter an integer.)
Write a program that has a global array of six 32-bit integers called arr . This program should prompt the user to enter six integers and
put those values in arr . For example, if the user enters 8, 17, -5, 20, 19, and 5, then should have the values 8, 17, -5, 20, 19, and 5 at the end of the program, i.e. once the end label in the template shown below is reached. Below is a skeleton version to help get you started.
https://www.grade
read %eax
arr:
arr
.data
.rept 6
.long -1
.endr
.text
.globl _start
_start:
# TODO: Your code goes here.
end:
# End of program.
nop
If you use the text box, note that pressing Tab will not create spaces, unfortunately. Please do not submit to both the text box and the file upload; pick one or the other. If you end up submitting a file multiple times, make it clear with a comment at the top of the file which one is
the most recent submission, because it isn’t clear on our end. No file chosen
Choose Files
scope.com/courses/256462/assignments/1202768/submissions/new
6/8

5/3/2021
Enter your answer here
 Please select file(s) Select file(s) Save Answer
Q9
6 Points
Suppose that we are running the following x86-64 assembly language program.
.text
.globl _start
bar:
call bar
mov $8, %eax
jmp done
add $4, %eax
done:
mov $0x3, %r9d
ret
nop
Submit Quiz 1 | Gradescope
https://www.grade
Assume that when the program is run, call bar is at address 100 and each instruction takes up 4 bytes in memory (so mov $8, %eax would be at address 104, jmp done would be at address 108,
would be at address 112, etc.). Assume that, before the line is executed, the RSP is at address 1000, and
assume that each element pushed to the stack takes up 8 bytes. Answer the following questions. Do not justify your answers.
Q9.1
2 Points
add $4, %eax
call bar
scope.com/courses/256462/assignments/1202768/submissions/new
7/8
_start:

5/3/2021
https://www.gradescope.com/courses/256462/assignments/1202768/submissions/new 8/8
Submit Quiz 1 | Gradescope
When the program is about to fetch the instruction , what is the value of the RIP register?
Enter your answer here
Save Answer
Q9.2
2 Points
When the program is executing the instruction mov $0x3, %r9d , what is the value of the RSP register?
Enter your answer here
Save Answer
Q9.3
2 Points
When the program is about to fetch the instruction ret , what value is stored at the top of the stack?
Enter your answer here
Save Answer
mov $0x3, %r9d
Save All Answers Submit & View Submission 