CSE MT1 & MT2 Questions (for Final)

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/85

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

86 Terms

1
New cards

For 1’s complement addition, which type of gate can be used with an input of the two msbs for the two numbers being added to output the correct bit to use as the first carry?

AND

2
New cards

What is a subroutine

A sequence of instructions which may be executed by using a call instruction in Y86-64

3
New cards

In Y86-64, how must the flags (condition codes) be set if the jump is taken for a jg label instruction?

The sign flag is 0 and the zero flag is 0

4
New cards

What kinds of values can be encoded precisely in IEEE 754 with finite bits?

Values which can be written as a quotient x/y, where y is a number which can be written as a power of 2

5
New cards

What is the most significant bit in any ASCII character code (without parity)

Always 0

6
New cards

What is the range of values that can be encoded as a B2U number of n bits

0 to 2^n - 1

7
New cards

What is true of a sequential circuit?
a) it always uses a clock input signal

b) it has ‘memory’; that is, it can store prior state

c) Its current output may depend on current input as well as prior input

d) all of the above

d) all of the above

8
New cards

For a D gate/latch/flip-flop, which we said is implemented with a clocked SR gate/latch/flip-flop, how do the D gate inputs correspond to the SR gate?

D is the S input, and not-D is the R input

9
New cards

In Y86-64, what does a ret instruction do?

It first pops the return address of the stack, then writes the address to the PC

10
New cards

Which of the following is true of the number of registers in Y86-64?

It is different then the # of registers in any real CPU because it is not equal to a power of 2

11
New cards

What is the key idea of pipelining?

To improve performance by executing multiple instructions at the same time

12
New cards

If a processor is pipelined, and if the pipeline has 12 stages, what is the theoretical maximum performance improvement once fully loaded?

Instructions will be executed 12 times faster

13
New cards

When a cache is used, what is the difference between write-through and write-back?

Write-through: changes to data in the cache are written to memory immediately

Write-back: changes not written until the cache block is evicted

14
New cards

Hazards with pipelining?

Data hazards & instruction hazards

15
New cards

What is true about addition of two B2U encoded numbers as described in a CPU?

If the last carry is 1, the result is incorrect

16
New cards

For a direct-mapped cache system using 16-bit addresses: if the blocks are 16 bytes long (2^4) and the cache is 128 blocks (2^7), how many bits is the tag?

5 bits long

17
New cards

For an IEEE single precision value (32-bit encoding), how many bits are used to encode the mantissa?

23 bits

18
New cards

What happens in Y86-64 when a function is called?

First, the simulated CPU pushes the address in the PC onto the stack; then, the address of the function1 label will be written to the PC register

19
New cards

If the bit string 110 is a B2O encoding of an integer, which integer is it?

-1

20
New cards

If the bit string 110 is a B2T encoding of an integer, which is it?

-2

21
New cards

If 110 is a B2S integer, which is it?

-2

22
New cards

Range of B2T integers?

-2^(n-1) to 2^(n-1) - 1

23
New cards

Which is true about assembly language labels:

A. When the assembly language is converted to machine language, the label occupies no space in memory

B. Labels mark addresses

C. Labels can be used to mark address of particular instruction

D. All of the above

D. All of the above

24
New cards

What is true about the MAR register of a simple accumulator architecture?

It is only used for the CPU to send addresses to memory

25
New cards

Which method of encoding signed ints is used today?

B2T

26
New cards

How much did we say pipeline hazards reduce performance in real pipelines below theoretical maximum?

About 10%

27
New cards

What is an important practical significance of Boolean identites/laws?

Reduce cost of circuit, amount of heat, and power consumed

28
New cards

Which of the gates are universal?

NAND and NOR

29
New cards

What is a full-adder circuit?

Circuit that takes 2 operand bits & carry-in bit as inputs, outputs sum bit and carry out bit

30
New cards

How is subtraction a - b done by a CPU using B2T?

Add a to the inverted bit string for b, using a carry bit of 1 for the lsbs

31
New cards

If a parity bit is used to transmit ASCII, when will the receiver determine that an error has occurred?

If the number of 1s received for a one-byte character encoding is odd

32
New cards

Which of the following gates can be used to compare the last 2 carries to set the overflow flag in the CPU?

XOR

33
New cards

How many bits in a word (today)?

Usually 64

34
New cards

Little-endian vs big-endian encoded data?

Little-endian storage of data in memory has least significant byte in a piece of numerical data stored at the lowest numbered address, or first

35
New cards

What’s address alignment?

The fact that, in some systems, memory addresses where valid words can be stored must be divisible by a certain whole number (like 8)

36
New cards

Which of the following is a type of operation that a CPU can do?

Arithmetic & logical operations, moveing/transfering data from CPU to memory or vice versa, program sequencing & control operations

37
New cards

Which of the following is true of RISC & CISC

RISC instructions always the same length

38
New cards

What is the PC in a CPU?

Register to store the address of the instruction to be read/fetched until the address is sent to memory

39
New cards

What is the IR in a CPU

Register to store the bit string for the instruction being executed

40
New cards

If a mutiplexor has 8 input lines to select from, how many control lines are needed?

3

41
New cards

Problem with return register for return address in subroutine call?

If a subroutine needs to call another before returning to calling subroutine, original return address will be overwritten

42
New cards

For a logical instruction, what does Y86-64 store in the overflow flag?

Always 0, since there can’t be overflow for a logical instruction

43
New cards

How to tell error in B2T addition?

If last two carries differ

44
New cards

How many bytes is a UTF-8 encoding?

between 1 and 4

45
New cards

What type of processors are Mac M1-M3s?

RISC

46
New cards

How many bytes are moved to and from teh cache when there’s a cache miss?

A whole block (block size depends on cache design)

47
New cards

How is exponent of IEEE 754 encoded?

8-bit unsigned value with 127 bias to subtract

48
New cards

What reasons to learn C?

Still one of most common languages

Commonly used for operating systems, device drivers, embedded systems

Very low overhead & fast

49
New cards

What is the initial value of an int declared in main()

Main is a block, so storage class is automatic—> initialized to garbage

50
New cards

In a C function, where must a function be declared before it can bee called?

In the same source file

51
New cards

What order do the systems programs build a C executable?

Preprocessor → compiler → assembler → linker

52
New cards

What is the value of argc

Number of parameters + 1 (for program name)

53
New cards

What would the value of argv[argc] be in main?

NULL

54
New cards

What is the storage class for a parameter declared in a function definition?

Automatic

55
New cards

Where can the register keyword be used on a variable in C?

It can only be used for variables declared with block scope

56
New cards

Where can the keyword ‘static’ NOT be used?

In the declaration of a parameter in a function definition

57
New cards

