summaryrefslogtreecommitdiff
path: root/target-tricore
diff options
context:
space:
mode:
authorBastian Koppelmann <kbastian@mail.uni-paderborn.de>2015-03-23 18:24:42 +0100
committerBastian Koppelmann <kbastian@mail.uni-paderborn.de>2015-03-24 09:45:28 +0100
commitf69c24e4584f2161f90ee7caba38728aa77f937f (patch)
tree7bdda3681d43ea7d3b5c832c1d15c5b38eb61307 /target-tricore
parent00e1754ff1f6294a29e08398a120663eac723216 (diff)
downloadqemu-f69c24e4584f2161f90ee7caba38728aa77f937f.zip
target-tricore: properly fix dvinit_b/h_13
The TriCore documentation was wrong on how to calculate ovf bits for those two instructions, which I confirmed with real hardware (TC1796 chip). An ovf actually happens, if the result (without remainder) does not fit into 8/16 bits. Signed-off-by: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
Diffstat (limited to 'target-tricore')
-rw-r--r--target-tricore/op_helper.c40
1 files changed, 10 insertions, 30 deletions
diff --git a/target-tricore/op_helper.c b/target-tricore/op_helper.c
index 2cfa95d696..220ec4a3c1 100644
--- a/target-tricore/op_helper.c
+++ b/target-tricore/op_helper.c
@@ -1942,29 +1942,19 @@ uint64_t helper_unpack(target_ulong arg1)
uint64_t helper_dvinit_b_13(CPUTriCoreState *env, uint32_t r1, uint32_t r2)
{
uint64_t ret;
- int32_t abs_sig_dividend, abs_base_dividend, abs_divisor;
- int32_t quotient_sign;
+ int32_t abs_sig_dividend, abs_divisor;
ret = sextract32(r1, 0, 32);
ret = ret << 24;
- quotient_sign = 0;
if (!((r1 & 0x80000000) == (r2 & 0x80000000))) {
ret |= 0xffffff;
- quotient_sign = 1;
}
- abs_sig_dividend = abs((int32_t)r1) >> 7;
- abs_base_dividend = abs((int32_t)r1) & 0x7f;
+ abs_sig_dividend = abs((int32_t)r1) >> 8;
abs_divisor = abs((int32_t)r2);
- /* calc overflow */
- env->PSW_USB_V = 0;
- if ((quotient_sign) && (abs_divisor)) {
- env->PSW_USB_V = (((abs_sig_dividend == abs_divisor) &&
- (abs_base_dividend >= abs_divisor)) ||
- (abs_sig_dividend > abs_divisor));
- } else {
- env->PSW_USB_V = (abs_sig_dividend >= abs_divisor);
- }
+ /* calc overflow
+ ofv if (a/b >= 255) <=> (a/255 >= b) */
+ env->PSW_USB_V = (abs_sig_dividend >= abs_divisor) << 31;
env->PSW_USB_V = env->PSW_USB_V << 31;
env->PSW_USB_SV |= env->PSW_USB_V;
env->PSW_USB_AV = 0;
@@ -1992,29 +1982,19 @@ uint64_t helper_dvinit_b_131(CPUTriCoreState *env, uint32_t r1, uint32_t r2)
uint64_t helper_dvinit_h_13(CPUTriCoreState *env, uint32_t r1, uint32_t r2)
{
uint64_t ret;
- int32_t abs_sig_dividend, abs_base_dividend, abs_divisor;
- int32_t quotient_sign;
+ int32_t abs_sig_dividend, abs_divisor;
ret = sextract32(r1, 0, 32);
ret = ret << 16;
- quotient_sign = 0;
if (!((r1 & 0x80000000) == (r2 & 0x80000000))) {
ret |= 0xffff;
- quotient_sign = 1;
}
- abs_sig_dividend = abs((int32_t)r1) >> 7;
- abs_base_dividend = abs((int32_t)r1) & 0x7f;
+ abs_sig_dividend = abs((int32_t)r1) >> 16;
abs_divisor = abs((int32_t)r2);
- /* calc overflow */
- env->PSW_USB_V = 0;
- if ((quotient_sign) && (abs_divisor)) {
- env->PSW_USB_V = (((abs_sig_dividend == abs_divisor) &&
- (abs_base_dividend >= abs_divisor)) ||
- (abs_sig_dividend > abs_divisor));
- } else {
- env->PSW_USB_V = (abs_sig_dividend >= abs_divisor);
- }
+ /* calc overflow
+ ofv if (a/b >= 0xffff) <=> (a/0xffff >= b) */
+ env->PSW_USB_V = (abs_sig_dividend >= abs_divisor) << 31;
env->PSW_USB_V = env->PSW_USB_V << 31;
env->PSW_USB_SV |= env->PSW_USB_V;
env->PSW_USB_AV = 0;