Re-started with z88dk since a few time (well, 2 days only ), looks great just like remember, and at this time I have some questions that maybe someone could know the answer:
- How can I get the end of program address? Currently I only achieved it doing something like this:
Compile with -DAMALLOC, then:Then memini has aprox the starting of the heap.Code: Select all
static uint total, largest, memini; static void *mem; mallinfo(&total, &largest); mem=malloc(largest); memini=mem; free(mem)
- Also, there is some way to specify to use all the heap area with a tolerance? (tolerance = room for the stack). Currently I do it by this way:
Execution of previous to get memini, then:OK maybe some bytes are wasted, but it is fine for me.Code: Select all
mallinit(); sbrk(memini, (total / 3 * 4) - tolerance); // "/3*4" because -DAMALLOC uses 3/4 of heap mallinfo(&total, &largest);
- Put data within code section, instead at the end. Not sure if there is some pragma or something. Now I achieve it doing:
Create some code file something like:
mem1.asmThen, for use simply reference it, can be a direct byte array, or with a struct, i.e.:Code: Select all
section code_compiler PUBLIC _data1 _data1: REPT <size_required_in_bytes> db 0 ENDR
somefile.cAnd then just compile in the order you want it:Code: Select all
typedef struct { unsigned int id; int x, y; } MyData; extern MyData *data1; // for array, for single object use without pointer my_function() { ... data1[2].id = 453; ... }
You will have your data space located properly.Code: Select all
zcc ... main.c part1.c mem1.asm part2.c ...