Setting values on registries

This commit is contained in:
2026-02-10 02:41:29 +02:00
parent e8850f37bc
commit c8d565d8b2

View File

@@ -37,8 +37,11 @@ enum : int {
SetTo, SetTo,
JumpTo, JumpTo,
Print, Print,
// Registry
StoreValueIn, StoreValueIn,
PutValueIn, PutValueIn,
SetValueIn, // Three Argumens!!
// Type // Type
W, W,
@@ -60,6 +63,7 @@ public:
private: private:
Command State = NoCommand; Command State = NoCommand;
int selectedRegistry = 0;
std::array<int, maxCells> memory; std::array<int, maxCells> memory;
int RW = 0, RX = 0, RY = 0, RZ = 0; int RW = 0, RX = 0, RY = 0, RZ = 0;
std::size_t currentPosition = 0; std::size_t currentPosition = 0;
@@ -97,10 +101,17 @@ private:
case StoreValueIn: case StoreValueIn:
whichRegistry(command) = memory[currentPosition]; whichRegistry(command) = memory[currentPosition];
break; break;
case PutValueIn: case PutValueIn:
memory[currentPosition] = whichRegistry(command); memory[currentPosition] = whichRegistry(command);
break; break;
case SetValueIn:
if (selectedRegistry == 0) {
selectedRegistry = command;
return;
}
whichRegistry(selectedRegistry) = command;
selectedRegistry = 0;
break;
case Print: case Print:
handlePrint(command); handlePrint(command);
@@ -112,7 +123,7 @@ private:
} }
// This is only called after multi-argument functions are done // This is only called after multi-argument functions are done
if (State != NoCommand) { if (State != NoCommand && selectedRegistry == 0) {
State = NoCommand; State = NoCommand;
return; return;
} }
@@ -140,12 +151,15 @@ private:
--memory[currentPosition]; --memory[currentPosition];
return; return;
// Double Argument Commands // Multi Argument Commands
case Print: case Print:
case JumpTo: case JumpTo:
case SetTo:
case StoreValueIn: case StoreValueIn:
case PutValueIn: case PutValueIn:
case SetValueIn:
case SetTo:
case IncrementBy: case IncrementBy:
case DecrementBy: case DecrementBy:
case MultiplyBy: case MultiplyBy: