Compare commits
1 Commits
V0.0.6-bet
...
V0.0.5
| Author | SHA1 | Date | |
|---|---|---|---|
| 5a24fa900e |
@@ -41,7 +41,6 @@ std::string generateAssembly(const CompilerState& state) {
|
|||||||
result += "global main\n";
|
result += "global main\n";
|
||||||
result += "extern printf\n";
|
result += "extern printf\n";
|
||||||
result += "extern getchar\n";
|
result += "extern getchar\n";
|
||||||
result += "extern _getch\n"; // ZMIANA: Dodajemy _getch (zamiast lub obok getchar)
|
|
||||||
result += "section .data\n";
|
result += "section .data\n";
|
||||||
result += " fmt db '%d', 10, 0\n";
|
result += " fmt db '%d', 10, 0\n";
|
||||||
result += "section .data\n";
|
result += "section .data\n";
|
||||||
@@ -187,10 +186,7 @@ std::string generateAssembly(const CompilerState& state) {
|
|||||||
}
|
}
|
||||||
case OpType::RETURN: {
|
case OpType::RETURN: {
|
||||||
std::string val = getVarLocation(instr.arg1, stackMap);
|
std::string val = getVarLocation(instr.arg1, stackMap);
|
||||||
if (val.empty() || val == ";");
|
result += " mov eax, " + val + " ; return value\n";
|
||||||
else {
|
|
||||||
result += " mov eax, " + val + " ; return value\n";
|
|
||||||
}
|
|
||||||
result += " leave\n";
|
result += " leave\n";
|
||||||
result += " ret\n";
|
result += " ret\n";
|
||||||
break;
|
break;
|
||||||
@@ -213,21 +209,9 @@ std::string generateAssembly(const CompilerState& state) {
|
|||||||
// Parsowanie argumentów
|
// Parsowanie argumentów
|
||||||
std::string argsRaw = instr.arg2;
|
std::string argsRaw = instr.arg2;
|
||||||
std::vector<std::string> callArgs;
|
std::vector<std::string> callArgs;
|
||||||
// --- SPECJALNE FUNKCJE SYSTEMOWE ---
|
|
||||||
|
|
||||||
// 1. input() - czeka na ENTER (stare)
|
|
||||||
if (instr.arg1 == "input") {
|
if (instr.arg1 == "input") {
|
||||||
result += " call getchar\n";
|
result += " call getchar\n"; // Czeka na enter
|
||||||
break;
|
break; // Wychodzimy, ¿eby nie robiæ standardowego call
|
||||||
}
|
|
||||||
|
|
||||||
// 2. read_key() - zwraca kod wciœniêtego klawisza (NOWOŒÆ)
|
|
||||||
if (instr.arg1 == "read_key") {
|
|
||||||
result += " call _getch\n"; // Zwraca kod znaku w EAX
|
|
||||||
// Jeœli to klawisz specjalny (strza³ki), _getch zwraca 0 lub 224,
|
|
||||||
// a potem trzeba wywo³aæ go drugi raz.
|
|
||||||
// Na razie zróbmy prosto: zwracamy to co zwróci³ pierwszy _getch.
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
if (!argsRaw.empty()) {
|
if (!argsRaw.empty()) {
|
||||||
size_t comma = argsRaw.find(',');
|
size_t comma = argsRaw.find(',');
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# PCC Compiler (My C++ Compiler)
|
# PCC Compiler (My C++ Compiler)
|
||||||
|
|
||||||

|

|
||||||

|

|
||||||

|

|
||||||
|
|
||||||
@@ -13,11 +13,9 @@ https://nodrop.xyz/docs/docs.html
|
|||||||
- **Custom Syntax**: C-like syntax easy for beginners.
|
- **Custom Syntax**: C-like syntax easy for beginners.
|
||||||
- **Variables**: Support for `int`, `bool` and `string`.
|
- **Variables**: Support for `int`, `bool` and `string`.
|
||||||
- **include files**: you can include base files from compiler `#include <main.pcc>` or your own files `#include "myfile.pcc"`.
|
- **include files**: you can include base files from compiler `#include <main.pcc>` or your own files `#include "myfile.pcc"`.
|
||||||
- **KeyBoard and Inputs Support**: now you can control keyboard inputs using `#include <Input.pcc>`.
|
|
||||||
- **Control Flow**: `if` statements support.
|
- **Control Flow**: `if` statements support.
|
||||||
- **Functions**: Define and call `void` functions.
|
- **Functions**: Define and call `void` functions.
|
||||||
- **Native Compilation**: Compiles directly to x64 machine code.
|
- **Native Compilation**: Compiles directly to x64 machine code.
|
||||||
- **More Informations**: For more informations check PCC Docs.
|
|
||||||
|
|
||||||
## 🛠️ Usage
|
## 🛠️ Usage
|
||||||
1. Download the latest release from the [Releases](../../releases) page.
|
1. Download the latest release from the [Releases](../../releases) page.
|
||||||
|
|||||||
Reference in New Issue
Block a user