Skip to content

Commit 68335b3

Browse files
committed
Fix order of values stored in the operand stack
1 parent 28e1079 commit 68335b3

31 files changed

+275
-31
lines changed

src/Kernel/Mnemonics/_dadd.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ final class _dadd implements OperationInterface
1111

1212
public function execute(): void
1313
{
14-
$value1 = $this->getStack();
1514
$value2 = $this->getStack();
15+
$value1 = $this->getStack();
1616

1717
$this->pushStack(BinaryTool::add($value1, $value2));
1818
}

src/Kernel/Mnemonics/_dmul.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ final class _dmul implements OperationInterface
1111

1212
public function execute(): void
1313
{
14-
$value1 = $this->getStack();
1514
$value2 = $this->getStack();
15+
$value1 = $this->getStack();
1616

1717
$this->pushStack(BinaryTool::multiply($value1, $value2, 8));
1818
}

src/Kernel/Mnemonics/_dsub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ final class _dsub implements OperationInterface
1111

1212
public function execute(): void
1313
{
14-
$leftValue = $this->getStack();
1514
$rightValue = $this->getStack();
15+
$leftValue = $this->getStack();
1616

1717
$this->pushStack(BinaryTool::sub($leftValue, $rightValue, 8));
1818
}

src/Kernel/Mnemonics/_iadd.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ final class _iadd implements OperationInterface
1111

1212
public function execute(): void
1313
{
14-
$leftValue = $this->getStack();
1514
$rightValue = $this->getStack();
15+
$leftValue = $this->getStack();
1616

1717
$this->pushStack(BinaryTool::add($leftValue, $rightValue));
1818
}

src/Kernel/Mnemonics/_iand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ final class _iand implements OperationInterface
1111

1212
public function execute(): void
1313
{
14-
$value1 = $this->getStack();
1514
$value2 = $this->getStack();
15+
$value1 = $this->getStack();
1616

1717
$this->pushStack(BinaryTool::andBits($value1, $value2, 4));
1818
}

src/Kernel/Mnemonics/_if_acmpeq.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ public function execute(): void
1313
{
1414
$offset = $this->readShort();
1515

16-
$leftOperand = $this->getStack();
1716
$rightOperand = $this->getStack();
17+
$leftOperand = $this->getStack();
1818

1919
if ($leftOperand === $rightOperand) {
2020
$this->setOffset($this->getProgramCounter() + $offset);

src/Kernel/Mnemonics/_if_acmpne.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ public function execute(): void
1313
{
1414
$offset = $this->readShort();
1515

16-
$leftOperand = $this->getStack();
1716
$rightOperand = $this->getStack();
17+
$leftOperand = $this->getStack();
1818

1919
if ($leftOperand !== $rightOperand) {
2020
$this->setOffset($this->getProgramCounter() + $offset);

src/Kernel/Mnemonics/_if_icmpge.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ public function execute(): void
1313
{
1414
$offset = $this->readShort();
1515

16-
$leftOperand = $this->getStack();
1716
$rightOperand = $this->getStack();
17+
$leftOperand = $this->getStack();
1818

19-
if ($leftOperand <= $rightOperand) {
19+
if ($leftOperand >= $rightOperand) {
2020
$this->setOffset($this->getProgramCounter() + $offset);
2121
}
2222
}

src/Kernel/Mnemonics/_if_icmpgt.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ public function execute(): void
1313
{
1414
$offset = $this->readShort();
1515

16-
$leftOperand = $this->getStack();
1716
$rightOperand = $this->getStack();
17+
$leftOperand = $this->getStack();
1818

19-
if ($leftOperand < $rightOperand) {
19+
if ($leftOperand > $rightOperand) {
2020
$this->setOffset($this->getProgramCounter() + $offset);
2121
}
2222
}

src/Kernel/Mnemonics/_if_icmplt.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ public function execute(): void
1313
{
1414
$offset = $this->readShort();
1515

16-
$leftOperand = $this->getStack();
1716
$rightOperand = $this->getStack();
17+
$leftOperand = $this->getStack();
1818

19-
if ($rightOperand < $leftOperand) {
19+
if ($leftOperand < $rightOperand) {
2020
$this->setOffset($this->getProgramCounter() + $offset);
2121
}
2222
}

0 commit comments

Comments
 (0)