$ unzip /home/lperkovi/public/hw3.zipand move to newly created directory hw3:
$ cd hw3This directory contains files hw3.c and Makefile. Open file hw3.c for editing and do the homework:
$ emacs hw3.cWhen done, submit the homework as follows:
$ make submit
long decode2(long x, long y, long z);gcc generates the following assembly code:
decode2:Parameters x, y, and z are passed in registers %rdi, %rsi, and %rdx. The code stores the return value in register %rax.
movq %rdi, %rax
subq %rdx, %rax
movq %rax, %rdx
imulq %rax, %rdi
salq $63, %rdx
sarq $63, %rdx
xorq %rdx, %rdi
leaq (%rdi,%rsi), %rax
ret
$ gcc -Og -S hw3.cand then view the file hw3.s:
$ cat hw3.s2. Problem 3.60 in BO but using this assembly code instead:
movl %esi, %ecxYour solution should be an implementation of C function loop(). You can check your solution as you did for problem 1. Note that there is a mistake in the book in line 1 of page 313. The function signature should be long loop(long x, int n).
movl $1, %edx
movl $0, %eax
.L3:
testq %rdx, %rdx
je .L5
movq %rdx, %r8
andq %rdi, %r8
orq %r8, %rax
salq %cl, %rdx
jmp .L3
.L5:
ret
http://windriver.cdm.depaul.edu:15213/scoreboardat 5:45pm on Thursday, October 21.