diff options
author | Aurelien Jarno <aurelien@aurel32.net> | 2015-06-25 21:16:58 +0200 |
---|---|---|
committer | Alexander Graf <agraf@suse.de> | 2015-07-07 17:51:47 +0200 |
commit | 92f2b4e71e988ad2751c71717e9fe3387753442a (patch) | |
tree | fe3ebf9202d577f588880e1c3fd192cf4ca43dfa /target-s390x/int_helper.c | |
parent | c9c19b493286db7358f9ee26401b927bbbd21604 (diff) | |
download | qemu-92f2b4e71e988ad2751c71717e9fe3387753442a.zip qemu-92f2b4e71e988ad2751c71717e9fe3387753442a.tar.gz qemu-92f2b4e71e988ad2751c71717e9fe3387753442a.tar.bz2 |
target-s390x: fix CONVERT TO BINARY (CVD, CVDY)
current_number being shift left by more than 32 bits, we can't use a
simple int. Similarly use an int64_t type for the input binary value,
to not get the -2^31 case wrong. Finally don't initialize shift to 4,
it's already done in the for loop.
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'target-s390x/int_helper.c')
-rw-r--r-- | target-s390x/int_helper.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/target-s390x/int_helper.c b/target-s390x/int_helper.c index 2c2b3f6..a46c736 100644 --- a/target-s390x/int_helper.c +++ b/target-s390x/int_helper.c @@ -121,11 +121,12 @@ uint64_t HELPER(clz)(uint64_t v) return clz64(v); } -uint64_t HELPER(cvd)(int32_t bin) +uint64_t HELPER(cvd)(int32_t reg) { /* positive 0 */ uint64_t dec = 0x0c; - int shift = 4; + int64_t bin = reg; + int shift; if (bin < 0) { bin = -bin; @@ -133,9 +134,7 @@ uint64_t HELPER(cvd)(int32_t bin) } for (shift = 4; (shift < 64) && bin; shift += 4) { - int current_number = bin % 10; - - dec |= (current_number) << shift; + dec |= (bin % 10) << shift; bin /= 10; } |