checkpoint

This commit is contained in:
aljazbrodar. 2025-12-07 09:56:50 +01:00
parent 4c6c4b8a22
commit 3c876211c2
35 changed files with 365 additions and 207 deletions

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 18.0.0, 2025-12-06T15:29:50. -->
<!-- Written by QtCreator 18.0.0, 2025-12-06T16:44:56. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>

View file

@ -16,6 +16,9 @@ qt_add_executable(simulator
device.h
device.cpp
opcode.h opcode.cpp
executor.h executor.cpp
loader.h loader.cpp
)
target_link_libraries(simulator

View file

@ -7,7 +7,7 @@
{
"build" : ".",
"hasInstallRule" : true,
"jsonFile" : "directory-.-Debug-b6d99062396e1794a7ce.json",
"jsonFile" : "directory-.-Debug-37186cc2dcdc365a64e7.json",
"minimumCMakeVersion" :
{
"string" : "3.16"
@ -44,7 +44,7 @@
{
"directoryIndex" : 0,
"id" : "simulator::@6890427a1f51a3e7e1df",
"jsonFile" : "target-simulator-Debug-0cbdc686daa89d68b1d7.json",
"jsonFile" : "target-simulator-Debug-2b3217783aa5062c29e1.json",
"name" : "simulator",
"projectIndex" : 0
},

View file

@ -17,13 +17,13 @@
{
"command" : 0,
"file" : 0,
"line" : 29,
"line" : 31,
"parent" : 0
},
{
"command" : 0,
"file" : 0,
"line" : 40,
"line" : 42,
"parent" : 0
}
]

View file

@ -26,7 +26,7 @@
"objects" :
[
{
"jsonFile" : "codemodel-v2-fc5483802601394ec595.json",
"jsonFile" : "codemodel-v2-bf109316b2adb0d27109.json",
"kind" : "codemodel",
"version" :
{
@ -77,7 +77,7 @@
},
"codemodel-v2" :
{
"jsonFile" : "codemodel-v2-fc5483802601394ec595.json",
"jsonFile" : "codemodel-v2-bf109316b2adb0d27109.json",
"kind" : "codemodel",
"version" :
{

View file

@ -71,13 +71,13 @@
{
"command" : 4,
"file" : 1,
"line" : 29,
"line" : 31,
"parent" : 0
},
{
"command" : 5,
"file" : 1,
"line" : 21,
"line" : 23,
"parent" : 0
},
{
@ -292,7 +292,8 @@
2,
6,
8,
10
10,
12
]
}
],
@ -383,8 +384,8 @@
"sourceIndexes" :
[
0,
11,
12
13,
14
]
},
{
@ -395,7 +396,8 @@
2,
6,
8,
10
10,
12
]
},
{
@ -405,7 +407,8 @@
3,
5,
7,
9
9,
11
]
},
{
@ -419,7 +422,7 @@
"name" : "CMake Rules",
"sourceIndexes" :
[
13
15
]
}
],
@ -487,6 +490,17 @@
"path" : "opcode.cpp",
"sourceGroupIndex" : 1
},
{
"backtrace" : 4,
"path" : "executor.h",
"sourceGroupIndex" : 2
},
{
"backtrace" : 4,
"compileGroupIndex" : 0,
"path" : "executor.cpp",
"sourceGroupIndex" : 1
},
{
"backtrace" : 0,
"isGenerated" : true,

View file

@ -7,7 +7,7 @@
{
"build" : ".",
"hasInstallRule" : true,
"jsonFile" : "directory-.-Debug-9e88f268bb4c5fb675f4.json",
"jsonFile" : "directory-.-Debug-b087ac99b4952b24d922.json",
"minimumCMakeVersion" :
{
"string" : "3.16"
@ -44,7 +44,7 @@
{
"directoryIndex" : 0,
"id" : "simulator::@6890427a1f51a3e7e1df",
"jsonFile" : "target-simulator-Debug-44f8bd757c2b053c3c98.json",
"jsonFile" : "target-simulator-Debug-edef6bab040a42101471.json",
"name" : "simulator",
"projectIndex" : 0
},

View file

@ -17,13 +17,13 @@
{
"command" : 0,
"file" : 0,
"line" : 28,
"line" : 32,
"parent" : 0
},
{
"command" : 0,
"file" : 0,
"line" : 39,
"line" : 43,
"parent" : 0
}
]

View file

@ -26,7 +26,7 @@
"objects" :
[
{
"jsonFile" : "codemodel-v2-8462ebb8de7ac0ba3995.json",
"jsonFile" : "codemodel-v2-9908d093f7d320a6f887.json",
"kind" : "codemodel",
"version" :
{
@ -77,7 +77,7 @@
},
"codemodel-v2" :
{
"jsonFile" : "codemodel-v2-8462ebb8de7ac0ba3995.json",
"jsonFile" : "codemodel-v2-9908d093f7d320a6f887.json",
"kind" : "codemodel",
"version" :
{

View file

@ -71,13 +71,13 @@
{
"command" : 4,
"file" : 1,
"line" : 28,
"line" : 32,
"parent" : 0
},
{
"command" : 5,
"file" : 1,
"line" : 20,
"line" : 24,
"parent" : 0
},
{
@ -291,7 +291,10 @@
1,
2,
6,
8
8,
10,
12,
14
]
}
],
@ -382,8 +385,8 @@
"sourceIndexes" :
[
0,
9,
10
15,
16
]
},
{
@ -393,7 +396,10 @@
1,
2,
6,
8
8,
10,
12,
14
]
},
{
@ -402,7 +408,10 @@
[
3,
5,
7
7,
9,
11,
13
]
},
{
@ -416,7 +425,7 @@
"name" : "CMake Rules",
"sourceIndexes" :
[
11
17
]
}
],
@ -473,6 +482,39 @@
"path" : "device.cpp",
"sourceGroupIndex" : 1
},
{
"backtrace" : 4,
"path" : "opcode.h",
"sourceGroupIndex" : 2
},
{
"backtrace" : 4,
"compileGroupIndex" : 0,
"path" : "opcode.cpp",
"sourceGroupIndex" : 1
},
{
"backtrace" : 4,
"path" : "executor.h",
"sourceGroupIndex" : 2
},
{
"backtrace" : 4,
"compileGroupIndex" : 0,
"path" : "executor.cpp",
"sourceGroupIndex" : 1
},
{
"backtrace" : 4,
"path" : "loader.h",
"sourceGroupIndex" : 2
},
{
"backtrace" : 4,
"compileGroupIndex" : 0,
"path" : "loader.cpp",
"sourceGroupIndex" : 1
},
{
"backtrace" : 0,
"isGenerated" : true,

View file

@ -1,38 +1,12 @@
# ninja log v6
16 224 1764073111478991803 CMakeFiles/simulator.dir/device.cpp.o 36fc5c8cf014f45b
15 1296 1764073111477991803 CMakeFiles/simulator.dir/mainwindow.cpp.o e3901bb2e4f9b516
197 1160 1763912062733203284 CMakeFiles/simulator.dir/simulator_autogen/mocs_compilation.cpp.o 5301f473905a545f
3 15 1764073111465991803 /home/aljaz/Desktop/spo/ass2/simulator/build/Desktop_Qt_6_10_1-Debug/simulator_autogen/mocs_compilation.cpp c193a23cfe79571d
197 384 1763912062733203284 CMakeFiles/simulator.dir/machine.cpp.o 7030a03f8cbf1ad0
197 1417 1763912062733203284 CMakeFiles/simulator.dir/main.cpp.o 9ebba9b7abc4cbf1
3 15 1764073111465991803 /home/aljaz/Desktop/spo/ass2/simulator/build/Desktop_Qt_6_10_1-Debug/simulator_autogen/timestamp c193a23cfe79571d
1296 1566 1764073112758991795 simulator fb8524dc610350ca
3 15 1764073111465991803 simulator_autogen/mocs_compilation.cpp c193a23cfe79571d
3 15 1764073111465991803 simulator_autogen/timestamp c193a23cfe79571d
3 201 1765010356075067547 simulator_autogen/timestamp c193a23cfe79571d
3 201 1765010356075067547 simulator_autogen/mocs_compilation.cpp c193a23cfe79571d
3 201 1765010356075067547 /home/aljaz/Desktop/spo/ass2/simulator/build/Desktop_Qt_6_10_1-Debug/simulator_autogen/timestamp c193a23cfe79571d
3 201 1765010356075067547 /home/aljaz/Desktop/spo/ass2/simulator/build/Desktop_Qt_6_10_1-Debug/simulator_autogen/mocs_compilation.cpp c193a23cfe79571d
201 521 1765010356080064621 CMakeFiles/simulator.dir/device.cpp.o 36fc5c8cf014f45b
201 1336 1765010356080064621 CMakeFiles/simulator.dir/main.cpp.o 9ebba9b7abc4cbf1
201 1347 1765010356080064621 CMakeFiles/simulator.dir/simulator_autogen/mocs_compilation.cpp.o 5301f473905a545f
201 1945 1765010356080064621 CMakeFiles/simulator.dir/mainwindow.cpp.o e3901bb2e4f9b516
2 12 1765010490358892516 simulator_autogen/timestamp c193a23cfe79571d
2 12 1765010490358892516 simulator_autogen/mocs_compilation.cpp c193a23cfe79571d
2 12 1765010490358892516 /home/aljaz/Desktop/spo/ass2/simulator/build/Desktop_Qt_6_10_1-Debug/simulator_autogen/timestamp c193a23cfe79571d
2 12 1765010490358892516 /home/aljaz/Desktop/spo/ass2/simulator/build/Desktop_Qt_6_10_1-Debug/simulator_autogen/mocs_compilation.cpp c193a23cfe79571d
14 1383 1765010511012053000 CMakeFiles/simulator.dir/mainwindow.cpp.o e3901bb2e4f9b516
12 22 1765010490368890036 CMakeFiles/simulator.dir/opcode.cpp.o da65f589ec5e1f76
12 1340 1765010490368890036 CMakeFiles/simulator.dir/mainwindow.cpp.o e3901bb2e4f9b516
1 12 1765010498397941821 simulator_autogen/timestamp c193a23cfe79571d
1 12 1765010498397941821 simulator_autogen/mocs_compilation.cpp c193a23cfe79571d
1 12 1765010498397941821 /home/aljaz/Desktop/spo/ass2/simulator/build/Desktop_Qt_6_10_1-Debug/simulator_autogen/timestamp c193a23cfe79571d
1 12 1765010498397941821 /home/aljaz/Desktop/spo/ass2/simulator/build/Desktop_Qt_6_10_1-Debug/simulator_autogen/mocs_compilation.cpp c193a23cfe79571d
13 196 1765010498409938977 CMakeFiles/simulator.dir/machine.cpp.o 7030a03f8cbf1ad0
12 1363 1765010498408939214 CMakeFiles/simulator.dir/mainwindow.cpp.o e3901bb2e4f9b516
2 14 1765010511000055645 simulator_autogen/timestamp c193a23cfe79571d
2 14 1765010511000055645 simulator_autogen/mocs_compilation.cpp c193a23cfe79571d
2 14 1765010511000055645 /home/aljaz/Desktop/spo/ass2/simulator/build/Desktop_Qt_6_10_1-Debug/simulator_autogen/timestamp c193a23cfe79571d
201 1347 1765010356080064621 CMakeFiles/simulator.dir/simulator_autogen/mocs_compilation.cpp.o 5301f473905a545f
2 14 1765010511000055645 /home/aljaz/Desktop/spo/ass2/simulator/build/Desktop_Qt_6_10_1-Debug/simulator_autogen/mocs_compilation.cpp c193a23cfe79571d
14 192 1765010511012053000 CMakeFiles/simulator.dir/machine.cpp.o 7030a03f8cbf1ad0
14 1383 1765010511012053000 CMakeFiles/simulator.dir/mainwindow.cpp.o e3901bb2e4f9b516
201 1336 1765010356080064621 CMakeFiles/simulator.dir/main.cpp.o 9ebba9b7abc4cbf1
2 14 1765010511000055645 /home/aljaz/Desktop/spo/ass2/simulator/build/Desktop_Qt_6_10_1-Debug/simulator_autogen/timestamp c193a23cfe79571d
1383 1623 1765010512380751634 simulator 9e4eca252dc331ef
2 14 1765010511000055645 simulator_autogen/mocs_compilation.cpp c193a23cfe79571d
2 14 1765010511000055645 simulator_autogen/timestamp c193a23cfe79571d

File diff suppressed because one or more lines are too long

View file

@ -420,6 +420,18 @@
"EWIEGA46WW/moc_device.cpp",
null
],
[
"/home/aljaz/Desktop/spo/ass2/simulator/executor.h",
"MU",
"EWIEGA46WW/moc_executor.cpp",
null
],
[
"/home/aljaz/Desktop/spo/ass2/simulator/loader.h",
"MU",
"EWIEGA46WW/moc_loader.cpp",
null
],
[
"/home/aljaz/Desktop/spo/ass2/simulator/machine.h",
"MU",
@ -498,6 +510,8 @@
"SOURCES" :
[
[ "/home/aljaz/Desktop/spo/ass2/simulator/device.cpp", "MU", null ],
[ "/home/aljaz/Desktop/spo/ass2/simulator/executor.cpp", "MU", null ],
[ "/home/aljaz/Desktop/spo/ass2/simulator/loader.cpp", "MU", null ],
[ "/home/aljaz/Desktop/spo/ass2/simulator/machine.cpp", "MU", null ],
[ "/home/aljaz/Desktop/spo/ass2/simulator/main.cpp", "MU", null ],
[ "/home/aljaz/Desktop/spo/ass2/simulator/mainwindow.cpp", "MU", null ],

View file

@ -1,3 +1,3 @@
Start testing: Dec 06 09:36 CET
Start testing: Dec 07 09:37 CET
----------------------------------------------------------
End testing: Dec 06 09:36 CET
End testing: Dec 07 09:37 CET

View file

@ -97,6 +97,22 @@ build CMakeFiles/simulator.dir/opcode.cpp.o: CXX_COMPILER__simulator_unscanned_D
OBJECT_DIR = CMakeFiles/simulator.dir
OBJECT_FILE_DIR = CMakeFiles/simulator.dir
build CMakeFiles/simulator.dir/executor.cpp.o: CXX_COMPILER__simulator_unscanned_Debug /home/aljaz/Desktop/spo/ass2/simulator/executor.cpp || cmake_object_order_depends_target_simulator
DEFINES = -DQT_CORE_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB
DEP_FILE = CMakeFiles/simulator.dir/executor.cpp.o.d
FLAGS = -DQT_QML_DEBUG -g -fdiagnostics-color=always -fPIC
INCLUDES = -I/home/aljaz/Desktop/spo/ass2/simulator/build/Desktop_Qt_6_10_1-Debug/simulator_autogen/include -isystem /home/aljaz/Qt/6.10.1/gcc_64/include/QtCore -isystem /home/aljaz/Qt/6.10.1/gcc_64/include -isystem /home/aljaz/Qt/6.10.1/gcc_64/mkspecs/linux-g++ -isystem /home/aljaz/Qt/6.10.1/gcc_64/include/QtWidgets -isystem /home/aljaz/Qt/6.10.1/gcc_64/include/QtGui
OBJECT_DIR = CMakeFiles/simulator.dir
OBJECT_FILE_DIR = CMakeFiles/simulator.dir
build CMakeFiles/simulator.dir/loader.cpp.o: CXX_COMPILER__simulator_unscanned_Debug /home/aljaz/Desktop/spo/ass2/simulator/loader.cpp || cmake_object_order_depends_target_simulator
DEFINES = -DQT_CORE_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB
DEP_FILE = CMakeFiles/simulator.dir/loader.cpp.o.d
FLAGS = -DQT_QML_DEBUG -g -fdiagnostics-color=always -fPIC
INCLUDES = -I/home/aljaz/Desktop/spo/ass2/simulator/build/Desktop_Qt_6_10_1-Debug/simulator_autogen/include -isystem /home/aljaz/Qt/6.10.1/gcc_64/include/QtCore -isystem /home/aljaz/Qt/6.10.1/gcc_64/include -isystem /home/aljaz/Qt/6.10.1/gcc_64/mkspecs/linux-g++ -isystem /home/aljaz/Qt/6.10.1/gcc_64/include/QtWidgets -isystem /home/aljaz/Qt/6.10.1/gcc_64/include/QtGui
OBJECT_DIR = CMakeFiles/simulator.dir
OBJECT_FILE_DIR = CMakeFiles/simulator.dir
# =============================================================================
# Link build statements for EXECUTABLE target simulator
@ -105,7 +121,7 @@ build CMakeFiles/simulator.dir/opcode.cpp.o: CXX_COMPILER__simulator_unscanned_D
#############################################
# Link the executable simulator
build simulator: CXX_EXECUTABLE_LINKER__simulator_Debug CMakeFiles/simulator.dir/simulator_autogen/mocs_compilation.cpp.o CMakeFiles/simulator.dir/main.cpp.o CMakeFiles/simulator.dir/mainwindow.cpp.o CMakeFiles/simulator.dir/machine.cpp.o CMakeFiles/simulator.dir/device.cpp.o CMakeFiles/simulator.dir/opcode.cpp.o | /home/aljaz/Qt/6.10.1/gcc_64/lib/libQt6Widgets.so.6.10.1 /home/aljaz/Qt/6.10.1/gcc_64/lib/libQt6Gui.so.6.10.1 /usr/lib/x86_64-linux-gnu/libGLX.so /usr/lib/x86_64-linux-gnu/libOpenGL.so /home/aljaz/Qt/6.10.1/gcc_64/lib/libQt6Core.so.6.10.1 || simulator_autogen simulator_autogen_timestamp_deps
build simulator: CXX_EXECUTABLE_LINKER__simulator_Debug CMakeFiles/simulator.dir/simulator_autogen/mocs_compilation.cpp.o CMakeFiles/simulator.dir/main.cpp.o CMakeFiles/simulator.dir/mainwindow.cpp.o CMakeFiles/simulator.dir/machine.cpp.o CMakeFiles/simulator.dir/device.cpp.o CMakeFiles/simulator.dir/opcode.cpp.o CMakeFiles/simulator.dir/executor.cpp.o CMakeFiles/simulator.dir/loader.cpp.o | /home/aljaz/Qt/6.10.1/gcc_64/lib/libQt6Widgets.so.6.10.1 /home/aljaz/Qt/6.10.1/gcc_64/lib/libQt6Gui.so.6.10.1 /usr/lib/x86_64-linux-gnu/libGLX.so /usr/lib/x86_64-linux-gnu/libOpenGL.so /home/aljaz/Qt/6.10.1/gcc_64/lib/libQt6Core.so.6.10.1 || simulator_autogen simulator_autogen_timestamp_deps
FLAGS = -DQT_QML_DEBUG -g
LINK_LIBRARIES = -Wl,-rpath,/home/aljaz/Qt/6.10.1/gcc_64/lib: /home/aljaz/Qt/6.10.1/gcc_64/lib/libQt6Widgets.so.6.10.1 /home/aljaz/Qt/6.10.1/gcc_64/lib/libQt6Gui.so.6.10.1 /usr/lib/x86_64-linux-gnu/libGLX.so /usr/lib/x86_64-linux-gnu/libOpenGL.so /home/aljaz/Qt/6.10.1/gcc_64/lib/libQt6Core.so.6.10.1 -Wl,-rpath-link,/home/aljaz/Qt/6.10.1/gcc_64/lib
OBJECT_DIR = CMakeFiles/simulator.dir

View file

@ -0,0 +1,27 @@
#include "executor.h"
#include "machine.cpp"
#include<chrono>
#include<thread>
Executor::Executor() {}
void Executor::start() {
running = true;
while (running) {
machine->execute();
std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
}
void Executor::stop() {
running = false;
}
bool Executor::isRunning() {
return running;
}
void Executor::step() {
machine->execute();
}

26
ass2/simulator/executor.h Normal file
View file

@ -0,0 +1,26 @@
#ifndef EXECUTOR_H
#define EXECUTOR_H
class Machine;
class Executor
{
private:
bool running = false;
Machine* machine;
public:
Executor();
// Zažene oz. nadaljuje samodejno izvajanje.
void start();
// Zaustavi samodejno izvajanje.
void stop();
// Pove, ali je samodejno izvajanje trenutno v teku.
bool isRunning();
// Izvede en ukaz.
void step();
};
#endif // EXECUTOR_H

View file

@ -0,0 +1,3 @@
#include "loader.h"
Loader::Loader() {}

19
ass2/simulator/loader.h Normal file
View file

@ -0,0 +1,19 @@
#ifndef LOADER_H
#define LOADER_H
#include <string>
class Loader
{
public:
Loader();
// Prebere niz dolžine len
std::string readString(string &r, int len);
// Prebere en bajt (2 heksadecimalni znaka)
int readByte(std::string &r);
// Prebere eno "besedo" (3 bajte = 6 heksadecimalnih znakov)
int readWord(std::string &r);
};
#endif // LOADER_H

View file

@ -181,7 +181,7 @@ bool Machine::execSICF3F4(int opcode, int ni, int operand) {
if (ni == 0) { // stari SIC (neposredno in enostavno naslavljanje)
UA = (((operand & 0x7F) << 8) | operand2) + x_val; //izracun uporabnega naslova: operand brez bita x + drugi del naslova + x_val
if (UA + 2 > MAX_ADDRESS) {
if (UA < 0 || UA + 2 > MAX_ADDRESS) {
invalidAddressing();
return false;
}
@ -205,7 +205,7 @@ bool Machine::execSICF3F4(int opcode, int ni, int operand) {
invalidAddressing();
}
if (UA + 2 > MAX_ADDRESS) {
if (UA < 0 || UA + 2 > MAX_ADDRESS) {
invalidAddressing();
return false;
}
@ -237,7 +237,7 @@ bool Machine::execSICF3F4(int opcode, int ni, int operand) {
invalidAddressing();
}
if (UA + 2 > MAX_ADDRESS) {
if (UA < 0 || UA + 2 > MAX_ADDRESS) {
invalidAddressing();
return false;
}
@ -252,149 +252,167 @@ bool Machine::execSICF3F4(int opcode, int ni, int operand) {
}
}
switch (opcode) {
case Opcode::ADD:
setA(getA() + UV);
return true;
case Opcode::AND:
setA(getA() & UV);
return true;
case Opcode::COMP:
temp = getA();
if (temp < UV) {
setSW(0x40);
} else if (temp == UV) {
setSW(0x0);
} else {
setSW(0x80);
}
return true;
break;
case Opcode::DIV:
if (UV == 0) {
cerr << "Error: Divison by zero." << endl;
return false;
}
setA(getA() / UV);
return true;
case Opcode::J:
setPC(UV);
return true;
case Opcode::JEQ:
if (getSW() == 0x00) {
case Opcode::ADD:
setA(getA() + UV);
return true;
case Opcode::AND:
setA(getA() & UV);
return true;
case Opcode::COMP:
temp = getA();
if (temp < UV) {
setSW(0x40);
} else if (temp == UV) {
setSW(0x0);
} else {
setSW(0x80);
}
return true;
break;
case Opcode::DIV:
if (UV == 0) {
cerr << "Error: Divison by zero." << endl;
return false;
}
setA(getA() / UV);
return true;
case Opcode::J:
setPC(UV);
}
return true;
case Opcode::JGT:
if (getSW() == 0x80) {
return true;
case Opcode::JEQ:
if (getSW() == 0x00) {
setPC(UV);
}
return true;
case Opcode::JGT:
if (getSW() == 0x80) {
setPC(UV);
}
return true;
case Opcode::JLT:
if (getSW() == 0x40) {
setPC(UV);
}
return true;
case Opcode::JSUB:
setL(getPC());
setPC(UV);
}
return true;
case Opcode::JLT:
if (getSW() == 0x40) {
setPC(UV);
}
return true;
case Opcode::JSUB:
setL(getPC());
setPC(UV);
return true;
case Opcode::LDA:
setA(UV);
return true;
case Opcode::LDB:
setB(UV);
return true;
case Opcode::LDCH:
setA((getA() & 0xFFFF00) | (UV & 0xFF));
return true;
case Opcode::LDL:
setL(UV);
return true;
case Opcode::LDS:
setS(UV);
return true;
case Opcode::LDT:
setT(UV);
return true;
case Opcode::LDX:
setX(UV);
return true;
case Opcode::MUL:
setA(getA() * UV);
return true;
case Opcode::OR:
setA(getA() | UV);
return true;
case Opcode::RD:
temp = UV & 0xFF;
if (devices[temp] != nullptr) {
setA(devices[temp]->read());
}
return true;
case Opcode::RSUB:
setPC(getL());
return true;
case Opcode::STA:
temp = getA();
memory[UV] = (temp >> 16) & 0xFF;
memory[UV + 1] = (temp >> 8) & 0xFF;
memory[UV + 2] = temp & 0xFF;
return true;
case Opcode::STCH:
temp = getA();
memory[UV] = temp & 0xFF;
return true;
case Opcode::STL:
temp = getL();
memory[UV] = (temp >> 16) & 0xFF;
memory[UV + 1] = (temp >> 8) & 0xFF;
memory[UV + 2] = temp & 0xFF;
return true;
case Opcode::STSW:
temp = getSW();
memory[UV] = (temp >> 16) & 0xFF;
memory[UV + 1] = (temp >> 8) & 0xFF;
memory[UV + 2] = temp & 0xFF;
return true;
case Opcode::STX:
temp = getX();
memory[UV] = (temp >> 16) & 0xFF;
memory[UV + 1] = (temp >> 8) & 0xFF;
memory[UV + 2] = temp & 0xFF;
return true;
case Opcode::SUB:
setA(getA() - UV);
return true;
case Opcode::TD:
temp = UV & 0xFF;
return true;
case Opcode::LDA:
setA(UV);
return true;
case Opcode::LDB:
setB(UV);
return true;
case Opcode::LDCH:
setA((getA() & 0xFFFF00) | (UV & 0xFF));
return true;
case Opcode::LDL:
setL(UV);
return true;
case Opcode::LDS:
setS(UV);
return true;
case Opcode::LDT:
setT(UV);
return true;
case Opcode::LDX:
setX(UV);
return true;
case Opcode::MUL:
setA(getA() * UV);
return true;
case Opcode::OR:
setA(getA() | UV);
return true;
case Opcode::RD:
temp = UV & 0xFF;
if (devices[temp] != nullptr) {
setA(devices[temp]->read());
}
return true;
case Opcode::RSUB:
setPC(getL());
return true;
case Opcode::STA:
temp = getA();
memory[UV] = (temp >> 16) & 0xFF;
memory[UV + 1] = (temp >> 8) & 0xFF;
memory[UV + 2] = temp & 0xFF;
return true;
case Opcode::STB:
temp = getB();
memory[UV] = (temp >> 16) & 0xFF;
memory[UV + 1] = (temp >> 8) & 0xFF;
memory[UV + 2] = temp & 0xFF;
return true;
case Opcode::STS:
temp = getS();
memory[UV] = (temp >> 16) & 0xFF;
memory[UV + 1] = (temp >> 8) & 0xFF;
memory[UV + 2] = temp & 0xFF;
return true;
case Opcode::STT:
temp = getA();
memory[UV] = (temp >> 16) & 0xFF;
memory[UV + 1] = (temp >> 8) & 0xFF;
memory[UV + 2] = temp & 0xFF;
return true;
case Opcode::STCH:
temp = getA();
memory[UV] = temp & 0xFF;
return true;
case Opcode::STL:
temp = getL();
memory[UV] = (temp >> 16) & 0xFF;
memory[UV + 1] = (temp >> 8) & 0xFF;
memory[UV + 2] = temp & 0xFF;
return true;
case Opcode::STSW:
temp = getSW();
memory[UV] = (temp >> 16) & 0xFF;
memory[UV + 1] = (temp >> 8) & 0xFF;
memory[UV + 2] = temp & 0xFF;
return true;
case Opcode::STX:
temp = getX();
memory[UV] = (temp >> 16) & 0xFF;
memory[UV + 1] = (temp >> 8) & 0xFF;
memory[UV + 2] = temp & 0xFF;
return true;
case Opcode::SUB:
setA(getA() - UV);
return true;
case Opcode::TD:
temp = UV & 0xFF;
ready = false;
if (devices[temp] != nullptr) {
ready = devices[temp]->test();
}
if (ready) {
setSW(0X40);
} else {
setSW(0x00);
}
ready = false;
if (devices[temp] != nullptr) {
ready = devices[temp]->test();
}
if (ready) {
setSW(0X40);
} else {
setSW(0x00);
}
return true;
case Opcode::TIX:
temp = getX();
setX(temp + 1);
if (temp < UV) setSW(0x40);
else if (temp == UV) setSW(0x00);
else setSW(0x80);
return true;
case Opcode::WD:
temp = UV & 0xFF;
if (devices[temp] != nullptr) {
devices[temp]->write(getA() & 0xFF);
}
return true;
default:
notImplemented(opcode);
break;
return true;
case Opcode::TIX:
temp = getX();
setX(temp + 1);
if (temp < UV) setSW(0x40);
else if (temp == UV) setSW(0x00);
else setSW(0x80);
return true;
case Opcode::WD:
temp = UV & 0xFF;
if (devices[temp] != nullptr) {
devices[temp]->write(getA() & 0xFF);
}
return true;
default:
notImplemented(opcode);
break;
}
return false;
}

View file

@ -68,6 +68,8 @@ public:
bool execF2(int opcode, int operand);
bool execSICF3F4(int opcode, int ni, int operand);
bool loadSection(Reader r);
};
#endif