145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgPROC_FRAME sample
245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org   db      048h; emit a REX prefix, to enable hot-patching
345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgpush rbp
445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org[pushreg rbp]
545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgsub rsp, 040h
645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org[allocstack 040h]
745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orglea rbp, [rsp+020h]
845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org[setframe rbp, 020h]
945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgmovdqa [rbp], xmm7
1045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org[savexmm128 xmm7, 020h];the offset is from the base of the frame
1145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org;not the scaled offset of the frame
1245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgmov [rbp+018h], rsi
1345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org[savereg rsi, 018h]
1445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgmov [rsp+010h], rdi
1545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org[savereg rdi, 010h]; you can still use RSP as the base of the frame
1645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org; or any other register you choose
1745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgEND_PROLOGUE
1845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org
1945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org; you can modify the stack pointer outside of the prologue (similar to alloca)
2045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org; because we have a frame pointer.
2145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org; if we didn't have a frame pointer, this would be illegal
2245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org; if we didn't make this modification,
2345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org; there would be no need for a frame pointer
2445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org
2545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgsub rsp, 060h
2645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org
2745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org; we can unwind from the following AV because of the frame pointer
2845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org
2945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgmov rax, 0
3045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgmov rax, [rax] ; AV!
3145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org
3245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org; restore the registers that weren't saved with a push
3345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org; this isn't part of the official epilog, as described in section 2.5
3445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org
3545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgmovdqa xmm7, [rbp]
3645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgmov rsi, [rbp+018h]
3745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgmov rdi, [rbp-010h]
3845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org
3945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org; Here's the official epilog
4045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org
4145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orglea rsp, [rbp-020h]
4245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgpop rbp
4345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgret
4445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgENDPROC_FRAME
45