Cs270 Final updated 3.0

¡Supera tus tareas y exámenes ahora con Quizwiz!

What character in C will give you the remainder of an integer division? What character in C will give you the quotient of an integer division?

% /

A not gate is implemented with what?

1 p-type and 1 n-type MOS transistors.

Which of the following instructions move the value in R5 into R6? 1) 0001 1101 0110 0000 2) 0101 1101 0111 1111 3) 1001 1101 0111 1111

1, 2

A Multiplexer selects one of four 16-bit registers and lets its contents pass through. How many Select lines are needed for selection.

2, since with two bits we can specify four choices.

A Multiplexer selects one of four 32-bit inputs as its 32-bit output. How many Select lines are needed for selection.

2, since with two bits we can specify four choices.

Convert the unsigned decimal integer 176 to base 9. (enter only digits that are valid in base 9 with no leading zeroes)

215

Convert the unsigned decimal integer 188 to base 9.

228

Convert the unsigned decimal integer 188 to base 9. (enter only digits that are valid in base 9 with no leading zeroes)

228

unning the following command ./testConv a2i 16 and then entering FE will return what value? (enter only the integer value)

254

What is the result of 0x2591 | 0x00FF in hex

25FF

A decoder with n inputs can have no more than _____ outputs.

2^n

Mux consists of ____ inputs and _____ select lines.

2^n / n

After the following C code segment is executed, what will the value of x be? int x; x = 10.2 / 3;

3

Assuming symbol_term calls symbol_reset how many additional frees will symbol_term need to preform to free all remaining allocated memory?

3

At any time there are exactly ______ transistors in a open state in a 2 input AND gate.

3

The number of memory accesses performed during the processing, i.e., entire instruction cycle, of the STI instruction is?

3

What is the hexadecimal representation of the binary number 0b100011001110? 0x

8CE

A fictitious alphabet has 410 symbols. If you wanted to assign a unique bit pattern to each symbol, what is the minimum number of bits you will need to represent all 410 symbols?

9

A school has 408 students. If you wanted to assign a unique bit pattern to each student, what is the minimum number of bits you will need in order to represent all 408 students?

9

What is the hexadecimal representation of the binary number 0b100111111101? 0x

9FD

A + AB = ...

A

AB + BA' = ...

A

(A'B')' equals...

A + B

If the first argument passed to the comparison function used by qsort should be sorted so it appears before the second argument passed to the comparison function, the comparison function will return what when comparing the two arguments?

A negative number

Which of the following is/are specified by the ISA of LC-3? (Multiple answers may apply) a. Encodings of opcodes b. Number of adders in an LC-3 processor c. Data types d. Number of general purpose registers

a, c, d

as Cache size increases...

access time /\ Capacity Misses \/

A single assembly language name for an opcode can be translated into two machine language codes

False

A stack is a First In First Out data structure

False

ANDing a value with a mask can result in the output having more bits set to '1' than the original value.

False

Accessing a value in a register is slower than accessing a value in memory.

False

All C functions must take at least one input parameter.

False

An I/O device can signal the microprocessor when it needs to interact with it. This form of interaction is known as polling.

False

Bits [11:0] of the RET instruction specify the address to return to.

False

Calling char_to_int() with the radix 10 and the char 'A' will return the integer 10.

False

During the setup for an interrupt the Program Counter (PC) Register is pushed onto the supervisor stack so that when the interrupt routine is complete the RTI instruction can return the condition code, priority level, and privilege to the state they were in before the interrupt. (Hint what is the purpose of the PC?)

False

During the setup for an interrupt the Program Status Register (PSR) is pushed onto the supervisor stack so that when the interrupt routine is complete the RTI instruction can set the Program Counter to the address of the instruction that was about to execute before the interrupt occured. (Hint: what is the purpose of the PSR?)

False

Every line of a C program should end with a semicolon.

False

Have you studied Boolean algebra? If A is TRUE, B is FALSE, then A AND B is

False

If using the provided debug framework you must remove all debug statements before turning in you code.

False

In C we can have at most one pointer pointing to any variable.

False

In a stack implemented in memory with a stack pointer, the data entries move after each operation performed on the stack.

False

In structured programming, one must enter a processing box at exactly one entrance point, but can leave the processing box at up to 4 exit points, depending on the nature of the processing being performed.

False

In the past 40 years latency for a memory access has improved more than the bandwidth of the memory transfer

False

It is likely that a program written in a (low level) language for one ISA will also run on a computer having a different ISA.

False

Order of magnitude clock speed increases and similar increases in chip power levels are seen as ways to improve processor performance in the future​

False

P is false Q is true What is the value of the expression P and (Q and not Q)

False

P is false What is the value of the expression P and not P

False

P is true Q is true What is the value of the expression P and (Q and not Q)

False

P is true What is the value of the expression P and not P

False

The Trap routine OUT, which writes a single character to the display, expects R0 to contain an address corresponding to the location of the character. After incrementing this address the eventually a null terminator will be found and end the printing of characters.

False

The concept of caching is only used for increasing the average time it takes a processor to access data in main memory.

False

The declaration of a variable as a struct is one of the constructs of structured programming.

False

The reason for caches is memory speed improvements have not kept pace with memory improvements over the last ~40 years

False

To use type FILE requires including the string.h header file

False

You can successfully turn in a file called Numconv.c to the checkin server.

False

The '.' operator may be substituted for the -> operator. False malloc returns a block of memory initialized to 0. False

False False

Over the last ~40 years processor performance has increased __________ than memory performance. During this same period bandwidth has improved at a _________rate than than latency.

Faster | Faster

Match the term to its position in the instruction cycle, what is the first instruction cycle?

Fetch

Match the term to its position in the instruction cycle, what is the fourth instruction cycle?

Fetch Operands

Order of Von Neumann model (F, D, EA, FO, EO, SR)

Fetch, Decode, Evaluate Address, Fetch Operands, Execute Operation, Store Result

Given this output from Valgrind at what file and what line is causing the invalid read? ==28069== Invalid read of size 8 ==28069== at 0x400C93: symbol_search (symbol.c:106) ==28069== by 0x400D0D: symbol_add (symbol.c:118) ==28069== by 0x401165: main (testSymbol.c:154)

File: symbol.c Line: 106

Sequential logic circuits are used to implement...

Finite State Machines

When deleting the first element of a linked list one must: (multiple answers may apply)

Free the first element Adjust the head pointer to point to the new beginning of the list

Which of the following contains the actual source code of a function?

Function Definition

Which of the following contains the actual source code of a function?

Function definition

Fill in the blanks. In C the local variable are defined only within their _____ while the global variables are always available. Local variables are stored _________, global variables are stored ________.

Functions On the runtime stack Heap

What is the output of the following program? .ORIG x3000 ST R0, x3007 LEA R0, LABEL TRAP x22 TRAP x25 LABEL .STRINGZ "FUNKY" LABEL2 .STRINGZ "Hello World" .END

Funky

If you were designing a storage system that needed to store 10 TB of data and low system cost is more important than low latency, what type of storage would you use?

HDD based

The per bit cost of Cache is ____ than Main Memory, while the number of clock cycles to access Cache is _______

Higher | Lower

Match the data structure in P4 to its definition node_t sym_table_t symbol_t

Holds a symbol and a pointer to the next element in a linked list Holds information related to the entire symbol table Holds the name and address of a particular symbol

as Cache Associativity increases...

access time /\ Conflict Misses \/

A pointer is a variable that contains the _____ of a _________

address variable

2^2-by-3-bit memory

address space of 4 locations, and addressability of 3 bits.

In the translation process, the compiler (specifically the compiler not the overall mechanism of preprocessor, compiler, and linker sometimes refered to as the compiler) translates the source file into its corresponding machine code. The output of the compiler is called

an object module

int a[] = {3,4,5}; int *aptr; For the above statement the following is/are legal: When a pointer is incremented by one, the result is computed as New address = Old address + (Size of data type) A pointer and an array differ when declared, because memory is always set aside for an array, whereas for a pointer no memory is set aside.

aptr = aptr + 1 True False

char array[20] = "School is fun!"; char *aptr; Which of the following would change the '!' to a '?' in array

aptr = array; *(aptr + 13) = '?';

char array[20] = "School is fun!"; char *aptr; Which of the following would change the '!' to a '?' in array

aptr = array; *(aptr + 13) = '?';

char array[20] = "School is fun!"; char *aptr; Which of the following would change the '!' to a '?' in array

aptr = array; *(aptr + 13) = '?';

To store the instruction that is currently being executed, the control unit has an ____ (Two letter register abbreviation)

IR

Addressing modes and data types are elements of the

ISA

The following LC-3 instruction is located at memory address 0x5F55. Which of the following describes the operation of this instruction? 0000 1011 0000 0000

If either N or P condition code is set, the instruction will load 0x5E56 into the PC.

char array[20] = "School is fun!"; char *aptr; Which of the following would change the '!' to a '?' in array

aptr = array; *(aptr + 13) = '?';

After learning about caches we can say that accessing items sequentially from an [blank] is fastest, this is due to [blank blank].

array spatial locality

A D flip-flop stores one bit of information. For a rising-edge triggered D flipflop, the current output is 1. If the input changes to a 0 and next rising edge arrives, the output will soon a. change to 1. b. change to 0. c. remain unchanged. d. will momentarily become 0, but will go back to 1.

b

What is this line of assemble code doing and why might it be necessary? AND R1, R1, #0

Initializing R1 to 0, this may be necessary because registers can contain any value before initialization

What do the circles on input and/or output lines on a AND gate represent?

Inputs or outputs being inverted

A block of combination logic called "shift left 2" most likely would do this:

Inserts two zeros on the right hand side and everything else is shifted two bits to the left.

In LC3, the instruction RET can be called by another name. It is

JMP R7

What are the differences between the JMP and BR instructions

JMP is an unconditional branch so PC always is set to address found in source register. BR is a conditional branch so if corresponding condition code is set the PC is set to address created from PC + offset.

What instruction(s) accomplish the following: Add contents of memory location LOC1 to contents of R1, and leave result in R1. i.e. R1 <- R1 + MEM[LOC1]

LD R2, LOC1 ADD R1, R2, R1

What instruction would you use to move a value in a memory location labeled Val to register R4.

LD R4 Val This assumes that Val is within 256 addresses of the LD instruction.

Per bit DRAM takes _________ ["more", "less", "the same"] space than SRAM, but requires _________

Less Periodic refreshes

If one module contains the pseudo-op .EXTERNAL A, and no module contains the label A, the error will be detected at

Link Time

The Program Counter (PC) contains the a. address of the current instruction b. value of the next instruction to be processed c. address of the next instruction to be processed d. value of the next instruction

c

The minimum number of transistors required to implement a two input OR gate is a. 4 b. 8 c. 6 d. 3

c

To include a header file that you have created, calculate.h, in your program, the following preprocessor directive should appear at the beginning of your program. a. #insert "calculate.h" b. #insert <calculate.h> c. #include "calculate.h" d. #include <calculate.h>

c

Obtain the minimized boolean expression for this combinational function F(a,b,c) using a Karnaugh map.The function is 1 for these input combinations:a,b,c = 000, 010, 100, 101, 110.

c' + ab'

Match the action taken when calling a function to the order it occurs in. What is the first?

caller pushes arguments (last to first).

When the write enable input is not asserted, the gated D latch ______ its output.

can not change

Which of the following is the correct way, in C, to declare a variable that holds a character and initialize it to G?

char letter = 'G';

Consider the following code: #define CHARGE_2 5 #define RADIUS 3 const float epsilon = 8.854E-19; main() { float k = 0; float charge_1 = 2.0; float force; k = 1 / (4 * 3.14159 * epsilon); force = (k * charge_1 * CHARGE_2) / (RADIUS * RADIUS); printf("The Coulomb force is: %f\n", force); } Which of the following is a value that can be change during the execution of the program?

charge_1

The translation between a higher-level language such as C and assembly language (the ISA) is usually done by the ...

compiler

The __________ construct is appropriate when one of two tasks is to be performed, depending on the state of some variable.

conditional

N-type transistor

connected to Ground; pulls voltage down when input is 1.

P-type transistor

connected to Power; voltage UP when input is 0

A high performance chip ..

consumes power which is converted into heat.

Given an algorithm X with a lower big 0 bound but poor cache locality vs an algorithm Y with a higher big O bound and good cache locality, at a specific problem size which algorithm will be the fastest.

could vary based on the specific problem size

Master-Slave Flip Flop

current state remains intact, while next state is produced by combinational logic.

A Multiplexer selects one of four 16-bit registers and lets its contents pass through. How many Select lines are needed for selection. a. 4x16 = 64 b. 4, since with 2^4 =16. c. 16, one for each bit. d. 2, since with two bits we can specify four choices.

d

It is likely that a program written in [1] language for one ISA will also run on a computer having a different ISA. a. an assembly b. a low level c. machine code d. a high level

d

One advantage of choosing interpretation instead of compilation is a. the interpreter will produce code that is easier to read. b. developing and debugging your code is usually easier. c. the interpreter will optimize your code for you. d. There is no advantage of choosing interpretation, which is why most real-world software is produced using compiled languages.

d

Which of the following conditions are allowed in an RS latch? (Multiple answers may apply)

R is asserted, S is negated R is asserted, S is asserted R is negated, S is asserted

(4.17/5) What is the range of unsigned integers that can be stored using 10 bits? What is the range for signed integers represented in 1's and 2's complement, with the same number of bits?

Range of unsigned integers: 0 to 1023 Range of signed integers: -512 to 511 (1's complement) Range of signed integers: -512 to 511 (2's complement)

Inside gdb hitting the return/enter key will do what?

Re-run the last command

List the addressing modes supported by the operate instructions (ADD, AND, NOT)

Register, Immediate

What is the type of error that exists in the following C program, which is supposed to output the sum of positive integers from 1 to 10? #include <stdio.h> main() { int result = 0; int i; for (i = 1; i <= 10; i++) { result = result + i; printf("%d\n", result); }

Semantic error

What is the type of error that exists in the following C program, which is supposed to output the sum of positive integers from 1 to 10? #include <stdio.h> main() { int result = 0; int i; for (i = 1; i <= 10; i++); result = result + i; printf("%d\n", result); }

Semantic error

A Full Adder has inputs Ai=1, Bi=1, and carry-in Ci=1. What would be the sum bit Si and the carry-out bit Cout?

Si=1, Cout=1

Over the last ~40 years memory performance has increased __________ than processor performance. During this same period bandwidth has improved at a _________rate than than latency.

Slower | Faster

All other factors being constant an increase in the voltage supplied to a chip will have the least effect on.

Static Power

Which type of power consumption increases relative to total power consumption as the size of transistors on a chip decreases?

Static Power

Match the term to its position in the instruction cycle, what is the sixth instruction cycle?

Store Result

What is the purpose of memory locations x0100 to x01FF? (Hint: addresses x0000 to x00FF serve this same purpose for the TRAP instruction, and just like there can be 256 different TRAP routines, locations x0100 to x01FF allow for 256 different routines of this type)

Store the addresses of interrupt service routines

Register

Stores a number of bits, taken together as a unit.

What is this instruction doing? STR R1, R2, #0

Storing the value in R1 at the location/memory address contained in R2

Which of the following errors are detected at compile time?

Syntactic errors

A long int in C CAN have twice the number of bits as a regular int in C. (T/F)

T

For a file transfer from a hard drive, an increase in the seek time will have a larger impact in the total transfer time of a small file vs a large file. (T/F)

T

When declaring an array, the size of the array always needs to be defined at compile time. (T/F)

T

after this statement: typedef struct carType Car; Car is another name for: struct carType (T/F)

T

int arr = {1, 2, 43, 5, 6, 99}; int sum = 0; for(int i = 0; i < 6; i++) { sum += arr[i]; } In this for loop the variable i would have temporal locality, and the elements of arr would have spacial locality. (T/F)

T

*&X == X always evaluates to 1. (T/F) &*X == X always evaluates to 1. (T/F)

T F

What does the -std=c11 flag do?

Tells gcc to compile the code based on the version of C defined in ISO/IEC 9899:2011

What does the o flag do?

Tells gcc to interpret the next argument as the name of the file that will contain the completed executable

What does the g flag do?

Tells gcc to produce extra info for debugging

Match the definition to the correct term Items accessed recently are likely to be accessed again soon. Items near those accessed recently are likely to be accessed soon

Temporal Locality Spatial Locality

Select the ways computing speed/capability can continue to increase in the face of end of the end of Dennard scaling and a slowing Moore's law. (Note: More than one option might be correct)

Utilize special IP blocks to do specific tasks like compression or security Offload some calculations to GPUs/Accelerators Increase the number of cores

The ability to ________ sets computers apart from previous devices that could do things like sorting or addition. a. use binary numbers b. input data c. run on electricity d. be programmed

d

It is always possible to convert an if-else statement into a switch statement

True

It is possible (but not necessary) to avoid creating a very similar doubly nested loop to the one in symbol_interate inside symbol_order by creating a function that adds a symbol to an array and passing that function to symbol_interate.

True

One way to stop execution of a program during debugging is by setting one or more breakpoints.

True

P is false What is the value of the expression P or not P

True

P is true Q is false What is the value of the expression P and (Q or not Q)

True

P is true What is the value of the expression P or not P

True

The .blkw pseudo-op sets aside some number of memory locations in the program space, probably to be used later for storing values.

True

The C statement scanf("%d", &time); reads in an entity, treats it as a decimal number, and stores the decimal number in variable time.

True

The JSR instruction can only jump to a subroutine, which is within +1024 or -1023 locations of the JSR instruction.

True

The LC-3 has two device registers to handle input from the keyboard. The keyboard data register (KBDR) and the keyboard status register (KBSR).

True

The System Control Block or the Trap Vector Table is a set of memory locations which contain the starting addresses of the service routines.

True

The bitwise OR operator can be used to set bits to '1' and the bitwise AND operator can be used to set bits to '0'.

True

The condition in the following if statement is always false. if ( !(x = 3 ) )

True

The condition in the following if statement is always false. if ( !(x = 3 ) )

True

The condition in the following if statement is always true. if ( x = 6 )

True

The difference between the next command and the step command is next will execute the next line of code without stepping into a function that line may contain, while step will execute the line of code and step into a function if the line contains one.

True

The instruction 0xEE00 at memory location 0xF011 sets the N condition code when executed in the LC3 simulator we are using. Not part of this question but something to think about: what would happen if the simulator was based on version 3 of the book instead of version 2? Why was this change made?

True

The number of operands required by an OPCODE depends on the opcode.

True

The semantics of a programming language specify how the properly formed code behaves.

True

To be able to use the square root function, sqrt, defined in the math library's header file, math.h, the preprocessor directive #include <math.h> should appear in your program before it is used.

True

To enable interrupt-driven I/O for the keyboard in the LC-3, bit 14 of the KBSR should be set.

True

True or False: It is possible to have a register that only stores 1 bit.

True

When using a TRAP instruction, the lower 8 bits of the instruction is the trap vector. The TRAP vector contains the 4 bit opcode that signifies the instruction is a TRAP instruction.

True

after this statement: typedef struct carType Car; Car is another name for struct carType

True

after this statement: typedef struct carType Car; Car is another name for struct carType

True

char string[15]; char *sptr; sptr = string; sptr contains the address of string[0].

True

*&X == X always evaluates to 1. &*X == X always evaluates to 1.

True False

What does the -Wall flag do?

Turns on multiple compiler warnings that can help you create a correct program

In memory based on DRAM a memory request that fall on the same row as the previous request can be served _________ as fast as one to a different row.

Twice

In the following C construct, the action statement will only be executed if the condition component evaluates to

a nonzero value

In the following C construct, the action statement will only be executed if the condition component evaluates to if (condition) action;

a nonzero value

Address

a unique identifier for a memory cell

What are the two recurring themes of the book? a. Abstraction b. Hardware vs Software c. Algorithms d. Assembly Language e. Computer Systems

a, b

Which of the following conditions are allowed in an RS latch? (Multiple answers may apply) - a. R is asserted, S is asserted - b. R is negated, S is asserted - c. R is asserted, S is negated - d. R is negated, S is negated

a, b, c

The finite state machine that controls all of the activity in a computer is in what part of the computer? a. processing unit b. peripherals c. memory d. control unit

d

The minimum number of transistors required to implement a two input NAND gate is a. 6 b. 2 c. 5 d. 4

d

The range of values that an int variable always represents is. a. -2,147,483,648 to +2,147,483,647 b. -32,768 to +32,676 c. Negative infinity to positive infinity d. The range of values depends on the ISA of the computer.

d

