Undefined __bdos with 8080 compile.

Post Reply
jacotton
Member
Posts: 63
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: 63
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: 1506
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: 63
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: 63
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: 63
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
Post Reply