Kawasaki Steel KC160 support

New features and project activity between releases
Post Reply
User avatar
dom
Well known member
Posts: 2316
Joined: Sun Jul 15, 2007 10:01 pm

Kawasaki Steel KC160 support

Post by dom »

Hot on the heels of Rabbit 4000, we've added support for the Kawasaki Steel KC160 CPU.

The what?

This is an almost forgotten-to-time z80 clone and extension from Kawasaki back in 1994. It was discontinued in 2004 and references to it online are very elusive. However, why let that be a barrier? We found a stash of docs and to save future treasure hunts, placed them here: https://github.com/z88dk/techdocs/tree/master/kawasaki

As a z80 clone, it's about 4 times as fast - a one byte instruction takes 1T vs 2T on the ez80 and 4T on z80. Where things become interesting is the additional instructions in the 0xed page:
kc160_new_inst.png
There's some new instructions for accessing bc, de, hl via (ix+d), (iy+d), (sp+d) and also 8 and 16 bit multiplication and division - both signed and unsigned. All things that can speed up compiled code.

The CPU does have another trick up its sleeve - a 24 bit address space. The extension methods used are actually similar to those used by both the Rabbit and ez80 but also different at the same time.

- 0xed page instructions (LDF) for loading memory outside the usual 64k range and JP3/CALL3 to jump into that range - similar to the Rabbit
- 3 new 8 bit registers: XP, YP, ZP (and an internal PP) which can be used to extend 16 bit registers to 24 bit
- Some of the ld r,r instructions are used as prefixes to do this extension, eg using ld b,b (0x40) as a prefix means that the 16 bit register in the following instruction will be extended and use XP as bits 16-23

We're still trying to figure out whether this means that ld r,r is always a prefix, or just when code is running outside of the z80 region at the bottom of the address space and there may well be more secrets hidden in the 100s of pages of documentation.

From a z88dk perspective it's a really nice processor to target. If I were a hardware person I'd try and get hold of some of the remaining stock and build a board for it.

I mentioned it was fast, here's some results from the md5 test that I'm so fond of:

Running pure z80 code

Code: Select all

% zcc +test md5sum.c
md5sum.c:369:28: warning: Converting integer type to pointer without cast. From unsigned int  to char * fmt*  [-Wincompatible-pointer-types]
md5sum.c:369:31: warning: Assigning 'v', type: unsigned char * v from char * fmt*  [-Wincompatible-pointer-types]
% ls -al a.bin
-rw-r--r--  1 dom  staff  13864  7 Oct 14:28 a.bin
% z88dk-ticks a.bin -- testfile.bin
996d17ca7b233f87a94325b21762dc35
Ticks: 42860895
% z88dk-ticks -mkc160 a.bin -- testfile.bin
996d17ca7b233f87a94325b21762dc35
Ticks: 10331355
For reference, the R800 also executes quickly, but it's slower than the KC160 as is the more recent ez80:

Code: Select all

z88dk-ticks -mr800 a.bin -- testfile.bin
996d17ca7b233f87a94325b21762dc35
Ticks: 11414616

z88dk-ticks -mez80_z80  a.bin -- testfile.bin
996d17ca7b233f87a94325b21762dc35
Ticks: 11149448

And now taking advantage of some of the new instructions:

Code: Select all

% zcc +test -clib=kc160 md5sum.c
% ls -al a.bin
-rw-r--r--  1 dom  staff  13052  7 Oct 14:30 a.bin
% z88dk-ticks -w 60 -mkc160 a.bin -- testfile.bin
996d17ca7b233f87a94325b21762dc35
Ticks: 8420887
You can use sdcc as well of course:

Vanilla Z80:

Code: Select all

% zcc +test  md5sum.c -compiler=sdcc
% ls -al a.bin
-rw-r--r--  1 dom  staff  20138  7 Oct 14:33 a.bin
% z88dk-ticks a.bin -- testfile.bin
996d17ca7b233f87a94325b21762dc35
Ticks: 35547930
% z88dk-ticks -mkc160  a.bin -- testfile.bin
996d17ca7b233f87a94325b21762dc35
Ticks: 9879435
And then with optimisations for kc160:

Code: Select all

% zcc +test  md5sum.c -compiler=sdcc -clib=kc160
% ls -al a.bin
-rw-r--r--  1 dom  staff  19628  7 Oct 14:35 a.bin
% z88dk-ticks -mkc160  a.bin -- testfile.bin
996d17ca7b233f87a94325b21762dc35
Ticks: 9533902
I'd like to say have fun with it, but I doubt anyone has got anything with one of these CPUs inside. However if anyone has got any information about where it was used it would be great to hear.
You do not have the required permissions to view the files attached to this post.
Post Reply