VirtualBox

Changeset 41793 in vbox for trunk/src/VBox/Disassembler


Ignore:
Timestamp:
Jun 16, 2012 11:58:34 PM (12 years ago)
Author:
vboxsync
Message:

Encourage tail optimizations and keeping things in the same registers across calls.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Disassembler/DisasmCore.cpp

    r41791 r41793  
    520520//*****************************************************************************
    521521//*****************************************************************************
    522 static size_t disParseInstruction(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis)
     522static size_t disParseInstruction(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, size_t cbExtra)
    523523{
    524524    size_t size = 0;
     
    570570    if (pOp->idxParse1 != IDX_ParseNop)
    571571    {
    572         size += pDis->pfnDisasmFnTable[pOp->idxParse1](offInstr, pOp, &pDis->Param1, pDis);
     572        size += pDis->pfnDisasmFnTable[pOp->idxParse1](offInstr, pOp, pDis, &pDis->Param1);
    573573        if (fFiltered == false) pDis->Param1.cb = DISGetParamSize(pDis, &pDis->Param1);
    574574    }
     
    576576    if (pOp->idxParse2 != IDX_ParseNop)
    577577    {
    578         size += pDis->pfnDisasmFnTable[pOp->idxParse2](offInstr+size, pOp, &pDis->Param2, pDis);
     578        size += pDis->pfnDisasmFnTable[pOp->idxParse2](offInstr+size, pOp, pDis, &pDis->Param2);
    579579        if (fFiltered == false) pDis->Param2.cb = DISGetParamSize(pDis, &pDis->Param2);
    580580    }
     
    582582    if (pOp->idxParse3 != IDX_ParseNop)
    583583    {
    584         size += pDis->pfnDisasmFnTable[pOp->idxParse3](offInstr+size, pOp, &pDis->Param3, pDis);
     584        size += pDis->pfnDisasmFnTable[pOp->idxParse3](offInstr+size, pOp, pDis, &pDis->Param3);
    585585        if (fFiltered == false) pDis->Param3.cb = DISGetParamSize(pDis, &pDis->Param3);
    586586    }
    587587    // else simple one byte instruction
    588588
    589     return size;
     589    return size + cbExtra;
    590590}
    591591//*****************************************************************************
    592592/* Floating point opcode parsing */
    593593//*****************************************************************************
    594 static size_t ParseEscFP(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     594static size_t ParseEscFP(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    595595{
    596596    size_t      size = 0;
     
    642642
    643643    if (fpop->idxParse1 != IDX_ParseNop)
    644         size += pDis->pfnDisasmFnTable[fpop->idxParse1](offInstr+size, fpop, pParam, pDis);
     644        size += pDis->pfnDisasmFnTable[fpop->idxParse1](offInstr+size, fpop, pDis, pParam);
    645645
    646646    if (fpop->idxParse2 != IDX_ParseNop)
    647         size += pDis->pfnDisasmFnTable[fpop->idxParse2](offInstr+size, fpop, pParam, pDis);
     647        size += pDis->pfnDisasmFnTable[fpop->idxParse2](offInstr+size, fpop, pDis, pParam);
    648648
    649649    return size;
     
    660660 *
    661661 ********************************************************************************************************************************/
    662 static void UseSIB(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     662static void UseSIB(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    663663{
    664664    NOREF(offInstr); NOREF(pOp);
     
    709709
    710710
    711 static size_t ParseSIB(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     711static size_t ParseSIB(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    712712{
    713713    unsigned size = sizeof(uint8_t);
     
    741741
    742742
    743 static size_t ParseSIB_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     743static size_t ParseSIB_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    744744{
    745745    unsigned size = sizeof(uint8_t);
     
    886886
    887887
    888 static size_t UseModRM(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     888static size_t UseModRM(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    889889{
    890890    unsigned vtype = OP_PARM_VTYPE(pParam->fParam);
     
    969969            if (rm == 4)
    970970            {   /* SIB byte follows ModRM */
    971                 UseSIB(offInstr, pOp, pParam, pDis);
     971                UseSIB(offInstr, pOp, pDis, pParam);
    972972            }
    973973            else
     
    995995        case 1: //effective address + 8 bits displacement
    996996            if (rm == 4) {//SIB byte follows ModRM
    997                 UseSIB(offInstr, pOp, pParam, pDis);
     997                UseSIB(offInstr, pOp, pDis, pParam);
    998998            }
    999999            else
     
    10081008        case 2: //effective address + 32 bits displacement
    10091009            if (rm == 4) {//SIB byte follows ModRM
    1010                 UseSIB(offInstr, pOp, pParam, pDis);
     1010                UseSIB(offInstr, pOp, pDis, pParam);
    10111011            }
    10121012            else
     
    10631063// Query the size of the ModRM parameters and fetch the immediate data (if any)
    10641064//*****************************************************************************
    1065 static size_t QueryModRM(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis, size_t *pSibInc)
     1065static size_t QueryModRM(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam, size_t *pSibInc)
    10661066{
    10671067    size_t sibinc;
     
    10851085        if (mod != 3 && rm == 4)
    10861086        {   /* SIB byte follows ModRM */
    1087             *pSibInc = ParseSIB(offInstr, pOp, pParam, pDis);
     1087            *pSibInc = ParseSIB(offInstr, pOp, pDis, pParam);
    10881088            offInstr += *pSibInc;
    10891089            size += *pSibInc;
     
    11461146// Query the size of the ModRM parameters and fetch the immediate data (if any)
    11471147//*****************************************************************************
    1148 static size_t QueryModRM_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis, size_t *pSibInc)
     1148static size_t QueryModRM_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam, size_t *pSibInc)
    11491149{
    11501150    size_t sibinc;
     
    11671167        if (mod != 3 && rm == 4)
    11681168        {   /* SIB byte follows ModRM */
    1169             *pSibInc = ParseSIB_SizeOnly(offInstr, pOp, pParam, pDis);
     1169            *pSibInc = ParseSIB_SizeOnly(offInstr, pOp, pDis, pParam);
    11701170            offInstr += *pSibInc;
    11711171            size += *pSibInc;
     
    12211221//*****************************************************************************
    12221222//*****************************************************************************
    1223 static size_t ParseIllegal(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     1223static size_t ParseIllegal(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    12241224{
    12251225    NOREF(offInstr); NOREF(pOp); NOREF(pParam); NOREF(pDis);
     
    12291229//*****************************************************************************
    12301230//*****************************************************************************
    1231 static size_t ParseModRM(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     1231static size_t ParseModRM(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    12321232{
    12331233    size_t size = sizeof(uint8_t);   //ModRM byte
     
    12671267        }
    12681268    }
    1269     size += QueryModRM(offInstr, pOp, pParam, pDis, &sibinc);
     1269    size += QueryModRM(offInstr, pOp, pDis, pParam, &sibinc);
    12701270    offInstr += sibinc;
    12711271
    1272     UseModRM(offInstr, pOp, pParam, pDis);
     1272    UseModRM(offInstr, pOp, pDis, pParam);
    12731273    return size;
    12741274}
    12751275//*****************************************************************************
    12761276//*****************************************************************************
    1277 static size_t ParseModRM_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     1277static size_t ParseModRM_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    12781278{
    12791279    size_t size = sizeof(uint8_t);   //ModRM byte
     
    13141314    }
    13151315
    1316     size += QueryModRM_SizeOnly(offInstr, pOp, pParam, pDis, &sibinc);
     1316    size += QueryModRM_SizeOnly(offInstr, pOp, pDis, pParam, &sibinc);
    13171317    offInstr += sibinc;
    13181318
     
    13221322//*****************************************************************************
    13231323//*****************************************************************************
    1324 static size_t ParseModFence(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     1324static size_t ParseModFence(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    13251325{
    13261326    ////AssertMsgFailed(("??\n"));
     
    13311331//*****************************************************************************
    13321332//*****************************************************************************
    1333 static size_t ParseImmByte(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     1333static size_t ParseImmByte(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    13341334{
    13351335    NOREF(pOp);
     
    13411341//*****************************************************************************
    13421342//*****************************************************************************
    1343 static size_t ParseImmByte_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     1343static size_t ParseImmByte_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    13441344{
    13451345    NOREF(offInstr); NOREF(pOp); NOREF(pParam); NOREF(pDis);
     
    13481348//*****************************************************************************
    13491349//*****************************************************************************
    1350 static size_t ParseImmByteSX(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     1350static size_t ParseImmByteSX(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    13511351{
    13521352    NOREF(pOp);
     
    13741374//*****************************************************************************
    13751375//*****************************************************************************
    1376 static size_t ParseImmByteSX_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     1376static size_t ParseImmByteSX_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    13771377{
    13781378    NOREF(offInstr); NOREF(pOp); NOREF(pParam); NOREF(pDis);
     
    13811381//*****************************************************************************
    13821382//*****************************************************************************
    1383 static size_t ParseImmUshort(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     1383static size_t ParseImmUshort(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    13841384{
    13851385    NOREF(pOp);
     
    13911391//*****************************************************************************
    13921392//*****************************************************************************
    1393 static size_t ParseImmUshort_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     1393static size_t ParseImmUshort_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    13941394{
    13951395    NOREF(offInstr); NOREF(pOp); NOREF(pParam); NOREF(pDis);
     
    13981398//*****************************************************************************
    13991399//*****************************************************************************
    1400 static size_t ParseImmUlong(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     1400static size_t ParseImmUlong(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    14011401{
    14021402    NOREF(pOp);
     
    14081408//*****************************************************************************
    14091409//*****************************************************************************
    1410 static size_t ParseImmUlong_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     1410static size_t ParseImmUlong_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    14111411{
    14121412    NOREF(offInstr); NOREF(pOp); NOREF(pParam); NOREF(pDis);
     
    14151415//*****************************************************************************
    14161416//*****************************************************************************
    1417 static size_t ParseImmQword(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     1417static size_t ParseImmQword(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    14181418{
    14191419    NOREF(pOp);
     
    14251425//*****************************************************************************
    14261426//*****************************************************************************
    1427 static size_t ParseImmQword_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     1427static size_t ParseImmQword_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    14281428{
    14291429    NOREF(offInstr); NOREF(pOp); NOREF(pParam); NOREF(pDis);
     
    14321432//*****************************************************************************
    14331433//*****************************************************************************
    1434 static size_t ParseImmV(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     1434static size_t ParseImmV(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    14351435{
    14361436    NOREF(pOp);
     
    14581458//*****************************************************************************
    14591459//*****************************************************************************
    1460 static size_t ParseImmV_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     1460static size_t ParseImmV_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    14611461{
    14621462    NOREF(offInstr); NOREF(pOp); NOREF(pParam);
     
    14691469//*****************************************************************************
    14701470//*****************************************************************************
    1471 static size_t ParseImmZ(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     1471static size_t ParseImmZ(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    14721472{
    14731473    NOREF(pOp);
     
    14981498//*****************************************************************************
    14991499//*****************************************************************************
    1500 static size_t ParseImmZ_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     1500static size_t ParseImmZ_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    15011501{
    15021502    NOREF(offInstr); NOREF(pOp); NOREF(pParam);
     
    15101510// Relative displacement for branches (rel. to next instruction)
    15111511//*****************************************************************************
    1512 static size_t ParseImmBRel(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     1512static size_t ParseImmBRel(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    15131513{
    15141514    NOREF(pOp);
     
    15211521// Relative displacement for branches (rel. to next instruction)
    15221522//*****************************************************************************
    1523 static size_t ParseImmBRel_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     1523static size_t ParseImmBRel_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    15241524{
    15251525    NOREF(offInstr); NOREF(pOp); NOREF(pParam); NOREF(pDis);
     
    15291529// Relative displacement for branches (rel. to next instruction)
    15301530//*****************************************************************************
    1531 static size_t ParseImmVRel(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     1531static size_t ParseImmVRel(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    15321532{
    15331533    NOREF(pOp);
     
    15571557// Relative displacement for branches (rel. to next instruction)
    15581558//*****************************************************************************
    1559 static size_t ParseImmVRel_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     1559static size_t ParseImmVRel_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    15601560{
    15611561    NOREF(offInstr); NOREF(pOp); NOREF(pParam);
     
    15671567//*****************************************************************************
    15681568//*****************************************************************************
    1569 static size_t ParseImmAddr(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     1569static size_t ParseImmAddr(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    15701570{
    15711571    if (pDis->uAddrMode == DISCPUMODE_32BIT)
     
    16291629//*****************************************************************************
    16301630//*****************************************************************************
    1631 static size_t ParseImmAddr_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     1631static size_t ParseImmAddr_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    16321632{
    16331633    NOREF(offInstr); NOREF(pOp);
     
    16621662//*****************************************************************************
    16631663//*****************************************************************************
    1664 static size_t ParseImmAddrF(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     1664static size_t ParseImmAddrF(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    16651665{
    16661666    // immediate far pointers - only 16:16 or 16:32; determined by operand, *not* address size!
     
    16851685//*****************************************************************************
    16861686//*****************************************************************************
    1687 static size_t ParseImmAddrF_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     1687static size_t ParseImmAddrF_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    16881688{
    16891689    NOREF(offInstr); NOREF(pOp);
     
    17041704//*****************************************************************************
    17051705//*****************************************************************************
    1706 static size_t ParseFixedReg(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     1706static size_t ParseFixedReg(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    17071707{
    17081708    NOREF(offInstr);
     
    18051805//*****************************************************************************
    18061806//*****************************************************************************
    1807 static size_t ParseXv(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     1807static size_t ParseXv(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    18081808{
    18091809    NOREF(offInstr);
     
    18301830//*****************************************************************************
    18311831//*****************************************************************************
    1832 static size_t ParseXb(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     1832static size_t ParseXb(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    18331833{
    18341834    NOREF(offInstr); NOREF(pOp);
     
    18551855//*****************************************************************************
    18561856//*****************************************************************************
    1857 static size_t ParseYv(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     1857static size_t ParseYv(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    18581858{
    18591859    NOREF(offInstr);
     
    18801880//*****************************************************************************
    18811881//*****************************************************************************
    1882 static size_t ParseYb(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     1882static size_t ParseYb(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    18831883{
    18841884    NOREF(offInstr); NOREF(pOp);
     
    19051905//*****************************************************************************
    19061906//*****************************************************************************
    1907 static size_t ParseTwoByteEsc(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     1907static size_t ParseTwoByteEsc(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    19081908{
    19091909    PCDISOPCODE   pOpcode;
     
    19591959    }
    19601960
    1961     size += disParseInstruction(offInstr+size, pOpcode, pDis);
    1962     return size;
    1963 }
    1964 //*****************************************************************************
    1965 //*****************************************************************************
    1966 static size_t ParseThreeByteEsc4(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     1961    return disParseInstruction(offInstr+size, pOpcode, pDis, size);
     1962}
     1963//*****************************************************************************
     1964//*****************************************************************************
     1965static size_t ParseThreeByteEsc4(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    19671966{
    19681967    PCDISOPCODE   pOpcode;
     
    20202019    }
    20212020
    2022     size += disParseInstruction(offInstr+size, pOpcode, pDis);
    2023     return size;
    2024 }
    2025 //*****************************************************************************
    2026 //*****************************************************************************
    2027 static size_t ParseThreeByteEsc5(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     2021    return disParseInstruction(offInstr+size, pOpcode, pDis, size);
     2022}
     2023//*****************************************************************************
     2024//*****************************************************************************
     2025static size_t ParseThreeByteEsc5(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    20282026{
    20292027    PCDISOPCODE   pOpcode;
     
    20552053        pOpcode = &g_InvalidOpcode[0];
    20562054
    2057     size += disParseInstruction(offInstr+size, pOpcode, pDis);
    2058     return size;
    2059 }
    2060 //*****************************************************************************
    2061 //*****************************************************************************
    2062 static size_t ParseNopPause(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     2055    return disParseInstruction(offInstr+size, pOpcode, pDis, size);
     2056}
     2057//*****************************************************************************
     2058//*****************************************************************************
     2059static size_t ParseNopPause(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    20632060{
    20642061    size_t size = 0;
     
    20732070        pOp = &g_aMapX86_NopPause[0]; /* NOP */
    20742071
    2075     size += disParseInstruction(offInstr, pOp, pDis);
    2076     return size;
    2077 }
    2078 //*****************************************************************************
    2079 //*****************************************************************************
    2080 static size_t ParseImmGrpl(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     2072    return disParseInstruction(offInstr, pOp, pDis, size);
     2073}
     2074//*****************************************************************************
     2075//*****************************************************************************
     2076static size_t ParseImmGrpl(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    20812077{
    20822078    int idx = (pDis->bOpCode - 0x80) * 8;
     
    20922088        size = sizeof(uint8_t); //ModRM byte
    20932089
    2094     size += disParseInstruction(offInstr, pOp, pDis);
    2095 
    2096     return size;
    2097 }
    2098 //*****************************************************************************
    2099 //*****************************************************************************
    2100 static size_t ParseShiftGrp2(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     2090    return disParseInstruction(offInstr, pOp, pDis, size);
     2091}
     2092//*****************************************************************************
     2093//*****************************************************************************
     2094static size_t ParseShiftGrp2(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    21012095{
    21022096    int idx;
     
    21322126        size = sizeof(uint8_t); //ModRM byte
    21332127
    2134     size += disParseInstruction(offInstr, pOp, pDis);
    2135 
    2136     return size;
    2137 }
    2138 //*****************************************************************************
    2139 //*****************************************************************************
    2140 static size_t ParseGrp3(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     2128    return disParseInstruction(offInstr, pOp, pDis, size);
     2129}
     2130//*****************************************************************************
     2131//*****************************************************************************
     2132static size_t ParseGrp3(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    21412133{
    21422134    int idx = (pDis->bOpCode - 0xF6) * 8;
     
    21532145        size = sizeof(uint8_t); //ModRM byte
    21542146
    2155     size += disParseInstruction(offInstr, pOp, pDis);
    2156 
    2157     return size;
    2158 }
    2159 //*****************************************************************************
    2160 //*****************************************************************************
    2161 static size_t ParseGrp4(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     2147    return disParseInstruction(offInstr, pOp, pDis, size);
     2148}
     2149//*****************************************************************************
     2150//*****************************************************************************
     2151static size_t ParseGrp4(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    21622152{
    21632153    size_t size = 0;
     
    21732163        size = sizeof(uint8_t); //ModRM byte
    21742164
    2175     size += disParseInstruction(offInstr, pOp, pDis);
    2176 
    2177     return size;
    2178 }
    2179 //*****************************************************************************
    2180 //*****************************************************************************
    2181 static size_t ParseGrp5(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     2165    return disParseInstruction(offInstr, pOp, pDis, size);
     2166}
     2167//*****************************************************************************
     2168//*****************************************************************************
     2169static size_t ParseGrp5(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    21822170{
    21832171    size_t size = 0;
     
    21932181        size = sizeof(uint8_t); //ModRM byte
    21942182
    2195     size += disParseInstruction(offInstr, pOp, pDis);
    2196 
    2197     return size;
     2183    return disParseInstruction(offInstr, pOp, pDis, size);
    21982184}
    21992185//*****************************************************************************
     
    22032189//
    22042190//*****************************************************************************
    2205 static size_t Parse3DNow(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     2191static size_t Parse3DNow(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    22062192{
    22072193    size_t size = 0;
     
    22172203    pDis->ModRM.Bits.Reg = MODRM_REG(ModRM);
    22182204
    2219     size_t modrmsize = QueryModRM(offInstr+sizeof(uint8_t), pOp, pParam, pDis, NULL);
     2205    size_t modrmsize = QueryModRM(offInstr+sizeof(uint8_t), pOp, pDis, pParam, NULL);
    22202206
    22212207    uint8_t opcode = disReadByte(pDis, offInstr+sizeof(uint8_t)+modrmsize);
     
    22322218    }
    22332219
    2234     size += disParseInstruction(offInstr, pOp, pDis);
    22352220    size += sizeof(uint8_t);   //imm8_opcode uint8_t
    2236 
    2237     return size;
    2238 }
    2239 //*****************************************************************************
    2240 //*****************************************************************************
    2241 static size_t ParseGrp6(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     2221    return disParseInstruction(offInstr, pOp, pDis, size);
     2222}
     2223//*****************************************************************************
     2224//*****************************************************************************
     2225static size_t ParseGrp6(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    22422226{
    22432227    size_t size = 0;
     
    22532237        size = sizeof(uint8_t); //ModRM byte
    22542238
    2255     size += disParseInstruction(offInstr, pOp, pDis);
    2256 
    2257     return size;
    2258 }
    2259 //*****************************************************************************
    2260 //*****************************************************************************
    2261 static size_t ParseGrp7(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     2239    return disParseInstruction(offInstr, pOp, pDis, size);
     2240}
     2241//*****************************************************************************
     2242//*****************************************************************************
     2243static size_t ParseGrp7(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    22622244{
    22632245    size_t size = 0;
     
    22812263        size = sizeof(uint8_t); //ModRM byte
    22822264
    2283     size += disParseInstruction(offInstr, pOp, pDis);
    2284 
    2285     return size;
    2286 }
    2287 //*****************************************************************************
    2288 //*****************************************************************************
    2289 static size_t ParseGrp8(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     2265    return disParseInstruction(offInstr, pOp, pDis, size);
     2266}
     2267//*****************************************************************************
     2268//*****************************************************************************
     2269static size_t ParseGrp8(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    22902270{
    22912271    size_t size = 0;
     
    23012281        size = sizeof(uint8_t); //ModRM byte
    23022282
    2303     size += disParseInstruction(offInstr, pOp, pDis);
    2304 
    2305     return size;
    2306 }
    2307 //*****************************************************************************
    2308 //*****************************************************************************
    2309 static size_t ParseGrp9(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     2283    return disParseInstruction(offInstr, pOp, pDis, size);
     2284}
     2285//*****************************************************************************
     2286//*****************************************************************************
     2287static size_t ParseGrp9(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    23102288{
    23112289    size_t size = 0;
     
    23212299        size = sizeof(uint8_t); //ModRM byte
    23222300
    2323     size += disParseInstruction(offInstr, pOp, pDis);
    2324 
    2325     return size;
    2326 }
    2327 //*****************************************************************************
    2328 //*****************************************************************************
    2329 static size_t ParseGrp10(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     2301    return disParseInstruction(offInstr, pOp, pDis, size);
     2302}
     2303//*****************************************************************************
     2304//*****************************************************************************
     2305static size_t ParseGrp10(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    23302306{
    23312307    size_t size = 0;
     
    23412317        size = sizeof(uint8_t); //ModRM byte
    23422318
    2343     size += disParseInstruction(offInstr, pOp, pDis);
    2344 
    2345     return size;
    2346 }
    2347 //*****************************************************************************
    2348 //*****************************************************************************
    2349 static size_t ParseGrp12(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     2319    return disParseInstruction(offInstr, pOp, pDis, size);
     2320}
     2321//*****************************************************************************
     2322//*****************************************************************************
     2323static size_t ParseGrp12(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    23502324{
    23512325    size_t size = 0;
     
    23642338        size = sizeof(uint8_t); //ModRM byte
    23652339
    2366     size += disParseInstruction(offInstr, pOp, pDis);
    2367     return size;
    2368 }
    2369 //*****************************************************************************
    2370 //*****************************************************************************
    2371 static size_t ParseGrp13(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
     2340    return disParseInstruction(offInstr, pOp, pDis, size);
     2341}
     2342//*****************************************************************************
     2343//*****************************************************************************
     2344static size_t ParseGrp13(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    23722345{
    23732346    size_t size = 0;
     
    23852358        size = sizeof(uint8_t); //ModRM byte
    23862359
    2387     size += disParseInstruction(offInstr, pOp, pDis);
    2388 
    2389     return size;
    2390 }
    2391 //*****************************************************************************
    2392 //*****************************************************************************
    2393 static size_t ParseGrp14(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
    2394 {
    2395     size_t size = 0;
     2360    return disParseInstruction(offInstr, pOp, pDis, size);
     2361}
     2362//*****************************************************************************
     2363//*****************************************************************************
     2364static size_t ParseGrp14(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
     2365{
    23962366    NOREF(pParam);
    23972367
    2398     unsigned modrm = disReadByte(pDis, offInstr);
    2399     unsigned reg   = MODRM_REG(modrm);
     2368    uint8_t modrm = disReadByte(pDis, offInstr);
     2369    uint8_t reg   = MODRM_REG(modrm);
    24002370    if (pDis->fPrefix & DISPREFIX_OPSIZE)
    24012371        reg += 8;   //2nd table
     
    24042374
    24052375    //little hack to make sure the ModRM byte is included in the returned size
     2376    size_t size = 0;
    24062377    if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM)
    24072378        size = sizeof(uint8_t); //ModRM byte
    24082379
    2409     size += disParseInstruction(offInstr, pOp, pDis);
    2410 
    2411     return size;
    2412 }
    2413 //*****************************************************************************
    2414 //*****************************************************************************
    2415 static size_t ParseGrp15(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
    2416 {
    2417     size_t size = 0;
     2380    return disParseInstruction(offInstr, pOp, pDis, size);
     2381}
     2382//*****************************************************************************
     2383//*****************************************************************************
     2384static size_t ParseGrp15(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
     2385{
    24182386    NOREF(pParam);
    24192387
    2420     unsigned modrm = disReadByte(pDis, offInstr);
    2421     unsigned mod   = MODRM_MOD(modrm);
    2422     unsigned reg   = MODRM_REG(modrm);
    2423     unsigned rm    = MODRM_RM(modrm);
     2388    uint8_t modrm = disReadByte(pDis, offInstr);
     2389    uint8_t mod   = MODRM_MOD(modrm);
     2390    uint8_t reg   = MODRM_REG(modrm);
     2391    uint8_t rm    = MODRM_RM(modrm);
    24242392
    24252393    if (mod == 3 && rm == 0)
     
    24292397
    24302398    //little hack to make sure the ModRM byte is included in the returned size
     2399    size_t size = 0;
    24312400    if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM)
    24322401        size = sizeof(uint8_t); //ModRM byte
    24332402
    2434     size += disParseInstruction(offInstr, pOp, pDis);
    2435     return size;
    2436 }
    2437 //*****************************************************************************
    2438 //*****************************************************************************
    2439 static size_t ParseGrp16(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISSTATE pDis)
    2440 {
     2403    return disParseInstruction(offInstr, pOp, pDis, size);
     2404}
     2405//*****************************************************************************
     2406//*****************************************************************************
     2407static size_t ParseGrp16(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
     2408{
     2409    NOREF(pParam);
     2410
     2411    uint8_t modrm = disReadByte(pDis, offInstr);
     2412    pOp = &g_aMapX86_Group16[MODRM_REG(modrm)];
     2413
     2414    //little hack to make sure the ModRM byte is included in the returned size
    24412415    size_t size = 0;
    2442     NOREF(pParam);
    2443 
    2444     unsigned modrm = disReadByte(pDis, offInstr);
    2445     unsigned reg   = MODRM_REG(modrm);
    2446 
    2447     pOp = &g_aMapX86_Group16[reg];
    2448 
    2449     //little hack to make sure the ModRM byte is included in the returned size
    24502416    if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM)
    24512417        size = sizeof(uint8_t); //ModRM byte
    24522418
    2453     size += disParseInstruction(offInstr, pOp, pDis);
    2454     return size;
     2419    return disParseInstruction(offInstr, pOp, pDis, size);
    24552420}
    24562421
     
    25642529            if (opcode != OP_REX)
    25652530            {
    2566                 /** Last prefix byte (for SSE2 extension tables); don't include the REX prefix */
     2531                /* Last prefix byte (for SSE2 extension tables); don't include the REX prefix */
    25672532                pDis->bLastPrefix = opcode;
    25682533                pDis->fPrefix &= ~DISPREFIX_REX;
     
    26362601        pDis->bOpCode  = codebyte;
    26372602        pDis->cbPrefix = (uint8_t)offInstr - 1;
    2638         offInstr += disParseInstruction(offInstr, &paOneByteMap[pDis->bOpCode], pDis);
     2603        offInstr = disParseInstruction(offInstr, &paOneByteMap[pDis->bOpCode], pDis, offInstr);
    26392604        break;
    26402605    }
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette