mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-10-15 15:32:51 +00:00
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>
This commit is contained in:
parent
c9c19b4932
commit
92f2b4e71e
|
@ -121,11 +121,12 @@ uint64_t HELPER(clz)(uint64_t v)
|
||||||
return clz64(v);
|
return clz64(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t HELPER(cvd)(int32_t bin)
|
uint64_t HELPER(cvd)(int32_t reg)
|
||||||
{
|
{
|
||||||
/* positive 0 */
|
/* positive 0 */
|
||||||
uint64_t dec = 0x0c;
|
uint64_t dec = 0x0c;
|
||||||
int shift = 4;
|
int64_t bin = reg;
|
||||||
|
int shift;
|
||||||
|
|
||||||
if (bin < 0) {
|
if (bin < 0) {
|
||||||
bin = -bin;
|
bin = -bin;
|
||||||
|
@ -133,9 +134,7 @@ uint64_t HELPER(cvd)(int32_t bin)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (shift = 4; (shift < 64) && bin; shift += 4) {
|
for (shift = 4; (shift < 64) && bin; shift += 4) {
|
||||||
int current_number = bin % 10;
|
dec |= (bin % 10) << shift;
|
||||||
|
|
||||||
dec |= (current_number) << shift;
|
|
||||||
bin /= 10;
|
bin /= 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue