aboutsummaryrefslogtreecommitdiffstats
path: root/c_compiler/src
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2017-03-08 21:52:17 +0000
committerYann Herklotz <ymherklotz@gmail.com>2017-03-08 21:52:17 +0000
commit3e145bf08b1ffcccb4df8f2fc34f5bb95b5b250c (patch)
treef4bce6cd2f20cd69e7c23001d31ea596aafcf125 /c_compiler/src
parent1e0edabcca97b60371d84879ad69f569eb9127f5 (diff)
downloadCompiler-3e145bf08b1ffcccb4df8f2fc34f5bb95b5b250c.tar.gz
Compiler-3e145bf08b1ffcccb4df8f2fc34f5bb95b5b250c.zip
Adding extra test case and slight mod to classes
Diffstat (limited to 'c_compiler/src')
-rw-r--r--c_compiler/src/compiler_main.cpp2
-rw-r--r--c_compiler/src/declaration.cpp9
2 files changed, 9 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)
{