Question: Modify the code at the assembly level to calculate fibonacci numbers, rather than factorials. You must have done this in x86 not C 1 .file

Modify the code at the assembly level to calculate fibonacci numbers, rather than factorials.

  • You must have done this in x86 not C

1 .file "example_fact.c" 2 .text 3 .section .rodata 4 .LC0: 5 .string "13! = %d " 6 .text 7 .globl main 8 .type main, @function 9 main: 10 .LFB0: 11 .cfi_startproc 12 pushq %rbp 13 .cfi_def_cfa_offset 16 14 .cfi_offset 6, -16 15 movq %rsp, %rbp 16 .cfi_def_cfa_register 6 17 subq $16, %rsp 18 movl $13, %edi 19 call my_fact 20 movl %eax, -4(%rbp) 21 movl -4(%rbp), %eax 22 movl %eax, %esi 23 leaq .LC0(%rip), %rdi 24 movl $0, %eax 25 call printf@PLT 26 movl $0, %eax 27 leave 28 .cfi_def_cfa 7, 8 29 ret 30 .cfi_endproc 31 .LFE0: 32 .size main, .-main 33 .globl my_fact 34 .type my_fact, @function 35 my_fact: 36 .LFB1: 37 .cfi_startproc 38 pushq %rbp 39 .cfi_def_cfa_offset 16 40 .cfi_offset 6, -16 41 movq %rsp, %rbp 42 .cfi_def_cfa_register 6 43 subq $16, %rsp 44 movl %edi, -4(%rbp) 45 cmpl $1, -4(%rbp) 46 jg .L4 47 movl $1, %eax 48 jmp .L5 49 .L4: 50 movl -4(%rbp), %eax 51 subl $1, %eax 52 movl %eax, %edi 53 call my_fact 54 imull -4(%rbp), %eax 55 .L5: 56 leave 57 .cfi_def_cfa 7, 8 58 ret 59 .cfi_endproc 60 .LFE1: 61 .size my_fact, .-my_fact 62 .ident "GCC: (Debian 8.3.0-6) 8.3.0"

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!