Giter Club home page Giter Club logo

zxcc's Introduction

ZXCC

Introduction

This is John Elliott's CP/M 2/3 emulator for cross-compiling and running CP/M tools under Microsoft Windows and Linux/Unix/macOS. The ability to run under MS-DOS/DR-DOS is no longer supported.

This repository has been initially extracted from John Elliott's Stable version 0.5.7 source-code at

http://www.seasip.info/Unix/Zxcc/zxcc-0.5.7.tar.gz

I have some updates that will be applied soon to remedy some issues that I found when using the latest version of the HI-TECH Z80 C compiler v3.09-x - obtainable from the repository at

https://github.com/agn453/HI-TECH-Z80-C

I welcome bug reports/fixes and additional commentry and discussion.

You can raise an issue here on GitHub or contact me directly via e-mail at [email protected].

Updates

  • An apparent error in the source of the CP/M BDOS function 10 (read console buffer) emulation - courtesy of @tsupplis from his repository at https://github.com/tsupplis/zxccp

  • The C compiler (zxc) front-end was not accepting HI-TECH C-style command options that require filenames. It now accepts the following

  -efile.com     CP/M executable file name
  -ffile.sym     Symbol-table for debugger or overlay creation
  -idirectory    Include directory (in native format)
  -mfile.map     Linker map file
  -crfile.crf    Cross-reference listing
  • The linker (zxlink) should use the renamed HI-TECH linker (now linq.com).

  • Fix compilation warnings

  • Emulation of CP/M BDOS function 60 (call resident system extension) should be disabled and return 0xFF in both the A and L registers.

  • Change cpm_bdos_10() to return an unsigned result to avoid buffer size being interpreted as negative.

  • Fix the emulation of Z80 opcodes for IN (HL),(C) and OUT (C),(HL) - opcodes 0xED,0x70 and 0xED,0x71 respectively. This is noted in Fred Weigel's AM9511 arithmetic processing unit emulation from https://github.com/ratboy666/am9511 in the howto.txt description. NB: I have not included Fred's am9511 support at this time into ZXCC.

  • Russell Marks contributed a fix to the emulation of the Z80 DAA (decimal adjust) instruction - based on code from the yaze 1.10 emulator. The original code in ZXCC was based on incorrect documentation of the DAA instruction in the Zilog and Mostek programming manuals (and even in Rodney Zaks "Programming the Z80" book). The most recent documentation from Zilog has the correct description1. With this fix in-place ZXCC is able to run the Z80 instruction emulator test suite ZEXDOC from yaze-ag2. You can download a copy of the CP/M binary for ZEXDOC from https://raw.githubusercontent.com/agn453/ZEXALL/main/zexdoc.com

  • Mark Ogden (@ogdenpm) has supplied some modifications to allow stdin redirection from a file, as well as a fix to the BDOS function 10 bdos_rdline() routine to process new-line '\n' and '\r\n' correctly from file input.

  • Further tweaks from Mark Ogden for Console Line input. A NULL character can now be read, and long-lines are truncated (as they would be on a real CP/M computer). Control characters are also echoed using the ^ prefix. For example, Ctrl-Z echoes as ^Z (and is read by the emulated program as on real CP/M).

  • More updates from Mark Ogden - this time to keep track of open files. CP/M does not care if you don't close a file open for input - whereas under ZXCC the operating system keeps a file handle for each open file. This can have an effect when files are deleted or renamed. There's a symbol FILETRACKER that's been added to the configuration file config.h. Undefine this if you wish to restore the previous behaviour.

  • Michal Tomek has added environment variables for BINDIR80, INCDIR80 and LIBDIR80 to allow overriding the compiled-in defaults. Also, the bios.bin file can be in the same directory as the ZXCC executable or with the CP/M .COM files.

  • More from Michal Tomek - Fix compilation under Cygwin on Windows and correct BDOS function 40 (Write with Zero-fill).

  • Mark Ogden has added the capability to build the ZXCC command-line programs under Microsoft Windows (using Visual Studio). You'll find build instructions in the winbuild/README.md file. Further details concerning the changes are in changes.md.

  • A fix was made so that any reference to the P: drive is now redirected to the local default directory. Also, filenames under Windows can use either a forward slash / or back-slash \ in the directory path.

  • Mark Ogden has cleaned up a number of warnings for the Windows build using Visual Studio and fixed some issues with the install script when it encountered spaces in a Windows directory pathname and the CPMDIR80 environment variable determining the search paths for the CP/M binaries, libraries and include files.

  • Modified the compiler front-end (zxc) to support environment variables for INCDIR80 or CPMDIR80 and more changes to build with Cygwin on Windows from Mark Ogden.

  • Finally fixed by Mark Ogden (much appreciated) is an issue that affected the processing of the $$exec.$$$ file by HI-TECH C's batch processing. This changes the way ZXCC implements "exact file size" handling to match that of Jon Saxton's and HI-TECH C (see the README.md file for details). Also, user area specifications on CP/M filenames have been removed - since they're not implemented by ZXCC.

  • Fix parsing of spaces in the FCBs - resolving issue #39.

  • Look for CP/M COM file in current directory (emulated drive P:) before the binaries (in BINDIR80 emulated as drive A:).

  • The search for bios.bin on macOS should not use Linux-style /proc path.

  • Add some hints on where to find some extra files. In addition to the previous locations for .COM binaries, .LIB libraries and object files .OBJ (in the bin80 and lib80 locations), ZXCC now searches for .HLP, .MSG and .OVR files in bin80, .REL in lib80 and .H header files in include80. The Microsoft BASIC-80 compiler run-time BCLOAD. can be in the lib80, and HI-TECH C options help OPTIONS in the bin80 locations.

  • The exact file size changes have been reverted to behave like the original John Elliott version - and now use the DOS Plus convention. The HI-TECH Z80 C behaviour has been altered too as at v3.09-13 to support this. Please see the HI TECH Z80 C repository at https://github.com/agn453/HI-TECH-Z80-C for details and to update to the latest version.

