aboutsummaryrefslogtreecommitdiff
path: root/src/tools/build.zc
blob: b2f838fb6567a25cfc1fda4649bc477294deec9a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
namespace;
include rt, run;

// the build tool pokes at headers and raw memory on purpose and runs at full speed: no index bounds checks
unbounded;

// compiles the rest of stdin (after the backtick) as a genome image at GORG
// and writes it to stdout as little-endian 64-bit words.


docs on;
// the genome has no line tables: its code is the runtime's and the compiler's, and a program
// built into an image turns them on for itself (lines on;)
lines off;
// writes the compiled genome image to stdout as little-endian 64-bit words.
int main() {
	int n = run.build_image_grow(rt.GORG, 4096), i = 0, w;
	while (i < n) {
		w = run.image_words[i];
		rt.put_c(w); rt.put_c(w >> 8); rt.put_c(w >> 16); rt.put_c(w >> 24);
		rt.put_c(w >> 32); rt.put_c(w >> 40); rt.put_c(w >> 48); rt.put_c(w >> 56);
		i++;
	}
	return 0;
}