RC2014-8085 Support

Discussion about other targets
Post Reply
User avatar
feilipu
Member
Posts: 45
Joined: Tue Nov 15, 2016 5:02 am

RC2014-8085 Support

Post by feilipu »

z88dk support of the RC2014-8085 Module. The intention is to provide both ACIA ROM and MS Basic RAM subtypes.
But at this stage I've focused on getting the basic85 working. ACIA support can come later.

As z88dk supports 8085 C compilation using the sccz80 compiler and the classic library, whilst the RC2014 target is normally a newlib library target, there was quite a bit of interesting blending of classic and new code to get the crt0 and libraries created and linked properly. But, now the RC2014-8085 is the first 8085 platform in the newlib targets. Woo Hoo!

Having the basic85 subtype means that C and assembly programs can be uploaded to the RC2014 using the MS Basic HLOAD keyword.

In host PC:

Code: Select all

> zcc +rc2014 -subtype=basic85 [ --list -m ] myfile.c -o myhexfile -create-app
Then from MS Basic:

Code: Select all

HLOAD

Code: Select all

> cat >/dev/ttyUSB0 <./myhexfile.ihx
And to run the program from MS Basic:

Code: Select all

? usr(0)
And that's all that's needed.

This is still being tested, and assume that there will be issues. But the first work is now done.

Image

In another note, Paulo has gone to town with synthetic instructions for the 8085 in z88dk-z80asm, to make coding more convenient. Essentially, anything you can do with loading indirectly from (hl), you can now transparently do from (de). The assembler implements the ex de,hl instructions silently to make life easy. This helps when writing assembly for Z80 and 8085, because you don't have to write alternate code paths depending on the CPU. Of course all of the other 8085 side effect free convenience opcodes are available too, like ld bc,hl and ld hl,sp+n.
User avatar
feilipu
Member
Posts: 45
Joined: Tue Nov 15, 2016 5:02 am

Re: RC2014-8085 Support

Post by feilipu »

Since my last post there have been three updates of note.

1. I've added another subtype called acia85, which is designed to used as a ROM load. It provides ACIA drivers, and the necessary page0 and jump vectors specifically for the 8085 CPU. This will be the basis of future ROMs for the RC2014-8085.

2. Since I'm very keen to support the Am9511A APU Module for the RC2014, I needed to provide support for Z80 wait state timing to the 8085 CPU. The 8085 doesn't provide an automatic I/O wait state, and the timing requirements are too tight for any normal peripheral to achieve. So there needed to be a wait state generator added to the 8085 CPU Module. I've designed and tested a new version, and it works great.

Image.

3. Since possibly 1998, and possibly even longer, the 8080, 8085 and Gameboy Z80 CPU support has used non-reentrant primitives, with some of the code being derived from the Amsterdam Compiler Kit.

Dom recently went to the trouble to reorganise all of the primitives (called l_ functions), so that there is a neat inheritance process, with 8085 derived from 8080 and using common primitives. Gameboy uses its own primitives, with common primitives, and Z80 also uses its own primitives inheriting from common too.

With that mechanism in place, initially it was just a process of picking functions where the 8085 undocumented instructions could contribute to better code. But, then I got a bit carried away and also rewrote all the 8080 and gbz80 primitives where necessary to ensure that the whole library was reentrant.

Its been an interesting few weeks, and hopefully these new compiler primitives will be useful for as long as the last set were.

Some notes on the instructions had learning here.

Cheers, Phillip
User avatar
feilipu
Member
Posts: 45
Joined: Tue Nov 15, 2016 5:02 am

Re: RC2014-8085 Support

Post by feilipu »

It has been a few months since the last update on the RC2014 8085 support project, so I thought it would be worth a status update.

The current situation is that two versions of Microsoft BASIC 85 are available for the 8085 CPU Module on the RC2014 platform. One using the MBF32 floating point (the normal way), and another with the Am9511A (Intel 8231) APU Module. Using Microsoft BASIC as a platform it is possible to upload z88dk compiled programs prepared with the basic85 subtype.

Using the ROM subtype acia85, a CP/M version has been developed, using z88dk sccz80 to prepare a FATFS library, which can access standard FAT drives. Also the shell / monitor for CP/M-IDE was written in C and the whole thing linked and built. This demonstrates that 8085 compatibility is now pretty solid.

IMG_1639.JPG

Applications can be built for the any 8085 CPU based CP/M (including CP/M-IDE obviously), by using target +cpm -clib=8085 to build the source. Some testing and benchmarking has been done with the standard z88dk examples and benchmarks. Again, 8085 compatibility and support is now pretty good.

As part of this there've been quite a few under the cover updates across z88dk string function library for the 8085 (and 8080 / GBZ80), using a faster loop mechanism which saves at least 10 cycles per byte, and extending and enabling callee access where possible. Hopefully, no additional breakage which would be on me.

Benchmarking of the 8085 vs Z80 has been completed, and in at least one case the 8085 wins! See here spectral-norm.
And, in most other cases is within a 1% of the Z80 result.

Possibly, the good results (without the additional registers and opcode extensions of the Z80) come down to just two things;
the stack relative addressing, and 16-bit load / store instructions added to the 8085.

These small additions to the 8085 allow the stack to be used almost as effectively as registers.
Makes me feel sorry that the Intel engineers who added these to the 8085 back when were never allowed to support these instructions. =(

Further work is to enable the use of the APU Module from within the 8085 CP/M, though enabling the Am9511A math library for 8085.
You do not have the required permissions to view the files attached to this post.
User avatar
feilipu
Member
Posts: 45
Joined: Tue Nov 15, 2016 5:02 am

Re: RC2014-8085 Support

Post by feilipu »

I've just added for the Am9511 (Intel 8231) APU math library for the 8085 CP/M and other 8085 targets within z88dk.
So now the 8085+Am9511 support is pretty much rounded out and complete.

To use the APU math library with CP/M, the library just needs to be linked with --math-am9511_8085.
For example:

Code: Select all

zcc +cpm -clib=8085 -v -O2 n-body.c -o nbody --math-am9511_8085 -lndos -create-app
Just working through some benchmarks on my CP/M System now.

The Whetstone Benchmark for RC2014 results are:
  • 8085+MBF32 -> 78.2 Seconds -> 12.8 kWhetstone.
  • 8085+AM9511 -> 30.4 Seconds. -> 32.9 kWhetstone.
And for the n-body Benchmark the RC2014 results are:
  • 8085+MBF32 -> 252.3 Seconds.
  • 8085+AM9511 -> 69.3 Seconds.
So the the 8085+APU system is 2.5x to 3.6x faster than the best 8085 software maths library.
And what is very interesting is that these numbers align very closely with the Z80 results.
User avatar
feilipu
Member
Posts: 45
Joined: Tue Nov 15, 2016 5:02 am

Re: RC2014-8085 Support

Post by feilipu »

I've written some documentation about the CP/M-IDE for the 8085 Module.

It might be a useful guide for someone new trying to understand where various files are found in the z88dk newlib targets taking the rc2014 as an example, how a project is built, and the code execution flow following reset.

CP/M-IDE 8085 uses these z88dk features.
  • hybrid newlib / classic target
  • sccz80 compiler for a shell written in C
  • extensive assembly files (for CP/M) using PHASE/DEPHASE for relocation of assembled code
  • preamble code to locate drivers to high memory
  • external library written in C providing FAT file system
Post Reply