[comp.sys.mac.programmer] m68k timing tables & Mac

tcd@vax5.cit.cornell.edu (04/29/91)

I'm trying to do some assembly language programming on a Mac and was 
wondering how to interpret the timing tables in e.g., the MC68020 User's
Guide relative to a Mac.  I'm not trying to get real precise, but just 
to develope some general guidelines, for a Mac II, IIcx, IIci in particular.
For example, which is likely to be faster?
     MULS.W  D1,D0          or       MOVE.L   (A0,D1.W),D0
Under the "No wait state memory (3 cycle read/write)" assumption for the
MC68020 timing tables, the MOVE.L would clearly be faster.  But, what are
the correct memory access assumptions for the Mac II family, and how do
these effect the timing tables?  From the Motorola manual, it looks like
I could take the total clocks for an instruction and subtract 3 times the
number of bus cycles given to get the number of internal clocks.  Then, if
I knew the number of clocks per read/write on the Mac, I could multiply
that by the number of bus cycles and add it back to the internal clocks to
get the total clocks for the Mac.  Somehow, I know it can't be that simple.
(if it is that simple, what are the appropriate clocks per read/write for
the various member of the Mac II family?).
     At the moment, I'm trying to figure out whether it makes sense to 
compute certain numbers on the fly, based on values already in registers,
or whether I should compute the set of numbers ahead of time and read them
from memory as I need them.  My current guess is that if it takes a 
multiply to get the number, then I'm better off putting it in a table; if
it takes a couple (register) moves and a shift or add then I should compute
it on the fly.  Anybody have any advice or recommendations on these matters?
Clearly, I'm a novice so please don't be too technical.
Thanks,
Tim Dorcey
tcd@cornella.cit.cornell.edu

deadman@garnet.berkeley.edu (Ben Haller) (05/05/91)

In article <1991Apr29.123112.4331@vax5.cit.cornell.edu> tcd@vax5.cit.cornell.edu writes:
>I'm trying to do some assembly language programming on a Mac and was 
>wondering how to interpret the timing tables in e.g., the MC68020 User's
>Guide relative to a Mac.  I'm not trying to get real precise, but just 
> [stuff omitted]
>Clearly, I'm a novice so please don't be too technical.

  Well, if you're a novice the timing information for the 68000 (versus the
68020) is much simpler, and should be sufficient for what you're trying to
do.  The timings for the 68020 in practice tend to *approximately* mirror
the 68000 instructions, but they're much more complex.  Actually, the best
way to determine the fastest code on a 68020 is to write all the
alternatives and clock them.  Of course, this isn't always easy/possible.
  There are a few important differences between chips in the 68000 line,
however, that you should be aware of if you care.  For example, register
shifts on the 68030 (not sure about the 020) run in a constant time that
doesn't depend on the shift count, while on the 68000 it's 8+2n or 6+2n, I
don't remember which, clocks where n is the shift count.  These kinds of
differences can, if fact, mean that you might want to write different code
and switch which code to run depending on which processor you're running
on.  Who knows.

-Ben Haller (deadman@garnet.berkeley.edu)
"Pop - ffffff" - Andrei