[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Decimal Flag Question



I wrote:
> It's possible that their state machine requires the extra state even
> though they don't add in the carry.  Or it could be an error.  Write a
> simple test program that runs the instruction ten million times, and
> measure the run time.

"Bryan Parkoff" <spam> writes:
>     How can you measure the run time that executes instruction ten million
> times.  It can only executes approximately less than 500,000 instructions
> per second.

What's difficult about it?  You write a loop that executes ten million
times, with nothing in the loop.  You time that.  Perhaps it takes a
few minutes.

Now you add the instruction you want to measure into the loop.  You time
it again.

Take the difference in the times, and divide by ten million.  That tells
you how much time a single execution of that instruction takes.  On
the Apple II, the average CPU clock cycle is 979.9 ns, so you easily
work out how many clock cycles the instruction takes.

This presumes that no interrupts occur during the timing.  On the IIgs,
perhaps it is necessary to disable interrupts to ensure this.