(SETPSR_F, SETPSR_S, SETPSR_X, SETPSR_C): New macros.
(SETPSR, SET_INTMODE, SETCC): Removed.
* armsupp.c (ARMul_FixCPSR, ARMul_FixSPSR): Do not test bit
mask. Use SETPSR_* to modify PSR.
(ARMul_SetCPSR): Load all bits from value.
* armemu.c (ARMul_Emulate, msr): Do not test bit mask.
2000-07-04 Alexandre Oliva <aoliva@redhat.com>
+ * armemu.h (PSR_FBITS, PSR_SBITS, PSR_XBITS, PSR_CBITS): New.
+ (SETPSR_F, SETPSR_S, SETPSR_X, SETPSR_C): New macros.
+ (SETPSR, SET_INTMODE, SETCC): Removed.
+ * armsupp.c (ARMul_FixCPSR, ARMul_FixSPSR): Do not test bit
+ mask. Use SETPSR_* to modify PSR.
+ (ARMul_SetCPSR): Load all bits from value.
+ * armemu.c (ARMul_Emulate, msr): Do not test bit mask.
+
* armemu.c (ARMul_Emulate): Compute writeback value before
loading, since the offset register may be the destination
register.
}
}
#endif
- if (DESTReg == 15 && BITS (17, 18) == 0)
+ if (DESTReg == 15)
{ /* MSR reg to CPSR */
UNDEF_MSRPC;
temp = DPRegRHS;
break;
}
#endif
- if (DESTReg == 15 && BITS (17, 18) == 0)
+ if (DESTReg == 15)
{ /* MSR */
UNDEF_MSRPC;
ARMul_FixSPSR (state, instr, DPRegRHS);
break;
case 0x32: /* TEQ immed and MSR immed to CPSR */
- if (DESTReg == 15 && BITS (17, 18) == 0)
+ if (DESTReg == 15)
{ /* MSR immed to CPSR */
ARMul_FixCPSR (state, instr, DPImmRHS);
}
break;
case 0x36: /* CMN immed and MSR immed to SPSR */
- if (DESTReg == 15 && BITS (17, 18) == 0) /* MSR */
+ if (DESTReg == 15) /* MSR */
ARMul_FixSPSR (state, instr, DPImmRHS);
else
{
#define ASSIGNINT(res) state->IFFlags = (((res) >> 6) & 3)
#define ASSIGNR15INT(res) state->IFFlags = (((res) >> 26) & 3) ;
+#define PSR_FBITS (0xff000000L)
+#define PSR_SBITS (0x00ff0000L)
+#define PSR_XBITS (0x0000ff00L)
+#define PSR_CBITS (0x000000ffL)
+
#define CCBITS (0xf0000000L)
#define INTBITS (0xc0L)
#endif
#define GETSPSR(bank) bank>0?state->Spsr[bank]:ECC | EINT | EMODE ;
-#define SETPSR(d,s) d = (s) & (ARMword)(CCBITS | INTBITS | MODEBITS)
-#define SETINTMODE(d,s) d = ((d) & CCBITS) | ((s) & (INTBITS | MODEBITS))
-#define SETCC(d,s) d = ((d) & (INTBITS | MODEBITS)) | ((s) & CCBITS)
+#define SETPSR_F(d,s) d = ((d) & ~PSR_FBITS) | ((s) & PSR_FBITS)
+#define SETPSR_S(d,s) d = ((d) & ~PSR_SBITS) | ((s) & PSR_SBITS)
+#define SETPSR_X(d,s) d = ((d) & ~PSR_XBITS) | ((s) & PSR_XBITS)
+#define SETPSR_C(d,s) d = ((d) & ~PSR_CBITS) | ((s) & PSR_CBITS)
#define SETR15PSR(s) if (state->Mode == USER26MODE) { \
state->Reg[15] = ((s) & CCBITS) | R15PC | ER15INT | EMODE ; \
ASSIGNN((state->Reg[15] & NBIT) != 0) ; \
void
ARMul_SetCPSR (ARMul_State * state, ARMword value)
{
- state->Cpsr = CPSR;
- SETPSR (state->Cpsr, value);
+ state->Cpsr = value;
ARMul_CPSRAltered (state);
}
ARMul_FixCPSR (ARMul_State * state, ARMword instr, ARMword rhs)
{
state->Cpsr = CPSR;
- if (state->Bank == USERBANK)
- { /* Only write flags in user mode */
- if (BIT (19))
- {
- SETCC (state->Cpsr, rhs);
- }
- }
- else
- { /* Not a user mode */
- if (BITS (16, 19) == 9)
- SETPSR (state->Cpsr, rhs);
- else if (BIT (16))
- SETINTMODE (state->Cpsr, rhs);
- else if (BIT (19))
- SETCC (state->Cpsr, rhs);
+ if (state->Bank != USERBANK)
+ { /* In user mode, only write flags */
+ if (BIT (16))
+ SETPSR_C (state->Cpsr, rhs);
+ if (BIT (17))
+ SETPSR_X (state->Cpsr, rhs);
+ if (BIT (18))
+ SETPSR_S (state->Cpsr, rhs);
}
+ if (BIT (19))
+ SETPSR_F (state->Cpsr, rhs);
ARMul_CPSRAltered (state);
}
{
if (BANK_CAN_ACCESS_SPSR (state->Bank))
{
- if (BITS (16, 19) == 9)
- SETPSR (state->Spsr[state->Bank], rhs);
- else if (BIT (16))
- SETINTMODE (state->Spsr[state->Bank], rhs);
- else if (BIT (19))
- SETCC (state->Spsr[state->Bank], rhs);
+ if (BIT (16))
+ SETPSR_C (state->Spsr[state->Bank], rhs);
+ if (BIT (17))
+ SETPSR_X (state->Spsr[state->Bank], rhs);
+ if (BIT (18))
+ SETPSR_S (state->Spsr[state->Bank], rhs);
+ if (BIT (19))
+ SETPSR_F (state->Spsr[state->Bank], rhs);
}
}