Undefined __bdos with 8080 compile.

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

Undefined __bdos with 8080 compile.

Post by jacotton »

Not finding the "why" of this bug.
$ make
zcc +cpm -clib=8080 -create-app -oxr --list --c-code-in-asm xr.c
Error at file 'fputc_cons.asm' line 32: symbol '__bdos' not defined
Error at file 'fputc_cons.asm' line 43: symbol '__bdos' not defined
Error at file 'fputc_cons.asm' line 48: symbol '__bdos' not defined


etc.

Code: Select all

Makefile
xr: xr.c
	zcc +cpm -clib=8080 -create-app -oxr --list --c-code-in-asm xr.c
#	zcc +cpm -create-app -otoupper main.c --list --c-code-in-asm

clean:
	rm *.o *.err *.lis *.def *.sym *.exe *.COM xr 

install:
	sudo cp ./*.COM /var/www/html/.
C code:

Code: Select all

#include <stdlib.h>
#include <fcntl.h>
/*
Read data from host via XMODEM protocol.

This will only read data.  */

#define SOH	0x01
#define EOT	0x04
#define ACK	0x06
#define NAK	0x15
#define ETB 	0x17
#define CAN	0x18
#define Sync	0x43
#define ThreeSeconds 4000
#define PayLoadSz 131-4

typedef struct packed
{
  unsigned char Header;
  unsigned char PackNr;
  unsigned char NotPackNr;
  unsigned char Data[PayLoadSz];
  unsigned char CRC[2];
} PACKET;

PACKET record;
int i;
int fd;
char filename[14];

/* poll console port for incoming data */
int Poll()
{
#asm
	ld	c,0bh
	call	5
	ld	l,a
	ld	h,0
#endasm
}
/* read a byte from console port */
int Read()
{
	while(!Poll());
#asm
	ld	c,06h
	ld	e,0ffh
	call	5
	ld	l,a
	ld	h,0
#endasm
}
unsigned char _c;
int Write(unsigned char c)
{
	_c = c;
#asm
	ld	c,06h
	ld	a,(__c)
	ld	e,a
	call	5
#endasm
}
/* close the output file */
int CloseFile()
{
	close(fd);
}
/* write to the output file */
/* may need to implement a blocking algorithm here */
int FileWrite(char *data)
{
	write(fd,data,PayLoadSz);
}
/* open the output file */
/* may want to check for file name conflict here */
int FileOpen(char *filename)
{
	fd = open(filename,O_WRONLY,O_CREAT);
}

int
ReadPacket (PACKET * buff)
{
/* see if the first char is an SOH or
at EOT or ETB */

  /* poll for data */
  while (!Poll ());
  buff->Header = Read ();
  if ((buff->Header) == EOT)
    {
      CloseFile ();
      exit (0);
    }
  else if ((buff->Header) == ETB)
    {
      CloseFile ();
      exit (0);
    }
/* read packet number */
  buff->PackNr = Read ();
  buff->NotPackNr = Read ();
/* may need those later */
  for (i = 0; i < PayLoadSz; i++)
    {
      buff->Data[i] = Read ();
    }
/* get the CRC bytes */
  buff->CRC[0] = Read ();
  buff->CRC[1] = Read ();
}

int
CheckSOH ()
{
  if (record.Header == SOH)
    return 1;
  return 0;
}

int timer;
void
AdvanceTime ()
{
  timer += 1;
}

void
AckOut ()
{
  Write(ACK);
}

void
NackOut ()
{
  Write(NAK);
}

void
SyncOut ()
{
  Write(Sync);
}

int
calcrc (unsigned char *ptr, int count)
{
  int crc;
 char i;

  crc = 0;
  while (--count >= 0)
    {
      crc = crc ^ (int) *ptr++ << 8;
      i = 8;
      do
	{
	  if (crc & 0x8000)
	    crc = crc << 1 ^ 0x1021;
	  else
	    crc = crc << 1;
	}
      while (--i);
    }
  return (crc);
}


int
CheckCRC ()
{

  if (record.CRC == calcrc (record.Data, PayLoadSz))
    return 1;
  else
    return 0;
}
void
main (int argc, char *argv[])
{
/* send a Sync, and wait for 3 seconds to see if the host
starts sending data, else after 3 seconds, send another one */

  while (1)
    {
      SyncOut ();
      timer = 0;
      while (timer <= ThreeSeconds)
	{
	  if (CheckSOH (record))
	    {
	      goto here;
	    }
	  AdvanceTime ();
	}
    }
here:
  if (CheckCRC (ReadPacket (record)) == 1)
    {
      AckOut ();
/* record is good, so write it out */
      FileWrite (record.Data);
    }
  else
    NackOut ();
  goto here;
}
jacotton
Member
Posts: 89
Joined: Fri Nov 24, 2017 1:35 am

Re: Undefined __bdos with 8080 compile.

Post by jacotton »

updated to latest, no change.
User avatar
dom
Well known member
Posts: 2072
Joined: Sun Jul 15, 2007 10:01 pm

Re: Undefined __bdos with 8080 compile.

Post by dom »

I've had a look at this, and I can't reproduce it, but I have a hunch what's happened.

It looks like when I introduced that function there was a period of time when I missed adding the functions to the 8080 library: this was one of the reasons why I added in the build step this year to compile examples for every target.

