mirror of
https://github.com/qemu/qemu.git
synced 2025-08-09 01:50:43 +00:00
target/sh4: fix FPSCR cause vs flag inversion
The floating-point status/control register contains cause and flag bits. The cause bits are set to 0 before executing the instruction, while the flag bits hold the status of the exception generated after the field was last cleared. Message-Id: <20170702202814.27793-4-aurelien@aurel32.net> Reviewed-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
This commit is contained in:
parent
fea7d77d3e
commit
801f4dac57
@ -219,29 +219,29 @@ static void update_fpscr(CPUSH4State *env, uintptr_t retaddr)
|
|||||||
|
|
||||||
xcpt = get_float_exception_flags(&env->fp_status);
|
xcpt = get_float_exception_flags(&env->fp_status);
|
||||||
|
|
||||||
/* Clear the flag entries */
|
/* Clear the cause entries */
|
||||||
env->fpscr &= ~FPSCR_FLAG_MASK;
|
env->fpscr &= ~FPSCR_CAUSE_MASK;
|
||||||
|
|
||||||
if (unlikely(xcpt)) {
|
if (unlikely(xcpt)) {
|
||||||
if (xcpt & float_flag_invalid) {
|
if (xcpt & float_flag_invalid) {
|
||||||
env->fpscr |= FPSCR_FLAG_V;
|
env->fpscr |= FPSCR_CAUSE_V;
|
||||||
}
|
}
|
||||||
if (xcpt & float_flag_divbyzero) {
|
if (xcpt & float_flag_divbyzero) {
|
||||||
env->fpscr |= FPSCR_FLAG_Z;
|
env->fpscr |= FPSCR_CAUSE_Z;
|
||||||
}
|
}
|
||||||
if (xcpt & float_flag_overflow) {
|
if (xcpt & float_flag_overflow) {
|
||||||
env->fpscr |= FPSCR_FLAG_O;
|
env->fpscr |= FPSCR_CAUSE_O;
|
||||||
}
|
}
|
||||||
if (xcpt & float_flag_underflow) {
|
if (xcpt & float_flag_underflow) {
|
||||||
env->fpscr |= FPSCR_FLAG_U;
|
env->fpscr |= FPSCR_CAUSE_U;
|
||||||
}
|
}
|
||||||
if (xcpt & float_flag_inexact) {
|
if (xcpt & float_flag_inexact) {
|
||||||
env->fpscr |= FPSCR_FLAG_I;
|
env->fpscr |= FPSCR_CAUSE_I;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Accumulate in cause entries */
|
/* Accumulate in flag entries */
|
||||||
env->fpscr |= (env->fpscr & FPSCR_FLAG_MASK)
|
env->fpscr |= (env->fpscr & FPSCR_CAUSE_MASK)
|
||||||
<< (FPSCR_CAUSE_SHIFT - FPSCR_FLAG_SHIFT);
|
>> (FPSCR_CAUSE_SHIFT - FPSCR_FLAG_SHIFT);
|
||||||
|
|
||||||
/* Generate an exception if enabled */
|
/* Generate an exception if enabled */
|
||||||
cause = (env->fpscr & FPSCR_CAUSE_MASK) >> FPSCR_CAUSE_SHIFT;
|
cause = (env->fpscr & FPSCR_CAUSE_MASK) >> FPSCR_CAUSE_SHIFT;
|
||||||
|
Loading…
Reference in New Issue
Block a user