#define BINARY_OP(returnType, type1, type2, op) \
{ \
register PTR pRet = pCurEvalStack - sizeof(type1) - sizeof(type2); \
pCurEvalStack = pRet + sizeof(returnType); \
*(returnType*)pRet = *(type1*)pRet op *(type2*)(pRet + sizeof(type1)); \
}
And the assembly generated is this: BINARY_OP(I32, I32, I32, +);
004117BA mov eax,dword ptr [pCurEvalStack]
004117BD sub eax,8
004117C0 mov dword ptr [pRet],eax
004117C6 mov ecx,dword ptr [pRet]
004117CC add ecx,4
004117CF mov dword ptr [pCurEvalStack],ecx
004117D2 mov edx,dword ptr [pRet]
004117D8 mov eax,dword ptr [edx]
004117DA mov ecx,dword ptr [pRet]
004117E0 add eax,dword ptr [ecx+4]
004117E3 mov edx,dword ptr [pRet]
004117E9 mov dword ptr [edx],eax
which is still unimaginably terrible. Why isn't it re-using values that have already been loaded into registers? Why isn't it using a register for pRet? I've even told it to! Although I think it's documented that the MS compiler ignores the 'register' keyword.And this is with all optimisations turned on. How depressing.