ELSE update
This commit is contained in:
@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user