Status of stack right after call instruction is executed - At this point, RSP ends in 8 - The function prologue will push 8 bytes to the stack so RSP ends in 0 - Then the function code can assume the stack is aligned Note: stack grows downwards (towards lower addresses). Pusing something decreases the stack pointer) RBP is used to refer to what's already on the stack (frame pointer). It is fixed througout a function execution and allows to refer to local variables at fixed offsets from the register (whereas rsp keeps moving as the code pushes and pops stuff). Expected outcome: ^ HIGH ADDRESSES ------------------------- (stack misaligned here) (hole for realigning the stack) ------------------------- (stack aligned on 16 bytes here) USER_DATA_SELECTOR user_rsp flags USER_CODE_SELECTOR ip < ... error_code < RBP+8 vector < RBP+4 iframe bottom < RBP (ends in 0) ------------------------- (stack aligned on 16 bytes here) return address < RSP (ends in 8) v LOW ADDRESSES With current code: ^ HIGH ADDRESSES ------------------------- (stack misaligned here) USER_DATA_SELECTOR user_rsp flags USER_CODE_SELECTOR ip < ... error_code < RBP+8 vector < RBP+4 iframe bottom < RBP (ends in 8) (hole for realigning the stack) ------------------------- (stack aligned on 16 bytes here) return address < RSP (ends in 8) v LOW ADDRESSES By using andq/movq: ^ HIGH ADDRESSES ------------------------- (stack misaligned here) USER_DATA_SELECTOR user_rsp flags USER_CODE_SELECTOR ip error_code vector iframe bottom (hole for realigning the stack) < RBP (now at the wrong place) return address < RSP (ends in 8) v LOW ADDRESSES