I'm using SDCC.
Is it possible to have multiple sections for my C code? For example, I have my main game code which I want at 0x8000, but also have some screens data and their decoder in C and that can happily go into the contended memory area. So can I say "I want this C code ORGed at 0x8000, but this C code at 0x6200"?
Can I have multiple sections for C code?
-
- Member
- Posts: 121
- Joined: Mon Mar 26, 2018 1:49 pm
Re: Can I have multiple sections for C code?
In case you’ve not found it #pragma codeseg name where name is your choice will push compiler code in that file into a new section.
You’ll need to fiddle with the section definitions of course.
You’ll need to fiddle with the section definitions of course.
-
- Member
- Posts: 121
- Joined: Mon Mar 26, 2018 1:49 pm
Re: Can I have multiple sections for C code?
I had not found the codeseg pragma, I'd settled on the hacky approach you suggested elsewhere:
That worked, mostly (see below), as does the codeseg approach, so double thanks.
(Once you know what you're looking for it's easier to find the answer. There's an old post from Alvin here which describes things in more details, which might be useful to anyone who arrives here via Google.)
One outstanding issue though: my "contended" section is currently ORGed at address 30000. My main() code starts at 32768 as normal. But when I use z88dk-appmake to create the TAP file the code is started with RANDOMISE USR 30000, because it seems to assume that the entry point of the code is the address where the code is ORGed. I want to LOAD to 30000, but RANDOMISE USR 32768. I can write my own BASIC loader, of course, or hack the source to z88dk-appmake (which is what I did), but am I right in thinking there's no way round this limitation with the current z88dk-appmake utility?
Code: Select all
static void set_section() __naked {
__asm
section contended
__endasm;
}
(Once you know what you're looking for it's easier to find the answer. There's an old post from Alvin here which describes things in more details, which might be useful to anyone who arrives here via Google.)
One outstanding issue though: my "contended" section is currently ORGed at address 30000. My main() code starts at 32768 as normal. But when I use z88dk-appmake to create the TAP file the code is started with RANDOMISE USR 30000, because it seems to assume that the entry point of the code is the address where the code is ORGed. I want to LOAD to 30000, but RANDOMISE USR 32768. I can write my own BASIC loader, of course, or hack the source to z88dk-appmake (which is what I did), but am I right in thinking there's no way round this limitation with the current z88dk-appmake utility?
Re: Can I have multiple sections for C code?
I was looking for something similar some time ago, I tried putting the section between "__asm" definition, but it didn't work for my case.
Another related thread with this topic, that I found via google too:
https://foro.speccy.org/viewtopic.php?t=5032
Another related thread with this topic, that I found via google too:
https://foro.speccy.org/viewtopic.php?t=5032
Re: Can I have multiple sections for C code?
The zx appmake just has a lot of features, I thought there was a way to do that, but it looks like load address == start address, so a new option/pragma would need to be added.derekfountain wrote: ↑Sun Apr 24, 2022 4:06 pmOne outstanding issue though: my "contended" section is currently ORGed at address 30000. My main() code starts at 32768 as normal. But when I use z88dk-appmake to create the TAP file the code is started with RANDOMISE USR 30000, because it seems to assume that the entry point of the code is the address where the code is ORGed. I want to LOAD to 30000, but RANDOMISE USR 32768. I can write my own BASIC loader, of course, or hack the source to z88dk-appmake (which is what I did), but am I right in thinking there's no way round this limitation with the current z88dk-appmake utility?