This wiki is being migrated to http://www.github.com/z88dk/z88dk/wiki

User Tools

Site Tools


advanced:cpmlink:programs

Linking Basic, Fortran, Pascal Programs with z88dk

The 'rel2z80' tool permits to convert any kind of object code being generated in REL format. This means that it is possible to work in a reverse-way and provide a new library set to a CP/M program, making it comatible with the z88dk targets.

Microsoft Basic

To link a Microsoft Basic program (compiled in the CP/M environment) it is necessary to adapt its library calls to the z88dk format. This can be done with a software interface, which can be written in C or assembler (see the example in the CVS tree). Given a REL file generated by the BASIC Compiler in CP/M, first convert it:

rel2z80 HILO.REL

This will extract a binary object SSMAIN.O, being SSMAIN the label for the BASIC compiled program entry. Now link it into a Z80ASM library and copy the lib in your Z88DK tree:

z80asm -d -ns -nm -Mo -xssmain ssmain.o
copy ssmain.lib "c:\Program Files\z88dk\lib\clibs"

At least the “main” entry needs to be written in C. It is included in the example provided, but you might prefer to provide your own runtime library.

  void main()
  {
      SSMAIN();
  }

Compile it referring to SSMAIN as a library to be included. In example a working command line for the Spectrum could be:

  zcc +zxansi -lndos -lssmain -lm -lmalloc -create-app baslib.c

The provided example library is able to work in “DEBUG” mode, you just need to specify the -DDEBUG flag when compiling. It will verbosely describe any function call:

Note that the example library is not complete: only small BASIC programs can be run with it.

advanced/cpmlink/programs.txt · Last modified: 2007/11/02 13:10 (external edit)