We indicate complement of a variable by a prime ('). If F' = (A+B').(C+D'), then we have (applying DeMorgan's theorem) a. F = A'B' + CD b. F = AB' + CD' c. F = A'B' + C'D' d. F = A'B + C'D

d

What is the attribute that is the most detrimental to allowing natural languages to be used to program computers? a. Context b. Precision c. Finiteness d. Ambiguity

d

//The following code contains a compile time error int *ptrx = &x; int x = 5; int y = 7; int z = 3; int *ptry = y; int *ptrz; The initialization of ptrx gives a compiler error because x should be defined before being used. The initialization of ptry is incorrect and should be corrected by using int *ptry = &y. True ptrz points to none of the above

declared True a random value

All else being equal as associativity in a cache increases the number of index bits -----, the number of tag bits -----, and the number of offset bits -----.

decreases increases stays the same

What does the following program do: .ORIG x3000 TRAP x20 TRAP X21

echoes the character typed on the keyboard to the monitor

Compile time per 1000 lines of code has shown a exponential decrease over the last 45 years.

exponential decrease

Relative to the historical performance increases of CPUs, performance for Memories has been _________ .

exponentially decreasing

The flash storage is ..

faster than magnetic storage, but is more expensive.

Which function returns a pointer to a memory location that becomes invalid after the function returns?​

foo

storage elements

output of storage element is an internal input to the combinational logic circuit.

The correct syntax to assign a value to a pointer variable is:

ptr = &x;

What operator symbol in C performs a logical NOT.

!

The beginning character of a preprocessor directive is a/an

# (pound sign)

Complete the following PUSH routine. Assume the stack grows toward lower numbered addresses, R6 is the stack pointer and each element of the stack requires three memory locations. ADD R6, R6, _____ STR R0, R6, #0

#-3

To include a header file that you have created, utils.h, in your program, the following preprocessor directive should appear at the beginning of your program.

#include "utils.h"

Conversion specifications for scanf/printf all begin with the ____ character

%

For symbol_find_by_name if we have a node_t* called nPtr, and we want to return a pointer to the symbol_t member of the node_t that nPtr is pointing to, we could use which of the following.

&(nPtr->symbol) &nPtr->symbol

Put the following C operators in precedence order from highest (1) to lowest (4) precedence.

* + == =

Consider this program segment: double barr[18]; double *ptr; ptr = barr; After the last instruction is executed, what is equivalent to barr[2]?

*(ptr+2)

Consider this program segment: double barr[18]; double *ptr; ptr = barr; After the last instruction is executed, what is equivalent to barr[2]?

*(ptr+2)

After this program segment: double arr[20]; double *ptr; ptr = arr; What is equivalent to arr[5]?

*(ptr+5)

After this program segment: double arr[20]; double *ptr; ptr = arr; What is equivalent to arr[5]?

*(ptr+5)

After this program segment:double arr[20];double *ptr;ptr = arr; What is equivalent to arr[5]?

*(ptr+5)

When calling the char2int() function with a radix of 13 and the char 'E' what should be returned

-1

What is the range of signed integers you can represent with 11 bits using two's complement? Minimum (in decimal): Maximum (in decimal):

-1024 1023

The following binary number uses a 14-bit 2's complement convention to represent a signed integer: 0b11 1111 1101 0111 What is this number in decimal?

-41

What is the range of signed integers you can represent with 7 bits using two's complement? Minimum (in decimal): Maximum (in decimal):

-64 63

The ____ operator accesses members of a structure using a pointer.

->

What flag needs to be passed to gcc to enable debugging with gdb?

-g

Match the flags passed to the gcc command in the P2 assignment to their definition.

-g Tells gcc to produce extra information that is used for debugging -o Tells gcc to interpret the next argument as the name of the file that will contain the completed executable -std=c11 Tells gcc to compile the code based on the version of C defined in ISO/IEC 9899:2011 -Wall Turns on multiple compiler warnings that can help you create a correct program

To remove a directory with the rm command what additional flag is necessary

-r

When would you use .BLKW?

.BLKW N: allocate a block of memory with size N

When would you use .FILL

.FILL N: allocate one memory location with value N

(10 % 1) =

0

The value of y will be what after the following C code segment is executed. int x = 7; int y; y = x ^ x;

0

char array[20] = "School is fun!"; What is the integer value of array[18]?

0

What is the range of unsigned integers you can represent using 8 bits? Minimum (in decimal): Maximum (in decimal):

0 255

What is the output for the following code? for (int i=0; i<10; i++) { if (i>5) { break; } printf("%d ", i); }

0 1 2 3 4 5

Add the following two binary numbers. The answer must have 6 bits (discard the last carry if any). 0b110011 0b001101 Result = 0b[binResult] (show all 6 bits!)

000000

Show the 2's complement subtraction of +13 minus +25, with both numbers in binary using 8 bits. Hint: make sure that the resulting binary number corresponds to the correct answer.

00001101 00011001 -00001100

(1.67/5) Show the 2's complement addition of -35 plus +16, with both numbers in binary using 8 bits.

000100011 00010000 00010011

(1.67/5) Show the 2's complement addition of -29 plus +13, with both numbers in binary using 8 bits

00011101 00001101 00000101

What is the 8-bit binary representation of the unsigned decimal value 93? 0b

01011101

What is the 8-bit binary representation of the unsigned decimal value 97?

01100001

What is the output for the following code? for (int i=0; i<10; i++) { if (i>5) { break; } printf("%d ", i); }

012345

The largest memory address that can be referenced by an LD instruction at location 0x6631 is:

0x6731

A C program has at least how many functions?

1

In C, what is the minimum number of iterations that a do-while loop will perform?

1

int val = 5; int x = (val >> 2) & 1 // x = ?

1

All else being equal as associativity in a cache increases the number of index bits____________ , the number of tag bits ______ , and the number of offset bits _________.

1 Decreases

The R-S Latch can store...

1 bit of information

List some types of registers

1 bit registers, 16 bit registers.

After the execution of which of the following instructions will the value in the Program Counter (PC) be 0x306E? 0000 1110 0101 1100 at location 0x3011 1001 0000 0110 1110 at location 0x3064 1010 0110 0110 1110 at location 0x306d

1, 3

The output of a 3-input NAND gate is 0. This is caused by these input values

1,1,1

What is the binary representations of the signed decimal integer -56? Use 7-bit 2's complement convention. Result = 0b

1001000

Running the following command ./testConv i2a 2 39 will return what value?

100111

What is the 8-bit binary representation of the hexadecimal value 0x9C? 0b

10011100

What is the result of performing the following bitwise operation using 8 bits? (0b11001100 AND 0b10101101) OR (0b00010101) = 0b

10011101

What is the 16-bit binary equivalent of the hexadecimal number 0xB5FE? 0b (show all 16 bits with no spaces)

1011010111111110

What is the 16-bit binary equivalent of the hexadecimal number 0xCD1A? 0b

1100 1101 0001 1010

What is the 16-bit binary equivalent of the hexadecimal number 0xC2AF? 0b

1100001010101111

What is the 8-bit binary representation of the hexadecimal value 0xE9? 0b

11101001

What is the result of performing the following bitwise operations using 8 bits? Show the result in binary. (0b11001010) OR (0b10101100 AND 0b11100111) = 0b

11101110

What is the result of performing the following bitwise operations using 8 bits? Show the result in binary. (0b11001010) OR (0b10101100 AND 0b11100111) = 0b (show all 8 bits!)

11101110

What is the result of performing the following bitwise operations using 8 bits? Show the result in binary. (0b11100110 AND 0b10110111) OR (0b11010001) = 0b

11110111

A certain forest has 900 trees. You want to identify each tree with a unique bit pattern. If you were to use the minimum number of bits in order to represent all 900 trees, how many bit patterns will remain unused?

124

The interrupt enable bit in the KBSR and the DSR is at what bit position?

14

What data types does the LC3 ISA support?

16 bit 2's complement integer

For symbol_reset you should free all allocated node_t structs along with the symbot_t struct they contain, then clear out any pointers in the addr_table array. If you have initialized your symbol table to a capacity of 15 and then added 9 unique symbols to your symbol table, how many calls to free will be required to correctly implement symbol_reset.

18

During which period was growth in single processor performance the fastest?

1986 to 2003

Use decimal numbers in your answer. There are ___ n-type transistors and ___ p-type transistors in a two input NAND gate.

2 / 2

A combination circuit has inputs A,B,C and D. It should implement the function F = AB+CD. We want a 2-level implementation using AND and OR gates. How many AND and OR gates do we need?

2 AND gates and 1 OR gate

Use decimal numbers in your answer. There are ____________ n-type transistors and _________ p-type transistors in a two input NAND gate.

2 and 2

Which of the following instructions at address 0x00FF clear register R5? 0001 1011 0110 0000 0101 1011 0110 0000 1110 1011 0000 0000 0010 1010 0000 0000

2, 3

Consider the following code: char name[ 100 ]; int a; float b; scanf ("%d %f %s", &a, &b, name); If the data typed in is 20 150.25 motor the above scanf statement will return a value of 0. If the data typed in is 20 motor 150.25 the above scanf statement will return a value of 3. True The following is/are true of the above command: neither answer

3 False & is not used before name because it is an array and is automatically passed by reference in C

void foo(int**x, int size){​ *x = malloc(size * sizeof(int));​ **x = 3;​ *(*x + 1) = 4;​ }​ ​ int main(){​ int a[] = {1, 9, 4, 3};​ int *v = &a[0];​ foo(&v, 4);​ printf("%d ", v[0]); ​ printf("%d ", v[1]); ​ printf("%d\n", v[2]); ​

3 4 ?

Given the following truth table with A and B as input and X and Y as outputs, how many AND and OR gates would we need to implement a circuit in logic with no optimizations that will produce the truth table.

3 AND, 2 OR

A 16 input mux has _____ select lines.

4

How many arguments does the C standard library function qsort take?

4

Of all the possible inputs to a Full Adder (rows in its truth table) how many generate a Carry Out?

4

The minimum number of transistors required to implement a two input NAND gate is

4

int think (int n) { if (n%5) return n%5 + think (n+1); else return n%5; } The maximum number of times this function can recurse is: 4 The maximum value this function can return is: [ Select ] ["3", "0", "7", "5", "10"] This function will behave the same for an input of 0 and 5. [ Select ] ["False", "True"]

4 10 True

A combination circuit has inputs A,B,C. It should implement the function F = ABC+A'B'C+A'BC', and the function G = ABC + A'B'C'. We want a 2-level implementation using AND and OR gates. How many AND and OR gates do we need, assuming the circuit is implemented directly as specified without any minimization? (NOT Gates are needed, but not counted).

4 AND, 2 OR

In a number system with base 64 what weight does the character at position 2 have with positions starting from 0 (position X in this figure: _ _ _ X _ _ ) More than one answer may apply.

4096 64^2

What are common sizes for disk sectors?

4096 Bytes 512 Bytes

What is the value of x after the following C statement. int x = 5 < 2 ? 7 : 42;

42

What is the value of x after the following C statement: int x = 5 < 2 ? 7 : 42;

42

Convert 2B3 which is in base 12 (unsigned integer) to a decimal number. (enter only valid decimal digits with no leading zeroes)

423

Convert 3A7 which is in base 11 (unsigned integer) to a decimal number.

480

After the following C code segment is executed, what will the value of x be? int x; x = 5.86;

5

The Von Neumann model consists of ___ parts

5

We have a PLA with inputs A,B,C and outputs D,E,F described by this truth table: If we minimize this PLA table, how many product terms we will finally have?

5

The ascii codes of characters "Z" and "z" are, when specified in hexadecimal

5A and 7A

The minimum number of transistors required to implement a two input OR gate is

6

What is the result of performing the following bitwise operations? Show the result in hexadecimal. (0xAB9 ^ 0xEF5) | (0x62D) = 0x

66D

What is the hexadecimal equivalent of the binary number 0b11110101100? 0x

7AC

What is the hexadecimal equivalent of the binary number 0b11110101100? 0x (express your answer using the minimum number of hexadecimal digits)

7AC

For a particular 16-bit ISA, the LDR instruction has the following format <Opcode = 0110> <DR><BaseR><OFFSET>. If there are 4 registers, the number of bits available to specify the offset is?

8

How many priority levels does the LC-3 processor have?

8

What is the result of performing the following bitwise operations? Show the result in hexadecimal. (0x8D7 | 0xBCA) ^ (0x16F) = 0x

AB0

Here is a C structure: typedef struct point { int x; int y; } Point; We declare a local variable of type point. local is the first local variable. Point local; Which of the following LC-3 code sequences implements the following C statement: local.x = 3; Assume that fields like array elements are stored from lower memory to higher memory. Therefore the x field will be stored in an earlier address than the y field.

AND R1, R1, #0 ADD R1, R1, #3 STR R1, R5, #-1

What is the result of performing the following bitwise operations using 8 bits? Show the result in binary. (0b01010010) AND (0b10101110 OR 0b01100100) = 0b (show all 8 bits!)

Answer 1: 01000010

The fprintf command has one additional parameter not found in printf, this parameter takes a pointer to a FILE . fprintf can be used to write formatted data to a file or to stdout True .

Answer 1: pointer to a FILE Answer 2: True

What is the range of signed integers you can represent with 11 bits using two's complement?

Answer 1:-1024 Answer 2:1023

What is the range of unsigned integers you can represent using 7 bits? Minimum (in decimal): Maximum (in decimal):

Answer 1:0 Answer 2:127

What does 64 look like as an unsigned number in binary with 8 bits? 0b What does 64- 1 look like as an unsigned number in binary with 8 bits? 0b

Answer 1:01000000 Answer 2:00111111

What is the binary representations of the signed decimal integer -56? Use 7-bit 2's complement convention. Result = 0b (enter exactly 7 bits)

Answer 1:1001000

What is the 16-bit binary equivalent of the hexadecimal number 0xB5FE? 0b (show all 16 bits with no spaces)

Answer 1:1011010111111110

Show the result of the following bitwise operations in hexadecimal: 0x93A & 0x70F = 0x (show exactly 3 hexadecimal digits) 0x93A | 0x70F = 0x (show exactly 3 hexadecimal digits) 0x93A ^ 0x70F = 0x (show exactly 3 hexadecimal digits)

Answer 1:10A Answer 2:F3F Answer 3:E35

Consider the following code: char name[ 100 ]; int a; float b; scanf ("%d %f %s", &a, &b, name); If the data typed in is 20 150.25 motor the above scanf statement will return a value of [ Select ] ["3", "2", "1", "0"] If the data typed in is 20 motor 150.25 the above scanf statement will return a value of 3. [ Select ] ["True", "False"] The following is/are true of the above command: [ Select ] ["the scanf return value is used to detect errors", "both answers", "neither answer", "& is not used before name because it is an array and is automatically passed by reference in C"]

Answer 1:3 Answer 2:False Answer 3:& is not used before name because it is an array and is automatically passed by reference in C

Given this output from Valgrind what line in user written code was memory malloc'd that was not correctly freed? 72 What line is user written code was the memory improperly freed? unknown ==28299== 11 bytes in 2 blocks are definitely lost in loss record 1 of 1 ==28299== at 0x4C2BBAD: malloc (vg_replace_malloc.c:299) ==28299== by 0x4EC0079: strdup (in /usr/lib64/libc-2.23.so) ==28299== by 0x400AFF: symbol_add_unique (symbol.c:72) ==28299== by 0x400D2B: symbol_add (symbol.c:119) ==28299== by 0x401158: main (testSymbol.c:154)

Answer 1:72 Answer 2:unknown

What is the hexadecimal representation of the binary number 0b100111111101? 0x (show 3 hexadecimal digits!)

Answer 1:9FD

Use the man command to answer the following. gcc is a compiler for what languages? C, C++ When gcc is invoked what does is normally do? [ Select ] ["Runs the make program", "Numerical Processing", "Interpreting, decryption", "Preprocessing, compilation, assembly and linking"] What does the -g flag specify? [ Select ] ["produce checksums", "produce debugging information", "produce assembly instructions", "produce binary output"] (You may want to google searching a man file to find the -g option (does this way of searching look similar to another program you have just seen?))

Answer 1:C, C++ Answer 2:Preprocessing, compilation, assembly and linking Answer 3:produce debugging information

DRAM uses less transistors to store a bit of data than SRAM, the trade off for this is it requires refreshes and has slower access times.

Answer 1:DRAM Answer 2:refreshes Answer 3:slower

The '.' operator may be substituted for the -> operator. False malloc returns a block of memory initialized to 0. False

Answer 1:False Answer 2:False

In an ideal memory we would like to have memory access times of SRAM with the capacity of HDD .

Answer 1:SRAM Answer 2:HDD

A pointer is a variable that contains the of a

Answer 1:address Answer 2:variable

A pointer is a variable that contains the of a .

Answer 1:address Answer 2:variable

A [ Select ] ["block", "byte", "bit", "word"] or [ Select ] ["row", "cache line", "page", "sector"] is the unit of data transferred between cache, memory and the processor. A common size for a block is 64 [ Select ] ["words", "bits", "lines", "bytes"] .

Answer 1:block Answer 2:cache line Answer 3:64 Answer 4:bytes

A short int always declares an integer that has one half the number of bits of a regular int.

False

Consider the following code: int *foo (){ int x= 10; return (&x); } int *bar (){ int * px; *px= 10; return px; } int *baz (){ int *px; px = (int *) malloc (sizeof(int)); *px= 10; return px; } Which function returns a pointer to a memory location that becomes invalid after the function returns? foo() Which function dereferences an uninitialized pointer? [ Select ] ["baz()", "bar()", "foo()"] Which function correctly returns a pointer to an int containing the value 10?

Answer 1:foo() Answer 2:bar() Answer 3:baz()

In vim to start entering text (change from normal mode to insert mode) you should enter what character (there are a few choices any choice will work). To return to normal mode enter the escape key. in normal mode what character will move the cursor up? down? left? right? . What character precedes all commands is vim? . Once this character is pressed what character is used to save a file? . quit?

Answer 1:i Answer 2:k Answer 3:j Answer 4:h Answer 5:l Answer 6:: Answer 7:w Answer 8:q

Increasing the ratio of hits in L1 cache to overall memory accesses [ Select ] ["is a desirable outcome of a cache design", "increases the miss ratio", "reduces the hit ratio", "not possible"] . All else being equal increasing this ratio would have the effect of [ Select ] ["increasing the miss ratio", "reducing the number of accesses from L2 cache", "increasing the number of accesses from the"] , and [ Select ] ["increasing the average memory access time", "increasing the cycle time of the processor", "decreasing the cycle time of the processor", "decreasing the average memory access time"]

Answer 1:is a desirable outcome of a cache design Answer 2:reducing the number of accesses from L2 cache Answer 3:decreasing the average memory access time

Consider the following code: 1| void printInt ( int n, int base ) { 2| char digit_table[ 16 ] = "0123456789abcdef"; 3| if ( n >= base ) 4| printInt ( n/base, base ); 5| printf ( "%c", digit_table[n % base] ); 6| } If base > 16 then an error may occur when the index to digit_table is out of bounds If base == 0, then an error occurs because division by zero is attempted at line 4 If base == 1, then error occurs because recursive call at line 4 fails to make progress as the two parameters remain the same

Answer 1:the index to digit_table is out of bounds Answer 2:division by zero is attempted at line 4 Answer 3:recursive call at line 4 fails to make progress as the two parameters remain the same

Segmentation faults are usually caused by trying to access memory you weren't supposed to access. . This can happen when you dereference a null pointer , try to access an uninitialized pointer

Answer 1:trying to access memory you weren't supposed to access. Answer 2:dereference a null pointer Answer 3:try to access an uninitialized pointer

When transferring one large file what factor has the biggest impact on the time the transfer takes?

Bandwidth

Which function correctly returns a pointer to an int containing the value 10?

Baz

Use the man command to answer the following. gcc is a compiler for what languages? C, C++ When gcc is invoked what does is normally do? __________ What does the -g flag specify? ________(You may want to google searching a man file to find the -g option (does this way of searching look similar to another program you have just seen?))

C, C++ Preprocessing, compilation, assembly and linking produce debugging information

What is the result of performing the following bitwise operations? Show the result in hexadecimal. (0x81F | 0x5C4) ^ (0x1A2) = 0x

C7D

What is missing in the LC3 that a modern computer would have?

Cache Secondary Memory (HDD/SSD)

Match the action taken when calling a function to the order it occurs in. What is the third?

Callee allocates return value, pushes R7 and R5

Match the action taken when calling a function to the order it occurs in. What is the fourth?

Callee allocates space for local variables

Match the action taken when calling a function to the order it occurs in. What is the fifth?

Callee executes function code

Match the action taken when calling a function to the order it occurs in. What is the seventh?

Callee pops local vars, pops R5, pops R7

Match the action taken when calling a function to the order it occurs in. What is the eighth?

Callee returns (RET).

Match the action taken when calling a function to the order it occurs in. What is the sixth?

Callee stores result into return value slot

Match the action taken when calling a function to the order it occurs in. What is the second?

Caller invokes subroutine (JSR)

Match the action taken when calling a function to the order it occurs in. What is the ninth?

Caller loads return value and pops arguments

Match the action taken when calling a function to the order it occurs in. What is the tenth?

Caller resumes computation

What saw a reduction or stop in growth starting in the early 2000's?

Clock speed of a chip Power consumption of a chip Performance of a single processor per clock cycle

In a future defined by an end of Dennard Scaling and a slowing of Moore's law which of the following will have to have optimizations or be redone to take advantage of current improvements?

Compilers Library Code Operating Systems User Code

All else being equal a cache with higher associativity will have lower _________ misses​

Conflict

JMP is an example of a/an ___________ instruction.

Control

Which phase happens first DECODE or FETCH OPERANDS?

DECODE

Which of the following have experience exponential growth over the last 45 years?

DRAM capacity Flash capacity HDD capacity Transistor density

Match the term to its position in the instruction cycle, what is the second instruction cycle?

Decode

A _________ is helpful in identifying the opcode of an instruction.

Decoder

Which circuit has N inputs and up to 2^N outputs. This circuit also has the property that given any combination of values as input, only one of the circuits outputs will have the value 1.

Decoder

Which circuit has the property that only one of its outputs is guaranteed to be1?

Decoder

What type of cache is the simplest to implement? What is the reason for this?

Direct mapped Data from memory can go to one locations in the cache, so it takes less logic to place and locate data.

What type of cache is the simplest to implement? _________What is the reason for this?_________

Direct mapped Data from memory can only go to one location in the cache, so it takes less logic to place and locate data.

What does the following code do: LEA R1, PROMPT L1 LDR R0, R1, #0 BRz FOO ;where FOO is some other routine. L2 LDI R3, DSR BRzp L2 STI R0, DDR ADD R1, R1, #1 BR L1 DSR .FILL xFE04 DDR .FILL xFE06 PROMPT .STRINGZ "Hello World"

Displays the string "Hello World"

Which type of power consumption is related to transistors changing state, i.e. going from open to close?

Dynamic Power

What is the result of performing the following bitwise operations? Show the result in hexadecimal. (0xF3C & 0xCF3) | (0x666) = 0x[bitwsResult] (show 3 hexadecimal digits!)

E76

Which phase happens first EVALUATE ADDRESS or EXECUTE?

EVALUATE ADDRESS

Match the term to its position in the instruction cycle, what is the third instruction cycle?

Evaluate Address

Match the term to its position in the instruction cycle, what is the fifth instruction cycle?

Execute

A missing semicolon at the end of a statement in a C program is a semantic error. (T/F)

F

Fully associative caches require fewer tag comparators than dirrect mapped caches. (T/F)

F

In C, functions can have two return values.(T/F)

F

Lower associativity in a cache will generally lower conflict misses. (T/F)

F

To use type FILE requires including the string.h header file (T/F)

F

fprintf takes one additional paramater that is not part of printf. This parameter is the last argument in fprintf's argument list. (T/F)

F

The '.' operator may be substituted for the -> operator. (T/F) malloc returns a block of memory initialized to 0. (T/F)

F F

We indicate complement of a variable by a prime ('). If F' = (A+B').(C+D'), then we have (applying DeMorgan's theorem)

F = A'B + C'D

We indicate complement of a variable by a prime ('). If F' = (A+B').(C+D), then we have (applying DeMorgan's theorem)

F = A'B + C'D'

A cache hit means data from the requested memory address is in the cache, cache hits are slower to service that cache misses​

False

To read the contents of a memory location, we first place the address of that location in the _______ (Three letters)

MAR

Most computers/microprocessors are constructed out of...

MOS transistors

If we were trying to add IO capabilities to a processor and memory system that did not have any IO functionality, and we could not add to / change the processor hardware (components on the inside of the LC3's bus), what type of IO would we have to implement?

Memory Mapped IO

What is the range of signed integers you can represent with 8 bits using two's complement?

Min: -128 Max: 127

What is the range of signed integers you can represent with 6 bits using two's complement?

Min: -32 Max: 31

What is the range of signed integers you can represent with 7 bits using two's complement?

Min: -64 Max: 63

What is the range of unsigned integers you can represent using 10 bits?

Min: 0 Max: 1023

What is the range of unsigned integers you can represent using 11 bits?

Min: 0 Max: 2047

What is the range of unsigned integers you can represent using 7 bits?

Min: 0 Max: 127

A 1 bit adder has ________ gates than a 1 bit multiplier. (Hint build the truth tables for each device)

More

Use the man command to answer this question. less is a program similar to ______ , but it has many more features. Less does not have to read the entire input file before starting, so with large input files it starts up _____than text editorslike vi.

More Faster

Select the approaches that are seen as ways for significantly increasing performance in the future

Multicore processors Accelerators (GPU, TPU, etc) Special IP / ASIC

Boolean algebraic precedence

NOT (') → AND (.) → OR (+)

If the 2 inputs of a 2 input nand gate are connected together, then the function of the nand gate is that of a?

NOT gate

Is the following number positive or negative (assuming it has been represented using the two's complement convention in 7 bits). 0b1001110

Negative

Is the following number positive or negative (assuming it has been represented using the two's complement convention in 7 bits). 0b1010010

Negative

If labels always came after the instructions that reference them, would it be possible to create a simple assembler that only makes a single forward pass through the assembly code to assemble the resulting binary file? (Hint: What does the assembler turn the labels into? Can it do this if it has not seen the address associated with the label yet?)

No

What remaing offsets from the Frame Pointer (R5) will be affected if the function that the stack frame belongs to does not have any local variables. (Keep in mind the location of the Frame Pointer in our protocol is the same regardless if the stack frame contains local variables)

No offsets will be affected.

Fill in the blanks.In C the local variables are defined only within their _____ while the global variables are always available. Local variables are stored _________, global variables are stored ________.

Not functionson the run-time stackon the heap

If the relationship between block size and miss penalty was changed so increasing block sizes reduced the miss penalty what effect would that have on the optimal size of a cache line?

Not_Decrease the size

When called with two files with identical content the diff command will output?

Nothing

Identify the design considerations associated with "Classical" computer architecture.

Number of registers Addressing modes Instruction encoding What operations are included

Match the bitwise operator to the operation. | & ^ ~ << >>

OR AND XOR NOT LEFT SHIFT Right shift

How can an OR instruction be simulated on the LC3?

OR R3, R1, R2 is equivalent to: NOT R1, R1 NOT R2, R2 AND R3, R1, R2 NOT R3, R3

Consider the following code: (1) #include <stdio.h> (2) (3) main() (4) { (5) int x, i; (6) char alpha; (7) (8) for (i = 0; i < 2; i++){ (9) for (x = 5; x > 0; x--); (10) alpha = a; (11) do (12) printf("%c",alpha++); (13) while (alpha <= 'z') (14) } (15) } The first syntax error occurs on line ____. The second syntax error occurs on line _____ .

One is right 1) 10 2) 11

P-type transistors act in exactly the _____ way of n-type.

Opposite

Full Adder

PLA that implements a specific truth table

Is the following number positive or negative (assuming it has been represented using the two's complement convention in 7 bits). 0b0100110

Positive

Is the following number positive or negative (assuming it has been represented using the two's complement convention in 7 bits). 0b0110100

Positive

Is the following number positive or negative (assuming it has been represented using the two's complement convention in 7 bits). 0b0111011

Positive

Match the following terms to their definitions Precedence In which order are operators combined? Associativity In which order are operators of the same precedence evaluated? Statement Express a complete unit of work to be carried out by the computer. Expression A valid combination of variables, literal values, and operators.

Precedence In which order are operators combined? Associativity In which order are operators of the same precedence evaluated? Statement Express a complete unit of work to be carried out by the computer. Expression A valid combination of variables, literal values, and operators.

A R-S latch is cleared by setting the _______ signal to _______.

R / 0

If plotting exponentially growing data on a Log scale what does the slope of the line correspond to?

The base of the exponential function that models the data

Comparing the cache memory and the main memory, ..

The main memory cost per bit is much lower and the access time is much higher.

What does the PC register contain after the FETCH phase?

The memory address of the next sequential instruction.

addressability

The number of bits stored in each addressable location in memory

Interrupt-driven I/O is more efficient that polling because:

The processor can perform other tasks instead of constantly being in a loop checking to see if the status bit has changed.

The output of an exclusive-OR gate is 1 whenever

The two inputs are different.

When would you use .STRINGZ? What is the last character produced by the assembler?

To create a null terminated array of characters in memory. The last character is '\0'

A long int in C CAN have twice the number of bits as a regular int in C.

True

A void * can be cast to a pointer of any type but it is up to you the programmer to ensure that at runtime the cast is correct.

True

Any function you are able to write recursively may also be written non-recursively.

True

Bandwidth: rate of data transfer​Latency: time between requesting data and receiving the data​

True

By default in gdb the command list followed by a line number or function name will show 10 lines your source file surrounding that line / function. The command set listsize <desired size> can be used to change the default number of lines shown.

True

Calling int_to_char() with radix 10 and the value 10 is an error.

True

For a file transfer from a hard drive, an increase in the seek time will have a larger impact in the total transfer time of a small file vs a large file.

True

For symbol_iterate you will have a doubly nested loop. The outer loop will iterate through locations 0 through capacity - 1 in the hash_table and the inner loop with iterate through the node_t in the linked list at each location in the hash_table. Each iteration of the inner loop should call the function pointer passed into symbol_iterate.

True

Given the statements int x; int *pi; pi is a variable that holds the address of an int (pi's type is a pointer to an int). If pi is initialized to the address of the int x, by the statement pi = &x; using the * operator on pi will give us access to the value of the int x that pi is pointing to and we can set x to 42 with the following statement *pi = 42;

True

If R6 is the stack pointer and each element in the stack occupies two memory locations, a push operation on the stack requires that R6 be decremented by 2.

True

If you write a whole C program all on one line with variable spacing between syntactic elements, it will still compile and execute correctly if you use proper C syntax.

True

In C, the name of an array evaluates to the address of its first element.

True

In C, the newline character is considered white space when reading input.

True

In gdb typing help will bring up a list of general help topics. Typing help <topic name> will then bring up a list of sub-topics related to the chosen topic.

True

In the LC-3, the user program invokes the OS to perform an I/O operation using the TRAP command.

True

What is the output format of the first and second printf statements after executing the following code segment? (Assume the standard I/O library's header file has already been included.) #define VALUE 11 int input; scanf("%d", &input); printf("%x\n", VALUE); printf("%c\n", input); a. b. c. d.

VALUE will be a hexadecimal number and input will be a character.

Show two ways to set the value in the register R2 to 32.

Val .FILL #32 or LD R2, Val AND R2, R2 #0 ADD R2, R2, #8 ADD R2, R2, R2 ADD R2, R2, R2

Match the terms to their definitions: Local variable Global variable Local variable initial value Global variable initial value

Variable defined in scope of function. Varibale defined outside the scope of a function. Random value (Value of this new mem location in STACK). 0 or NULL depending on data type

What will happen if inside symbol_add() we create a new node then set its symbol.name field which is of type char* to the const char* name parameter of symbol_add?

When symbol_add is called in the future to add a new node the node and name will be different but the const char* name parameter will have the same address as befor

Which output signal is asserted for all possible values for Input1 (most significant) and Input0 (least significant) in binary order 00, 01, 10, 11?

X, Z, W, Y

What operation does the ^ symbol perform in C?

XOR

Given a growth rate of 100% what formula will give the number of periods it takes for Y to increase by a factor of 500?

Y = log2 500

Could an architecture be produced that had additional addressing modes for operate instructions? If yes what additional modes might be desirable?

Yes. Possible options are zero, one, or two registers being used by the operate instruction instead of three like in the LC3, also might want to be able to load operands directly from memory. Google ISA instruction formats for more info.

What is the correct precedence (highest to lowest) for the following operators: +, [], =, <= ​

[], +, <=, =, ​

A long int in C CAN have twice the number of bits as a regular int in C. a. True b. False

a

A sequential circuit that implements a FSM has 3 flipflops. What is the maximum number of states it can implement? a. 8 states, because 2^3=8 b. 3 states, because there are 3 flipflops. c. 2 states, because 2^3=8 d. 8-3=5 states

a

An analog value can be a. a measurement of the length of a rod b. all of the above c. a sequence of three single digit integers d. a sequence of four 0s and 1s

a

For a logic circuit to work as a storage element the output of the circuit must be fed back to the input. a. True b. False

a

For the LC-3 ISA, the ADD instruction does not require an EVALUATE ADDRESS phase. a. True b. False

a

If you write a whole C program all on one line with variable spacing between syntactic elements, it will still compile and execute correctly if you use proper C syntax. a. True b. False

a

In the article on effective practice techniques, what technique deals with studying material in a mixed sequence? a. Interleaved Practice b. Applicable Practice c. Spaced Practice d. Varied Practice e. Massed Practice

a

In the translation process, the compiler translates the source file into its corresponding machine code. The output of the compiler is called a. an object module b. an executable image c. a header file d. a library routine

a

Is the following number positive or negative (assuming it has been represented using the two's complement convention in 7 bits). 0b0110100 a. Positive b. Negative

a

JMP is an example of a/an ___________ instruction. a. Control b. Data Movement c. Operate

a

The LC-3 ADD instruction: a. can add a 16-bit value to a sign-extended 5-bit value b. can add a 16-bit value to a sign-extended 10-bit value c. can only add two 16-bit values found in registers d. can add a 16-bit value to a zero-extended 5-bit value

a

Which of the following is the correct way, in C, to declare a variable that holds a character and initialize it to G? a. char letter = 'G'; b. char letter = "G"; c. char letter = G;

a

A semicolon (;) alone on a line is

a comment that serves to make the program more readable to a human by separating two parts of the program with a blank line

The expression on which a switch decision is based CANNOT be

a double

An analog value can be

a measurement of the length of a rod

A combination circuit has inputs A,B,C and D. It should implement the function F = AB+CD+A'CD. We want a 2-level implementation using AND and OR gates. How many AND and OR gates do we need, assuming the circuit is implemented directly as specified without any minimization? (NOT Gates are needed, but not counted). a. 3 OR gates and 1 AND gate b. 3 AND gates and 1 OR gate c. 4 AND gates. d. 2 AND gates and 1 OR gate

b

Accessing a value in a register is slower than accessing a value in memory. a. True b. False

b

All LC-3 instructions modify the condition codes. a. True b. False

b

Every implementation of C for every ISA requires an int to be 32 bits. a. True b. False

b

Every line of a C program should end with a semicolon. a. True b. False

b

Fortran is a natural language. a. True b. False

b

Given: P is true What is the value of the expression P and not P a. True b. False

b

PC, IR, MAR, and MDR are ... a. clocks b. registers c. decoders d. muxes

b

Sometimes it is possible to carry out only a part of instruction, in which case, the computer only carries out that part of the instruction that it can. a. True b. False

b

The Evaluate Address phase can happen before the instruction Decode phase. a. True b. False

b

The LC-3 ALU can perform which three operations? a. OR, ADD, and NOT b. ADD, AND, and NOT c. NOT, AND, and OR d. SUB, AND, and NOT

b

What operation does the ^ symbol perform in C? a. bitwise NOT b. XOR c. logical NOT d. exponentiation

b

Which circuit has N inputs and up to 2^N outputs. This circuit also has the property that given any combination of values as input, only one of the circuits outputs will have the value 1. a. half adder b. decoder c. full adder d. multiplexer

b

Which of the following LC-3 instructions can only have operands that are in registers (i.e. cannot have immediate or memory operands)? a. ADD b. NOT c. AND d. LD

b

Which function dereferences an uninitialized pointer?

bar

Sequential Logic Circuits

base decisions on state and previous inputs

In gdb to set a break point at a specific line in your file what command would you use?

break <line number>

A C program starts with these two lines #include <stdio.h> # define MAX 25 What do they do? a. The first one indicates the beginning of a C program, and the second line states that the maximum value of any variable is 25. b. The first one includes a header file that you always need to have, and the second line states that MAX everywhere stands for number 25. c. The first one includes a header file that provides standard library I/O functions, and the second line states that MAX everywhere stands for number 25. d. The first one includes a header file that provides standard library I/O functions, and the second line states that the maximum value of any variable is 25.

c

A decoder with n inputs can have no more than _____ outputs. a. n b. 2*n c. 2^n d. log2(n)

c

Fill in the blanks.In C the local variable are defined only within their _____ while the global variables are always available. Local variables are stored _________, global variables are stored ________. a. scopes on the heap in the text segment b. functions on the run-time stack on the heap c. scopes on the run-time stack in the data segment. d. scopes on the run-time stack on the heap

c

If the operand of an instruction is a part of the instruction, the operand is called a(n) ___________ operand. a. indirect b. indefinite c. immediate d. local e. logical

c

In a Karnaugh map, two terms can be combined if they are "adjacent". "Adjacent' means that they are .. a. same for all variables except one, which is not complemented in one term and not presented in the other. b. are in the same row or the same column of the K-map. c. same for all variables except one, which is complemented in one term and uncomplemented in the other. d. the two cellls are toucing each other in the K-map.

c

LDR is an example of a/an ______________ instruction a. Control b. Operate c. Data Movement

c

Consider the following code: int *foo (){ int x= 10; return (&x); } int *bar (){ int * px; *px= 10; return px; } int *baz (){ int *px; px = (int *) malloc (sizeof(int)); *px= 10; return px; } Which function returns a pointer to a memory location that becomes invalid after the function returns? Which function dereferences an uninitialized pointer? Which function correctly returns a pointer to an int containing the value 10?

foo() bar() baz()

Some memory was allocated using the statement biz = (Zim*) malloc(2*sizeof(Zim)); We can free this memory using the statement

free(biz);

Consider the following code: typedef struct cat{ int **dog; int *y; }cat_t; int main() { struct cat *c = malloc(1 * sizeof(cat_t)); c->dog = malloc(34 * sizeof(int*)); // free memory here } What statements need to be added to free all allocated memory?

free(c->dog); free(c);

open circuit

gate of n-type is supplied with 0 volts

closed circuit

gate of n-type is supplied with 2.9 volts

To use GDB to debug the file testConv what command could you use? (Multiple answers may apply)

gdb then return, once inside gdb: file testConv gdb testConv

What commands to the program testSymbol are required for P4B that were not expressly required for P4A

get label order search reset size

The region of main memory where memory is allocated dynamically is called the

heap

The nodes in linked list are stored in the ...

heap.

Match the following characters to their purpose in a Linux file system. ~ . ..

home directory current directory parent directory

In gdb what command can be used to show information on the breakpoints that are set in the file you are debugging?

info breakpoints

An important first step in any algorithm, or computer program, is to __________ all the variables, that is, to put each variable into a known state.

initialize

You can implement NOR of A and B by (hint: build the truth tables)

inverting A and B and using an AND gate

Here is a code segment int a =3, b =6, c[10]; int *ip; ip = &a; b = *ip; *ip = 0; ip = &c[0]; What can we say about ip and a at this point?

ip now points to c[0] and a is currently 0.

Here is a code segment int x =1, y =2, z[10]; int *ip; ip = &x; y = *ip; *ip = 0; ip = &z[0]; What can we say about ip and x at this point?

ip now points to z[0] and x is currently 0.

Here is a code segment int x =5, y =20, z[4]; int *ip; ip = &y; x = *ip; *ip = 0; ip = z + 2; What can we say about ip and x at this point?

ip now points to z[2] and y is currently 0.

int a; int *j; What makes a and *j the same value

j = &a;

Per bit DRAM takes ____ space than SRAM, but requires _______.

less periodic refreshes

A __________ is a collection of programs/functions that can be used by application programmers to perform frequent tasks.

library

The #define preprocessor directive is used to provide the compiler with

macro substitutions.

If an allocation with malloc fails then

malloc returns NULL

as Cache Block Size increases...

miss penalty /\ Compulsory Misses \/

Use the man command to answer this question. less is a program similar to , but it has many more features. Less does not have to read the entire input file before starting, so with large input files it starts up than text editorslike vi.

more faster

Inside gdb to run a file called testConv that has already been loaded, with the the following arguments: i2c 10 9 what command would you need?

run i2c 10 9

Fill in the blanks.In C the local variable are defined only within their _____ while the global variables are always available. Local variables are stored _________, global variables are stored ________.

scopeson the run-time stackin the data segment.

Mux function

select one of the inputs and connect it to the output

Here is a code segment taken from the book. Fill in the blanks: typedef struct carType Car; _______ carType { int vehicleID; char make[20]; char model[20]; int year; int mileage; double cost; _______ *next; /* ptr to next car in list */ }

struct Car

Consider the function void swap (int x, int y) { int temp = x; x = y; y = temp; } int main(){ int a = 5; int b = 10; swap(a, b); } After the call to swap(a, b) in main() the values of a and b are not swapped because:

swap() only receives a copy of a and b, these copies are then swapped by swap().

What functions need to be implemented specifically for P4B

symbol_reset symbol_term symbol_order symbol_find_by_name symbol_find_by_addr compare_names compare_addresses symbol_size

In C, using the special character sequence \t in a printf statement causes a _________ character to be printed out.

tab

The following Valgrind output indicates what problem ==28069== Address 0x51fa0b8 is 16 bytes after a block of size 8 alloc'd

the address you are trying to access is not part of a block of allocated memory

Consider the following code: void printInt ( int n, int base ) { 2| char digit_table[ 16 ] = "0123456789abcdef"; if ( n >= base ) printInt ( n/base, base ); printf ( "%c", digit_table[n % base] ); } If base > 16 then an error may occur when

the index to digit_table is out of bounds division by zero is attempted at line 4 recursive call at line 4 fails to make progress as the two parameters remainthe same

After using the free function for a given node:

the memory is released for other usage

The components involved in the compilation process, listed in the order that they are used, are

the preprocessor, the compiler, and the linker.

In the KBSR, an interrupt signal is generated by the AND of:

the ready bit and the interrupt-enable bit

Consider the following code: int * ptr; int i = 5; *ptr = i; What will *ptr equal after this code;

the statement *ptr = i; dereferences an uninitialized pointer and may cause a segmentation fault

To keep track of data used within a C program, the compiler needs all the following information EXCEPT

the variable's initial value.

address space

total # of uniquely identifiable locations

The following command would define Number to have the same meaning as int using typedef:

typedef int Number

A 2-to-4 decoder has two inputs A and B and outputs W, X, Y, Z. When A=1, B=0, Y is selected. When is W selected?

when A=0, B=0

A decoder has two inputs A and B and outputs D0, D1, D2, D3. When A=0, B=0, D0 is selected. When is D3 selected?

when A=1, B=1

On a write-through cache write around refers to not fetching the missing block from memory before writing the updated value for the block to memory. This behavior would not be helpful if the code that is accessing the memory locations found in the block is doing a mixture of reads and writes

write around is doing a mixture of reads and writes

If we want to keep identical data in memory and cache at all times we would want to implement a [1] cache.

write-through

If we want to keep identical data in memory and cache at all times we would want to implement a [1] cache. write-back

write-through

If we want to keep identical data in memory and cache at all times we would want to implement a ______ cache.

write-through

Consider the following code: int arr[3] = {1, 2, 3}; int *p = arr; int x = *p++; int y = *p; What is the value of x and y after this code executes?

x = 1, y = 2

What is the value of x and y after these instructions? x = 3; y = --x+1;

x = 2, y = 3

What is the value of x and y after these instructions? x = 3; y = --x+1;

x = 2, y = 3

What is the value of x and y after these instructions? x = 3; y = --x+1;

x = 2, y = 3

What is the value of x and y after these instructions?x = 3;y = --x+1;

x = 2, y = 3

Here is a code segment int x =1, y =3, z[8]; int *ip; ip = &y; x = *ip; What is the value of x at this point?

x is now 3

Here is a code segment int x =1, y =3, z[8]; int *ip; ip = &y; x = *ip; What is the value of x at this point?

x is now 3.

Here is a code segment int x =1, y =3, z[8]; int *ip; ip = &y; x = *ip; What is the value of x at this point?

x is now 3.

In the following program, what would the contents of R0 and R6 right before HALT? (This question is not using the stack protocol we have discussed just pushing and popping from a basic stack) ;Calling program.ORIG x3000LD R6, STACKLD R0, AJSR PUSHLD R0, BJSR PUSHJSR POPLD R0, CJSR PUSHJSR POPJSR POPHALT;subroutinePOP LDR R0, R6, #0 ; The actual "pop."ADD R6, R6, #1 ; Adjust stack pointerBRnzp success_exitPUSH ADD R6, R6, #-1 ; Adjust stack pointerSTR R0, R6, #0 ; The actual "push"success_exit RETSTACK .FILL x301bA .FILL x03B .FILL x04C .Fill x05.END R0 = x03 R6 = x301B

x03 x301B

What does the PC contain on executing JSR FOO in the following code fragment: .ORIG x3000 JSR FOO ADD R0,R4,R2 FOO ADD R0,R0,#1 RET

x3002

The execution of the JSR instruction at location x4202, causes R7 to be loaded with:

x4203

int x =9, y =5, z[10]; ​ int *pi; ​ pi = &x; ​ y = *pi; ​ *pi = 0; ​ What are the values of x and y after this code executes?​

x: 0, y: 9

What is the output of the following C statement? printf("x%x", 15);

xf

We want to allocate enough memory for an 11 element array, where each element of the array is of type char. We can do that by using a statement like this ...

zib = (char *) malloc(11*sizeof(char)); where zib points to a variable of the type char

We want to allocate enough memory for an 5 element array, where each element of the array is of type double. We can do that by using a statement like this ...

zib = (double *) malloc(5*sizeof(double)); where zib points to a variable of the type double

We want to allocate enough memory for an 7 element array, where each element of the array is of type float. We can do that by using a statement like this ...

zib = (float *) malloc(7*sizeof(float)); where zib points to a variable of the type float

What operator symbol in C performs a bit-wise OR

|

Match the bitwise operator to the operation. | & ^ ~ << >>

| OR & AND ^ XOR ~ NOT / Complement << Left Shift >> Right Shift

In C, the symbol used to designate the bitwise NOT operator is:

~

What operator symbol in C performs a bit-wise NOT?

~

Match the following characters to their purpose in a Linux file system.

~ home directory . current directory .. parent directory


Conjuntos de estudio relacionados

Psychology: Chapter 4 Study Guide

View Set

OT Survey: Poetry and Prophecy study guide

View Set

Pathophysiology Review Questions

View Set

02/03: Phonics and Word Analysis

View Set