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
|
393
|
15 function u8* 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;
|
393
|
25 return cast<u8*>(ptr2);
|
283
|
26 }
|
|
27
|
393
|
28 function void memcpy(u8* dst, u8* src, int size)
|
|
29 {
|
|
30 //
|
|
31 var int i;
|
|
32 for (i = 0; i < size; i = i + 1)
|
|
33 {
|
|
34 *(dst + i) = *(src + i);
|
|
35 }
|
|
36 }
|
283
|
37
|