View Single Post
  #21  
Old 07-21-2018, 07:01
chants chants is offline
VIP
 
Join Date: Jul 2016
Posts: 826
Rept. Given: 47
Rept. Rcvd 50 Times in 31 Posts
Thanks Given: 737
Thanks Rcvd at 1,140 Times in 529 Posts
chants Reputation: 51
Microsoft x64 calling convention

Quote:
Stack aligned on 16 bytes. 32 bytes shadow space on stack.
Therefore code given here is all non-standards compliant with arbitrary calling convention (compiler will have return address of 8 bytes so an extra 8 indeed is needed but if called from assembler directly, etc assumption may not hold). If not calling back into C code which has been externed for use by the asm code (like puts is for sure), this should obviously not be necessary - neither alignment or shadow space.

PHP Code:
  SUB RSP32 Allocate space on the stack 32 for shadow space
  
AND RSP, -16 Align on 16 bytes

  LEAVE 
That pattern is needed for both F1 and F2 and its straightforward.

Last edited by chants; 07-22-2018 at 01:08.
Reply With Quote
The Following 2 Users Say Thank You to chants For This Useful Post:
niculaita (07-21-2018), vic4key (07-21-2018)