2020 Computer Architecture Final

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

D

Study the following circuit. Use the final page of this exam as a reference if you do not recall the graphical representation of fundamental gates. Circle the choice that describes the values of the output lines if the circuit represented is a half-adder. A. XXX = sum and YYY = carry B. XXX = a and YYY = b C. XXX = load and YYY = sel D. XXX = carry and YYY = sum E. XXX = sel and YYY = load

B

An HDL program consists of header and parts sections. In the header section, the program: A. Only contains comments about the chip. B. Specifies the name of the chip and the names of the inputs and outputs of a chip. C. Defines the more primative chips that will be used to build the chip. D. Both B and C. E. None of A through D.

A

Assume that 3, 5, and 7 were pushed onto the stack in that order before a function with 3 arguments and 2 local variables was called. What will be in the local segment after the following VM code completes? Potential answers are listed beginning at local 0. push argument 2 pop local 1 push constant 5 push argument 1 neg pop local 0 a. -5, 7 b. 10, 3 c. -5, 5 d. -5, 3 e. 0, 7

B

Assume that the inputs to the gate are as follows: x y 0 0 0 1 1 0 1 1 What are the corresponding outputs of the "if y then x" gate, also expressed a x + NOT(Y)? A. 1101 B. 1011 C. 0001 D. 0110 E. 0111

return address, local, argument, this, that

When a function is called in the virtual machine, 5 things are pushed onto the stack. List 4 of them.

D

When only one copy of a variable is shared by all objects having the variable, what is this variable labeled? A. private B. int C. var D. static E. field

C

When writing Hack machine language, which of the following refers to the contents of the memory address stored in register A? A. D B. R C. M D. A E. *A

D

Which is true of the Jack high level language? A. it is a functional language, like LISP B. it is a strictly procedural language like C C. it is a scripting language, like Python D. it is an object oriented language, like Java E. it is an assembly language for communicating directly with the hardware

C

Which of the following Hack assembly language command sequences will place the contents of R12 in the R10 register? Assume "," is a new line character. A. @R12,D=A,@R10,M=D B. @R12,A=M,@R10,M=A C. @R12,D=M,@R10,M=D D. @R10,D=M,@R12,M=D E. @R12,D=A*,@R10,M=A*

C

Which of the following can not be achieved with a single C-instruction on the Hack platform? A. Set the D register to 1. B. Set the A register to -1. C. Load 27 in to the A register. D. Set the D register to the contents of the memory cell specified in the A register. E. Both b and c.

C

Which of the following can not be preformed in a single ALU operation? A. add B. subtract C. logical xor D. negation E. logical or

D

Which of the following happens in the first pass of the assembler? A. Add label and RAM addresses of next line to the symbol table when @label is encountered. B. Add label and ROM addresses of current line to the symbol table when (label) is encountered. C. Add label and ROM addresses of next line to the symbol table when @label is encountered. D. Add label and ROM addresses of next line to the symbol table when (label) is encountered. E. None of the above.

D

Which of the following is an aspect of the standard mapping of the Hack computer? a. The stack frame consists of return address, LCL, ARG, THIS, and THAT. b. The gt operator determines if x>y where y is at the top of the stack and x is one position below y. c. Functions are called using the syntax 'call f n'. d. The heap begins at RAM address 2048 and ends at 16383. e. The constant segment is virtual.

D

Which of the following is not computable in a single ALU operation? Assume the 16 bit inputs of the ALU are x and y. A. output 1 B. compute x+1 C. compute x-y D. compute !x+1 (not x plus 1) E. compute -x

D

Which of the following is not in the Jack standard library? A. Array B. String C. Keyboard D. File E. Math

BASE ADDRESS IS POINTER

argument

"VIRTUAL" SEGMENT HAS NO BASE ADDRESS

constant

C

On the Hack platform, controlling input or output devices like a screen or keyboard is done by: A. writing to and reading from a file B. writing to and reading from special areas of ROM C. writing to and reading from special areas of RAM D. calling a library that is provided by the text book authors E. clicking the correct icon in the hardware simulator

A

Study the following circuit. Use the final page of this exam as a reference if you do not recall the graphical representation of fundamental gates. Circle the choice that describes the function of this set of more primitive gates. A. Xor B. Not C. If D. And E. Register

D

Which primitive data type is not supported by the Jack high level language? A. char B. int C. boolean D. float E. void

C

@sum M=0 @R0 D=M @i M=D (LOOP) @i MD=M-1 // decrement the counter @FINISH D;JLT @R1 D=M @sum M=D+M // tally the sum @LOOP 0;JMP (FINISH) @sum D=M @R2 M=D (END) @END 0;JMP Why is the destination of the line that has the comment // decrement the counter both M and D and not just M? A. M-1 will be copied to M B. This always has to be done when decrementing a memory cell. C. The contents of the D register is going to be used for the jump condition two lines later. D. This line of code is actually wrong, it should just be M for the destination. E. The value in D will have to be set to R1 and this prepares for that.

C

A chip is being developed that has 2 input bits and 2 output bits. How many different boolean functions could this chip compute? Warning: the two column output should be considered with care. A. 8 B. 128 C. 256 D. 512 E. 1024

C

Consider the following Hack assembly code to multiply two numbers. The following two questions refer to it. @sum M=0 @R0 D=M @i M=D (LOOP) @i MD=M-1 // decrement the counter @FINISH D;JLT @R1 D=M @sum M=D+M // tally the sum @LOOP 0;JMP (FINISH) @sum D=M @R2 M=D (END) @END 0;JMP When is the label (FINISH) jumped to? A. When MD=M-1 B. When R2=sum C. When i<0. D. When i=0. E. When sum = M

B

Consider the following Hack machine language commands: @4 D = A @sum A = D + A M = 0 Which of the following best describes what this code does? A. this sets the memory cell sum to 4 B. this sets a cell 4 positions beyond sum or, sum[4] to 0. C. this sets the memory cell sum to the contents of sum plus 4 D. this sets the memory cell sum to 0 E. this moves the contents of memory cell sum to a memory cell 4 cells beyond the memory cell sum.

D

Correctly handling the virtual machine command pop static index Requires information beyond the index and the name of the segment. What information is that? a. A value that tells the VM this is the nth static variable to occur in the file. b. A unique label that can be concatenated to the index as the value is stored in RAM. c. The value in RAM[6], called STATIC. d. The name of the file that is currently being parsed in the VM. e. The value of the argument pointer, ARG.

C

In the Hack machine language, the ability to use a command like @LOOP before the (LOOP) label declaration in the assembly program is thanks to the A. fact that the program counter feeds directly from the A register B. fact that the order of HDL statements is insignificant C. two-pass assembly process D. multi-purpose use of the A register E. subsequent VM translation process

A

How does the assembler manage labels it encounters in the code? A. in a symbol table B. in a linked list C. in a graph D. in an array E. in a binary tree

A

How many bits are input to and output from a 1-bit register? A. 2 in, 1 out B. 1 in, 1 out C. 1 in, 2 out D. 2 in, 2 out E. 3 in, 1 out

E

How many bits are input to and output from a RAM8 chip (stores 8, 16 bit words)? A. 16 in, 1 out B. 16 in, 16 out C. 17 in, 16 out D. 18 in, 16 out E. 20 in, 16 out

D

How many bits does a hexadecimal symbol represent? How many hexadecimal symbols are required to represent an instruction on the Hack platform? A. 2 and 4, respectively. B. 4 and 8, respectively. C. 4 and 6, respectively. D. 4 and 4, respectively. E. 8 and 2, respectively

C

In a 1-bit storage unit you have two inputs, load and in. There is one output, out. If load(t-1) is true then: A. out(t) = in(t) B. out(t) = load(t) C. out(t) = in(t-1) D. out(t) = load(t) E. out(t) = out(t-1)

