KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am currently in the process of writing a compiler and I seem to have run into some problems getting it to output code that executes in a decent timeframe. A brief overview of the compiler: 7Basic is a compiler that aims to compile 7Basic code directly into machine code for the target architecture / platform. Currently 7Basic generates x86 assembly given a source file. The problem is that the assembly code generated by the compiler is slow and inefficient . For example, this code (which compiles down to this assembly code) takes nearly 80.47 times longer to execute than the equivalent C code . Part of the problem is that the compiler is generating code like the following: push eax push 5000000 pop ebx pop eax Instead of the more logical: mov ebx,5000000 ...which accomplishes the same thing. My question is: what are some techniques to avoid this sort of problem? The parser basically uses recursion to parse the expressions, so the code generated reflects this.
Tags (comma-separated)
Save Edits
Cancel