Hi to all,
I have a rookie question.
When I am compiling for the Commodore 128, how much memory can I use in a C program for (code+data)?
I had a peek at the cfg file:
https://github.com/cc65/cc65/blob/master/cfg/c128.cfg
and it seems to me that the MAIN is 39923 bytes long. Is that correct?
So the ancillary inevitable question is: is it possible to access more than that on a machine with 128K? I am trying to port some interactive fiction games and accessing more than 64K in reasonably standard C programs would be a real bless. If the answer is written somewhere in the Cc65 doc, can someone please point me in the right direction?
Thanks!
D.
Define reasonably standard C programs. The extra RAM in bank 1 or at least most of it (~62 KiB), can be used via an extended memory driver: c128-ram.emd. See the em.h file and it's functions documentation.
You may also have additional 64K of video RAM!
https://cc65.github.io/doc/c128.html#ss5.2
Define reasonably standard C programs.
I don't see how that would help here.
As already mentioned by @Marrin and @polluks the only way supported by cc65 is https://cc65.github.io/doc/c128.html#ss5.2. This of course means (significant ?) adjustments to your C program.
You can either put data in the extended memory. Or you can use the extended memory as cache for overlays - meaning you put code there. However, cc65 doesn't have strong support for overlays so putting data in the extended memory is supposed to be simpler - if your data flow allows for it.
See https://github.com/cc65/cc65/blob/master/samples/overlaydemo.c for overlays in general and https://github.com/cc65/cc65/blob/master/samples/multidemo.c for using extended memory as overlay cache.
Hi to all,
thank you for your replies!
Define reasonably standard C programs.
Something that I can think about compiling for another system with another compiler (hence "standard"). But some adjustments to the C if it well worth it (hence "reasonably").
See https://github.com/cc65/cc65/blob/master/samples/overlaydemo.c for overlays in general and https://github.com/cc65/cc65/blob/master/samples/multidemo.c for using extended memory as overlay cache.
Thank you @oliverschmidt, I will have a more detailed look at those examples and I will try to see what I can do. In the meanwhile, is it possible to ask the compiler to allocate all the DATA segment in the extended memory and to generate code to retrieve it automatically when needed (even if it slower)? Or this should be done manually?
Regards,
D.
We/I understood your issue. If "moved" DATA would be possible we would already have mentioned it. What we pointed you at is all that's there.
Thank you @oliverschmidt, I think I can foresee a solution with the proposed techniques.
Kind regards,
D.
(Regarding @DarwinNE's initial question about how to access "more that 64K" I don't have an idea except of using the extended memory driver as stated before. Ok, one could think about (complicated) solutions to have DATA and CODE in different memory banks, but before going down that route...)
I always found it strange that the c128 target provides less memory for the cc65 program than the c64 target. I (think I) understand the technical reasons, but wouldn't it be nice to have a cc65 target which uses a whole memory bank for the cc65 program? Maybe/probably in addition to the existing c128 cc65 target.
It could be done by conditional compilation of the c128 runtime library, similar to the atari/atarixl implementation. I don't know much about c128 internals, so I cannot guide someone interested in implementing that, except for telling him how similar tasks are being done in the atarixl target.
Rough draft of what is needed:
Any volunteers?
Hi @groessler,
that sounds nice, indeed.
I am a rookie about cc65 internals and, to say the truth, coming from the VIC-20 and the C64 I still do not know very well the C128. I am at least planning however to study more about that computer in a near future, as I have some projects for it.
I would be glad to give my help on cc65, but I certainly can not do that alone.
Right now c128 has a c16-like layout.
But a plus4-like should be possible.
I think the original question is for sure answered by now.
Most helpful comment
(Regarding @DarwinNE's initial question about how to access "more that 64K" I don't have an idea except of using the extended memory driver as stated before. Ok, one could think about (complicated) solutions to have DATA and CODE in different memory banks, but before going down that route...)
I always found it strange that the c128 target provides less memory for the cc65 program than the c64 target. I (think I) understand the technical reasons, but wouldn't it be nice to have a cc65 target which uses a whole memory bank for the cc65 program? Maybe/probably in addition to the existing c128 cc65 target.
It could be done by conditional compilation of the c128 runtime library, similar to the atari/atarixl implementation. I don't know much about c128 internals, so I cannot guide someone interested in implementing that, except for telling him how similar tasks are being done in the atarixl target.
Rough draft of what is needed:
Any volunteers?