mirror of
https://github.com/holub/mame
synced 2025-05-21 13:18:56 +03:00
Enhanced the UML opcodes for LOAD, LOADS, and STORE to support
arbitrary scaling factors. Previously, specifying a size implied a scaling factor equal to the size (i.e., specifying DWORD meant the index was scaled by 4). This is still the default. However, now you can specify the scale explicitly for other cases. For example, you can specify DWORD_x1 to fetch a DWORD but don't scale the index at all, or BYTE_x8 to fetch a BYTE while scaling the index by 8. Updated all backends to make this work.
This commit is contained in:
parent
c254101a9a
commit
8bccdbd5cc
@ -49,16 +49,52 @@
|
|||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
DRCUML_OP_LOAD1 = DRCUML_OP_MAX,
|
DRCUML_OP_LOAD1 = DRCUML_OP_MAX,
|
||||||
|
DRCUML_OP_LOAD1x2,
|
||||||
|
DRCUML_OP_LOAD1x4,
|
||||||
|
DRCUML_OP_LOAD1x8,
|
||||||
|
DRCUML_OP_LOAD2x1,
|
||||||
DRCUML_OP_LOAD2,
|
DRCUML_OP_LOAD2,
|
||||||
|
DRCUML_OP_LOAD2x4,
|
||||||
|
DRCUML_OP_LOAD2x8,
|
||||||
|
DRCUML_OP_LOAD4x1,
|
||||||
|
DRCUML_OP_LOAD4x2,
|
||||||
DRCUML_OP_LOAD4,
|
DRCUML_OP_LOAD4,
|
||||||
|
DRCUML_OP_LOAD4x8,
|
||||||
|
DRCUML_OP_LOAD8x1,
|
||||||
|
DRCUML_OP_LOAD8x2,
|
||||||
|
DRCUML_OP_LOAD8x4,
|
||||||
DRCUML_OP_LOAD8,
|
DRCUML_OP_LOAD8,
|
||||||
DRCUML_OP_LOADS1,
|
DRCUML_OP_LOADS1,
|
||||||
|
DRCUML_OP_LOADS1x2,
|
||||||
|
DRCUML_OP_LOADS1x4,
|
||||||
|
DRCUML_OP_LOADS1x8,
|
||||||
|
DRCUML_OP_LOADS2x1,
|
||||||
DRCUML_OP_LOADS2,
|
DRCUML_OP_LOADS2,
|
||||||
|
DRCUML_OP_LOADS2x4,
|
||||||
|
DRCUML_OP_LOADS2x8,
|
||||||
|
DRCUML_OP_LOADS4x1,
|
||||||
|
DRCUML_OP_LOADS4x2,
|
||||||
DRCUML_OP_LOADS4,
|
DRCUML_OP_LOADS4,
|
||||||
|
DRCUML_OP_LOADS4x8,
|
||||||
|
DRCUML_OP_LOADS8x1,
|
||||||
|
DRCUML_OP_LOADS8x2,
|
||||||
|
DRCUML_OP_LOADS8x4,
|
||||||
DRCUML_OP_LOADS8,
|
DRCUML_OP_LOADS8,
|
||||||
DRCUML_OP_STORE1,
|
DRCUML_OP_STORE1,
|
||||||
|
DRCUML_OP_STORE1x2,
|
||||||
|
DRCUML_OP_STORE1x4,
|
||||||
|
DRCUML_OP_STORE1x8,
|
||||||
|
DRCUML_OP_STORE2x1,
|
||||||
DRCUML_OP_STORE2,
|
DRCUML_OP_STORE2,
|
||||||
|
DRCUML_OP_STORE2x4,
|
||||||
|
DRCUML_OP_STORE2x8,
|
||||||
|
DRCUML_OP_STORE4x1,
|
||||||
|
DRCUML_OP_STORE4x2,
|
||||||
DRCUML_OP_STORE4,
|
DRCUML_OP_STORE4,
|
||||||
|
DRCUML_OP_STORE4x8,
|
||||||
|
DRCUML_OP_STORE8x1,
|
||||||
|
DRCUML_OP_STORE8x2,
|
||||||
|
DRCUML_OP_STORE8x4,
|
||||||
DRCUML_OP_STORE8,
|
DRCUML_OP_STORE8,
|
||||||
DRCUML_OP_READ1,
|
DRCUML_OP_READ1,
|
||||||
DRCUML_OP_READ2,
|
DRCUML_OP_READ2,
|
||||||
@ -473,13 +509,13 @@ static void drcbec_generate(drcbe_state *drcbe, drcuml_block *block, const drcum
|
|||||||
if (opcode == DRCUML_OP_FFRINT || opcode == DRCUML_OP_FFRFLT)
|
if (opcode == DRCUML_OP_FFRINT || opcode == DRCUML_OP_FFRFLT)
|
||||||
psize[1] = 1 << inst->param[2].value;
|
psize[1] = 1 << inst->param[2].value;
|
||||||
|
|
||||||
/* pre-expand opcodes that encode size in them */
|
/* pre-expand opcodes that encode size/scale in them */
|
||||||
if (opcode == DRCUML_OP_LOAD)
|
if (opcode == DRCUML_OP_LOAD)
|
||||||
opcode = (drcuml_opcode)(DRCUML_OP_LOAD1 + (inst->param[3].value & 3));
|
opcode = (drcuml_opcode)(DRCUML_OP_LOAD1 + (inst->param[3].value & 3) * 4 + ((inst->param[3].value >> 4) & 3));
|
||||||
if (opcode == DRCUML_OP_LOADS)
|
if (opcode == DRCUML_OP_LOADS)
|
||||||
opcode = (drcuml_opcode)(DRCUML_OP_LOADS1 + (inst->param[3].value & 3));
|
opcode = (drcuml_opcode)(DRCUML_OP_LOADS1 + (inst->param[3].value & 3) * 4 + ((inst->param[3].value >> 4) & 3));
|
||||||
if (opcode == DRCUML_OP_STORE)
|
if (opcode == DRCUML_OP_STORE)
|
||||||
opcode = (drcuml_opcode)(DRCUML_OP_STORE1 + (inst->param[3].value & 3));
|
opcode = (drcuml_opcode)(DRCUML_OP_STORE1 + (inst->param[3].value & 3) * 4 + ((inst->param[3].value >> 4) & 3));
|
||||||
if (opcode == DRCUML_OP_READ)
|
if (opcode == DRCUML_OP_READ)
|
||||||
opcode = (drcuml_opcode)(DRCUML_OP_READ1 + (inst->param[2].value & 3));
|
opcode = (drcuml_opcode)(DRCUML_OP_READ1 + (inst->param[2].value & 3));
|
||||||
if (opcode == DRCUML_OP_READM)
|
if (opcode == DRCUML_OP_READM)
|
||||||
@ -728,38 +764,146 @@ static int drcbec_execute(drcbe_state *drcbe, drcuml_codehandle *entry)
|
|||||||
PARAM0 = inst[1].puint8[PARAM2];
|
PARAM0 = inst[1].puint8[PARAM2];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD1x2, 4, 0): /* LOAD dst,base,index,BYTE_x2 */
|
||||||
|
PARAM0 = *(UINT8 *)&inst[1].puint16[PARAM2];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD1x4, 4, 0): /* LOAD dst,base,index,BYTE_x4 */
|
||||||
|
PARAM0 = *(UINT8 *)&inst[1].puint32[PARAM2];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD1x8, 4, 0): /* LOAD dst,base,index,BYTE_x8 */
|
||||||
|
PARAM0 = *(UINT8 *)&inst[1].puint64[PARAM2];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD2x1, 4, 0): /* LOAD dst,base,index,WORD_x1 */
|
||||||
|
PARAM0 = *(UINT16 *)&inst[1].puint8[PARAM2];
|
||||||
|
break;
|
||||||
|
|
||||||
case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD2, 4, 0): /* LOAD dst,base,index,WORD */
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD2, 4, 0): /* LOAD dst,base,index,WORD */
|
||||||
PARAM0 = inst[1].puint16[PARAM2];
|
PARAM0 = inst[1].puint16[PARAM2];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD2x4, 4, 0): /* LOAD dst,base,index,WORD_x4 */
|
||||||
|
PARAM0 = *(UINT16 *)&inst[1].puint32[PARAM2];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD2x8, 4, 0): /* LOAD dst,base,index,WORD_x8 */
|
||||||
|
PARAM0 = *(UINT16 *)&inst[1].puint64[PARAM2];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD4x1, 4, 0): /* LOAD dst,base,index,DWORD_x1 */
|
||||||
|
PARAM0 = *(UINT32 *)&inst[1].puint8[PARAM2];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD4x2, 4, 0): /* LOAD dst,base,index,DWORD_x2 */
|
||||||
|
PARAM0 = *(UINT32 *)&inst[1].puint16[PARAM2];
|
||||||
|
break;
|
||||||
|
|
||||||
case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD4, 4, 0): /* LOAD dst,base,index,DWORD */
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD4, 4, 0): /* LOAD dst,base,index,DWORD */
|
||||||
PARAM0 = inst[1].puint32[PARAM2];
|
PARAM0 = inst[1].puint32[PARAM2];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD4x8, 4, 0): /* LOAD dst,base,index,DWORD_x8 */
|
||||||
|
PARAM0 = *(UINT32 *)&inst[1].puint64[PARAM2];
|
||||||
|
break;
|
||||||
|
|
||||||
case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS1, 4, 0): /* LOADS dst,base,index,BYTE */
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS1, 4, 0): /* LOADS dst,base,index,BYTE */
|
||||||
PARAM0 = inst[1].pint8[PARAM2];
|
PARAM0 = inst[1].pint8[PARAM2];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS1x2, 4, 0): /* LOADS dst,base,index,BYTE_x2 */
|
||||||
|
PARAM0 = *(INT8 *)&inst[1].pint16[PARAM2];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS1x4, 4, 0): /* LOADS dst,base,index,BYTE_x4 */
|
||||||
|
PARAM0 = *(INT8 *)&inst[1].pint32[PARAM2];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS1x8, 4, 0): /* LOADS dst,base,index,BYTE_x8 */
|
||||||
|
PARAM0 = *(INT8 *)&inst[1].pint64[PARAM2];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS2x1, 4, 0): /* LOADS dst,base,index,WORD_x1 */
|
||||||
|
PARAM0 = *(INT16 *)&inst[1].pint8[PARAM2];
|
||||||
|
break;
|
||||||
|
|
||||||
case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS2, 4, 0): /* LOADS dst,base,index,WORD */
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS2, 4, 0): /* LOADS dst,base,index,WORD */
|
||||||
PARAM0 = inst[1].pint16[PARAM2];
|
PARAM0 = inst[1].pint16[PARAM2];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS2x4, 4, 0): /* LOADS dst,base,index,WORD_x4 */
|
||||||
|
PARAM0 = *(INT16 *)&inst[1].pint32[PARAM2];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS2x8, 4, 0): /* LOADS dst,base,index,WORD_x8 */
|
||||||
|
PARAM0 = *(INT16 *)&inst[1].pint64[PARAM2];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS4x1, 4, 0): /* LOADS dst,base,index,DWORD_x1 */
|
||||||
|
PARAM0 = *(INT32 *)&inst[1].pint8[PARAM2];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS4x2, 4, 0): /* LOADS dst,base,index,DWORD_x2 */
|
||||||
|
PARAM0 = *(INT32 *)&inst[1].pint16[PARAM2];
|
||||||
|
break;
|
||||||
|
|
||||||
case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS4, 4, 0): /* LOADS dst,base,index,DWORD */
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS4, 4, 0): /* LOADS dst,base,index,DWORD */
|
||||||
PARAM0 = inst[1].pint32[PARAM2];
|
PARAM0 = inst[1].pint32[PARAM2];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS4x8, 4, 0): /* LOADS dst,base,index,DWORD_x8 */
|
||||||
|
PARAM0 = *(INT32 *)&inst[1].pint64[PARAM2];
|
||||||
|
break;
|
||||||
|
|
||||||
case MAKE_OPCODE_SHORT(DRCUML_OP_STORE1, 4, 0): /* STORE dst,base,index,BYTE */
|
case MAKE_OPCODE_SHORT(DRCUML_OP_STORE1, 4, 0): /* STORE dst,base,index,BYTE */
|
||||||
inst[0].puint8[PARAM1] = PARAM2;
|
inst[0].puint8[PARAM1] = PARAM2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_STORE1x2, 4, 0): /* STORE dst,base,index,BYTE_x2 */
|
||||||
|
*(UINT8 *)&inst[0].puint16[PARAM1] = PARAM2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_STORE1x4, 4, 0): /* STORE dst,base,index,BYTE_x4 */
|
||||||
|
*(UINT8 *)&inst[0].puint32[PARAM1] = PARAM2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_STORE1x8, 4, 0): /* STORE dst,base,index,BYTE_x8 */
|
||||||
|
*(UINT8 *)&inst[0].puint64[PARAM1] = PARAM2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_STORE2x1, 4, 0): /* STORE dst,base,index,WORD_x1 */
|
||||||
|
*(UINT16 *)&inst[0].puint8[PARAM1] = PARAM2;
|
||||||
|
break;
|
||||||
|
|
||||||
case MAKE_OPCODE_SHORT(DRCUML_OP_STORE2, 4, 0): /* STORE dst,base,index,WORD */
|
case MAKE_OPCODE_SHORT(DRCUML_OP_STORE2, 4, 0): /* STORE dst,base,index,WORD */
|
||||||
inst[0].puint16[PARAM1] = PARAM2;
|
inst[0].puint16[PARAM1] = PARAM2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_STORE2x4, 4, 0): /* STORE dst,base,index,WORD_x4 */
|
||||||
|
*(UINT16 *)&inst[0].puint32[PARAM1] = PARAM2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_STORE2x8, 4, 0): /* STORE dst,base,index,WORD_x8 */
|
||||||
|
*(UINT16 *)&inst[0].puint64[PARAM1] = PARAM2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_STORE4x1, 4, 0): /* STORE dst,base,index,DWORD_x1 */
|
||||||
|
*(UINT32 *)&inst[0].puint8[PARAM1] = PARAM2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_STORE4x2, 4, 0): /* STORE dst,base,index,DWORD_x2 */
|
||||||
|
*(UINT32 *)&inst[0].puint16[PARAM1] = PARAM2;
|
||||||
|
break;
|
||||||
|
|
||||||
case MAKE_OPCODE_SHORT(DRCUML_OP_STORE4, 4, 0): /* STORE dst,base,index,DWORD */
|
case MAKE_OPCODE_SHORT(DRCUML_OP_STORE4, 4, 0): /* STORE dst,base,index,DWORD */
|
||||||
inst[0].puint32[PARAM1] = PARAM2;
|
inst[0].puint32[PARAM1] = PARAM2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_STORE4x8, 4, 0): /* STORE dst,base,index,DWORD_x8 */
|
||||||
|
*(UINT32 *)&inst[0].puint64[PARAM1] = PARAM2;
|
||||||
|
break;
|
||||||
|
|
||||||
case MAKE_OPCODE_SHORT(DRCUML_OP_READ1, 4, 0): /* READ dst,src1,space_BYTE */
|
case MAKE_OPCODE_SHORT(DRCUML_OP_READ1, 4, 0): /* READ dst,src1,space_BYTE */
|
||||||
PARAM0 = memory_read_byte(drcbe->space[PARAM2 / 16], PARAM1);
|
PARAM0 = memory_read_byte(drcbe->space[PARAM2 / 16], PARAM1);
|
||||||
break;
|
break;
|
||||||
@ -1151,15 +1295,63 @@ static int drcbec_execute(drcbe_state *drcbe, drcuml_codehandle *entry)
|
|||||||
DPARAM0 = inst[1].puint8[PARAM2];
|
DPARAM0 = inst[1].puint8[PARAM2];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD1x2, 8, 0): /* DLOAD dst,base,index,BYTE_x2 */
|
||||||
|
DPARAM0 = *(UINT8 *)&inst[1].puint16[PARAM2];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD1x4, 8, 0): /* DLOAD dst,base,index,BYTE_x4 */
|
||||||
|
DPARAM0 = *(UINT8 *)&inst[1].puint32[PARAM2];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD1x8, 8, 0): /* DLOAD dst,base,index,BYTE_x8 */
|
||||||
|
DPARAM0 = *(UINT8 *)&inst[1].puint64[PARAM2];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD2x1, 8, 0): /* DLOAD dst,base,index,WORD_x1 */
|
||||||
|
DPARAM0 = *(UINT16 *)&inst[1].puint8[PARAM2];
|
||||||
|
break;
|
||||||
|
|
||||||
case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD2, 8, 0): /* DLOAD dst,base,index,WORD */
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD2, 8, 0): /* DLOAD dst,base,index,WORD */
|
||||||
DPARAM0 = inst[1].puint16[PARAM2];
|
DPARAM0 = inst[1].puint16[PARAM2];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD2x4, 8, 0): /* DLOAD dst,base,index,WORD_x4 */
|
||||||
|
DPARAM0 = *(UINT16 *)&inst[1].puint32[PARAM2];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD2x8, 8, 0): /* DLOAD dst,base,index,WORD_x8 */
|
||||||
|
DPARAM0 = *(UINT16 *)&inst[1].puint64[PARAM2];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD4x1, 8, 0): /* DLOAD dst,base,index,DWORD_x1 */
|
||||||
|
DPARAM0 = *(UINT32 *)&inst[1].puint8[PARAM2];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD4x2, 8, 0): /* DLOAD dst,base,index,DWORD_x2 */
|
||||||
|
DPARAM0 = *(UINT32 *)&inst[1].puint16[PARAM2];
|
||||||
|
break;
|
||||||
|
|
||||||
case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD4, 8, 0): /* DLOAD dst,base,index,DWORD */
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD4, 8, 0): /* DLOAD dst,base,index,DWORD */
|
||||||
DPARAM0 = inst[1].puint32[PARAM2];
|
DPARAM0 = inst[1].puint32[PARAM2];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD8, 8, 0): /* DLOAD dst,base,index,QWORD */
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD4x8, 8, 0): /* DLOAD dst,base,index,DWORD_x8 */
|
||||||
|
DPARAM0 = *(UINT32 *)&inst[1].puint64[PARAM2];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD8x1, 8, 0): /* DLOAD dst,base,index,QWORD_x1 */
|
||||||
|
DPARAM0 = *(UINT64 *)&inst[1].puint8[PARAM2];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD8x2, 8, 0): /* DLOAD dst,base,index,QWORD_x2 */
|
||||||
|
DPARAM0 = *(UINT64 *)&inst[1].puint16[PARAM2];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD8x4, 8, 0): /* DLOAD dst,base,index,QWORD_x4 */
|
||||||
|
DPARAM0 = *(UINT64 *)&inst[1].puint32[PARAM2];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD8, 8, 0): /* DLOAD dst,base,index,QWORD */
|
||||||
DPARAM0 = inst[1].puint64[PARAM2];
|
DPARAM0 = inst[1].puint64[PARAM2];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1167,27 +1359,127 @@ static int drcbec_execute(drcbe_state *drcbe, drcuml_codehandle *entry)
|
|||||||
DPARAM0 = inst[1].pint8[PARAM2];
|
DPARAM0 = inst[1].pint8[PARAM2];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS1x2, 8, 0): /* DLOADS dst,base,index,BYTE_x2 */
|
||||||
|
DPARAM0 = *(INT8 *)&inst[1].pint16[PARAM2];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS1x4, 8, 0): /* DLOADS dst,base,index,BYTE_x4 */
|
||||||
|
DPARAM0 = *(INT8 *)&inst[1].pint32[PARAM2];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS1x8, 8, 0): /* DLOADS dst,base,index,BYTE_x8 */
|
||||||
|
DPARAM0 = *(INT8 *)&inst[1].pint64[PARAM2];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS2x1, 8, 0): /* DLOADS dst,base,index,WORD_x1 */
|
||||||
|
DPARAM0 = *(INT16 *)&inst[1].pint8[PARAM2];
|
||||||
|
break;
|
||||||
|
|
||||||
case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS2, 8, 0): /* DLOADS dst,base,index,WORD */
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS2, 8, 0): /* DLOADS dst,base,index,WORD */
|
||||||
DPARAM0 = inst[1].pint16[PARAM2];
|
DPARAM0 = inst[1].pint16[PARAM2];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS2x4, 8, 0): /* DLOADS dst,base,index,WORD_x4 */
|
||||||
|
DPARAM0 = *(INT16 *)&inst[1].pint32[PARAM2];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS2x8, 8, 0): /* DLOADS dst,base,index,WORD_x8 */
|
||||||
|
DPARAM0 = *(INT16 *)&inst[1].pint64[PARAM2];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS4x1, 8, 0): /* DLOADS dst,base,index,DWORD_x1 */
|
||||||
|
DPARAM0 = *(INT32 *)&inst[1].pint8[PARAM2];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS4x2, 8, 0): /* DLOADS dst,base,index,DWORD_x2 */
|
||||||
|
DPARAM0 = *(INT32 *)&inst[1].pint16[PARAM2];
|
||||||
|
break;
|
||||||
|
|
||||||
case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS4, 8, 0): /* DLOADS dst,base,index,DWORD */
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS4, 8, 0): /* DLOADS dst,base,index,DWORD */
|
||||||
DPARAM0 = inst[1].pint32[PARAM2];
|
DPARAM0 = inst[1].pint32[PARAM2];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS4x8, 8, 0): /* DLOADS dst,base,index,DWORD_x8 */
|
||||||
|
DPARAM0 = *(INT32 *)&inst[1].pint64[PARAM2];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS8x1, 8, 0): /* DLOADS dst,base,index,QWORD_x1 */
|
||||||
|
DPARAM0 = *(INT64 *)&inst[1].pint8[PARAM2];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS8x2, 8, 0): /* DLOADS dst,base,index,QWORD_x2 */
|
||||||
|
DPARAM0 = *(INT64 *)&inst[1].pint16[PARAM2];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS8x4, 8, 0): /* DLOADS dst,base,index,QWORD_x4 */
|
||||||
|
DPARAM0 = *(INT64 *)&inst[1].pint32[PARAM2];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS8, 8, 0): /* DLOADS dst,base,index,QWORD */
|
||||||
|
DPARAM0 = inst[1].pint64[PARAM2];
|
||||||
|
break;
|
||||||
|
|
||||||
case MAKE_OPCODE_SHORT(DRCUML_OP_STORE1, 8, 0): /* DSTORE dst,base,index,BYTE */
|
case MAKE_OPCODE_SHORT(DRCUML_OP_STORE1, 8, 0): /* DSTORE dst,base,index,BYTE */
|
||||||
inst[0].puint8[PARAM1] = DPARAM2;
|
inst[0].puint8[PARAM1] = DPARAM2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_STORE1x2, 8, 0): /* DSTORE dst,base,index,BYTE_x2 */
|
||||||
|
*(UINT8 *)&inst[0].puint16[PARAM1] = DPARAM2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_STORE1x4, 8, 0): /* DSTORE dst,base,index,BYTE_x4 */
|
||||||
|
*(UINT8 *)&inst[0].puint32[PARAM1] = DPARAM2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_STORE1x8, 8, 0): /* DSTORE dst,base,index,BYTE_x8 */
|
||||||
|
*(UINT8 *)&inst[0].puint64[PARAM1] = DPARAM2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_STORE2x1, 8, 0): /* DSTORE dst,base,index,WORD_x1 */
|
||||||
|
*(UINT16 *)&inst[0].puint8[PARAM1] = DPARAM2;
|
||||||
|
break;
|
||||||
|
|
||||||
case MAKE_OPCODE_SHORT(DRCUML_OP_STORE2, 8, 0): /* DSTORE dst,base,index,WORD */
|
case MAKE_OPCODE_SHORT(DRCUML_OP_STORE2, 8, 0): /* DSTORE dst,base,index,WORD */
|
||||||
inst[0].puint16[PARAM1] = DPARAM2;
|
inst[0].puint16[PARAM1] = DPARAM2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_STORE2x4, 8, 0): /* DSTORE dst,base,index,WORD_x4 */
|
||||||
|
*(UINT16 *)&inst[0].puint32[PARAM1] = DPARAM2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_STORE2x8, 8, 0): /* DSTORE dst,base,index,WORD_x8 */
|
||||||
|
*(UINT16 *)&inst[0].puint64[PARAM1] = DPARAM2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_STORE4x1, 8, 0): /* DSTORE dst,base,index,DWORD_x1 */
|
||||||
|
*(UINT32 *)&inst[0].puint8[PARAM1] = DPARAM2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_STORE4x2, 8, 0): /* DSTORE dst,base,index,DWORD_x2 */
|
||||||
|
*(UINT32 *)&inst[0].puint16[PARAM1] = DPARAM2;
|
||||||
|
break;
|
||||||
|
|
||||||
case MAKE_OPCODE_SHORT(DRCUML_OP_STORE4, 8, 0): /* DSTORE dst,base,index,DWORD */
|
case MAKE_OPCODE_SHORT(DRCUML_OP_STORE4, 8, 0): /* DSTORE dst,base,index,DWORD */
|
||||||
inst[0].puint32[PARAM1] = DPARAM2;
|
inst[0].puint32[PARAM1] = DPARAM2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MAKE_OPCODE_SHORT(DRCUML_OP_STORE8, 8, 0): /* DSTORE dst,base,index,QWORD */
|
case MAKE_OPCODE_SHORT(DRCUML_OP_STORE4x8, 8, 0): /* DSTORE dst,base,index,DWORD_x8 */
|
||||||
|
*(UINT32 *)&inst[0].puint64[PARAM1] = DPARAM2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_STORE8x1, 8, 0): /* DSTORE dst,base,index,QWORD_x1 */
|
||||||
|
*(UINT64 *)&inst[0].puint8[PARAM1] = DPARAM2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_STORE8x2, 8, 0): /* DSTORE dst,base,index,QWORD_x2 */
|
||||||
|
*(UINT64 *)&inst[0].puint16[PARAM1] = DPARAM2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_STORE8x4, 8, 0): /* DSTORE dst,base,index,QWORD_x4 */
|
||||||
|
*(UINT64 *)&inst[0].puint32[PARAM1] = DPARAM2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAKE_OPCODE_SHORT(DRCUML_OP_STORE8, 8, 0): /* DSTORE dst,base,index,QWORD */
|
||||||
inst[0].puint64[PARAM1] = DPARAM2;
|
inst[0].puint64[PARAM1] = DPARAM2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -3808,8 +3808,8 @@ static x86code *op_restore(drcbe_state *drcbe, x86code *dst, const drcuml_instru
|
|||||||
|
|
||||||
static x86code *op_load(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst)
|
static x86code *op_load(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst)
|
||||||
{
|
{
|
||||||
drcuml_parameter dstp, basep, indp, sizep;
|
drcuml_parameter dstp, basep, indp, scalesizep;
|
||||||
int basereg, dstreg;
|
int basereg, dstreg, scale, size;
|
||||||
INT32 baseoffs;
|
INT32 baseoffs;
|
||||||
|
|
||||||
/* validate instruction */
|
/* validate instruction */
|
||||||
@ -3818,7 +3818,9 @@ static x86code *op_load(drcbe_state *drcbe, x86code *dst, const drcuml_instructi
|
|||||||
assert_no_flags(inst);
|
assert_no_flags(inst);
|
||||||
|
|
||||||
/* normalize parameters */
|
/* normalize parameters */
|
||||||
param_normalize_4(drcbe, inst, &dstp, PTYPE_MR, &basep, PTYPE_M, &indp, PTYPE_MRI, &sizep, PTYPE_I);
|
param_normalize_4(drcbe, inst, &dstp, PTYPE_MR, &basep, PTYPE_M, &indp, PTYPE_MRI, &scalesizep, PTYPE_I);
|
||||||
|
scale = 1 << (scalesizep.value / 16);
|
||||||
|
size = scalesizep.value % 16;
|
||||||
|
|
||||||
/* determine the pointer base */
|
/* determine the pointer base */
|
||||||
basereg = get_base_register_and_offset(drcbe, &dst, basep.value, REG_RDX, &baseoffs);
|
basereg = get_base_register_and_offset(drcbe, &dst, basep.value, REG_RDX, &baseoffs);
|
||||||
@ -3829,14 +3831,14 @@ static x86code *op_load(drcbe_state *drcbe, x86code *dst, const drcuml_instructi
|
|||||||
/* immediate index */
|
/* immediate index */
|
||||||
if (indp.type == DRCUML_PTYPE_IMMEDIATE)
|
if (indp.type == DRCUML_PTYPE_IMMEDIATE)
|
||||||
{
|
{
|
||||||
if (sizep.value == DRCUML_SIZE_BYTE)
|
if (size == DRCUML_SIZE_BYTE)
|
||||||
emit_movzx_r32_m8(&dst, dstreg, MBD(basereg, baseoffs + 1*indp.value)); // movzx dstreg,[basep + 1*indp]
|
emit_movzx_r32_m8(&dst, dstreg, MBD(basereg, baseoffs + scale*indp.value)); // movzx dstreg,[basep + scale*indp]
|
||||||
else if (sizep.value == DRCUML_SIZE_WORD)
|
else if (size == DRCUML_SIZE_WORD)
|
||||||
emit_movzx_r32_m16(&dst, dstreg, MBD(basereg, baseoffs + 2*indp.value)); // movzx dstreg,[basep + 2*indp]
|
emit_movzx_r32_m16(&dst, dstreg, MBD(basereg, baseoffs + scale*indp.value));// movzx dstreg,[basep + scale*indp]
|
||||||
else if (sizep.value == DRCUML_SIZE_DWORD)
|
else if (size == DRCUML_SIZE_DWORD)
|
||||||
emit_mov_r32_m32(&dst, dstreg, MBD(basereg, baseoffs + 4*indp.value)); // mov dstreg,[basep + 4*indp]
|
emit_mov_r32_m32(&dst, dstreg, MBD(basereg, baseoffs + scale*indp.value)); // mov dstreg,[basep + scale*indp]
|
||||||
else if (sizep.value == DRCUML_SIZE_QWORD)
|
else if (size == DRCUML_SIZE_QWORD)
|
||||||
emit_mov_r64_m64(&dst, dstreg, MBD(basereg, baseoffs + 8*indp.value)); // mov dstreg,[basep + 8*indp]
|
emit_mov_r64_m64(&dst, dstreg, MBD(basereg, baseoffs + scale*indp.value)); // mov dstreg,[basep + scale*indp]
|
||||||
}
|
}
|
||||||
|
|
||||||
/* other index */
|
/* other index */
|
||||||
@ -3844,14 +3846,14 @@ static x86code *op_load(drcbe_state *drcbe, x86code *dst, const drcuml_instructi
|
|||||||
{
|
{
|
||||||
int indreg = param_select_register(REG_ECX, &indp, NULL);
|
int indreg = param_select_register(REG_ECX, &indp, NULL);
|
||||||
emit_mov_r32_p32(drcbe, &dst, indreg, &indp);
|
emit_mov_r32_p32(drcbe, &dst, indreg, &indp);
|
||||||
if (sizep.value == DRCUML_SIZE_BYTE)
|
if (size == DRCUML_SIZE_BYTE)
|
||||||
emit_movzx_r32_m8(&dst, dstreg, MBISD(basereg, indreg, 1, baseoffs)); // movzx dstreg,[basep + 1*indp]
|
emit_movzx_r32_m8(&dst, dstreg, MBISD(basereg, indreg, scale, baseoffs)); // movzx dstreg,[basep + scale*indp]
|
||||||
else if (sizep.value == DRCUML_SIZE_WORD)
|
else if (size == DRCUML_SIZE_WORD)
|
||||||
emit_movzx_r32_m16(&dst, dstreg, MBISD(basereg, indreg, 2, baseoffs)); // movzx dstreg,[basep + 2*indp]
|
emit_movzx_r32_m16(&dst, dstreg, MBISD(basereg, indreg, scale, baseoffs)); // movzx dstreg,[basep + scale*indp]
|
||||||
else if (sizep.value == DRCUML_SIZE_DWORD)
|
else if (size == DRCUML_SIZE_DWORD)
|
||||||
emit_mov_r32_m32(&dst, dstreg, MBISD(basereg, indreg, 4, baseoffs)); // mov dstreg,[basep + 4*indp]
|
emit_mov_r32_m32(&dst, dstreg, MBISD(basereg, indreg, scale, baseoffs)); // mov dstreg,[basep + scale*indp]
|
||||||
else if (sizep.value == DRCUML_SIZE_QWORD)
|
else if (size == DRCUML_SIZE_QWORD)
|
||||||
emit_mov_r64_m64(&dst, dstreg, MBISD(basereg, indreg, 8, baseoffs)); // mov dstreg,[basep + 8*indp]
|
emit_mov_r64_m64(&dst, dstreg, MBISD(basereg, indreg, scale, baseoffs)); // mov dstreg,[basep + scale*indp]
|
||||||
}
|
}
|
||||||
|
|
||||||
/* store result */
|
/* store result */
|
||||||
@ -3870,8 +3872,8 @@ static x86code *op_load(drcbe_state *drcbe, x86code *dst, const drcuml_instructi
|
|||||||
|
|
||||||
static x86code *op_loads(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst)
|
static x86code *op_loads(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst)
|
||||||
{
|
{
|
||||||
drcuml_parameter dstp, basep, indp, sizep;
|
drcuml_parameter dstp, basep, indp, scalesizep;
|
||||||
int basereg, dstreg;
|
int basereg, dstreg, scale, size;
|
||||||
INT32 baseoffs;
|
INT32 baseoffs;
|
||||||
|
|
||||||
/* validate instruction */
|
/* validate instruction */
|
||||||
@ -3880,7 +3882,9 @@ static x86code *op_loads(drcbe_state *drcbe, x86code *dst, const drcuml_instruct
|
|||||||
assert_no_flags(inst);
|
assert_no_flags(inst);
|
||||||
|
|
||||||
/* normalize parameters */
|
/* normalize parameters */
|
||||||
param_normalize_4(drcbe, inst, &dstp, PTYPE_MR, &basep, PTYPE_M, &indp, PTYPE_MRI, &sizep, PTYPE_I);
|
param_normalize_4(drcbe, inst, &dstp, PTYPE_MR, &basep, PTYPE_M, &indp, PTYPE_MRI, &scalesizep, PTYPE_I);
|
||||||
|
scale = 1 << (scalesizep.value / 16);
|
||||||
|
size = scalesizep.value % 16;
|
||||||
|
|
||||||
/* determine the pointer base */
|
/* determine the pointer base */
|
||||||
basereg = get_base_register_and_offset(drcbe, &dst, basep.value, REG_RDX, &baseoffs);
|
basereg = get_base_register_and_offset(drcbe, &dst, basep.value, REG_RDX, &baseoffs);
|
||||||
@ -3893,23 +3897,23 @@ static x86code *op_loads(drcbe_state *drcbe, x86code *dst, const drcuml_instruct
|
|||||||
{
|
{
|
||||||
if (inst->size == 4)
|
if (inst->size == 4)
|
||||||
{
|
{
|
||||||
if (sizep.value == DRCUML_SIZE_BYTE)
|
if (size == DRCUML_SIZE_BYTE)
|
||||||
emit_movsx_r32_m8(&dst, dstreg, MBD(basereg, baseoffs + 1*indp.value)); // movsx dstreg,[basep + 1*indp]
|
emit_movsx_r32_m8(&dst, dstreg, MBD(basereg, baseoffs + scale*indp.value)); // movsx dstreg,[basep + scale*indp]
|
||||||
else if (sizep.value == DRCUML_SIZE_WORD)
|
else if (size == DRCUML_SIZE_WORD)
|
||||||
emit_movsx_r32_m16(&dst, dstreg, MBD(basereg, baseoffs + 2*indp.value));// movsx dstreg,[basep + 2*indp]
|
emit_movsx_r32_m16(&dst, dstreg, MBD(basereg, baseoffs + scale*indp.value));// movsx dstreg,[basep + scale*indp]
|
||||||
else if (sizep.value == DRCUML_SIZE_DWORD)
|
else if (size == DRCUML_SIZE_DWORD)
|
||||||
emit_mov_r32_m32(&dst, dstreg, MBD(basereg, baseoffs + 4*indp.value)); // mov dstreg,[basep + 4*indp]
|
emit_mov_r32_m32(&dst, dstreg, MBD(basereg, baseoffs + scale*indp.value)); // mov dstreg,[basep + scale*indp]
|
||||||
}
|
}
|
||||||
else if (inst->size == 8)
|
else if (inst->size == 8)
|
||||||
{
|
{
|
||||||
if (sizep.value == DRCUML_SIZE_BYTE)
|
if (size == DRCUML_SIZE_BYTE)
|
||||||
emit_movsx_r64_m8(&dst, dstreg, MBD(basereg, baseoffs + 1*indp.value)); // movzx dstreg,[basep + 1*indp]
|
emit_movsx_r64_m8(&dst, dstreg, MBD(basereg, baseoffs + scale*indp.value)); // movzx dstreg,[basep + scale*indp]
|
||||||
else if (sizep.value == DRCUML_SIZE_WORD)
|
else if (size == DRCUML_SIZE_WORD)
|
||||||
emit_movsx_r64_m16(&dst, dstreg, MBD(basereg, baseoffs + 2*indp.value));// movzx dstreg,[basep + 2*indp]
|
emit_movsx_r64_m16(&dst, dstreg, MBD(basereg, baseoffs + scale*indp.value));// movzx dstreg,[basep + scale*indp]
|
||||||
else if (sizep.value == DRCUML_SIZE_DWORD)
|
else if (size == DRCUML_SIZE_DWORD)
|
||||||
emit_movsxd_r64_m32(&dst, dstreg, MBD(basereg, baseoffs + 4*indp.value));// movsxd dstreg,[basep + 4*indp]
|
emit_movsxd_r64_m32(&dst, dstreg, MBD(basereg, baseoffs + scale*indp.value));// movsxd dstreg,[basep + scale*indp]
|
||||||
else if (sizep.value == DRCUML_SIZE_QWORD)
|
else if (size == DRCUML_SIZE_QWORD)
|
||||||
emit_mov_r64_m64(&dst, dstreg, MBD(basereg, baseoffs + 8*indp.value)); // mov dstreg,[basep + 8*indp]
|
emit_mov_r64_m64(&dst, dstreg, MBD(basereg, baseoffs + scale*indp.value)); // mov dstreg,[basep + scale*indp]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3920,23 +3924,23 @@ static x86code *op_loads(drcbe_state *drcbe, x86code *dst, const drcuml_instruct
|
|||||||
emit_mov_r32_p32(drcbe, &dst, indreg, &indp);
|
emit_mov_r32_p32(drcbe, &dst, indreg, &indp);
|
||||||
if (inst->size == 4)
|
if (inst->size == 4)
|
||||||
{
|
{
|
||||||
if (sizep.value == DRCUML_SIZE_BYTE)
|
if (size == DRCUML_SIZE_BYTE)
|
||||||
emit_movsx_r32_m8(&dst, dstreg, MBISD(basereg, indreg, 1, baseoffs)); // movsx dstreg,[basep + 1*indp]
|
emit_movsx_r32_m8(&dst, dstreg, MBISD(basereg, indreg, scale, baseoffs)); // movsx dstreg,[basep + scale*indp]
|
||||||
else if (sizep.value == DRCUML_SIZE_WORD)
|
else if (size == DRCUML_SIZE_WORD)
|
||||||
emit_movsx_r32_m16(&dst, dstreg, MBISD(basereg, indreg, 2, baseoffs)); // movsx dstreg,[basep + 2*indp]
|
emit_movsx_r32_m16(&dst, dstreg, MBISD(basereg, indreg, scale, baseoffs)); // movsx dstreg,[basep + scale*indp]
|
||||||
else if (sizep.value == DRCUML_SIZE_DWORD)
|
else if (size == DRCUML_SIZE_DWORD)
|
||||||
emit_mov_r32_m32(&dst, dstreg, MBISD(basereg, indreg, 4, baseoffs)); // mov dstreg,[basep + 4*indp]
|
emit_mov_r32_m32(&dst, dstreg, MBISD(basereg, indreg, scale, baseoffs)); // mov dstreg,[basep + scale*indp]
|
||||||
}
|
}
|
||||||
else if (inst->size == 8)
|
else if (inst->size == 8)
|
||||||
{
|
{
|
||||||
if (sizep.value == DRCUML_SIZE_BYTE)
|
if (size == DRCUML_SIZE_BYTE)
|
||||||
emit_movsx_r64_m8(&dst, dstreg, MBISD(basereg, indreg, 1, baseoffs)); // movsx dstreg,[basep + 1*indp]
|
emit_movsx_r64_m8(&dst, dstreg, MBISD(basereg, indreg, scale, baseoffs)); // movsx dstreg,[basep + scale*indp]
|
||||||
else if (sizep.value == DRCUML_SIZE_WORD)
|
else if (size == DRCUML_SIZE_WORD)
|
||||||
emit_movsx_r64_m16(&dst, dstreg, MBISD(basereg, indreg, 2, baseoffs)); // movsx dstreg,[basep + 2*indp]
|
emit_movsx_r64_m16(&dst, dstreg, MBISD(basereg, indreg, scale, baseoffs)); // movsx dstreg,[basep + scale*indp]
|
||||||
else if (sizep.value == DRCUML_SIZE_DWORD)
|
else if (size == DRCUML_SIZE_DWORD)
|
||||||
emit_movsxd_r64_m32(&dst, dstreg, MBISD(basereg, indreg, 4, baseoffs)); // movsxd dstreg,[basep + 4*indp]
|
emit_movsxd_r64_m32(&dst, dstreg, MBISD(basereg, indreg, scale, baseoffs)); // movsxd dstreg,[basep + scale*indp]
|
||||||
else if (sizep.value == DRCUML_SIZE_QWORD)
|
else if (size == DRCUML_SIZE_QWORD)
|
||||||
emit_mov_r64_m64(&dst, dstreg, MBISD(basereg, indreg, 8, baseoffs)); // mov dstreg,[basep + 8*indp]
|
emit_mov_r64_m64(&dst, dstreg, MBISD(basereg, indreg, scale, baseoffs)); // mov dstreg,[basep + scale*indp]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3956,8 +3960,8 @@ static x86code *op_loads(drcbe_state *drcbe, x86code *dst, const drcuml_instruct
|
|||||||
|
|
||||||
static x86code *op_store(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst)
|
static x86code *op_store(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst)
|
||||||
{
|
{
|
||||||
drcuml_parameter srcp, basep, indp, sizep;
|
drcuml_parameter srcp, basep, indp, scalesizep;
|
||||||
int srcreg, basereg;
|
int srcreg, basereg, scale, size;
|
||||||
INT32 baseoffs;
|
INT32 baseoffs;
|
||||||
|
|
||||||
/* validate instruction */
|
/* validate instruction */
|
||||||
@ -3966,7 +3970,9 @@ static x86code *op_store(drcbe_state *drcbe, x86code *dst, const drcuml_instruct
|
|||||||
assert_no_flags(inst);
|
assert_no_flags(inst);
|
||||||
|
|
||||||
/* normalize parameters */
|
/* normalize parameters */
|
||||||
param_normalize_4(drcbe, inst, &basep, PTYPE_M, &indp, PTYPE_MRI, &srcp, PTYPE_MRI, &sizep, PTYPE_I);
|
param_normalize_4(drcbe, inst, &basep, PTYPE_M, &indp, PTYPE_MRI, &srcp, PTYPE_MRI, &scalesizep, PTYPE_I);
|
||||||
|
scale = 1 << (scalesizep.value / 16);
|
||||||
|
size = scalesizep.value % 16;
|
||||||
|
|
||||||
/* determine the pointer base */
|
/* determine the pointer base */
|
||||||
basereg = get_base_register_and_offset(drcbe, &dst, basep.value, REG_RDX, &baseoffs);
|
basereg = get_base_register_and_offset(drcbe, &dst, basep.value, REG_RDX, &baseoffs);
|
||||||
@ -3980,21 +3986,21 @@ static x86code *op_store(drcbe_state *drcbe, x86code *dst, const drcuml_instruct
|
|||||||
/* immediate source */
|
/* immediate source */
|
||||||
if (srcp.type == DRCUML_PTYPE_IMMEDIATE)
|
if (srcp.type == DRCUML_PTYPE_IMMEDIATE)
|
||||||
{
|
{
|
||||||
if (sizep.value == DRCUML_SIZE_BYTE)
|
if (size == DRCUML_SIZE_BYTE)
|
||||||
emit_mov_m8_imm(&dst, MBD(basereg, baseoffs + 1*indp.value), srcp.value); // mov [basep + 1*indp],srcp
|
emit_mov_m8_imm(&dst, MBD(basereg, baseoffs + scale*indp.value), srcp.value); // mov [basep + scale*indp],srcp
|
||||||
else if (sizep.value == DRCUML_SIZE_WORD)
|
else if (size == DRCUML_SIZE_WORD)
|
||||||
emit_mov_m16_imm(&dst, MBD(basereg, baseoffs + 2*indp.value), srcp.value); // mov [basep + 2*indp],srcp
|
emit_mov_m16_imm(&dst, MBD(basereg, baseoffs + scale*indp.value), srcp.value); // mov [basep + scale*indp],srcp
|
||||||
else if (sizep.value == DRCUML_SIZE_DWORD)
|
else if (size == DRCUML_SIZE_DWORD)
|
||||||
emit_mov_m32_imm(&dst, MBD(basereg, baseoffs + 4*indp.value), srcp.value); // mov [basep + 4*indp],srcp
|
emit_mov_m32_imm(&dst, MBD(basereg, baseoffs + scale*indp.value), srcp.value); // mov [basep + scale*indp],srcp
|
||||||
else if (sizep.value == DRCUML_SIZE_QWORD)
|
else if (size == DRCUML_SIZE_QWORD)
|
||||||
{
|
{
|
||||||
if (short_immediate(srcp.value))
|
if (short_immediate(srcp.value))
|
||||||
emit_mov_m64_imm(&dst, MBD(basereg, baseoffs + 8*indp.value), srcp.value);// mov [basep + 8*indp],srcp
|
emit_mov_m64_imm(&dst, MBD(basereg, baseoffs + scale*indp.value), srcp.value);// mov [basep + scale*indp],srcp
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
emit_mov_m32_imm(&dst, MBD(basereg, baseoffs + 8*indp.value), srcp.value);// mov [basep + 8*indp],srcp
|
emit_mov_m32_imm(&dst, MBD(basereg, baseoffs + scale*indp.value), srcp.value);// mov [basep + scale*indp],srcp
|
||||||
emit_mov_m32_imm(&dst, MBD(basereg, baseoffs + 8*indp.value + 4), srcp.value >> 32);
|
emit_mov_m32_imm(&dst, MBD(basereg, baseoffs + scale*indp.value + 4), srcp.value >> 32);
|
||||||
// mov [basep + 8*indp + 4],srcp >> 32
|
// mov [basep + scale*indp + 4],srcp >> 32
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4002,18 +4008,18 @@ static x86code *op_store(drcbe_state *drcbe, x86code *dst, const drcuml_instruct
|
|||||||
/* variable source */
|
/* variable source */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (sizep.value != DRCUML_SIZE_QWORD)
|
if (size != DRCUML_SIZE_QWORD)
|
||||||
emit_mov_r32_p32(drcbe, &dst, srcreg, &srcp); // mov srcreg,srcp
|
emit_mov_r32_p32(drcbe, &dst, srcreg, &srcp); // mov srcreg,srcp
|
||||||
else
|
else
|
||||||
emit_mov_r64_p64(drcbe, &dst, srcreg, &srcp); // mov srcreg,srcp
|
emit_mov_r64_p64(drcbe, &dst, srcreg, &srcp); // mov srcreg,srcp
|
||||||
if (sizep.value == DRCUML_SIZE_BYTE)
|
if (size == DRCUML_SIZE_BYTE)
|
||||||
emit_mov_m8_r8(&dst, MBD(basereg, baseoffs + 1*indp.value), srcreg); // mov [basep + 1*indp],srcreg
|
emit_mov_m8_r8(&dst, MBD(basereg, baseoffs + scale*indp.value), srcreg); // mov [basep + scale*indp],srcreg
|
||||||
else if (sizep.value == DRCUML_SIZE_WORD)
|
else if (size == DRCUML_SIZE_WORD)
|
||||||
emit_mov_m16_r16(&dst, MBD(basereg, baseoffs + 2*indp.value), srcreg); // mov [basep + 2*indp],srcreg
|
emit_mov_m16_r16(&dst, MBD(basereg, baseoffs + scale*indp.value), srcreg); // mov [basep + scale*indp],srcreg
|
||||||
else if (sizep.value == DRCUML_SIZE_DWORD)
|
else if (size == DRCUML_SIZE_DWORD)
|
||||||
emit_mov_m32_r32(&dst, MBD(basereg, baseoffs + 4*indp.value), srcreg); // mov [basep + 4*indp],srcreg
|
emit_mov_m32_r32(&dst, MBD(basereg, baseoffs + scale*indp.value), srcreg); // mov [basep + scale*indp],srcreg
|
||||||
else if (sizep.value == DRCUML_SIZE_QWORD)
|
else if (size == DRCUML_SIZE_QWORD)
|
||||||
emit_mov_m64_r64(&dst, MBD(basereg, baseoffs + 8*indp.value), srcreg); // mov [basep + 8*indp],srcreg
|
emit_mov_m64_r64(&dst, MBD(basereg, baseoffs + scale*indp.value), srcreg); // mov [basep + scale*indp],srcreg
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4026,21 +4032,21 @@ static x86code *op_store(drcbe_state *drcbe, x86code *dst, const drcuml_instruct
|
|||||||
/* immediate source */
|
/* immediate source */
|
||||||
if (srcp.type == DRCUML_PTYPE_IMMEDIATE)
|
if (srcp.type == DRCUML_PTYPE_IMMEDIATE)
|
||||||
{
|
{
|
||||||
if (sizep.value == DRCUML_SIZE_BYTE)
|
if (size == DRCUML_SIZE_BYTE)
|
||||||
emit_mov_m8_imm(&dst, MBISD(basereg, indreg, 1, baseoffs), srcp.value); // mov [basep + 1*ecx],srcp
|
emit_mov_m8_imm(&dst, MBISD(basereg, indreg, scale, baseoffs), srcp.value); // mov [basep + scale*ecx],srcp
|
||||||
else if (sizep.value == DRCUML_SIZE_WORD)
|
else if (size == DRCUML_SIZE_WORD)
|
||||||
emit_mov_m16_imm(&dst, MBISD(basereg, indreg, 2, baseoffs), srcp.value);// mov [basep + 2*ecx],srcp
|
emit_mov_m16_imm(&dst, MBISD(basereg, indreg, scale, baseoffs), srcp.value);// mov [basep + scale*ecx],srcp
|
||||||
else if (sizep.value == DRCUML_SIZE_DWORD)
|
else if (size == DRCUML_SIZE_DWORD)
|
||||||
emit_mov_m32_imm(&dst, MBISD(basereg, indreg, 4, baseoffs), srcp.value);// mov [basep + 4*ecx],srcp
|
emit_mov_m32_imm(&dst, MBISD(basereg, indreg, scale, baseoffs), srcp.value);// mov [basep + scale*ecx],srcp
|
||||||
else if (sizep.value == DRCUML_SIZE_QWORD)
|
else if (size == DRCUML_SIZE_QWORD)
|
||||||
{
|
{
|
||||||
if (short_immediate(srcp.value))
|
if (short_immediate(srcp.value))
|
||||||
emit_mov_m64_imm(&dst, MBISD(basereg, indreg, 8, baseoffs), srcp.value);// mov [basep + 8*indp],srcp
|
emit_mov_m64_imm(&dst, MBISD(basereg, indreg, scale, baseoffs), srcp.value);// mov [basep + scale*indp],srcp
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
emit_mov_m32_imm(&dst, MBISD(basereg, indreg, 8, baseoffs), srcp.value);// mov [basep + 8*ecx],srcp
|
emit_mov_m32_imm(&dst, MBISD(basereg, indreg, scale, baseoffs), srcp.value);// mov [basep + scale*ecx],srcp
|
||||||
emit_mov_m32_imm(&dst, MBISD(basereg, indreg, 8, baseoffs + 4), srcp.value >> 32);
|
emit_mov_m32_imm(&dst, MBISD(basereg, indreg, scale, baseoffs + 4), srcp.value >> 32);
|
||||||
// mov [basep + 8*ecx + 4],srcp >> 32
|
// mov [basep + scale*ecx + 4],srcp >> 32
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4048,18 +4054,18 @@ static x86code *op_store(drcbe_state *drcbe, x86code *dst, const drcuml_instruct
|
|||||||
/* variable source */
|
/* variable source */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (sizep.value != DRCUML_SIZE_QWORD)
|
if (size != DRCUML_SIZE_QWORD)
|
||||||
emit_mov_r32_p32(drcbe, &dst, srcreg, &srcp); // mov srcreg,srcp
|
emit_mov_r32_p32(drcbe, &dst, srcreg, &srcp); // mov srcreg,srcp
|
||||||
else
|
else
|
||||||
emit_mov_r64_p64(drcbe, &dst, srcreg, &srcp); // mov edx:srcreg,srcp
|
emit_mov_r64_p64(drcbe, &dst, srcreg, &srcp); // mov edx:srcreg,srcp
|
||||||
if (sizep.value == DRCUML_SIZE_BYTE)
|
if (size == DRCUML_SIZE_BYTE)
|
||||||
emit_mov_m8_r8(&dst, MBISD(basereg, indreg, 1, baseoffs), srcreg); // mov [basep + 1*ecx],srcreg
|
emit_mov_m8_r8(&dst, MBISD(basereg, indreg, scale, baseoffs), srcreg); // mov [basep + scale*ecx],srcreg
|
||||||
else if (sizep.value == DRCUML_SIZE_WORD)
|
else if (size == DRCUML_SIZE_WORD)
|
||||||
emit_mov_m16_r16(&dst, MBISD(basereg, indreg, 2, baseoffs), srcreg); // mov [basep + 2*ecx],srcreg
|
emit_mov_m16_r16(&dst, MBISD(basereg, indreg, scale, baseoffs), srcreg);// mov [basep + scale*ecx],srcreg
|
||||||
else if (sizep.value == DRCUML_SIZE_DWORD)
|
else if (size == DRCUML_SIZE_DWORD)
|
||||||
emit_mov_m32_r32(&dst, MBISD(basereg, indreg, 4, baseoffs), srcreg); // mov [basep + 4*ecx],srcreg
|
emit_mov_m32_r32(&dst, MBISD(basereg, indreg, scale, baseoffs), srcreg);// mov [basep + scale*ecx],srcreg
|
||||||
else if (sizep.value == DRCUML_SIZE_QWORD)
|
else if (size == DRCUML_SIZE_QWORD)
|
||||||
emit_mov_m64_r64(&dst, MBISD(basereg, indreg, 8, baseoffs), srcreg); // mov [basep + 8*ecx],srcreg
|
emit_mov_m64_r64(&dst, MBISD(basereg, indreg, scale, baseoffs), srcreg);// mov [basep + scale*ecx],srcreg
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return dst;
|
return dst;
|
||||||
|
@ -3856,8 +3856,8 @@ static x86code *op_restore(drcbe_state *drcbe, x86code *dst, const drcuml_instru
|
|||||||
|
|
||||||
static x86code *op_load(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst)
|
static x86code *op_load(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst)
|
||||||
{
|
{
|
||||||
drcuml_parameter dstp, basep, indp, sizep;
|
drcuml_parameter dstp, basep, indp, scalesizep;
|
||||||
int dstreg;
|
int dstreg, scale, size;
|
||||||
|
|
||||||
/* validate instruction */
|
/* validate instruction */
|
||||||
assert(inst->size == 4 || inst->size == 8);
|
assert(inst->size == 4 || inst->size == 8);
|
||||||
@ -3865,7 +3865,9 @@ static x86code *op_load(drcbe_state *drcbe, x86code *dst, const drcuml_instructi
|
|||||||
assert_no_flags(inst);
|
assert_no_flags(inst);
|
||||||
|
|
||||||
/* normalize parameters */
|
/* normalize parameters */
|
||||||
param_normalize_4(drcbe, inst, &dstp, PTYPE_MR, &basep, PTYPE_M, &indp, PTYPE_MRI, &sizep, PTYPE_I);
|
param_normalize_4(drcbe, inst, &dstp, PTYPE_MR, &basep, PTYPE_M, &indp, PTYPE_MRI, &scalesizep, PTYPE_I);
|
||||||
|
scale = 1 << (scalesizep.value / 16);
|
||||||
|
size = scalesizep.value % 16;
|
||||||
|
|
||||||
/* pick a target register for the general case */
|
/* pick a target register for the general case */
|
||||||
dstreg = param_select_register(REG_EAX, &dstp, NULL);
|
dstreg = param_select_register(REG_EAX, &dstp, NULL);
|
||||||
@ -3873,16 +3875,16 @@ static x86code *op_load(drcbe_state *drcbe, x86code *dst, const drcuml_instructi
|
|||||||
/* immediate index */
|
/* immediate index */
|
||||||
if (indp.type == DRCUML_PTYPE_IMMEDIATE)
|
if (indp.type == DRCUML_PTYPE_IMMEDIATE)
|
||||||
{
|
{
|
||||||
if (sizep.value == DRCUML_SIZE_BYTE)
|
if (size == DRCUML_SIZE_BYTE)
|
||||||
emit_movzx_r32_m8(&dst, dstreg, MABS(basep.value + 1*indp.value)); // movzx dstreg,[basep + 1*indp]
|
emit_movzx_r32_m8(&dst, dstreg, MABS(basep.value + scale*indp.value)); // movzx dstreg,[basep + scale*indp]
|
||||||
else if (sizep.value == DRCUML_SIZE_WORD)
|
else if (size == DRCUML_SIZE_WORD)
|
||||||
emit_movzx_r32_m16(&dst, dstreg, MABS(basep.value + 2*indp.value)); // movzx dstreg,[basep + 2*indp]
|
emit_movzx_r32_m16(&dst, dstreg, MABS(basep.value + scale*indp.value)); // movzx dstreg,[basep + scale*indp]
|
||||||
else if (sizep.value == DRCUML_SIZE_DWORD)
|
else if (size == DRCUML_SIZE_DWORD)
|
||||||
emit_mov_r32_m32(&dst, dstreg, MABS(basep.value + 4*indp.value)); // mov dstreg,[basep + 4*indp]
|
emit_mov_r32_m32(&dst, dstreg, MABS(basep.value + scale*indp.value)); // mov dstreg,[basep + scale*indp]
|
||||||
else if (sizep.value == DRCUML_SIZE_QWORD)
|
else if (size == DRCUML_SIZE_QWORD)
|
||||||
{
|
{
|
||||||
emit_mov_r32_m32(&dst, REG_EDX, MABS(basep.value + 8*indp.value + 4)); // mov edx,[basep + 8*indp + 4]
|
emit_mov_r32_m32(&dst, REG_EDX, MABS(basep.value + scale*indp.value + 4)); // mov edx,[basep + scale*indp + 4]
|
||||||
emit_mov_r32_m32(&dst, dstreg, MABS(basep.value + 8*indp.value)); // mov dstreg,[basep + 8*indp]
|
emit_mov_r32_m32(&dst, dstreg, MABS(basep.value + scale*indp.value)); // mov dstreg,[basep + scale*indp]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3891,16 +3893,16 @@ static x86code *op_load(drcbe_state *drcbe, x86code *dst, const drcuml_instructi
|
|||||||
{
|
{
|
||||||
int indreg = param_select_register(REG_ECX, &indp, NULL);
|
int indreg = param_select_register(REG_ECX, &indp, NULL);
|
||||||
emit_mov_r32_p32(drcbe, &dst, indreg, &indp);
|
emit_mov_r32_p32(drcbe, &dst, indreg, &indp);
|
||||||
if (sizep.value == DRCUML_SIZE_BYTE)
|
if (size == DRCUML_SIZE_BYTE)
|
||||||
emit_movzx_r32_m8(&dst, dstreg, MISD(indreg, 1, basep.value)); // movzx dstreg,[basep + 1*indp]
|
emit_movzx_r32_m8(&dst, dstreg, MISD(indreg, scale, basep.value)); // movzx dstreg,[basep + scale*indp]
|
||||||
else if (sizep.value == DRCUML_SIZE_WORD)
|
else if (size == DRCUML_SIZE_WORD)
|
||||||
emit_movzx_r32_m16(&dst, dstreg, MISD(indreg, 2, basep.value)); // movzx dstreg,[basep + 2*indp]
|
emit_movzx_r32_m16(&dst, dstreg, MISD(indreg, scale, basep.value)); // movzx dstreg,[basep + scale*indp]
|
||||||
else if (sizep.value == DRCUML_SIZE_DWORD)
|
else if (size == DRCUML_SIZE_DWORD)
|
||||||
emit_mov_r32_m32(&dst, dstreg, MISD(indreg, 4, basep.value)); // mov dstreg,[basep + 4*indp]
|
emit_mov_r32_m32(&dst, dstreg, MISD(indreg, scale, basep.value)); // mov dstreg,[basep + scale*indp]
|
||||||
else if (sizep.value == DRCUML_SIZE_QWORD)
|
else if (size == DRCUML_SIZE_QWORD)
|
||||||
{
|
{
|
||||||
emit_mov_r32_m32(&dst, REG_EDX, MISD(indreg, 8, basep.value + 4)); // mov edx,[basep + 8*indp + 4]
|
emit_mov_r32_m32(&dst, REG_EDX, MISD(indreg, scale, basep.value + 4)); // mov edx,[basep + scale*indp + 4]
|
||||||
emit_mov_r32_m32(&dst, dstreg, MISD(indreg, 8, basep.value)); // mov dstreg,[basep + 8*indp]
|
emit_mov_r32_m32(&dst, dstreg, MISD(indreg, scale, basep.value)); // mov dstreg,[basep + scale*indp]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3911,7 +3913,7 @@ static x86code *op_load(drcbe_state *drcbe, x86code *dst, const drcuml_instructi
|
|||||||
if (inst->size == 8)
|
if (inst->size == 8)
|
||||||
{
|
{
|
||||||
/* 1, 2, or 4-byte case */
|
/* 1, 2, or 4-byte case */
|
||||||
if (sizep.value != DRCUML_SIZE_QWORD)
|
if (size != DRCUML_SIZE_QWORD)
|
||||||
{
|
{
|
||||||
if (dstp.type == DRCUML_PTYPE_MEMORY)
|
if (dstp.type == DRCUML_PTYPE_MEMORY)
|
||||||
emit_mov_m32_imm(&dst, MABS(dstp.value + 4), 0); // mov [dstp+4],0
|
emit_mov_m32_imm(&dst, MABS(dstp.value + 4), 0); // mov [dstp+4],0
|
||||||
@ -3938,8 +3940,8 @@ static x86code *op_load(drcbe_state *drcbe, x86code *dst, const drcuml_instructi
|
|||||||
|
|
||||||
static x86code *op_loads(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst)
|
static x86code *op_loads(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst)
|
||||||
{
|
{
|
||||||
drcuml_parameter dstp, basep, indp, sizep;
|
drcuml_parameter dstp, basep, indp, scalesizep;
|
||||||
int dstreg;
|
int dstreg, scale, size;
|
||||||
|
|
||||||
/* validate instruction */
|
/* validate instruction */
|
||||||
assert(inst->size == 4 || inst->size == 8);
|
assert(inst->size == 4 || inst->size == 8);
|
||||||
@ -3947,7 +3949,9 @@ static x86code *op_loads(drcbe_state *drcbe, x86code *dst, const drcuml_instruct
|
|||||||
assert_no_flags(inst);
|
assert_no_flags(inst);
|
||||||
|
|
||||||
/* normalize parameters */
|
/* normalize parameters */
|
||||||
param_normalize_4(drcbe, inst, &dstp, PTYPE_MR, &basep, PTYPE_M, &indp, PTYPE_MRI, &sizep, PTYPE_I);
|
param_normalize_4(drcbe, inst, &dstp, PTYPE_MR, &basep, PTYPE_M, &indp, PTYPE_MRI, &scalesizep, PTYPE_I);
|
||||||
|
scale = 1 << (scalesizep.value / 16);
|
||||||
|
size = scalesizep.value % 16;
|
||||||
|
|
||||||
/* pick a target register for the general case */
|
/* pick a target register for the general case */
|
||||||
dstreg = param_select_register(REG_EAX, &dstp, NULL);
|
dstreg = param_select_register(REG_EAX, &dstp, NULL);
|
||||||
@ -3955,16 +3959,16 @@ static x86code *op_loads(drcbe_state *drcbe, x86code *dst, const drcuml_instruct
|
|||||||
/* immediate index */
|
/* immediate index */
|
||||||
if (indp.type == DRCUML_PTYPE_IMMEDIATE)
|
if (indp.type == DRCUML_PTYPE_IMMEDIATE)
|
||||||
{
|
{
|
||||||
if (sizep.value == DRCUML_SIZE_BYTE)
|
if (size == DRCUML_SIZE_BYTE)
|
||||||
emit_movsx_r32_m8(&dst, dstreg, MABS(basep.value + 1*indp.value)); // movsx dstreg,[basep + 1*indp]
|
emit_movsx_r32_m8(&dst, dstreg, MABS(basep.value + scale*indp.value)); // movsx dstreg,[basep + scale*indp]
|
||||||
else if (sizep.value == DRCUML_SIZE_WORD)
|
else if (size == DRCUML_SIZE_WORD)
|
||||||
emit_movsx_r32_m16(&dst, dstreg, MABS(basep.value + 2*indp.value)); // movsx dstreg,[basep + 2*indp]
|
emit_movsx_r32_m16(&dst, dstreg, MABS(basep.value + scale*indp.value)); // movsx dstreg,[basep + scale*indp]
|
||||||
else if (sizep.value == DRCUML_SIZE_DWORD)
|
else if (size == DRCUML_SIZE_DWORD)
|
||||||
emit_mov_r32_m32(&dst, dstreg, MABS(basep.value + 4*indp.value)); // mov dstreg,[basep + 4*indp]
|
emit_mov_r32_m32(&dst, dstreg, MABS(basep.value + scale*indp.value)); // mov dstreg,[basep + scale*indp]
|
||||||
else if (sizep.value == DRCUML_SIZE_QWORD)
|
else if (size == DRCUML_SIZE_QWORD)
|
||||||
{
|
{
|
||||||
emit_mov_r32_m32(&dst, REG_EDX, MABS(basep.value + 8*indp.value + 4)); // mov edx,[basep + 8*indp + 4]
|
emit_mov_r32_m32(&dst, REG_EDX, MABS(basep.value + scale*indp.value + 4)); // mov edx,[basep + scale*indp + 4]
|
||||||
emit_mov_r32_m32(&dst, dstreg, MABS(basep.value + 8*indp.value)); // mov dstreg,[basep + 8*indp]
|
emit_mov_r32_m32(&dst, dstreg, MABS(basep.value + scale*indp.value)); // mov dstreg,[basep + scale*indp]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3973,16 +3977,16 @@ static x86code *op_loads(drcbe_state *drcbe, x86code *dst, const drcuml_instruct
|
|||||||
{
|
{
|
||||||
int indreg = param_select_register(REG_ECX, &indp, NULL);
|
int indreg = param_select_register(REG_ECX, &indp, NULL);
|
||||||
emit_mov_r32_p32(drcbe, &dst, indreg, &indp);
|
emit_mov_r32_p32(drcbe, &dst, indreg, &indp);
|
||||||
if (sizep.value == DRCUML_SIZE_BYTE)
|
if (size == DRCUML_SIZE_BYTE)
|
||||||
emit_movsx_r32_m8(&dst, dstreg, MISD(indreg, 1, basep.value)); // movsx dstreg,[basep + 1*indp]
|
emit_movsx_r32_m8(&dst, dstreg, MISD(indreg, scale, basep.value)); // movsx dstreg,[basep + scale*indp]
|
||||||
else if (sizep.value == DRCUML_SIZE_WORD)
|
else if (size == DRCUML_SIZE_WORD)
|
||||||
emit_movsx_r32_m16(&dst, dstreg, MISD(indreg, 2, basep.value)); // movsx dstreg,[basep + 2*indp]
|
emit_movsx_r32_m16(&dst, dstreg, MISD(indreg, scale, basep.value)); // movsx dstreg,[basep + scale*indp]
|
||||||
else if (sizep.value == DRCUML_SIZE_DWORD)
|
else if (size == DRCUML_SIZE_DWORD)
|
||||||
emit_mov_r32_m32(&dst, dstreg, MISD(indreg, 4, basep.value)); // mov dstreg,[basep + 4*indp]
|
emit_mov_r32_m32(&dst, dstreg, MISD(indreg, scale, basep.value)); // mov dstreg,[basep + scale*indp]
|
||||||
else if (sizep.value == DRCUML_SIZE_QWORD)
|
else if (size == DRCUML_SIZE_QWORD)
|
||||||
{
|
{
|
||||||
emit_mov_r32_m32(&dst, REG_EDX, MISD(indreg, 8, basep.value + 4)); // mov edx,[basep + 8*indp + 4]
|
emit_mov_r32_m32(&dst, REG_EDX, MISD(indreg, scale, basep.value + 4)); // mov edx,[basep + scale*indp + 4]
|
||||||
emit_mov_r32_m32(&dst, dstreg, MISD(indreg, 8, basep.value)); // mov dstreg,[basep + 8*indp]
|
emit_mov_r32_m32(&dst, dstreg, MISD(indreg, scale, basep.value)); // mov dstreg,[basep + scale*indp]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4008,8 +4012,8 @@ static x86code *op_loads(drcbe_state *drcbe, x86code *dst, const drcuml_instruct
|
|||||||
|
|
||||||
static x86code *op_store(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst)
|
static x86code *op_store(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst)
|
||||||
{
|
{
|
||||||
drcuml_parameter srcp, basep, indp, sizep;
|
drcuml_parameter srcp, basep, indp, scalesizep;
|
||||||
int srcreg;
|
int srcreg, scale, size;
|
||||||
|
|
||||||
/* validate instruction */
|
/* validate instruction */
|
||||||
assert(inst->size == 4 || inst->size == 8);
|
assert(inst->size == 4 || inst->size == 8);
|
||||||
@ -4017,11 +4021,13 @@ static x86code *op_store(drcbe_state *drcbe, x86code *dst, const drcuml_instruct
|
|||||||
assert_no_flags(inst);
|
assert_no_flags(inst);
|
||||||
|
|
||||||
/* normalize parameters */
|
/* normalize parameters */
|
||||||
param_normalize_4(drcbe, inst, &basep, PTYPE_M, &indp, PTYPE_MRI, &srcp, PTYPE_MRI, &sizep, PTYPE_I);
|
param_normalize_4(drcbe, inst, &basep, PTYPE_M, &indp, PTYPE_MRI, &srcp, PTYPE_MRI, &scalesizep, PTYPE_I);
|
||||||
|
scale = 1 << (scalesizep.value / 16);
|
||||||
|
size = scalesizep.value % 16;
|
||||||
|
|
||||||
/* pick a source register for the general case */
|
/* pick a source register for the general case */
|
||||||
srcreg = param_select_register(REG_EAX, &srcp, NULL);
|
srcreg = param_select_register(REG_EAX, &srcp, NULL);
|
||||||
if (sizep.value == DRCUML_SIZE_BYTE && (srcreg & 4))
|
if (size == DRCUML_SIZE_BYTE && (srcreg & 4))
|
||||||
srcreg = REG_EAX;
|
srcreg = REG_EAX;
|
||||||
|
|
||||||
/* degenerate case: constant index */
|
/* degenerate case: constant index */
|
||||||
@ -4030,37 +4036,37 @@ static x86code *op_store(drcbe_state *drcbe, x86code *dst, const drcuml_instruct
|
|||||||
/* immediate source */
|
/* immediate source */
|
||||||
if (srcp.type == DRCUML_PTYPE_IMMEDIATE)
|
if (srcp.type == DRCUML_PTYPE_IMMEDIATE)
|
||||||
{
|
{
|
||||||
if (sizep.value == DRCUML_SIZE_BYTE)
|
if (size == DRCUML_SIZE_BYTE)
|
||||||
emit_mov_m8_imm(&dst, MABS(basep.value + 1*indp.value), srcp.value); // mov [basep + 1*indp],srcp
|
emit_mov_m8_imm(&dst, MABS(basep.value + scale*indp.value), srcp.value); // mov [basep + scale*indp],srcp
|
||||||
else if (sizep.value == DRCUML_SIZE_WORD)
|
else if (size == DRCUML_SIZE_WORD)
|
||||||
emit_mov_m16_imm(&dst, MABS(basep.value + 2*indp.value), srcp.value); // mov [basep + 2*indp],srcp
|
emit_mov_m16_imm(&dst, MABS(basep.value + scale*indp.value), srcp.value); // mov [basep + scale*indp],srcp
|
||||||
else if (sizep.value == DRCUML_SIZE_DWORD)
|
else if (size == DRCUML_SIZE_DWORD)
|
||||||
emit_mov_m32_imm(&dst, MABS(basep.value + 4*indp.value), srcp.value); // mov [basep + 4*indp],srcp
|
emit_mov_m32_imm(&dst, MABS(basep.value + scale*indp.value), srcp.value); // mov [basep + scale*indp],srcp
|
||||||
else if (sizep.value == DRCUML_SIZE_QWORD)
|
else if (size == DRCUML_SIZE_QWORD)
|
||||||
{
|
{
|
||||||
emit_mov_m32_imm(&dst, MABS(basep.value + 8*indp.value), srcp.value); // mov [basep + 8*indp],srcp
|
emit_mov_m32_imm(&dst, MABS(basep.value + scale*indp.value), srcp.value); // mov [basep + scale*indp],srcp
|
||||||
emit_mov_m32_imm(&dst, MABS(basep.value + 8*indp.value + 4), srcp.value >> 32);
|
emit_mov_m32_imm(&dst, MABS(basep.value + scale*indp.value + 4), srcp.value >> 32);
|
||||||
// mov [basep + 8*indp + 4],srcp >> 32
|
// mov [basep + scale*indp + 4],srcp >> 32
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* variable source */
|
/* variable source */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (sizep.value != DRCUML_SIZE_QWORD)
|
if (size != DRCUML_SIZE_QWORD)
|
||||||
emit_mov_r32_p32(drcbe, &dst, srcreg, &srcp); // mov srcreg,srcp
|
emit_mov_r32_p32(drcbe, &dst, srcreg, &srcp); // mov srcreg,srcp
|
||||||
else
|
else
|
||||||
emit_mov_r64_p64(drcbe, &dst, srcreg, REG_EDX, &srcp); // mov edx:srcreg,srcp
|
emit_mov_r64_p64(drcbe, &dst, srcreg, REG_EDX, &srcp); // mov edx:srcreg,srcp
|
||||||
if (sizep.value == DRCUML_SIZE_BYTE)
|
if (size == DRCUML_SIZE_BYTE)
|
||||||
emit_mov_m8_r8(&dst, MABS(basep.value + 1*indp.value), srcreg); // mov [basep + 1*indp],srcreg
|
emit_mov_m8_r8(&dst, MABS(basep.value + scale*indp.value), srcreg); // mov [basep + scale*indp],srcreg
|
||||||
else if (sizep.value == DRCUML_SIZE_WORD)
|
else if (size == DRCUML_SIZE_WORD)
|
||||||
emit_mov_m16_r16(&dst, MABS(basep.value + 2*indp.value), srcreg); // mov [basep + 2*indp],srcreg
|
emit_mov_m16_r16(&dst, MABS(basep.value + scale*indp.value), srcreg); // mov [basep + scale*indp],srcreg
|
||||||
else if (sizep.value == DRCUML_SIZE_DWORD)
|
else if (size == DRCUML_SIZE_DWORD)
|
||||||
emit_mov_m32_r32(&dst, MABS(basep.value + 4*indp.value), srcreg); // mov [basep + 4*indp],srcreg
|
emit_mov_m32_r32(&dst, MABS(basep.value + scale*indp.value), srcreg); // mov [basep + scale*indp],srcreg
|
||||||
else if (sizep.value == DRCUML_SIZE_QWORD)
|
else if (size == DRCUML_SIZE_QWORD)
|
||||||
{
|
{
|
||||||
emit_mov_m32_r32(&dst, MABS(basep.value + 8*indp.value), srcreg); // mov [basep + 8*indp],srcreg
|
emit_mov_m32_r32(&dst, MABS(basep.value + scale*indp.value), srcreg); // mov [basep + scale*indp],srcreg
|
||||||
emit_mov_m32_r32(&dst, MABS(basep.value + 8*indp.value + 4), REG_EDX); // mov [basep + 8*indp + 4],edx
|
emit_mov_m32_r32(&dst, MABS(basep.value + scale*indp.value + 4), REG_EDX); // mov [basep + scale*indp + 4],edx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4074,16 +4080,16 @@ static x86code *op_store(drcbe_state *drcbe, x86code *dst, const drcuml_instruct
|
|||||||
/* immediate source */
|
/* immediate source */
|
||||||
if (srcp.type == DRCUML_PTYPE_IMMEDIATE)
|
if (srcp.type == DRCUML_PTYPE_IMMEDIATE)
|
||||||
{
|
{
|
||||||
if (sizep.value == DRCUML_SIZE_BYTE)
|
if (size == DRCUML_SIZE_BYTE)
|
||||||
emit_mov_m8_imm(&dst, MISD(indreg, 1, basep.value), srcp.value); // mov [basep + 1*ecx],srcp
|
emit_mov_m8_imm(&dst, MISD(indreg, scale, basep.value), srcp.value); // mov [basep + 1*ecx],srcp
|
||||||
else if (sizep.value == DRCUML_SIZE_WORD)
|
else if (size == DRCUML_SIZE_WORD)
|
||||||
emit_mov_m16_imm(&dst, MISD(indreg, 2, basep.value), srcp.value); // mov [basep + 2*ecx],srcp
|
emit_mov_m16_imm(&dst, MISD(indreg, scale, basep.value), srcp.value); // mov [basep + 2*ecx],srcp
|
||||||
else if (sizep.value == DRCUML_SIZE_DWORD)
|
else if (size == DRCUML_SIZE_DWORD)
|
||||||
emit_mov_m32_imm(&dst, MISD(indreg, 4, basep.value), srcp.value); // mov [basep + 4*ecx],srcp
|
emit_mov_m32_imm(&dst, MISD(indreg, scale, basep.value), srcp.value); // mov [basep + 4*ecx],srcp
|
||||||
else if (sizep.value == DRCUML_SIZE_QWORD)
|
else if (size == DRCUML_SIZE_QWORD)
|
||||||
{
|
{
|
||||||
emit_mov_m32_imm(&dst, MISD(indreg, 8, basep.value), srcp.value); // mov [basep + 8*ecx],srcp
|
emit_mov_m32_imm(&dst, MISD(indreg, scale, basep.value), srcp.value); // mov [basep + 8*ecx],srcp
|
||||||
emit_mov_m32_imm(&dst, MISD(indreg, 8, basep.value + 4), srcp.value >> 32);
|
emit_mov_m32_imm(&dst, MISD(indreg, scale, basep.value + 4), srcp.value >> 32);
|
||||||
// mov [basep + 8*ecx + 4],srcp >> 32
|
// mov [basep + 8*ecx + 4],srcp >> 32
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4091,20 +4097,20 @@ static x86code *op_store(drcbe_state *drcbe, x86code *dst, const drcuml_instruct
|
|||||||
/* variable source */
|
/* variable source */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (sizep.value != DRCUML_SIZE_QWORD)
|
if (size != DRCUML_SIZE_QWORD)
|
||||||
emit_mov_r32_p32(drcbe, &dst, srcreg, &srcp); // mov srcreg,srcp
|
emit_mov_r32_p32(drcbe, &dst, srcreg, &srcp); // mov srcreg,srcp
|
||||||
else
|
else
|
||||||
emit_mov_r64_p64(drcbe, &dst, srcreg, REG_EDX, &srcp); // mov edx:srcreg,srcp
|
emit_mov_r64_p64(drcbe, &dst, srcreg, REG_EDX, &srcp); // mov edx:srcreg,srcp
|
||||||
if (sizep.value == DRCUML_SIZE_BYTE)
|
if (size == DRCUML_SIZE_BYTE)
|
||||||
emit_mov_m8_r8(&dst, MISD(indreg, 1, basep.value), srcreg); // mov [basep + 1*ecx],srcreg
|
emit_mov_m8_r8(&dst, MISD(indreg, scale, basep.value), srcreg); // mov [basep + 1*ecx],srcreg
|
||||||
else if (sizep.value == DRCUML_SIZE_WORD)
|
else if (size == DRCUML_SIZE_WORD)
|
||||||
emit_mov_m16_r16(&dst, MISD(indreg, 2, basep.value), srcreg); // mov [basep + 2*ecx],srcreg
|
emit_mov_m16_r16(&dst, MISD(indreg, scale, basep.value), srcreg); // mov [basep + 2*ecx],srcreg
|
||||||
else if (sizep.value == DRCUML_SIZE_DWORD)
|
else if (size == DRCUML_SIZE_DWORD)
|
||||||
emit_mov_m32_r32(&dst, MISD(indreg, 4, basep.value), srcreg); // mov [basep + 4*ecx],srcreg
|
emit_mov_m32_r32(&dst, MISD(indreg, scale, basep.value), srcreg); // mov [basep + 4*ecx],srcreg
|
||||||
else if (sizep.value == DRCUML_SIZE_QWORD)
|
else if (size == DRCUML_SIZE_QWORD)
|
||||||
{
|
{
|
||||||
emit_mov_m32_r32(&dst, MISD(indreg, 8, basep.value), srcreg); // mov [basep + 8*ecx],srcreg
|
emit_mov_m32_r32(&dst, MISD(indreg, scale, basep.value), srcreg); // mov [basep + 8*ecx],srcreg
|
||||||
emit_mov_m32_r32(&dst, MISD(indreg, 8, basep.value + 4), REG_EDX); // mov [basep + 8*ecx],edx
|
emit_mov_m32_r32(&dst, MISD(indreg, scale, basep.value + 4), REG_EDX); // mov [basep + 8*ecx],edx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,10 +100,11 @@
|
|||||||
#define PTYPES_CFUNC (PTYPES_MEM | 0x4000)
|
#define PTYPES_CFUNC (PTYPES_MEM | 0x4000)
|
||||||
#define PTYPES_HAND (PTYPES_MEM | 0x5000)
|
#define PTYPES_HAND (PTYPES_MEM | 0x5000)
|
||||||
#define PTYPES_SIZE (PTYPES_IMM | 0x8000)
|
#define PTYPES_SIZE (PTYPES_IMM | 0x8000)
|
||||||
#define PTYPES_SPACE (PTYPES_IMM | 0x9000)
|
#define PTYPES_SCSZ (PTYPES_IMM | 0x9000)
|
||||||
#define PTYPES_SPSZ (PTYPES_IMM | 0xa000)
|
#define PTYPES_SPACE (PTYPES_IMM | 0xa000)
|
||||||
#define PTYPES_FMOD (PTYPES_IMM | 0xb000)
|
#define PTYPES_SPSZ (PTYPES_IMM | 0xb000)
|
||||||
#define PTYPES_LAB (PTYPES_IMM | 0xc000)
|
#define PTYPES_FMOD (PTYPES_IMM | 0xc000)
|
||||||
|
#define PTYPES_LAB (PTYPES_IMM | 0xd000)
|
||||||
|
|
||||||
/* combinations of types */
|
/* combinations of types */
|
||||||
#define PTYPES_IRM (PTYPES_IREG | PTYPES_MEM)
|
#define PTYPES_IRM (PTYPES_IREG | PTYPES_MEM)
|
||||||
@ -227,9 +228,9 @@ static const drcuml_opcode_info opcode_info_source[] =
|
|||||||
OPINFO1(RESTORE, "restore", 4, FALSE, NONE, ALL, ALL, PINFO(IN, OP, STATE))
|
OPINFO1(RESTORE, "restore", 4, FALSE, NONE, ALL, ALL, PINFO(IN, OP, STATE))
|
||||||
|
|
||||||
/* Integer Operations */
|
/* Integer Operations */
|
||||||
OPINFO4(LOAD, "!load", 4|8, FALSE, NONE, NONE, ALL, PINFO(OUT, OP, IRM), PINFO(IN, OP, PTR), PINFO(IN, 4, IANY), PINFO(IN, OP, SIZE))
|
OPINFO4(LOAD, "!load", 4|8, FALSE, NONE, NONE, ALL, PINFO(OUT, OP, IRM), PINFO(IN, OP, PTR), PINFO(IN, 4, IANY), PINFO(IN, OP, SCSZ))
|
||||||
OPINFO4(LOADS, "!loads", 4|8, FALSE, NONE, NONE, ALL, PINFO(OUT, OP, IRM), PINFO(IN, OP, PTR), PINFO(IN, 4, IANY), PINFO(IN, OP, SIZE))
|
OPINFO4(LOADS, "!loads", 4|8, FALSE, NONE, NONE, ALL, PINFO(OUT, OP, IRM), PINFO(IN, OP, PTR), PINFO(IN, 4, IANY), PINFO(IN, OP, SCSZ))
|
||||||
OPINFO4(STORE, "!store", 4|8, FALSE, NONE, NONE, ALL, PINFO(IN, OP, PTR), PINFO(IN, 4, IANY), PINFO(IN, OP, IANY), PINFO(IN, OP, SIZE))
|
OPINFO4(STORE, "!store", 4|8, FALSE, NONE, NONE, ALL, PINFO(IN, OP, PTR), PINFO(IN, 4, IANY), PINFO(IN, OP, IANY), PINFO(IN, OP, SCSZ))
|
||||||
OPINFO3(READ, "!read", 4|8, FALSE, NONE, NONE, ALL, PINFO(OUT, OP, IRM), PINFO(IN, 4, IANY), PINFO(IN, OP, SPSZ))
|
OPINFO3(READ, "!read", 4|8, FALSE, NONE, NONE, ALL, PINFO(OUT, OP, IRM), PINFO(IN, 4, IANY), PINFO(IN, OP, SPSZ))
|
||||||
OPINFO4(READM, "!readm", 4|8, FALSE, NONE, NONE, ALL, PINFO(OUT, OP, IRM), PINFO(IN, 4, IANY), PINFO(IN, OP, IANY), PINFO(IN, OP, SPSZ))
|
OPINFO4(READM, "!readm", 4|8, FALSE, NONE, NONE, ALL, PINFO(OUT, OP, IRM), PINFO(IN, 4, IANY), PINFO(IN, OP, IANY), PINFO(IN, OP, SPSZ))
|
||||||
OPINFO3(WRITE, "!write", 4|8, FALSE, NONE, NONE, ALL, PINFO(IN, 4, IANY), PINFO(IN, OP, IANY), PINFO(IN, OP, SPSZ))
|
OPINFO3(WRITE, "!write", 4|8, FALSE, NONE, NONE, ALL, PINFO(IN, 4, IANY), PINFO(IN, OP, IANY), PINFO(IN, OP, SPSZ))
|
||||||
@ -1193,6 +1194,17 @@ void drcuml_disasm(const drcuml_instruction *inst, char *buffer, drcuml_state *d
|
|||||||
else if (typemask == PTYPES_SPSZ)
|
else if (typemask == PTYPES_SPSZ)
|
||||||
dest += sprintf(dest, "%s_%s", address_space_names[param->value / 16], sizes[param->value % 16]);
|
dest += sprintf(dest, "%s_%s", address_space_names[param->value / 16], sizes[param->value % 16]);
|
||||||
|
|
||||||
|
/* size + scale immediate */
|
||||||
|
else if (typemask == PTYPES_SCSZ)
|
||||||
|
{
|
||||||
|
int scale = param->value / 16;
|
||||||
|
int size = param->value % 16;
|
||||||
|
if (scale == size)
|
||||||
|
dest += sprintf(dest, "%s", sizes[size]);
|
||||||
|
else
|
||||||
|
dest += sprintf(dest, "%s_x%d", sizes[size], 1 << scale);
|
||||||
|
}
|
||||||
|
|
||||||
/* fmod immediate */
|
/* fmod immediate */
|
||||||
else if (typemask == PTYPES_FMOD)
|
else if (typemask == PTYPES_FMOD)
|
||||||
dest += sprintf(dest, "%s", fmods[param->value]);
|
dest += sprintf(dest, "%s", fmods[param->value]);
|
||||||
|
@ -163,6 +163,28 @@ enum
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* scale/space combinations */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
DRCUML_SCSIZE_BYTE = (0 * 16) + DRCUML_SIZE_BYTE,
|
||||||
|
DRCUML_SCSIZE_BYTE_x2 = (1 * 16) + DRCUML_SIZE_BYTE,
|
||||||
|
DRCUML_SCSIZE_BYTE_x4 = (2 * 16) + DRCUML_SIZE_BYTE,
|
||||||
|
DRCUML_SCSIZE_BYTE_x8 = (3 * 16) + DRCUML_SIZE_BYTE,
|
||||||
|
DRCUML_SCSIZE_WORD_x1 = (0 * 16) + DRCUML_SIZE_WORD,
|
||||||
|
DRCUML_SCSIZE_WORD = (1 * 16) + DRCUML_SIZE_WORD,
|
||||||
|
DRCUML_SCSIZE_WORD_x4 = (2 * 16) + DRCUML_SIZE_WORD,
|
||||||
|
DRCUML_SCSIZE_WORD_x8 = (3 * 16) + DRCUML_SIZE_WORD,
|
||||||
|
DRCUML_SCSIZE_DWORD_x1 = (0 * 16) + DRCUML_SIZE_DWORD,
|
||||||
|
DRCUML_SCSIZE_DWORD_x2 = (1 * 16) + DRCUML_SIZE_DWORD,
|
||||||
|
DRCUML_SCSIZE_DWORD = (2 * 16) + DRCUML_SIZE_DWORD,
|
||||||
|
DRCUML_SCSIZE_DWORD_x8 = (3 * 16) + DRCUML_SIZE_DWORD,
|
||||||
|
DRCUML_SCSIZE_QWORD_x1 = (0 * 16) + DRCUML_SIZE_QWORD,
|
||||||
|
DRCUML_SCSIZE_QWORD_x2 = (1 * 16) + DRCUML_SIZE_QWORD,
|
||||||
|
DRCUML_SCSIZE_QWORD_x4 = (2 * 16) + DRCUML_SIZE_QWORD,
|
||||||
|
DRCUML_SCSIZE_QWORD = (3 * 16) + DRCUML_SIZE_QWORD
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/* size/space combinations */
|
/* size/space combinations */
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
@ -106,9 +106,9 @@
|
|||||||
|
|
||||||
|
|
||||||
/* ----- 32-Bit Integer Operations ----- */
|
/* ----- 32-Bit Integer Operations ----- */
|
||||||
#define UML_LOAD(block, dst, base, index, size) do { drcuml_block_append_4(block, DRCUML_OP_LOAD, 4, IF_ALWAYS, dst, MEM(base), index, IMM(DRCUML_SIZE_##size)); } while (0)
|
#define UML_LOAD(block, dst, base, index, size) do { drcuml_block_append_4(block, DRCUML_OP_LOAD, 4, IF_ALWAYS, dst, MEM(base), index, IMM(DRCUML_SCSIZE_##size)); } while (0)
|
||||||
#define UML_LOADS(block, dst, base, index, size) do { drcuml_block_append_4(block, DRCUML_OP_LOADS, 4, IF_ALWAYS, dst, MEM(base), index, IMM(DRCUML_SIZE_##size)); } while (0)
|
#define UML_LOADS(block, dst, base, index, size) do { drcuml_block_append_4(block, DRCUML_OP_LOADS, 4, IF_ALWAYS, dst, MEM(base), index, IMM(DRCUML_SCSIZE_##size)); } while (0)
|
||||||
#define UML_STORE(block, base, index, src1, size) do { drcuml_block_append_4(block, DRCUML_OP_STORE, 4, IF_ALWAYS, MEM(base), index, src1, IMM(DRCUML_SIZE_##size)); } while (0)
|
#define UML_STORE(block, base, index, src1, size) do { drcuml_block_append_4(block, DRCUML_OP_STORE, 4, IF_ALWAYS, MEM(base), index, src1, IMM(DRCUML_SCSIZE_##size)); } while (0)
|
||||||
#define UML_READ(block, dst, src1, spsize) do { drcuml_block_append_3(block, DRCUML_OP_READ, 4, IF_ALWAYS, dst, src1, IMM(DRCUML_SPSIZE_##spsize)); } while (0)
|
#define UML_READ(block, dst, src1, spsize) do { drcuml_block_append_3(block, DRCUML_OP_READ, 4, IF_ALWAYS, dst, src1, IMM(DRCUML_SPSIZE_##spsize)); } while (0)
|
||||||
#define UML_READM(block, dst, src1, mask, spsize) do { drcuml_block_append_4(block, DRCUML_OP_READM, 4, IF_ALWAYS, dst, src1, mask, IMM(DRCUML_SPSIZE_##spsize)); } while (0)
|
#define UML_READM(block, dst, src1, mask, spsize) do { drcuml_block_append_4(block, DRCUML_OP_READM, 4, IF_ALWAYS, dst, src1, mask, IMM(DRCUML_SPSIZE_##spsize)); } while (0)
|
||||||
#define UML_WRITE(block, dst, src1, spsize) do { drcuml_block_append_3(block, DRCUML_OP_WRITE, 4, IF_ALWAYS, dst, src1, IMM(DRCUML_SPSIZE_##spsize)); } while (0)
|
#define UML_WRITE(block, dst, src1, spsize) do { drcuml_block_append_3(block, DRCUML_OP_WRITE, 4, IF_ALWAYS, dst, src1, IMM(DRCUML_SPSIZE_##spsize)); } while (0)
|
||||||
@ -145,9 +145,9 @@
|
|||||||
|
|
||||||
|
|
||||||
/* ----- 64-Bit Integer Operations ----- */
|
/* ----- 64-Bit Integer Operations ----- */
|
||||||
#define UML_DLOAD(block, dst, base, index, size) do { drcuml_block_append_4(block, DRCUML_OP_LOAD, 8, IF_ALWAYS, dst, MEM(base), index, IMM(DRCUML_SIZE_##size)); } while (0)
|
#define UML_DLOAD(block, dst, base, index, size) do { drcuml_block_append_4(block, DRCUML_OP_LOAD, 8, IF_ALWAYS, dst, MEM(base), index, IMM(DRCUML_SCSIZE_##size)); } while (0)
|
||||||
#define UML_DLOADS(block, dst, base, index, size) do { drcuml_block_append_4(block, DRCUML_OP_LOADS, 8, IF_ALWAYS, dst, MEM(base), index, IMM(DRCUML_SIZE_##size)); } while (0)
|
#define UML_DLOADS(block, dst, base, index, size) do { drcuml_block_append_4(block, DRCUML_OP_LOADS, 8, IF_ALWAYS, dst, MEM(base), index, IMM(DRCUML_SCSIZE_##size)); } while (0)
|
||||||
#define UML_DSTORE(block, base, index, src1, size) do { drcuml_block_append_4(block, DRCUML_OP_STORE, 8, IF_ALWAYS, MEM(base), index, src1, IMM(DRCUML_SIZE_##size)); } while (0)
|
#define UML_DSTORE(block, base, index, src1, size) do { drcuml_block_append_4(block, DRCUML_OP_STORE, 8, IF_ALWAYS, MEM(base), index, src1, IMM(DRCUML_SCSIZE_##size)); } while (0)
|
||||||
#define UML_DREAD(block, dst, src1, spsize) do { drcuml_block_append_3(block, DRCUML_OP_READ, 8, IF_ALWAYS, dst, src1, IMM(DRCUML_SPSIZE_##spsize)); } while (0)
|
#define UML_DREAD(block, dst, src1, spsize) do { drcuml_block_append_3(block, DRCUML_OP_READ, 8, IF_ALWAYS, dst, src1, IMM(DRCUML_SPSIZE_##spsize)); } while (0)
|
||||||
#define UML_DREADM(block, dst, src1, mask, spsize) do { drcuml_block_append_4(block, DRCUML_OP_READM, 8, IF_ALWAYS, dst, src1, mask, IMM(DRCUML_SPSIZE_##spsize)); } while (0)
|
#define UML_DREADM(block, dst, src1, mask, spsize) do { drcuml_block_append_4(block, DRCUML_OP_READM, 8, IF_ALWAYS, dst, src1, mask, IMM(DRCUML_SPSIZE_##spsize)); } while (0)
|
||||||
#define UML_DWRITE(block, dst, src1, spsize) do { drcuml_block_append_3(block, DRCUML_OP_WRITE, 8, IF_ALWAYS, dst, src1, IMM(DRCUML_SPSIZE_##spsize)); } while (0)
|
#define UML_DWRITE(block, dst, src1, spsize) do { drcuml_block_append_3(block, DRCUML_OP_WRITE, 8, IF_ALWAYS, dst, src1, IMM(DRCUML_SPSIZE_##spsize)); } while (0)
|
||||||
|
Loading…
Reference in New Issue
Block a user