ARM has a dedicated register, whereas Hack pushes the instruction address to the stack

In a single sentence, contrast how the ARM platform maintains the location to go to after a called function returns to the way it is done on the Hack platform.

C

In the Hack assembly language, a C-instruction's destination is specified by: A. the contents of the A register always contains the destination B. the previous instruction, which would be an A-instruction C. there are three bits within the C-instruction that specify the destination D. as part of the ALU control portion of the C-instruction E. it is inferred from the previously defined label

A

In the Hack machine language, the ability to use a command like @label before the label was actually declared in the program is thanks to the A. two-pass assembly process B. fact that the program counter feeds directly from the A register C. fact that the order of HDL statements is insignificant D. multi-purpose use of the A register E. subsequent VM translation process

C

In the Jack high level language, what does the expression 2+3*4 evaluates to? A. 20 B. returns an error C. 14 or 20 but it's impossible to know which D. 14 E. 24

17 16 6 22

In the following Hack assembly program, enter into the blank spots the numerical value the assembler will assign the label that appears to the left of the blank. 1: @n // n = 0 2: M=0 3: 4: @100 // addr = 100 5: D=A 6: @addr 7: M=D 8: 9: (Loop) // do { 10: @n // RAM[addr] = n 11: D=M 12: @addr Answer 13: A=M 14: M=D 15: 16: @addr // addr = addr+1 17: M=M+1 18: 19: @11 // n = n+11 20: D=A 21: @n Answer 22: MD=M+D // (tricky: also leaves new 'n' value in D) 23: 24: @99 // } while n <= 99 25: D=D-A 26: @Loop Answer 27: D;JLE 28: 29: @Halt Answer 30: (Halt) 31: 0;JMP

This is the right Mux

In the following diagram of the Hack CPU, circle the control bit or bits (the circled 'C's) corresponding to a portion of the C-instruction that specifies if the contents of the A register are interpreted directly as a number, or "dereferenced" to provide the contents of the memory address specified by the A register

Two lines to the output control of the ALU, label them zero and negative

In the following diagram of the Hack CPU, draw a line(s) from the control bit(s) of the PC to the their source. Label the line or lines that you've drawn with appropriate descriptions of the bit(s).

Circles around LOOP, FINISH, END boxes around (sum, i)

Inspect the following assembly code. Circle all the lines of code that result in a value being added to the symbol table in pass one. Put an asterix to the right of all the lines of code that result in a value being added to the symbol table in pass two. @sum M=0 @R0 D=M @i M=D (LOOP) @i MD = M - 1 @FINISH D;JLT @R1 D = M @sum M = D + M @LOOP 0;JMP (FINISH) @sum D=M @R2 M=D (END) @END 0;JMP

Named registers static variables stack heap memory mapped I/O

Label each section of the Hack computer's memory in the below table.

argument, this, that, local, temp, pointer, constant, static

List at any 6 of the 8 memory segments that can be named in virtual machine code.

B

On the Hack platform, controlling input or output devices like a screen or keyboard is done by: A. writing to and reading from a file B. writing to and reading from special areas of RAM C. writing to and reading from special areas of ROM D. calling a library that is provided by the text book authors E. clicking the correct icon in the hardware simulator

D

Push and pop operations involving segments always have the syntax : push/pop segment index Except for constant, which is a virtual segment, and static, the syntax is meant to identify a memory address by doing the arithmetic segment base + index and using that as a RAM address to pop to or push from. The arithmetic segment base + index can be done in Python, and not assembly, for which of the following segments? There is only one correct answer. a.this b.local c.argument d.pointer e.that

Can have multiple languages that are translated to the same virtual machine. The virtual machine is tailored to the hardware, not the compiler. Stack based computing is very powerful. The improvements to the virtual machine are shared by all virtual machine compilers, making for a modular design.

State 3 advantages of using a virtual machine approach over compiling high level language directly to binary code.

B

