[C++, ASM] Pomoc w kodzie...

Czepek221

Użytkownik
Dołączył
Maj 18, 2010
Posty
26
Próbuję przerobić ASM z MSVC do MINGW, lecz z problemami :F

Oryginał:
PHP:
template <class T>
T Blablabla<T>::operator ()(int numArgs, ...)
{
	T retorno;
	va_list listaArgs;
	void** args = new void*[numArgs];

	va_start(listaArgs, numArgs);
	for (int n=0; n<numArgs; n++)
		args[n] = va_arg(listaArgs, void*);

	for(int x=numArgs-1; x>=0; x--)
	{
		int temp = x*4;
		__asm
		{
			mov  eax, dword ptr args
			add  eax, temp
			push [eax]
		}
	}

	BYTE *tem = buffer;
	__asm
	{
		mov eax, tem
		call eax
		mov  retorno, eax
	}
	
	delete [] args;
	va_end(listaArgs);
	return retorno;
}

Próba przerobienia:
PHP:
template <class T>
T Blablabla<T>::operator ()(int numArgs, ...)
{
	T retorno;
	va_list listaArgs;
	void** args = new void*[numArgs];

	va_start(listaArgs, numArgs);
	for(int nk=0; nk<numArgs; nk++)
		args[nk] = va_arg(listaArgs, void*);

	for(int n=numArgs-1; n>=0; n--)
	{
		int temp = n*4;
		asm("mov  eax, DWORD ptr args");
		asm("add  eax, temp");
		asm("push eax");
	}

	BYTE *tem = buffer;
	asm("mov eax, tem");
	asm("call eax");
	asm("mov retorno, eax");

	delete[] args;
	va_end(listaArgs);
	return retorno;
}

Kod:
Assembler messages:
Error: too many memory references for `mov'
Error: too many memory references for `add'

Error: too many memory references for `mov'
Error: too many memory references for `mov'

Od razu mówię, że pierwszy raz korzystam z ASM w C++, więc nie mam zielonego pojęcia jak to ma poprawnie być napisane.
 
Do góry Bottom