WorksheetsCS2110 Spring 24 Final Exam Prep
Total questions: 35
Worksheet time: 20mins
Convert 42 to 8-bit unsigned binary
00101010
01010100
00101100
00100110
What is 8 in 4-bit 2's complement binary?
0000
0111
1000
You cannot represent 8 in 4-bit 2's complement binary
Given 8-bit unsigned binary numbers: A = 1001 0100 B = 0110 1101 C = 1011 1011, calculate (A & B) ^ C
(NOTE: ^ is XOR)
0000 0100
1011 1011
1011 1111
1011 0111
Which of the following bit masks will clear bit 5 of A?
A | ~(1 << 5)
A | (1 << 5)
A & ~(1 << 5)
A & (1 << 5)
Using DeMorgan's Law, find the equivalent boolean expression to: ~(~A & (B | ~C))
A & ~(B & ~C)
~A | ~(B | ~C)
A | (~B | C)
A | (~B & C)
How many of each transistor type do you need to make a NOT gate?
1 N-type, 2 P-type
1 P-type, 2 N-type
1 P-type, 1 N-type
2 P-type, 2 N-type
What type of gate is this circuit?
AND
OR
NAND
NOR
In a multiplexer with 4 inputs, we have a minimum of ___ selector bit(s) and ___ output(s)
1, 2
2, 2
4, 1
2, 1
What will the output be when A = 1, B = 1?
0
1
Which of the following shows the correct groupings for this K-map? (orange = yellow-red overlap, green = yellow-blue overlap)
Simplify the following K-map to a correct minimum boolean expression
B'C'D' + BC'D' + BCD'
B'C'D' + A'BD' + ABD'
C'D' + BD'
CD' + C'D'
(T/F) State machines are built from level-triggered components
True
False
Which of the following are examples of sequential logic? (Select all that apply)
RS Latch
Gated D Latch
D flip flop
AND gate
What is the addressability and address space of the LC3's memory?
Addressability: 16, Address Space: 16
Addressability: 16, Address Space: 65,536
Addressability: 65,536, Address Space: 16
Addressability: 65,536, Address Space: 65,536
Which of these control signals correspond to a tri-state buffer in the LC-3?
LD.MAR
ALUK
PCMUX
GateMDR
What control signals are set in the 2nd clock cycle of FETCH?
GateALU, LD.MAR, MEM.EN
GateMDR, LD.IR
GatePC, LD.MAR, LD.PC
MEM.EN, LD.MDR
Which type of control signal is used to write to various registers throughout the LC3?
Gate
MUX
MEM
LD
This data flow is used in which of the following LC3 macrostates?
FETCH
EXECUTE - LEA
EXECUTE - LD
EXECUTE - ST
What instruction should fill the given blank to make the program follow the provided pseudocode?
BRp
BRzp
BRnz
BRn
What does .fill 5 do?
Allocates 5 spots in memory
Puts 5 into R0
Put the number 5 in memory
Nothing
The following code implements which structure in LC3 assembly?
If statement
For loop
Function call
Switch Statement
Which of the instructions causes the program to not assemble?
Instruction 1
Instruction 2
Instruction 3
Instruction 4
Match each reserved register (R5-7) with its purpose
R5 - frame pointer, R6 - stack pointer, R7 - return address
R5 - stack pointer, R6 - return address, R7 - frame pointer
R5 - return address, R6 - stack pointer, R7 - frame pointer
R5 - frame pointer, R6 - return address, R7 - stack pointer
In the LC3 calling convention, which of the following are responsibilities of the callee? (Select all that apply)
Pop the return value
Save the previous return address
Allocate space for local variables
Allocate space for arguments
Set the frame pointer to the first local variable
How do we create a pointer to an integer variable x in C?
int ptr = x;
int* ptr = x;
int* ptr = *x;
int *ptr = &x;
What is the type of something in the following declaration:
int *something(struct student)[5];
Something is an array of five functions taking in student structs returning a
pointer to an int
Something is a function taking student structs and returning an array of 5
pointers to ints
Something is an array of five functions taking in student structs and returning
int pointers
Something is an array of 5 int pointers to functions taking in student structs
How can we get the value at index 2 of an array using pointers?
int arr[3] = {1, 2, 3};
&(arr + 2)
*(arr + 2)
arr + 2
*arr + 2
What does static do to a function? (ex: static func(int x))
Makes it not visible outside of its C file
Makes it not lose values between function calls
Means it was defined in another C file
Means it cannot be called multiple times
In which region of memory will a be stored?
Data
Stack
Heap
Code
In which region of memory will "b" and "d" be stored? What are their highest level of visibility?
b: data, outside of file
d: stack. within function
b: data, outside of file
d: data: outside of file
b: data, within file
d: data, within function
b: data, within file
d: data, within file
Where is the variable ptr stored? Assumes ptr is declared in a function.
Heap
Data
Code
Stack
[Choose All Correct] What are some problems with this snippet of code?
Did not null check namePtr
Cannot assume sizeof(char) = 1
Did not reserve enough space for the entire string.
should be &namePtr = myString to assign correctly
[Multi-Select] Which of the following way are valid to access "name" from s1 or s2?
s1.name
s1->name
s2->name
(*s2).name
What is the behavior of this code?
It compiles and runs without errors, printing "10" as the output.
It compiles, but the value printed may not be 10 because the memory where 10 is stored has been freed and may change unpredictably.
It compiles but crashes at runtime due to memory leak.
It does not compile due to a syntax error.
When an instance of this struct is allocated in memory, how are the struct members (name, age) typically stored?
All struct members are stored in contiguous memory locations, with name first, followed by age
Each struct member is stored in its own separate memory location, not near one another.
To optimize space usage, compiler stacks name and age together in the same memory address