Study the following circuit. Use the final page of this exam as a reference if you do not recall the graphical representation of fundamental gates. Assume inputs are: a b 0 0 0 1 1 0 1 1 and the outputs in the choices correspond to the inputs, top to bottom.Which of the following describes the outputs based on the inputs. A. 0101 B. 0100 C. 0010 D. 0110 E. 1001

@RETURN_HERE D=A @SP A=M M=D @SP M =M+1

Suppose that RETURN_HERE is a label for a ROM address, created by the assembly line (RETURN_HERE) that is found elsewhere in the code. Write code that will push the RETURN_HERE ROM address to the stack, as you would when calling a function. You CAN NOT assume that you have 'pushD()' type function available to you and instead must write the instruction to push to the stack.

B

Suppose that you have a program counter in the following state at t-1: in = 67, inc = 0, load = 1, out[t-1] = 55, reset = 0. What will out[t] be? A. 0 B. 67 C. 68 D. 55 E. 56

D

Suppose that you have a program counter in the following state at t-1: in = 67, inc = 1, load = 0, out[t-1] = 55, reset = 0. What will out[t] be? A. 67 B. 68 C. 0 D. 56 E. 55

These are the jump bits of a C-instruction. They have to be run through some logic with the ALU out (zero, negative, positive) in order to determine if the jump takes place.

The design of the CPU, done in the CPU.hdl project, involved mapping bits from instruction to their proper location in a CPU for control of the CPU units. Refer to the diagram above. What is (are) the bit(s) that go to the program counter? Answer in as much detail as possible.

This is just the bit that indicates if it is an A-instruction.

The design of the CPU, done in the CPU.hdl project, involved mapping bits from instructions to their proper location in a CPU for control of the units. Refer to the diagram above. What is (are) the bit(s), or portion of an instruction, that goes to the left-most multiplexor? Answer in as much detail as you can.

The CPU registers A,D and memory location specified by register A, which is referred to as M.

The destination field of a C-instruction can be one of three places, and combinations of those three places. List the three places that ALU output can be written in the destination. Be specific about where each location is physically located in the computer.

M = D

The following instructions push the contents of register D onto the stack. Complete the instructions by stating the line of assembly language that should replace XXX. @SP, A=M, XXX, @SP, M=M+1

1

The following is a listing of one of the test directories for testing the virtual machine to assembly program. How many output files are produced if the program is called on this directory? $ ls FunctionCalls/StaticsTest/ Class1.vm Class2.vm StaticsTest.cmp StaticsTest.tst StaticsTestVME.tst Sys.vm

E

The following is a table that summarizes the memory chips implemented in Chapter 3, Sequential Logic. n is the number of 16 bit words stored on the chip and k is the width of the address bus. What are the values of a,b, and c (repectively) in this table? A. 6, 13, 14 B. 6, 12, 13 C. 7, 13, 15 D. 5, 11, 13 E. 6, 12, 14

A

The following line of Python code has had the logic that causes it to execute removed. Based on the code, determine which of the following VM language lines will cause this Python code to execute. return ('@%d, D=M,'%(5 + int(index)) + getPushD()) a.push temp 2 b.push argument 2 c.push static 2 d.push that 2 e.push constant 2

B

The hardware simulator used in this course is A. An HDL program B. A program which is written in some high-level language C. A script program D. Answers (a)-(b)-(c) are correct E. All the answers are wrong

E

The majority of the bits in a C-instruction are for A. specifying the destination B. specifying the jump condition C. a number that is stored in the A register D. unused bits E. specifying the ALU's operation

D

The so-called canonical representation depends on only three fundamental gates to represent a truth table. What are those three gates? A. AND, OR, NAND B. NOT, AND, XOR C. NOT, NAND, XOR D. AND, OR, NOT E. NOT, NOR, AND

C

The virtual machine syntax for calling a function is call f n, where f is the label associated with the function. What is n? A. the number of local variables used by the function B. the argument of the function C. the number of arguments passed to the function D. the location of the stack pointer E. the starting memory location of the arguments passed to the function

