VirtualBox

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


Ignore:
Timestamp:
Apr 25, 2008 8:23:14 AM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
30173
Message:

Disassembler fixes + testcase for 64 bits

Location:
trunk/src/VBox/Disassembler
Files:
5 edited

Legend:

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

    r8365 r8377  
    173173
    174174            /* Hardcoded assumption about OP_* values!! */
    175             if (opcode <= OP_LOCK)
     175            if (opcode <= OP_LAST_PREFIX)
    176176            {
    177177                pCpu->lastprefix = opcode;
     
    253253                    /* REX prefix byte */
    254254                    pCpu->prefix    |= PREFIX_REX;
    255                     pCpu->prefix_rex = PREFIX_REX_OP_2_FLAGS(opcode);
     255                    pCpu->prefix_rex = PREFIX_REX_OP_2_FLAGS(paOneByteMap[codebyte].param1);
     256                    i += sizeof(uint8_t);
     257                    prefixbytes += sizeof(uint8_t);
    256258
    257259                    if (pCpu->prefix_rex & PREFIX_REX_FLAGS_W)
    258260                        pCpu->opmode = CPUMODE_64BIT;  /* overrides size prefix byte */
    259                     break;
     261                    continue;   //fetch the next byte
    260262                }
    261263            }
  • trunk/src/VBox/Disassembler/DisasmCore.cpp

    r8365 r8377  
    278278
    279279        /* Hardcoded assumption about OP_* values!! */
    280         if (opcode <= OP_LOCK)
     280        if (opcode <= OP_LAST_PREFIX)
    281281        {
    282282            pCpu->lastprefix = opcode;
     
    350350                /* REX prefix byte */
    351351                pCpu->prefix    |= PREFIX_REX;
    352                 pCpu->prefix_rex = PREFIX_REX_OP_2_FLAGS(opcode);
     352                pCpu->prefix_rex = PREFIX_REX_OP_2_FLAGS(paOneByteMap[codebyte].param1);
     353                iByte           += sizeof(uint8_t);
    353354
    354355                if (pCpu->prefix_rex & PREFIX_REX_FLAGS_W)
    355356                    pCpu->opmode = CPUMODE_64BIT;  /* overrides size prefix byte */
    356                 break;
     357                continue;   //fetch the next byte
    357358            }
    358359        }
     
    20272028    subtype = OP_PARM_VSUBTYPE(pParam->param);
    20282029    if (fRegAddr)
    2029         subtype = OP_PARM_d;
     2030        subtype = (pCpu->opmode == CPUMODE_64BIT) ? OP_PARM_q : OP_PARM_d;
    20302031    else
    20312032    if (subtype == OP_PARM_v || subtype == OP_PARM_NONE)
  • trunk/src/VBox/Disassembler/DisasmReg.cpp

    r8364 r8377  
    188188
    189189    if (subtype == OP_PARM_v)
    190     {
    191190        subtype = (pCpu->opmode == CPUMODE_32BIT) ? OP_PARM_d : OP_PARM_w;
    192     }
    193191
    194192    switch(subtype)
     
    476474    memset(pParamVal, 0, sizeof(*pParamVal));
    477475
    478     if (pParam->flags & (USE_BASE|USE_INDEX|USE_DISPLACEMENT32|USE_DISPLACEMENT16|USE_DISPLACEMENT8))
     476    if (pParam->flags & (USE_BASE|USE_INDEX|USE_DISPLACEMENT32|USE_DISPLACEMENT16|USE_DISPLACEMENT8|USE_RIPDISPLACEMENT32))
    479477    {
    480478        // Effective address
     
    528526        if (pParam->flags & USE_DISPLACEMENT8)
    529527        {
    530             if (pCpu->mode & CPUMODE_32BIT)
     528            if (pCpu->mode == CPUMODE_32BIT)
    531529                pParamVal->val.val32 += (int32_t)pParam->disp8;
    532530            else
     
    536534        if (pParam->flags & USE_DISPLACEMENT16)
    537535        {
    538             if (pCpu->mode & CPUMODE_32BIT)
     536            if (pCpu->mode == CPUMODE_32BIT)
    539537                pParamVal->val.val32 += (int32_t)pParam->disp16;
    540538            else
     
    544542        if (pParam->flags & USE_DISPLACEMENT32)
    545543        {
    546             if (pCpu->mode & CPUMODE_32BIT)
     544            if (pCpu->mode == CPUMODE_32BIT)
    547545                pParamVal->val.val32 += pParam->disp32;
     546            else
     547                AssertFailed();
     548        }
     549        else
     550        if (pParam->flags & USE_RIPDISPLACEMENT32)
     551        {
     552            if (pCpu->mode == CPUMODE_64BIT)
     553                pParamVal->val.val64 += pParam->disp32 + pCtx->rip;
    548554            else
    549555                AssertFailed();
     
    597603            pParamVal->type = PARMTYPE_REGISTER;
    598604        }
     605        Assert(!(pParam->flags & USE_IMMEDIATE));
     606        return VINF_SUCCESS;
    599607    }
    600608
  • trunk/src/VBox/Disassembler/DisasmTest.cpp

    r8155 r8377  
    3030
    3131DECLASM(int) TestProc();
     32DECLASM(int) TestProc64();
    3233//uint8_t aCode16[] = { 0x66, 0x67, 0x89, 0x07 };
    3334
     
    6162            pInstr += cb;
    6263        }
     64
     65        printf("\n64 bits disassembly\n");
     66        pInstr = (RTUINTPTR)TestProc64;
     67
     68        for (int i=0;i<50;i++)
     69        {
     70            unsigned    cb;
     71            DISCPUSTATE cpu;
     72            char         szOutput[256];
     73
     74            memset(&cpu, 0, sizeof(cpu));
     75            cpu.mode = CPUMODE_64BIT;
     76//__debugbreak();
     77            if (VBOX_SUCCESS(DISInstr(&cpu, pInstr, 0, &cb, szOutput)))
     78                printf(szOutput);
     79            else
     80            {
     81                printf("DISOne failed!\n");
     82                return 1;
     83            }
     84            pInstr += cb;
     85        }
    6386    }
    6487    return 0;
  • trunk/src/VBox/Disassembler/DisasmTestA.asm

    r8155 r8377  
    6666ENDPROC   TestProc
    6767
     68
     69BITS 64
     70align 16
     71BEGINPROC TestProc64
     72      movzx rax,byte  [edx]
     73      movzx rax,word  [edx]
     74      lock cmpxchg [rcx], rax
     75      lock cmpxchg [rcx], ax
     76      lock cmpxchg [r15], dl
     77      movzx RSI, word [R8]
     78      in al, dx
     79      in ax, dx
     80      in eax, dx
     81      mov rbx, [rcx + rax*4 + 17]
     82      mov rbx, [rbp + rax*4 + 4]
     83      mov rbx, [rbp + rax*4]
     84      int 80h
     85      in  al, 60h
     86      in  ax, dx
     87      out 64h, eax
     88
     89      movss xmm0, xmm14
     90      movsd xmm6, xmm1
     91      ret
     92ENDPROC   TestProc64
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