I'm compiling the Petit FatFs source (attached) with the following command:
sdcc -mz80 --data-loc 0xC001 --no-std-crt0 --oldralloc --no-peep --code-loc 0x8000 pff.c
My SDCC version is:
mcs51/gbz80/z80/z180/ds390/pic16/pic14/TININative/ds400/hc08 3.0.5 #6899
(Oct 2 2011) (MINGW32)
When building the Petit FatFs code for the Z80 I decided to put some of the low-level disk I/O routines it uses in a separate bank.
So I replaced e.g. this prototype:
with a define like this:
#define disk_initialize ((DSTATUS (*)(void))0xD689)
(I generate these defines automatically from the map files with a tool)
After doing these changes the compiler incorrectly marks large portions of code as unreachable.
For example, it considers the following return to always be taken:
if (disk_initialize() != 0)
even though that depends on the value returned by disk_initialize.
Attached the code in question.