Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .text
- .globl main
- .type main, @function
- main:
- pushq %rbp # save caller’s frame pointer
- movq %rsp, %rbp # establish our frame pointer
- addq $localSize, %rsp # for local variable
- movl $promptSz, %edx # prompt size
- movl $prompt, %esi # address of prompt number string
- movl $STDOUT, %edi # standard out
- call Fibinacci # invoke write function
- movl $1, %edi # base case, n offset by 1
- movl $0, %r8d # 0 is the first number
- movl $1, %r9d # 1 is the second number
- movl $STDIN, %edi # standard in
- call Fibinacci # invoke read function
- movl $STDOUT, %edi # standard out
- leaq .result(%rip), %rdi
- movl $0, %eax
- call printf # invoke write function
- subq $localSize, %rsp
- movq %rsp, %rbp
- popq %rbp
- ret
- fibonacci:
- pushq %rbp # set base pointer
- movq %rsp, %rbp # set stack pointer
- addq $localSize, %rsp # offset stack pointer
- cmpl $1, %edi # Base case comparison (user input is arbitrary as our goal number)
- jae allDone
- addl $1, %edi # increment count by 1 and rerun
- movl $STDOUT, %edi # standard out
- call fibonacci
- movl $0, %eax # return 0
- movq %rbp, %rsp # delete local variables
- popq %rbp # restore caller’s frame pointer
- ret # back to calling function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement