From 80b9584de4b9c2b0601c709877b50d589aece57d Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 29 Jun 2024 01:44:21 +0900 Subject: test: I64Test passed --- src/Execution/Runtime.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src/Execution/Runtime.php') diff --git a/src/Execution/Runtime.php b/src/Execution/Runtime.php index 71faddf..3c8592e 100644 --- a/src/Execution/Runtime.php +++ b/src/Execution/Runtime.php @@ -1539,22 +1539,28 @@ final class Runtime private function execInstrNumericI64RotL(Instrs\Numeric\I64RotL $instr): void { - $i2 = $this->stack->popInt(); + $i2 = self::convertS64ToBigUInt($this->stack->popInt()); + $k = (int)bcmod($i2, '64'); $i1 = $this->stack->popInt(); - $k = $i2 % 64; $left = $i1 << $k; - $right = ($i1 >> (64 - $k)) & 0x7FFFFFFFFFFFFFFF; + $right = $i1; + for ($i = 0; $i < 64 - $k; $i++) { + $right = ($right >> 1) & 0x7FFFFFFFFFFFFFFF; + } $this->stack->pushValue($left | $right); } private function execInstrNumericI64RotR(Instrs\Numeric\I64RotR $instr): void { - $i2 = $this->stack->popInt(); + $i2 = self::convertS64ToBigUInt($this->stack->popInt()); + $k = (int)bcmod($i2, '64'); $i1 = $this->stack->popInt(); - $k = $i2 % 64; - $left = ($i1 >> $k) & 0x7FFFFFFFFFFFFFFF; + $left = $i1; + for ($i = 0; $i < $k; $i++) { + $left = ($left >> 1) & 0x7FFFFFFFFFFFFFFF; + } $right = $i1 << (64 - $k); - $this->stack->pushValue(($i1 >> $k) | ($i1 << (64 - $k))); + $this->stack->pushValue($left | $right); } private function execInstrNumericI64Shl(Instrs\Numeric\I64Shl $instr): void -- cgit v1.2.3-70-g09d2