dComArk15/Aflevering5-x86-64/fib_iter.objdump.s
Christoffer Müller Madsen e2e36f9f0d initial commit
2016-01-03 13:29:05 +01:00

118 lines
3.7 KiB
ArmAsm

fib_iter.o: file format elf64-x86-64
Disassembly of section .text:
0000000000000000 <fib_iter>:
#include <stdio.h>
#include <stdlib.h>
unsigned long long fib_iter(unsigned long long a)
{
0: 55 push %rbp
1: 48 89 e5 mov %rsp,%rbp
4: 48 89 7d d8 mov %rdi,-0x28(%rbp)
unsigned long long r = 0;
8: 48 c7 45 f8 00 00 00 movq $0x0,-0x8(%rbp)
f: 00
unsigned long long minus_one = 1;
10: 48 c7 45 f0 01 00 00 movq $0x1,-0x10(%rbp)
17: 00
unsigned long long minus_two = 0;
18: 48 c7 45 e8 00 00 00 movq $0x0,-0x18(%rbp)
1f: 00
unsigned long long i;
if (a == 0) {
20: 48 83 7d d8 00 cmpq $0x0,-0x28(%rbp)
25: 75 0a jne 31 <fib_iter+0x31>
r = 0;
27: 48 c7 45 f8 00 00 00 movq $0x0,-0x8(%rbp)
2e: 00
2f: eb 49 jmp 7a <fib_iter+0x7a>
} else if (a == 1) {
31: 48 83 7d d8 01 cmpq $0x1,-0x28(%rbp)
36: 75 0a jne 42 <fib_iter+0x42>
r = 1;
38: 48 c7 45 f8 01 00 00 movq $0x1,-0x8(%rbp)
3f: 00
40: eb 38 jmp 7a <fib_iter+0x7a>
} else {
for (i = 2; i <= a; i++) {
42: 48 c7 45 e0 02 00 00 movq $0x2,-0x20(%rbp)
49: 00
4a: eb 24 jmp 70 <fib_iter+0x70>
r = minus_one + minus_two;
4c: 48 8b 55 f0 mov -0x10(%rbp),%rdx
50: 48 8b 45 e8 mov -0x18(%rbp),%rax
54: 48 01 d0 add %rdx,%rax
57: 48 89 45 f8 mov %rax,-0x8(%rbp)
minus_two = minus_one;
5b: 48 8b 45 f0 mov -0x10(%rbp),%rax
5f: 48 89 45 e8 mov %rax,-0x18(%rbp)
minus_one = r;
63: 48 8b 45 f8 mov -0x8(%rbp),%rax
67: 48 89 45 f0 mov %rax,-0x10(%rbp)
if (a == 0) {
r = 0;
} else if (a == 1) {
r = 1;
} else {
for (i = 2; i <= a; i++) {
6b: 48 83 45 e0 01 addq $0x1,-0x20(%rbp)
70: 48 8b 45 e0 mov -0x20(%rbp),%rax
74: 48 3b 45 d8 cmp -0x28(%rbp),%rax
78: 76 d2 jbe 4c <fib_iter+0x4c>
minus_two = minus_one;
minus_one = r;
}
}
return r;
7a: 48 8b 45 f8 mov -0x8(%rbp),%rax
}
7e: 5d pop %rbp
7f: c3 retq
0000000000000080 <main>:
int main(int argc, char *argv[])
{
80: 55 push %rbp
81: 48 89 e5 mov %rsp,%rbp
84: 48 83 ec 20 sub $0x20,%rsp
88: 89 7d ec mov %edi,-0x14(%rbp)
8b: 48 89 75 e0 mov %rsi,-0x20(%rbp)
unsigned long long a = 0;
8f: 48 c7 45 f8 00 00 00 movq $0x0,-0x8(%rbp)
96: 00
unsigned long long r = 0;
97: 48 c7 45 f0 00 00 00 movq $0x0,-0x10(%rbp)
9e: 00
a = atol(argv[1]);
9f: 48 8b 45 e0 mov -0x20(%rbp),%rax
a3: 48 83 c0 08 add $0x8,%rax
a7: 48 8b 00 mov (%rax),%rax
aa: 48 89 c7 mov %rax,%rdi
ad: e8 00 00 00 00 callq b2 <main+0x32>
b2: 48 89 45 f8 mov %rax,-0x8(%rbp)
r = fib_iter(a);
b6: 48 8b 45 f8 mov -0x8(%rbp),%rax
ba: 48 89 c7 mov %rax,%rdi
bd: e8 00 00 00 00 callq c2 <main+0x42>
c2: 48 89 45 f0 mov %rax,-0x10(%rbp)
printf("fib(%llu) = %llu\n",a,r);
c6: 48 8b 55 f0 mov -0x10(%rbp),%rdx
ca: 48 8b 45 f8 mov -0x8(%rbp),%rax
ce: 48 89 c6 mov %rax,%rsi
d1: bf 00 00 00 00 mov $0x0,%edi
d6: b8 00 00 00 00 mov $0x0,%eax
db: e8 00 00 00 00 callq e0 <main+0x60>
return 0;
e0: b8 00 00 00 00 mov $0x0,%eax
}
e5: c9 leaveq
e6: c3 retq