Advertisement
Agus_Darmawan

assembly fibonacci

Jan 7th, 2020
428
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     .file   "fib.c"
  2.     .def    ___main;    .scl    2;  .type   32; .endef
  3.     .section .rdata,"dr"
  4.  
  5. LC0:
  6.     .ascii "%d\12\0"
  7.     .text
  8.  
  9. .globl _main
  10.     .def    _main;  .scl    2;  .type   32; .endef
  11.  
  12. _main:
  13.     pushl   %ebp
  14.     movl    %esp, %ebp
  15.     andl    $-16, %esp
  16.     subl    $32, %esp       # alokasikan sebanyak 32 bytes di lokal stack
  17.     call    ___main
  18.  
  19. L3:
  20.     movl    $0, 28(%esp)
  21.     movl    $1, 24(%esp)
  22.  
  23. L2:
  24.     movl    28(%esp), %eax
  25.     movl    %eax, 4(%esp)
  26.     movl    $LC0, (%esp)
  27.     call    _printf
  28.     movl    24(%esp), %eax
  29.     movl    28(%esp), %edx
  30.     leal    (%edx,%eax), %eax
  31.     movl    %eax, 20(%esp)
  32.     movl    24(%esp), %eax
  33.     movl    %eax, 28(%esp)
  34.     movl    20(%esp), %eax
  35.     movl    %eax, 24(%esp)
  36.     cmpl    $254, 28(%esp)
  37.     jle L2 # loncat jika kurang atau sama dengan
  38.     jmp L3 # unconditional jump (loncat tanpa kondisi)
  39.     .def    _printf;    .scl    2;  .type   32; .endef
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement