From b5455751929d7f9a3581e27eb0adcf7ef9d01a0c Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 18 May 2024 14:27:02 +0900 Subject: fix: i64.shr_u --- src/Execution/Runtime.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Execution/Runtime.php b/src/Execution/Runtime.php index d15e098..90d05e6 100644 --- a/src/Execution/Runtime.php +++ b/src/Execution/Runtime.php @@ -1570,8 +1570,13 @@ final class Runtime { $c2 = $this->stack->popInt(); $k = $c2 % 64; + if ($k === 0) { + return; + } + // Perform shr_u based on string manipulation because PHP does not + // support shr_u operation. $c1 = $this->stack->popInt(); - $this->stack->pushValue($c1 >> $k); + $this->stack->pushValue(bindec(substr(decbin($c1), 0, -$k))); } private function execInstrNumericI64Sub(Instrs\Numeric\I64Sub $instr): void -- cgit v1.2.3-70-g09d2