12/11/2021, 10:14 Quiz: ELEC1601/ELEC9601 Final Exam https://canvas.sydney.edu.au/courses/29226/quizzes/119941/take?preview=1 1/15 ELEC1601/ELEC9601 Final Exam This is a preview of the published version of the quiz. Started: Nov 12 at 10:10 Quiz Instructions 1 ptsQuestion 1 A computer encodes integers that lie in the range [ -81; 120 ] using two's complement numbers. How many bits are required to represent these numbers? 1 ptsQuestion 2 A computer system has 2^17 bytes of memory, where addresses are encoded using 13 bits; how many bytes are there per memory cell? 1 ptsQuestion 3 Complete the truth table for the following boolean function: 12/11/2021, 10:14 Quiz: ELEC1601/ELEC9601 Final Exam https://canvas.sydney.edu.au/courses/29226/quizzes/119941/take?preview=1 2/15 A B C out 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 ( +C) + C(A+B) ′ B ′ A ′ 1 ptsQuestion 4 Study the following combinational digital circuit: What is the value of Out1 when A = 0 and B = 1? 1 ptsQuestion 5 12/11/2021, 10:14 Quiz: ELEC1601/ELEC9601 Final Exam https://canvas.sydney.edu.au/courses/29226/quizzes/119941/take?preview=1 3/15 Study the following circuit and timing diagram: What is the values for Out1 and Out2, during clock cycle 1 just after the falling clock edge? Assume gates have negligible delay Out1 = [ Select ] Out2 = [ Select ] 1 ptsQuestion 6 Select all registers in the AVR architecture that are changed over the course of the following instruction: LD R28, -X You can assume: R28 initially has the value 4, The address referenced by X contains the value 1 The address referenced by X+1 contains the value 0 The address referenced by X-1 contains the value 2 12/11/2021, 10:14 Quiz: ELEC1601/ELEC9601 Final Exam https://canvas.sydney.edu.au/courses/29226/quizzes/119941/take?preview=1 4/15 program counter status register 'X' Register R1 in register file instruction register 'Y' Register 1 ptsQuestion 7 System B Both finish at same time System A Not enough information to answer question Suppose there are two computer systems: System A has a 3 stage pipeline, and clock period of 50ns, System B has a 5 stage pipeline, and clock period of 30ns. Assume both systems receive their first instruction at the same time, which system will be the first to complete the first instruction, assuming no pipeline stalls? 1 ptsQuestion 8 A computer system has the value 0x333 in its stack pointer. The stack grows (when you push data) towards lower memory positions. Suppose the system executes the sequence of instructions: PUSH R4 12/11/2021, 10:14 Quiz: ELEC1601/ELEC9601 Final Exam https://canvas.sydney.edu.au/courses/29226/quizzes/119941/take?preview=1 5/15 PUSH R5 PUSH R6 POP R1 POP R2 What is the value of the stack pointer after this sequence? (If it cannot be computed given the above information, enter the value 0) 1 ptsQuestion 9 Consider the 16 bit encoding used in the AVR architecture shown in the following figure: Assume the following values: R3 = 3 R19 = 51 The instruction being executed (in machine code is): 0011 0011 0011 0011 After the instruction: R3 has the value: (write this as a decimal value) R19 has the value: (write this as a decimal value) 12/11/2021, 10:14 Quiz: ELEC1601/ELEC9601 Final Exam https://canvas.sydney.edu.au/courses/29226/quizzes/119941/take?preview=1 6/15 ( ) The Z flag in the status register has the value: 1 ptsQuestion 10 Status Register Program Counter Instruction Register Stack Pointer R1 in register file 'X' Register Suppose the following command is executed: jmp someSubroutine Assume that the address of someSubroutine is held in the 'X' Register Select all registers in the AVR architecture that are modified during this instruction: 1 ptsQuestion 11 Consider the following definitions in an assembly program: d1: .byte 0, 1, 2, 3 If d1 is located in address 0xC33D, what is the value stored in that position after executing the following instructions? LDI R27, hi8(d1) LDI R26, lo8(d1) LDI R19, hi8(d1) 12/11/2021, 10:14 Quiz: ELEC1601/ELEC9601 Final Exam https://canvas.sydney.edu.au/courses/29226/quizzes/119941/take?preview=1 7/15 LDI R18, lo8(d1) ST -X, R18 1 ptsQuestion 12 An AVR assembly program defines the following variables and labels: .section .data D1: .byte 3, 6, 2 D2: .byte 10, 6, 4 What is the result if we subtract the address number of label D1 from the address number of label D2 1 ptsQuestion 13 How many bytes are reserved in memory if an AVR assembly program has the following data section: .section .data .byte 0x21, 0x2, 0x31 .space 90, 8 1 ptsQuestion 14 12/11/2021, 10:14 Quiz: ELEC1601/ELEC9601 Final Exam https://canvas.sydney.edu.au/courses/29226/quizzes/119941/take?preview=1 8/15 What is the decimal value (base 10) held in R9 after the following sequence of instructions? LDI R18, 0x36 MOV R9, R18 SUB R9, R18 1 ptsQuestion 15 From the program memory From one field of the instruction From the data memory From the register file. Consider the AVR assembly instruction: LDS R12, label, (label has been defined in the data section). Where is the microprocessor getting the operand loaded in R12? 1 ptsQuestion 16 Register X contains an address with value 0x012F. 12/11/2021, 10:14 Quiz: ELEC1601/ELEC9601 Final Exam https://canvas.sydney.edu.au/courses/29226/quizzes/119941/take?preview=1 9/15 The values in Data memory at addresses 0x012E, 0x12F and 0x0130 are 0x05, 0x05 and 0x08 respectively. What is the value of Register 13 after the following instructions? LD R12, X+ LD R13, X- (write the base10 equivalent) 1 ptsQuestion 17 Suppose a program invokes a subroutine. The subroutine requires 8 input parameters and 7 global variables to operate. Assume the parameters are passed to the subroutine and result returned through the stack. The result is 1 byte. After the subroutine call, you wish to discard all input parameters and store the result in R20. How many times should you execute the command POP R20 after returning from the subroutine? 1 ptsQuestion 18 Study the following program It was generated by the compiler avr-gcc that uses the AVR libc library, so obeys the convention for register management LDI R5, 1 LDI R20, 2 12/11/2021, 10:14 Quiz: ELEC1601/ELEC9601 Final Exam https://canvas.sydney.edu.au/courses/29226/quizzes/119941/take?preview=1 10/15 LDI R21, 3 PUSH R21 CALL my_subroutine ; Call the subroutine POP R20 The result of the subroutine call was the integer 0x5123. State the values (in base 10) in each of the following registers after the end of this section of code. If unknown, type UNKNOWN. R5: R20: R21: R24: R25: 1 ptsQuestion 19 Suppose a subroutine receives 5 1 byte parameters, returns a 1 byte result, and the return address occupies 3 bytes. Internally, the subroutine needs 2 local register. The subroutine returns a 1 byte result via the stack. The program was generated by the compiler avr-gcc that uses the AVR libc library, so obeys the convention for register management Once in the subroutine, at the first instruction, what is the required displacement (in bytes) from the top of the stack to the memory location where the result will be stored? 12/11/2021, 10:14 Quiz: ELEC1601/ELEC9601 Final Exam https://canvas.sydney.edu.au/courses/29226/quizzes/119941/take?preview=1 11/15 1 ptsQuestion 20 Study the following code (you can assume ". . ." refers to code that is not shown main: ... LDS R25, x CALL subroutine2 ... PUSH R25, CALL subroutine1 POP R0, ... subroutine1: ... MOV R25, R8 CALL subroutine2 ... MOV R24, R7 ; result RET subroutine2: ... RET How many calls to subroutine 2 are made in this code fragment (you can assume that there all subroutine calls are shown in this code? 1 ptsQuestion 21 Study the following Boolean Expressions: Show how this could be implemented on the following device: F = ( )(A+B+C) ′ (A (B+ ))C ′ ′ ′ G = +CB ′ 12/11/2021, 10:14 Quiz: ELEC1601/ELEC9601 Final Exam https://canvas.sydney.edu.au/courses/29226/quizzes/119941/take?preview=1 12/15 Upload Draw your answer, take a picture and upload it Choose a File 1 ptsQuestion 22 Imagine a door lock that is password protected. It has two inputs, ‘x’, ‘y’, and a reset button. The user can only press one input at a time. To open the door, a user must first press the reset button. The user can then enter one of two codes to unlock the door: ‘x’, ‘y’, ‘y’, ‘x’ or y’, ‘x’, ‘y’, ‘x’ After the door has been unlocked, after 30 seconds it is automatically re-locked. 1. Draw the state transition diagram for the finite state machine (FSM) encoding such a system. It must include the value of the inputs and output (door unlocked or door locked). Try to use as few states as possible. Take a picture of your final drawing and upload this to Canvas 12/11/2021, 10:14 Quiz: ELEC1601/ELEC9601 Final Exam https://canvas.sydney.edu.au/courses/29226/quizzes/119941/take?preview=1 13/15 Upload Choose a File 1 ptsQuestion 23 Consider the following fragment of code written in a high level programming language: int data[5] = {15, 25, 36, 12, 50}; int result = 0; int count = 0; while (count < 5) { result = my_function(result, data[count]); count = count + 1; } Write a sequence of AVR assembly instructions equivalent to the previous code. You can assume my_function is written elsewhere. You do not need to write this, but you can access it by calling the subroutine. .segment .data data: .byte 15, 25, 36, 12, 50 result: .space 1, 0 count: .byte 0 12/11/2021, 10:14 Quiz: ELEC1601/ELEC9601 Final Exam https://canvas.sydney.edu.au/courses/29226/quizzes/119941/take?preview=1 14/15 p 0 words > 1 ptsQuestion 24 Complete the following program that monitors the status of a sensor connected to digital PIN 5 (copy, then fill in gaps. Note that you do not need to fill in every gap). The program should achieve the following: When the sensor is not active, the program makes an LED connected to PIN 9 flash off and then on for half a second each and the message SENSOR DOWN is sent to the serial communication link at 9600bps. When the sensor is active, the LED should change its current value (if it is off, it should change to on), then hold for 2 seconds and send the message SENSOR UP through the serial communication link. //Global variable declarations bool sensor_on = false; (gap 1) .................................. (gap 2) .................................. void setup() { (gap 3) .................................. (gap 4) .................................. (gap 5) .................................. } void loop () { (gap 6) if (..................................) { (gap 7) .................................. (gap 8) .................................. (gap 9) .................................. (gap 10) .................................. } else { (gap 11) .................................. (gap 12) .................................. (gap 13) .................................. (gap 14) .................................. (gap 15) .................................. (gap 16) .................................. (gap 17) .................................. (gap 18) .................................. } } Edit View Insert Format Tools Table 12/11/2021, 10:14 Quiz: ELEC1601/ELEC9601 Final Exam https://canvas.sydney.edu.au/courses/29226/quizzes/119941/take?preview=1 15/15 No new data to save. Last checked at 10:14 p 0 words > Submit Quiz 12pt Paragraph
欢迎咨询51作业君