ELSE update

This commit is contained in:
mmichlol
2026-02-09 20:46:14 +01:00
parent 0dff8628ac
commit 1eb29c430a
4 changed files with 199 additions and 112 deletions

View File

@@ -350,27 +350,24 @@ std::string generateAssembly(const CompilerState& state) {
case OpType::PRINT: {
// Instrukcja PRINT zwyk³a (liczba)
std::string val = getVarLocation(instr.arg1, stackMap);
result += " mov edx, " + val + "\\n";
result += " lea rcx, [rel fmt_int]\\n";
result += " xor eax, eax\\n"; // <-- DODAJ TO
result += " call printf\\n";
result += " mov edx, " + val + "\n";
result += " lea rcx, [rel fmt_int]\n";
result += " xor eax, eax\n";
result += " call printf\n";
break;
}
case OpType::PRINT_STRING: {
// Instrukcja PRINT_STRING (tekst)
std::string target = instr.arg1;
if (target.find("str_") == 0) {
// Litera³: print("tekst")
result += " lea rdx, [rel " + target + "]\\n";
if (target.rfind("str_", 0) == 0) {
result += " lea rdx, [rel " + target + "]\n";
}
else {
// Zmienna: print(s) -> s trzyma adres
std::string val = getVarLocation(target, stackMap);
result += " mov rdx, " + val + "\\n";
result += " mov rdx, " + val + "\n";
}
result += " lea rcx, [rel fmt_str]\\n";
result += " xor eax, eax\\n"; // <-- DODAJ TO
result += " call printf\\n";
result += " lea rcx, [rel fmt_str]\n";
result += " xor eax, eax\n";
result += " call printf\n";
break;
}
case OpType::CALL: {