Hello Adrian,

Wednesday, March 29, 2023, 5:52:01 AM, you wrote:

just implement your own __sdcc_heap_init which set __sdcc_heap_free->next
to something like SP - <max_stack_size> instead of HEAP_END.


AC> On Tue, 28 Mar 2023 at 12:55, Adrian Chadd <adr...@freebsd.org> wrote:

>> Hi! I'm writing a little editor for CP/M 3. I have found a bunch of
>> examples to generate CP/M binaries using SDCC and that works just fine.
>>
>> But the default 1k heap isn't large enough, and I'd really like to be able
>> to use whatever RAM is available between the end of the segment list(s) and
>> the top of the transient program area (TPA.)
>>
>> If I were doing this with gcc/gnu linker, I'd just define a symbol at the
>> end of the generated segments in RAM. but the segment/area list here is ..
>> not defined the same way. And it seems that the linker logic is a little
>> different per target platform because, well, embedded
>> microprocessor/controllers can have funky addressing/banking requirements.
>> :)
>>
>> So, what's a neat hack I could do to find the end of the generated segment
>> list? I thought about using a .o at the end of the build line, but I am not
>> sure what is the "last" generated segment.
>>
>>
AC> Ah, I think I figured out something that works.

AC> * fully list the areas in the CP/M crt0.s that is being used here, rather
AC> than only a handful
AC> * that includes HEAP/HEAP_END and such
AC> * put my end of file area (called ZZZ) with a symbol in it in that area
AC> * the linker now puts things in that order and bam, I end up with a symbol
AC> pointing to the end of the program + its memory allotments at runtime.

AC> It also means I can eventually do stuff like verify I have enough CP/M TPA
AC> for the data/heap segments rather than it just trashing RAM later on.

AC> I /also/ came up with a semi-neat way to add heap segments at runtime, as
AC> now i can enumerate the "rest of RAM" using the above method (which is
AC> basically the space between "end of program" above and the end of the CP/M
AC> TPA), I'll go pull down the svn version of sdcc and generate a diff against
AC> malloc.c to expose an extra API to add memory regions to the heap at
AC> runtime. (Obviously that only works for regions that aren't going to be
AC> banked out, but I figure if someone adds memory to the heap at runtime they
AC> know what they're doing.)




AC> -adrian



-- 
Best regards,
 Tony                            mailto:unt...@mail.ru



_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to