added "j" command

This commit is contained in:
black
2025-07-09 12:31:31 +02:00
parent cf45a6e634
commit 45e9218ebd
2 changed files with 19 additions and 9 deletions

View File

@@ -111,13 +111,15 @@ std::streampos Manager::getNextStreamLineOffset() {
std::string Manager::gotoNextStreamLine() {
std::string line;
getline(m_programFile, line);
do {
getline(m_programFile, line);
} while (line.empty());
return line;
}
bool Manager::handleUserInput() {
constexpr const char *COLOR_GREEN = "\033[32m";
constexpr const char *COLOR_RESET = "\033[0m";
constexpr auto COLOR_GREEN = "\033[32m";
constexpr auto COLOR_RESET = "\033[0m";
std::cout << "\nOptionen: ("
<< COLOR_GREEN << "s" << COLOR_RESET << ") Programm durchlaufen lassen, ("
@@ -170,7 +172,7 @@ void Manager::handleExitInput() {
input = std::tolower(input);
if (input == 'e') {
std::cout << "Programm wird beendet.\n";
std::cout << "Programm wird beendet. :pepeExit:\n";
exit(0); // oder andere Beendigung
} else if (input == 'm') {
std::cout << "Wie viele Speicherzellen sollen gedumpt werden? ";

View File

@@ -32,11 +32,13 @@ void Alu::calculate(const std::vector<std::string> &commandVector) {
// Wandle Vektor[2] (das zweite Argument) in eine Adresse um, falls es ein SW/LW Argument ist
int arg2 = 0;
if (commandVector.at(2).find('(') != std::string::npos) {
arg2 = parseAddress(commandVector.at(2));
} else {
// Ansonsten wandle es in ein Registerargument um
arg2 = parseArgument(commandVector.at(2));
if (commandVector.size() > 2) {
if (commandVector.at(2).find('(') != std::string::npos) {
arg2 = parseAddress(commandVector.at(2));
} else {
// Ansonsten wandle es in ein Registerargument um
arg2 = parseArgument(commandVector.at(2));
}
}
// Wandle Vektor[3] (das dritte Argument) nur um, falls dieser existiert und kein immediate Wert ist
@@ -168,6 +170,12 @@ void Alu::calculate(const std::vector<std::string> &commandVector) {
for (int i = 0; i < posOffset; ++i) {
man.gotoNextStreamLine();
}
} else if (command == "j") {
// Jump Befehl
// Springe um den immediate value nach vorne (erhöhe den PC)
for (int i = 1; i < arg1; i++) {
man.gotoNextStreamLine();
}
} else {
std::cerr << "Befehl " << command << " wurde nicht gefunden!";
}