aboutsummaryrefslogtreecommitdiffstats
path: root/c_compiler
diff options
context:
space:
mode:
Diffstat (limited to 'c_compiler')
-rw-r--r--c_compiler/src/expression.cpp6
-rw-r--r--c_compiler/test/in/Add.c2
2 files changed, 4 insertions, 4 deletions
diff --git a/c_compiler/src/expression.cpp b/c_compiler/src/expression.cpp
index fb5b62b..cd20e24 100644
--- a/c_compiler/src/expression.cpp
+++ b/c_compiler/src/expression.cpp
@@ -68,12 +68,12 @@ AdditiveExpression::AdditiveExpression(Expression* _lhs, const std::string& _ope
VariableStackBindings AdditiveExpression::printasm(VariableStackBindings bindings) const
{
- rhs->printasm(bindings);
+ lhs->printasm(bindings);
// move the rhs out of the way to be able to evaluate the lhs
std::cout << "\tmove\t$3,$2" << std::endl;
- lhs->printasm(bindings);
+ rhs->printasm(bindings);
// then perform the right operation
@@ -82,7 +82,7 @@ VariableStackBindings AdditiveExpression::printasm(VariableStackBindings binding
if(operation == "+")
std::cout << "\tadd\t$2,$2,$3" << std::endl;
else if(operation == "-")
- std::cout << "\tsub\t$2,$2,$3" << std::endl;
+ std::cout << "\tsub\t$2,$3,$2" << std::endl;
else
std::cerr << "Don't recognize symbol: '" << operation << "'" << std::endl;
diff --git a/c_compiler/test/in/Add.c b/c_compiler/test/in/Add.c
index acdcffc..43e557e 100644
--- a/c_compiler/test/in/Add.c
+++ b/c_compiler/test/in/Add.c
@@ -5,7 +5,7 @@ int main() {
{
{
- z = x + y;
+ z = x + y + x + y - x;
}
}