A

The virtual machine syntax for declaring a function is function f k, where f is the label associated with the function. What is k? A. the number of local variables in the function B. the number of arguments passed to the function C. the size of memory needed by the function D. the memory address of the function that called the function E. the position of the stack pointer minus 5

Arithmetic, memory, functions, and flow control

To implement the virtual machine, four essential types of commands were identified. Two were implemented in chapter 7, and the other 2 were implemented in chapter 8. List to four major types of VM commands here.

B

What are the smallest and largest numbers that can be represented with twos complement of n bits. Hint: for four bits, 1000 is the smallest number and 0111 is the largest. A. −2^n − 1, 2^n B. −2^(n−1) , 2^(n−1) − 1 C. −2^(n−1) − 1, 2^(n−1) D. −2^(n−1) + 1, 2^(n−1) − 1 E. −2^n, 2^n − 1

D

What data structure does the virtual machine use for computations? A. Queue B. Symbol table C. Binary search tree D. Stack E. Dictionary

E

What is at the top of the stack after this sequence of stack operations? push 39 push 5 push 7 push 4 add mult eq A. 55 B. 39 C. True (-1) D. 32 E. False (0)

A

What is the chip described in the following HDL code? IN a, b; OUT out; PARTS: Not (in=a, out=nota); Not (in=b, out=notb); Nand (a=nota, b=notb, out=out); A. Or B. XOr C. And D. Not E. Mux

C

What is the data structure that we rely on to deal with labels and symbols in Hack assembly language? A. array B. list C. symbol table D. queue E. stack

E

What is the primary data structure used in virtual machine computing? A. array B. list C. symbol table D. queue E. stack

C

What should be the result of running the assembler on a file that contains the command (R8)? A. R8 will be added to the symbol table with the next available RAM address. B. R8 will be added to the symbol table with the appropriate ROM address for the line. C. The assembler will report an error on the first pass through the code. D. The assembler will report an error on the second pass through the code. E. This line will be skipped by the assembler.

D

What sort of code is produced by the preprocessor? A. Assembly language. B. Object code (binary) C. Virtual machine code D. High-level language code E. Pseudo-code

B

What were the three high level components of the Hack computer, as implemented by you in the Computer.hdl file? A. ROM, CPU, Registers B. RAM, ROM, CPU C. ALU, CPU, RAM D. Program Counter, ALU, Registers E. ROM, RAM, ALU

B

What will be at the top of the stack, and how many entries are in the stack (respectively) after the following set of operations are performed on an initially empty stack? push 4 push 8 gt push 8 push 5 pop push 12 sub push 4 eq or a. true, 2 b. false, 1 c. true, 1 d. false, 2 e. 4,1

D

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 for zero and negative results, respectively. Also assume that a ';' indicates a new line. A. Not (in=AluNg, out=aluPos); B. Or (a=aluZr, b=aluNg, out=zrng); And(a=zrng,b=aluNg out=aluPos); C. Nand (a=aluZr, b=aluNg, out=zrng); Not (in=zrng, out=aluPos); D. Or (a=aluZr, b=aluNg, out=zrng); Not (in=zrng, out=aluPos); E. And (a=aluZr, b=aluNg, out=zrng); Not (in=zrng, out=aluPos);

C

Which of the following provides a complete summary of a boolean function's inputs and outputs and is often the clearest expression of a combinational logic chip's requirements? A. De Morgan's law B. boolean algebra C. truth table D. Hardware Description Language (HDL) E. formulas

B

Which of the following represents the canonical representation of the following boolean function:

D

Which of the following represents the integer -11 in twos compliment with 8 bits? A. 1110 0101 B. 1110 1101 C. 1111 1110 D. 1111 0101 E. 1111 1001

E

Which of the following sequence of assembly instructions would negate 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. A. @SP, A = M, M = -M B. @SP, M = -M C. @SP, A = M, M = -A D. @SP, A = M - 1, M = -A E. @SP, A = M - 1, M = -M

