aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Execution
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2024-06-29 01:44:21 +0900
committernsfisis <nsfisis@gmail.com>2024-06-29 01:44:21 +0900
commit80b9584de4b9c2b0601c709877b50d589aece57d (patch)
tree80441bf14a5f08a2c05c3054ade3bfbcd152286f /src/Execution
parent8589fd9fb5fda63579fd152c958e1678d9724a77 (diff)
downloadphp-waddiwasi-80b9584de4b9c2b0601c709877b50d589aece57d.tar.gz
php-waddiwasi-80b9584de4b9c2b0601c709877b50d589aece57d.tar.zst
php-waddiwasi-80b9584de4b9c2b0601c709877b50d589aece57d.zip
test: I64Test passed
Diffstat (limited to 'src/Execution')
-rw-r--r--src/Execution/Runtime.php20
1 files changed, 13 insertions, 7 deletions
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