CS ECE 354 Machine Programming and Organization Summer 2022 SOLUTION Final Exam Thursday August 11th 2022 Weight 20 CLOSED BOOK TWO 8 5 x11 SHEET OF NOTES TWO SIDED ALLOWED NAME DO NOT OPEN EXAM UNTIL TOLD TO DO SO Read over the entire exam before beginning WRITE YOUR NAME ON EACH SHEET You will turn in your cheat sheet with your exam so please make sure your name is written on it Upon announcement of the end of the exam stop writing on the exam paper immediately Pass the exam to the head of the tables to be picked up by the proctor the TAs and me The instructor will announce when to leave the room Failure to follow instructions may result in forfeiture of your exam and will be handled according to the UW Academic Misconduct policy After the final please do not discuss exam questions with other students Name Section 1 Multiple Choice 40 points Please fill in the provided Scantron answer sheet for your answers to this section We will not be looking at any marking you make in this section of the exam Question 1 1 point When using gdb to debug a program you can use the step and next commands to advance the current state of the debugger If one of these commands is entered a line of output is printed Which of the following is true about that line A gdb shows all the contents of all the registers B gdb shows the line of code that was just executed C gdb shows the line of code that is about to be executed D None of the above Question 2 1 point Think back to one of the earlier projects in this course P1 P2 or P3 Each of these projects set up CI CD pipelines to automate testing of student submissions After committing changes on a local repo what action should be done in order to trigger the pipeline to be run on the GitLab server A Add local changes to local staging area B Commit local changes C View the log history of local commits D Prompt a display for the current status of the git repo E Push local commits to remote Question 3 1 point What is the largest unsigned decimal number that can be represented with 12 bits Question 4 1 point In a 7 bit one s complement system 53 will be represented by the bit pattern 0110101 What is the bit pattern for 53 in this system A 4096 B 4095 C 1024 D 1023 E None of the above A 0110101 B 1110101 C 1001011 D 1001010 E None of the above Name Question 5 1 point Is the following statement true Regardless of the numbering system unsigned one s comp signed magnitude or two s comp the number of distinct bit patterns that can be represented by a n bit system is always the same Question 6 1 point Is the following statement true Regardless of the numbering system unsigned one s comp signed magnitude or two s comp the number of distinct decimal values that are represented in a n bit system is always the same Question 7 1 point Which of the following are suitable instructions to implement a nop instruction A True B False A True B False A addl 0 eax B subq 0 rax C leaq 0 rax rdx D leaq 0 rax rax E None of the above Question 8 1 point xorq rax rax notq rax movw 0xDEAD ax movb 0xED al What is the final value of rax after the above lines of assembly execute Make no assumptions about the value of rax before the above instructions are executed A 0x0000000000000000 B 0xFFFFFFFFFFFFFFFF C 0xFFFFFFFFFFFFDEAD D 0xFFFFFFFFFFFFDEED E Cannot be determined with the information provided Name Question 9 1 point int a 0x12345678 char p 4 p 0 char a 0 p 1 char a 1 p 2 char a 2 p 3 char a 3 printf 0x x x x x n p 0 p 1 p 2 p 3 The above code snippet was compiled on a little endian machine using the m64 flag without error What is the output of running this code snippet A 0x12345678 B 0x87654321 C 0x21436587 D 0x78563412 E None of these Question 10 1 point For the mov instruction which of the following is illegal in the x86 64 AT T ISA A movq 0xFF rax B movl 8 rbp eax C movl 8 rax ebx ecx D movq rbp rax E movq rbp rax Question 11 1 point Consider the following x86 64 instruction executed on a 64 bit machine The contents of rcx constitute the divisor Where is the dividend stored idiv rcx A rcx only B rax only C rcx and rax D rdx and rax E None of the above A True B False Question 12 1 point Is the following statement true In the x86 64 AT T ISA there is no functional difference between the operation of the sal and shl instructions Name Question 13 1 point Consider the following line of x86 64 assembly pseudo code cmp b a The cmp instruction sets the CCR based on the result of what computation Question 14 1 point Consider the following line of x86 64 assembly pseudo code test b a The test instruction sets the CCR based on the result of what computation A a b B b a C a b D a b E None of the above A a b B b a C a b D a b E None of the above A True B False A rcx B rsp C rip D rbp E None of the above Question 15 1 point Is the following statement true When adding two signed numbers on an x86 64 machine two s complement binary system it is impossible for both the carry flag and the overflow flag to both be set by the addition operation Question 16 1 point When adhering to the x86 64 calling convention the register that holds a pointer to the top of the runtime stack is Name Question 17 1 point When adhering to the x86 64 calling convention the register that holds a pointer to the next instruction that will be executed is A rcx B rsp C rip D rbp E None of the above A rcx B rsp C rip D rbp E None of the above Question 18 1 point When adhering to the x86 64 calling convention the register that holds the fourth argument when a caller function is about to call a callee function is Question 19 1 point As part of the x86 64 calling a callee function may move the contents of rsp into rbp as one of the first operations in the assembly of the function If the function is not a leaf function this operation is Select the option that best fills in the blank If you believe multiple options apply select the one that is most accurate A Merely a performance operation and can be skipped B A necessary operation as instructions …
View Full Document
Unlocking...