VirtualBox

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


Ignore:
Timestamp:
Jun 12, 2012 1:15:51 PM (12 years ago)
Author:
vboxsync
Message:

DIS,DIS-users: Drop the operand/parameter formatting during instruction parsing. The desired formatter can do this afterwards if desired. Should save time + size. (DISCPUSTATE is now 256 bytes here on 64-bit linux, was ~406 yesterday.)

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

Legend:

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

    r41658 r41668  
     1/* $Id$ */
    12/** @file
    2  *
    3  * VBox disassembler:
    4  * Main
     3 * VBox disassembler - Disassemble and optionally format.
    54 */
    65
    76/*
    8  * Copyright (C) 2006-2007 Oracle Corporation
     7 * Copyright (C) 2006-2012 Oracle Corporation
    98 *
    109 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2120*   Header Files                                                               *
    2221*******************************************************************************/
    23 #ifdef USING_VISUAL_STUDIO
    24 # include <stdafx.h>
    25 #endif
     22#define LOG_GROUP LOG_GROUP_DIS
    2623#include <VBox/dis.h>
    2724#include <VBox/disopcode.h>
     
    4037 *                          set correctly.
    4138 * @param   uInstrAddr      Pointer to the structure to disassemble.
    42  * @param   pcbSize         Where to store the size of the instruction.
    43  *                          NULL is allowed.
     39 * @param   pcbInstr        Where to store the size of the instruction. NULL is
     40 *                          allowed.
    4441 * @param   pszOutput       Storage for disassembled instruction
    4542 *
    4643 * @todo    Define output callback.
    4744 */
    48 DISDECL(int) DISInstr(RTUINTPTR uInstrAddr, DISCPUMODE enmCpuMode, PDISCPUSTATE pCpu, uint32_t *pcbSize, char *pszOutput)
     45DISDECL(int) DISInstr(RTUINTPTR uInstrAddr, DISCPUMODE enmCpuMode, PDISCPUSTATE pCpu, uint32_t *pcbInstr, char *pszOutput)
    4946{
    5047    return DISInstrEx(uInstrAddr, 0, enmCpuMode, NULL, NULL, OPTYPE_ALL,
    51                       pCpu, pcbSize, pszOutput);
     48                      pCpu, pcbInstr, pszOutput);
    5249}
    5350
     
    6158 * @param   offRealAddr     Offset to add to instruction address to get the real
    6259 *                          virtual address.
    63  * @param   pcbSize         Where to store the size of the instruction.
    64  *                          NULL is allowed.
     60 * @param   pcbInstr        Where to store the size of the instruction. NULL is
     61 *                          allowed.
    6562 * @param   pszOutput       Storage for disassembled instruction
    6663 *
     
    6865 */
    6966DISDECL(int) DISInstrWithOff(PDISCPUSTATE pCpu, RTUINTPTR uInstrAddr, RTUINTPTR offRealAddr,
    70                              unsigned *pcbSize, char *pszOutput)
     67                             uint32_t *pcbInstr, char *pszOutput)
    7168{
    7269    return DISInstrEx(uInstrAddr, offRealAddr, pCpu->mode, pCpu->pfnReadBytes, pCpu->apvUserData[0], OPTYPE_ALL,
    73                       pCpu, pcbSize, pszOutput);
     70                      pCpu, pcbInstr, pszOutput);
    7471}
    7572
     
    8481 *                          DISCPUSTATE::apvUserData[0]).
    8582 * @param   pCpu            Where to return the disassembled instruction.
    86  * @param   pcbSize         Where to store the size of the instruction.
    87  *                          NULL is allowed.
     83 * @param   pcbInstr        Where to store the size of the instruction. NULL is
     84 *                          allowed.
    8885 * @param   pszOutput       Storage for disassembled instruction
    8986 *
     
    9188 */
    9289DISDECL(int) DISInstrWithReader(RTUINTPTR uInstrAddr, DISCPUMODE enmCpuMode, PFNDISREADBYTES pfnReadBytes, void *pvUser,
    93                                 PDISCPUSTATE pCpu, uint32_t *pcbSize, char *pszOutput)
     90                                PDISCPUSTATE pCpu, uint32_t *pcbInstr, char *pszOutput)
    9491
    9592{
    9693    return DISInstrEx(uInstrAddr, 0, enmCpuMode, pfnReadBytes, pvUser, OPTYPE_ALL,
    97                       pCpu, pcbSize, pszOutput);
     94                      pCpu, pcbInstr, pszOutput);
    9895}
    9996
     
    106103 * @param   uInstrAddr      Pointer to the structure to disassemble.
    107104 * @param   u32EipOffset    Offset to add to instruction address to get the real virtual address
    108  * @param   pcbSize         Where to store the size of the instruction.
    109  *                          NULL is allowed.
     105 * @param   pcbInstr        Where to store the size of the instruction. NULL is
     106 *                          allowed.
    110107 * @param   pszOutput       Storage for disassembled instruction
    111  * @param   uFilter         Instruction type filter
     108 * @param   uFilter         Instruction type filter.
    112109 *
    113110 * @todo    Define output callback.
     
    115112DISDECL(int) DISInstrEx(RTUINTPTR uInstrAddr, RTUINTPTR offRealAddr, DISCPUMODE enmCpuMode,
    116113                        PFNDISREADBYTES pfnReadBytes, void *pvUser, uint32_t uFilter,
    117                         PDISCPUSTATE pCpu, uint32_t *pcbSize, char *pszOutput)
     114                        PDISCPUSTATE pCpu, uint32_t *pcbInstr, char *pszOutput)
    118115{
    119     const OPCODE   *paOneByteMap;
     116    int rc = DISCoreOneExEx(uInstrAddr, enmCpuMode, uFilter, pfnReadBytes, pvUser, pCpu, pcbInstr);
     117    if (RT_SUCCESS(rc) && pszOutput)
     118    {
     119        size_t      cbOutput = 128;
     120        size_t      cch;
     121#if 0
     122        RTUINTPTR   uRealAddr = uInstrAddr + offRealAddr;
     123        if (pCpu->mode == CPUMODE_64BIT || uRealAddr > UINT32_MAX)
     124            cch = RTStrPrintf(pszOutput, cbOutput, "%016RTptr:  ", uRealAddr);
     125        else
     126            cch = RTStrPrintf(pszOutput, cbOutput, "%08RX32:  ", (uint32_t)uRealAddr);
     127        rc = DISFormatYasmEx(pCpu, pszOutput + cch, cbOutput - cch,
     128                             DIS_FMT_FLAGS_BYTES_LEFT | DIS_FMT_FLAGS_BYTES_BRACKETS | DIS_FMT_FLAGS_BYTES_SPACED
     129                             | DIS_FMT_FLAGS_RELATIVE_BRANCH,
     130                             NULL /*pfnGetSymbol*/, NULL /*pvUser*/);
     131#else
     132        pCpu->uInstrAddr += offRealAddr;
     133        rc = DISFormatYasmEx(pCpu, pszOutput, cbOutput,
     134                             DIS_FMT_FLAGS_BYTES_LEFT | DIS_FMT_FLAGS_BYTES_BRACKETS | DIS_FMT_FLAGS_BYTES_SPACED
     135                             | DIS_FMT_FLAGS_RELATIVE_BRANCH | DIS_FMT_FLAGS_ADDR_LEFT,
     136                             NULL /*pfnGetSymbol*/, NULL /*pvUser*/);
     137        pCpu->uInstrAddr = uInstrAddr;
     138#endif
     139        cch = strlen(pszOutput);
     140        if (cch < cbOutput)
     141        {
     142            pszOutput[cch++] = '\n';
     143            pszOutput[cch] = '\0';
     144        }
     145    }
     146    return rc;
     147}
    120148
    121     /*
    122      * Initialize the CPU state.
    123      * Note! The RT_BZERO make ASSUMPTIONS about the placement of apvUserData.
    124      */
    125     RT_BZERO(pCpu, RT_OFFSETOF(DISCPUSTATE, apvUserData));
    126 
    127     pCpu->mode              = enmCpuMode;
    128     if (enmCpuMode == CPUMODE_64BIT)
    129     {
    130         paOneByteMap        = g_aOneByteMapX64;
    131         pCpu->addrmode      = CPUMODE_64BIT;
    132         pCpu->opmode        = CPUMODE_32BIT;
    133     }
    134     else
    135     {
    136         paOneByteMap        = g_aOneByteMapX86;
    137         pCpu->addrmode      = enmCpuMode;
    138         pCpu->opmode        = enmCpuMode;
    139     }
    140     pCpu->prefix            = PREFIX_NONE;
    141     pCpu->enmPrefixSeg      = DIS_SELREG_DS;
    142     pCpu->uInstrAddr        = uInstrAddr;
    143     pCpu->opaddr            = uInstrAddr + offRealAddr;
    144     pCpu->pfnDisasmFnTable  = pfnFullDisasm;
    145     pCpu->uFilter           = uFilter;
    146     pCpu->rc                = VINF_SUCCESS;
    147     pCpu->pfnReadBytes      = pfnReadBytes ? pfnReadBytes : disReadBytesDefault;
    148     pCpu->apvUserData[0]    = pvUser;
    149 
    150     /*
    151      * Parse the instruction byte by byte.
    152      */
    153     unsigned i        = 0;
    154     unsigned cbPrefix = 0; /** @todo this isn't really needed, is it? Seems to be a bit too many variables tracking the same stuff here. cbInc, i, cbPrefix, idx... */
    155     for (;;)
    156     {
    157         uint8_t codebyte = DISReadByte(pCpu, uInstrAddr+i);
    158         uint8_t opcode   = paOneByteMap[codebyte].opcode;
    159 
    160         /* Hardcoded assumption about OP_* values!! */
    161         if (opcode <= OP_LAST_PREFIX)
    162         {
    163             /* The REX prefix must precede the opcode byte(s). Any other placement is ignored. */
    164             if (opcode != OP_REX)
    165             {
    166                 pCpu->lastprefix = opcode;
    167                 pCpu->prefix &= ~PREFIX_REX;
    168             }
    169 
    170             switch (opcode)
    171             {
    172             case OP_INVALID:
    173                 if (pcbSize)
    174                     *pcbSize = pCpu->opsize;
    175                 return pCpu->rc = VERR_DIS_INVALID_OPCODE;
    176 
    177             // segment override prefix byte
    178             case OP_SEG:
    179                 pCpu->enmPrefixSeg = (DIS_SELREG)(paOneByteMap[codebyte].param1 - OP_PARM_REG_SEG_START);
    180                 /* Segment prefixes for CS, DS, ES and SS are ignored in long mode. */
    181                 if (   pCpu->mode != CPUMODE_64BIT
    182                     || pCpu->enmPrefixSeg >= DIS_SELREG_FS)
    183                     pCpu->prefix |= PREFIX_SEG;
    184                 i += sizeof(uint8_t);
    185                 cbPrefix++;
    186                 continue;   //fetch the next byte
    187 
    188             // lock prefix byte
    189             case OP_LOCK:
    190                 pCpu->prefix |= PREFIX_LOCK;
    191                 i += sizeof(uint8_t);
    192                 cbPrefix++;
    193                 continue;   //fetch the next byte
    194 
    195             // address size override prefix byte
    196             case OP_ADDRSIZE:
    197                 pCpu->prefix |= PREFIX_ADDRSIZE;
    198                 if (pCpu->mode == CPUMODE_16BIT)
    199                     pCpu->addrmode = CPUMODE_32BIT;
    200                 else
    201                 if (pCpu->mode == CPUMODE_32BIT)
    202                     pCpu->addrmode = CPUMODE_16BIT;
    203                 else
    204                     pCpu->addrmode = CPUMODE_32BIT;     /* 64 bits */
    205 
    206                 i += sizeof(uint8_t);
    207                 cbPrefix++;
    208                 continue;   //fetch the next byte
    209 
    210             // operand size override prefix byte
    211             case OP_OPSIZE:
    212                 pCpu->prefix |= PREFIX_OPSIZE;
    213                 if (pCpu->mode == CPUMODE_16BIT)
    214                     pCpu->opmode = CPUMODE_32BIT;
    215                 else
    216                     pCpu->opmode = CPUMODE_16BIT;  /* for 32 and 64 bits mode (there is no 32 bits operand size override prefix) */
    217 
    218                 i += sizeof(uint8_t);
    219                 cbPrefix++;
    220                 continue;   //fetch the next byte
    221 
    222             // rep and repne are not really prefixes, but we'll treat them as such
    223             case OP_REPE:
    224                 pCpu->prefix |= PREFIX_REP;
    225                 i += sizeof(uint8_t);
    226                 cbPrefix += sizeof(uint8_t);
    227                 continue;   //fetch the next byte
    228 
    229             case OP_REPNE:
    230                 pCpu->prefix |= PREFIX_REPNE;
    231                 i += sizeof(uint8_t);
    232                 cbPrefix += sizeof(uint8_t);
    233                 continue;   //fetch the next byte
    234 
    235             case OP_REX:
    236                 Assert(pCpu->mode == CPUMODE_64BIT);
    237                 /* REX prefix byte */
    238                 pCpu->prefix    |= PREFIX_REX;
    239                 pCpu->prefix_rex = PREFIX_REX_OP_2_FLAGS(paOneByteMap[codebyte].param1);
    240                 i += sizeof(uint8_t);
    241                 cbPrefix += sizeof(uint8_t);
    242 
    243                 if (pCpu->prefix_rex & PREFIX_REX_FLAGS_W)
    244                     pCpu->opmode = CPUMODE_64BIT;  /* overrides size prefix byte */
    245                 continue;   //fetch the next byte
    246             }
    247         }
    248 
    249         pCpu->cbPrefix = i; Assert(cbPrefix == i);
    250         pCpu->opcode   = codebyte;
    251 
    252         unsigned idx = i;
    253         i += sizeof(uint8_t); //first opcode byte
    254 
    255         unsigned cbInc = ParseInstruction(uInstrAddr + i, &paOneByteMap[pCpu->opcode], pCpu);
    256 
    257         AssertMsg(pCpu->opsize == cbPrefix + cbInc + sizeof(uint8_t),
    258                   ("%u %u\n", pCpu->opsize, cbPrefix + cbInc + sizeof(uint8_t)));
    259         pCpu->opsize = cbPrefix + cbInc + sizeof(uint8_t);
    260 
    261         if (pszOutput)
    262             disasmSprintf(pszOutput, uInstrAddr+i-1-cbPrefix, pCpu, &pCpu->param1, &pCpu->param2, &pCpu->param3);
    263 
    264         i += cbInc;
    265         cbPrefix = 0;
    266         break;
    267     }
    268 
    269     if (pcbSize)
    270         *pcbSize = i;
    271 
    272     if (pCpu->prefix & PREFIX_LOCK)
    273         disValidateLockSequence(pCpu);
    274 
    275     return pCpu->rc;
    276 }
    277 //*****************************************************************************
    278 //*****************************************************************************
    279 static size_t DbgBytesToString(PDISCPUSTATE pCpu, char *pszOutput, size_t offStart)
    280 {
    281     unsigned off = offStart;
    282 
    283     while (off < 40)
    284         pszOutput[off++] = ' ';
    285     pszOutput[off++] = ' ';
    286     pszOutput[off++] = '[';
    287 
    288     for (unsigned i = 0; i < pCpu->opsize; i++)
    289         off += RTStrPrintf(&pszOutput[off], 64, "%02X ", pCpu->abInstr[i]);
    290 
    291     pszOutput[off - 1] = ']';  // replaces space
    292     return off - offStart;
    293 }
    294 //*****************************************************************************
    295 //*****************************************************************************
    296 void disasmSprintf(char *pszOutput, RTUINTPTR uInstrAddr, PDISCPUSTATE pCpu,
    297                    OP_PARAMETER *pParam1, OP_PARAMETER *pParam2, OP_PARAMETER *pParam3)
    298 {
    299     const char *pszFormat = pCpu->pszOpcode;
    300     int   param = 1;
    301 
    302 
    303     size_t off = RTStrPrintf(pszOutput, 64, "%08RTptr:  ", pCpu->opaddr);
    304     if (pCpu->prefix & PREFIX_LOCK)
    305         off += RTStrPrintf(&pszOutput[off], 64, "lock ");
    306     if (pCpu->prefix & PREFIX_REP)
    307         off += RTStrPrintf(&pszOutput[off], 64, "rep(e) ");
    308     else if(pCpu->prefix & PREFIX_REPNE)
    309         off += RTStrPrintf(&pszOutput[off], 64, "repne ");
    310 
    311     if (!strcmp("Invalid Opcode", pszFormat))
    312     {
    313         if (pCpu->opsize >= 2)
    314             off += RTStrPrintf(&pszOutput[off], 64, "Invalid Opcode [%02X][%02X]", pCpu->abInstr[0], pCpu->abInstr[1]);
    315         else
    316             off += RTStrPrintf(&pszOutput[off], 64, "Invalid Opcode [%02X]", pCpu->abInstr[0]);
    317     }
    318     else
    319         while (*pszFormat)
    320         {
    321             switch (*pszFormat)
    322             {
    323             case '%':
    324                 switch (pszFormat[1])
    325                 {
    326                 case 'J': //Relative jump offset
    327                 {
    328                     int32_t disp;
    329 
    330                     AssertMsg(param == 1, ("Invalid branch parameter nr"));
    331                     if (pParam1->flags & USE_IMMEDIATE8_REL)
    332                         disp = (int32_t)(char)pParam1->parval;
    333                     else if (pParam1->flags & USE_IMMEDIATE16_REL)
    334                         disp = (int32_t)(uint16_t)pParam1->parval;
    335                     else if (pParam1->flags & USE_IMMEDIATE32_REL)
    336                         disp = (int32_t)pParam1->parval;
    337                     else if(pParam1->flags & USE_IMMEDIATE64_REL)
    338                         /** @todo: is this correct? */
    339                         disp = (int32_t)pParam1->parval;
    340                     else
    341                     {
    342                         AssertMsgFailed(("Oops!\n"));
    343                         return;
    344                     }
    345                     uint32_t addr = (uint32_t)(pCpu->opaddr + pCpu->opsize) + disp;
    346                     off += RTStrPrintf(&pszOutput[off], 64, "[%08X]", addr);
    347                 }
    348 
    349                     //no break;
    350 
    351                 case 'A': //direct address
    352                 case 'C': //control register
    353                 case 'D': //debug register
    354                 case 'E': //ModRM specifies parameter
    355                 case 'F': //Eflags register
    356                 case 'G': //ModRM selects general register
    357                 case 'I': //Immediate data
    358                 case 'M': //ModRM may only refer to memory
    359                 case 'O': //No ModRM byte
    360                 case 'P': //ModRM byte selects MMX register
    361                 case 'Q': //ModRM byte selects MMX register or memory address
    362                 case 'R': //ModRM byte may only refer to a general register
    363                 case 'S': //ModRM byte selects a segment register
    364                 case 'T': //ModRM byte selects a test register
    365                 case 'V': //ModRM byte selects an XMM/SSE register
    366                 case 'W': //ModRM byte selects an XMM/SSE register or a memory address
    367                 case 'X': //DS:SI
    368                 case 'Y': //ES:DI
    369                     switch(param)
    370                     {
    371                     case 1:
    372                         off += RTStrPrintf(&pszOutput[off], 64, pParam1->szParam);
    373                         break;
    374                     case 2:
    375                         off += RTStrPrintf(&pszOutput[off], 64, pParam2->szParam);
    376                         break;
    377                     case 3:
    378                         off += RTStrPrintf(&pszOutput[off], 64, pParam3->szParam);
    379                         break;
    380                     }
    381                     break;
    382 
    383                 case 'e': //register based on operand size (e.g. %eAX)
    384                     if(pCpu->opmode == CPUMODE_32BIT)
    385                         off += RTStrPrintf(&pszOutput[off], 64, "E");
    386                     if(pCpu->opmode == CPUMODE_64BIT)
    387                         off += RTStrPrintf(&pszOutput[off], 64, "R");
    388 
    389                     off += RTStrPrintf(&pszOutput[off], 64, "%c%c", pszFormat[2], pszFormat[3]);
    390                     break;
    391 
    392                 default:
    393                     AssertMsgFailed(("Oops!\n"));
    394                     break;
    395                 }
    396 
    397                 //Go to the next parameter in the format string
    398                 while (*pszFormat && *pszFormat != ',')
    399                     pszFormat++;
    400                 if (*pszFormat == ',')
    401                     pszFormat--;
    402 
    403                 break;
    404 
    405             case ',':
    406                 param++;
    407                 //no break
    408 
    409             default:
    410                 off += RTStrPrintf(&pszOutput[off], 64, "%c", *pszFormat);
    411                 break;
    412             }
    413 
    414             if (*pszFormat)
    415                 pszFormat++;
    416         }
    417 
    418     off += DbgBytesToString(pCpu, pszOutput, off);
    419     off += RTStrPrintf(&pszOutput[off], 64, "\n");
    420 }
    421 //*****************************************************************************
    422 //*****************************************************************************
  • trunk/src/VBox/Disassembler/DisasmCore.cpp

    r41663 r41668  
    2121*******************************************************************************/
    2222#define LOG_GROUP LOG_GROUP_DIS
    23 #ifdef USING_VISUAL_STUDIO
    24 # include <stdafx.h>
    25 #endif
    26 
    2723#include <VBox/dis.h>
    2824#include <VBox/disopcode.h>
     
    3531#include "DisasmTables.h"
    3632
    37 #if !defined(DIS_CORE_ONLY) && defined(LOG_ENABLED)
    38 # include <stdlib.h>
    39 # include <stdio.h>
    40 #endif
    41 
    4233
    4334/*******************************************************************************
    4435*   Internal Functions                                                         *
    4536*******************************************************************************/
    46 static int disCoreParseInstr(PDISCPUSTATE pCpu, RTUINTPTR uInstrAddr, const OPCODE *paOneByteMap,
    47                              unsigned *pcbInstruction);
    48 #if !defined(DIS_CORE_ONLY) && defined(LOG_ENABLED)
    49 static void disasmAddString(char *psz, const char *pszString);
    50 static void disasmAddStringF(char *psz, const char *pszFormat, ...);
    51 static void disasmAddChar(char *psz, char ch);
    52 # define disasmAddStringF1(psz, pszFmt, a1)         disasmAddStringF(psz, pszFmt, a1)
    53 # define disasmAddStringF2(psz, pszFmt, a1, a2)     disasmAddStringF(psz, pszFmt, a1, a2)
    54 # define disasmAddStringF3(psz, pszFmt, a1, a2, a3) disasmAddStringF(psz, pszFmt, a1, a2, a3)
    55 #else
    56 # define disasmAddString(psz, pszString)            do {} while (0)
    57 # define disasmAddStringF1(psz, pszFmt, a1)         do {} while (0)
    58 # define disasmAddStringF2(psz, pszFmt, a1, a2)     do {} while (0)
    59 # define disasmAddStringF3(psz, pszFmt, a1, a2, a3) do {} while (0)
    60 # define disasmAddChar(psz, ch)                     do {} while (0)
    61 #endif
    62 
    63 static unsigned QueryModRM(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu, unsigned *pSibInc = NULL);
    64 static unsigned QueryModRM_SizeOnly(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu, unsigned *pSibInc = NULL);
    65 static void     UseSIB(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    66 static unsigned ParseSIB_SizeOnly(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
     37static int disCoreParseInstr(PDISCPUSTATE pCpu, RTUINTPTR uInstrAddr, const OPCODE *paOneByteMap, uint32_t *pcbInstr);
     38
     39static unsigned QueryModRM(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu, unsigned *pSibInc = NULL);
     40static unsigned QueryModRM_SizeOnly(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu, unsigned *pSibInc = NULL);
     41static void     UseSIB(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
     42static unsigned ParseSIB_SizeOnly(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
     43
     44static void disasmModRMReg(PDISCPUSTATE pCpu, PCOPCODE pOp, unsigned idx, POP_PARAMETER pParam, int fRegAddr);
     45static void disasmModRMReg16(PDISCPUSTATE pCpu, PCOPCODE pOp, unsigned idx, POP_PARAMETER pParam);
     46static void disasmModRMSReg(PDISCPUSTATE pCpu, PCOPCODE pOp, unsigned idx, POP_PARAMETER pParam);
     47
     48
     49/** @name Parsers
     50 * @{ */
     51static FNDISPARSE ParseIllegal;
     52static FNDISPARSE ParseModRM;
     53static FNDISPARSE ParseModRM_SizeOnly;
     54static FNDISPARSE UseModRM;
     55static FNDISPARSE ParseImmByte;
     56static FNDISPARSE ParseImmByte_SizeOnly;
     57static FNDISPARSE ParseImmByteSX;
     58static FNDISPARSE ParseImmByteSX_SizeOnly;
     59static FNDISPARSE ParseImmBRel;
     60static FNDISPARSE ParseImmBRel_SizeOnly;
     61static FNDISPARSE ParseImmUshort;
     62static FNDISPARSE ParseImmUshort_SizeOnly;
     63static FNDISPARSE ParseImmV;
     64static FNDISPARSE ParseImmV_SizeOnly;
     65static FNDISPARSE ParseImmVRel;
     66static FNDISPARSE ParseImmVRel_SizeOnly;
     67static FNDISPARSE ParseImmZ;
     68static FNDISPARSE ParseImmZ_SizeOnly;
     69
     70static FNDISPARSE ParseImmAddr;
     71static FNDISPARSE ParseImmAddr_SizeOnly;
     72static FNDISPARSE ParseImmAddrF;
     73static FNDISPARSE ParseImmAddrF_SizeOnly;
     74static FNDISPARSE ParseFixedReg;
     75static FNDISPARSE ParseImmUlong;
     76static FNDISPARSE ParseImmUlong_SizeOnly;
     77static FNDISPARSE ParseImmQword;
     78static FNDISPARSE ParseImmQword_SizeOnly;
     79
     80static FNDISPARSE ParseTwoByteEsc;
     81static FNDISPARSE ParseThreeByteEsc4;
     82static FNDISPARSE ParseThreeByteEsc5;
     83static FNDISPARSE ParseImmGrpl;
     84static FNDISPARSE ParseShiftGrp2;
     85static FNDISPARSE ParseGrp3;
     86static FNDISPARSE ParseGrp4;
     87static FNDISPARSE ParseGrp5;
     88static FNDISPARSE Parse3DNow;
     89static FNDISPARSE ParseGrp6;
     90static FNDISPARSE ParseGrp7;
     91static FNDISPARSE ParseGrp8;
     92static FNDISPARSE ParseGrp9;
     93static FNDISPARSE ParseGrp10;
     94static FNDISPARSE ParseGrp12;
     95static FNDISPARSE ParseGrp13;
     96static FNDISPARSE ParseGrp14;
     97static FNDISPARSE ParseGrp15;
     98static FNDISPARSE ParseGrp16;
     99static FNDISPARSE ParseModFence;
     100static FNDISPARSE ParseNopPause;
     101
     102static FNDISPARSE ParseYv;
     103static FNDISPARSE ParseYb;
     104static FNDISPARSE ParseXv;
     105static FNDISPARSE ParseXb;
     106
     107/* Floating point parsing */
     108static FNDISPARSE ParseEscFP;
     109/** @}  */
     110
    67111
    68112/*******************************************************************************
    69113*   Global Variables                                                           *
    70114*******************************************************************************/
    71 
    72 PFNDISPARSE  pfnFullDisasm[IDX_ParseMax] =
     115/** Parser opcode table for full disassembly. */
     116PFNDISPARSE  g_apfnFullDisasm[IDX_ParseMax] =
    73117{
    74118    ParseIllegal,
     
    115159};
    116160
    117 PFNDISPARSE  pfnCalcSize[IDX_ParseMax] =
     161/** Parser opcode table for only calculating instruction size. */
     162PFNDISPARSE  g_apfnCalcSize[IDX_ParseMax] =
    118163{
    119164    ParseIllegal,
     
    163208/**
    164209 * Parses one guest instruction.
    165  * The result is found in pCpu and pcbInstruction.
     210 *
     211 * The result is found in pCpu and pcbInstr.
     212 *
     213 * @returns VBox status code.
     214 * @param   uInstrAddr      Address of the instruction to decode.  This is a
     215 *                          real address in the current context that can be
     216 *                          derefferenced.  (Consider DISCoreOneWithReader if
     217 *                          this isn't the case.)
     218 * @param   enmCpuMode      The CPU mode. CPUMODE_32BIT, CPUMODE_16BIT, or CPUMODE_64BIT.
     219 * @param   pfnReadBytes    Callback for reading instruction bytes.
     220 * @param   pvUser          User argument for the instruction reader. (Ends up in apvUserData[0].)
     221 * @param   pCpu            Pointer to cpu structure. Will be initialized.
     222 * @param   pcbInstr        Where to store the size of the instruction.
     223 *                          NULL is allowed.  This is also stored in
     224 *                          PDISCPUSTATE::opsize.
     225 */
     226DISDECL(int) DISCoreOne(RTUINTPTR uInstrAddr, DISCPUMODE enmCpuMode, PDISCPUSTATE pCpu, uint32_t *pcbInstr)
     227{
     228    return DISCoreOneExEx(uInstrAddr, enmCpuMode, OPTYPE_ALL, NULL /*pfnReadBytes*/, NULL /*pvUser*/, pCpu, pcbInstr);
     229}
     230
     231
     232/**
     233 * Parses one guest instruction.
     234 *
     235 * The result is found in pCpu and pcbInstr.
    166236 *
    167237 * @returns VBox status code.
     
    172242 * @param   pvUser          User argument for the instruction reader. (Ends up in apvUserData[0].)
    173243 * @param   pCpu            Pointer to cpu structure. Will be initialized.
    174  * @param   pcbInstruction  Where to store the size of the instruction.
    175  *                          NULL is allowed.
     244 * @param   pcbInstr        Where to store the size of the instruction.
     245 *                          NULL is allowed.  This is also stored in
     246 *                          PDISCPUSTATE::opsize.
    176247 */
    177 DISDECL(int) DISCoreOneEx(RTUINTPTR uInstrAddr, DISCPUMODE enmCpuMode, PFNDISREADBYTES pfnReadBytes, void *pvUser,
    178                           PDISCPUSTATE pCpu, unsigned *pcbInstruction)
     248DISDECL(int) DISCoreOneWithReader(RTUINTPTR uInstrAddr, DISCPUMODE enmCpuMode, PFNDISREADBYTES pfnReadBytes, void *pvUser,
     249                                  PDISCPUSTATE pCpu, uint32_t *pcbInstr)
     250{
     251    return DISCoreOneExEx(uInstrAddr, enmCpuMode, OPTYPE_ALL, pfnReadBytes, pvUser, pCpu, pcbInstr);
     252}
     253
     254
     255/**
     256 * Parses one guest instruction.
     257 *
     258 * The result is found in pCpu and pcbInstr.
     259 *
     260 * @returns VBox status code.
     261 * @param   uInstrAddr      Address of the instruction to decode. What this means
     262 *                          is left to the pfnReadBytes function.
     263 * @param   enmCpuMode      The CPU mode. CPUMODE_32BIT, CPUMODE_16BIT, or CPUMODE_64BIT.
     264 * @param   pfnReadBytes    Callback for reading instruction bytes.
     265 * @param   uFilter         Instruction type filter.
     266 * @param   pvUser          User argument for the instruction reader. (Ends up in apvUserData[0].)
     267 * @param   pCpu            Pointer to cpu structure. Will be initialized.
     268 * @param   pcbInstr        Where to store the size of the instruction.
     269 *                          NULL is allowed.  This is also stored in
     270 *                          PDISCPUSTATE::opsize.
     271 */
     272DISDECL(int) DISCoreOneExEx(RTUINTPTR uInstrAddr, DISCPUMODE enmCpuMode, uint32_t uFilter,
     273                            PFNDISREADBYTES pfnReadBytes, void *pvUser,
     274                            PDISCPUSTATE pCpu, uint32_t *pcbInstr)
    179275{
    180276    const OPCODE *paOneByteMap;
     
    202298    pCpu->enmPrefixSeg      = DIS_SELREG_DS;
    203299    pCpu->uInstrAddr        = uInstrAddr;
    204     pCpu->pfnDisasmFnTable  = pfnFullDisasm;
    205     pCpu->uFilter           = OPTYPE_ALL;
     300    pCpu->pfnDisasmFnTable  = g_apfnFullDisasm;
     301    pCpu->uFilter           = uFilter;
    206302    pCpu->rc                = VINF_SUCCESS;
    207303    pCpu->pfnReadBytes      = pfnReadBytes ? pfnReadBytes : disReadBytesDefault;
    208304    pCpu->apvUserData[0]    = pvUser;
    209305
    210     return disCoreParseInstr(pCpu, uInstrAddr, paOneByteMap, pcbInstruction);
    211 }
     306    return disCoreParseInstr(pCpu, uInstrAddr, paOneByteMap, pcbInstr);
     307}
     308
    212309
    213310/**
     
    218315 * @param   paOneByteMap    The one byte opcode map to use.
    219316 * @param   uInstrAddr      Instruction address.
    220  * @param   pcbInstruction  Where to store the instruction size. Can be NULL.
     317 * @param   pcbInstr        Where to store the instruction size. Can be NULL.
    221318 */
    222 static int disCoreParseInstr(PDISCPUSTATE pCpu, RTUINTPTR uInstrAddr, const OPCODE *paOneByteMap, unsigned *pcbInstruction)
     319static int disCoreParseInstr(PDISCPUSTATE pCpu, RTUINTPTR uInstrAddr, const OPCODE *paOneByteMap, uint32_t *pcbInstr)
    223320{
    224321    /*
     
    246343            {
    247344            case OP_INVALID:
    248                 if (pcbInstruction)
    249                     *pcbInstruction = iByte + 1;
     345                if (pcbInstr)
     346                    *pcbInstr = iByte + 1;
    250347                return pCpu->rc = VERR_DIS_INVALID_OPCODE;
    251348
     
    320417        iByte += sizeof(uint8_t); //first opcode byte
    321418
    322         pCpu->opaddr = uInstrAddr;
    323419        pCpu->opcode = codebyte;
    324420
     
    330426    AssertMsg(pCpu->opsize == iByte || RT_FAILURE_NP(pCpu->rc), ("%u %u\n", pCpu->opsize, iByte));
    331427    pCpu->opsize = iByte;
    332     if (pcbInstruction)
    333         *pcbInstruction = iByte;
     428    if (pcbInstr)
     429        *pcbInstr = iByte;
    334430
    335431    if (pCpu->prefix & PREFIX_LOCK)
     
    340436//*****************************************************************************
    341437//*****************************************************************************
    342 unsigned ParseInstruction(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, PDISCPUSTATE pCpu)
     438unsigned ParseInstruction(RTUINTPTR uCodePtr, PCOPCODE pOp, PDISCPUSTATE pCpu)
    343439{
    344440    int  size = 0;
    345441    bool fFiltered = false;
    346442
    347     Assert(lpszCodeBlock && pOp && pCpu);
     443    Assert(uCodePtr && pOp && pCpu);
    348444
    349445    // Store the opcode format string for disasmPrintf
     
    360456    {
    361457        fFiltered = true;
    362         pCpu->pfnDisasmFnTable = pfnCalcSize;
     458        pCpu->pfnDisasmFnTable = g_apfnCalcSize;
    363459    }
    364460    else
    365461    {
    366462        /* Not filtered out -> full disassembly */
    367         pCpu->pfnDisasmFnTable = pfnFullDisasm;
     463        pCpu->pfnDisasmFnTable = g_apfnFullDisasm;
    368464    }
    369465
     
    393489    if (pOp->idxParse1 != IDX_ParseNop)
    394490    {
    395         size += pCpu->pfnDisasmFnTable[pOp->idxParse1](lpszCodeBlock, pOp, &pCpu->param1, pCpu);
     491        size += pCpu->pfnDisasmFnTable[pOp->idxParse1](uCodePtr, pOp, &pCpu->param1, pCpu);
    396492        if (fFiltered == false) pCpu->param1.cb = DISGetParamSize(pCpu, &pCpu->param1);
    397493    }
     
    399495    if (pOp->idxParse2 != IDX_ParseNop)
    400496    {
    401         size += pCpu->pfnDisasmFnTable[pOp->idxParse2](lpszCodeBlock+size, pOp, &pCpu->param2, pCpu);
     497        size += pCpu->pfnDisasmFnTable[pOp->idxParse2](uCodePtr+size, pOp, &pCpu->param2, pCpu);
    402498        if (fFiltered == false) pCpu->param2.cb = DISGetParamSize(pCpu, &pCpu->param2);
    403499    }
     
    405501    if (pOp->idxParse3 != IDX_ParseNop)
    406502    {
    407         size += pCpu->pfnDisasmFnTable[pOp->idxParse3](lpszCodeBlock+size, pOp, &pCpu->param3, pCpu);
     503        size += pCpu->pfnDisasmFnTable[pOp->idxParse3](uCodePtr+size, pOp, &pCpu->param3, pCpu);
    408504        if (fFiltered == false) pCpu->param3.cb = DISGetParamSize(pCpu, &pCpu->param3);
    409505    }
     
    415511/* Floating point opcode parsing */
    416512//*****************************************************************************
    417 unsigned ParseEscFP(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     513unsigned ParseEscFP(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    418514{
    419515    int index;
     
    423519    NOREF(pOp);
    424520
    425     ModRM = DISReadByte(pCpu, lpszCodeBlock);
     521    ModRM = DISReadByte(pCpu, uCodePtr);
    426522
    427523    index = pCpu->opcode - 0xD8;
     
    446542     */
    447543    if ((fpop->optype & pCpu->uFilter) == 0)
    448     {
    449         pCpu->pfnDisasmFnTable = pfnCalcSize;
    450     }
    451     else
    452     {
     544        pCpu->pfnDisasmFnTable = g_apfnCalcSize;
     545    else
    453546        /* Not filtered out -> full disassembly */
    454         pCpu->pfnDisasmFnTable = pfnFullDisasm;
    455     }
     547        pCpu->pfnDisasmFnTable = g_apfnFullDisasm;
    456548
    457549    /* Correct the operand size if the instruction is marked as forced or default 64 bits */
     
    472564
    473565    if (fpop->idxParse1 != IDX_ParseNop)
    474         size += pCpu->pfnDisasmFnTable[fpop->idxParse1](lpszCodeBlock+size, (PCOPCODE)fpop, pParam, pCpu);
     566        size += pCpu->pfnDisasmFnTable[fpop->idxParse1](uCodePtr+size, (PCOPCODE)fpop, pParam, pCpu);
    475567
    476568    if (fpop->idxParse2 != IDX_ParseNop)
    477         size += pCpu->pfnDisasmFnTable[fpop->idxParse2](lpszCodeBlock+size, (PCOPCODE)fpop, pParam, pCpu);
     569        size += pCpu->pfnDisasmFnTable[fpop->idxParse2](uCodePtr+size, (PCOPCODE)fpop, pParam, pCpu);
    478570
    479571    // Store the opcode format string for disasmPrintf
     
    497589#endif
    498590//*****************************************************************************
    499 void UseSIB(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     591void UseSIB(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    500592{
    501593    unsigned scale, base, index, regtype;
    502594    const char **ppszSIBIndexReg;
    503595    const char **ppszSIBBaseReg;
    504     NOREF(lpszCodeBlock); NOREF(pOp);
     596    NOREF(uCodePtr); NOREF(pOp);
    505597
    506598    scale = pCpu->SIB.Bits.Scale;
     
    531623             pParam->scale  = (1<<scale);
    532624         }
    533 
    534          if (base == 5 && pCpu->ModRM.Bits.Mod == 0)
    535              disasmAddStringF2(pParam->szParam, "%s%s", ppszSIBIndexReg[index], szSIBScale[scale]);
    536          else
    537              disasmAddStringF3(pParam->szParam, "%s+%s%s", ppszSIBBaseReg[base], ppszSIBIndexReg[index], szSIBScale[scale]);
    538     }
    539     else
    540     {
    541          if (base != 5 || pCpu->ModRM.Bits.Mod != 0)
    542              disasmAddStringF1(pParam->szParam, "%s", ppszSIBBaseReg[base]);
    543625    }
    544626
     
    550632            pParam->flags |= USE_DISPLACEMENT32;
    551633            pParam->uDisp.i32 = pCpu->i32SibDisp;
    552             disasmAddChar(pParam->szParam, '+');
    553             disasmPrintDisp32(pParam);
    554634        }
    555635        else
     
    557637            pParam->flags |= USE_DISPLACEMENT64;
    558638            pParam->uDisp.i64 = pCpu->i32SibDisp;
    559             disasmAddChar(pParam->szParam, '+');
    560             disasmPrintDisp64(pParam);
    561639        }
    562640    }
     
    570648//*****************************************************************************
    571649//*****************************************************************************
    572 unsigned ParseSIB(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     650unsigned ParseSIB(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    573651{
    574652    unsigned size = sizeof(uint8_t);
     
    576654    NOREF(pOp); NOREF(pParam);
    577655
    578     SIB = DISReadByte(pCpu, lpszCodeBlock);
    579     lpszCodeBlock += size;
     656    SIB = DISReadByte(pCpu, uCodePtr);
     657    uCodePtr += size;
    580658
    581659    pCpu->SIB.Bits.Base  = SIB_BASE(SIB);
     
    596674    {
    597675        /* Additional 32 bits displacement. No change in long mode. */
    598         pCpu->i32SibDisp = DISReadDWord(pCpu, lpszCodeBlock);
     676        pCpu->i32SibDisp = DISReadDWord(pCpu, uCodePtr);
    599677        size += sizeof(int32_t);
    600678    }
     
    603681//*****************************************************************************
    604682//*****************************************************************************
    605 unsigned ParseSIB_SizeOnly(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     683unsigned ParseSIB_SizeOnly(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    606684{
    607685    unsigned size = sizeof(uint8_t);
     
    609687    NOREF(pOp); NOREF(pParam);
    610688
    611     SIB = DISReadByte(pCpu, lpszCodeBlock);
    612     lpszCodeBlock += size;
     689    SIB = DISReadByte(pCpu, uCodePtr);
     690    uCodePtr += size;
    613691
    614692    pCpu->SIB.Bits.Base  = SIB_BASE(SIB);
     
    637715// Mod    Reg/Opcode  R/M
    638716//*****************************************************************************
    639 unsigned UseModRM(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     717unsigned UseModRM(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    640718{
    641719    int      vtype = OP_PARM_VTYPE(pParam->param);
     
    667745                else
    668746                    pParam->base.reg_ctrl = reg;
    669 
    670                 disasmAddStringF1(pParam->szParam, "CR%d", pParam->base.reg_ctrl);
    671747                return 0;
    672748
    673749            case OP_PARM_D: //debug register
    674                 disasmAddStringF1(pParam->szParam, "DR%d", reg);
    675750                pParam->flags |= USE_REG_DBG;
    676751                pParam->base.reg_dbg = reg;
     
    679754            case OP_PARM_P: //MMX register
    680755                reg &= 7;   /* REX.R has no effect here */
    681                 disasmAddStringF1(pParam->szParam, "MM%d", reg);
    682756                pParam->flags |= USE_REG_MMX;
    683757                pParam->base.reg_mmx = reg;
     
    692766            case OP_PARM_T: //test register
    693767                reg &= 7;   /* REX.R has no effect here */
    694                 disasmAddStringF1(pParam->szParam, "TR%d", reg);
    695768                pParam->flags |= USE_REG_TEST;
    696769                pParam->base.reg_test = reg;
     
    704777
    705778            case OP_PARM_V: //XMM register
    706                 disasmAddStringF1(pParam->szParam, "XMM%d", reg);
    707779                pParam->flags |= USE_REG_XMM;
    708780                pParam->base.reg_xmm = reg;
     
    724796        {
    725797        case 0: //effective address
    726             disasmGetPtrString(pCpu, pOp, pParam);
    727             disasmAddChar(pParam->szParam, '[');
    728798            if (rm == 4)
    729799            {   /* SIB byte follows ModRM */
    730                 UseSIB(lpszCodeBlock, pOp, pParam, pCpu);
     800                UseSIB(uCodePtr, pOp, pParam, pCpu);
    731801            }
    732802            else
     
    738808                    pParam->flags |= USE_DISPLACEMENT32;
    739809                    pParam->uDisp.i32 = pCpu->i32SibDisp;
    740                     disasmPrintDisp32(pParam);
    741810                }
    742811                else
     
    744813                    pParam->flags |= USE_RIPDISPLACEMENT32;
    745814                    pParam->uDisp.i32 = pCpu->i32SibDisp;
    746                     disasmAddString(pParam->szParam, "RIP+");
    747                     disasmPrintDisp32(pParam);
    748815                }
    749816            }
     
    753820                disasmModRMReg(pCpu, pOp, rm, pParam, 1);
    754821            }
    755             disasmAddChar(pParam->szParam, ']');
    756822            break;
    757823
    758824        case 1: //effective address + 8 bits displacement
    759             disasmGetPtrString(pCpu, pOp, pParam);
    760             disasmAddChar(pParam->szParam, '[');
    761825            if (rm == 4) {//SIB byte follows ModRM
    762                 UseSIB(lpszCodeBlock, pOp, pParam, pCpu);
     826                UseSIB(uCodePtr, pOp, pParam, pCpu);
    763827            }
    764828            else
     
    769833            pParam->uDisp.i8 = pCpu->i32SibDisp;
    770834            pParam->flags |= USE_DISPLACEMENT8;
    771 
    772             if (pParam->uDisp.i8 != 0)
    773             {
    774                 if (pParam->uDisp.i8 > 0)
    775                     disasmAddChar(pParam->szParam, '+');
    776                 disasmPrintDisp8(pParam);
    777             }
    778             disasmAddChar(pParam->szParam, ']');
    779835            break;
    780836
    781837        case 2: //effective address + 32 bits displacement
    782             disasmGetPtrString(pCpu, pOp, pParam);
    783             disasmAddChar(pParam->szParam, '[');
    784838            if (rm == 4) {//SIB byte follows ModRM
    785                 UseSIB(lpszCodeBlock, pOp, pParam, pCpu);
     839                UseSIB(uCodePtr, pOp, pParam, pCpu);
    786840            }
    787841            else
     
    792846            pParam->uDisp.i32 = pCpu->i32SibDisp;
    793847            pParam->flags |= USE_DISPLACEMENT32;
    794 
    795             if (pParam->uDisp.i32 != 0)
    796             {
    797                 disasmAddChar(pParam->szParam, '+');
    798                 disasmPrintDisp32(pParam);
    799             }
    800             disasmAddChar(pParam->szParam, ']');
    801848            break;
    802849
     
    811858        {
    812859        case 0: //effective address
    813             disasmGetPtrString(pCpu, pOp, pParam);
    814             disasmAddChar(pParam->szParam, '[');
    815860            if (rm == 6)
    816861            {//16 bits displacement
    817862                pParam->uDisp.i16 = pCpu->i32SibDisp;
    818863                pParam->flags |= USE_DISPLACEMENT16;
    819                 disasmPrintDisp16(pParam);
    820864            }
    821865            else
     
    824868                disasmModRMReg16(pCpu, pOp, rm, pParam);
    825869            }
    826             disasmAddChar(pParam->szParam, ']');
    827870            break;
    828871
    829872        case 1: //effective address + 8 bits displacement
    830             disasmGetPtrString(pCpu, pOp, pParam);
    831             disasmAddChar(pParam->szParam, '[');
    832873            disasmModRMReg16(pCpu, pOp, rm, pParam);
    833874            pParam->uDisp.i8 = pCpu->i32SibDisp;
    834875            pParam->flags |= USE_BASE | USE_DISPLACEMENT8;
    835 
    836             if (pParam->uDisp.i8 != 0)
    837             {
    838                 if (pParam->uDisp.i8 > 0)
    839                     disasmAddChar(pParam->szParam, '+');
    840                 disasmPrintDisp8(pParam);
    841             }
    842             disasmAddChar(pParam->szParam, ']');
    843876            break;
    844877
    845878        case 2: //effective address + 16 bits displacement
    846             disasmGetPtrString(pCpu, pOp, pParam);
    847             disasmAddChar(pParam->szParam, '[');
    848879            disasmModRMReg16(pCpu, pOp, rm, pParam);
    849880            pParam->uDisp.i16 = pCpu->i32SibDisp;
    850881            pParam->flags |= USE_BASE | USE_DISPLACEMENT16;
    851 
    852             if (pParam->uDisp.i16 != 0)
    853             {
    854                 disasmAddChar(pParam->szParam, '+');
    855                 disasmPrintDisp16(pParam);
    856             }
    857             disasmAddChar(pParam->szParam, ']');
    858882            break;
    859883
     
    868892// Query the size of the ModRM parameters and fetch the immediate data (if any)
    869893//*****************************************************************************
    870 unsigned QueryModRM(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu, unsigned *pSibInc)
     894unsigned QueryModRM(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu, unsigned *pSibInc)
    871895{
    872896    unsigned sibinc;
     
    890914        if (mod != 3 && rm == 4)
    891915        {   /* SIB byte follows ModRM */
    892             *pSibInc = ParseSIB(lpszCodeBlock, pOp, pParam, pCpu);
    893             lpszCodeBlock += *pSibInc;
     916            *pSibInc = ParseSIB(uCodePtr, pOp, pParam, pCpu);
     917            uCodePtr += *pSibInc;
    894918            size += *pSibInc;
    895919        }
     
    899923        case 0: /* Effective address */
    900924            if (rm == 5) {  /* 32 bits displacement */
    901                 pCpu->i32SibDisp = DISReadDWord(pCpu, lpszCodeBlock);
     925                pCpu->i32SibDisp = DISReadDWord(pCpu, uCodePtr);
    902926                size += sizeof(int32_t);
    903927            }
     
    906930
    907931        case 1: /* Effective address + 8 bits displacement */
    908             pCpu->i32SibDisp = (int8_t)DISReadByte(pCpu, lpszCodeBlock);
     932            pCpu->i32SibDisp = (int8_t)DISReadByte(pCpu, uCodePtr);
    909933            size += sizeof(char);
    910934            break;
    911935
    912936        case 2: /* Effective address + 32 bits displacement */
    913             pCpu->i32SibDisp = DISReadDWord(pCpu, lpszCodeBlock);
     937            pCpu->i32SibDisp = DISReadDWord(pCpu, uCodePtr);
    914938            size += sizeof(int32_t);
    915939            break;
     
    926950        case 0: /* Effective address */
    927951            if (rm == 6) {
    928                 pCpu->i32SibDisp = DISReadWord(pCpu, lpszCodeBlock);
     952                pCpu->i32SibDisp = DISReadWord(pCpu, uCodePtr);
    929953                size += sizeof(uint16_t);
    930954            }
     
    933957
    934958        case 1: /* Effective address + 8 bits displacement */
    935             pCpu->i32SibDisp = (int8_t)DISReadByte(pCpu, lpszCodeBlock);
     959            pCpu->i32SibDisp = (int8_t)DISReadByte(pCpu, uCodePtr);
    936960            size += sizeof(char);
    937961            break;
    938962
    939963        case 2: /* Effective address + 32 bits displacement */
    940             pCpu->i32SibDisp = (int16_t)DISReadWord(pCpu, lpszCodeBlock);
     964            pCpu->i32SibDisp = (int16_t)DISReadWord(pCpu, uCodePtr);
    941965            size += sizeof(uint16_t);
    942966            break;
     
    951975// Query the size of the ModRM parameters and fetch the immediate data (if any)
    952976//*****************************************************************************
    953 unsigned QueryModRM_SizeOnly(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu, unsigned *pSibInc)
     977unsigned QueryModRM_SizeOnly(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu, unsigned *pSibInc)
    954978{
    955979    unsigned sibinc;
     
    972996        if (mod != 3 && rm == 4)
    973997        {   /* SIB byte follows ModRM */
    974             *pSibInc = ParseSIB_SizeOnly(lpszCodeBlock, pOp, pParam, pCpu);
    975             lpszCodeBlock += *pSibInc;
     998            *pSibInc = ParseSIB_SizeOnly(uCodePtr, pOp, pParam, pCpu);
     999            uCodePtr += *pSibInc;
    9761000            size += *pSibInc;
    9771001        }
     
    10261050//*****************************************************************************
    10271051//*****************************************************************************
    1028 unsigned ParseIllegal(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    1029 {
    1030     NOREF(lpszCodeBlock); NOREF(pOp); NOREF(pParam); NOREF(pCpu);
     1052unsigned ParseIllegal(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     1053{
     1054    NOREF(uCodePtr); NOREF(pOp); NOREF(pParam); NOREF(pCpu);
    10311055    AssertFailed();
    10321056    return 0;
     
    10341058//*****************************************************************************
    10351059//*****************************************************************************
    1036 unsigned ParseModRM(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     1060unsigned ParseModRM(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    10371061{
    10381062    unsigned size = sizeof(uint8_t);   //ModRM byte
    10391063    unsigned sibinc, ModRM;
    10401064
    1041     ModRM = DISReadByte(pCpu, lpszCodeBlock);
    1042     lpszCodeBlock += sizeof(uint8_t);
     1065    ModRM = DISReadByte(pCpu, uCodePtr);
     1066    uCodePtr += sizeof(uint8_t);
    10431067
    10441068    pCpu->ModRM.Bits.Rm  = MODRM_RM(ModRM);
     
    10721096        }
    10731097    }
    1074     size += QueryModRM(lpszCodeBlock, pOp, pParam, pCpu, &sibinc);
    1075     lpszCodeBlock += sibinc;
    1076 
    1077     UseModRM(lpszCodeBlock, pOp, pParam, pCpu);
    1078     return size;
    1079 }
    1080 //*****************************************************************************
    1081 //*****************************************************************************
    1082 unsigned ParseModRM_SizeOnly(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     1098    size += QueryModRM(uCodePtr, pOp, pParam, pCpu, &sibinc);
     1099    uCodePtr += sibinc;
     1100
     1101    UseModRM(uCodePtr, pOp, pParam, pCpu);
     1102    return size;
     1103}
     1104//*****************************************************************************
     1105//*****************************************************************************
     1106unsigned ParseModRM_SizeOnly(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    10831107{
    10841108    unsigned size = sizeof(uint8_t);   //ModRM byte
    10851109    unsigned sibinc, ModRM;
    10861110
    1087     ModRM = DISReadByte(pCpu, lpszCodeBlock);
    1088     lpszCodeBlock += sizeof(uint8_t);
     1111    ModRM = DISReadByte(pCpu, uCodePtr);
     1112    uCodePtr += sizeof(uint8_t);
    10891113
    10901114    pCpu->ModRM.Bits.Rm  = MODRM_RM(ModRM);
     
    11191143    }
    11201144
    1121     size += QueryModRM_SizeOnly(lpszCodeBlock, pOp, pParam, pCpu, &sibinc);
    1122     lpszCodeBlock += sibinc;
     1145    size += QueryModRM_SizeOnly(uCodePtr, pOp, pParam, pCpu, &sibinc);
     1146    uCodePtr += sibinc;
    11231147
    11241148    /* UseModRM is not necessary here; we're only interested in the opcode size */
     
    11271151//*****************************************************************************
    11281152//*****************************************************************************
    1129 unsigned ParseModFence(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     1153unsigned ParseModFence(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    11301154{
    11311155    ////AssertMsgFailed(("??\n"));
    11321156    //nothing to do apparently
    1133     NOREF(lpszCodeBlock); NOREF(pOp); NOREF(pParam); NOREF(pCpu);
     1157    NOREF(uCodePtr); NOREF(pOp); NOREF(pParam); NOREF(pCpu);
    11341158    return 0;
    11351159}
    11361160//*****************************************************************************
    11371161//*****************************************************************************
    1138 unsigned ParseImmByte(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     1162unsigned ParseImmByte(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    11391163{
    11401164    NOREF(pOp);
    1141     pParam->parval = DISReadByte(pCpu, lpszCodeBlock);
     1165    pParam->parval = DISReadByte(pCpu, uCodePtr);
    11421166    pParam->flags |= USE_IMMEDIATE8;
    11431167    pParam->cb     = sizeof(uint8_t);
    1144 
    1145     disasmAddStringF1(pParam->szParam, "0%02Xh", (uint32_t)pParam->parval);
    11461168    return sizeof(uint8_t);
    11471169}
    11481170//*****************************************************************************
    11491171//*****************************************************************************
    1150 unsigned ParseImmByte_SizeOnly(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    1151 {
    1152     NOREF(lpszCodeBlock); NOREF(pOp); NOREF(pParam); NOREF(pCpu);
     1172unsigned ParseImmByte_SizeOnly(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     1173{
     1174    NOREF(uCodePtr); NOREF(pOp); NOREF(pParam); NOREF(pCpu);
    11531175    return sizeof(uint8_t);
    11541176}
    11551177//*****************************************************************************
    11561178//*****************************************************************************
    1157 unsigned ParseImmByteSX(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     1179unsigned ParseImmByteSX(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    11581180{
    11591181    NOREF(pOp);
    11601182    if (pCpu->opmode == CPUMODE_32BIT)
    11611183    {
    1162         pParam->parval = (uint32_t)(int8_t)DISReadByte(pCpu, lpszCodeBlock);
     1184        pParam->parval = (uint32_t)(int8_t)DISReadByte(pCpu, uCodePtr);
    11631185        pParam->flags |= USE_IMMEDIATE32_SX8;
    11641186        pParam->cb     = sizeof(uint32_t);
    1165         disasmAddStringF1(pParam->szParam, "0%08Xh", (uint32_t)pParam->parval);
    11661187    }
    11671188    else
    11681189    if (pCpu->opmode == CPUMODE_64BIT)
    11691190    {
    1170         pParam->parval = (uint64_t)(int8_t)DISReadByte(pCpu, lpszCodeBlock);
     1191        pParam->parval = (uint64_t)(int8_t)DISReadByte(pCpu, uCodePtr);
    11711192        pParam->flags |= USE_IMMEDIATE64_SX8;
    11721193        pParam->cb     = sizeof(uint64_t);
    1173         disasmAddStringF1(pParam->szParam, "0%016RX64h", pParam->parval);
    1174     }
    1175     else
    1176     {
    1177         pParam->parval = (uint16_t)(int8_t)DISReadByte(pCpu, lpszCodeBlock);
     1194    }
     1195    else
     1196    {
     1197        pParam->parval = (uint16_t)(int8_t)DISReadByte(pCpu, uCodePtr);
    11781198        pParam->flags |= USE_IMMEDIATE16_SX8;
    11791199        pParam->cb     = sizeof(uint16_t);
    1180         disasmAddStringF1(pParam->szParam, "0%04Xh", (uint16_t)pParam->parval);
    11811200    }
    11821201    return sizeof(uint8_t);
     
    11841203//*****************************************************************************
    11851204//*****************************************************************************
    1186 unsigned ParseImmByteSX_SizeOnly(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    1187 {
    1188     NOREF(lpszCodeBlock); NOREF(pOp); NOREF(pParam); NOREF(pCpu);
     1205unsigned ParseImmByteSX_SizeOnly(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     1206{
     1207    NOREF(uCodePtr); NOREF(pOp); NOREF(pParam); NOREF(pCpu);
    11891208    return sizeof(uint8_t);
    11901209}
    11911210//*****************************************************************************
    11921211//*****************************************************************************
    1193 unsigned ParseImmUshort(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     1212unsigned ParseImmUshort(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    11941213{
    11951214    NOREF(pOp);
    1196     pParam->parval = DISReadWord(pCpu, lpszCodeBlock);
     1215    pParam->parval = DISReadWord(pCpu, uCodePtr);
    11971216    pParam->flags |= USE_IMMEDIATE16;
    11981217    pParam->cb     = sizeof(uint16_t);
    1199 
    1200     disasmAddStringF1(pParam->szParam, "0%04Xh", (uint16_t)pParam->parval);
    12011218    return sizeof(uint16_t);
    12021219}
    12031220//*****************************************************************************
    12041221//*****************************************************************************
    1205 unsigned ParseImmUshort_SizeOnly(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    1206 {
    1207     NOREF(lpszCodeBlock); NOREF(pOp); NOREF(pParam); NOREF(pCpu);
     1222unsigned ParseImmUshort_SizeOnly(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     1223{
     1224    NOREF(uCodePtr); NOREF(pOp); NOREF(pParam); NOREF(pCpu);
    12081225    return sizeof(uint16_t);
    12091226}
    12101227//*****************************************************************************
    12111228//*****************************************************************************
    1212 unsigned ParseImmUlong(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     1229unsigned ParseImmUlong(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    12131230{
    12141231    NOREF(pOp);
    1215     pParam->parval = DISReadDWord(pCpu, lpszCodeBlock);
     1232    pParam->parval = DISReadDWord(pCpu, uCodePtr);
    12161233    pParam->flags |= USE_IMMEDIATE32;
    12171234    pParam->cb     = sizeof(uint32_t);
    1218 
    1219     disasmAddStringF1(pParam->szParam, "0%08Xh", (uint32_t)pParam->parval);
    12201235    return sizeof(uint32_t);
    12211236}
    12221237//*****************************************************************************
    12231238//*****************************************************************************
    1224 unsigned ParseImmUlong_SizeOnly(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    1225 {
    1226     NOREF(lpszCodeBlock); NOREF(pOp); NOREF(pParam); NOREF(pCpu);
     1239unsigned ParseImmUlong_SizeOnly(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     1240{
     1241    NOREF(uCodePtr); NOREF(pOp); NOREF(pParam); NOREF(pCpu);
    12271242    return sizeof(uint32_t);
    12281243}
    12291244//*****************************************************************************
    12301245//*****************************************************************************
    1231 unsigned ParseImmQword(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     1246unsigned ParseImmQword(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    12321247{
    12331248    NOREF(pOp);
    1234     pParam->parval = DISReadQWord(pCpu, lpszCodeBlock);
     1249    pParam->parval = DISReadQWord(pCpu, uCodePtr);
    12351250    pParam->flags |= USE_IMMEDIATE64;
    12361251    pParam->cb     = sizeof(uint64_t);
    1237 
    1238     disasmAddStringF2(pParam->szParam, "0%08X%08Xh",
    1239                       (uint32_t)pParam->parval, (uint32_t)(pParam->parval >> 32));
    12401252    return sizeof(uint64_t);
    12411253}
    12421254//*****************************************************************************
    12431255//*****************************************************************************
    1244 unsigned ParseImmQword_SizeOnly(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    1245 {
    1246     NOREF(lpszCodeBlock); NOREF(pOp); NOREF(pParam); NOREF(pCpu);
     1256unsigned ParseImmQword_SizeOnly(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     1257{
     1258    NOREF(uCodePtr); NOREF(pOp); NOREF(pParam); NOREF(pCpu);
    12471259    return sizeof(uint64_t);
    12481260}
    12491261//*****************************************************************************
    12501262//*****************************************************************************
    1251 unsigned ParseImmV(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     1263unsigned ParseImmV(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    12521264{
    12531265    NOREF(pOp);
    12541266    if (pCpu->opmode == CPUMODE_32BIT)
    12551267    {
    1256         pParam->parval = DISReadDWord(pCpu, lpszCodeBlock);
     1268        pParam->parval = DISReadDWord(pCpu, uCodePtr);
    12571269        pParam->flags |= USE_IMMEDIATE32;
    12581270        pParam->cb     = sizeof(uint32_t);
    1259 
    1260         disasmAddStringF1(pParam->szParam, "0%08Xh", (uint32_t)pParam->parval);
    12611271        return sizeof(uint32_t);
    12621272    }
    1263     else
     1273
    12641274    if (pCpu->opmode == CPUMODE_64BIT)
    12651275    {
    1266         pParam->parval = DISReadQWord(pCpu, lpszCodeBlock);
     1276        pParam->parval = DISReadQWord(pCpu, uCodePtr);
    12671277        pParam->flags |= USE_IMMEDIATE64;
    12681278        pParam->cb     = sizeof(uint64_t);
    1269 
    1270         disasmAddStringF1(pParam->szParam, "0%RX64h", pParam->parval);
    12711279        return sizeof(uint64_t);
    12721280    }
    1273     else
    1274     {
    1275         pParam->parval = DISReadWord(pCpu, lpszCodeBlock);
    1276         pParam->flags |= USE_IMMEDIATE16;
    1277         pParam->cb     = sizeof(uint16_t);
    1278 
    1279         disasmAddStringF1(pParam->szParam, "0%04Xh", (uint32_t)pParam->parval);
    1280         return sizeof(uint16_t);
    1281     }
    1282 }
    1283 //*****************************************************************************
    1284 //*****************************************************************************
    1285 unsigned ParseImmV_SizeOnly(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    1286 {
    1287     NOREF(lpszCodeBlock); NOREF(pOp); NOREF(pParam);
     1281
     1282    pParam->parval = DISReadWord(pCpu, uCodePtr);
     1283    pParam->flags |= USE_IMMEDIATE16;
     1284    pParam->cb     = sizeof(uint16_t);
     1285    return sizeof(uint16_t);
     1286}
     1287//*****************************************************************************
     1288//*****************************************************************************
     1289unsigned ParseImmV_SizeOnly(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     1290{
     1291    NOREF(uCodePtr); NOREF(pOp); NOREF(pParam);
    12881292    if (pCpu->opmode == CPUMODE_32BIT)
    12891293        return sizeof(uint32_t);
     
    12941298//*****************************************************************************
    12951299//*****************************************************************************
    1296 unsigned ParseImmZ(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     1300unsigned ParseImmZ(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    12971301{
    12981302    NOREF(pOp);
     
    13001304    if (pCpu->opmode == CPUMODE_16BIT)
    13011305    {
    1302         pParam->parval = DISReadWord(pCpu, lpszCodeBlock);
     1306        pParam->parval = DISReadWord(pCpu, uCodePtr);
    13031307        pParam->flags |= USE_IMMEDIATE16;
    13041308        pParam->cb     = sizeof(uint16_t);
    1305 
    1306         disasmAddStringF1(pParam->szParam, "0%04Xh", (uint32_t)pParam->parval);
    13071309        return sizeof(uint16_t);
    13081310    }
    1309     else
    1310     {
    1311         /* 64 bits op mode means *sign* extend to 64 bits. */
    1312         if (pCpu->opmode == CPUMODE_64BIT)
    1313         {
    1314             pParam->parval = (uint64_t)(int32_t)DISReadDWord(pCpu, lpszCodeBlock);
    1315             pParam->flags |= USE_IMMEDIATE64;
    1316             pParam->cb     = sizeof(uint64_t);
    1317             disasmAddStringF1(pParam->szParam, "0%RX64h", pParam->parval);
    1318         }
    1319         else
    1320         {
    1321             pParam->parval = DISReadDWord(pCpu, lpszCodeBlock);
    1322             pParam->flags |= USE_IMMEDIATE32;
    1323             pParam->cb     = sizeof(uint32_t);
    1324             disasmAddStringF1(pParam->szParam, "0%08Xh", (uint32_t)pParam->parval);
    1325         }
    1326         return sizeof(uint32_t);
    1327     }
    1328 }
    1329 //*****************************************************************************
    1330 //*****************************************************************************
    1331 unsigned ParseImmZ_SizeOnly(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    1332 {
    1333     NOREF(lpszCodeBlock); NOREF(pOp); NOREF(pParam);
     1311
     1312    /* 64 bits op mode means *sign* extend to 64 bits. */
     1313    if (pCpu->opmode == CPUMODE_64BIT)
     1314    {
     1315        pParam->parval = (uint64_t)(int32_t)DISReadDWord(pCpu, uCodePtr);
     1316        pParam->flags |= USE_IMMEDIATE64;
     1317        pParam->cb     = sizeof(uint64_t);
     1318    }
     1319    else
     1320    {
     1321        pParam->parval = DISReadDWord(pCpu, uCodePtr);
     1322        pParam->flags |= USE_IMMEDIATE32;
     1323        pParam->cb     = sizeof(uint32_t);
     1324    }
     1325    return sizeof(uint32_t);
     1326}
     1327//*****************************************************************************
     1328//*****************************************************************************
     1329unsigned ParseImmZ_SizeOnly(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     1330{
     1331    NOREF(uCodePtr); NOREF(pOp); NOREF(pParam);
    13341332    /* Word for 16-bit operand-size or doubleword for 32 or 64-bit operand-size. */
    13351333    if (pCpu->opmode == CPUMODE_16BIT)
     
    13411339// Relative displacement for branches (rel. to next instruction)
    13421340//*****************************************************************************
    1343 unsigned ParseImmBRel(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     1341unsigned ParseImmBRel(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    13441342{
    13451343    NOREF(pOp);
    1346     pParam->parval = DISReadByte(pCpu, lpszCodeBlock);
     1344    pParam->parval = DISReadByte(pCpu, uCodePtr);
    13471345    pParam->flags |= USE_IMMEDIATE8_REL;
    13481346    pParam->cb     = sizeof(uint8_t);
    1349 
    1350     disasmAddStringF1(pParam->szParam, " (0%02Xh)", (uint32_t)pParam->parval);
    13511347    return sizeof(char);
    13521348}
     
    13541350// Relative displacement for branches (rel. to next instruction)
    13551351//*****************************************************************************
    1356 unsigned ParseImmBRel_SizeOnly(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    1357 {
    1358     NOREF(lpszCodeBlock); NOREF(pOp); NOREF(pParam); NOREF(pCpu);
     1352unsigned ParseImmBRel_SizeOnly(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     1353{
     1354    NOREF(uCodePtr); NOREF(pOp); NOREF(pParam); NOREF(pCpu);
    13591355    return sizeof(char);
    13601356}
     
    13621358// Relative displacement for branches (rel. to next instruction)
    13631359//*****************************************************************************
    1364 unsigned ParseImmVRel(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     1360unsigned ParseImmVRel(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    13651361{
    13661362    NOREF(pOp);
    13671363    if (pCpu->opmode == CPUMODE_32BIT)
    13681364    {
    1369         pParam->parval = DISReadDWord(pCpu, lpszCodeBlock);
     1365        pParam->parval = DISReadDWord(pCpu, uCodePtr);
    13701366        pParam->flags |= USE_IMMEDIATE32_REL;
    13711367        pParam->cb     = sizeof(int32_t);
    1372 
    1373         disasmAddStringF1(pParam->szParam, " (0%08Xh)", (uint32_t)pParam->parval);
    13741368        return sizeof(int32_t);
    13751369    }
    1376     else
     1370
    13771371    if (pCpu->opmode == CPUMODE_64BIT)
    13781372    {
    13791373        /* 32 bits relative immediate sign extended to 64 bits. */
    1380         pParam->parval = (uint64_t)(int32_t)DISReadDWord(pCpu, lpszCodeBlock);
     1374        pParam->parval = (uint64_t)(int32_t)DISReadDWord(pCpu, uCodePtr);
    13811375        pParam->flags |= USE_IMMEDIATE64_REL;
    13821376        pParam->cb     = sizeof(int64_t);
    1383 
    1384         disasmAddStringF1(pParam->szParam, " (0%RX64h)", pParam->parval);
    13851377        return sizeof(int32_t);
    13861378    }
    1387     else
    1388     {
    1389         pParam->parval = DISReadWord(pCpu, lpszCodeBlock);
    1390         pParam->flags |= USE_IMMEDIATE16_REL;
    1391         pParam->cb     = sizeof(int16_t);
    1392 
    1393         disasmAddStringF1(pParam->szParam, " (0%04Xh)", (uint32_t)pParam->parval);
    1394         return sizeof(int16_t);
    1395     }
     1379
     1380    pParam->parval = DISReadWord(pCpu, uCodePtr);
     1381    pParam->flags |= USE_IMMEDIATE16_REL;
     1382    pParam->cb     = sizeof(int16_t);
     1383    return sizeof(int16_t);
    13961384}
    13971385//*****************************************************************************
    13981386// Relative displacement for branches (rel. to next instruction)
    13991387//*****************************************************************************
    1400 unsigned ParseImmVRel_SizeOnly(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    1401 {
    1402     NOREF(lpszCodeBlock); NOREF(pOp); NOREF(pParam);
     1388unsigned ParseImmVRel_SizeOnly(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     1389{
     1390    NOREF(uCodePtr); NOREF(pOp); NOREF(pParam);
    14031391    if (pCpu->opmode == CPUMODE_16BIT)
    14041392        return sizeof(int16_t);
     
    14081396//*****************************************************************************
    14091397//*****************************************************************************
    1410 unsigned ParseImmAddr(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    1411 {
    1412     disasmGetPtrString(pCpu, pOp, pParam);
     1398unsigned ParseImmAddr(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     1399{
    14131400    if (pCpu->addrmode == CPUMODE_32BIT)
    14141401    {
    14151402        if (OP_PARM_VSUBTYPE(pParam->param) == OP_PARM_p)
    1416         {// far 16:32 pointer
    1417             pParam->parval = DISReadDWord(pCpu, lpszCodeBlock);
    1418             *((uint32_t*)&pParam->parval+1) = DISReadWord(pCpu, lpszCodeBlock+sizeof(uint32_t));
     1403        {
     1404            /* far 16:32 pointer */
     1405            pParam->parval = DISReadDWord(pCpu, uCodePtr);
     1406            *((uint32_t*)&pParam->parval+1) = DISReadWord(pCpu, uCodePtr+sizeof(uint32_t));
    14191407            pParam->flags  |= USE_IMMEDIATE_ADDR_16_32;
    14201408            pParam->cb     = sizeof(uint16_t) + sizeof(uint32_t);
    1421 
    1422             disasmAddStringF2(pParam->szParam, "0%04X:0%08Xh", (uint32_t)(pParam->parval>>32), (uint32_t)pParam->parval);
    14231409            return sizeof(uint32_t) + sizeof(uint16_t);
    14241410        }
    1425         else
    1426         {// near 32 bits pointer
    1427             /*
    1428              * Note: used only in "mov al|ax|eax, [Addr]" and "mov [Addr], al|ax|eax"
    1429              * so we treat it like displacement.
    1430              */
    1431             pParam->uDisp.i32 = DISReadDWord(pCpu, lpszCodeBlock);
    1432             pParam->flags |= USE_DISPLACEMENT32;
    1433             pParam->cb     = sizeof(uint32_t);
    1434 
    1435             disasmAddStringF1(pParam->szParam, "[0%08Xh]", pParam->uDisp.i32);
    1436             return sizeof(uint32_t);
    1437         }
    1438     }
    1439     else
    1440     if (pCpu->addrmode == CPUMODE_64BIT)
    1441     {
    1442         Assert(OP_PARM_VSUBTYPE(pParam->param) != OP_PARM_p);
    1443         /* near 64 bits pointer */
     1411
    14441412        /*
     1413         * near 32 bits pointer
     1414         *
    14451415         * Note: used only in "mov al|ax|eax, [Addr]" and "mov [Addr], al|ax|eax"
    14461416         * so we treat it like displacement.
    14471417         */
    1448         pParam->uDisp.i64 = DISReadQWord(pCpu, lpszCodeBlock);
     1418        pParam->uDisp.i32 = DISReadDWord(pCpu, uCodePtr);
     1419        pParam->flags |= USE_DISPLACEMENT32;
     1420        pParam->cb     = sizeof(uint32_t);
     1421        return sizeof(uint32_t);
     1422    }
     1423
     1424    if (pCpu->addrmode == CPUMODE_64BIT)
     1425    {
     1426        Assert(OP_PARM_VSUBTYPE(pParam->param) != OP_PARM_p);
     1427        /*
     1428         * near 64 bits pointer
     1429         *
     1430         * Note: used only in "mov al|ax|eax, [Addr]" and "mov [Addr], al|ax|eax"
     1431         * so we treat it like displacement.
     1432         */
     1433        pParam->uDisp.i64 = DISReadQWord(pCpu, uCodePtr);
    14491434        pParam->flags |= USE_DISPLACEMENT64;
    14501435        pParam->cb     = sizeof(uint64_t);
    1451 
    1452         disasmAddStringF2(pParam->szParam, "[0%08X%08Xh]", (uint32_t)(pParam->uDisp.i64 >> 32), (uint32_t)pParam->uDisp.i64);
    14531436        return sizeof(uint64_t);
    14541437    }
    1455     else
    1456     {
    1457         if (OP_PARM_VSUBTYPE(pParam->param) == OP_PARM_p)
    1458         {// far 16:16 pointer
    1459             pParam->parval = DISReadDWord(pCpu, lpszCodeBlock);
    1460             pParam->flags |= USE_IMMEDIATE_ADDR_16_16;
    1461             pParam->cb     = 2*sizeof(uint16_t);
    1462 
    1463             disasmAddStringF2(pParam->szParam, "0%04X:0%04Xh", (uint32_t)(pParam->parval>>16), (uint16_t)pParam->parval );
    1464             return sizeof(uint32_t);
    1465         }
    1466         else
    1467         {// near 16 bits pointer
    1468             /*
    1469              * Note: used only in "mov al|ax|eax, [Addr]" and "mov [Addr], al|ax|eax"
    1470              * so we treat it like displacement.
    1471              */
    1472             pParam->uDisp.i16 = DISReadWord(pCpu, lpszCodeBlock);
    1473             pParam->flags |= USE_DISPLACEMENT16;
    1474             pParam->cb     = sizeof(uint16_t);
    1475 
    1476             disasmAddStringF1(pParam->szParam, "[0%04Xh]", (uint32_t)pParam->uDisp.i16);
    1477             return sizeof(uint16_t);
    1478         }
    1479     }
    1480 }
    1481 //*****************************************************************************
    1482 //*****************************************************************************
    1483 unsigned ParseImmAddr_SizeOnly(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    1484 {
    1485     NOREF(lpszCodeBlock); NOREF(pOp);
     1438    if (OP_PARM_VSUBTYPE(pParam->param) == OP_PARM_p)
     1439    {
     1440        /* far 16:16 pointer */
     1441        pParam->parval = DISReadDWord(pCpu, uCodePtr);
     1442        pParam->flags |= USE_IMMEDIATE_ADDR_16_16;
     1443        pParam->cb     = 2*sizeof(uint16_t);
     1444        return sizeof(uint32_t);
     1445    }
     1446
     1447    /*
     1448     * near 16 bits pointer
     1449     *
     1450     * Note: used only in "mov al|ax|eax, [Addr]" and "mov [Addr], al|ax|eax"
     1451     * so we treat it like displacement.
     1452     */
     1453    pParam->uDisp.i16 = DISReadWord(pCpu, uCodePtr);
     1454    pParam->flags |= USE_DISPLACEMENT16;
     1455    pParam->cb     = sizeof(uint16_t);
     1456    return sizeof(uint16_t);
     1457}
     1458//*****************************************************************************
     1459//*****************************************************************************
     1460unsigned ParseImmAddr_SizeOnly(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     1461{
     1462    NOREF(uCodePtr); NOREF(pOp);
    14861463    if (pCpu->addrmode == CPUMODE_32BIT)
    14871464    {
     
    15141491//*****************************************************************************
    15151492//*****************************************************************************
    1516 unsigned ParseImmAddrF(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    1517 {
    1518     disasmGetPtrString(pCpu, pOp, pParam);
     1493unsigned ParseImmAddrF(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     1494{
    15191495    // immediate far pointers - only 16:16 or 16:32; determined by operand, *not* address size!
    15201496    Assert(pCpu->opmode == CPUMODE_16BIT || pCpu->opmode == CPUMODE_32BIT);
     
    15231499    {
    15241500        // far 16:32 pointer
    1525         pParam->parval = DISReadDWord(pCpu, lpszCodeBlock);
    1526         *((uint32_t*)&pParam->parval+1) = DISReadWord(pCpu, lpszCodeBlock+sizeof(uint32_t));
     1501        pParam->parval = DISReadDWord(pCpu, uCodePtr);
     1502        *((uint32_t*)&pParam->parval+1) = DISReadWord(pCpu, uCodePtr+sizeof(uint32_t));
    15271503        pParam->flags  |= USE_IMMEDIATE_ADDR_16_32;
    15281504        pParam->cb     = sizeof(uint16_t) + sizeof(uint32_t);
    1529 
    1530         disasmAddStringF2(pParam->szParam, "0%04X:0%08Xh", (uint32_t)(pParam->parval>>32), (uint32_t)pParam->parval);
    15311505        return sizeof(uint32_t) + sizeof(uint16_t);
    15321506    }
    1533     else
    1534     {
    1535         // far 16:16 pointer
    1536         pParam->parval = DISReadDWord(pCpu, lpszCodeBlock);
    1537         pParam->flags |= USE_IMMEDIATE_ADDR_16_16;
    1538         pParam->cb     = 2*sizeof(uint16_t);
    1539 
    1540         disasmAddStringF2(pParam->szParam, "0%04X:0%04Xh", (uint32_t)(pParam->parval>>16), (uint16_t)pParam->parval );
    1541         return sizeof(uint32_t);
    1542     }
    1543 }
    1544 //*****************************************************************************
    1545 //*****************************************************************************
    1546 unsigned ParseImmAddrF_SizeOnly(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    1547 {
    1548     NOREF(lpszCodeBlock); NOREF(pOp);
     1507
     1508    // far 16:16 pointer
     1509    pParam->parval = DISReadDWord(pCpu, uCodePtr);
     1510    pParam->flags |= USE_IMMEDIATE_ADDR_16_16;
     1511    pParam->cb     = 2*sizeof(uint16_t);
     1512    return sizeof(uint32_t);
     1513}
     1514//*****************************************************************************
     1515//*****************************************************************************
     1516unsigned ParseImmAddrF_SizeOnly(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     1517{
     1518    NOREF(uCodePtr); NOREF(pOp);
    15491519    // immediate far pointers - only 16:16 or 16:32
    15501520    Assert(pCpu->opmode == CPUMODE_16BIT || pCpu->opmode == CPUMODE_32BIT);
     
    15631533//*****************************************************************************
    15641534//*****************************************************************************
    1565 unsigned ParseFixedReg(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    1566 {
    1567     NOREF(lpszCodeBlock);
     1535unsigned ParseFixedReg(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     1536{
     1537    NOREF(uCodePtr);
    15681538
    15691539    /*
     
    16641634//*****************************************************************************
    16651635//*****************************************************************************
    1666 unsigned ParseXv(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    1667 {
    1668     NOREF(pu8CodeBlock);
    1669     disasmGetPtrString(pCpu, pOp, pParam);
    1670     disasmAddString(pParam->szParam, (pCpu->addrmode == CPUMODE_32BIT) ? "DS:ESI" : "DS:SI");
     1636unsigned ParseXv(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     1637{
     1638    NOREF(uCodePtr);
    16711639
    16721640    pParam->flags |= USE_POINTER_DS_BASED;
     
    16911659//*****************************************************************************
    16921660//*****************************************************************************
    1693 unsigned ParseXb(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    1694 {
    1695     NOREF(pu8CodeBlock); NOREF(pOp);
    1696     disasmAddString(pParam->szParam, (pCpu->addrmode == CPUMODE_32BIT) ? "DS:ESI" : "DS:SI");
     1661unsigned ParseXb(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     1662{
     1663    NOREF(uCodePtr); NOREF(pOp);
    16971664
    16981665    pParam->flags |= USE_POINTER_DS_BASED;
     
    17171684//*****************************************************************************
    17181685//*****************************************************************************
    1719 unsigned ParseYv(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    1720 {
    1721     NOREF(pu8CodeBlock);
    1722     disasmGetPtrString(pCpu, pOp, pParam);
    1723     disasmAddString(pParam->szParam, (pCpu->addrmode == CPUMODE_32BIT) ? "ES:EDI" : "ES:DI");
     1686unsigned ParseYv(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     1687{
     1688    NOREF(uCodePtr);
    17241689
    17251690    pParam->flags |= USE_POINTER_ES_BASED;
     
    17441709//*****************************************************************************
    17451710//*****************************************************************************
    1746 unsigned ParseYb(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    1747 {
    1748     NOREF(pu8CodeBlock); NOREF(pOp);
    1749     disasmAddString(pParam->szParam, (pCpu->addrmode == CPUMODE_32BIT) ? "ES:EDI" : "ES:DI");
     1711unsigned ParseYb(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     1712{
     1713    NOREF(uCodePtr); NOREF(pOp);
    17501714
    17511715    pParam->flags |= USE_POINTER_ES_BASED;
     
    17701734//*****************************************************************************
    17711735//*****************************************************************************
    1772 unsigned ParseTwoByteEsc(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     1736unsigned ParseTwoByteEsc(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    17731737{
    17741738    const OPCODE *pOpcode;
     
    17771741
    17781742    /* 2nd byte */
    1779     pCpu->opcode = DISReadByte(pCpu, lpszCodeBlock);
     1743    pCpu->opcode = DISReadByte(pCpu, uCodePtr);
    17801744
    17811745    /* default to the non-prefixed table. */
     
    18241788    }
    18251789
    1826     size += ParseInstruction(lpszCodeBlock+size, pOpcode, pCpu);
    1827     return size;
    1828 }
    1829 //*****************************************************************************
    1830 //*****************************************************************************
    1831 unsigned ParseThreeByteEsc4(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     1790    size += ParseInstruction(uCodePtr+size, pOpcode, pCpu);
     1791    return size;
     1792}
     1793//*****************************************************************************
     1794//*****************************************************************************
     1795unsigned ParseThreeByteEsc4(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    18321796{
    18331797    const OPCODE *pOpcode;
     
    18361800
    18371801    /* 3rd byte */
    1838     pCpu->opcode = DISReadByte(pCpu, lpszCodeBlock);
     1802    pCpu->opcode = DISReadByte(pCpu, uCodePtr);
    18391803
    18401804    /* default to the non-prefixed table. */
     
    18851849    }
    18861850
    1887     size += ParseInstruction(lpszCodeBlock+size, pOpcode, pCpu);
    1888     return size;
    1889 }
    1890 //*****************************************************************************
    1891 //*****************************************************************************
    1892 unsigned ParseThreeByteEsc5(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     1851    size += ParseInstruction(uCodePtr+size, pOpcode, pCpu);
     1852    return size;
     1853}
     1854//*****************************************************************************
     1855//*****************************************************************************
     1856unsigned ParseThreeByteEsc5(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    18931857{
    18941858    const OPCODE *pOpcode;
     
    18971861
    18981862    /* 3rd byte */
    1899     pCpu->opcode = DISReadByte(pCpu, lpszCodeBlock);
     1863    pCpu->opcode = DISReadByte(pCpu, uCodePtr);
    19001864
    19011865    /** @todo Should we take the first or last prefix byte in case of multiple prefix bytes??? */
     
    19201884        pOpcode = &g_InvalidOpcode[0];
    19211885
    1922     size += ParseInstruction(lpszCodeBlock+size, pOpcode, pCpu);
    1923     return size;
    1924 }
    1925 //*****************************************************************************
    1926 //*****************************************************************************
    1927 unsigned ParseNopPause(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     1886    size += ParseInstruction(uCodePtr+size, pOpcode, pCpu);
     1887    return size;
     1888}
     1889//*****************************************************************************
     1890//*****************************************************************************
     1891unsigned ParseNopPause(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    19281892{
    19291893    unsigned size = 0;
     
    19381902        pOp = &g_aMapX86_NopPause[0]; /* NOP */
    19391903
    1940     size += ParseInstruction(pu8CodeBlock, pOp, pCpu);
    1941     return size;
    1942 }
    1943 //*****************************************************************************
    1944 //*****************************************************************************
    1945 unsigned ParseImmGrpl(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     1904    size += ParseInstruction(uCodePtr, pOp, pCpu);
     1905    return size;
     1906}
     1907//*****************************************************************************
     1908//*****************************************************************************
     1909unsigned ParseImmGrpl(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    19461910{
    19471911    int idx = (pCpu->opcode - 0x80) * 8;
     
    19491913    NOREF(pParam);
    19501914
    1951     modrm = DISReadByte(pCpu, lpszCodeBlock);
     1915    modrm = DISReadByte(pCpu, uCodePtr);
    19521916    reg   = MODRM_REG(modrm);
    19531917
     
    19571921        size = sizeof(uint8_t); //ModRM byte
    19581922
    1959     size += ParseInstruction(lpszCodeBlock, pOp, pCpu);
    1960 
    1961     return size;
    1962 }
    1963 //*****************************************************************************
    1964 //*****************************************************************************
    1965 unsigned ParseShiftGrp2(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     1923    size += ParseInstruction(uCodePtr, pOp, pCpu);
     1924
     1925    return size;
     1926}
     1927//*****************************************************************************
     1928//*****************************************************************************
     1929unsigned ParseShiftGrp2(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    19661930{
    19671931    int idx;
     
    19881952    }
    19891953
    1990     modrm = DISReadByte(pCpu, lpszCodeBlock);
     1954    modrm = DISReadByte(pCpu, uCodePtr);
    19911955    reg   = MODRM_REG(modrm);
    19921956
     
    19971961        size = sizeof(uint8_t); //ModRM byte
    19981962
    1999     size += ParseInstruction(lpszCodeBlock, pOp, pCpu);
    2000 
    2001     return size;
    2002 }
    2003 //*****************************************************************************
    2004 //*****************************************************************************
    2005 unsigned ParseGrp3(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     1963    size += ParseInstruction(uCodePtr, pOp, pCpu);
     1964
     1965    return size;
     1966}
     1967//*****************************************************************************
     1968//*****************************************************************************
     1969unsigned ParseGrp3(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    20061970{
    20071971    int idx = (pCpu->opcode - 0xF6) * 8;
     
    20091973    NOREF(pParam);
    20101974
    2011     modrm = DISReadByte(pCpu, lpszCodeBlock);
     1975    modrm = DISReadByte(pCpu, uCodePtr);
    20121976    reg   = MODRM_REG(modrm);
    20131977
     
    20181982        size = sizeof(uint8_t); //ModRM byte
    20191983
    2020     size += ParseInstruction(lpszCodeBlock, pOp, pCpu);
    2021 
    2022     return size;
    2023 }
    2024 //*****************************************************************************
    2025 //*****************************************************************************
    2026 unsigned ParseGrp4(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     1984    size += ParseInstruction(uCodePtr, pOp, pCpu);
     1985
     1986    return size;
     1987}
     1988//*****************************************************************************
     1989//*****************************************************************************
     1990unsigned ParseGrp4(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    20271991{
    20281992    unsigned size = 0, modrm, reg;
    20291993    NOREF(pParam);
    20301994
    2031     modrm = DISReadByte(pCpu, lpszCodeBlock);
     1995    modrm = DISReadByte(pCpu, uCodePtr);
    20321996    reg   = MODRM_REG(modrm);
    20331997
     
    20382002        size = sizeof(uint8_t); //ModRM byte
    20392003
    2040     size += ParseInstruction(lpszCodeBlock, pOp, pCpu);
    2041 
    2042     return size;
    2043 }
    2044 //*****************************************************************************
    2045 //*****************************************************************************
    2046 unsigned ParseGrp5(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     2004    size += ParseInstruction(uCodePtr, pOp, pCpu);
     2005
     2006    return size;
     2007}
     2008//*****************************************************************************
     2009//*****************************************************************************
     2010unsigned ParseGrp5(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    20472011{
    20482012    unsigned size = 0, modrm, reg;
    20492013    NOREF(pParam);
    20502014
    2051     modrm = DISReadByte(pCpu, lpszCodeBlock);
     2015    modrm = DISReadByte(pCpu, uCodePtr);
    20522016    reg   = MODRM_REG(modrm);
    20532017
     
    20582022        size = sizeof(uint8_t); //ModRM byte
    20592023
    2060     size += ParseInstruction(lpszCodeBlock, pOp, pCpu);
     2024    size += ParseInstruction(uCodePtr, pOp, pCpu);
    20612025
    20622026    return size;
     
    20682032//
    20692033//*****************************************************************************
    2070 unsigned Parse3DNow(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     2034unsigned Parse3DNow(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    20712035{
    20722036    unsigned size = 0, modrmsize;
     
    20772041#endif
    20782042
    2079     unsigned ModRM = DISReadByte(pCpu, lpszCodeBlock);
     2043    unsigned ModRM = DISReadByte(pCpu, uCodePtr);
    20802044    pCpu->ModRM.Bits.Rm  = MODRM_RM(ModRM);
    20812045    pCpu->ModRM.Bits.Mod = MODRM_MOD(ModRM);
    20822046    pCpu->ModRM.Bits.Reg = MODRM_REG(ModRM);
    20832047
    2084     modrmsize = QueryModRM(lpszCodeBlock+sizeof(uint8_t), pOp, pParam, pCpu);
    2085 
    2086     uint8_t opcode = DISReadByte(pCpu, lpszCodeBlock+sizeof(uint8_t)+modrmsize);
     2048    modrmsize = QueryModRM(uCodePtr+sizeof(uint8_t), pOp, pParam, pCpu);
     2049
     2050    uint8_t opcode = DISReadByte(pCpu, uCodePtr+sizeof(uint8_t)+modrmsize);
    20872051
    20882052    pOp = (PCOPCODE)&g_aTwoByteMapX86_3DNow[opcode];
     
    20972061    }
    20982062
    2099     size += ParseInstruction(lpszCodeBlock, pOp, pCpu);
     2063    size += ParseInstruction(uCodePtr, pOp, pCpu);
    21002064    size += sizeof(uint8_t);   //imm8_opcode uint8_t
    21012065
     
    21042068//*****************************************************************************
    21052069//*****************************************************************************
    2106 unsigned ParseGrp6(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     2070unsigned ParseGrp6(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    21072071{
    21082072    unsigned size = 0, modrm, reg;
    21092073    NOREF(pParam);
    21102074
    2111     modrm = DISReadByte(pCpu, lpszCodeBlock);
     2075    modrm = DISReadByte(pCpu, uCodePtr);
    21122076    reg   = MODRM_REG(modrm);
    21132077
     
    21182082        size = sizeof(uint8_t); //ModRM byte
    21192083
    2120     size += ParseInstruction(lpszCodeBlock, pOp, pCpu);
    2121 
    2122     return size;
    2123 }
    2124 //*****************************************************************************
    2125 //*****************************************************************************
    2126 unsigned ParseGrp7(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     2084    size += ParseInstruction(uCodePtr, pOp, pCpu);
     2085
     2086    return size;
     2087}
     2088//*****************************************************************************
     2089//*****************************************************************************
     2090unsigned ParseGrp7(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    21272091{
    21282092    unsigned size = 0, modrm, reg, rm, mod;
    21292093    NOREF(pParam);
    21302094
    2131     modrm = DISReadByte(pCpu, lpszCodeBlock);
     2095    modrm = DISReadByte(pCpu, uCodePtr);
    21322096    mod   = MODRM_MOD(modrm);
    21332097    reg   = MODRM_REG(modrm);
     
    21462110        size = sizeof(uint8_t); //ModRM byte
    21472111
    2148     size += ParseInstruction(lpszCodeBlock, pOp, pCpu);
    2149 
    2150     return size;
    2151 }
    2152 //*****************************************************************************
    2153 //*****************************************************************************
    2154 unsigned ParseGrp8(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     2112    size += ParseInstruction(uCodePtr, pOp, pCpu);
     2113
     2114    return size;
     2115}
     2116//*****************************************************************************
     2117//*****************************************************************************
     2118unsigned ParseGrp8(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    21552119{
    21562120    unsigned size = 0, modrm, reg;
    21572121    NOREF(pParam);
    21582122
    2159     modrm = DISReadByte(pCpu, lpszCodeBlock);
     2123    modrm = DISReadByte(pCpu, uCodePtr);
    21602124    reg   = MODRM_REG(modrm);
    21612125
     
    21662130        size = sizeof(uint8_t); //ModRM byte
    21672131
    2168     size += ParseInstruction(lpszCodeBlock, pOp, pCpu);
    2169 
    2170     return size;
    2171 }
    2172 //*****************************************************************************
    2173 //*****************************************************************************
    2174 unsigned ParseGrp9(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     2132    size += ParseInstruction(uCodePtr, pOp, pCpu);
     2133
     2134    return size;
     2135}
     2136//*****************************************************************************
     2137//*****************************************************************************
     2138unsigned ParseGrp9(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    21752139{
    21762140    unsigned size = 0, modrm, reg;
    21772141    NOREF(pParam);
    21782142
    2179     modrm = DISReadByte(pCpu, lpszCodeBlock);
     2143    modrm = DISReadByte(pCpu, uCodePtr);
    21802144    reg   = MODRM_REG(modrm);
    21812145
     
    21862150        size = sizeof(uint8_t); //ModRM byte
    21872151
    2188     size += ParseInstruction(lpszCodeBlock, pOp, pCpu);
    2189 
    2190     return size;
    2191 }
    2192 //*****************************************************************************
    2193 //*****************************************************************************
    2194 unsigned ParseGrp10(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     2152    size += ParseInstruction(uCodePtr, pOp, pCpu);
     2153
     2154    return size;
     2155}
     2156//*****************************************************************************
     2157//*****************************************************************************
     2158unsigned ParseGrp10(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    21952159{
    21962160    unsigned size = 0, modrm, reg;
    21972161    NOREF(pParam);
    21982162
    2199     modrm = DISReadByte(pCpu, lpszCodeBlock);
     2163    modrm = DISReadByte(pCpu, uCodePtr);
    22002164    reg   = MODRM_REG(modrm);
    22012165
     
    22062170        size = sizeof(uint8_t); //ModRM byte
    22072171
    2208     size += ParseInstruction(lpszCodeBlock, pOp, pCpu);
    2209 
    2210     return size;
    2211 }
    2212 //*****************************************************************************
    2213 //*****************************************************************************
    2214 unsigned ParseGrp12(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     2172    size += ParseInstruction(uCodePtr, pOp, pCpu);
     2173
     2174    return size;
     2175}
     2176//*****************************************************************************
     2177//*****************************************************************************
     2178unsigned ParseGrp12(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    22152179{
    22162180    unsigned size = 0, modrm, reg;
    22172181    NOREF(pParam);
    22182182
    2219     modrm = DISReadByte(pCpu, lpszCodeBlock);
     2183    modrm = DISReadByte(pCpu, uCodePtr);
    22202184    reg   = MODRM_REG(modrm);
    22212185
     
    22292193        size = sizeof(uint8_t); //ModRM byte
    22302194
    2231     size += ParseInstruction(lpszCodeBlock, pOp, pCpu);
    2232     return size;
    2233 }
    2234 //*****************************************************************************
    2235 //*****************************************************************************
    2236 unsigned ParseGrp13(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     2195    size += ParseInstruction(uCodePtr, pOp, pCpu);
     2196    return size;
     2197}
     2198//*****************************************************************************
     2199//*****************************************************************************
     2200unsigned ParseGrp13(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    22372201{
    22382202    unsigned size = 0, modrm, reg;
    22392203    NOREF(pParam);
    22402204
    2241     modrm = DISReadByte(pCpu, lpszCodeBlock);
     2205    modrm = DISReadByte(pCpu, uCodePtr);
    22422206    reg   = MODRM_REG(modrm);
    22432207    if (pCpu->prefix & PREFIX_OPSIZE)
     
    22502214        size = sizeof(uint8_t); //ModRM byte
    22512215
    2252     size += ParseInstruction(lpszCodeBlock, pOp, pCpu);
    2253 
    2254     return size;
    2255 }
    2256 //*****************************************************************************
    2257 //*****************************************************************************
    2258 unsigned ParseGrp14(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     2216    size += ParseInstruction(uCodePtr, pOp, pCpu);
     2217
     2218    return size;
     2219}
     2220//*****************************************************************************
     2221//*****************************************************************************
     2222unsigned ParseGrp14(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    22592223{
    22602224    unsigned size = 0, modrm, reg;
    22612225    NOREF(pParam);
    22622226
    2263     modrm = DISReadByte(pCpu, lpszCodeBlock);
     2227    modrm = DISReadByte(pCpu, uCodePtr);
    22642228    reg   = MODRM_REG(modrm);
    22652229    if (pCpu->prefix & PREFIX_OPSIZE)
     
    22722236        size = sizeof(uint8_t); //ModRM byte
    22732237
    2274     size += ParseInstruction(lpszCodeBlock, pOp, pCpu);
    2275 
    2276     return size;
    2277 }
    2278 //*****************************************************************************
    2279 //*****************************************************************************
    2280 unsigned ParseGrp15(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     2238    size += ParseInstruction(uCodePtr, pOp, pCpu);
     2239
     2240    return size;
     2241}
     2242//*****************************************************************************
     2243//*****************************************************************************
     2244unsigned ParseGrp15(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    22812245{
    22822246    unsigned size = 0, modrm, reg, mod, rm;
    22832247    NOREF(pParam);
    22842248
    2285     modrm = DISReadByte(pCpu, lpszCodeBlock);
     2249    modrm = DISReadByte(pCpu, uCodePtr);
    22862250    mod   = MODRM_MOD(modrm);
    22872251    reg   = MODRM_REG(modrm);
     
    22972261        size = sizeof(uint8_t); //ModRM byte
    22982262
    2299     size += ParseInstruction(lpszCodeBlock, pOp, pCpu);
    2300     return size;
    2301 }
    2302 //*****************************************************************************
    2303 //*****************************************************************************
    2304 unsigned ParseGrp16(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
     2263    size += ParseInstruction(uCodePtr, pOp, pCpu);
     2264    return size;
     2265}
     2266//*****************************************************************************
     2267//*****************************************************************************
     2268unsigned ParseGrp16(RTUINTPTR uCodePtr, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    23052269{
    23062270    unsigned size = 0, modrm, reg;
    23072271    NOREF(pParam);
    23082272
    2309     modrm = DISReadByte(pCpu, lpszCodeBlock);
     2273    modrm = DISReadByte(pCpu, uCodePtr);
    23102274    reg   = MODRM_REG(modrm);
    23112275
     
    23162280        size = sizeof(uint8_t); //ModRM byte
    23172281
    2318     size += ParseInstruction(lpszCodeBlock, pOp, pCpu);
     2282    size += ParseInstruction(uCodePtr, pOp, pCpu);
    23192283    return size;
    23202284}
     
    23312295static const int   IndexModRMReg16[4] = { USE_REG_SI, USE_REG_DI, USE_REG_SI, USE_REG_DI};
    23322296//*****************************************************************************
    2333 void disasmModRMReg(PDISCPUSTATE pCpu, PCOPCODE pOp, unsigned idx, POP_PARAMETER pParam, int fRegAddr)
     2297static void disasmModRMReg(PDISCPUSTATE pCpu, PCOPCODE pOp, unsigned idx, POP_PARAMETER pParam, int fRegAddr)
    23342298{
    23352299    int subtype, type, mod;
     
    23752339            idx += (USE_REG_SPL - USE_REG_AH);
    23762340        }
    2377         disasmAddString(pParam->szParam, szModRMReg8[idx]);
    23782341
    23792342        pParam->flags |= USE_REG_GEN8;
     
    23822345
    23832346    case OP_PARM_w:
    2384         disasmAddString(pParam->szParam, szModRMReg16[idx]);
    23852347        Assert(idx < (pCpu->prefix & PREFIX_REX) ? 16 : 8);
    23862348
     
    23902352
    23912353    case OP_PARM_d:
    2392         disasmAddString(pParam->szParam, szModRMReg32[idx]);
    23932354        Assert(idx < (pCpu->prefix & PREFIX_REX) ? 16 : 8);
    23942355
     
    23982359
    23992360    case OP_PARM_q:
    2400         disasmAddString(pParam->szParam, szModRMReg64[idx]);
    24012361        pParam->flags |= USE_REG_GEN64;
    24022362        pParam->base.reg_gen = idx;
     
    24112371//*****************************************************************************
    24122372//*****************************************************************************
    2413 void disasmModRMReg16(PDISCPUSTATE pCpu, PCOPCODE pOp, unsigned idx, POP_PARAMETER pParam)
     2373static void disasmModRMReg16(PDISCPUSTATE pCpu, PCOPCODE pOp, unsigned idx, POP_PARAMETER pParam)
    24142374{
    24152375    NOREF(pCpu); NOREF(pOp);
    2416     disasmAddString(pParam->szParam, szModRMReg1616[idx]);
    24172376    pParam->flags |= USE_REG_GEN16;
    24182377    pParam->base.reg_gen = BaseModRMReg16[idx];
     
    24252384//*****************************************************************************
    24262385//*****************************************************************************
    2427 void disasmModRMSReg(PDISCPUSTATE pCpu, PCOPCODE pOp, unsigned idx, POP_PARAMETER pParam)
     2386static void disasmModRMSReg(PDISCPUSTATE pCpu, PCOPCODE pOp, unsigned idx, POP_PARAMETER pParam)
    24282387{
    24292388    NOREF(pOp);
     
    24352394    }
    24362395
    2437     disasmAddString(pParam->szParam, szModRMSegReg[idx]);
    24382396    pParam->flags |= USE_REG_SEG;
    24392397    pParam->base.reg_seg = (DIS_SELREG)idx;
    2440 }
    2441 //*****************************************************************************
    2442 //*****************************************************************************
    2443 void disasmPrintAbs32(POP_PARAMETER pParam)
    2444 {
    2445     disasmAddStringF1(pParam->szParam, "%08Xh", pParam->uDisp.i32); NOREF(pParam);
    2446 }
    2447 //*****************************************************************************
    2448 //*****************************************************************************
    2449 void disasmPrintDisp32(POP_PARAMETER pParam)
    2450 {
    2451     disasmAddStringF1(pParam->szParam, "%08Xh", pParam->uDisp.i32); NOREF(pParam);
    2452 }
    2453 //*****************************************************************************
    2454 //*****************************************************************************
    2455 void disasmPrintDisp64(POP_PARAMETER pParam)
    2456 {
    2457     disasmAddStringF1(pParam->szParam, "%16RX64h", pParam->uDisp.i64); NOREF(pParam);
    2458 }
    2459 //*****************************************************************************
    2460 //*****************************************************************************
    2461 void disasmPrintDisp8(POP_PARAMETER pParam)
    2462 {
    2463     disasmAddStringF1(pParam->szParam, "%d", pParam->uDisp.i8); NOREF(pParam);
    2464 }
    2465 //*****************************************************************************
    2466 //*****************************************************************************
    2467 void disasmPrintDisp16(POP_PARAMETER pParam)
    2468 {
    2469     disasmAddStringF1(pParam->szParam, "%04Xh", pParam->uDisp.i16); NOREF(pParam);
    2470 }
    2471 //*****************************************************************************
    2472 //*****************************************************************************
    2473 void disasmGetPtrString(PDISCPUSTATE pCpu, PCOPCODE pOp, POP_PARAMETER pParam)
    2474 {
    2475     int subtype = OP_PARM_VSUBTYPE(pParam->param);
    2476     NOREF(pOp);
    2477 
    2478     if (subtype == OP_PARM_v)
    2479     {
    2480         switch(pCpu->opmode)
    2481         {
    2482         case CPUMODE_32BIT:
    2483             subtype = OP_PARM_d;
    2484             break;
    2485         case CPUMODE_64BIT:
    2486             subtype = OP_PARM_q;
    2487             break;
    2488         case CPUMODE_16BIT:
    2489             subtype = OP_PARM_w;
    2490             break;
    2491         default:
    2492             /* make gcc happy */
    2493             break;
    2494         }
    2495     }
    2496 
    2497     switch (subtype)
    2498     {
    2499     case OP_PARM_a: //two words or dwords depending on operand size (bound only)
    2500         break;
    2501 
    2502     case OP_PARM_b:
    2503         disasmAddString(pParam->szParam, "byte ptr ");
    2504         break;
    2505 
    2506     case OP_PARM_w:
    2507         disasmAddString(pParam->szParam, "word ptr ");
    2508         break;
    2509 
    2510     case OP_PARM_d:
    2511         disasmAddString(pParam->szParam, "dword ptr ");
    2512         break;
    2513 
    2514     case OP_PARM_q:
    2515     case OP_PARM_dq:
    2516         disasmAddString(pParam->szParam, "qword ptr ");
    2517         break;
    2518 
    2519     case OP_PARM_p:
    2520         disasmAddString(pParam->szParam, "far ptr ");
    2521         break;
    2522 
    2523     case OP_PARM_s:
    2524         break; //??
    2525 
    2526     case OP_PARM_z:
    2527         break;
    2528     default:
    2529         break; //no pointer type specified/necessary
    2530     }
    2531     if (pCpu->prefix & PREFIX_SEG)
    2532         disasmAddStringF1(pParam->szParam, "%s:", szModRMSegReg[pCpu->enmPrefixSeg]);
    25332398}
    25342399
     
    27222587    return uTemp.u;
    27232588}
    2724 
    2725 #if !defined(DIS_CORE_ONLY) && defined(LOG_ENABLED)
    2726 //*****************************************************************************
    2727 //*****************************************************************************
    2728 void disasmAddString(char *psz, const char *pszAdd)
    2729 {
    2730     strcat(psz, pszAdd);
    2731 }
    2732 //*****************************************************************************
    2733 //*****************************************************************************
    2734 void disasmAddStringF(char *psz, const char *pszFormat, ...)
    2735 {
    2736     va_list args;
    2737     va_start(args, pszFormat);
    2738     size_t  cchCur = strlen(psz);
    2739     Assert(cchCur < RT_SIZEOFMEMB(OP_PARAMETER, szParam));
    2740     RTStrPrintfV(psz + cchCur, RT_SIZEOFMEMB(OP_PARAMETER, szParam) - cchCur,
    2741                  pszFormat, args);
    2742     va_end(args);
    2743 }
    2744 
    2745 //*****************************************************************************
    2746 //*****************************************************************************
    2747 void disasmAddChar(char *psz, char ch)
    2748 {
    2749     char sz[2];
    2750 
    2751     sz[0] = ch;
    2752     sz[1] = '\0';
    2753     strcat(psz, sz);
    2754 }
    2755 #endif /* !DIS_CORE_ONLY */
    27562589
    27572590
  • trunk/src/VBox/Disassembler/DisasmFormatYasm.cpp

    r41666 r41668  
    348348    {
    349349#if HC_ARCH_BITS == 64 || GC_ARCH_BITS == 64
    350         if (pCpu->opaddr >= _4G)
    351             PUT_NUM(9, "%08x`", (uint32_t)(pCpu->opaddr >> 32));
     350        if (pCpu->uInstrAddr >= _4G)
     351            PUT_NUM(9, "%08x`", (uint32_t)(pCpu->uInstrAddr >> 32));
    352352#endif
    353         PUT_NUM(8, "%08x", (uint32_t)pCpu->opaddr);
     353        PUT_NUM(8, "%08x", (uint32_t)pCpu->uInstrAddr);
    354354        PUT_C(' ');
    355355    }
     
    896896                            PUT_SZ(" (");
    897897
    898                         RTUINTPTR uTrgAddr = pCpu->opaddr + pCpu->opsize + offDisplacement;
     898                        RTUINTPTR uTrgAddr = pCpu->uInstrAddr + pCpu->opsize + offDisplacement;
    899899                        if (pCpu->mode == CPUMODE_16BIT)
    900900                            PUT_NUM_16(uTrgAddr);
     
    11321132            PUT_C(' ');
    11331133#if HC_ARCH_BITS == 64 || GC_ARCH_BITS == 64
    1134             if (pCpu->opaddr >= _4G)
    1135                 PUT_NUM(9, "%08x`", (uint32_t)(pCpu->opaddr >> 32));
     1134            if (pCpu->uInstrAddr >= _4G)
     1135                PUT_NUM(9, "%08x`", (uint32_t)(pCpu->uInstrAddr >> 32));
    11361136#endif
    1137             PUT_NUM(8, "%08x", (uint32_t)pCpu->opaddr);
     1137            PUT_NUM(8, "%08x", (uint32_t)pCpu->uInstrAddr);
    11381138        }
    11391139
  • trunk/src/VBox/Disassembler/DisasmInternal.h

    r41658 r41668  
     1/* $Id$ */
    12/** @file
    2  *
    3  * VBox disassembler:
    4  * Internal header
     3 * VBox disassembler - Internal header.
    54 */
    65
    76/*
    8  * Copyright (C) 2006-2007 Oracle Corporation
     7 * Copyright (C) 2006-2012 Oracle Corporation
    98 *
    109 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2019#define ___DisasmInternal_h___
    2120
    22 #include <VBox/cdefs.h>
    2321#include <VBox/types.h>
    2422#include <VBox/dis.h>
     
    7270
    7371
    74 extern PFNDISPARSE  pfnFullDisasm[IDX_ParseMax];
    75 extern PFNDISPARSE  pfnCalcSize[IDX_ParseMax];
    76 
     72extern PFNDISPARSE  g_apfnFullDisasm[IDX_ParseMax];
     73extern PFNDISPARSE  g_apfnCalcSize[IDX_ParseMax];
    7774
    7875unsigned ParseInstruction(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, PDISCPUSTATE pCpu);
    79 
    80 unsigned ParseIllegal(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    81 unsigned ParseModRM(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    82 unsigned ParseModRM_SizeOnly(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    83 unsigned UseModRM(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    84 unsigned ParseImmByte(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    85 unsigned ParseImmByte_SizeOnly(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    86 unsigned ParseImmByteSX(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    87 unsigned ParseImmByteSX_SizeOnly(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    88 unsigned ParseImmBRel(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    89 unsigned ParseImmBRel_SizeOnly(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    90 unsigned ParseImmUshort(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    91 unsigned ParseImmUshort_SizeOnly(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    92 unsigned ParseImmV(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    93 unsigned ParseImmV_SizeOnly(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    94 unsigned ParseImmVRel(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    95 unsigned ParseImmVRel_SizeOnly(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    96 unsigned ParseImmZ(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    97 unsigned ParseImmZ_SizeOnly(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    98 
    99 unsigned ParseImmAddr(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    100 unsigned ParseImmAddr_SizeOnly(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    101 unsigned ParseImmAddrF(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    102 unsigned ParseImmAddrF_SizeOnly(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    103 unsigned ParseFixedReg(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    104 unsigned ParseImmUlong(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    105 unsigned ParseImmUlong_SizeOnly(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    106 unsigned ParseImmQword(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    107 unsigned ParseImmQword_SizeOnly(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    108 
    109 unsigned ParseTwoByteEsc(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    110 unsigned ParseThreeByteEsc4(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    111 unsigned ParseThreeByteEsc5(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    112 unsigned ParseImmGrpl(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    113 unsigned ParseShiftGrp2(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    114 unsigned ParseGrp3(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    115 unsigned ParseGrp4(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    116 unsigned ParseGrp5(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    117 unsigned Parse3DNow(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    118 unsigned ParseGrp6(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    119 unsigned ParseGrp7(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    120 unsigned ParseGrp8(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    121 unsigned ParseGrp9(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    122 unsigned ParseGrp10(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    123 unsigned ParseGrp12(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    124 unsigned ParseGrp13(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    125 unsigned ParseGrp14(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    126 unsigned ParseGrp15(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    127 unsigned ParseGrp16(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    128 unsigned ParseModFence(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    129 unsigned ParseNopPause(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    130 
    131 unsigned ParseYv(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    132 unsigned ParseYb(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    133 unsigned ParseXv(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    134 unsigned ParseXb(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    135 
    136 /* Floating point parsing */
    137 unsigned ParseEscFP(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu);
    138 
    13976void disValidateLockSequence(PDISCPUSTATE pCpu);
    140 
    141 /* Disassembler printf */
    142 void disasmSprintf(char *pszOutput, RTUINTPTR pu8Instruction, PDISCPUSTATE pCpu, POP_PARAMETER pParam1, POP_PARAMETER pParam2, POP_PARAMETER pParam3 = NULL);
    143 void disasmGetPtrString(PDISCPUSTATE pCpu, PCOPCODE pOp, POP_PARAMETER pParam);
    144 void disasmModRMReg(PDISCPUSTATE pCpu, PCOPCODE pOp, unsigned idx, POP_PARAMETER pParam, int fRegAddr);
    145 void disasmModRMReg16(PDISCPUSTATE pCpu, PCOPCODE pOp, unsigned idx, POP_PARAMETER pParam);
    146 void disasmModRMSReg(PDISCPUSTATE pCpu, PCOPCODE pOp, unsigned idx, POP_PARAMETER pParam);
    147 void disasmPrintAbs32(POP_PARAMETER pParam);
    148 void disasmPrintDisp32(POP_PARAMETER pParam);
    149 void disasmPrintDisp64(POP_PARAMETER pParam);
    150 void disasmPrintDisp8(POP_PARAMETER pParam);
    151 void disasmPrintDisp16(POP_PARAMETER pParam);
    152 
    15377
    15478/* Read functions */
     
    16185size_t disFormatBytes(PCDISCPUSTATE pCpu, char *pszDst, size_t cchDst, uint32_t fFlags);
    16286
    163 #endif /* !___DisasmInternal_h___ */
     87#endif
    16488
  • trunk/src/VBox/Disassembler/DisasmReg.cpp

    r41663 r41668  
     1/* $Id$ */
    12/** @file
    2  *
    3  * VBox disassembler:
    4  * Core components
     3 * VBox disassembler- Register Info Helpers.
    54 */
    65
    76/*
    8  * Copyright (C) 2006-2007 Oracle Corporation
     7 * Copyright (C) 2006-2012 Oracle Corporation
    98 *
    109 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2221*******************************************************************************/
    2322#define LOG_GROUP LOG_GROUP_DIS
    24 #ifdef USING_VISUAL_STUDIO
    25 # include <stdafx.h>
    26 #endif
    27 
    2823#include <VBox/dis.h>
    2924#include <VBox/disopcode.h>
     
    3631#include "DisasmInternal.h"
    3732#include "DisasmTables.h"
    38 
    39 #if !defined(DIS_CORE_ONLY) && defined(LOG_ENABLED)
    40 # include <stdlib.h>
    41 # include <stdio.h>
    42 #endif
    4333
    4434
     
    825815    return VERR_INVALID_PARAMETER;
    826816}
    827 //*****************************************************************************
    828 //*****************************************************************************
     817
  • trunk/src/VBox/Disassembler/DisasmTables.cpp

    r40577 r41668  
     1/* $Id$ */
    12/** @file
    2  * VBox disassembler - Tables.
     3 * VBox disassembler - Tables for X86 (32-bit and 16-bit modes).
    34 */
    45
    56/*
    6  * Copyright (C) 2006-2011 Oracle Corporation
     7 * Copyright (C) 2006-2012 Oracle Corporation
    78 *
    89 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1920*   Header Files                                                               *
    2021*******************************************************************************/
    21 #ifdef USING_VISUAL_STUDIO
    22 # include <stdafx.h>
    23 #endif
    2422#include <VBox/dis.h>
    2523#include <VBox/disopcode.h>
     
    2725#include "DisasmInternal.h"
    2826
    29 
    30 /** @def O
    31  * Wrapper which initializes an OPCODE.
    32  * We must use this so that we can exclude unused fields in order
    33  * to save precious bytes in the GC version.
    34  *
    35  * @internal
    36  */
    37 #ifndef DIS_CORE_ONLY
    38 # define OP(pszOpcode, idxParse1, idxParse2, idxParse3, opcode, param1, param2, param3, optype) \
    39     { pszOpcode, idxParse1, idxParse2, idxParse3, opcode, param1, param2, param3, optype }
    40 #else
    41 # define OP(pszOpcode, idxParse1, idxParse2, idxParse3, opcode, param1, param2, param3, optype) \
    42     { idxParse1, idxParse2, idxParse3, opcode, param1, param2, param3, optype }
    43 #endif
    4427
    4528//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  • trunk/src/VBox/Disassembler/DisasmTables.h

    r28800 r41668  
     1/* $Id$ */
    12/** @file
    2  *
    3  * VBox disassembler:
    4  * Tables.header
     3 * VBox disassembler - Tables Header.
    54 */
    65
    76/*
    8  * Copyright (C) 2006-2007 Oracle Corporation
     7 * Copyright (C) 2006-2012 Oracle Corporation
    98 *
    109 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1716 */
    1817
    19 #ifndef __disasmtable_h__
    20 #define __disasmtable_h__
     18#ifndef ___disasmtable_h___
     19#define ___disasmtable_h___
    2120
    2221#include <VBox/dis.h>
     
    9998/** @} */
    10099
    101 #endif /* !__disasmtable_h__ */
     100/** @def OP
     101 * Wrapper which initializes an OPCODE.
     102 * We must use this so that we can exclude unused fields in order
     103 * to save precious bytes in the GC version.
     104 *
     105 * @internal
     106 */
     107#ifndef DIS_CORE_ONLY
     108# define OP(pszOpcode, idxParse1, idxParse2, idxParse3, opcode, param1, param2, param3, optype) \
     109    { pszOpcode, idxParse1, idxParse2, idxParse3, opcode, param1, param2, param3, optype }
     110#else
     111# define OP(pszOpcode, idxParse1, idxParse2, idxParse3, opcode, param1, param2, param3, optype) \
     112    { idxParse1, idxParse2, idxParse3, opcode, param1, param2, param3, optype }
     113#endif
    102114
     115#endif
     116
  • trunk/src/VBox/Disassembler/DisasmTablesX64.cpp

    r38733 r41668  
     1/* $Id$ */
    12/** @file
    2  * VBox disassembler - Tables for AMD64 (long mode).
     3 * VBox disassembler - Tables for AMD64 (64-bit mode).
    34 */
    45
    56/*
    6  * Copyright (C) 2006-2011 Oracle Corporation
     7 * Copyright (C) 2006-2012 Oracle Corporation
    78 *
    89 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1920*   Header Files                                                               *
    2021*******************************************************************************/
    21 #ifdef USING_VISUAL_STUDIO
    22 # include <stdafx.h>
    23 #endif
    2422#include <VBox/dis.h>
    2523#include <VBox/disopcode.h>
     
    2725#include "DisasmInternal.h"
    2826
    29 
    30 /** @def O
    31  * Wrapper which initializes an OPCODE.
    32  * We must use this so that we can exclude unused fields in order
    33  * to save precious bytes in the GC version.
    34  *
    35  * @internal
    36  */
    37 #ifndef DIS_CORE_ONLY
    38 # define OP(pszOpcode, idxParse1, idxParse2, idxParse3, opcode, param1, param2, param3, optype) \
    39     { pszOpcode, idxParse1, idxParse2, idxParse3, opcode, param1, param2, param3, optype }
    40 #else
    41 # define OP(pszOpcode, idxParse1, idxParse2, idxParse3, opcode, param1, param2, param3, optype) \
    42     { idxParse1, idxParse2, idxParse3, opcode, param1, param2, param3, optype }
    43 #endif
    4427
    4528//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  • trunk/src/VBox/Disassembler/DisasmTestCore.cpp

    r41658 r41668  
    3939        unsigned    cb;
    4040        DISCPUSTATE cpu;
    41         if (DISCoreOneEx((uintptr_t)&DISCoreOneEx, CPUMODE_32BIT, NULL /*pfnReadBytes*/, NULL /*pvUser*/, &cpu, &cb))
     41        if (DISCoreOne((uintptr_t)&DISCoreOne, CPUMODE_32BIT, &cpu, &cb))
    4242            printf("ok %d\n", cpu.addrmode);
    4343        else
  • trunk/src/VBox/Disassembler/testcase/tstDisasm-2.cpp

    r41658 r41668  
    103103#endif
    104104
    105     RTPrintf("    %s ; %08llu %s", szTmp, pState->uAddress, pState->szLine);
     105    RTPrintf("    %s ; %s", szTmp, pState->szLine);
    106106}
    107107
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