10/30/22, 11:28 AM Quiz: ELEC1601_ELEC9601 End of Sem (practice)
https://canvas.sydney.edu.au/courses/44479/quizzes/208463/take 1/14
ELEC1601_ELEC9601 End of Sem
(practice)
Started: Oct 30 at 14:27
Quiz Instructions
1 ptsQuestion 1
A machine code must support arithmetic instructions of the
following format:
opcode, destination register, source register.
e.g. SUB, R0, R1 translates to perform the subtract R0 - R1 and
store the result in R0
The total number of different arithmetic instructions that must be
supported is 183, with 2^4 different registers. All bits for this
instruction are utilised in the encoding.
What is the minimum number of bits required for this machine
code?
1 ptsQuestion 2
10/30/22, 11:28 AM Quiz: ELEC1601_ELEC9601 End of Sem (practice)
https://canvas.sydney.edu.au/courses/44479/quizzes/208463/take 2/14
Suppose you have a circuit that implements the following truth
table:
x y z Out
0 0 0 1
0 0 1 1
0 1 0 0
0 1 1 1
1 0 0 0
1 0 1 0
1 1 0 0
1 1 1 1
Suppose you then create two instances of this circuit and wire
them up as follows (the second instance has its final input
inverted):
What is the output of the circuit if a=1, b=1, c=1?
1 ptsQuestion 3
10/30/22, 11:28 AM Quiz: ELEC1601_ELEC9601 End of Sem (practice)
https://canvas.sydney.edu.au/courses/44479/quizzes/208463/take 3/14
Study the following circuit and timing diagram (consisting of D-
type latches, D-type Flip-Flops and Logic Gates):
What is the value for Out at the highlighted times (if it cannot be
determined, write UNKNOWN)
(highlighted red) = [ Select ]
(highlighted yellow) = [ Select ]
1 ptsQuestion 4
Study the following Finite State Machine:
10/30/22, 11:28 AM Quiz: ELEC1601_ELEC9601 End of Sem (practice)
https://canvas.sydney.edu.au/courses/44479/quizzes/208463/take 4/14
p 0 words
First create a truth table showing how to compute the next state
from the current state
1 ptsQuestion 5
Edit View Insert Format Tools Table
20px Paragraph
10/30/22, 11:28 AM Quiz: ELEC1601_ELEC9601 End of Sem (practice)
https://canvas.sydney.edu.au/courses/44479/quizzes/208463/take 5/14
Assume that a memory is initialised as follows:
Memory
Address
Cell
Contents
0xC336 0x11
0xC337 0x00
0xC338 0x11
0xC339 0x11
0xC33A 0x11
0xC33B 0x00
Suppose the X register is initialised to 0xC338 and the following
commands are issued:
LD R1, X+
LD R2, X+
What is the value in R26? (Write your answer in decimal, 0 for
unknown)
1 ptsQuestion 6
Assume that a memory is initialised as follows:
Memory
Address
Cell
Contents
0x00C336 0x25
10/30/22, 11:28 AM Quiz: ELEC1601_ELEC9601 End of Sem (practice)
https://canvas.sydney.edu.au/courses/44479/quizzes/208463/take 6/14
0x00C337 0x65
0x00C338 0x60
0x00C339 0x67
0x00C33A 0x72
0x00C33B 0x44
A computer system has the value 0x00C338 in its stack pointer.
The stack grows (when you push data) towards lower memory
positions. Suppose the system executes the sequence of
instructions:
POP R1
POP R2
ADD R1 R2
MOV R2 R1
ADD R2 R2
PUSH R1
PUSH R2
PUSH R3
What value is in R3. (Write your answer in decimal. If it cannot be
computed given the above information, enter the value 0)
1 ptsQuestion 7
Suppose the following two instructions are executed:
ANDI R20, 5
BREQ Destination
10/30/22, 11:28 AM Quiz: ELEC1601_ELEC9601 End of Sem (practice)
https://canvas.sydney.edu.au/courses/44479/quizzes/208463/take 7/14
The machine code for the BREQ instruction is as follows:
1111 0000 0011 1001
Assume the following register values:
Program counter = 0x001
R20 = 0x07
What is the new value of the PC?
The relevant information for the instruction set is given below:
10/30/22, 11:28 AM Quiz: ELEC1601_ELEC9601 End of Sem (practice)
https://canvas.sydney.edu.au/courses/44479/quizzes/208463/take 8/14
1 ptsQuestion 8
Study the following code (you can assume ". . ." refers to code
that is not shown)
main:
...
LDI R27, hi8(d1) ; PC = 0x0A35, SP = 0x0B17
LDI R26, lo8(d1)
LD R18, X+
ADD R18, R18
PUSH R18
CALL subroutine1
...
10/30/22, 11:28 AM Quiz: ELEC1601_ELEC9601 End of Sem (practice)
https://canvas.sydney.edu.au/courses/44479/quizzes/208463/take 9/14
subroutine1:
POP R18 ; What is the value of the SP at this line of
code?
...
MOV R24, R7 ; result
RET
You can assume that the address of subroutine1 is 0x1A19.
What is the value of the Stack Pointer at the highlighted line of
code? (Write your answer in Decimal)
1 ptsQuestion 9
Consider the following definitions for d1, which represents a 4
byte array of integer values:
d1: .byte 0, 1, 2, 3
(1st element of the array for d1 has the value 0, 2nd element of
the array for d1 has the value 1, 4th element of the array has the
value 3)
If d1 is located in address 0x0637, what is the value of the
second element of d1 after executing the following instructions?
(Write your answer in Decimal)
LDI R27, hi8(d1)
LDI R26, lo8(d1)
LDI R19, hi8(d1)
LDI R18, lo8(d1)
ST X+, R18
10/30/22, 11:28 AM Quiz: ELEC1601_ELEC9601 End of Sem (practice)
https://canvas.sydney.edu.au/courses/44479/quizzes/208463/take 10/14
ADD R19 R18
ST -X, R19
1 ptsQuestion 10
An AVR assembly program defines the following variables and
labels:
.section .data
D1: .byte 4, 4, 4, 10
D2: .byte 7, 8
If the address of D1 is 0x109, what is the address of D2? (Write
your answer in Decimal)
1 ptsQuestion 11
What is the decimal value (base 10) held in R9 after the following
sequence of instructions?
LDI R18, 0x219
MOV R9, R18
10/30/22, 11:28 AM Quiz: ELEC1601_ELEC9601 End of Sem (practice)
https://canvas.sydney.edu.au/courses/44479/quizzes/208463/take 11/14
ADD R9, R9
1 ptsQuestion 12
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 R18, 5
PUSH R18
PUSH R10
CALL subroutine1; Call the subroutine
POP R2
POP R2
ADD R10 R2
ADD R10 R3
ADD R10 R18
...
subroutine1:
...
ADD R18 R10; Values for the registers after completion of th
is line of code are shown in the text below
PUSH R0;
RET;
Suppose at the start of the subroutine, R18 = 2, R10 = 8;
Suppose at the end of the subroutine after completion of the line
highlighted in Red: R0=4, R2=9, R18=8
What is the value stored in R10 after completion of the line
highlighted in Green? Write 0 if unknown. Write your answer in
Decimal
10/30/22, 11:28 AM Quiz: ELEC1601_ELEC9601 End of Sem (practice)
https://canvas.sydney.edu.au/courses/44479/quizzes/208463/take 12/14
1 ptsQuestion 13
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 R20, 3
LDI R21, 7
LDI R22, 7
LDI R23, 7
LDI R24, 4
PUSH R20
PUSH R21
PUSH R22
PUSH R23
PUSH R24
CALL subroutine1; Call the subroutine
...
subroutine1:
IN R31, 0x3E ; Z <- SP
IN R30, 0x3D
LDD R18, Z+4
SUB R18, R19 ; What is the value for R18 after execution of
this line is complete?
...
Reminder, the IN R31, 0x3E ; IN R30, 0x3D commands load the
stack pointer into the Z register
What is the value stored in R18 in subroutine 1 after completion
of the highlighted SUB instruction. Write 0 if unknown. Write your
answer in Decimal
10/30/22, 11:28 AM Quiz: ELEC1601_ELEC9601 End of Sem (practice)
https://canvas.sydney.edu.au/courses/44479/quizzes/208463/take 13/14
1 ptsQuestion 14
Study the following handwritten (potentially buggy) code (you can
assume ". . ." refers to code that is not shown
main:
...
LDS R25, x
PUSH R25,
CALL subroutine1 ; This instruction is at location 0x1234
POP R0,
...
subroutine1: ; This subroutine is at location 0xAB99
...
MOV R25, R8
PUSH R0
CALL subroutine2
POP R25
...
MOV R24, R7 ; result
RET
subroutine2: ; This subroutine is at location 0xAD36. No
code is missing from this subroutine
POP R0
ADD R0 R0
PUSH R0
RET
Assume the return address stored in the stack by the CALL
instruction is 3 bytes.
What is the value of the Program Counter after the RET
instruction in Subroutine 2? (Write your answer in Decimal, write
0 if unknown)
10/30/22, 11:28 AM Quiz: ELEC1601_ELEC9601 End of Sem (practice)
https://canvas.sydney.edu.au/courses/44479/quizzes/208463/take 14/14
Saved at 11:28
1 ptsQuestion 15
Suppose you have a computer system with a 4 stage pipeline and
clock period of 193 ns.
Assuming there are no pipeline stalls (no branching, no I/O
requests, no interrupts etc.), how long would it take to execute the
following instructions:
ADD R1 R2
ADD R1 R3
SUB R1 R4
Registers R1 to R4 are initialised to 5, 8, 5 and 4 respectively.
Your answer should be in ns.
Submit Quiz