diff --git a/.gitignore b/.gitignore index 9070e8a..558f18a 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,6 @@ sictools.jar #ignorej ukaze za sic/xe Appendix_A_thru_C.pdf rek_sum.asm -ass2/sic \ No newline at end of file +ass2/sic +ass2/CMakeLists.txt +ass2/build \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 7c8d6eb..22b626a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -51,5 +51,6 @@ "thread": "cpp", "typeinfo": "cpp", "sstream": "cpp" - } + }, + "cmake.sourceDirectory": "/home/boobsson/Desktop/3. letnik FRI/SPO/spo-vaje/ass2" } \ No newline at end of file diff --git a/ass2/implementations/machine.cpp b/ass2/implementations/machine.cpp index 49bc881..510bb0a 100644 --- a/ass2/implementations/machine.cpp +++ b/ass2/implementations/machine.cpp @@ -174,11 +174,40 @@ machine::machine() { naprave[num] = make_unique(filename); } - int getUN(int n, int i, int x, int b, int p, int e, int operand) { - //NEED TO IMPLEMENT - return 1; + int machine::getUN(int n, int i, int x, int b, int p, int e, int operand){ + int UN; + + if (e == 1) { + UN = operand; + } + else if (n == 0 && i == 0) { + // SIC format + UN = operand; + } + else { + if (p == 1)//PC relativno + UN = PC + operand; + else if (b == 1)//Bazno relativno + UN = B + operand; + else + UN = operand; + } + //indeksno + if (x == 1) + UN += X; + //takojsnje + if (n == 0 && i == 1) + return UN; + + //posredno + if (n == 1 && i == 0) + return getWord(UN); + + //enostavno n=i=1 + return UN; } + void machine::outOfMemoryRange(int memory) { throw out_of_range("Naslov je izven pomnilniškega obmocja: " + to_string(memory)); } @@ -247,9 +276,6 @@ machine::machine() { } } - - ////////////////////////////////////////////////////////////////////////////////// - //TO DO, racunanje uporabnih naslovov!!!! bool machine::execF1(uint8_t opcode, const string& mnemonic){ //FIX, FLOAT, HIO, TIO, SIO, NORM auto it = Opcode::OPCODES.find(opcode); @@ -325,5 +351,3 @@ machine::machine() { return it->second(UN); // tukaj dejansko pozenemo ukaz z uporabnim naslovom } - //TO DO - /////////////////////////////////////////////////////////////////////////////////////