diff --git a/src/app/test/testopcode.cpp b/src/app/test/testopcode.cpp index 582e8b2..dd5332b 100644 --- a/src/app/test/testopcode.cpp +++ b/src/app/test/testopcode.cpp @@ -6,7 +6,7 @@ // This file is used to test opcodes generated by AsmJit. Output can be // disassembled in your IDE or by your favourite disassembler. Instructions -// are sorted alphabetically. +// are grouped by category and then sorted alphabetically. // [Dependencies - AsmJit] #include diff --git a/src/asmjit/x86/x86assembler.cpp b/src/asmjit/x86/x86assembler.cpp index faa676e..7ca6802 100644 --- a/src/asmjit/x86/x86assembler.cpp +++ b/src/asmjit/x86/x86assembler.cpp @@ -3180,13 +3180,15 @@ _EmitX86M: mIndex = rmMem->getIndex(); // Size override prefix. - if (Arch == kArchX86) { - if (rmMem->getMemType() != kMemTypeLabel && !rmMem->hasGpdBase()) - EMIT_BYTE(0x67); - } - else { - if (rmMem->getMemType() != kMemTypeLabel && rmMem->hasGpdBase()) - EMIT_BYTE(0x67); + if (rmMem->hasBaseOrIndex()) { + if (Arch == kArchX86) { + if (!rmMem->hasGpdBase()) + EMIT_BYTE(0x67); + } + else { + if (rmMem->hasGpdBase()) + EMIT_BYTE(0x67); + } } // Segment override prefix. diff --git a/src/asmjit/x86/x86defs.h b/src/asmjit/x86/x86defs.h index a38f5b8..edcbfe8 100644 --- a/src/asmjit/x86/x86defs.h +++ b/src/asmjit/x86/x86defs.h @@ -2685,12 +2685,14 @@ struct Mem : public BaseMem { // -------------------------------------------------------------------------- //! @brief Get whether the memory operand has base register. - ASMJIT_INLINE bool hasBase() const - { return _vmem.base != kInvalidValue; } + ASMJIT_INLINE bool hasBase() const { + return _vmem.base != kInvalidValue; + } //! @brief Get memory operand base register code, variable id, or @ref kInvalidValue. - ASMJIT_INLINE uint32_t getBase() const - { return _vmem.base; } + ASMJIT_INLINE uint32_t getBase() const { + return _vmem.base; + } //! @brief Set memory operand base register code, variable id, or @ref kInvalidValue. ASMJIT_INLINE Mem& setBase(uint32_t base) { @@ -2796,6 +2798,20 @@ struct Mem : public BaseMem { return _setVSib(kMemVSibGpz); } + // -------------------------------------------------------------------------- + // [Misc] + // -------------------------------------------------------------------------- + + //! @brief Get whether the memory operand has base and index register. + ASMJIT_INLINE bool hasBaseOrIndex() const { + return _vmem.base != kInvalidValue || _vmem.index != kInvalidValue; + } + + //! @brief Get whether the memory operand has base and index register. + ASMJIT_INLINE bool hasBaseAndIndex() const { + return _vmem.base != kInvalidValue && _vmem.index != kInvalidValue; + } + // -------------------------------------------------------------------------- // [Shift] // --------------------------------------------------------------------------