JMU CS261 Final
In ATT format for x86-64 assembly, how would you write the constant number 12 as an operand specifier for an instruction?
$12
How would you access the least significant byte of the %rax register?
%al
How would you access the least significant byte of the %rcx register?
%cl
Which of the following must be saved by a calling procedure in x86-64 if its value must be preserved through the procedure call?
%r11
Which of the following must be saved by a called procedure in x86-64 if the procedure wishes to use the register?
%r13
In x86-64, assume the %rax register stores the address of the data you want to access. Which of the following operand specifiers could NOT be used to access the data?
%rax
Which register is typically used to store the return value of a procedure in x86-64?
%rax
Which of the following registers is NOT typically used in x86-64 to pass arguments to a procedure?
%rbx
In x86-64, which register holds the program counter?
%rip
In x86-64, which register indicates the address in memory of the next instruction to be executed?
%rip
The target of some jump instructions is encoded relative to which register?
%rip
Which of the following x86-64 memory operands correctly references an array element? Assume that %rbx stores the base address of the array, and %rdi stores the index of the element in the array? Assume each element is 64 bits wide.
( %rbx , %rdi, 8 )
What is the Boolean formula for the following circuit? Note that the small circles ("bubbles") mean logical negation. Picture at: https://w3.cs.jmu.edu/lam2mo/cs261_2016_08/images/circuit01.png
(!a && b && !c) || (!a && !b && !c)
Which of the following x86-64 memory operands correctly references an array element, if %rbx stores the base offset of the array and %rdi stores the element's index in the array? Assume each element is 16 bits wide.
(%rbx, %rdi, 2)
What is the Boolean expression for "a XOR b" ?
(a && !b) || (!a && b)
Which HCL/boolean formula(s) have the same output as the following circuit? Select all that apply. picture at: https://canvas.jmu.edu/files/81391713/download?download_frd=1&verifier=daraL5VuDRBNUD7LU1MboGx86F0EuAd7xK6gPASb
(b && s) || (a && !s)
Which C operator is used to dereference a pointer?
* i.e. the star
Using the IEEE-754 single-precision standard,a floating-point number is stored in memory as the hexadecimal value C17A0000 What is the corresponding decimal value?
-15.625
What is the offset of the "c" field in the following data type? union foo { uint8_t a; uint16_t b; uint32_t c; uint64_t d; };
0
In 4-bit two's complement representation, what is the binary encoding of the number 5?
0101
Let x be an 8-bit unsigned variable storing 0xc3. What is the result of calculating (x << 2) >> 3?
0x01
Assume that x is a 32-bit int that has the value 5, and the address of x is 0x0804a254. If the machine is a big endian architecture, what is stored at address 0x0804a257?
0x05
Assume that x is a 4-byte int that has the value 5, and the address of x is 0x0804a254. If the machine is a Big-Endian architecture, what is stored at address 0x0804a257?
0x05
Assume that %rax stores the memory address 0x1000. The value stored in memory at location 0x1000 is 0x500. What is the effective address of the operand specifier: 2( %rax ) ?
0x1002
What is the hex result of: 0x26 & 0xA5
0x24
What is the hex result of ~(0xa7 | 0x3c)?
0x40
What is the hex result of 0x52 & 0x7c?
0x50
Assume that x is a 32-bit int that has the value 0xab78f29e, and the address of x is 0x08049000. If the machine is a little endian architecture, what byte value is stored at address 0x08049003?
0xab
What is the hex result of: ~( 0xa7 | 0x3c ) (note the tilde in front of the parentheses)
0xdb
Consider the instruction "rmmovq %rax, 4(%rsp)". If %rax is 2 and %rsp is 0xee0, what is the value of valE after the execute stage?
0xee4
Consider the instruction: rmmovq %rax, 4(%rsp) If %rax is 2 and %rsp is 0xee0, what is the value of valE after the execute stage?
0xee4
Give an example of a decimal (base 10) number that would have the same meaning in decimal, binary, and hexadecimal.
1
What is the decimal equivalent of the binary value 1.101?
1.625
In 4-bit two's complement representation, what is the binary encoding of the number -5?
1011
What is the binary expansion of the hexadecimal value 0xc02d?
1100000000101101
What is the value of x << 2 if x is equal to 3 in 8-bit unsigned binary?
12
What is the value of x after execution of the following code assuming x and y are 8-bit unsigned integer values and x originally equals 4? y = x;x = x << 1;x = x + y;
12
What is the result in base 10 of the addition of 0101 1011 + 0010 0100 if using 8-bit unsigned binary representation?
127
What is the result in base 10 of the addition of: 0101 1011 + 0010 0100 if using 8-bit two's complement representation?
127
Assume a struct contains three elements: a 4-byte field, a 2-byte field, and an 8-byte field. With a 2-byte alignment restriction, what is the total number of bytes required for the struct?
14
Assume a struct contains three elements: a 4-byte field, a 2-byte field, and an 8-byte field. With a 4-byte alignment restriction, what is the total number of bytes required for the struct?
16
The x86-64 integer register file contains how much storage?
16 registers for 64-bit values
What is the result in base 10 of the addition of 0100 1101 + 0110 0011 if using 8-bit unsigned binary representation?
176
What is the result in decimal of the addition of 0100 1101 and 0110 0011 if using 8-bit unsigned binary representation?
176
Give the decimal (base 10) equivalent of a 4-bit integer bit pattern that would have the same meaning in unsigned, 1's complement, and 2's complement.
2
Using an 16-bit floating point representation with 1 sign bit, 6 exponent bits with a bias of 31, and 9 fractional bits, what is the decimal value of the hexadecimal value 4000?
2
What is the decimal equivalent of the binary value 10.01?
2.25
What is the decimal value of the C expression 1 << 8 ?
256
What is the decimal equivalent of the binary value 11.01?
3.25
Which of the following is NOT a valid interpretation of the 4-bit binary value 1100?
30 in base 8
What is the maximum value representable by a signed 16-bit integer?
32,767
What is the minimum amount of memory required to store a novel_t variable? Specify your answer as an exact numerical byte count.
36
If the register %rdx contains the value y, what value will be in %rax after executing this instruction: leaq $8 ( %rdx , %rdx , 2 ) , %rax
3y + 8
What is the limit of the virtual address space (i.e. the largest memory) size in bytes for a processor with a 32-bit word size?
4 GB
What is the little endian hex encoding of the following Y86-64 assembly instruction : rmmovq %rdi, 0x1234(%rbp)
40753412000000000000
What is the decimal equivalent of 0x2A?
42
Translate 0x2f into its decimal equivalent as an unsigned integer.
47
What is the output of the following code? Assume that the address of the variable x is 8 and the address of the variable y is 6. int x = 5; int *y = &x; *y = 1; printf ( "%d" , x + *y );
6
What is the value of x >> 2 if x is equal to 24 in 8-bit unsigned binary?
6
What is the decimal value of the binary fraction 110.01?
6.25
What will the value in %rax be after the following x86-64 code executes? movq $0x10 , %rax movq $8 , %rbx cmp %rax , %rbx cmovne %rbx , %rax
8
What will the value in %rax be after the following x86-64 code executes? movq $5, %rax movq $8, %rbx cmp %rax, %rbx cmovne %rbx, %rax
8
What is a disassembler?
A tool that parses an executable file to extract its instruction sequences
Which of the following statements about character encodings is FALSE?
ASCII contains encodings for all English, French, and Spanish alphabetic characters
Why would a conditional move be preferred over a move guarded by a conditional jump?
Better performance because of fewer branch predictions.
Which of the following is NOT true of combinational circuits?
Circuits may contain loops.
Which technique allows data to travel directly between disks and memory without passing through the CPU?
DMA
What technology is used for flash memory (e.g. SSDs)?
EEPROM
Which of the following statements is true of assembly code?
Every indented line corresponds to a single machine code instruction.
Significantly different hardware is required to perform addition in unsigned binary representation and 2's complement representation.
False
What kind of loop translation was used to generate the following x86-64 code? L1: testq %rsi , %rsi jz L3 movq %rsi , %rax L2: imulq %rdi , %rax subq %rdi , %rsi testq %rsi , %rsi jnz L2 L3: ret
Guarded-do
Which statement is generally true of the body of a short machine code loop?
It exhibits both good spatial locality and good temporal locality.
Which of the following is true of the Boolean expression: (a && b) || (!a && !b)
It is true if and only if a == b
Which of the following is true of the HCL/boolean expression "(a && b) || (!a && !b)"?
It is true if and only if a == b
What data structure can be used to make x86-64 translations of the C language's switch statements more efficient?
Jump table
Which of the following types of memory is the fastest, but also the smallest?
L1 cache
Which memory elements are typically shared by all cores on a CPU?
L3 cache and main memory
Which of the following is NOT a component of a standard for loop in the C language?
Label
Which of the following is NOT an advantage of SSDs over traditional disk drives?
Less expensive per byte
Which of the following techniques are used to prevent buffer overflow attacks? Choose all correct options.
Limiting executable memory regions Stack randomization Adding stack corruption detection
What happens during the memory stage of a rmmovq instruction?
Memory is written at the location specified by the effective address.
If an IEEE 754 floating-point number has the hex representation 0xFFFF0000, what kind of number is represented?
NaN
If an IEEE 754 floating-point number has the hex representation 0xFFFFFFFF, what kind of number is represented?
NaN
Which of the following statements is true of recursive procedures in x86-64?
No special handling is necessary to enable recursive procedure calls.
What happens during the decode stage of a jmp instruction?
Nothing.
Which of the following is NOT a common type of device controller that communicates with the CPU and main memory via the I/O bus?
RAM controller
A cache can be defined by the following tuple (S, E, B, m). Match each element in the tuple on the left with the correct meaning on the right. S: E: B: m:
S: the number of sets E: the number of lines per set B: the number of bytes per block m: the number of address bits for accessing memory
Which x86-64 condition code register indicates that the previous instruction produced a negative result?
SF
What technology is used for CPU cache memory?
SRAM
Which of the following statements is true about the technologies that SRAM and DRAM use to store information?
SRAM relies on transistors and DRAM relies on capacitors.
When converting a 32-bit signed two's-complement integer to a 64-bit signed two's-complement integer, which operation will preserve the correct value?
Sign extension
Which of the following are true about the memory hierarchy in a computing system? (Select all that are true.)
Storage devices get cheaper as we move from higher to lower levels Storage devices get slower as we move from higher to lower levels Storage devices get larger as we move from higher to lower levels
Which arithmetic operations are supported in Y86-64? (More than one answer may be correct.)
Subtraction Bitwise AND Addition
Assume that a function P calls a function Q. Immediately after the processor executes the call instruction, what would the %rsp register point to?
The address in P's code to return to after Q finishes
Assume that a function P calls a function Q. Immediately after the processor executes the call instruction, what would the %rsp register point to?
The address in P's code to return to after Q finishes
What should GET_YEAR be replaced by for correct functionality?
The answer is not: (*novels)[i].year
Using a 16-bit floating point representation with 1 sign bit, 6 exponent bits, and 9 fractional bits, what is the decimal value of the hexadecimal value BB00?
The answer is not: -0.275
When using 8-bit word size in unsigned binary addition of number x and y, overflow occurs when
The answer is not: -128 <= x + y < 128
Assume this code: short x = 0x8000 ; What is the hex value of the C expression x >> 2 ? Assume short integers are 16-bit wide.
The answer is not: 0x2000
Assume that x is an int that has the value 0xab78f29e. Also assume that the address of x is 0x08049000. If the machine is a Little-Endian architecture, what is the byte stored at address 0x08049001?
The answer is not: 0x9e
How many bytes of memory are needed to store the string "CS261 rocks!" in C?
The answer is not: 12
How many bytes of memory are needed to store the following string (notice the one space after the comma): "Hey, Jude"
The answer is not: 13
Which of the following is NOT true about character encodings?
The answer is not: ASCII character values have the same single-byte encoding in UTF-8
Which of the following is NOT true of processes?
The answer is not: The are an abstraction of running programs (I didn't get this question right)
What would happen if you try to compile and run the following code in a C function? char str[] = "hey jude"; str[3] = '\0'; printf ( "%s", &str[0]);
The answer is not: The code would compile, but there would be a segmentation fault.
Which of the following is true about compiling a C program with the -m64 flag?
The answer is not: The executable can run on either 32- or 64-bit architectures
Which of the following typically resides closest to the top end of an address space?
The answer is not: The user's read-only code (I didn't get this question right)
Which stage of compilation produces executable object files as output?
The answer is not: assembling
Consider the following line of code (assume it is in main()): char *c = (char*)malloc(sizeof(char)*16); What is the type of c[0][0]?
The answer is not: char (I didn't get this right)
Consider the following line of code (assume it is in main()): char *c = (char*)malloc(sizeof(char)*16); What is the type of *c?
The answer is not: char*
How would you access the 'title' field of the 'gatsby' variable?
The answer is not: char* title;
Threads from the same process share
The answer is not: code and local data (I didn't get this question right)
What is the part of the operating system that is always present in memory?
The answer is not: context switch (I didn't get this question right)
Which of the following commands will compile "test.c" into the executable "myprog", forcing the compiler to use the C99 standard?
The answer is not: gcc -std=c99 -o myprog -c test.c
What is the 8-bit 2's complement representation of the negation of: 0001 0001
The answer is not: negative overflow
Assume the pointer ptr is initialized to NULL. Which of the following lines will NOT produce a segmentation fault?
The answer is not: printf ( "%s", *ptr );
If you wanted to check how the value in register %rax is related to zero , which instruction would you use? Select all correct choices (if you think more than one choice is correct)
The answers are not: test %rax , $0 test %rax , %rax
Consider the following function: // Multiply two numbers and store the answer using result. void mul_ptr (int num1, int num2, int *result) { *result = num1 * num2; } Check all of the statements below that are true after this function finishes executing.
The answers are not: the calling function has access to the product of num1 and num2 the product of num1 and num2 is stored in the stack
Assume: char **ptr = 65 ; What would you get by accessing **ptr ?
The character whose address is stored in memory location 65
Which of the following statements is TRUE about the following code? int *x = 1; printf ("x = %d", *x);
The code will cause a segmentation fault
When converting a 32-bit unsigned integer to a 32-bit signed two's-complement integer, which operation will preserve the correct value?
The correct value cannot always be preserved
When converting a 64-bit unsigned integer to a 32-bit unsigned integer, which operation will preserve the correct value?
The correct value cannot always be preserved
What happens during the execute and write back stages of a pushq instruction?
The stack pointer is decremented.
Consider the following function: // Add two numbers and store the results in ans. void add_ptr (int num1, int num2, int *ans) { int sum = num1 + num2; ans = ∑ } int main() { int x=3, y=4, z; add_ptr( x , y, &z ); return 0; } Check all of the options below that are true after this function is called.
The value of sum inside the add_ptr() function will be equal to 7. The sum of num1 and num2 never makes it back to main().
Assume that a pointer, ptr, has the value 4567. What would you get by accessing *ptr[0]?
The value stored at the address that is stored at address 4567
Which of the following statements is FALSE about floating point representations?
There is a unique floating-point number for every bit pattern.
Which of the following statements is TRUE about the following code? int *x = 0; printf ( "x = %d", *x );
There is not enough information to know the output.
Which of the following is NOT true of IEEE 754 floating-point numbers?
They are equally spaced on the number line
Consider the four-bit value 1101. Choose all of the answers below that are true: A wrong answers cancels out a correct one, so choose wisely.
This value represents -3 in 2's complement representation This value represents 13 in unsigned binary
Which of the following is true?
Typecasting a 16-bit unsigned integer into a 7-bit unsigned integer is equivalent to performing a modulo-128 operation and keeping the remainder.
Which of the following is NOT true of arrays in C?
Variable-size arrays must be allocated on the heap.
What kind of loop translation was used to generate the following x86-64 code? jmp .L2 .L1: addq $2, %rbx .L2: cmpq %rsi, %rbx jl .L1
While using Jump-to-Middle
Which of the following selections is the same between x86-64 and Y86-64?
Y86-64 uses the stack to implement the call and ret instructions
Which of the following is NOT a reason to understand how compilation works?
You can quickly debug run-time exceptions
When converting a 32-bit unsigned integer to a 64-bit unsigned integer, which operation will preserve the correct value?
Zero extension
Multiplication by an arbitrary constant can be accomplished by using
a combination of shifting, adding, and subtracting
A cache memory is
a small, fast buffer for larger, slower memory.
Given the following function in assembly code, what kind of instruction begins at address 0x40061C ? 0000000000400606 <add>:400606: 55 push %rbp400607: 48 89 e5 mov %rsp,%rbp40060a: 89 fa mov %edi,%edx40060c: 89 f0 mov %esi,%eax40060e: 88 55 fc mov %dl,-0x4(%rbp)400611: 88 45 f8 mov %al,-0x8(%rbp)400614: 0f b6 55 fc movzbl -0x4(%rbp),%edx400618: 0f b6 45 f8 movzbl -0x8(%rbp),%eax40061c: 01 d0 add %edx,%eax40061e: 5d pop %rbp40061f: c3 retq
add
Printing &x will produce what output?
address of x
A pointer is a variable that stores what type of information?
an address
x86_64 is
an instruction set architecture (ISA)
Which of the following instructions does NOT require an eight-byte immediate value or destination address?
andq
Consider the following C code: typedef struct point { int x; int y; } point_t; int distsq3( point_t *p , point_t *q ) { int dx = p->x - q->x; int dy = p->y - q->y; return dx*dx + dy*dy; } Convert the above C code to assembly by completing the missing parts in the following partial x86-64 code: distsq3: mov ( %rdi ) , %eax sub %rdi , %eax mov 0x4 ( %rdi ) , %edx sub [ Select ] , %edx imul %eax , %eax imul [ Select ], %edx add %edx , %eax retq
answer 1: ( %rsi ) answer 2: 0x4 ( %rsi ) answer 3: %eax answer 4: %edx
Consider the x86-64 code below: movq $0x2468 , %rax shr $1 , %rax pushq %rax sal $1 , %rax mov %rax , %rbx pushq %rbx popq %rcx popq %rbx After the above code executes, what are the values in hexadecimal of each of the registers listed below: %rax: %rbx: %rcx:
answer 1: 0x2468 answer 2: 0x1234 answer 3: 0x2468
Consider the following C code: int add( int x , int y ) { return x + y; } Complete the following x86-64 assembly code in order to translate the above C function: add: [ Select ] %eax , %eax addl %ecx , %eax addl %ebx , %eax [ Select ]
answer 1: xorl answer 2: %edi answer 3: %esi answer 4: retq
Which stage of compilation produces object files as output?
assembling
Which stage(s) of compilation will occur by executing gcc -c code.c?
assembling compiling preprocessing
Which stage(s) of compilation will occur by executing gcc -c code.c? (More than one may be correct.)
assembling compiling preprocessing
Match the Intel x86 instruction postfix with its meaning.
b: byte (8-bit) w: word (16-bit) l: double word (32-bit) q: quad word (64-bit)
If a program accesses (in rapid succession) many values that are all exactly 1027 bytes apart in memory, that program exhibits
bad spatial locality.
Assume there is a two-dimensional array starting at address "base". It has "r" number of rows and "c" number of columns. Each array element is "size" bytes wide. What is the address of the item in the ith row and the jth column, assuming that the array is stored in row-major order?
base + size * (c * i + j)
If "base" is the address of the first element in an array, "size" is the size (in bytes) of each element, what is the address of the ith element?
base + size * i
Which of the following is NOT stored explicitly in the IEEE 754 format?
bias
Which component is used to carry word-size chunks of information?
buses
A file is a sequence of
bytes
When a requested data object is not present in a cache, this is called a
cache miss
Which of the following Y86-64 instructions decrements the stack pointer?
call
When a working set cannot fit in a cache, the cache is experiencing a
capacity miss
Given the declaration: char **argv ; what is the type of & argv[0] ?
char **
Consider the following line of code (assume it is in main()): char *c = (char*)malloc(sizeof(char) *16); What is the type of &c?
char**
Which of the following Y86-64 instructions does NOT modify the stack?
cmovle
Which component for a digital system computes functions on bits?
combinational logic
Information = bits +
context
What distinguishes the meaning of bits used to represent data objects?
context
Which two stages of execution read from or write to the register file?
decode and write back
Which of the following are effects of the call instruction? Choose all that apply.
decrements the stack pointer pushes the address of the next instruction on the stack changes the control flow of the program
If the exponent field of an IEEE 754 floating-point number is all zeros but the significand has at least one non-zero bit, what kind of number is represented?
denormalized
When a device writes directly to memory without involving the CPU, it is called
direct memory access
Consider the following line of code (assume it is in main()): double *d = (double*) malloc( sizeof(double) ); What is the type of &d ?
double **
Consider the following line of code (assume it is in main()): double *d = (double*) malloc( sizeof(double) ); What is the type of d ?
double*
What is the output of the following code? Assume that the address of the variable s is 10 and the address of the variable t is 11. char s = 'c'; char *t = &s; *t = *t + 1; printf ("%c", *t + 1);
e
During which stage of execution for a jle instruction does the CPU determine (but not actually make the jump) whether or not the branch should be taken?
execute
During which stage of execution does the CPU determine that an irmovq will use %rsi?
fetch
What is the correct order for the stages of executing a single Y86 instruction?
fetch, decode, execute, memory, write back, PC update
Which standard C library function is used to load a line of text data from a file? Enter the name of the function only in lowercase letters - no parentheses, parameters, or return type.
fgets
Given the declaration float **matrix, what is the type of &matrix[0]?
float**
If a program accesses the same location many times in a short period of time, that program exhibits
good temporal locality.
Which of the following instructions will set the processor status code to something other than AOK?
halt
Which of the following opcodes can be used to multiply a number by 4 using a single instruction? Choose all correct answers.
imul sal lea
Assume the %rbx register stores the value 5, and the %rax register stores the value -3. Which x86-64 instruction would multiply 5 and -3, leaving the result in %rbx ?
imulq %rax , %rbx
If an IEEE 754 floating-point number has the hex representation 0x7F800000, what kind of number is represented?
infinity
Which of the following provides an abstraction of the actual processor hardware?
instruction set architecture
Which of the following provides an abstraction of the operations executed by a CPU?
instruction set architecture
Which of the following describe the "shell"? (More than one answer may be correct.)
it prints a prompt then waits for the user to type a command line it is a command-line interpreter it performs commands typed by the user
If you wanted to test whether some value A is > 0 , which conditional jump instruction would you use? (Assume A is unsigned.)
ja
If you wanted to make a jump if ( x < 0 ) , which conditional jump instruction would be most appropriate? (Assume x is signed.)
jl
If you wanted to test whether (y <= 0) , which conditional jump instruction would you use? (Assume y is signed.)
jle
Which of the following x86-64 instructions does NOT modify the stack pointer?
jmp
A function that does not call any other functions is called a
leaf procedure
Which component of the compilation process combines object files into one executable object program?
linker
Computers directly execute
machine code
Which C function serves the purpose of assigning new memory to a pointer?
malloc()
Which computer organization component serves as a temporary storage device that holds data while a program is executing?
memory
Which computer organization component serves as a temporary storage device that holds the data all of a program's instructions while that program is executing?
memory
Which metric measures the amount of time lost to a cache miss?
miss penalty
In ATT format for x86-64 assembly, which of the following instructions would copy 32 bits from %esp into %ebp ?
movl %esp , %ebp
In Y86-64, which instruction moves a value from a memory location into a register?
mrmovq
Which combinational circuit component is used to select between one of several possible inputs?
multiplexor
Which of the following instructions is equivalent to x * 8 if x is represented in 8-bit 2's complement.
none of these
What should GET_TITLE be replaced by for correct functionality?
novels[i]->title
Match the following cache class with the appropriate description: direct-mapped cache: four-way set associative cache: fully associative cache: two-way set associative cache:
one line per set four lines per set all cache lines map to the same set two lines per set
What occurs if the full integer result of an arithmetic calculation cannot fit within the word size limits of the data type?
overflow
Assume ptr is a C pointer to an array element, and the size of each array element is 16 bits. If the current value of the pointer ptr is some address p , What is the final numeric value of the C expression ptr - i ?
p - ( 2 * i )
Assume "ptr" is a C pointer to an array element, and the size of each array element is 32 bits. If "p" is the current value of the pointer, what is the value of the C expression "ptr-i"?
p - (4 * i)
A disk controller maintains associations between logical blocks and
physical sectors
What is the result in base 10 of the addition of: 0100 1101 + 0110 0011 if using 8-bit two's complement representation?
positive overflow
Which stage of compilation handles statements like #include <stdio.h>?
preprocessing
Which stage of compilation works with statements like #include <stdio.h>?
preprocessing
What CPU component consists of word-size storage units that have unique names?
register file
What is the output of an assembler?
relocatable object program
Which x86-64 instruction is used to return control to the caller at the end of a procedure?
ret
Which of the following Y86-64 instructions modify data on the stack? (Choose all that apply.)
ret popq pushq
Choose the correct line to finish the following C function: /* interpret the least-significant 'width' bits in 'value' as a two's complement signed number; returns true if that number is negative and false otherwise */ bool is_negative_2c (uint64_t value, uint64_t width) { _______________________ }
return value & (1 << (width-1)));
Suppose a Y86-64 machine code instruction is two bytes long and its little-endian hex encoding is 20 40. What is the corresponding assembly code?
rrmovq %rsp, %rax
Suppose a Y86-64 machine code instruction is two bytes long and its hex encoding is 20 45. What is the corresponding assembly code?
rrmovq %rsp, %rbp
Consider an 8-bit floating-point representation based on the IEEE floating-point format, with one sign bit, three exponent bits, and 4 fraction bits. For the decimal value 1.25. Give the bit(s) for each of the following: s: e: f:
s: 0 e: 011 f: 0100
In ATT format for x86-64 assembly, which x86-64 instruction would perform the equivalent of x >>= 2 in C ? Assuming "x" is a signed integer currently stored in register %rax
sar $2 , %rax
The time that it takes for a disk arm to position itself over the correct track in order to read data is called the
seek time
In ATT format for x86-64 assembly, which of the following is equivalent to the x86-64 instruction: sal $4, %rcx ?
shl $4 , %rcx
Which number representation(s) have multiple representations for zero? Choose all that apply.
single precision floating point double precision floating point
If "base" is the address of the first element in an array, "size" is the size (in bytes) of each element, and "len" is the number of elements in the array, what is the total size (in bytes) of the array?
size * len
Parameters passed to a function are stored in what part of memory?
stack
Variables that are local to a function are stored in what part of memory?
stack
Which of the following instructions correctly allocates local space on the stack for two 32-bit integers?
subq $8, %rsp
Assume the %rbx register stores the value 5, and the %rax register stores the value 3. In ATT format for x86-64 assembly, which x86-64 instruction would compute 5 - 3, leaving the result in %rbx ?
subq %rax , %rbx
Which of the following correct implements this definition of a traditional swap function in x86-64? void swap( int* x , int* y )
swap: mov ( %rdi ) , %eax mov ( %rsi ) , %edx mov %edx , ( %rdi ) mov %eax , ( %rsi ) retq
The output files of the pre-processor and compiler are both stored as _________, but the output files of the assembler and the linker are both stored as _______ files.
text, binary
What is the big-endian binary expansion of the hexadecimal value 0xA70C?
the answer is not: What is the big-endian binary expansion of the hexadecimal value 0xA70C?
"Moore's Law" predicted that ______ will double every year.
the number of transistors per chip
For a ret instruction, which internal field of the Y86 processor is used to update the PC?
valM
Which of the following is the operating system abstraction that provides each process with the illusion that it is running alone?
virtual memory
A "stride-1 reference pattern" describes memory accesses that
visit every element of an array in order.
Which of the following best describes a memory leak?
when variables allocated in a function and stored in the heap are lost when the function returns
The valid bit in a cache indicates:
whether or not the line has meaningful information
Buses transfer fixed-size chunks of data that are called what?
words
Which cache write policy will delay as long as possible before propagating updates to lower levels of the memory hierarchy?
write-back
What is the appropriate C-expression for CONDITION if when given the following C code: void cond( int x , int *p ) { if ( CONDITION ) *p = 5; } GCC generated the following assembly code: # void cond( long x , int *p # Value of x is in %rdi , while value of p is in %rsi cond: testq %rdi , %rdi je L1 movq $5 , ( %rsi ) L1: ret
x != 0
Which of the following Boolean algebra statements is true?
x & (y | z) = (x & y) | (x & z)
When using 8-bit word size in two's complement addition, negative overflow occurs when
x + y < -128
When using 8-bit word size in two's complement addition, positive overflow occurs when
x + y >= 128
When using 4-bit word size in two's complement addition, positive overflow occurs when
x + y >= 8
Which of the following instructions is equivalent to x * 16 if x is represented in 8-bit 2's complement.
x << 4
Which of the following boolean algebra statements is NOT true?
x ^ 0 = 0
Which of the following is the correct way to reference the "bar" field of variable "x" in the following snippet? struct stuff { char foo; int bar; int baz; } v; struct stuff *x = &v;
x->bar