__asm block question

__asm block question

Hi All,

The question is: when using mixed C++ with __asm blocks do I have to preserve registers? All registers, or some registers?

If I use -use_msasm option then I don't have to worry about saving/restoring registers in __asm blocks?

Thanks!

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

I think I need a little more info to understand exactly what you're asking, but perhaps I can clear up one point. The option "-use-msasm" means to interpret "MS-style" asm code, rather than (or in addition to)"gcc-style", which is the default onLinux and MacOS. Without this option, you'd probably get a syntax error if you used ms-style asm blocks.

As far as saving/restoring registers, perhaps you can give a specific example of what you mean?

Thanks

Dale

You have to preserve:

  • ESP - pretty obvious why
  • EBP - variable access
  • EBX - stack alignment for functions with __m128 parameters
  • ECX - this pointer in C++

Others usually don't need to be preserved.

Regards,
Igor Levicki

Leave a Comment

Please sign in to add a comment. Not a member? Join today