Changeset 93888 in vbox for trunk/src/VBox/VMM/VMMAll
- Timestamp:
- Feb 22, 2022 3:46:53 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/IEMAllAImplC.cpp
r93887 r93888 1567 1567 1568 1568 # define DIV_STORE(a_Quotient, a_uReminder) *puA = (a_Quotient), *puD = (a_uReminder) 1569 # define DIV_STORE_U8(a_Quotient, a_uReminder) *puAX = ( a_Quotient) | ((uint16_t)(a_uReminder) << 8)1569 # define DIV_STORE_U8(a_Quotient, a_uReminder) *puAX = (uint8_t)(a_Quotient) | ((uint16_t)(a_uReminder) << 8) 1570 1570 1571 1571 # define MUL_LOAD_F1() *puA … … 1603 1603 \ 1604 1604 /* MUL EFLAGS according to Skylake (similar to IMUL). */ \ 1605 *pfEFlags &=~(X86_EFL_SF | X86_EFL_CF | X86_EFL_OF | X86_EFL_AF | X86_EFL_ZF | X86_EFL_PF); \1605 uint32_t fEfl = *pfEFlags & ~(X86_EFL_SF | X86_EFL_CF | X86_EFL_OF | X86_EFL_AF | X86_EFL_ZF | X86_EFL_PF); \ 1606 1606 if (Result.s.Lo & RT_BIT_64(a_cBitsWidth - 1)) \ 1607 *pfEFlags|= X86_EFL_SF; \1608 *pfEFlags|= g_afParity[Result.s.Lo & 0xff]; /* (Skylake behaviour) */ \1607 fEfl |= X86_EFL_SF; \ 1608 fEfl |= g_afParity[Result.s.Lo & 0xff]; /* (Skylake behaviour) */ \ 1609 1609 if (Result.s.Hi != 0) \ 1610 *pfEFlags |= X86_EFL_CF | X86_EFL_OF; \ 1610 fEfl |= X86_EFL_CF | X86_EFL_OF; \ 1611 *pfEFlags = fEfl; \ 1611 1612 return 0; \ 1612 1613 } … … 1627 1628 RTUINT ## a_cBitsWidth2x ## U Result; \ 1628 1629 /* The SF, ZF, AF and PF flags are "undefined". AMD (3990x) leaves these \ 1629 flags as is. Whereas Intel skylake always clear AF and ZF and calculates \ 1630 SF and PF as per the lower half of the result. */ \ 1630 flags as is - at least for the two op version. Whereas Intel skylake \ 1631 always clear AF and ZF and calculates SF and PF as per the lower half \ 1632 of the result. */ \ 1631 1633 uint32_t fEfl = *pfEFlags & ~(X86_EFL_CF | X86_EFL_OF); \ 1632 1634 \ … … 1642 1644 else \ 1643 1645 { \ 1644 a_fnMul(Result, uFactor1, UINT ## a_cBitsWidth ## _C(0) - uFactor2, a_cBitsWidth2x); \ 1646 uint ## a_cBitsWidth ## _t const uPositiveFactor2 = UINT ## a_cBitsWidth ## _C(0) - uFactor2; \ 1647 a_fnMul(Result, uFactor1, uPositiveFactor2, a_cBitsWidth2x); \ 1645 1648 if (Result.s.Hi != 0 || Result.s.Lo > RT_BIT_64(a_cBitsWidth - 1)) \ 1646 1649 fEfl |= X86_EFL_CF | X86_EFL_OF; \ … … 1652 1655 if (!(uFactor2 & RT_BIT_64(a_cBitsWidth - 1))) \ 1653 1656 { \ 1654 a_fnMul(Result, UINT ## a_cBitsWidth ## _C(0) - uFactor1, uFactor2, a_cBitsWidth2x); \ 1657 uint ## a_cBitsWidth ## _t const uPositiveFactor1 = UINT ## a_cBitsWidth ## _C(0) - uFactor1; \ 1658 a_fnMul(Result, uPositiveFactor1, uFactor2, a_cBitsWidth2x); \ 1655 1659 if (Result.s.Hi != 0 || Result.s.Lo > RT_BIT_64(a_cBitsWidth - 1)) \ 1656 1660 fEfl |= X86_EFL_CF | X86_EFL_OF; \ … … 1659 1663 else \ 1660 1664 { \ 1661 /*a_fnMul(Result, UINT ## a_cBitsWidth ## _C(0) - uFactor1, UINT ## a_cBitsWidth ## _C(0) - uFactor2, a_cBitsWidth2x);*/ \ 1662 a_fnMul(Result, uFactor1, uFactor2, a_cBitsWidth2x); \ 1665 uint ## a_cBitsWidth ## _t const uPositiveFactor1 = UINT ## a_cBitsWidth ## _C(0) - uFactor1; \ 1666 uint ## a_cBitsWidth ## _t const uPositiveFactor2 = UINT ## a_cBitsWidth ## _C(0) - uFactor2; \ 1667 a_fnMul(Result, uPositiveFactor1, uPositiveFactor2, a_cBitsWidth2x); \ 1663 1668 if (Result.s.Hi != 0 || Result.s.Lo >= RT_BIT_64(a_cBitsWidth - 1)) \ 1664 1669 fEfl |= X86_EFL_CF | X86_EFL_OF; \ … … 1723 1728 { \ 1724 1729 RTUINT ## a_cBitsWidth2x ## U Remainder, Quotient; \ 1725 a_fnDivRem( Remainder, Quotient, Dividend, uDivisor); \1730 a_fnDivRem(Quotient, Remainder, Dividend, uDivisor); \ 1726 1731 a_fnStore(Quotient.s.Lo, Remainder.s.Lo); \ 1727 1732 /** @todo research the undefined DIV flags. */ \ … … 1756 1761 RTUINT ## a_cBitsWidth2x ## U Dividend; \ 1757 1762 a_fnLoad(Dividend); \ 1758 if ((int ## a_cBitsWidth ## _t)Dividend.s.Hi < 0) \ 1763 bool const fSignedDividend = RT_BOOL(Dividend.s.Hi & RT_BIT_64(a_cBitsWidth - 1)); \ 1764 if (fSignedDividend) \ 1759 1765 a_fnNeg(Dividend, a_cBitsWidth2x); \ 1760 1766 \ 1761 1767 uint ## a_cBitsWidth ## _t uDivisorPositive; \ 1762 if ( (int ## a_cBitsWidth ## _t)uDivisor >= 0) \1768 if (!(uDivisor & RT_BIT_64(a_cBitsWidth - 1))) \ 1763 1769 uDivisorPositive = uDivisor; \ 1764 1770 else \ … … 1766 1772 \ 1767 1773 RTUINT ## a_cBitsWidth2x ## U Remainder, Quotient; \ 1768 a_fnDivRem( Remainder, Quotient, Dividend, uDivisorPositive); \1774 a_fnDivRem(Quotient, Remainder, Dividend, uDivisorPositive); \ 1769 1775 \ 1770 1776 /* \ 1771 1777 * Setup the result, checking for overflows. \ 1772 1778 */ \ 1773 if ( (int ## a_cBitsWidth ## _t)uDivisor >= 0) \1779 if (!(uDivisor & RT_BIT_64(a_cBitsWidth - 1))) \ 1774 1780 { \ 1775 if ( (int ## a_cBitsWidth ## _t)Dividend.s.Hi >= 0) \1781 if (!fSignedDividend) \ 1776 1782 { \ 1777 1783 /* Positive divisor, positive dividend => result positive. */ \ … … 1784 1790 else \ 1785 1791 { \ 1786 /* Positive divisor, positive dividend => result negative. */ \1792 /* Positive divisor, negative dividend => result negative. */ \ 1787 1793 if (Quotient.s.Hi == 0 && Quotient.s.Lo <= RT_BIT_64(a_cBitsWidth - 1)) \ 1788 1794 { \ … … 1794 1800 else \ 1795 1801 { \ 1796 if ( (int ## a_cBitsWidth ## _t)Dividend.s.Hi >= 0) \1802 if (!fSignedDividend) \ 1797 1803 { \ 1798 1804 /* Negative divisor, positive dividend => negative quotient, positive remainder. */ \
Note:
See TracChangeset
for help on using the changeset viewer.