--

--

Tony Nicholson 06-Jan-2024

Footnotes

  1. The most recent Zilog Z80 Family CPU User Manual (UM008001-1000) can be found at http://www.zilog.com/docs/z80/z80cpu_um.pdf

  2. You'll find the final version of yaze-ag 2.51.1 (as curated by Andreas Gerlich) at http://www.mathematik.uni-ulm.de/users/ag/yaze-ag

zxcc's People

Contributors

agn453 avatar mtdev79 avatar ogdenpm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zxcc's Issues

Order of search? local first?

The current zxcc search first for A: and then for P: for COM files. Wouldn't it be more logic to do the contrary?

Here is the suggested fix just switching the order:

/*
 * load_comfile() loads the COM file whose name was passed as a parameter.
 *
 */


void load_comfile(void)
{
    size_t com_len;
    char fname[CPM_MAXPATH + 1];
    FILE *fp;

    strcpy(fname, argv[1]);
    fp = try_com(fname);
    if (!fp) 
    {
        strcpy(fname, bindir80);
        strcat(fname, argv[1]);
        fp = try_com(fname);
    }

bds c not working on zxcc

bds c does not work and fails with a 'Disk read error'. I will investigate the reason for the failure as it works on zxccp that I know archived to switch to your version fully.

Parsing FCBs issues.

The current also for parsing fabs in xxcc.c is incorrect. In particular it ignores spaces: The fix is captured below:

image

char *parse_to_fcb(char *s, int afcb)
     RAM[afcb] = 0;
     memset(fcb, ' ', 11);
 
+    while (s[0]==' ')
+    {
+        s++;
+    }
     while (1)
     {
         if (s[0] == 0) break;  
-        if (s[0] == ' ') {++s; continue; }
+        if (s[0] == ' ') break; 
         if (s[1] == ':')

Extend zxcc to work with MacOS

MacOS does not support /proc. The code in zxcc uses /proc to find out a potential location for bios.bin.
Here is a suggested fix

    if (!fp)
    {
        dir[0] = 0;                           /* use strncat in case the path is very long */
#ifdef _MSC_VER
        strncat(dir, _pgmptr, CPM_MAXPATH - 8);   /* copy the executable path */
#elif defined(__linux)  
        readlink("/proc/self/exe", dir, CPM_MAXPATH - 8);   /* allow room for bios.bin */
#endif
        if(dir[0]) {
            q = strrchr(dir, DIRSEPCH);
            *++q = 0;
            strcpy(fname, dir);
            strcat(fname, "bios.bin");
            fp = fopen(fname, "rb");
        }
    }

Widening of BIN80/LIB80/INCLUDE80 mapping

Here is a suggestion of a couple of well known mappings that could be added to zxdbdos.c

int fcbforce(byte *fcb, byte *odrv)
{
	byte drive;
	char typ[4];	
	char nam[9];	
	int n;

	for (n = 0; n < 8; n++) nam[n] = fcb[n+1] & 0x7F;
	nam[8] = 0;
	for (n = 0; n < 3; n++) typ[n] = fcb[n+9] & 0x7F;
	typ[3] = 0;

	drive = 0;
	if (*fcb) return 0;	/* not using default drive */
	if (!strcasecmp(nam,"BCLOAD  ") && !strcasecmp(typ, "   ")) drive = 2;
	if (!strcasecmp(nam,"OPTIONS ") && !strcasecmp(typ, "   ")) drive = 1;
	if (!strcasecmp(typ, "COM")) drive = 1;
	if (!strcasecmp(typ, "HLP")) drive = 1;
	if (!strcasecmp(typ, "MSG")) drive = 1;
	if (!strcasecmp(typ, "OVR")) drive = 1;
	if (!strcasecmp(typ, "LIB")) drive = 2; 
	if (!strcasecmp(typ, "OBJ")) drive = 2; 
	if (!strcasecmp(typ, "REL")) drive = 2; 
	if (!strcasecmp(typ, "H  ")) drive = 3; 

	if (!drive) return 0;
	
	*odrv = *fcb;
	*fcb = drive;
	return 1;
}
  • BCLOAD for bascom
  • H Headers include
  • REL Objects in lib
  • MSG, OVR, HLP in bin for turbo pascal in particular but very generic
  • OPTIONS in bin (for htc cc -h)

file track.c is not in the repo

presumably, this is part of the file tracking addition in the latest commit.

cpmredir/lib:
make: *** No rule to make target 'track.c', needed by 'track.o'. Stop.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.