VirtualBox

Changeset 37918 in vbox


Ignore:
Timestamp:
Jul 13, 2011 1:38:33 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
72825
Message:

IEM: Implemented AAD (used by the bios build by watcomc) and fixed a LES decoding bug.

Location:
trunk/src/VBox/VMM/VMMAll
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/IEMAll.cpp

    r37090 r37918  
    50055005#ifdef DEBUG
    50065006# define IEMOP_MNEMONIC(a_szMnemonic) \
    5007     Log2(("decode - %04x:%RGv %s%s\n", pIemCpu->CTX_SUFF(pCtx)->cs, pIemCpu->CTX_SUFF(pCtx)->rip, \
    5008           pIemCpu->fPrefixes & IEM_OP_PRF_LOCK ? "lock " : "", a_szMnemonic))
     5007    Log2(("decode - %04x:%RGv %s%s [#%u]\n", pIemCpu->CTX_SUFF(pCtx)->cs, pIemCpu->CTX_SUFF(pCtx)->rip, \
     5008          pIemCpu->fPrefixes & IEM_OP_PRF_LOCK ? "lock " : "", a_szMnemonic, pIemCpu->cInstructions))
    50095009# define IEMOP_MNEMONIC2(a_szMnemonic, a_szOps) \
    5010     Log2(("decode - %04x:%RGv %s%s %s\n", pIemCpu->CTX_SUFF(pCtx)->cs, pIemCpu->CTX_SUFF(pCtx)->rip, \
    5011           pIemCpu->fPrefixes & IEM_OP_PRF_LOCK ? "lock " : "", a_szMnemonic, a_szOps))
     5010    Log2(("decode - %04x:%RGv %s%s %s [#%u]\n", pIemCpu->CTX_SUFF(pCtx)->cs, pIemCpu->CTX_SUFF(pCtx)->rip, \
     5011          pIemCpu->fPrefixes & IEM_OP_PRF_LOCK ? "lock " : "", a_szMnemonic, a_szOps, pIemCpu->cInstructions))
    50125012#else
    50135013# define IEMOP_MNEMONIC(a_szMnemonic) do { } while (0)
     
    50365036    do \
    50375037    { \
    5038         if (pIemCpu->fPrefixes & IEM_OP_PRF_LOCK) \
     5038        if (pIemCpu->enmCpuMode == IEMMODE_64BIT) \
    50395039            return IEMOP_RAISE_INVALID_OPCODE(); \
    50405040    } while (0)
     
    58235823     * Execute the instruction in REM.
    58245824     */
    5825     int rc = REMR3EmulateInstruction(IEMCPU_TO_VM(pIemCpu), IEMCPU_TO_VMCPU(pIemCpu));
     5825    PVM pVM = IEMCPU_TO_VM(pIemCpu);
     5826    EMRemLock(pVM);
     5827    int rc = REMR3EmulateInstruction(pVM, IEMCPU_TO_VMCPU(pIemCpu));
    58265828    AssertRC(rc);
     5829    EMRemUnlock(pVM);
    58275830
    58285831    /*
  • trunk/src/VBox/VMM/VMMAll/IEMAllCImpl.cpp.h

    r37079 r37918  
    4444    return VINF_SUCCESS;
    4545}
     46
     47
     48#if 0
     49/**
     50 * Calculates the parity bit.
     51 *
     52 * @returns true if the bit is set, false if not.
     53 * @param   u8Result            The least significant byte of the result.
     54 */
     55static bool iemHlpCalcParityFlag(uint8_t u8Result)
     56{
     57    /*
     58     * Parity is set if the number of bits in the least significant byte of
     59     * the result is even.
     60     */
     61    uint8_t cBits;
     62    cBits  = u8Result & 1;              /* 0 */
     63    u8Result >>= 1;
     64    cBits += u8Result & 1;
     65    u8Result >>= 1;
     66    cBits += u8Result & 1;
     67    u8Result >>= 1;
     68    cBits += u8Result & 1;
     69    u8Result >>= 1;
     70    cBits += u8Result & 1;              /* 4 */
     71    u8Result >>= 1;
     72    cBits += u8Result & 1;
     73    u8Result >>= 1;
     74    cBits += u8Result & 1;
     75    u8Result >>= 1;
     76    cBits += u8Result & 1;
     77    return !(cBits & 1);
     78}
     79#endif /* not used */
     80
     81
     82/**
     83 * Updates the specified flags according to a 8-bit result.
     84 *
     85 * @param   pIemCpu             The.
     86 * @param   u8Result            The result to set the flags according to.
     87 * @param   fToUpdate           The flags to update.
     88 * @param   fUndefined          The flags that are specified as undefined.
     89 */
     90static void iemHlpUpdateArithEFlagsU8(PIEMCPU pIemCpu, uint8_t u8Result, uint32_t fToUpdate, uint32_t fUndefined)
     91{
     92    PCPUMCTX pCtx = pIemCpu->CTX_SUFF(pCtx);
     93
     94    uint32_t fEFlags = pCtx->eflags.u;
     95    iemAImpl_test_u8(&u8Result, u8Result, &fEFlags);
     96    pCtx->eflags.u &= ~(fToUpdate | fUndefined);
     97    pCtx->eflags.u |= (fToUpdate | fUndefined) & fEFlags;
     98}
     99
    46100
    47101/** @} */
     
    28782932
    28792933
     2934/**
     2935 * Implements 'AAD'.
     2936 *
     2937 * @param   enmEffOpSize    The effective operand size.
     2938 */
     2939IEM_CIMPL_DEF_1(iemCImpl_aad, uint8_t, bImm)
     2940{
     2941    PCPUMCTX pCtx = pIemCpu->CTX_SUFF(pCtx);
     2942
     2943    uint16_t const ax = pCtx->ax;
     2944    uint8_t const  al = (uint8_t)ax + (uint8_t)(ax >> 8) * bImm;
     2945    pCtx->ax = al;
     2946    iemHlpUpdateArithEFlagsU8(pIemCpu, al,
     2947                              X86_EFL_SF | X86_EFL_SF | X86_EFL_PF,
     2948                              X86_EFL_OF | X86_EFL_AF | X86_EFL_CF);
     2949
     2950    iemRegAddToRip(pIemCpu, cbInstr);
     2951    return VINF_SUCCESS;
     2952}
     2953
     2954
     2955
     2956
    28802957/*
    28812958 * Instantiate the various string operation combinations.
  • trunk/src/VBox/VMM/VMMAll/IEMAllInstructions.cpp.h

    r37084 r37918  
    32743274    if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
    32753275        return IEMOP_RAISE_INVALID_OPCODE();
    3276     uint8_t const iGReg = ((bRm >> X86_MODRM_REG_SHIFT) & bRm & X86_MODRM_REG_SMASK) | pIemCpu->uRexReg;
     3276    uint8_t const iGReg = ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pIemCpu->uRexReg;
    32773277
    32783278    switch (pIemCpu->enmEffOpSize)
     
    97589758/** Opcode 0xd4. */
    97599759FNIEMOP_STUB(iemOp_aam_Ib);
     9760
     9761
    97609762/** Opcode 0xd5. */
    9761 FNIEMOP_STUB(iemOp_aad_Ib);
     9763FNIEMOP_DEF(iemOp_aad_Ib)
     9764{
     9765    IEMOP_MNEMONIC("aad Ib");
     9766    uint8_t bImm; IEM_OPCODE_GET_NEXT_U8(&bImm);
     9767    IEMOP_HLP_NO_LOCK_PREFIX();
     9768    IEMOP_HLP_NO_64BIT();
     9769    return IEM_MC_DEFER_TO_CIMPL_1(iemCImpl_aad, bImm);
     9770}
    97629771
    97639772
Note: See TracChangeset for help on using the changeset viewer.

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