1/85
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
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
What is a subroutine
A sequence of instructions which may be executed by using a call instruction in Y86-64
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
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
What is the most significant bit in any ASCII character code (without parity)
Always 0
What is the range of values that can be encoded as a B2U number of n bits
0 to 2^n - 1
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
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
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
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
What is the key idea of pipelining?
To improve performance by executing multiple instructions at the same time
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
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
Hazards with pipelining?
Data hazards & instruction hazards
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
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
For an IEEE single precision value (32-bit encoding), how many bits are used to encode the mantissa?
23 bits
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
If the bit string 110 is a B2O encoding of an integer, which integer is it?
-1
If the bit string 110 is a B2T encoding of an integer, which is it?
-2
If 110 is a B2S integer, which is it?
-2
Range of B2T integers?
-2^(n-1) to 2^(n-1) - 1
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
What is true about the MAR register of a simple accumulator architecture?
It is only used for the CPU to send addresses to memory
Which method of encoding signed ints is used today?
B2T
How much did we say pipeline hazards reduce performance in real pipelines below theoretical maximum?
About 10%
What is an important practical significance of Boolean identites/laws?
Reduce cost of circuit, amount of heat, and power consumed
Which of the gates are universal?
NAND and NOR
What is a full-adder circuit?
Circuit that takes 2 operand bits & carry-in bit as inputs, outputs sum bit and carry out bit
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
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
Which of the following gates can be used to compare the last 2 carries to set the overflow flag in the CPU?
XOR
How many bits in a word (today)?
Usually 64
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
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)
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
Which of the following is true of RISC & CISC
RISC instructions always the same length
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
What is the IR in a CPU
Register to store the bit string for the instruction being executed
If a mutiplexor has 8 input lines to select from, how many control lines are needed?
3
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
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
How to tell error in B2T addition?
If last two carries differ
How many bytes is a UTF-8 encoding?
between 1 and 4
What type of processors are Mac M1-M3s?
RISC
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)
How is exponent of IEEE 754 encoded?
8-bit unsigned value with 127 bias to subtract
What reasons to learn C?
Still one of most common languages
Commonly used for operating systems, device drivers, embedded systems
Very low overhead & fast
What is the initial value of an int declared in main()
Main is a block, so storage class is automatic—> initialized to garbage
In a C function, where must a function be declared before it can bee called?
In the same source file
What order do the systems programs build a C executable?
Preprocessor → compiler → assembler → linker
What is the value of argc
Number of parameters + 1 (for program name)
What would the value of argv[argc] be in main?
NULL
What is the storage class for a parameter declared in a function definition?
Automatic
Where can the register keyword be used on a variable in C?
It can only be used for variables declared with block scope
Where can the keyword ‘static’ NOT be used?
In the declaration of a parameter in a function definition
How is a static variable declared inside a function initialized? (ex: function(){ static int x …}
0
Equivalent to NodePtr→next?
(*NodePtr).next
Fill in the blank:
float rate;
scanf(“%f”, _____);
float rate;
scanf(“%f”, &rate);
Return type of calloc() is…
void *
Where does a NULL pointer point?
The address 0
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
What aggregate data types did we learn?
Structures & arrays
What type of programming language is C?
Procedural
What function makes it unnecessary to keep track of string size?
strlen
What did we say about the size of a static array?
It must be a constant value (not a variable)
How do Boolean-like objects work in C?
Any expression which evaluates to 0 will be treated as false.
What to know about calloc()
Replaces malloc() on coelinux
Returns NULL if bytes can’t be allocated
Initializes all bytes to 0
Where can variables declared inside blocks be validly declared in C18?
There are no restrictions—C18 has just-in-time declaration
How to pass intVar by reference?
int intVar;
int *intPtr = &intVar;
function(intPtr)
How does static keyword change linkage in file scope?
Changes linkage to internal
How does static keyword change declaration inside a block?
Storage class becomes static
Default linkage for file scope variables?
External
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
What parameters to pass to free()?
Just 1 - pointer to or address of first byte of allocated memory
What is the linkage of a function parameter?
None
void insertNode (Node **listHeadPtr, Node *newNodePtr) {
Node *traversePtr = *listHeadPtr;
if (traversePtr == NULL) {
*listHeadPtr = new Node Ptr;
______________________;
}
newNodePtr→next = NULL
void insertNode (______ listHeadPtr, Node *newNodePtr) {
Node *traversePtr = *listHeadPtr;
if (traversePtr == NULL) {
*listHeadPtr = new Node Ptr;
newNodePtr→next = NULL;
}
Node **
void insertNode (Node **listHeadPtr, Node *newNodePtr) {
Node *traversePtr = _______;
if (traversePtr == NULL) {
*listHeadPtr = new Node Ptr;
newNodePtr→next = NULL;
}
*listHeadPtr
void insertNode (Node **listHeadPtr, Node *newNodePtr) {
Node *traversePtr = *listHeadPtr;
if (traversePtr == NULL) {
_____________________;
newNodePtr→next = NULL;
}
*listHeadPtr = newNodePtr
void insertNode(…) {
if (traversePtr == NULL) {…}
else if (newNodePtr→book.stockNumber < traversePtr→book.stockNumber {
______________________;
newNodePtr→next = traversePtr;
}
*listHeadPtr = newNodePtr
void insertNode(…) {
if (traversePtr == NULL) {…}
else if (newNodePtr→book.stockNumber < traversePtr→book.stockNumber {
*listHeadPtr = newNodePtr;
_______________________;
}
newNodePtr→next = traversePtr
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
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
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
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