z80 Development Kit
You are not logged in.
I can't get printf working on cpc, it only prints '<><><><><>' and even it hangs the cpc.
This simply program:
#include <stdio.h>
main()
{
printf("HELLO WORD\n");
printf("Z88DK\n");
printf("ON AMSTRAD CPC\n");
while (getk() != 13) {};
}Compiled with:
zcc +cpc -o printf4.bin printf4.c -create-app -lndos -Ca-v
Gets this on the cpc:
The program/machine is also hang. I've used the sourceforge 1.8 binaries zip.
Of course, this works perfectly on v1.7
Cheers.
Offline
Wow.. it's not exactly what we meant for "stability improvements" ![]()
Offline
Not still, I just got to reproduce the problem... I'll try it.
The random cleans I'm responsible for are related to the ZX81 stuff, I decided to force a clean before and after the build process.. I also thought to leave it unchained, in such case the "zx81libs" group would fit.
Offline
Hey, I tried to rebuild the library and tried to include the 8080 version of vfprintf_mini (seems to be the only difference from the working version), but I didn't succeed.
The only quick workaround I have so far is to recover the older LIB version and put it inthe z88dk/lib/clibs folder:
http://z88dk.cvs.sourceforge.net/*check … vision=1.7
It also proves the issue is on the library, probably for something happening during compilation.
Offline
Ok, I found the point making the programs crash, but the reason is still unclear.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Code crashing:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
.fputc_cons
ld hl,2
add hl,sp
ld a,(hl)
cp 13
jr nz,nocr
call firmware
defw txt_output
ld a,10
.nocr call firmware
defw txt_output
ret
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Code working:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
.fputc_cons
ld hl,2
add hl,sp
ld a,(hl)
cp 13 ; CR ?
jr nz,nocr
call $BB5A
ld a,10
.nocr
jp $BB5A
Offline
Found the problem.
The firmware calling routine in the CRT0 stub had two errors:
- AF' wasn't saved properly, and the A register was altered before the ROM call
- The interrupt needed to be disabled after every ROM call
The latter change could have greatly improved the stability of the port, so I put in the new library recompilation the full version of stdio.. let me know if you find problems.
The required files to patch a bin 'distro' are:
http://z88dk.cvs.sourceforge.net/*check … c_crt0.asm
http://z88dk.cvs.sourceforge.net/*check … c_clib.lib
http://z88dk.cvs.sourceforge.net/*check … i_clib.lib
Offline
stefano wrote:
Found the problem.
...
The required files to patch a bin 'distro' are:
http://z88dk.cvs.sourceforge.net/*check … c_crt0.asm
http://z88dk.cvs.sourceforge.net/*check … c_clib.lib
http://z88dk.cvs.sourceforge.net/*check … i_clib.lib
I have test these files and printf now works correctly
.
But i have found another bug or at least another difference with v1.7
:
Function getk() in v1.7 waits for a keypress and then return key code
Function getk() in v1.8 retunrs inmediately with code 0 or if a key is pressed returns key code, but never waits.
Cheers.
Offline
It is correct.
The function you're looking for is fgetc_cons.
Offline