283
|
1 module memory;
|
293
|
2
|
377
|
3 import arch;
|
381
|
4 import io;
|
283
|
5
|
301
|
6 var int ptr;
|
283
|
7
|
393
|
8 // Let the heap grow upwards..
|
|
9
|
367
|
10 function void init()
|
|
11 {
|
393
|
12 ptr = 0x80000;
|
367
|
13 }
|
|
14
|
402
|
15 function byte* alloc(int size)
|
283
|
16 {
|
393
|
17 var int ptr2;
|
|
18 ptr2 = ptr;
|
|
19
|
|
20 io.print2("alloc size ", size);
|
|
21 io.print2("alloc address ", ptr);
|
|
22
|
|
23 // Increment new free point:
|
296
|
24 ptr = ptr + size;
|
402
|
25 return ptr2;
|
283
|
26 }
|
|
27
|
402
|
28 function void memcpy(byte* dst, byte* src, int size)
|
393
|
29 {
|
|
30 var int i;
|
|
31 for (i = 0; i < size; i = i + 1)
|
|
32 {
|
|
33 *(dst + i) = *(src + i);
|
|
34 }
|
|
35 }
|
283
|
36
|