@@ -87,7 +87,7 @@ struct ARM7TDMI {
87
87
p_spsr = &state.spsr [new_bank];
88
88
} else {
89
89
/* In system/user mode reading from SPSR returns the current CPSR value.
90
- * However writes to SPSR appear to do nothing.
90
+ * However, writes to SPSR appear to do nothing.
91
91
* We take care of this fact in the MSR implementation.
92
92
*/
93
93
p_spsr = &state.cpsr ;
@@ -118,10 +118,16 @@ struct ARM7TDMI {
118
118
state.bank [old_bank][5 ] = state.r13 ;
119
119
state.bank [old_bank][6 ] = state.r14 ;
120
120
121
- state.r13 = state.bank [new_bank][5 ];
122
- state.r14 = state.bank [new_bank][6 ];
123
-
124
- cpu_mode_is_invalid = new_bank == BANK_INVALID;
121
+ if (new_bank != BANK_INVALID) [[likely]] {
122
+ state.r13 = state.bank [new_bank][5 ];
123
+ state.r14 = state.bank [new_bank][6 ];
124
+ cpu_mode_is_invalid = false ;
125
+ } else {
126
+ for (int i = 0 ; i < 7 ; i++) {
127
+ state.reg [8 + i] = 0u ;
128
+ }
129
+ cpu_mode_is_invalid = true ;
130
+ }
125
131
}
126
132
127
133
void LoadState (SaveState const & save_state);
@@ -136,19 +142,14 @@ struct ARM7TDMI {
136
142
friend struct TableGen ;
137
143
138
144
auto GetReg (int id) -> u32 {
139
- u32 result = 0 ;
140
- bool is_banked = id >= 8 && id != 15 ;
145
+ u32 result = state.reg [id];
141
146
142
- if (unlikely (ldm_usermode_conflict && is_banked )) {
147
+ if (unlikely (ldm_usermode_conflict && id >= 8 && id != 15 )) {
143
148
// This array holds the current user/sys bank value only if the CPU wasn't in user or system mode all along during the user mode LDM instruction.
144
149
// We take care in the LDM implementation that this branch is only taken if that was the case.
145
150
result |= state.bank [BANK_NONE][id - 8 ];
146
151
}
147
152
148
- if (likely (!cpu_mode_is_invalid || !is_banked)) {
149
- result |= state.reg [id];
150
- }
151
-
152
153
return result;
153
154
}
154
155
0 commit comments