So, I think what you need to do is to rebuild the libraries:

Code: Select all

cd libsrc
make clean
make
cp *.lib ../lib/clibs/
This will also pick up the fread() implementation that was missing as well.
jacotton
Member
Posts: 89
Joined: Fri Nov 24, 2017 1:35 am

Re: Undefined __bdos with 8080 compile.

Post by jacotton »

Guess I should have pointed out that I am running this instance on windows 10, under cygwin.
The cygwin build is a bust. And the windows build is a no start.

Here is the date code for zcc
zcc - Frontend for the z88dk Cross-C Compiler - v18243-d44d588-20210418

I will move my project to linux and try it there.
jacotton
Member
Posts: 89
Joined: Fri Nov 24, 2017 1:35 am

Re: Undefined __bdos with 8080 compile.

Post by jacotton »

After reload/rebuild on linux, my code now builds.
Still not working on windows.
jacotton
Member
Posts: 89
Joined: Fri Nov 24, 2017 1:35 am

Re: Undefined __bdos with 8080 compile.

Post by jacotton »

I can confirm that the bug is now gone on the windows package.
thanks
jc
jacotton
Member
Posts: 89
Joined: Fri Nov 24, 2017 1:35 am

Re: Undefined __bdos with 8080 compile.

Post by jacotton »

It's back....
Error at file 'fputc_cons.asm' line 32: symbol '__bdos' not defined


This is on windows 10 running under cygwin.
User avatar
dom
Well known member
Posts: 2072
Joined: Sun Jul 15, 2007 10:01 pm

Re: Undefined __bdos with 8080 compile.

Post by dom »

I took the latest nightly and attempted to compile examples/console/world.c, here's a screenshot:
Screenshot 2022-01-19 at 19.55.58.png
So you can see it's pulling in fgetc_cons and __bdos.

So it looks like this is local environmental issue on your side - are you building on Cygwin yourself or using the nightly kits?
You do not have the required permissions to view the files attached to this post.
jacotton
Member
Posts: 89
Joined: Fri Nov 24, 2017 1:35 am

Re: Undefined __bdos with 8080 compile.

Post by jacotton »

No joy here, even after a fresh install of nightly. Also cleaned out all the /usr/local/bin and lib stuff. still get the error.

Here is the PATH
PATH=/home/lbmgm/projects/z88dk/bin:/usr/local/bin:/usr/bin:/cygdrive/c/Program Files (x86)/Common Files/Oracle/Java/javapath:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/WINDOWS/System32/WindowsPowerShell/v1.0:/cygdrive/c/WINDOWS/System32/OpenSSH:/cygdrive/c/Program Files (x86)/HP/Common/HPDestPlgIn:/cygdrive/c/Program Files (x86)/Common Files/Intuit/QBPOSSDKRuntime:/cygdrive/c/Wincupl/WINCUPL/EXE:/cygdrive/c/Wincupl/WINCUPL/FITTERS:/cygdrive/c/Program Files (x86)/HP/Common/HPDestPlgIn:/cygdrive/c/Users/lbmgm/AppData/Local/Microsoft/WindowsApps:/cygdrive/c/ProgramData/lbmgm/GitHubDesktop/bin:/home/lbmgm/projects/z88dk/bin:/cygdrive/c/SysGCC/m68k-elf/bin

zcc - Frontend for the z88dk Cross-C Compiler - v18243-d44d588-20210418

Downloaded and install most current nightly.

I can't build the repo on my cygwin/windows box. All kinds of compile bugs.

Also, this works find on the linux machine. So must be a windows issue.
User avatar
dom
Well known member
Posts: 2072
Joined: Sun Jul 15, 2007 10:01 pm

Re: Undefined __bdos with 8080 compile.

Post by dom »

That doesn’t look like the latest - has a date of April 2021.
cborn
Well known member
Posts: 267
Joined: Tue Oct 06, 2020 7:45 pm

Re: Undefined __bdos with 8080 compile.

Post by cborn »

Hi, i have a common question, would this code work with any XMODEM ?
eg an VTX5000 on an ZX, if vtx is an xmodem, afaik there are xmodem for zx.

edit, maybe i have an answer already
"CALL 5" is not typical ZX although it is a jump ( JP $11cb,START)
jacotton
Member
Posts: 89
Joined: Fri Nov 24, 2017 1:35 am

Re: Undefined __bdos with 8080 compile.

Post by jacotton »

download from http://nightly.z88dk.org/
this file z88dk-win32-latest.zip 2022-01-24 03:09 79M
do rm -rf z88dk to clear out the old copy.
... I found the my bug... self induced as usual .
copy 'z88dk-win32-latest (6).zip'
................................^^^ ops gotta check for that... remember its windows.
unzip 'z88dk-win32-latest (6).zip'

And, now it makes correctly.
User avatar
dom
Well known member
Posts: 2072
Joined: Sun Jul 15, 2007 10:01 pm

Re: Undefined __bdos with 8080 compile.

Post by dom »

jacotton wrote: Mon Jan 24, 2022 5:24 pmunzip 'z88dk-win32-latest (6).zip'
I had a feeling that might be what was happening (I got caught by it whilst investigating this issue!) - I'm glad it's all working again.
Post Reply