# assuming the value of rax is 0xffffffffffffffff and the value of rdx is 0x0000000000 5195891

Assuming the value of %rax is 0xffffffffffffffff
and the value of %rdx is 0x0000000000000001
what are the values of the condition codes after the following statement is executed:
cmpq %rax, %rdx

For example, the answer: 0, 0, 1, 1 would indicate ZF is set to 0, CF is set to 0, SF is set to 1 and OF is set to 1

Note: for X86 machines, the carry flag for subtraction holds the value of the borrow.

Question 2

Points out of 1.00

Flag question

Question text

Assuming the value of %rax is 0x0000000000000001
and the value of %rdx is 0xffffffffffffffff
what are the values of the condition codes after the following statement is executed:
cmpq %rax, %rdx

For example, the answer: 0, 0, 1, 1 would indicate ZF is set to 0, CF is set to 0, SF is set to 1 and OF is set to 1

Question 3

Points out of 1.00

Flag question

Question text

Assuming the value of %rax is 0x8000000000000001
and the value of %rdx is 0x7fffffffffffffff
what are the values of the condition codes after the following statement is executed:
cmpq %rax, %rdx

For example, the answer: 0, 0, 1, 1 would indicate ZF is set to 0, CF is set to 0, SF is set to 1 and OF is set to 1

Question 4

Points out of 1.00

Flag question

Question text

Assuming the value of %rax is 0x0000000000000001
and the value of %rdx is 0x0000000000000001
what are the values of the condition codes after the following statement is executed:
cmpq %rax, %rdx

For example, the answer: 0, 0, 1, 1 would indicate ZF is set to 0, CF is set to 0, SF is set to 1 and OF is set to 1

Question 5

Points out of 1.00

Flag question

Question text

Assuming the value of %rax is 0xffffffffffffffff
and the value of %rdx is 0x800000000000000
what are the values of the condition codes after the following statement is executed:
cmpq %rax, %rdx

For example, the answer: 0, 0, 1, 1 would indicate ZF is set to 0, CF is set to 0, SF is set to 1 and OF is set to 1

Question 6

Points out of 1.00

Flag question

Question text

Assuming the value of %rax is 0xffffffffffffffff
what are the values of the condition codes after the following statement is executed:
testq %rax, %rax

For example, the answer: 0, 0, 1, 1 would indicate ZF is set to 0, CF is set to 0, SF is set to 1 and OF is set to 1

Question 7

Points out of 1.00

Flag question

Question text

Assuming the value of %rax is 0x0000000000000003
what are the values of the condition codes after the following statement is executed:
testq %rax, %rax

For example, the answer: 0, 0, 1, 1 would indicate ZF is set to 0, CF is set to 0, SF is set to 1 and OF is set to 1

Question 8

Points out of 1.00

Flag question

Question text

Assuming the value of %rax is 0xffffffffffffffff
what are the values of the condition codes after the following statements are executed:

xorq %rax, %rax
testq %rax, %rax

For example, the answer: 0, 0, 1, 1 would indicate ZF is set to 0, CF is set to 0, SF is set to 1 and OF is set to 1

Question 9

Points out of 1.00

Flag question

Question text

Consider the following X86 assembly:

_mystery:
cmpq    %rsi, %rdi
cmovlq %rsi, %rdi
movq    %rdi, %rax
retq

The prototype for the C function from which this assembly was generated is:

long mystery(long n, long m);

The parameter n is in register %rdi and the parameter m is in register %rsi. The result is returned in register %rax. What is printed if the mystery function is called like this:

printf(“%ldn”, mystery(7, 5));

Select one:

a. -2

b. 7

c. 5

d. 12

e. 2

Question 10

Points out of 1.00

Flag question

Question text

Consider the following X86 assembly:

_mystery:
cmpq    %rsi, %rdi
cmovlq %rsi, %rdi
movq    %rdi, %rax
retq

The prototype for the C function from which this assembly was generated is:

long mystery(long n, long m);

The parameter n is in register %rdi and the parameter m is in register %rsi. The result is returned in register %rax. What is printed if the mystery function is called like this:

printf(“%ldn”, mystery(-3, 5));

Select one:

a. -2

b. -3

c. 5

d. 8

e. 2

Question 11

Points out of 1.00

Flag question

Question text

Consider the following X86 assembly:

_mystery:
movq    (%rdi), %rax
cmpq    %rsi, %rax
leaq    1(%rax), %rax
leaq    -2(%rsi), %rcx
cmovleq %rax, %rcx
movq    %rcx, (%rdi)
retq

The prototype for the C function from which this assembly was generated is:

void mystery(long * a, long b);

The parameter a is in register %rdi and the parameter b is in register %rsi. What is printed if the mystery function is called like this:

long a = 2, b = 3;
mystery(&a, b);
printf(“%ldn”, a);

Select one:

a. 5

b. 1

c. 3

d. 4

e. -1

Question 12

Points out of 1.00

Flag question

Question text

Consider the following X86 assembly:

_mystery:
movq    (%rdi), %rax
cmpq    %rsi, %rax
leaq    1(%rax), %rax
leaq    -2(%rsi), %rcx
cmovleq %rax, %rcx
movq    %rcx, (%rdi)
retq

The prototype for the C function from which this assembly was generated is:

void mystery(long * a, long b);

The parameter a is in register %rdi and the parameter b is in register %rsi. What is printed if the mystery function is called like this:

long a = 4, b = 1;
mystery(&a, b);
printf(“%ldn”, a);

Select one:

a. -1

b. 7

c. 1

d. 5

e. 3

Question 13

Points out of 1.00

Flag question

Question text

Consider the following X86 assembly:

_mystery:
cmpq    %rsi, (%rdi)
je      LBB1_2
incq    %rsi
movq    %rsi, (%rdi)
LBB1_2:
retq

The prototype of the C function from which the mystery function was generated is:

void mystery(long * a, long b);

The parameter a is in register %rdi and the parameter b is in register %rsi.

What is printed if the mystery function is called like this?

long a = 3, b = 4;
mystery(&a, b);
printf(“%ldn”, a);

Select one:

a. 5

b. 3

c. 7

d. 4

e. 9

Question 14

Points out of 1.00

Flag question

Question text

Consider the following X86 assembly:

_mystery:
cmpq    %rsi, (%rdi)
je      LBB1_2
incq    %rsi
movq    %rsi, (%rdi)
LBB1_2:
retq

The prototype of the C function from which the mystery function was generated is:

void mystery(long * a, long b);

The parameter a is in register %rdi and the parameter b is in register %rsi.

What is printed if the mystery function is called like this?

long a = 4, b = 6;
mystery(&a, b);
printf(“%ldn”, a);

Select one:

a. 9

b. 3

c. 5

d. 7

e. 4