|
There are several steps for a compiler, and the number of steps varies depending upon the complexity. Each step consumes time. They are not merely "lookup tables".
I'm guessing that PB is a recursive descent, which is the easiest to write by hand. The first step it does is recognize the "words" in the file. This is called tokenizing. For instance, when it first opens the file, is the first character it sees a semi (comment), a hash (constant), or a letter (var or func call)? Some tokenizers read a whole word (characters until a "separator" char is found). After the word is tokenized, the compiler determines what to do (skip the comment, use the constant, or call the func). During this final handling, "output code" is produced. More sophisticated compilers use an intermediate code so it can be optimized more efficiently after code generation has completed. There is reason to believe that PB just goes straight to asm. The compiler just repeats these steps until the file is done.
A more complicated compiler may run multiple passes on the input file. For instance, a two-pass compiler might use the first pass to recognize all of the variables and constants, and a second pass to do the rest. This allows for referencing a function or constant that has not yet been defined, or implementing a preprocessor as in C.
A common next step is the optimizer, if the system has one. I can't tell if PB has one or not; it may simply have efficient asm output, or it may run a rudimentary optimizer. Just like compilers, optimizers vary greatly in complexity; some run in one pass, some in two or more.
Next comes the assembling. This is basically done the exact same way as compiling, except assemblers are much less sophisticated (they have fewer rules, and tighter constraints) so it can go faster. Also, instead of readable code for output, the assembler generates binary code. Assembling is simple enough that it can merely be a lookup table type program, although they are generally not.
Just as a "gut feel" comparison, I am guessing that the Gnu Assembler takes about 5 times as long to assemble a file as the Fasm assembler that PB uses. I don't know why it is so slow, but I can tell you that it is horribly inefficient with macros.
Anyway, back to your "how can I make it faster" question. In reality, aside from precompiling libraries, there is not much you can do. That will save you from repeatedly compiling code that is not being edited.
|