diff options
| author | nsfisis <nsfisis@gmail.com> | 2024-04-27 17:51:09 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2024-04-28 01:02:35 +0900 |
| commit | 25ad2004c1d786a1dbe42d24c08f228c870210a4 (patch) | |
| tree | 3977e88ee88a1fa43a3772504b2f0f37a70ae0ee /src/BinaryFormat | |
| parent | 75948f43b09848870bf447f10c39e3f0f109f481 (diff) | |
| download | php-waddiwasi-25ad2004c1d786a1dbe42d24c08f228c870210a4.tar.gz php-waddiwasi-25ad2004c1d786a1dbe42d24c08f228c870210a4.tar.zst php-waddiwasi-25ad2004c1d786a1dbe42d24c08f228c870210a4.zip | |
feat: implement some missing instructions
Diffstat (limited to 'src/BinaryFormat')
| -rw-r--r-- | src/BinaryFormat/Decoder.php | 10 |
1 files changed, 7 insertions, 3 deletions
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; |
