Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- addThree:
- push rbp
- mov rbp, rsp
- mov DWORD PTR [rbp-4], edi
- mov eax, DWORD PTR [rbp-4]
- add eax, 3
- pop rbp
- ret
- main:
- push rbp
- mov rbp, rsp
- sub rsp, 16
- mov DWORD PTR [rbp-4], 0
- mov edi, 2
- call addThree
- mov DWORD PTR [rbp-4], eax
- add DWORD PTR [rbp-4], 5
- mov eax, 0
- leave
- ret
- ;Line 9 is where the program begins.
- ;Line 10, 11, and 12 are just some setup.
- ;Line 13 is where it initializes "n" to be zero.
- ;Line 14 moves the integer "2" into the register "edi".
- ;Line 15 calls "addThree" and the program jumps to executing from line 2.
- ;Lines 2 and 3 are just some setup.
- ;Lines 4 and 5 are just moving the value from the edi register into the eax register (the value being the integer "2").
- ;Line 6 then performs an addition operation (value of eax+2) which stores the resulting value in the eax register.
- ;Line 7 does some cleanup, and then line 8 returns. Now the program jumps down to line 16, right after the call to addThree.
- ;Line 16 moves the value from eax to somewhere in memory.
- ;Line 17 performs an addition operation which adds 5 to the value that was returned from addThree.
- ;Line 18 sets up the zero for the return code, then finally...
- ;Lines 19 and 20 is the conclusion of our program: termination.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement