Question: Please help. Deduct as much as question you want. Question 1 Execute the given sequence of assembly instructions. List the final value of the four
Please help. Deduct as much as question you want.
Question 1
-
Execute the given sequence of assembly instructions. List the final value of the four condition codes after the sequence is completed. Using 0 to indicate the flag is cleared and 1 to indicate the flag is set. Keep in mind that the operations are working with 1 byte values. (b suffix).
Assembly sequence:
movb $0xFF, %al
movb $0x81, %bl
addb %bl, %al
Condition code final value:
CF = Blank 1
OF = Blank 2
SF = Blank 3
ZF = Blank 4
20 points
Question 2
-
Execute the given sequence of assembly instructions. List the final value of the four condition codes after the sequence is completed. Using 0 to indicate the flag is cleared and 1 to indicate the flag is set. Keep in mind that the operations are working with 1 byte values. (b suffix).
Assembly sequence:
movb $0xF0, %al
testb %al, %al
Condition code final values:
CF = Blank 1
OF = Blank 2
SF = Blank 3
ZF = Blank 4
20 points
Question 3
-
Which C function matches the given assembly code? Assume that x is in %rdi, y is in %rsi, and return value is in %rax.
Assembly code:
cmpq %rsi, %rdi
jl L1
leaq 1(%rdi), %rax
ret
L1:
leaq -1(%rsi), %rax
ret
Choices below:
/*============================*/
long foo(long x, long y){
if (x<=y)
return x+1;
else
return y-1;
}
/*============================*/
long foo(long x, long y){
if (x
return x+1;
else
return y-1;
}
/*============================*/
long foo(long x, long y){
if (x>=y)
return x+1;
else
return y-1;
}
/*============================*/ long foo(long x, long y){
if (x>y)
return x+1;
else
return y-1;
}
20 points
Question 4
-
What is the final value of %rax after the given sequence of assembly code is executed? Assume that at the start of the sequence, %rdi = 30, %rsi = 20.
Assembly code:
movq $1, %rax
cmpq %rsi, %rdi
cmovge $0, %rax
30
20
1
0
20 points
Question 5
-
Given the sequence of assembly code, what would be the final value of %rsi and %rdx after the sequence is executed? Assume that at the start of the execution, %rdi = 9.
Assembly code:
movq $0, %rsi
movq $0, %rdx
jmp L2
L1: incq %rdx
addq $2, %rsi
L2: cmpq %rsi, %rdi
jg L1
L3:
decq %rdi
Final values:
%rsi = Blank 1
%rdx = Blank 2
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
