Backport fixes (ida_idaapi.as_signed/ida_idaapi.as_int32)

This commit is contained in:
Arnaud Diederen
2023-06-20 15:30:01 +02:00
parent bf1344dd68
commit d81e2982b2
2 changed files with 2 additions and 2 deletions
Binary file not shown.
+2 -2
View File
@@ -342,7 +342,7 @@ def as_uint32(v):
# -----------------------------------------------------------------------
def as_int32(v):
"""Returns a number as a signed int32 number"""
return -((~v & 0xffffffff)+1)
return as_signed(v, 32)
# -----------------------------------------------------------------------
def as_signed(v, nbits = 32):
@@ -350,7 +350,7 @@ def as_signed(v, nbits = 32):
Returns a number as signed. The number of bits are specified by the user.
The MSB holds the sign.
"""
return -(( ~v & ((1 << nbits)-1) ) + 1) if v & (1 << nbits-1) else v
return -(( ~v & ((1 << nbits)-1) ) + 1) if v & (1 << nbits-1) else v & ((1 << nbits)-1)
# ----------------------------------------------------------------------
def TRUNC(ea):