VirtualBox

Changeset 103611 in vbox for trunk/include


Ignore:
Timestamp:
Feb 29, 2024 11:26:29 AM (15 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
161969
Message:

ValKit/bs3-cpu-instr-2: Test the alternate reg/reg encoding of and, or, xor, add, adc, sub, sbb and cmp. Extended x86extra.mac with macros for manually encoding reg/reg instructions like this. bugref:10376

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/x86extra.mac

    r98103 r103611  
    222222
    223223
     224;; @name Helper values for the X86_MKOP_XXX macros.
     225;; @{
     226%define X86_MKOP_GREG8_al     0
     227%define X86_MKOP_GREG8_cl     1
     228%define X86_MKOP_GREG8_dl     2
     229%define X86_MKOP_GREG8_bl     3
     230%define X86_MKOP_GREG8_ah     4
     231%define X86_MKOP_GREG8_ch     5
     232%define X86_MKOP_GREG8_dh     6
     233%define X86_MKOP_GREG8_bh     7
     234%define X86_MKOP_GREG8_spl   20
     235%define X86_MKOP_GREG8_bpl   21
     236%define X86_MKOP_GREG8_sil   22
     237%define X86_MKOP_GREG8_dil   23
     238%define X86_MKOP_GREG8_r8b    8
     239%define X86_MKOP_GREG8_r9b    9
     240%define X86_MKOP_GREG8_r10b  10
     241%define X86_MKOP_GREG8_r11b  11
     242%define X86_MKOP_GREG8_r12b  12
     243%define X86_MKOP_GREG8_r13b  13
     244%define X86_MKOP_GREG8_r14b  14
     245%define X86_MKOP_GREG8_r15b  15
     246
     247%define X86_MKOP_GREG16_ax    0
     248%define X86_MKOP_GREG16_cx    1
     249%define X86_MKOP_GREG16_dx    2
     250%define X86_MKOP_GREG16_bx    3
     251%define X86_MKOP_GREG16_sp    4
     252%define X86_MKOP_GREG16_bp    5
     253%define X86_MKOP_GREG16_si    6
     254%define X86_MKOP_GREG16_di    7
     255%define X86_MKOP_GREG16_r8w   8
     256%define X86_MKOP_GREG16_r9w   9
     257%define X86_MKOP_GREG16_r10w 10
     258%define X86_MKOP_GREG16_r11w 11
     259%define X86_MKOP_GREG16_r12w 12
     260%define X86_MKOP_GREG16_r13w 13
     261%define X86_MKOP_GREG16_r14w 14
     262%define X86_MKOP_GREG16_r15w 15
     263
     264%define X86_MKOP_GREG32_eax   0
     265%define X86_MKOP_GREG32_ecx   1
     266%define X86_MKOP_GREG32_edx   2
     267%define X86_MKOP_GREG32_ebx   3
     268%define X86_MKOP_GREG32_esp   4
     269%define X86_MKOP_GREG32_ebp   5
     270%define X86_MKOP_GREG32_esi   6
     271%define X86_MKOP_GREG32_edi   7
     272%define X86_MKOP_GREG32_r8d   8
     273%define X86_MKOP_GREG32_r9d   9
     274%define X86_MKOP_GREG32_r10d 10
     275%define X86_MKOP_GREG32_r11d 11
     276%define X86_MKOP_GREG32_r12d 12
     277%define X86_MKOP_GREG32_r13d 13
     278%define X86_MKOP_GREG32_r14d 14
     279%define X86_MKOP_GREG32_r15d 15
     280
     281%define X86_MKOP_GREG64_rax   0
     282%define X86_MKOP_GREG64_rcx   1
     283%define X86_MKOP_GREG64_rdx   2
     284%define X86_MKOP_GREG64_rbx   3
     285%define X86_MKOP_GREG64_rsp   4
     286%define X86_MKOP_GREG64_rbp   5
     287%define X86_MKOP_GREG64_rsi   6
     288%define X86_MKOP_GREG64_rdi   7
     289%define X86_MKOP_GREG64_r8    8
     290%define X86_MKOP_GREG64_r9    9
     291%define X86_MKOP_GREG64_r10  10
     292%define X86_MKOP_GREG64_r11  11
     293%define X86_MKOP_GREG64_r12  12
     294%define X86_MKOP_GREG64_r13  13
     295%define X86_MKOP_GREG64_r14  14
     296%define X86_MKOP_GREG64_r15  15
     297;; @}
     298
     299;;
     300; Encodes the MODRM byte for an instruction with 8-bit operand size.
     301; @param 1     The MODRM.MOD value (X86_MOD_REG, X86_MOD_MEM0, X86_MOD_MEM1, X86_MOD_MEM4).
     302; @param 2     The MODRM.REG register mnemonic.
     303; @param 3     The MODRM.RM register mnemonic.
     304%macro X86_MKOP_MODRM8 3
     305 %assign x86_mkop_modrm8_iReg  X86_MKOP_GREG8_ %+ %2
     306 %assign x86_mkop_modrm8_iRm   X86_MKOP_GREG8_ %+ %3
     307        db      X86_MODRM_MAKE(%1, x86_mkop_modrm8_iReg & 7, x86_mkop_modrm8_iRm & 7)
     308%endmacro
     309
     310;;
     311; Encodes the optional REX prefix for an instruction with 8-bit operand size.
     312; @param 1     The MODRM.REG register mnemonic.
     313; @param 2     The MODRM.RM register mnemonic.
     314%macro X86_MKOP_REX8 2
     315 %assign x86_mkop_rex8_iReg     X86_MKOP_GREG8_ %+ %1
     316 %assign x86_mkop_rex8_iRm      X86_MKOP_GREG8_ %+ %2
     317 %if x86_mkop_rex8_iReg >= 8 || x86_mkop_rex8_iRm >= 8
     318  %if __BITS__ == 64
     319   %if (x86_mkop_rex8_iReg < 4 || x86_mkop_rex8_iReg >= 8) && (x86_mkop_rex8_iRm < 4 || x86_mkop_rex8_iRm >= 8)
     320        db      X86_OP_REX | (((x86_mkop_rex8_iReg >> 3) & 1) * X86_OP_REX_R) | (((x86_mkop_rex8_iRm >> 3) & 1) * X86_OP_REX_B)
     321   %else
     322    %error X86_MKOP_REX8: Invalid operand mix: %1, %2
     323   %endif
     324  %else
     325   %error X86_MKOP_REX8: not in 64-bit code: %1, %2
     326  %endif
     327 %endif
     328%endmacro
     329
     330
     331;;
     332; Encodes the MODRM byte for an instruction with 16-bit operand size.
     333; @param 1     The MODRM.MOD value (X86_MOD_REG, X86_MOD_MEM0, X86_MOD_MEM1, X86_MOD_MEM4).
     334; @param 2     The MODRM.REG register mnemonic.
     335; @param 3     The MODRM.RM register mnemonic.
     336%macro X86_MKOP_MODRM16 3
     337 %assign x86_mkop_modrm16_iReg  X86_MKOP_GREG16_ %+ %2
     338 %assign x86_mkop_modrm16_iRm   X86_MKOP_GREG16_ %+ %3
     339        db      X86_MODRM_MAKE(%1, x86_mkop_modrm16_iReg & 7, x86_mkop_modrm16_iRm & 7)
     340%endmacro
     341
     342;;
     343; Encodes the optional REX prefix for an instruction with 16-bit operand size.
     344; @param 1     The MODRM.REG register mnemonic.
     345; @param 2     The MODRM.RM register mnemonic.
     346%macro X86_MKOP_REX16 2
     347 %assign x86_mkop_rex16_iReg    X86_MKOP_GREG16_ %+ %1
     348 %assign x86_mkop_rex16_iRm     X86_MKOP_GREG16_ %+ %2
     349 %if x86_mkop_rex16_iReg >= 8 || x86_mkop_rex16_iRm >= 8
     350  %if __BITS__ == 64
     351        db      X86_OP_REX | ((x86_mkop_rex16_iReg >> 3) * X86_OP_REX_R) | ((x86_mkop_rex16_iRm >> 3) * X86_OP_REX_B)
     352  %else
     353   %error X86_MKOP_REX16: not in 64-bit code: %1, %2
     354  %endif
     355 %endif
     356%endmacro
     357
     358
     359;;
     360; Encodes the MODRM byte for an instruction with 32-bit operand size.
     361; @param 1     The MODRM.MOD value (X86_MOD_REG, X86_MOD_MEM0, X86_MOD_MEM1, X86_MOD_MEM4).
     362; @param 2     The MODRM.REG register mnemonic.
     363; @param 3     The MODRM.RM register mnemonic.
     364%macro X86_MKOP_MODRM32 3
     365 %assign x86_mkop_modrm32_iReg  X86_MKOP_GREG32_ %+ %2
     366 %assign x86_mkop_modrm32_iRm   X86_MKOP_GREG32_ %+ %3
     367        db      X86_MODRM_MAKE(%1, x86_mkop_modrm32_iReg & 7, x86_mkop_modrm32_iRm & 7)
     368%endmacro
     369
     370;;
     371; Encodes the optional REX prefix for an instruction with 32-bit operand size.
     372; @param 1     The MODRM.REG register mnemonic.
     373; @param 2     The MODRM.RM register mnemonic.
     374%macro X86_MKOP_REX32 2
     375 %assign x86_mkop_rex32_iReg    X86_MKOP_GREG32_ %+ %1
     376 %assign x86_mkop_rex32_iRm     X86_MKOP_GREG32_ %+ %2
     377 %if x86_mkop_rex32_iReg >= 8 || x86_mkop_rex32_iRm >= 8
     378  %if __BITS__ == 64
     379        db      X86_OP_REX | ((x86_mkop_rex32_iReg >> 3) * X86_OP_REX_R) | ((x86_mkop_rex32_iRm >> 3) * X86_OP_REX_B)
     380  %else
     381   %error X86_MKOP_REX32: not in 64-bit code: %1, %2
     382  %endif
     383 %endif
     384%endmacro
     385
     386
     387;;
     388; Encodes the MODRM byte for an instruction with 64-bit operand size.
     389; @param 1     The MODRM.MOD value (X86_MOD_REG, X86_MOD_MEM0, X86_MOD_MEM1, X86_MOD_MEM4).
     390; @param 2     The MODRM.REG register mnemonic.
     391; @param 3     The MODRM.RM register mnemonic.
     392%macro X86_MKOP_MODRM64 3
     393 %assign x86_mkop_modrm64_iReg  X86_MKOP_GREG64_ %+ %2
     394 %assign x86_mkop_modrm64_iRm   X86_MKOP_GREG64_ %+ %3
     395        db      X86_MODRM_MAKE(%1, x86_mkop_modrm64_iReg & 7, x86_mkop_modrm64_iRm & 7)
     396%endmacro
     397
     398;;
     399; Encodes the REX prefix for an instruction with 64-bit operand size.
     400; @param 1     The MODRM.REG register mnemonic.
     401; @param 2     The MODRM.RM register mnemonic.
     402%macro X86_MKOP_REX64 2
     403 %assign x86_mkop_rex64_iReg    X86_MKOP_GREG64_ %+ %1
     404 %assign x86_mkop_rex64_iRm     X86_MKOP_GREG64_ %+ %2
     405 %if __BITS__ == 64
     406        db      X86_OP_REX_W | ((x86_mkop_rex64_iReg >> 3) * X86_OP_REX_R) | ((x86_mkop_rex64_iRm >> 3) * X86_OP_REX_B)
     407 %else
     408  %error X86_MKOP_REX64: not in 64-bit code: %1, %2
     409 %endif
     410%endmacro
     411
     412
    224413%endif
    225414
Note: See TracChangeset for help on using the changeset viewer.

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