[Coco] Devastated. Long term OVCC project falls short
Walter Zambotti
zambotti at iinet.net.au
Fri Oct 4 00:06:05 EDT 2019
Hello all.
As you all know I have been working on OVCC which is the portable
version of VCC for Linux/OSX and Windows.
I have just released version 1.1.0 which has finally added the CPU 6309
Turbo feature.
The 6309 turbo feature is a reworking of the 6309 cpu emulator written
in C rewritten in X86 assembly.
I actually targeted this project for VCC 1.43 and started before writing
OVCC. So it was put on hold until OVCC was complete.
It is now complete.
As I was writing the assembly emulator I ran across some major obstacles
that I had to overcome.
The first was functional testing. To address this I wrote a
verification suite that could execute any instruction in isolation for
all its data and condition code combinations and compare the results to
another assumed working 6309 emulator (already available in VCC).
After many months work all 437 6309 instructions with countless billions
of test iterations was completed about two weeks ago. Some instructions
that work with 16 x 16 bit data take 4-8 billion iterations to test. A
single test of one of these instructions takes about 10-20 minutes on a
decent Intel system and there about a hundred or so of these.
During the testing the verification suite which was also timing the
execution of each instruction was indicating the assembly was twice the
performance or efficiency of the C code.
However late in the testing stage I remember the C code was not being
compiled optimized for debugging purposes.
After recompiling the C code with optimization the assembly was only 25%
faster. Wow I was taken back but at the same time really impressed with
the optimizations of modern compilers.
But the real performance test is where the rubber meets the road and
until I got the new 6309 emulator into OVCC then I couldn't be sure what
the performance gain would be.
Well I have now completed the integration of the new 6309 turbo emulator
into OVCC.
Along the way I had some major hurdles. At first the new emulator
wouldn't work at all even with all the verification testing. How was I
going to find which instruction(s) was causing the problem!
I had an awful (but incorrect) realization that I was going to have to
make a special version of OVCC that ran both the old and new cpu
emulators side by side comparing all results after each instruction.
I was beside myself for a few days until I remember to divide and concur
the problem.
Basically each CPU emulator contains a jump table (3 actually) to each
of the cpu instructions. The only difference is the C emulator has C
functions and the assembly emulator has assembly functions.
The jump table or the CPU executive doesn't care or know that they are
one or the other type of function.
So I just substituted a hand full of the C functions pointers for
assembly function pointers (in the jump table) at a time and waited for
OVCC to crash.
In the end there were only a few instructions that were causing problems
and I managed to get it all going.
So what are the results?
Disappointing!!!!!!!!!!!!!!!!!!!!!!!!!!!!
On Windows the assembly 6309 CPU runs about 1-1.5% SLOWER!
On Linux the assembly 6309 CPU runs about 45%-50% SLOWER!!!
I can't accurately estimate the amount of time I spent on this project
but it is a lot (I guesstimate about 6 months worth).
The only recompense is along the way I did learn a lot about X86 machine
instructions.
And...
The new cpu emulator can also gather instruction usage statistics.
And, and ...
As I was verifying/comparing the 6309 C code to the assembly code I
added all the missing 6309 instructions and made some corrections to
existing instructions that did not fully comply with the 6309
instruction manual.
So the 6309 emulation in OVCC is full and complete with all
instructions, both the C and assembly. This would be easily back ported
to VCC!!!
For now I will leave the 6309 turbo option in OVCC out of interest only.
I have also placed an additional indicator on the OVCC message bar that
shows whether the 6309 is running in emulation or native mode. You will
see either:
6309E at 0.89mhz <-- 6309 in emulation mode
6309N at 0.89mhz <-- 6309 in native mode
6309XE at 0.89mhz <-- 6309 turbo in emulation mode
6309XN at 0.89mhz <-- 6309 turbo in native mode
Hope I didn't rant for to long!
Walter
More information about the Coco
mailing list