Mercurial > hg > index.cgi
comparison docs/internals.txt @ 0:2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
author | lost@l-w.ca |
---|---|
date | Wed, 19 Jan 2011 22:27:17 -0700 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:2c24602be78f |
---|---|
1 LWASM Internals | |
2 =============== | |
3 | |
4 LWASM is a table-driven assembler that notionally uses two passes. However, | |
5 it implements its assembly in several passes as follows. | |
6 | |
7 Pass 1 | |
8 ------ | |
9 | |
10 This pass reads the entire source code and parses each line into an internal | |
11 representation. Macros, file inclusions, and conditional assembly | |
12 instructions are resolved at this point as well. Instructions with known | |
13 sizes will have their sizes resolved at this point. | |
14 | |
15 Pass 2 | |
16 ------ | |
17 | |
18 Check all exported symbols for validity and set them as imports if the | |
19 assembler state says so. Also resolve all symbol references in all | |
20 expressions to be direct references either to the symbol table or | |
21 to the import list. | |
22 | |
23 Pass 3 | |
24 ------ | |
25 | |
26 This pass resolves all instruction sizes that can be resolved without | |
27 forcing any instruction sizes. This pass will run repeatedly until no | |
28 no new resolution occurs. | |
29 | |
30 Pass 4 | |
31 ------ | |
32 | |
33 Work through all un-resolved instructions and force sizes. After each size | |
34 is forced, try re-resolving all other instructions. This is done starting | |
35 at the beginning of the source and working forward. If any instruction does | |
36 not resolve when forced, an error will be thrown. | |
37 | |
38 Pass 5 | |
39 ------ | |
40 | |
41 Constantize all line addresses and throw errors if any cannot be. This | |
42 pass will repeat until no further lines addresses are reduced to constants | |
43 at which time all lines will be checked for constant-ness. | |
44 | |
45 Pass 6 | |
46 ------ | |
47 | |
48 Finalize all expressions related to instructions. Carp about any that | |
49 cannot be reduced to a usable form. That means, for the non-object target | |
50 all expressions must resolve to a constant. For the object form, all | |
51 expressions must resolve to symbol references and constants. Those symbol | |
52 references may be internal or external. | |
53 | |
54 Pass 7 | |
55 ------ | |
56 | |
57 Emit object code for each line for later output. |