Browse code

[GSF] Minor changes.

Naram Qashat authored on 2013/05/16 19:35:37
Showing 1 changed files
... ...
@@ -663,22 +663,22 @@ template<typename T> static inline T POS(const T &i) { return ~i >> 31; }
663 663
 #endif
664 664
 
665 665
 // C core
666
-#ifndef ADDCARRY
667
-# define ADDCARRY(a, b, c) \
666
+static inline void ADDCARRY(uint32_t a, uint32_t b, uint32_t c)
667
+{
668 668
 	C_FLAG = !!((NEG(a) & NEG(b)) | (NEG(a) & POS(c)) | (NEG(b) & POS(c)));
669
-#endif
670
-#ifndef ADDOVERFLOW
671
-# define ADDOVERFLOW(a, b, c) \
669
+}
670
+static inline void ADDOVERFLOW(uint32_t a, uint32_t b, uint32_t c)
671
+{
672 672
 	V_FLAG = !!((NEG(a) & NEG(b) & POS(c)) | (POS(a) & POS(b) & NEG(c)));
673
-#endif
674
-#ifndef SUBCARRY
675
-# define SUBCARRY(a, b, c) \
673
+}
674
+static inline void SUBCARRY(uint32_t a, uint32_t b, uint32_t c)
675
+{
676 676
 	C_FLAG = !!((NEG(a) & POS(b)) | (NEG(a) & POS(c)) | (POS(b) & POS(c)));
677
-#endif
678
-#ifndef SUBOVERFLOW
679
-# define SUBOVERFLOW(a, b, c) \
677
+}
678
+static inline void SUBOVERFLOW(uint32_t a, uint32_t b, uint32_t c)
679
+{
680 680
 	V_FLAG = !!((NEG(a) & POS(b) & POS(c)) | (POS(a) & NEG(b) & NEG(c)));
681
-#endif
681
+}
682 682
 #ifndef ADD_RD_RS_RN
683 683
 # define ADD_RD_RS_RN(N) \
684 684
 { \
... ...
@@ -1767,31 +1767,6 @@ static INSN_REGPARM void thumbBD(uint32_t opcode)
1767 1767
 
1768 1768
 // Load/store multiple ////////////////////////////////////////////////////
1769 1769
 
1770
-#define THUMB_STM_REG(val, r, b) \
1771
-	if (opcode & (val)) \
1772
-	{ \
1773
-		CPUWriteMemory(address, reg[(r)].I); \
1774
-		reg[(b)].I = temp; \
1775
-		if (!count) \
1776
-			clockTicks += 1 + dataTicksAccess32(address); \
1777
-		else \
1778
-			clockTicks += 1 + dataTicksAccessSeq32(address); \
1779
-		++count; \
1780
-		address += 4; \
1781
-	}
1782
-
1783
-#define THUMB_LDM_REG(val, r) \
1784
-	if (opcode & (val)) \
1785
-	{ \
1786
-		reg[(r)].I = CPUReadMemory(address); \
1787
-		if (!count) \
1788
-			clockTicks += 1 + dataTicksAccess32(address); \
1789
-		else \
1790
-			clockTicks += 1 + dataTicksAccessSeq32(address); \
1791
-		++count; \
1792
-		address += 4; \
1793
-	}
1794
-
1795 1770
 // STM R0~7!, {Rlist}
1796 1771
 static INSN_REGPARM void thumbC0(uint32_t opcode)
1797 1772
 {
... ...
@@ -1802,6 +1777,20 @@ static INSN_REGPARM void thumbC0(uint32_t opcode)
1802 1777
 	uint32_t temp = reg[regist].I + 4 * cpuBitsSet[opcode & 0xff];
1803 1778
 	int count = 0;
1804 1779
 	// store
1780
+	auto THUMB_STM_REG = [&](int val, int r, uint8_t b)
1781
+	{
1782
+		if (opcode & val)
1783
+		{
1784
+			CPUWriteMemory(address, reg[r].I);
1785
+			reg[b].I = temp;
1786
+			if (!count)
1787
+				clockTicks += 1 + dataTicksAccess32(address);
1788
+			else
1789
+				clockTicks += 1 + dataTicksAccessSeq32(address);
1790
+			++count;
1791
+			address += 4;
1792
+		}
1793
+	};
1805 1794
 	THUMB_STM_REG(1, 0, regist);
1806 1795
 	THUMB_STM_REG(2, 1, regist);
1807 1796
 	THUMB_STM_REG(4, 2, regist);
... ...
@@ -1823,6 +1812,19 @@ static INSN_REGPARM void thumbC8(uint32_t opcode)
1823 1812
 	uint32_t temp = reg[regist].I + 4 * cpuBitsSet[opcode & 0xFF];
1824 1813
 	int count = 0;
1825 1814
 	// load
1815
+	auto THUMB_LDM_REG = [&](int val, int r)
1816
+	{
1817
+		if (opcode & val)
1818
+		{
1819
+			reg[r].I = CPUReadMemory(address);
1820
+			if (!count)
1821
+				clockTicks += 1 + dataTicksAccess32(address);
1822
+			else
1823
+				clockTicks += 1 + dataTicksAccessSeq32(address);
1824
+			++count;
1825
+			address += 4;
1826
+		}
1827
+	};
1826 1828
 	THUMB_LDM_REG(1, 0);
1827 1829
 	THUMB_LDM_REG(2, 1);
1828 1830
 	THUMB_LDM_REG(4, 2);