aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--c_compiler/src/compiler_main.cpp2
-rw-r--r--c_compiler/src/declaration.cpp9
-rw-r--r--c_compiler/test/in/05.c6
3 files changed, 15 insertions, 2 deletions
diff --git a/c_compiler/src/compiler_main.cpp b/c_compiler/src/compiler_main.cpp
index e0222a3..2ba8e3d 100644
--- a/c_compiler/src/compiler_main.cpp
+++ b/c_compiler/src/compiler_main.cpp
@@ -5,7 +5,7 @@
int main(int argc, char *argv[])
{
Node* ast = parseAST();
-
+
ast->printasm();
return 0;
diff --git a/c_compiler/src/declaration.cpp b/c_compiler/src/declaration.cpp
index e2f27cc..7b924b3 100644
--- a/c_compiler/src/declaration.cpp
+++ b/c_compiler/src/declaration.cpp
@@ -30,7 +30,14 @@ void Declaration::printxml() const
}
void Declaration::printasm() const
-{}
+{
+ if(init == nullptr)
+ std::cout << "\t.comm\t" << id << ",4,4" << std::endl;
+ else {
+ std::cout << "\t.data\n\t.globl\t" << id << std::endl;
+ std::cout << id << ":\n\t.word\t" << std::endl;
+ }
+}
void Declaration::addDeclaration(Declaration* _next_decl)
{
diff --git a/c_compiler/test/in/05.c b/c_compiler/test/in/05.c
new file mode 100644
index 0000000..546012c
--- /dev/null
+++ b/c_compiler/test/in/05.c
@@ -0,0 +1,6 @@
+char *glob;
+
+int main() {
+ glob = "Yann";
+ return 0;
+}