|
@@ -37,6 +37,7 @@ module.exports = class Computer {
|
|
|
JUMP_IF_FALSE: 6,
|
|
|
LESS_THAN: 7,
|
|
|
EQUALS: 8,
|
|
|
+ MODIFY_RELATIVE_BASE: 9,
|
|
|
HALT: 99,
|
|
|
};
|
|
|
|
|
@@ -212,6 +213,10 @@ module.exports = class Computer {
|
|
|
this.running = false;
|
|
|
status = false;
|
|
|
break;
|
|
|
+ case this.OPCODES.MODIFY_RELATIVE_BASE: {
|
|
|
+ this.Operation_ModifyRelativeBase(rawOpcode);
|
|
|
+ break;
|
|
|
+ }
|
|
|
default:
|
|
|
this.ThrowError(`Opcode ${opcode} not found`);
|
|
|
}
|
|
@@ -425,6 +430,19 @@ module.exports = class Computer {
|
|
|
this.stack.Put(outputPosition, Number(testPassed));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Adjusts the current relative base offset of the computer
|
|
|
+ *
|
|
|
+ * @param {number} rawOpcode The opcode in memory used to make this call
|
|
|
+ * @returns {void}
|
|
|
+ */
|
|
|
+ Operation_ModifyRelativeBase(rawOpcode) {
|
|
|
+ const operandMode = ComputerParameterMode.ParseParameterMode(rawOpcode);
|
|
|
+ const adjustmentValue = this.stack.Next().Get(operandMode);
|
|
|
+
|
|
|
+ this.stack.AdjustRelativeBaseOffset(adjustmentValue);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Inspects various parts of the computer before every call to Execution
|
|
|
*
|