[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 211
  • Last Modified:

freezing then modifying a member function's generated assembly

I'm hoping there is an easy way to freeze a member function's generated assembly (using VC++ 6.0) and then modify it inline without the compiler generating more instructions. When I take the assembly instructions the compiler first generates for a function and place them more or less verbatim inside an _asm block within that function, the compiler keeps adding more instructions before and after the _asm block.
 
bool classname::operator>(classname& x)
{
   _asm
  {
     //all the assembly instructions of the old function
  }
}

The compiler adds extra pushes and pops before and after the _asm block.

Is there a way to tell the compiler not to add any instructions before and after the _asm block here?
0
Posit
Asked:
Posit
1 Solution
 
jkrCommented:
>>Is there a way to tell the compiler not to add any instructions before and after the _asm block here?

You could use '__declspec(naked)', e.g.

__declspec(naked) bool classname::operator>(classname& x)
{
  _asm
 {
    //all the assembly instructions of the old function
 }
}
0
 
PositAuthor Commented:
Great, exactly what I was looking for. Works like a charm.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now