ARM: Remove need for CPSR load in some flag calculations

This commit is contained in:
Vicki Pfau 2019-03-31 11:59:18 -07:00
parent e18f275aaa
commit bf8c1d1b4b
3 changed files with 18 additions and 0 deletions

View File

@ -93,6 +93,20 @@ union PSR {
#endif #endif
}; };
struct {
#if defined(__BIG_ENDIAN__)
uint8_t flags;
uint8_t status;
uint8_t extension;
uint8_t control;
#else
uint8_t control;
uint8_t extension;
uint8_t status;
uint8_t flags;
#endif
};
int32_t packed; int32_t packed;
}; };

View File

@ -185,6 +185,7 @@ static inline void _immediate(struct ARMCore* cpu, uint32_t opcode) {
// Beware pre-processor antics // Beware pre-processor antics
ATTRIBUTE_NOINLINE static void _additionS(struct ARMCore* cpu, int32_t m, int32_t n, int32_t d) { ATTRIBUTE_NOINLINE static void _additionS(struct ARMCore* cpu, int32_t m, int32_t n, int32_t d) {
cpu->cpsr.flags = 0;
cpu->cpsr.n = ARM_SIGN(d); cpu->cpsr.n = ARM_SIGN(d);
cpu->cpsr.z = !d; cpu->cpsr.z = !d;
cpu->cpsr.c = ARM_CARRY_FROM(m, n, d); cpu->cpsr.c = ARM_CARRY_FROM(m, n, d);
@ -192,6 +193,7 @@ ATTRIBUTE_NOINLINE static void _additionS(struct ARMCore* cpu, int32_t m, int32_
} }
ATTRIBUTE_NOINLINE static void _subtractionS(struct ARMCore* cpu, int32_t m, int32_t n, int32_t d) { ATTRIBUTE_NOINLINE static void _subtractionS(struct ARMCore* cpu, int32_t m, int32_t n, int32_t d) {
cpu->cpsr.flags = 0;
cpu->cpsr.n = ARM_SIGN(d); cpu->cpsr.n = ARM_SIGN(d);
cpu->cpsr.z = !d; cpu->cpsr.z = !d;
cpu->cpsr.c = ARM_BORROW_FROM(m, n, d); cpu->cpsr.c = ARM_BORROW_FROM(m, n, d);

View File

@ -12,12 +12,14 @@
// Beware pre-processor insanity // Beware pre-processor insanity
#define THUMB_ADDITION_S(M, N, D) \ #define THUMB_ADDITION_S(M, N, D) \
cpu->cpsr.flags = 0; \
cpu->cpsr.n = ARM_SIGN(D); \ cpu->cpsr.n = ARM_SIGN(D); \
cpu->cpsr.z = !(D); \ cpu->cpsr.z = !(D); \
cpu->cpsr.c = ARM_CARRY_FROM(M, N, D); \ cpu->cpsr.c = ARM_CARRY_FROM(M, N, D); \
cpu->cpsr.v = ARM_V_ADDITION(M, N, D); cpu->cpsr.v = ARM_V_ADDITION(M, N, D);
#define THUMB_SUBTRACTION_S(M, N, D) \ #define THUMB_SUBTRACTION_S(M, N, D) \
cpu->cpsr.flags = 0; \
cpu->cpsr.n = ARM_SIGN(D); \ cpu->cpsr.n = ARM_SIGN(D); \
cpu->cpsr.z = !(D); \ cpu->cpsr.z = !(D); \
cpu->cpsr.c = ARM_BORROW_FROM(M, N, D); \ cpu->cpsr.c = ARM_BORROW_FROM(M, N, D); \