2

I am beginning to write some assembly. What is the fastest way to push and pop all 64-bit registers to the stack in x86-64? I know pusha will save the state of all 32-bit general purpose registers.

I want to save the state(using cdecl convention) of all the registers I will use(I will use all 64-bit registers).

Thanks.

JFMR
  • 23,265
  • 4
  • 52
  • 76
  • Note that the "duplicate" question is tagged `isr` (interrupt service routine). For regular user-mode code, it may not be necessary to push all registers. For example with the Windows 64bit [calling convention](https://msdn.microsoft.com/en-us/library/ms235286.aspx), rcx, rdx, r8 & r9 are used for the first 4 parameters, and can be clobbered by the called routine. Likewise r10 & r11 are scratch and can be clobbered, and rax is either the return value, or scratch (neither requires a save). I'm sure linux (if that's what you use) has similar characteristics. Save just what you must. – David Wohlferd Aug 14 '17 at 06:23

0 Answers0