1/202
Exam questions, quizzes, and practice exams. Includes syllabus quiz cause Jesse might do crazy shit like that.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
What percent of your grade are midterms and the final?
60
How many classes can you miss before you have to provide formal documentation for why you miss class?
2
What are your chances of being selected to present a solution in class?
1-1 / number_students * number_questions
What do you get for a successful bug bounty call?
5 points on my lowest score group quiz or student presentation
Which of the following units is deemed harder, and requires two weeks instead of one?
Virtual Machine I
Midterm II includes material that was tested over on midterm I.
False
Where are office hours held for Johnson?
Interdisciplinary Science Building Room 406A
There is an assignment that is to be completed for January 21st.
True
Which of the following units will not be covered in class?
Operating Systems
How will I know if you've been abusing generative AI on the assignments?
You'll do poorly on the exams
What form does group work take?
Online quizzes done by a group
How much does the very good course textbook cost?
$36.14
How many unique inputs are possible in a boolean function that accepts n bits?
2^n
What is the correct notation for the logical operation xy
And
What is the correct notation for the logical operation x+y
Or
What is the correct notation for the logical operation (Bar over x)
_
x
Not
How many boolean functions can be attributed to n input bits?
2^(2^n)
What is the canonical representation of the function given on 3 input variables that results in 01010111? Assume labels for input variables are x (most significant bit), y, and z (least significant bit).
not(xy)z + not(x)yz + x not (yz) + xy not(z) + xyz
The boolean expression not(x)y+xnot(y) is equivalent to which of the following?
XOR(xy)
What is the decimal equivalent of the binary number 0101 1011? Do not use a calculator!
91
What is the sum of the binary numbers 1101 + 0111? Include any overflow bit or bits in your answer.
10100
Which is the correct output for a half-adder given inputs of 0 and 1?
sum = 1, carry = 0
Suppose you have a 16-bit input called 'b' for a chip you are building. The chip adds one to a value and is called Inc16. You'd like that input to always be (decimal) 1. Which of the following statements achieves that in HDL? In the array, the lowest index corresponds to the least significant bit.
b[0] = true, b[15] = false
To find the two's complement of a binary number, you should:
flip all the bits and then add one
Which of the following represents the integer -11 in two's compliment with 8 bits?
1111 0101
You are given the input of 4 and you need to flip the sign. What is the output to represent -4 in two’s complement?
1100
What is the result of adding the 8-bit signed binary numbers 11100101 and 01111010 in two's complement representation?
Consider the numbers to be in two's complement.
Include any overflow or carry-out bits if necessary.
01011111
In twos compliment, what is the value of not(0), irrespective of the number of bits?
-1
What is the result of taking the twos compliment representation of negative 1 AND x? Assume x is some 16 bit binary number in twos compliment form?
x
What is NOT(NOT(X)-1)? The + operator below is addition. - is subtraction.
x+1
The ALU has a zr flag to determine if the output is all zeros. Which of the following gates will be indispensable in finding zr?
Or16
The f bit of the ALU controls the operation performed on the processed inputs x and y. The operation is either AND16 or binary addition, ADD16. Which of the following is the best strategy to completing the logic with basic gates?
Compute both AND16(x,y) as well as ADD16(x,y) and use a MUX16 to determine which advances to the next stage.
Time is the key to memory. For example, the data flip-flop (DFF) upholds the following relationship:
out(t+1) = in(t)
The all-important 'bit' (storage) is a multiplexor with a DFF. Its logic is: if load(t-1) then out(t) = in(X) else out(t) = Y(t-1)
. What are the correct values of X and Y in this logic?
X = t-1, Y= out
For a RAM that holds 256 kilobytes of 64 bit words, the load line has to be how many bits?
1
For a RAM that holds 256 kilowords of 64 bit words, the address line has to be how many bits?
18
Consider the RAM8 chip you need to write. The output should be the contents of the register specified by the address line. Select the best chip for doing that.
Mux8Way16
What does the following Hack machine language code block do?
If D=0 goto 100, else goto 150
Which of the following machine language commands sets y to be a value equal to the line number or address in the instruction code?
(y)
Which of the following machine language commands sets x to a value corresponding to the location of the next free memory cell?
@x
What is the appropriate form of addressing to Set register R1 to be the constant 12
Immediate Addressing
What is the appropriate form of addressing to Set register R2 to be the contents of memory cell 55?
Direct Addressing
What is the appropriate form of addressing to Set the value of R3 to be M[M[R1]], the memory address specified in R1?
Indirect Addressing
What is the appropriate form of addressing to AND registers 1 and 3?
Only addressing registers
What is the appropriate form of addressing to Set the value of R4 to M[sp], the value of the memory cell sp?
Direct addressing
What does this machine language instruction do?
M=D
Set the contents of memory cell M[A] to register D
What does the machine language instruction do?
D=A-1
Set register D to register A minus 1
What does the machine language instruction do?
A = M
Set register A to the memory cell M[A]
What does the machine language instruction do?
D = M-1
Set the contents of register D to the value of the memory cell M[A] minus 1
What does the machine language instruction do?
AM = @17
Set the value of register A and the memory cell M[A] to 17
The C-instruction has what format?
dest = comp; jump
Which parts of a C-instruction are optional?
dest, jump
A 16-bit instruction with the leftmost bit set to 0 (e.g. 0xxx xxxx xxxx xxxx) is what kind of instruction?
A-instruction
What is the correct binary structure of a C-instruction?
A
Which of the following is NOT part of the Hack computer?
Disk Storage
Suppose you want a screen pattern of alternating black and white pixels across each row. The first (left) pixel should be black. What unsigned 16-bit number should be written to the screen's memory locations? Use a binary-to-decimal converter. LSB is leftmost!
43690
Which of the following machine language commands will color the set of 16 pixels all black? SCREEN_COUNTER stores the memory-mapped address of the current screen word. " / " here is used to indicate new line.
@SCREEN_COUNTER / A = M / M = -1
Which of the following machine language commands will advance the screen pointer to the next position for writing to the screen. " / " is new line.
@SCREEN_COUNTER / M = M + 1
Which of the following is the address of the last 16 bit word in screen?
24575
Which of the following will jump to a line of code labeled "(BLACKEN)" if a key is pressed? In this problem " / " is new line.
@KBD / D=M / @BLACKEN / D;JNE
Which of the following lines of HDL will successfully identify an instruction as an A-instruction (true if A instruction)?
Not (in=instruction[15], out=aInst);
Which of the following lines of HDL will test to see if a ALU result is positive. Assume outputs from the ALU are aluZr and aluNg of zero and negative respectively. Also assume that a ' / ' indicates a new line.
Or (a=aluZr, b=aluNg, out=zrng) / Not (in=zrng, out=aluPos)
A difficulty arises in coding the HDL for the Memory chip. The keyboard address is 0x6000 = 0110 0000 0000 0000. To devise a test to see if a memory address is this value, one should:
See if bits 14 and 13 are 1, and check that bits 0..12 are 0
Another difficulty of creating the memory chip is determining if the memory address is specifying the screen. We know that the screen begins at 16,384 and ends at 24,575. What are their hex and binary equivalents?
0x4000 = 0100 0000 0000 0000, 0x5FFF = 0101 1111 1111 1111
The test to see if an address goes to the screen and not the keyboard or RAM should be based on address bits (remember, the right most bit is bit 0):
14 and 13
How many entries will be in the symbol table prior to reading the first line of code?
23
In the Chapter 6 notes, slide 56, the comp table contains only 18 rows. Why might you need more entries in the dictionary used to represent the comp table?
The 10 extra M vs. A instructions should be added, and reversible commands should be included to avoid parsing complications.
Which of the following python commands will remove all spaces from a line of text stored in the variable line?
line.replace(" ", "")
Which of the following Python data structures is most appropriate for managing a symbol table?
dictionary
Given that line is a string variable representing a "C-command" that has been stripped of spaces, which of the following is the best strategy to break it into dest, comp, jump portions?
use line.split(x) where x will be "=" or ";" to break the line into its parts. Get the output list, check it's length, and subdivide it if needed.
What type of operation is SUB?
Binary
What type of operation is LT
Binary
What type of operation is ADD
Binary
What type of operation is NEG
Unary
What type of operation is EQ
Binary
What type of operation is GT
Binary
What type of operation is AND
Binary
What type of operation is OR
Binary
What type of operation is NOT
Unary
From the options below, select the assembly language that will set the D register to true (D = -1), or false (D = 0) based on the value in the D register being greater than 0. Assume ' / ' means new line.
@TRUE / D;JGT / @FALSE / D=0;JMP / (TRUE) / D= -1 / (FALSE)
Which of the following sequence of assembly instructions would negatate the top of the stack? Assume that ' / ' means new line and that popToD() is the Python function that produces assembly to pop the top of the stack into the D register.
@SP / A = M - 1 / M = -M
Suppose the top of the stack is y and the next thing down is x. What do the assembly instructions
"@SP
A = M-1
A = A-1
D = M
A =A + 1
D = D - M
do?
Make the D register x - y and don't change the stack pointer.
When dealing with segments, the assembly produced will be different for push and pop operations. Suppose the appropriate segment has the name "seg". Identify the appropriate assembly code for push seg and pop seg, respectively. Assume the functions pushFromD() and popToD() are implemented.
@seg / D = M / pushFromD() : popToD() / @seg / M = D
Is pointer
base address is stored in another RAM cell (pointer), mapped directly to a fixed area of RAM (fixed), or mapped to a specific symbol (symbol).
fixed
Is local
base address is stored in another RAM cell (pointer), mapped directly to a fixed area of RAM (fixed), or mapped to a specific symbol (symbol).
pointer
Is this
base address is stored in another RAM cell (pointer), mapped directly to a fixed area of RAM (fixed), or mapped to a specific symbol (symbol).
pointer
Is argument
base address is stored in another RAM cell (pointer), mapped directly to a fixed area of RAM (fixed), or mapped to a specific symbol (symbol).
pointer
Is temp
base address is stored in another RAM cell (pointer), mapped directly to a fixed area of RAM (fixed), or mapped to a specific symbol (symbol).
fixed
Is that
base address is stored in another RAM cell (pointer), mapped directly to a fixed area of RAM (fixed), or mapped to a specific symbol (symbol).
pointer
Is constant
base address is stored in another RAM cell (pointer), mapped directly to a fixed area of RAM (fixed), or mapped to a specific symbol (symbol).
other
Is static
base address is stored in another RAM cell (pointer), mapped directly to a fixed area of RAM (fixed), or mapped to a specific symbol (symbol).
symbol
If the VM encounters the line "push pointer 12", which of the following is the best explanation of what will happen?
push the contents of RAM[3+12] onto the stack
If the VM encounters the line "pop argument 3", which of the following is the best explanation of what will happen?
pop the top of the stack into RAM[RAM[2]+3]
Which of the following sequences of assembly instructions will place the memory address of 'argument 4' in the A register?
@ARG
D=M
@4
D=D+A
A=D
@ARG / D=M / @4 / D=D+A / A=D
Which of the following is a problem unique to writing assembly for VM commands of the type 'pop X index', where X is a pointer type segment?
both the address of "X index" and the thing being popped need to be stored in register D, hence a storage space must be used to prevent overwriting D.
The virtual machine language commands write machine language. In that machine language, when is ARG set after "call foo nArgs" is encountered in VM language? Chose the best answer.
After the calling frame (return address, LCL, ARG, THIS, and THAT) are all recorded.
When a function is called in the virtual machine by "call foo nArgs", what is the called function's ARG segment set to?
SP-nArgs-5
The virtual machine creates a functions with syntax "function foo nVars", where nVars is the number of local variables needed by the function "foo". When is this local segment initialized?
On entry to the called function.
The "calling frame" or set of things that the calling function records about itself before handing control over to the called functions consists of the following, in correct order.
return address, LCL, ARG, THIS, THAT
When the 'return' command in a virtual machine is encountered, what should be at the top of the stack? Where will the top of the stack be copied to as part of the implementation of "return"?
return value, ARG