Please Do it ASPS. Thanks
1. Consider the following C code:
long func(long x, long m, long n)
{
long result = 0;
int p = 1;
int q = 10
if ((x > m) && (x < n)){
p = p + m;
q = q + n;
}
else
p = p * m;
q = q * n;
result = p – q;
return result;
}
• Rewrite the code and replace the if-else with ‘goto’ statements.
• Write the assembly code that corresponds to the C ‘goto’ version.
• Compile the C code to assembly using gcc compiler and see how
your code compares
with the compiler version.
2. Assume the following values are stored at the indicated
memory addresses and registers:
Address Value
Register Value
0x200 0xFF
%rax
0x200
0x204 0xAA
%rcx
0x1
0x208 0x11
%rdx
0x3
0x20C 0x13
Fill in the following table showing the values for the
indicated operands:
Operand
Value
addq %rcx,(%rax)
-----------
subq %rdx,4(%rax)
-----------
imulq $16, (%rax,%rdx,4)
-----------
incq 8(%rax)
--------------
decq %rcx
---------------
subq %rdx,%rax
-------------------
xorq %rdx,%rdx
-----------------
sarq 3, %rdx
--------------
notq %rdx
----------------------------
Please Do it ASPS. Thanks 1. Consider the following C code: long func(long x, long m, long n) { long result =
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am