COMP1411 Tutorial Exercise 5
The following exercises are adapted from the textbook.
Question 1.
Copyright By PowCoder代写 加微信 powcoder
For each of the following instruction, fill in the suitable suffix based on the operands. (e.g., use movb, movw, movl, movq).
· mov__ %eax, (%rsp)
· mov__ $0xFF, %bl
· mov__ (%rdx), %rax
· mov__ %dx, (%rax)
Question 2.
Suppose that the following function
void decode(long *xp, long *yp, long *zp)
is compiled into the following assembly code:
movq (%rdi), %r8
movq (%rsi), %rcx
movq (%rdx), %rax
movq %r8, (%rsi)
movq %rcx, (%rdx)
movq %rax, (%rdi)
Suppose that parameters xp, yp, zp are stored in registers %rdi, %rsi, and %rdx respectively.
Guess the C code of the function decode.
void decode(long *xp, long *yp, long *zp) {
Question 3.
Suppose that the following function
long arith(long x, long y, long z)
is compiled into the following assembly code:
orq %rsi, %rdi
sarq $3, %rdi
notq %rdi
movq %rdx, %rax
subq %rdi, %rax
Suppose that parameters x, y, z are stored in registers %rdi, %rsi, and %rdx respectively.
Guess the C code of the function arith.
long arith(long x, long y, long z) {
long t1 = __________________;
long t2 = __________________;
long t3 = __________________;
long t4 = __________________;
return t4;
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com