func.s (1120B)
1 .text 2 .global _start 3 4 _start: 5 # Store 3 on the stack. 6 push $3 7 # call stores return address on the stack. 8 call square 9 # Use the return value, in %rax, as our exit status number. 10 mov %rax, %rdi 11 mov $231, %rax 12 syscall 13 14 # square expects an integer on the stack, 16 bytes down from RBP. 15 # The squared value is returned on %rax. 16 square: 17 # Function Epilogue --> { 18 push %rbp 19 mov %rsp, %rbp 20 21 # Retrieve the parameter from the stack. 22 # 8 bytes down from RSP is the return address from square. 23 # 8 bytes down from that is the parameter to multiple. 24 mov 16(%rbp), %rax 25 mul %rax 26 27 # Function Prologue --> } 28 mov %rbp, %rsp 29 pop %rbp 30 # ret pops and return to address on stack. 31 ret 32 33 # |----------------+-----------+----------------| 34 # | Address | Data | Stack Pointers | 35 # |----------------+-----------+----------------| 36 # | 0x7fffffffe8f8 | | | 37 # | 0x7fffffffe900 | 0x0 (rbp) | | 38 # | 0x7fffffffe908 | 0x401002 | | 39 # | 0x7fffffffe910 | 3 | ←rsp | 40 # |----------------+-----------+----------------| 41 # ←rbp