How can CP/M file caching symbols be disabled?
Posted: Wed Feb 09, 2022 11:49 am
Firstly, I'm not sure if the following approach is best for what I'd like to achieve here, so I'm open to any suggestions of less 'hacky' alternatives.
As a result of the fairly new file caching for CP/M, lib/crt/classic/crt_cpm_fcntl.asm has this block of code:
For my project, I'm compiling a program for CP/M, MSXDOS1 and MSXDOS2. The initial loader program determines whether it's running on MSXDOS2 and uses MSXDOS2 file access routines or CP/M's FCB based file access routines otherwise. (It also detects whether an MSXDOS2 compatible memory mapper bios extension is available independently of this, and uses it even for MSXDOS1 if found.)
However, I found that this only works if the __sgoioblk and __sgoioblk_end symbols are located in the same address for both msx2 and fcb variants.
I have been able to always locate these symbols in the same place by placing #pragma output CRT_ENABLE_STDIO = 0 in my C source code, then manually writing an assembly language file that has contains these symbols.
Now that the CP/M file caching exists, I've found that I now need to also move the __fcb symbol as well (which is fine for me to do) as I also need to be careful the fcb and msx2 routines don't go past address 0x3fff, as I'm banking the memory from 0x4000 to 0x7fff.
But although __sgoioblk and __sgoioblk_end can be disabled from the standard crt0 startup code when using nofileio, the __fcb symbol in crt_cpm_fcntl.asm cannot be.
What I'd like to request is that the __fcb symbol be wrapped by an IF CRT_ENABLE_STDIO = 1 block, like so:
If file io is disabled at present, the symbols __sgoioblk and __sgoioblk_end aren't even defined, so the memory used by __fcb would be wasted at the moment anyhow right?
Finally, is there perhaps some better means of detecting whether MSXDOS2 file access routines are available and using the FCB based ones if they aren't?
As a result of the fairly new file caching for CP/M, lib/crt/classic/crt_cpm_fcntl.asm has this block of code:
Code: Select all
IF CLIB_OPEN_MAX > 0
SECTION bss_crt
PUBLIC __fcb
__fcb:
defs CLIB_OPEN_MAX * 166 ; Each FCB is 43 bytes long
ENDIF
However, I found that this only works if the __sgoioblk and __sgoioblk_end symbols are located in the same address for both msx2 and fcb variants.
I have been able to always locate these symbols in the same place by placing #pragma output CRT_ENABLE_STDIO = 0 in my C source code, then manually writing an assembly language file that has contains these symbols.
Now that the CP/M file caching exists, I've found that I now need to also move the __fcb symbol as well (which is fine for me to do) as I also need to be careful the fcb and msx2 routines don't go past address 0x3fff, as I'm banking the memory from 0x4000 to 0x7fff.
But although __sgoioblk and __sgoioblk_end can be disabled from the standard crt0 startup code when using nofileio, the __fcb symbol in crt_cpm_fcntl.asm cannot be.
What I'd like to request is that the __fcb symbol be wrapped by an IF CRT_ENABLE_STDIO = 1 block, like so:
Code: Select all
; CP/M style FCB support (CP/M + MSXDOS1)
SECTION bss_crt
IF CRT_ENABLE_STDIO = 1
IF CLIB_OPEN_MAX > 0
SECTION bss_crt
PUBLIC __fcb
__fcb:
defs CLIB_OPEN_MAX * 166 ; Each FCB is 43 bytes long
ENDIF
ENDIF
PUBLIC defltdsk
defltdsk: defb 0 ;Default disc
Finally, is there perhaps some better means of detecting whether MSXDOS2 file access routines are available and using the FCB based ones if they aren't?