[asm] Invalid combination of opcode and operands (32bits version)

Started by frankie, August 29, 2014, 04:23:23 PM

Previous topic - Next topic

frankie

Compiling the following snippet with whichever optimization on you get the error.
Is'nt possible to see which opcode/operand the compiler is trying to use (is there a way to force compiler to emit only assembler ?), but I suspect that it want use an addressing mode valid only for  64bits.

#include <Windows.h>
#include <stdio.h>

typedef struct
{
int a;
int b;
POINTS pts;
} OBJ;

OBJ Obj, *lpObj;

POINTS func1(OBJ *lpObj, LPPOINTS p)
{
return (POINTS){1,2};
}

DWORD func2(OBJ *lpObj, DWORD a, DWORD b)
{
return a;
}

DWORD func3(OBJ *lpObj, DWORD a)
{
return a;
}

void ffunc(OBJ *lpObj, LPARAM lParam)
{
POINTS pt1 = func1(lpObj, &lpObj->pts);
POINTS pt2 = func1(lpObj, &MAKEPOINTS(lParam));

/*** On the following line we have:
error #3114: [asm] Invalid combination of opcode and operands.
***/
if (abs(pt1.x - (pt2.x)) < 10)
goto Error;

func2 (lpObj, func3(lpObj, min(pt1.x, pt2.x) - lpObj->b),
func3(lpObj, max(pt1.x, pt2.x) - lpObj->b));
Error:
lpObj->b = FALSE;
}
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide


frankie

Yes Czerny, I'm really getting old!  ;D
I got it, the offending instructions are:

movsx edi,edi
movsx esi,eax

The movsx (move with sign extension) instructions don't support two 32 bits register, and it would not have made any sense to extend in the same format with sign extension ...  >:(
This is a compiler bug. And it is also very annoying, it's impossible to compile something that want sign extend a structure of two shorts...  >:(
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide