From 12472d2590b0a8e1fad4c52c063859f6f6dabe3a Mon Sep 17 00:00:00 2001 From: "aljazbrodar." Date: Sat, 6 Dec 2025 11:54:51 +0100 Subject: [PATCH] stari sic format ukazi v1 --- ass2/simulator/machine.cpp | 43 +++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/ass2/simulator/machine.cpp b/ass2/simulator/machine.cpp index 258d0d2..0e794ff 100644 --- a/ass2/simulator/machine.cpp +++ b/ass2/simulator/machine.cpp @@ -167,11 +167,52 @@ bool Machine::execF2(int opcode, int operand) { return false; } - bool Machine::execSICF3F4(int opcode, int ni, int operand) { + int x_val = 0; + int operand2 = fetch(); + int UA; + int UV; + if (ni == 0) { // stari SIC (neposredno in enostavno naslavljanje) + if (((operand >> 7) & 0x1) == 1) { //preverimo ali je indeksno naslavljanje + x_val = getX(); + } + UA = (((operand & 0x7F) << 8) | operand2) + x_val; //izracun uporabnega naslova: operand brez bita x + drugi del naslova + x_val + if (UA + 2 > MAX_ADDRESS) { + invalidAddressing(); + return false; + } + + UV = (memory[UA] << 16) | (memory[UA + 1] << 8) | memory[UA + 2]; //izracunamo operand oz. uporabno vrednost + + switch (opcode) { + case Opcode::ADD: + setA(getA() + UV); + return true; + case Opcode::AND: + setA(getA() & UV); + return true; + case Opcode::COMP: + if (getA() < UV) { + + } else { + + } + return true; + default: + notImplemented(opcode); + break; + } + + } else if (((operand >> 4) & 0x1) == 0) { // ce e bit ni prizgan e je F3, sicer F4 + + } else { + + } + return false; } + void Machine::execute() { int opcode = fetch(); int operand;