JS> I'm in the process of trying to write a high-level single-pass
JS> compiler. If anyone knows anything on compilers, I'd love to
JS> talk to them.
JC> I should know something. Imho the easiest way for a single-pass
JC> compiler is to store all the offset-addresses (and segment-addresses
JC> if necessary) of the labels and the offsets of the jmp-
JC> instructions with the labels to jmp to. Of course use all
JC> the jmp-instructions that require 2 bytes instead of 1.
JC> After the complete source-code has been compiled fill in
JC> the jmp-offsets.
JC> When using segments always use jmp-instructions that
JC> require 4 bytes. The code won't be optimized. If you'd like
JC> to optimize, I recommend to use a double-pass.
I was talking about a single-pass high-level compilers. :) Ie
file->syntax->semantic->parse/expression tree->object code->executable.
My main problem right now is concerning building jumps/loops in the parse
tree, and also regarding scopes. (ie how to store symbol tables, and have a
"FindSymbol" command work in unison with other symbol tables above/beside
it) Other problems which I don't know to handle, which I can see coming up,
is collapsing the expression trees with variable identifiers (I don't
think this will be -too- hard, but hard enough), and code generation
from the parse tree.
Anyhow, I think a conversation is getting a bit off-topic (except maybe
for object code/exe generation). If you have any sites to get a FAQ or
some good information, pass them along.
- DarkFire
[John Stephenson (an INTP), Fingerprint: 66BE3A3B6EEE9A5B-48001A32901ECA21]
[Composed at 7:45:17a on 1998-04-10 (UTC) using PGPWave v1.24a Beta]
--- Maximus 2.01wb
---------------
* Origin: *Synthesis* Kingston, Ont., Canada! (1:249/127)
|