summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAmlal El Mahrouss <113760121+Amlal-ElMahrouss@users.noreply.github.com>2024-03-27 08:31:41 +0100
committerAmlal El Mahrouss <113760121+Amlal-ElMahrouss@users.noreply.github.com>2024-03-27 08:31:41 +0100
commit3939adadfecc486173df35e1f54c606a9bb4bb94 (patch)
tree3b80ea14534e74e4bdb2c3db26a6270f66e49ce4
parent69b78ac22d04b56a9882e845230a1df27d9af9a9 (diff)
Toolchain: Fix bpp and link, deprecate ccplus (C++ compiler)
repurpose all rule to compile everything. Signed-off-by: Amlal El Mahrouss <113760121+Amlal-ElMahrouss@users.noreply.github.com>
-rw-r--r--Examples/HelloWorld.asm7
-rw-r--r--Examples/HelloWorld.asm.pp19
-rw-r--r--Sources/Deprecated/ccplus.cc (renamed from Sources/ccplus.cc)0
-rw-r--r--Sources/bpp.cc65
-rw-r--r--Sources/link.cc18
-rw-r--r--makefile9
6 files changed, 40 insertions, 78 deletions
diff --git a/Examples/HelloWorld.asm b/Examples/HelloWorld.asm
index ccfccc3..71e90f0 100644
--- a/Examples/HelloWorld.asm
+++ b/Examples/HelloWorld.asm
@@ -3,9 +3,12 @@
; Start sequence of program.
+%def gdtBase 0x1000
+%def gdtLimit 0x100
+
export .data GDT
- .number 55
- .number 100
+ .number gdtBase
+ .number gdtLimit
export .text __start
mov rcx, 47 ; exit program
diff --git a/Examples/HelloWorld.asm.pp b/Examples/HelloWorld.asm.pp
new file mode 100644
index 0000000..c9625c4
--- /dev/null
+++ b/Examples/HelloWorld.asm.pp
@@ -0,0 +1,19 @@
+#bits 64
+#org 1000
+
+; Start sequence of program.
+
+
+export .data GDT
+ .number 0x1000
+ .number 0x100
+
+export .text __start
+ mov rcx, 47 ; exit program
+ mov rdx, 0x0 ; exit code 0
+ int 50
+ int 50
+ int 50
+ int 50
+ int 50
+ ret
diff --git a/Sources/ccplus.cc b/Sources/Deprecated/ccplus.cc
index 00b6994..00b6994 100644
--- a/Sources/ccplus.cc
+++ b/Sources/Deprecated/ccplus.cc
diff --git a/Sources/bpp.cc b/Sources/bpp.cc
index fbe414f..acae226 100644
--- a/Sources/bpp.cc
+++ b/Sources/bpp.cc
@@ -279,64 +279,10 @@ void bpp_parse_file(std::ifstream &hdr_file, std::ofstream &pp_out) {
for (auto macro : kMacros) {
if (ParserKit::find_word(hdr_line, macro.fName) &&
hdr_line.find("%def") == std::string::npos) {
- auto substr = hdr_line.substr(hdr_line.find(macro.fName));
-
- std::vector<std::string> sym_vec;
- std::string sym_str;
-
- for (auto &subc : substr) {
- if (subc == ',' || subc == ')') {
- if (sym_str.empty()) continue;
-
- sym_vec.push_back(sym_str);
- sym_str.clear();
-
- continue;
- }
-
- if (isalnum(subc)) sym_str.push_back(subc);
- }
-
- if (macro.fArgs.size() > 0) {
- for (auto &item : sym_vec) {
- std::size_t cnt = 0;
-
- for (auto &arg : macro.fArgs) {
- if (item == arg) ++cnt;
- }
-
- if (cnt > 1) {
- auto it =
- std::find(macro.fArgs.begin(), macro.fArgs.end(), item);
-
- while (it != macro.fArgs.end()) {
- macro.fArgs.erase(it);
- it = std::find(macro.fArgs.begin(), macro.fArgs.end(), item);
- }
- }
- }
-
- if (sym_vec.size() != macro.fArgs.size()) {
- throw std::runtime_error(
- "bpp: arguments count mismatch, except " +
- std::to_string(sym_vec.size()) +
- ", got: " + std::to_string(macro.fArgs.size()));
- return;
- }
-
- substr = macro.fValue;
-
- std::size_t cnt = 0UL;
-
- for (auto &val : macro.fArgs) {
- substr.replace(substr.find(val), val.size(), sym_vec[cnt]);
- ++cnt;
- }
- }
-
+ auto value = macro.fValue;
+
hdr_line.replace(hdr_line.find(macro.fName), macro.fName.size(),
- substr);
- hdr_line.erase(hdr_line.find(substr) + substr.size());
+ value);
}
}
@@ -863,13 +809,12 @@ MPCC_MODULE(HCorePreprocessor) {
}
if (argv[index][0] == '-') {
- if (strcmp(argv[index], "-version") == 0) {
+ if (strcmp(argv[index], "-v") == 0) {
printf("%s\n", "bpp v1.11, (c) Mahrouss Logic");
return 0;
}
- if (strcmp(argv[index], "-h") == 0 ||
- strcmp(argv[index], "-help") == 0) {
+ if (strcmp(argv[index], "-h") == 0) {
printf("%s\n", "bpp v1.11, (c) Mahrouss Logic");
printf("%s\n", "-working-dir <path>: set directory to working path.");
printf("%s\n", "-include-dir <path>: add directory to include path.");
diff --git a/Sources/link.cc b/Sources/link.cc
index b771470..204b84d 100644
--- a/Sources/link.cc
+++ b/Sources/link.cc
@@ -96,7 +96,7 @@ MPCC_MODULE(HCoreLinker) {
kStdOut << "-output-file: Select output file name.\n";
return 0;
- } else if (StringCompare(argv[i], "-version") == 0) {
+ } else if (StringCompare(argv[i], "-v") == 0) {
kStdOut << kToolVersion << std::endl;
return 0;
@@ -144,7 +144,7 @@ MPCC_MODULE(HCoreLinker) {
continue;
} else {
if (argv[i][0] == '-') {
- kStdOut << "link: Unknown flag: " << argv[i] << "\n";
+ kStdOut << "link: unknown flag: " << argv[i] << "\n";
return -MPCC_EXEC_ERROR;
}
@@ -155,13 +155,13 @@ MPCC_MODULE(HCoreLinker) {
}
if (kOutput.empty()) {
- kStdOut << "link: no Output filename set." << std::endl;
+ kStdOut << "link: no output filename set." << std::endl;
return MPCC_EXEC_ERROR;
}
// sanity check.
if (kObjectList.empty()) {
- kStdOut << "link: No input files." << std::endl;
+ kStdOut << "link: no input files." << std::endl;
return MPCC_EXEC_ERROR;
} else {
// check for existing files, if they don't throw an error.
@@ -169,7 +169,7 @@ MPCC_MODULE(HCoreLinker) {
if (!std::filesystem::exists(obj)) {
// if filesystem doesn't find file
// -> throw error.
- kStdOut << "link: No such file: " << obj << std::endl;
+ kStdOut << "link: no such file: " << obj << std::endl;
return MPCC_EXEC_ERROR;
}
}
@@ -177,7 +177,7 @@ MPCC_MODULE(HCoreLinker) {
// PEF expects a valid architecture when outputing a binary.
if (kArch == 0) {
- kStdOut << "link: No target architecture set, can't continue." << std::endl;
+ kStdOut << "link: no target architecture set, can't continue." << std::endl;
return MPCC_EXEC_ERROR;
}
@@ -227,10 +227,10 @@ MPCC_MODULE(HCoreLinker) {
if (ae_header.fMagic[0] == kAEMag0 && ae_header.fMagic[1] == kAEMag1 &&
ae_header.fSize == sizeof(CompilerKit::AEHeader)) {
if (ae_header.fArch != kArch) {
- if (kVerbose) kStdOut << "link: info: is it a FAT binary? : ";
+ if (kVerbose) kStdOut << "link: info: is this a FAT binary? : ";
if (!kFatBinaryEnable) {
- if (kVerbose) kStdOut << "no.\n";
+ if (kVerbose) kStdOut << "No.\n";
kStdOut << "link: error: object " << i
<< " is a different kind of architecture and output isn't "
@@ -241,7 +241,7 @@ MPCC_MODULE(HCoreLinker) {
return -MPCC_FAT_ERROR;
} else {
if (kVerbose) {
- kStdOut << "yes.\n";
+ kStdOut << "Yes.\n";
}
}
}
diff --git a/makefile b/makefile
index 156bd11..3992b25 100644
--- a/makefile
+++ b/makefile
@@ -30,10 +30,6 @@ SRC_COMMON=Sources/String.cc Sources/AsmKit.cc
CC_SRC=Sources/cc.cc $(SRC_COMMON)
CC_OUTPUT=Output/cc.exe
-# C++ Compiler
-CXX_SRC=Sources/ccplus.cc $(SRC_COMMON)
-CXX_OUTPUT=Output/ccplus.exe
-
# 64x0 Assembler
ASM_SRC=Sources/64asm.cc $(SRC_COMMON)
ASM_OUTPUT=Output/64asm.exe
@@ -43,8 +39,8 @@ IASM_SRC=Sources/i64asm.cc $(SRC_COMMON)
IASM_OUTPUT=Output/i64asm.exe
.PHONY: all
-all:
- @echo "Use a specific target."
+all: pp cl link
+ @echo "DONE."
.PHONY: pp
pp:
@@ -53,7 +49,6 @@ pp:
.PHONY: cl
cl:
$(LINK_CC) $(COMMON_INC) $(CC_SRC) -o $(CC_OUTPUT)
- $(LINK_CC) $(COMMON_INC) $(CXX_SRC) -o $(CXX_OUTPUT)
$(LINK_CC) $(COMMON_INC) $(IASM_SRC) -o $(IASM_OUTPUT)
$(LINK_CC) $(COMMON_INC) $(ASM_SRC) -o $(ASM_OUTPUT)