From 25ad2004c1d786a1dbe42d24c08f228c870210a4 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 27 Apr 2024 17:51:09 +0900 Subject: feat: implement some missing instructions --- src/BinaryFormat/Decoder.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/BinaryFormat') diff --git a/src/BinaryFormat/Decoder.php b/src/BinaryFormat/Decoder.php index 30c5b56..c61fade 100644 --- a/src/BinaryFormat/Decoder.php +++ b/src/BinaryFormat/Decoder.php @@ -1052,10 +1052,14 @@ final class Decoder $shiftBits += 7; if ($b < 0b10000000) { if (($b & 0b01000000) !== 0) { - if ($shiftBits < $bits - 1) { - $result |= -(1 << $shiftBits); + if ($bits === 32) { + $result |= (-1) ^ (1 << $shiftBits) - 1; } else { - $result |= 1 << $shiftBits; + if ($shiftBits < $bits - 1) { + $result |= -(1 << $shiftBits); + } else { + $result |= 1 << $shiftBits; + } } } return $result; -- cgit v1.2.3-70-g09d2