VirtualBox

Changeset 67079 in vbox for trunk/src/VBox/ValidationKit


Ignore:
Timestamp:
May 25, 2017 9:43:41 AM (8 years ago)
Author:
vboxsync
Message:

bs3-cpu-generated-1: cleanups

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-generated-1-template.c

    r67078 r67079  
    14331433
    14341434
     1435/** Also encodes idxField of the register operand using idxFieldBase. */
     1436static unsigned BS3_NEAR_CODE
     1437Bs3Cfg1EncodeMemMod0DispWithRegFieldAndSizeAndDefaults(PBS3CG1STATE pThis, unsigned off, uint8_t iReg, uint8_t cbOp)
     1438{
     1439    pThis->aOperands[pThis->iRegOp].idxField = pThis->aOperands[pThis->iRegOp].idxFieldBase + iReg;
     1440    return Bs3Cfg1EncodeMemMod0Disp(pThis, false /*fAddrOverride*/, off, iReg & 7, cbOp, 0 /*cbMisalign*/,
     1441                                    pThis->aOperands[pThis->iRmOp].enmLocation);
     1442}
     1443
     1444/** Also encodes idxField of the register operand using idxFieldBase. */
     1445static unsigned BS3_NEAR_CODE
     1446Bs3Cfg1EncodeMemMod0DispWithRegFieldAndSizeAndDefaultsAddrOverride(PBS3CG1STATE pThis, unsigned off, uint8_t iReg, uint8_t cbOp)
     1447{
     1448    pThis->aOperands[pThis->iRegOp].idxField = pThis->aOperands[pThis->iRegOp].idxFieldBase + iReg;
     1449    return Bs3Cfg1EncodeMemMod0Disp(pThis, true /*fAddrOverride*/, off, iReg & 7, cbOp, 0 /*cbMisalign*/,
     1450                                    pThis->aOperands[pThis->iRmOp].enmLocation);
     1451}
     1452
     1453
    14351454/** The modrm.reg value is taken from the instruction byte at @a off.  */
    14361455static unsigned BS3_NEAR_CODE
     
    22722291    unsigned off;
    22732292    unsigned cbOp = BS3_MODE_IS_16BIT_CODE(pThis->bMode) ? 2 : 4;
    2274     if (iEncoding == 0)
    2275     {
    2276         pThis->aOperands[pThis->iRegOp].idxField = BS3CG1DST_OZ_RBP;
    2277         off = Bs3Cg1InsertOpcodes(pThis, Bs3Cg1InsertReqPrefix(pThis, 0));
    2278         off = Bs3Cfg1EncodeMemMod0Disp(pThis, false, off, X86_GREG_xBP, cbOp * 2, 0, BS3CG1OPLOC_MEM);
    2279     }
    2280     else if (iEncoding == 1 && (g_uBs3CpuDetected & BS3CPU_TYPE_MASK) >= BS3CPU_80386)
    2281     {
    2282         cbOp = cbOp == 2 ? 4 : 2;
    2283         pThis->aOperands[pThis->iRegOp].idxField = BS3CG1DST_OZ_RBP;
    2284         pThis->abCurInstr[0] = P_OZ;
    2285         off = Bs3Cg1InsertOpcodes(pThis, Bs3Cg1InsertReqPrefix(pThis, 1));
    2286         off = Bs3Cfg1EncodeMemMod0Disp(pThis, false, off, X86_GREG_xBP, cbOp * 2, 0, BS3CG1OPLOC_MEM);
    2287     }
    2288     else if (iEncoding == 2)
    2289     {
    2290         pThis->aOperands[pThis->iRegOp].idxField = BS3CG1DST_OZ_RBP;
    2291         pThis->abCurInstr[0] = P_AZ;
    2292         off = Bs3Cg1InsertOpcodes(pThis, Bs3Cg1InsertReqPrefix(pThis, 1));
    2293         off = Bs3Cfg1EncodeMemMod0Disp(pThis, true, off, X86_GREG_xBP, cbOp * 2, 0, BS3CG1OPLOC_MEM);
    2294     }
    2295     else if (iEncoding == 3)
    2296     {
    2297         cbOp = cbOp == 2 ? 4 : 2;
    2298         pThis->aOperands[pThis->iRegOp].idxField = BS3CG1DST_OZ_RBP;
    2299         pThis->abCurInstr[0] = P_AZ;
    2300         pThis->abCurInstr[1] = P_OZ;
    2301         off = Bs3Cg1InsertOpcodes(pThis, Bs3Cg1InsertReqPrefix(pThis, 2));
    2302         off = Bs3Cfg1EncodeMemMod0Disp(pThis, true, off, X86_GREG_xBP, cbOp * 2, 0, BS3CG1OPLOC_MEM);
    2303     }
    2304     else
    2305         return 0;
     2293    switch (iEncoding)
     2294    {
     2295        case 0:
     2296            off = Bs3Cg1InsertOpcodes(pThis, Bs3Cg1InsertReqPrefix(pThis, 0));
     2297            off = Bs3Cfg1EncodeMemMod0DispWithRegFieldAndSizeAndDefaults(pThis, off, X86_GREG_xBP, cbOp * 2);
     2298            break;
     2299        case 1:
     2300            if ((g_uBs3CpuDetected & BS3CPU_TYPE_MASK) < BS3CPU_80386)
     2301                return 0;
     2302            cbOp = cbOp == 2 ? 4 : 2;
     2303            pThis->abCurInstr[0] = P_OZ;
     2304            off = Bs3Cg1InsertOpcodes(pThis, Bs3Cg1InsertReqPrefix(pThis, 1));
     2305            off = Bs3Cfg1EncodeMemMod0DispWithRegFieldAndSizeAndDefaults(pThis, off, X86_GREG_xBP, cbOp * 2);
     2306            break;
     2307        case 2:
     2308            pThis->abCurInstr[0] = P_AZ;
     2309            off = Bs3Cg1InsertOpcodes(pThis, Bs3Cg1InsertReqPrefix(pThis, 1));
     2310            off = Bs3Cfg1EncodeMemMod0DispWithRegFieldAndSizeAndDefaultsAddrOverride(pThis, off, X86_GREG_xBP, cbOp * 2);
     2311            break;
     2312        case 3:
     2313            cbOp = cbOp == 2 ? 4 : 2;
     2314            pThis->abCurInstr[0] = P_AZ;
     2315            pThis->abCurInstr[1] = P_OZ;
     2316            off = Bs3Cg1InsertOpcodes(pThis, Bs3Cg1InsertReqPrefix(pThis, 2));
     2317            off = Bs3Cfg1EncodeMemMod0DispWithRegFieldAndSizeAndDefaultsAddrOverride(pThis, off, X86_GREG_xBP, cbOp * 2);
     2318            break;
     2319        default:
     2320            return 0;
     2321    }
    23062322    pThis->aOperands[pThis->iRegOp].cbOp = cbOp;
    23072323    pThis->cbOperand  = cbOp;
     
    39453961            return Bs3Cg1EncodeNext_MODRM_VqZx_WO_Nq(pThis, iEncoding);
    39463962
    3947         case BS3CG1ENC_MODRM_Gv_RO_Ma:
    3948             return Bs3Cg1EncodeNext_MODRM_Gv_RO_Ma(pThis, iEncoding);
    3949 
    39503963        case BS3CG1ENC_FIXED:
    39513964            return Bs3Cg1EncodeNext_FIXED(pThis, iEncoding);
     
    41024115
    41034116        case BS3CG1ENC_MODRM_Gv_RO_Ma:
     4117            pThis->pfnEncoder        = Bs3Cg1EncodeNext_MODRM_Gv_RO_Ma;
    41044118            pThis->iRmOp             = 1;
    41054119            pThis->iRegOp            = 0;
     
    41074121            pThis->aOperands[0].cbOp = 2;
    41084122            pThis->aOperands[1].cbOp = 4;
    4109             pThis->aOperands[0].enmLocation = BS3CG1OPLOC_CTX;
    4110             pThis->aOperands[1].enmLocation = BS3CG1OPLOC_MEM;
    4111             pThis->aOperands[1].idxField    = BS3CG1DST_INVALID;
     4123            pThis->aOperands[0].enmLocation  = BS3CG1OPLOC_CTX;
     4124            pThis->aOperands[1].enmLocation  = BS3CG1OPLOC_MEM;
     4125            pThis->aOperands[0].idxFieldBase = BS3CG1DST_OZ_RAX;
    41124126            break;
    41134127
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