sscanf, fscanf etc on clib=8080 missing

Post Reply
jacotton
Member
Posts: 89
Joined: Fri Nov 24, 2017 1:35 am

sscanf, fscanf etc on clib=8080 missing

Post by jacotton »

I am on a project to convert my inettools-z80 repo to run on 8080 cpu.
I am hitting a small bug. Seems to be the same one every time.

Here is the zcc version
zcc - Frontend for the z88dk Cross-C Compiler - v19234-6605bce02-20220124

This should be very recent.

$ grep error log
libhost.c::Hosts_Init::3::3:70: error: undefined symbol: fscanf
telnet_client.c::main::3::10:152: error: undefined symbol: sscanf
telnet_client.c::main::2::23:243: error: undefined symbol: _InStat
telnet_client.c::main::3::24:245: error: undefined symbol: _InChar
libhost.c::Hosts_Init::3::3:70: error: undefined symbol: fscanf
ping.c::main::3::5:121: error: undefined symbol: sscanf
libhost.c::Hosts_Init::3::3:70: error: undefined symbol: fscanf
libhost.c::Hosts_Init::3::3:70: error: undefined symbol: fscanf
htget.c::main::2::19:247: error: undefined symbol: sscanf
libhost.c::Hosts_Init::3::3:70: error: undefined symbol: fscanf
htlist.c::main::3::27:292: error: undefined symbol: sscanf
libhost.c::Hosts_Init::3::3:70: error: undefined symbol: fscanf
libhost.c::Hosts_Init::3::3:70: error: undefined symbol: fscanf
libhost.c::Hosts_Init::3::3:70: error: undefined symbol: fscanf
mac.c::main::1::3:28: error: undefined symbol: scanf

Typical:
$ make
zcc +cpm -create-app -clib=8080 -s -m -pragma-include:zpragma.inc -DAMALLOC2 -oifconfig -Wunused addrprint.o w5500.o dhcp.o spi.o socket.o ethernet.o dns.o libhost.o libinet.o
libhost.c::Hosts_Init::3::3:70: error: undefined symbol: fscanf
^---- fscanf
make: *** [Makefile:47: ifconfig] Error 1

I create a very short test program
#include <stdio.h>
main()
{
FILE *in;
int i,j;

fscanf(in, "%d %d",&i,&j);
}

$ zcc +cpm test.c

$ zcc +cpm -clib=8080 test.c
C:/cygwin64/home/lbmgm/projects/z88dk/lib/../lib/crt/classic/crt_runtime_selecti
on.asm:96: error: undefined symbol: __scanf_handle_d
^---- __scanf_handle_d
test.c::main::0::1:3: error: undefined symbol: fscanf
^---- fscanf
User avatar
dom
Well known member
Posts: 2072
Joined: Sun Jul 15, 2007 10:01 pm

Re: sscanf, fscanf etc on clib=8080 missing

Post by dom »

That one is documented here: https://github.com/z88dk/z88dk/wiki/Classic-8080#stdioh

I’ll need to look at the code to see how long it’ll take to port over to 8080.
User avatar
dom
Well known member
Posts: 2072
Joined: Sun Jul 15, 2007 10:01 pm

Re: sscanf, fscanf etc on clib=8080 missing

Post by dom »

Actually what formatters do you need? I should have a C version somewhere that won't be a feature rich, but should be a quick drop in.
jacotton
Member
Posts: 89
Joined: Fri Nov 24, 2017 1:35 am

Re: sscanf, fscanf etc on clib=8080 missing

Post by jacotton »

The ones listed above, sscanf, fscanf and scanf.

If you have that in C, I'd be happy with that.
User avatar
dom
Well known member
Posts: 2072
Joined: Sun Jul 15, 2007 10:01 pm

Re: sscanf, fscanf etc on clib=8080 missing

Post by dom »

I had a look at updating the regular version - shouldn’t take too long so I’ll aim for that rather than a different version.

Hopefully should be done in the next few days.
User avatar
dom
Well known member
Posts: 2072
Joined: Sun Jul 15, 2007 10:01 pm

Re: sscanf, fscanf etc on clib=8080 missing

Post by dom »

..or hours. The next nightly should have a version of the scanf family available for 808x.
jacotton
Member
Posts: 89
Joined: Fri Nov 24, 2017 1:35 am

Re: sscanf, fscanf etc on clib=8080 missing

Post by jacotton »

wow, thanks for the fast turn around.
jacotton
Member
Posts: 89
Joined: Fri Nov 24, 2017 1:35 am

Re: sscanf, fscanf etc on clib=8080 missing

Post by jacotton »

Getting there:

__scanf_handle_c.asm:18: error: undefined symbol: __scanf_get_width

This seems to be the last one.
jacotton
Member
Posts: 89
Joined: Fri Nov 24, 2017 1:35 am

Re: sscanf, fscanf etc on clib=8080 missing

Post by jacotton »

in ~/stdio/__scanf_8080.asm
at line 110 is ___scanf_get_width:
But there is no PUBLIC for it.

Attempting a rebuild with the PUBLIC added. My success rate
has been zero in the past, but worth a try.
jacotton
Member
Posts: 89
Joined: Fri Nov 24, 2017 1:35 am

Re: sscanf, fscanf etc on clib=8080 missing

Post by jacotton »

Well, that was as expected. I can't build it.
make cpm8080_clib.lib

--- Building CP/M Library (8080)---

TARGET=cpm TYPE=8080 DEVICE=nodevice z88dk-z80asm -d -Ic:\cygwin64\home\lbmgm\projects\z88dk\lib\config/../ -m8080 -DSTANDARDESCAPECHARS -x/home/lbmgm/projects/z88dk/libsrc//cpm8080_clib @/home/lbmgm/projects/z88dk/libsrc//../libsrc//target/cpm/cpm_8080.lst
error: file open: /home/lbmgm/projects/z88dk/libsrc//../libsrc//target/cpm/cpm_8080.lst
make: [Makefile:713: cpm8080_clib.lib] Error 1 (ignored)

I did find that there is an extra _ on the lable ___scanf_get_width it shoud be __scanf_get_width
User avatar
dom
Well known member
Posts: 2072
Joined: Sun Jul 15, 2007 10:01 pm

Re: sscanf, fscanf etc on clib=8080 missing

Post by dom »

Oh I’m sorry. Because there’s a test I assumed all formatters were tested. Turns out only %d is covered.

I shall sort that this evening. Apologies.
jacotton
Member
Posts: 89
Joined: Fri Nov 24, 2017 1:35 am

Re: sscanf, fscanf etc on clib=8080 missing

Post by jacotton »

No problem. Thanks for taking care of this.
User avatar
dom
Well known member
Posts: 2072
Joined: Sun Jul 15, 2007 10:01 pm

Re: sscanf, fscanf etc on clib=8080 missing

Post by dom »

Thanks for the understanding, there's now quite few tests: https://github.com/z88dk/z88dk/blob/mas ... io/scanf.c and z80 and 8080 versions both produce the same results.

The only thing missing is the the %f handler which I'll leave for a rainy day.
jacotton
Member
Posts: 89
Joined: Fri Nov 24, 2017 1:35 am

Re: sscanf, fscanf etc on clib=8080 missing

Post by jacotton »

o.k. I don't need floating point output for basic ethernet anyway. Maybe next week when I start working on the 9511 coprocessor. wink!
User avatar
dom
Well known member
Posts: 2072
Joined: Sun Jul 15, 2007 10:01 pm

Re: sscanf, fscanf etc on clib=8080 missing

Post by dom »

jacotton wrote: Mon Jan 31, 2022 5:42 pm o.k. I don't need floating point output for basic ethernet anyway. Maybe next week when I start working on the 9511 coprocessor. wink!
Don't write it, use @feilipu's code with the --am9511 option!

In all seriousness if you do need it, let me know and I'll fix it up.
jacotton
Member
Posts: 89
Joined: Fri Nov 24, 2017 1:35 am

Re: sscanf, fscanf etc on clib=8080 missing

Post by jacotton »

I am getting a clean build now.

Not really planning to do a 9511 on my 8080 (maybe next year) but Will be working on it for z80 S100 platform. I
don't think this will require any additional code work.....
Post Reply