B

Which of the following statements about the Hack ALU is wrong? A. The efficiency of the ALU is related to the efficiency of the Adder chip B. The ALU implementation is based on sequential logic C. The ALU is eventually based on a set of Nand gates D. The ALU can compute a fixed set of functions on its two 16-bit inputs E. The ALU is part of the computer's CPU

E

Which of the following statements about the Hack ALU is wrong? A. The efficiency of the ALU is related to the efficiency of the Adder chip. B. The ALU is ultimately based on a set of Nand gates. C. The ALU can compute a fixed set of functions on its two 16-bit inputs. . D. The ALU is part of the computer's CPU. E. The ALU is a "clocked" chip.

B

Which of the following twos complement representations of a number, when added to 37, results in 0? A. 1101 1110 B. 1101 1011 C. 1110 1011 D. 1101 1010 E. 1111 1110

D

Which of the following will jump to a line of code labeled (BLACKEN) if a key is pressed? In this problem "," is new line. Recall that the ASCII value of the key is placed in a special RAM location when a key is pressed, otherwise that location contains zero. A. @SCREEN,D=M,@BLACKEN,D;JNE B. @SCREEN,D=M,@BLACKEN,D;JGT C. @KBD,D=M,@BLACKEN,0;JNE D. @KBD,D=M,@BLACKEN,D;JNE E. @KBD,D=M,@BLACKEN,D;JLT

D

Which of these can be learned by considering the status flags of the ALU designed in this course? A. the result is negative B. there has been overflow C. the result is zero D. choice A and C only E. choices A, B and C

E

Why does the virtual machine language we specified force us to include k in the declaration of functions? Where the syntax is: function f k where f is a function name. a. k is the number of arguments. The k is is to make sure space is allocated for them on entering the fuction. b. k is the number of local variables and if you take the position of the stack pointer minus k, minus 5, you get the location of ARG, which is needed for putting the return value in the correct place. c. k is the number of arguments. The k let's the function know how many arguments have been pushed to the stack. d. k is the number of local variables and k locates the start of the LCL segment in the stack. e. k is the number of local variables in the function. k is the number of zeros to be pushed onto the stack on entry into the function.

@y D=M @5 D=D-A @REPEAT D;JLE

Write Hack assembly language code to execute the following psuedo-code: if (y<=5) goto REPEAT Where REPEAT is a ROM label. You may assume that y will be a RAM symbol.

if the add the label to the symbol table with the line number.

Write a sequence of pseudocode instructions detailing what is done in the assembler on pass 1 when a label is encountered.

1. if it is in symbol table, replace code with address. 2. if it is not in symbol table, add it to the symbol table with next available memory address.

Write a sequence of pseudocode instructions detailing what is done in the assembler on pass 2 when a symbol is encountered.

AM=M-1

Write the single line of Hack assembly to complete the following code that pops the stack to the D register. Do so by stating what XXX is. Don't forget to move the stack pointer! @SP XXX D=M

A

You have to implement the VM language presented in this course. Which of the following virtual segments is the easiest to handle? A. constant B. static C. local D. argument E. this

BASE ADDRESS IS POINTER

local

BASE ADDRESS IS A SPECIFIC RAM ADDRESS

pointer

BASE ADDRESS IS DETERMINED BY FILENAME

static

BASE ADDRESS IS A SPECIFIC RAM ADDRESS

temp

BASE ADDRESS IS POINTER

that

BASE ADDRESS IS POINTER

this


संबंधित स्टडी सेट्स

ECON: Oligopoly/Game theory Terms

View Set

Legal Concepts of the Insurance Contract

View Set

Algebra 2 Honors Semester 1 Review

View Set

Week 1: Nature of Anthropology, Sociology, and Political Science

View Set

A separate peace chapter 5-10 discussion quiz

View Set

Basiswissen Geschichte 15 (Erster Weltkrieg)

View Set

Social Science - Chapter 2, 3, and 10

View Set