How is a static variable declared inside a function initialized? (ex: function(){ static int x …}

0

58
New cards

Equivalent to NodePtr→next?

(*NodePtr).next

59
New cards

Fill in the blank:

float rate;

scanf(“%f”, _____);

float rate;

scanf(“%f”, &rate);

60
New cards

Return type of calloc() is…

void *

61
New cards

Where does a NULL pointer point?

The address 0

62
New cards

What’s wrong here:

char *string1 = “Frutus”

string1[0] = “B”;

pointer to char strings can’t be edited, but can change where they point - SEGMENTATION FAULT

63
New cards

What aggregate data types did we learn?

Structures & arrays

64
New cards

What type of programming language is C?

Procedural

65
New cards

What function makes it unnecessary to keep track of string size?

strlen

66
New cards

What did we say about the size of a static array?

It must be a constant value (not a variable)

67
New cards

How do Boolean-like objects work in C?

Any expression which evaluates to 0 will be treated as false.

68
New cards

What to know about calloc()

  1. Replaces malloc() on coelinux

  2. Returns NULL if bytes can’t be allocated

  3. Initializes all bytes to 0

69
New cards

Where can variables declared inside blocks be validly declared in C18?

There are no restrictions—C18 has just-in-time declaration

70
New cards

How to pass intVar by reference?

int intVar;

int *intPtr = &intVar;

function(intPtr)

71
New cards

How does static keyword change linkage in file scope?

Changes linkage to internal

72
New cards

How does static keyword change declaration inside a block?

Storage class becomes static

73
New cards

Default linkage for file scope variables?

External

74
New cards

How many memory accesses to read a dereferenced pointer?

2 - first to read the address stored in the ptr, then to read the value at that address

75
New cards

What parameters to pass to free()?

Just 1 - pointer to or address of first byte of allocated memory

76
New cards

What is the linkage of a function parameter?

None

77
New cards

void insertNode (Node **listHeadPtr, Node *newNodePtr) {

Node *traversePtr = *listHeadPtr;

if (traversePtr == NULL) {

*listHeadPtr = new Node Ptr;

______________________;

}

newNodePtr→next = NULL

78
New cards

void insertNode (______ listHeadPtr, Node *newNodePtr) {

Node *traversePtr = *listHeadPtr;

if (traversePtr == NULL) {

*listHeadPtr = new Node Ptr;

newNodePtr→next = NULL;

}

Node **

79
New cards

void insertNode (Node **listHeadPtr, Node *newNodePtr) {

Node *traversePtr = _______;

if (traversePtr == NULL) {

*listHeadPtr = new Node Ptr;

newNodePtr→next = NULL;

}

*listHeadPtr

80
New cards

void insertNode (Node **listHeadPtr, Node *newNodePtr) {

Node *traversePtr = *listHeadPtr;

if (traversePtr == NULL) {

_____________________;

newNodePtr→next = NULL;

}

*listHeadPtr = newNodePtr

81
New cards

void insertNode(…) {

if (traversePtr == NULL) {…}

else if (newNodePtr→book.stockNumber < traversePtr→book.stockNumber {

______________________;

newNodePtr→next = traversePtr;

}

*listHeadPtr = newNodePtr

82
New cards

void insertNode(…) {

if (traversePtr == NULL) {…}

else if (newNodePtr→book.stockNumber < traversePtr→book.stockNumber {

*listHeadPtr = newNodePtr;

_______________________;

}

newNodePtr→next = traversePtr

83
New cards

void insertNode(…) {

if (traversePtr == NULL) {…}

else if (newNodePtr→book.stockNumber < traversePtr→book.stockNumber {…}

else {

Node *priorNodePtr = traversePtr;

traversePtr = traversePtr→next;

while ( _________ && traversePtr→book.stockNumber < newNodePtr→book.stockNumber) {

priorNodePtr = traversePtr;

traversePtr = traversePtr→next;

}

priorNodePtr→next = newNodePtr;

newNodePtr→next = traversePtr;

}

}

traversePtr != NULL

84
New cards

void insertNode(…) {

if (traversePtr == NULL) {…}

else if (newNodePtr→book.stockNumber < traversePtr→book.stockNumber {…}

else {

Node *priorNodePtr = traversePtr;

traversePtr = traversePtr→next;

while ( traversePtr != NULL && ___________) {

priorNodePtr = traversePtr;

traversePtr = traversePtr→next;

}

priorNodePtr→next = newNodePtr;

newNodePtr→next = traversePtr;

}

}

traversePtr→book.stockNumber < newNodePtr→book.stockNumber

85
New cards

void insertNode(…) {

if (traversePtr == NULL) {…}

else if (newNodePtr→book.stockNumber < traversePtr→book.stockNumber {…}

else {

Node *priorNodePtr = traversePtr;

traversePtr = traversePtr→next;

while ( traversePtr != NULL && traversePtr→book.stockNumber < newNodePtr→book.stockNumber) {

priorNodePtr = traversePtr;

traversePtr = traversePtr→next;

}

_________________________;

newNodePtr→next = traversePtr;

}

}

priorNodePtr→next = newNodePtr

86
New cards

void insertNode(…) {

if (traversePtr == NULL) {…}

else if (newNodePtr→book.stockNumber < traversePtr→book.stockNumber {…}

else {

Node *priorNodePtr = traversePtr;

traversePtr = traversePtr→next;

while ( traversePtr != NULL && traversePtr→book.stockNumber < newNodePtr→book.stockNumber) {

priorNodePtr = traversePtr;

traversePtr = traversePtr→next;

}

priorNodePtr→next = newNodePtr;

___________________________;

}

}

newNodePtr→next = traversePtr