MIXAL
machine_load.cpp
Go to the documentation of this file.
1 #include <iostream>
2 #include "machine.h"
3 
9 namespace mixal {
10 
12 void Computer::executeLD(const InstructionWord& instruction, Register5* reg) {
13  int address = getIndexedAddress(instruction, true);
14  copyToRegister5(instruction, memory[address], reg);
15 }
16 
18 void Computer::executeLDi(const InstructionWord& instruction) {
19  int address = getIndexedAddress(instruction, true);
20  int registerIndex = instruction.operation() - Instructions::LD1 + 1;
21  auto& rIi = rI(registerIndex);
22  copyToRegister2(instruction, memory[address], &rIi);
23 }
24 
26 void Computer::executeLDN(const InstructionWord& instruction, Register5* reg) {
27  executeLD(instruction, reg);
28  reg->negative = !reg->negative;
29 }
30 
32 void Computer::executeLDiN(const InstructionWord& instruction) {
33  int address = getIndexedAddress(instruction, true);
34  int registerIndex = instruction.operation() - Instructions::LD1N + 1;
35  auto& rIi = rI(registerIndex);
36  copyToRegister2(instruction, memory[address], &rIi);
37  rIi.negative = 1 - rIi.negative;
38 }
39 
40 }; // namespace mixal
mixal::Computer::memory
ComputerWord memory[NUM_MEMORY]
Definition: machine.h:38
machine.h
The virtual machine.
mixal::Computer::rI
Register2 & rI(int index)
Definition: machine.cpp:16