|
@@ -261,10 +261,11 @@ module.exports = class Computer {
|
|
|
Operation_Add(rawOpcode) {
|
|
|
const operandLeftMode = ComputerParameterMode.ParseParameterMode(rawOpcode, 1);
|
|
|
const operandRightMode = ComputerParameterMode.ParseParameterMode(rawOpcode, 2);
|
|
|
+ const outputMode = ComputerParameterMode.ParseParameterMode(rawOpcode, 3) || 1;
|
|
|
|
|
|
const operandLeft = this.stack.Next().Get(operandLeftMode);
|
|
|
const operandRight = this.stack.Next().Get(operandRightMode);
|
|
|
- const outputPosition = this.stack.Next().Get(ComputerParameterMode.IMMEDIATE_MODE);
|
|
|
+ const outputPosition = this.stack.Next().Get(outputMode, true);
|
|
|
|
|
|
const newValue = operandLeft + operandRight;
|
|
|
this.stack.Put(outputPosition, newValue);
|
|
@@ -283,10 +284,11 @@ module.exports = class Computer {
|
|
|
Operation_Multiply(rawOpcode) {
|
|
|
const operandLeftMode = ComputerParameterMode.ParseParameterMode(rawOpcode, 1);
|
|
|
const operandRightMode = ComputerParameterMode.ParseParameterMode(rawOpcode, 2);
|
|
|
+ const outputMode = ComputerParameterMode.ParseParameterMode(rawOpcode, 3) || 1;
|
|
|
|
|
|
const operandLeft = this.stack.Next().Get(operandLeftMode);
|
|
|
const operandRight = this.stack.Next().Get(operandRightMode);
|
|
|
- const outputPosition = this.stack.Next().Get(ComputerParameterMode.IMMEDIATE_MODE);
|
|
|
+ const outputPosition = this.stack.Next().Get(outputMode, true);
|
|
|
|
|
|
const newValue = operandLeft * operandRight;
|
|
|
this.stack.Put(outputPosition, newValue);
|
|
@@ -414,10 +416,11 @@ module.exports = class Computer {
|
|
|
Operation_Equality(rawOpcode, testCondition) {
|
|
|
const operandLeftMode = ComputerParameterMode.ParseParameterMode(rawOpcode, 1);
|
|
|
const operandRightMode = ComputerParameterMode.ParseParameterMode(rawOpcode, 2);
|
|
|
+ const outputMode = ComputerParameterMode.ParseParameterMode(rawOpcode, 3) || 1;
|
|
|
|
|
|
const operandLeft = this.stack.Next().Get(operandLeftMode);
|
|
|
const operandRight = this.stack.Next().Get(operandRightMode);
|
|
|
- const outputPosition = this.stack.Next().Get(ComputerParameterMode.IMMEDIATE_MODE);
|
|
|
+ const outputPosition = this.stack.Next().Get(outputMode, true);
|
|
|
|
|
|
let testPassed = false;
|
|
|
|