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"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!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> <qtcreator>
<data> <data>
<variable>EnvironmentId</variable> <variable>EnvironmentId</variable>

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,38 +1,12 @@
# ninja log v6 # 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 521 1765010356080064621 CMakeFiles/simulator.dir/device.cpp.o 36fc5c8cf014f45b
201 1336 1765010356080064621 CMakeFiles/simulator.dir/main.cpp.o 9ebba9b7abc4cbf1 14 1383 1765010511012053000 CMakeFiles/simulator.dir/mainwindow.cpp.o e3901bb2e4f9b516
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
12 22 1765010490368890036 CMakeFiles/simulator.dir/opcode.cpp.o da65f589ec5e1f76 12 22 1765010490368890036 CMakeFiles/simulator.dir/opcode.cpp.o da65f589ec5e1f76
12 1340 1765010490368890036 CMakeFiles/simulator.dir/mainwindow.cpp.o e3901bb2e4f9b516 201 1347 1765010356080064621 CMakeFiles/simulator.dir/simulator_autogen/mocs_compilation.cpp.o 5301f473905a545f
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
2 14 1765010511000055645 /home/aljaz/Desktop/spo/ass2/simulator/build/Desktop_Qt_6_10_1-Debug/simulator_autogen/mocs_compilation.cpp c193a23cfe79571d 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 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 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", "EWIEGA46WW/moc_device.cpp",
null 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", "/home/aljaz/Desktop/spo/ass2/simulator/machine.h",
"MU", "MU",
@ -498,6 +510,8 @@
"SOURCES" : "SOURCES" :
[ [
[ "/home/aljaz/Desktop/spo/ass2/simulator/device.cpp", "MU", null ], [ "/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/machine.cpp", "MU", null ],
[ "/home/aljaz/Desktop/spo/ass2/simulator/main.cpp", "MU", null ], [ "/home/aljaz/Desktop/spo/ass2/simulator/main.cpp", "MU", null ],
[ "/home/aljaz/Desktop/spo/ass2/simulator/mainwindow.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_DIR = CMakeFiles/simulator.dir
OBJECT_FILE_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 # 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 # 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 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 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 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) 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 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(); invalidAddressing();
return false; return false;
} }
@ -205,7 +205,7 @@ bool Machine::execSICF3F4(int opcode, int ni, int operand) {
invalidAddressing(); invalidAddressing();
} }
if (UA + 2 > MAX_ADDRESS) { if (UA < 0 || UA + 2 > MAX_ADDRESS) {
invalidAddressing(); invalidAddressing();
return false; return false;
} }
@ -237,7 +237,7 @@ bool Machine::execSICF3F4(int opcode, int ni, int operand) {
invalidAddressing(); invalidAddressing();
} }
if (UA + 2 > MAX_ADDRESS) { if (UA < 0 || UA + 2 > MAX_ADDRESS) {
invalidAddressing(); invalidAddressing();
return false; return false;
} }
@ -252,149 +252,167 @@ bool Machine::execSICF3F4(int opcode, int ni, int operand) {
} }
} }
switch (opcode) { switch (opcode) {
case Opcode::ADD: case Opcode::ADD:
setA(getA() + UV); setA(getA() + UV);
return true; return true;
case Opcode::AND: case Opcode::AND:
setA(getA() & UV); setA(getA() & UV);
return true; return true;
case Opcode::COMP: case Opcode::COMP:
temp = getA(); temp = getA();
if (temp < UV) { if (temp < UV) {
setSW(0x40); setSW(0x40);
} else if (temp == UV) { } else if (temp == UV) {
setSW(0x0); setSW(0x0);
} else { } else {
setSW(0x80); setSW(0x80);
} }
return true; return true;
break; break;
case Opcode::DIV: case Opcode::DIV:
if (UV == 0) { if (UV == 0) {
cerr << "Error: Divison by zero." << endl; cerr << "Error: Divison by zero." << endl;
return false; return false;
} }
setA(getA() / UV); setA(getA() / UV);
return true; return true;
case Opcode::J: case Opcode::J:
setPC(UV);
return true;
case Opcode::JEQ:
if (getSW() == 0x00) {
setPC(UV); setPC(UV);
} return true;
return true; case Opcode::JEQ:
case Opcode::JGT: if (getSW() == 0x00) {
if (getSW() == 0x80) { 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); setPC(UV);
} return true;
return true; case Opcode::LDA:
case Opcode::JLT: setA(UV);
if (getSW() == 0x40) { return true;
setPC(UV); case Opcode::LDB:
} setB(UV);
return true; return true;
case Opcode::JSUB: case Opcode::LDCH:
setL(getPC()); setA((getA() & 0xFFFF00) | (UV & 0xFF));
setPC(UV); return true;
return true; case Opcode::LDL:
case Opcode::LDA: setL(UV);
setA(UV); return true;
return true; case Opcode::LDS:
case Opcode::LDB: setS(UV);
setB(UV); return true;
return true; case Opcode::LDT:
case Opcode::LDCH: setT(UV);
setA((getA() & 0xFFFF00) | (UV & 0xFF)); return true;
return true; case Opcode::LDX:
case Opcode::LDL: setX(UV);
setL(UV); return true;
return true; case Opcode::MUL:
case Opcode::LDS: setA(getA() * UV);
setS(UV); return true;
return true; case Opcode::OR:
case Opcode::LDT: setA(getA() | UV);
setT(UV); return true;
return true; case Opcode::RD:
case Opcode::LDX: temp = UV & 0xFF;
setX(UV); if (devices[temp] != nullptr) {
return true; setA(devices[temp]->read());
case Opcode::MUL: }
setA(getA() * UV); return true;
return true; case Opcode::RSUB:
case Opcode::OR: setPC(getL());
setA(getA() | UV); return true;
return true; case Opcode::STA:
case Opcode::RD: temp = getA();
temp = UV & 0xFF; memory[UV] = (temp >> 16) & 0xFF;
if (devices[temp] != nullptr) { memory[UV + 1] = (temp >> 8) & 0xFF;
setA(devices[temp]->read()); memory[UV + 2] = temp & 0xFF;
} return true;
return true; case Opcode::STB:
case Opcode::RSUB: temp = getB();
setPC(getL()); memory[UV] = (temp >> 16) & 0xFF;
return true; memory[UV + 1] = (temp >> 8) & 0xFF;
case Opcode::STA: memory[UV + 2] = temp & 0xFF;
temp = getA(); return true;
memory[UV] = (temp >> 16) & 0xFF; case Opcode::STS:
memory[UV + 1] = (temp >> 8) & 0xFF; temp = getS();
memory[UV + 2] = temp & 0xFF; memory[UV] = (temp >> 16) & 0xFF;
return true; memory[UV + 1] = (temp >> 8) & 0xFF;
case Opcode::STCH: memory[UV + 2] = temp & 0xFF;
temp = getA(); return true;
memory[UV] = temp & 0xFF; case Opcode::STT:
return true; temp = getA();
case Opcode::STL: memory[UV] = (temp >> 16) & 0xFF;
temp = getL(); memory[UV + 1] = (temp >> 8) & 0xFF;
memory[UV] = (temp >> 16) & 0xFF; memory[UV + 2] = temp & 0xFF;
memory[UV + 1] = (temp >> 8) & 0xFF; return true;
memory[UV + 2] = temp & 0xFF; case Opcode::STCH:
return true; temp = getA();
case Opcode::STSW: memory[UV] = temp & 0xFF;
temp = getSW(); return true;
memory[UV] = (temp >> 16) & 0xFF; case Opcode::STL:
memory[UV + 1] = (temp >> 8) & 0xFF; temp = getL();
memory[UV + 2] = temp & 0xFF; memory[UV] = (temp >> 16) & 0xFF;
return true; memory[UV + 1] = (temp >> 8) & 0xFF;
case Opcode::STX: memory[UV + 2] = temp & 0xFF;
temp = getX(); return true;
memory[UV] = (temp >> 16) & 0xFF; case Opcode::STSW:
memory[UV + 1] = (temp >> 8) & 0xFF; temp = getSW();
memory[UV + 2] = temp & 0xFF; memory[UV] = (temp >> 16) & 0xFF;
return true; memory[UV + 1] = (temp >> 8) & 0xFF;
case Opcode::SUB: memory[UV + 2] = temp & 0xFF;
setA(getA() - UV); return true;
return true; case Opcode::STX:
case Opcode::TD: temp = getX();
temp = UV & 0xFF; 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; ready = false;
if (devices[temp] != nullptr) { if (devices[temp] != nullptr) {
ready = devices[temp]->test(); ready = devices[temp]->test();
} }
if (ready) { if (ready) {
setSW(0X40); setSW(0X40);
} else { } else {
setSW(0x00); setSW(0x00);
} }
return true; return true;
case Opcode::TIX: case Opcode::TIX:
temp = getX(); temp = getX();
setX(temp + 1); setX(temp + 1);
if (temp < UV) setSW(0x40); if (temp < UV) setSW(0x40);
else if (temp == UV) setSW(0x00); else if (temp == UV) setSW(0x00);
else setSW(0x80); else setSW(0x80);
return true; return true;
case Opcode::WD: case Opcode::WD:
temp = UV & 0xFF; temp = UV & 0xFF;
if (devices[temp] != nullptr) { if (devices[temp] != nullptr) {
devices[temp]->write(getA() & 0xFF); devices[temp]->write(getA() & 0xFF);
} }
return true; return true;
default: default:
notImplemented(opcode); notImplemented(opcode);
break; break;
} }
return false; return false;
} }

View file

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