[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Apple II benchmark
In article <20000606193815.23514.00001484@ng-mb1.aol.com>,
Michael J. Mahon <mjmahon@aol.com> wrote:
>>> upshot was that the 65c02, being a more efficent
>>> processor than the x86, they said that the
>>> 8mhz chip was comprabable to a 33mhz 386, as far as
>>> doing the same number of instructions per second.
>
> A 386 typically required 8-10 clock cycles per
> instruction, while a 65x02 requires about 3+,
> on the average. So, *if* you're processing 8-bit
> data, a 65x02 should be about comparable to
> a 386 at three times the clock speed. (Of course,
> all the standard waivers apply, your mileage may
> vary. ;-)
>
> The 65x02 was a very efficient processor for
> the pre-RISC era, and the 65C02 is only
> marginally more efficient than the 6502.
The 386 has much more internal CPU registers than the 65x02, and if
you do the data processing in the internal registers, most
instructions execute in considerably less than 8 cycles -- some even
executes in 2 cycles (yes, the 386 was more cycle efficient than the
8086/8088, which required a minimum of 4 cycles for each operation).
Which of course means that if you program the 386 as if it was a
6502, i.e. if you use only a few of the 386's internal CPU registers
and fetch and store most of your data in external memory, and if you
process only 8-bit data this way, then the 6502 may be able to
compete with the 386.
And if you process only 8-bit data, you have A LOT of internal CPU
registers in the 386, since each 32-bit register can be used to store
no less than four 8-bit quantities. Consider for instance EAX, which
is 32 bits: the lowermost 8 bits are accessible as AL, and the next
lowermost 8 bits as AH. The highermost 16 bits cannot be addressed
separately, instead you'll have to rotate EAX by 16 bits, which will
swap the 16 lowermost and 16 highermost bits (the 386 introduced
the "barrel shifter": a hardware device which made shifts and
rotates any number of bits as fast as shifts/rotates of 1 bit. Thus,
swapping the 16 lowermost and 16 highermost bits by rotating EAX
by 16 bits is a fast operation, which executes in 2 cycles on the
386). This will enable you to store four 8-bit quantities in
EAX only. Then you have EBX, ECX and EDX too.....
And in the real world, one often wants to process data in bigger
chunks than 8 bits at a time -- in such cases the 8-bit data bus
of the 6502 becomes a real bottleneck.
------------------------------------------------------------------
The bottom line is: to be able to use it optimally from assembly
langauge, you must become familiar with the CPU and find the optimum
programming style for that particular CPU. If you e.g. program the
386 as if it was a 6502, then it's not really surprising that it
won't perform much better than a 6502. In the 386 you should keep
your data in internal CPU registers as long as you can, since any
access to external memory means a performance penalty compared to
accessing internal CPU registers. In the 6502 you cannot follow
this rule, since the 6502 hardly has any CPU registers at all...
--
----------------------------------------------------------------
Paul Schlyter, Swedish Amateur Astronomer's Society (SAAF)
Grev Turegatan 40, S-114 38 Stockholm, SWEDEN
e-mail: pausch at saaf dot se or paul.schlyter at ausys dot se
WWW: http://hotel04.ausys.se/pausch http://welcome.to/pausch