Three questions

Other misc things
Post Reply
alank2
Member
Posts: 116
Joined: Wed Mar 01, 2017 7:24 pm

Three questions

Post by alank2 »

#1 - Can you use the newlib or oldlib with either compiler?

#2 - I somewhat remember the old compiler not supporting multiple indexed arrays or something, is that true?

#3 - Are there any predefined macros like _Z88DK_ or something that can be used to tell if z88dk is compiling something? I know they can be added on the command line, but i wonder if there are any built-ins.
User avatar
dom
Well known member
Posts: 2072
Joined: Sun Jul 15, 2007 10:01 pm

Re: Three questions

Post by dom »

1. Yes, both classic and newlib work with either compiler. newlib uses a different library for each compiler (-clib=new, -clib=sdcc_ix, -clib=sdcc_iy) whilst classic uses the same library and the compiler is selected with -compiler=sdcc or -compiler=sccz80

2. That limitation was removed a few years ago

3. There's __SCCZ80 and __SDCC available.
alank2
Member
Posts: 116
Joined: Wed Mar 01, 2017 7:24 pm

Re: Three questions

Post by alank2 »

I'm trying to compile this:

Code: Select all

#include <stdio.h>

void main()
{
  char s1[256];
  FILE *file;
  
  printf("Hello World\r\n");

  file=fopen("file.txt", "rb");
  if (file!=NULL)
    {
      printf("opened\r\n");


      while (!feof(file))
	{
	  if (fgets(s1, 128, file)==NULL)
	    continue;
	  printf("%s", s1);
	}
      fclose(file);

    }
  
}

with this batch file:

Code: Select all

@echo off

set temp=
set tmp=

if not "%Z80_OZFILES%"=="" goto skip
SET Z80_OZFILES=C:\z88dk\Lib\
SET ZCCCFG=C:\z88dk\Lib\Config\
SET PATH=%PATH%;C:\z88dk\Bin
:skip

rem zcc +cpm -compiler=sdcc -clib=new -create-app main.c -omain.com %1
rem zcc +cpm -compiler=sdcc -clib=sdcc_ix -create-app main.c -omain.com %1
rem zcc +cpm -compiler=sdcc -clib=sdcc_iy -create-app main.c -omain.com %1

rem zcc +cpm -compiler=sccz80 -clib=new -create-app main.c -omain.com %1
rem zcc +cpm -compiler=sccz80 -clib=sdcc_ix -create-app main.c -omain.com %1
rem zcc +cpm -compiler=sczz80 -clib=sdcc_iy -create-app main.c -omain.com %1

But all give errors.
User avatar
dom
Well known member
Posts: 2072
Joined: Sun Jul 15, 2007 10:01 pm

Re: Three questions

Post by dom »

I'm guessing it's the perennial problem, newlib doesn't support FILE io and no one wants to write it. If you want to use file io you have to use the classic library.

These days, for +cpm, +vgl I don't think there are any benefits to using newlib.

However, your compile lines are wrong, they should be (and I've commented what they're doing):

Code: Select all

; Newlib with sccz80
rem zcc +cpm  -clib=new -create-app main.c -omain.com %1
; Newlib with SDCC
rem zcc +cpm -clib=sdcc_ix -create-app main.c -omain.com %1
; Newly with SDCC and swapped ixiy
rem zcc +cpm -clib=sdcc_iy -create-app main.c -omain.com %1

; Classic with sccz80
rem zcc +cpm -compiler=sccz80 -create-app main.c -omain.com %1
; Classic with sdcc
rem zcc +cpm -compiler=sdcc -create-app main.c -omain.com %1
; Classic with sccz80 target 8080 processor
rem zcc +cpm -clib=8080 -create-app main.c -omain.com %1
alank2
Member
Posts: 116
Joined: Wed Mar 01, 2017 7:24 pm

Re: Three questions

Post by alank2 »

I appreciate your help dom; I'm having some trouble with these still. I commented out all the file stuff so they were just doing single printf hello world, and here are the results:

my command lines:

1st no
2nd 1853 bytes, works
3rd 1851 bytes, works
4th 3270 bytes, works
5th 1853 bytes, works
6th 1851 bytes, works

yours

Newlib with sccz80 3270 works
Newlib with SDCC 1852 works
Newly with SDCC and swapped ixiy 1851 works
Classic with sccz80 6618 runs, delays 5sec, exits no printing
Classic with sdcc 5173 runs, never exits, no printing
Classic with sccz80 target 8080 processor 6795 runs, delays 5sec, exits no printing

Any ideas why the classic are not working? Does there need to be more options specified?
alank2
Member
Posts: 116
Joined: Wed Mar 01, 2017 7:24 pm

Re: Three questions

Post by alank2 »

I'm testing them with a command line cp/m emulator called zx.
User avatar
dom
Well known member
Posts: 2072
Joined: Sun Jul 15, 2007 10:01 pm

Re: Three questions

Post by dom »

I've no idea at the moment. I've just tried it out with examples/console/world.c and the classic versions work correctly with z88dk-ticks and zxcc.

Can you add the -m option to the command line, and then email me (dom@...) the .map and .com files and I'll take a look.

BTW, Don't worry about the file sizes, the classic binaries are pulling a load of code to do command line redirection to files
alank2
Member
Posts: 116
Joined: Wed Mar 01, 2017 7:24 pm

Re: Three questions

Post by alank2 »

Email sent dom; thanks for your help!
alank2
Member
Posts: 116
Joined: Wed Mar 01, 2017 7:24 pm

Re: Three questions

Post by alank2 »

I'm using z88dk v2.1 - 07.02.2021
Timmy
Well known member
Posts: 392
Joined: Sat Mar 10, 2012 4:18 pm

Re: Three questions

Post by Timmy »

Just to make sure I understand this, multidimensional arrays are working now?
User avatar
dom
Well known member
Posts: 2072
Joined: Sun Jul 15, 2007 10:01 pm

Re: Three questions

Post by dom »

To wrap up Alan's issue. The output file was comprised of 0xff bytes. This was caused by reading and writing to the same file and was only an issue on Windows brought about by using the -o option with -create-app.
User avatar
dom
Well known member
Posts: 2072
Joined: Sun Jul 15, 2007 10:01 pm

Re: Three questions

Post by dom »

Timmy wrote: Thu Apr 22, 2021 3:44 pm Just to make sure I understand this, multidimensional arrays are working now?
Yup, they have been for a few years now, it went in as: https://github.com/z88dk/z88dk/issues/452 and https://github.com/z88dk/z88dk/pull/471 which was released in 1.99C
Post Reply