execf34s restructuring

This commit is contained in:
aljazbrodar. 2025-12-06 16:37:07 +01:00
parent b105f4cc6a
commit 4c6c4b8a22
2 changed files with 218 additions and 160 deletions

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 18.0.0, 2025-12-04T14:58:13. -->
<!-- Written by QtCreator 18.0.0, 2025-12-06T15:29:50. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
@ -105,16 +105,16 @@
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_COLOR_DIAGNOSTICS:BOOL=ON
-DCMAKE_BUILD_TYPE:STRING=Debug
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DQT_MAINTENANCE_TOOL:FILEPATH=/home/aljaz/Qt/MaintenanceTool
-DCMAKE_BUILD_TYPE:STRING=Debug
-DCMAKE_GENERATOR:STRING=Ninja
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake</value>
-DCMAKE_COLOR_DIAGNOSTICS:BOOL=ON
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}</value>
<value type="int" key="EnableQmlDebugging">0</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/aljaz/Desktop/spo/ass2/simulator/build/Desktop_Qt_6_10_1-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">

View file

@ -170,15 +170,15 @@ bool Machine::execF2(int opcode, int operand) {
bool Machine::execSICF3F4(int opcode, int ni, int operand) {
int x_val = 0;
int operand2 = fetch();
int UA;
int UV;
int temp;
int UA = 0;
int UV = 0;
int temp = 0;
bool ready = false;
if (ni == 0) { // stari SIC (neposredno in enostavno naslavljanje)
int offset = 0;
if (((operand >> 7) & 0x1) == 1) { //preverimo ali je indeksno naslavljanje
x_val = getX();
}
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) {
@ -187,6 +187,70 @@ bool Machine::execSICF3F4(int opcode, int ni, int operand) {
}
UV = (memory[UA] << 16) | (memory[UA + 1] << 8) | memory[UA + 2]; //izracunamo operand oz. uporabno vrednost
} else if (((operand >> 4) & 0x1) == 0) { // ce e bit ni prizgan e je F3, sicer F4
bool b = ((operand >> 6) & 0x1) == 1; //preverimo bit za bazno naslavljanje
bool p = ((operand >> 5) & 0x1) == 1;
offset = (((operand & 0x0F) << 8) | operand2);
if (offset & 0x800) { // če je bit 11 = 1 (negativno)
offset |= 0xFFFFF000; // nastavi vse višje bite na 1 (sign extend)
}
offset += x_val;
if (!b && p) { //PC - relativno
UA = getPC() + offset;
} else if (b && !p) {
UA = getB() + offset;
} else if (!b && !p) { //neposredno
UA = (((operand & 0x0F) << 8) | operand2);
} else { // b && p je nedovoljeno!
invalidAddressing();
}
if (UA + 2 > MAX_ADDRESS) {
invalidAddressing();
return false;
}
if (ni == 2) { //posredno
int UV_temp = (memory[UA] << 16) | (memory[UA + 1] << 8) | memory[UA + 2];
UV = (memory[UV_temp] << 16) | (memory[UV_temp + 1] << 8) | memory[UV_temp + 2];
} else if (ni == 1) { //takojšnje
UV = UA;
} else if (ni == 3) { //enostavno
UV = (memory[UA] << 16) | (memory[UA + 1] << 8) | memory[UA + 2]; //izracunamo operand oz. uporabno vrednost
}
} else {
int operand3 = fetch();
bool b = ((operand >> 6) & 0x1) == 1; //preverimo bit za bazno naslavljanje
bool p = ((operand >> 5) & 0x1) == 1;
offset = (((operand & 0x0F) << 16) | (operand2 << 8) | operand3);
if (offset & 0x80000) { // če je bit 11 = 1 (negativno)
offset |= 0xFFF00000; // nastavi vse višje bite na 1 (sign extend)
}
offset += x_val;
if (!b && p) { //PC - relativno
UA = getPC() + offset;
} else if (b && !p) {
UA = getB() + offset;
} else if (!b && !p) { //neposredno
UA = (((operand & 0x0F) << 16) | (operand2 << 8) | operand3);
} else { // b && p je nedovoljeno!
invalidAddressing();
}
if (UA + 2 > MAX_ADDRESS) {
invalidAddressing();
return false;
}
if (ni == 2) { //posredno
int UV_temp = (memory[UA] << 16) | (memory[UA + 1] << 8) | memory[UA + 2];
UV = (memory[UV_temp] << 16) | (memory[UV_temp + 1] << 8) | memory[UV_temp + 2];
} else if (ni == 1) { //takojšnje
UV = UA;
} else if (ni == 3) { //enostavno
UV = (memory[UA] << 16) | (memory[UA + 1] << 8) | memory[UA + 2]; //izracunamo operand oz. uporabno vrednost
}
}
switch (opcode) {
case Opcode::ADD:
setA(getA() + UV);
@ -332,12 +396,6 @@ bool Machine::execSICF3F4(int opcode, int ni, int operand) {
notImplemented(opcode);
break;
}
} else if (((operand >> 4) & 0x1) == 0) { // ce e bit ni prizgan e je F3, sicer F4
} else {
}
return false;
}