https://github.com/akkartik/mu/blob/master/subx/037heap.cc
1
2
3
4
5
6 :(before "Begin rewrite_global_variables")
7 insert_heap_global_variable(p);
8 :(code)
9 void insert_heap_global_variable(program& p) {
10 if (SIZE(p.segments) < 2)
11 return;
12
13 p.segments.at(1).lines.push_back(label("Start-of-heap"));
14 }
15
16 line label(string s) {
17 line result;
18 result.words.push_back(word());
19 result.words.back().data = (s+":");
20 return result;
21 }
22
23 line imm32(const string& s) {
24 line result;
25 result.words.push_back(word());
26 result.words.back().data = s;
27 result.words.back().metadata.push_back("imm32");
28 return result;
29 }