stack frame optimization problem

sprucely timberdig at gmail.com
Tue Oct 20 08:45:50 PDT 2009


This works with g++ and inline ATT assembly, but I have had no such luck in D. I have many simple functions that need to be executed sequentially and have identical stack frames. To avoid the overhead of setting up and tearing down the stack frames I want to jmp from the body of one function to the body of the next. A simplified example...

extern(C) byte jumpHere;

byte* jumpTo = &jumpHere;

void f1()
{
	asm
	{
		//jmp dword ptr jumpTo;
		mov EAX, jumpTo;
		jmp EAX;
		//jmp [EAX]
	}
}

void f2()
{
	asm{jumpHere:;}
}

No matter what I try I get a segfault. My assembly skills are very limited. I'm not using the naked keyword yet, because I want to get a proof-of-concept working first. Anyone see anything wrong with this? Any suggestions?



More information about the Digitalmars-d mailing list