Fixed the division error. Kinda
This commit is contained in:
parent
72023962f5
commit
7cf7c336a7
4 changed files with 3 additions and 16 deletions
|
|
@ -112,7 +112,7 @@ namespace Compiler
|
|||
{
|
||||
*/
|
||||
|
||||
string file = "/home/clemens/repositorys/lcc/stage_3/valid/div_2.c";
|
||||
string file = "/home/clemens/repositorys/lcc/stage_3/valid/div_neg.c";
|
||||
|
||||
Console.WriteLine("-------------");
|
||||
List<Token> tokens = TestLexer(file, 0);
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ namespace Compiler.Generator
|
|||
case OperatorType.LogicalNegation:
|
||||
s = $"{Generate(rootNode.Children[0])}" +
|
||||
"cmpl $0, %eax\n" +
|
||||
"movl $0, %eax\n" + //xorl %eax, %eax should also work, but doesn't
|
||||
"movl $0, %eax\n" +
|
||||
"sete %al\n";
|
||||
break;
|
||||
default:
|
||||
|
|
@ -95,8 +95,7 @@ namespace Compiler.Generator
|
|||
"movl %eax, %ecx\n" + //move calculated divisor to %ecx
|
||||
"pop %rax\n" + //pop divident do %eax
|
||||
"cdq\n" +
|
||||
"divl %ecx\n" +
|
||||
"movl %ecx, %eax\n";
|
||||
"divl %ecx\n"; //eax contains the result, edx the rest
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue