Created
November 26, 2009 20:04
-
-
Save jakedouglas/243634 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This code should align the stack to a 16 byte boundary for OSX function calls | |
push rbx // save rbx. joe says rbx is caller saved, but other things say its callee-saved? | |
mov rdx, 0 // move 0 into the first division register | |
mov rax, rsp // move rsp's address into the second division register | |
mov rbx, 16 // move the divisor, 16, into rbx | |
div rbx // perform the division using the value we just put into rbx | |
mov rbx, rdx // store the remainder into rbx so we have it when we return | |
subq rsp, rbx // grow the stack pointer by our offset | |
callq 0xdeadbeef // call out to the function | |
addq rsp, rbx // put the stack pointer back where it was | |
pop rbx // restore rbx |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment