Sorry to bother with this again, but I can't get automatic banking working with SDCC+NEWLIB, even manually adding my own banking function:
- I just copied the zx_banked_call.asm to my directory and included it in my compilation. The section this code goes into is "code_driver"
- I have included a custom mmap.inc to ensure the section "code_driver" is linked into the executable
- I have included a custom pragma file to make use of the custom mmap.inc
But still, when compiling this with sdcc+newlib, I always get the error that some code was not linked. Also the TAP file only shows one code block:
Code: Select all
$ make
zcc +zx -vn -c --list -s -m -compiler=sdcc -clib=sdcc_iy --c-code-in-asm -pragma-include zpragma.inc zx_banked_call.asm
zcc +zx -vn -c --list -s -m -compiler=sdcc -clib=sdcc_iy --c-code-in-asm -pragma-include zpragma.inc main.c
zcc +zx -vn -c --list -s -m -compiler=sdcc -clib=sdcc_iy --c-code-in-asm -pragma-include zpragma.inc bank6.c
zcc +zx -vn --list -s -m -compiler=sdcc -clib=sdcc_iy --c-code-in-asm -pragma-include zpragma.inc zx_banked_call.o main.o bank6.o -create-app -o banked.bin
Warning: Non-empty UNASSIGNED section ignored -
this indicates that some code/data is not part of the memory map
$ ../../rage1/tools/tapdump.pl *.tap
Block #0: pos = 0, size = 19, flag = 0 (header), cksum = 59
[Header] Type: PROGRAM, File Name: "Loader ", Length: 30, Autostart: 10, Program Length: 30
Block #1: pos = 21, size = 32, flag = 255 (data), cksum = 101
[Data] Size: 30
Block #2: pos = 55, size = 19, flag = 0 (header), cksum = 136
[Header] Type: CODE, File Name: "banked.bin", Length: 5591, Start Address: 33156 (0x8184)
Block #3: pos = 76, size = 5593, flag = 255 (data), cksum = 51
[Data] Size: 5591
If I compile with SDCC+Classic, everything works fine, apparently:
Code: Select all
$ make
zcc +zx -vn -c --list -s -m -compiler=sdcc --c-code-in-asm -lndos zx_banked_call.asm
zcc +zx -vn -c --list -s -m -compiler=sdcc --c-code-in-asm -lndos main.c
zcc +zx -vn -c --list -s -m -compiler=sdcc --c-code-in-asm -lndos bank6.c
zcc +zx -vn --list -s -m -compiler=sdcc --c-code-in-asm -lndos zx_banked_call.o main.o bank6.o -create-app -o banked.bin
$ ../../rage1/tools/tapdump.pl *.tap
Block #0: pos = 0, size = 19, flag = 0 (header), cksum = 59
[Header] Type: PROGRAM, File Name: "Loader ", Length: 30, Autostart: 10, Program Length: 30
Block #1: pos = 21, size = 32, flag = 255 (data), cksum = 105
[Data] Size: 30
Block #2: pos = 55, size = 19, flag = 0 (header), cksum = 66
[Header] Type: CODE, File Name: "banked.bin", Length: 3970, Start Address: 32768 (0x8000)
Block #3: pos = 76, size = 3972, flag = 255 (data), cksum = 135
[Data] Size: 3970
Block #4: pos = 4050, size = 6, flag = 255 (data), cksum = 124
[Data] Size: 4
I believe there is some missing thing with the linker here, but I can't see what it is, any help?
The code for my full tests here:
https://github.com/jorgegv/banked-sdcc-newlib-tests
And after that, another question on the same topic, but unrelated to the problem above:
Why the banked_call asm function in Classic uses a separate call stack for banked functions? It is reserved from the main stack, but it is located several bytes below (adjusted with CLIB_BANKING_STACK_SIZE pragma), but I can't see why a separate stack is needed.
Of course there is a need to save the previous bank before switching to the new one (so that banked calls are reentrant), but this can also be achieved by using just the regular stack, so why switch to an alternate one? This stack-switching dance impacts performance of banked calls.
For the record, my (private) banking routine just uses the regular stack and everything works fine.