KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Just started learning x64 assembly and I have a question about functions, arguments, and the stack. As far as I understand it, the first four arguments in a function get passed to rcx, rdx, r8, and r9 registers (and xmm0-xmm3 for floats) in Windows. So a trivial addition function with four parameters would looks like this: add: mov r10, rcx add r10, rdx add r10, r8 add r10, r9 mov rax, r10 ret However, I've come across documentation that mentions this : At a minimum, each function must reserve 32 bytes (four 64-bit values) on the stack. This space allows registers passed into the function to be easily copied to a well-known stack location. The callee function isn't required to spill the input register params to the stack, but the stack space reservation ensures that it can if needed. So, do I have to reserve stack space even if the functions I'm making take four parameters or less, or is it just a recommendation?
Tags (comma-separated)
Save Edits
Cancel