|
@@ -95,7 +95,7 @@ module.exports = class Computer {
|
|
|
break;
|
|
|
}
|
|
|
case this.OPCODES.OUTPUT: {
|
|
|
- this.Operation_Output();
|
|
|
+ this.Operation_Output(rawOpcode);
|
|
|
break;
|
|
|
}
|
|
|
case this.OPCODES.JUMP_IF_TRUE: {
|
|
@@ -201,13 +201,15 @@ module.exports = class Computer {
|
|
|
/**
|
|
|
* Execute the OUTPUT opcode
|
|
|
*
|
|
|
+ * @param {number} rawOpcode The opcode in memory used to make this call
|
|
|
* @returns {void}
|
|
|
*/
|
|
|
- Operation_Output() {
|
|
|
+ Operation_Output(rawOpcode) {
|
|
|
const currAddress = this.stack.pointer;
|
|
|
- const outputPosition = this.stack.Next().Get(ComputerParameterMode.IMMEDIATE_MODE);
|
|
|
+ const outputPositionMode = ComputerParameterMode.ParseParameterMode(rawOpcode, 1);
|
|
|
+ const output = this.stack.Next().Get(outputPositionMode);
|
|
|
|
|
|
- console.log(`OUTPUT FROM ADDRESS ${currAddress}: ${this.stack.GetAtIndex(outputPosition, ComputerParameterMode.IMMEDIATE_MODE)}`);
|
|
|
+ console.log(`OUTPUT FROM ADDRESS ${currAddress}: ${output}`);
|
|
|
}
|
|
|
|
|
|
/**
|