home *** CD-ROM | disk | FTP | other *** search
/ Dream 48 / Amiga_Dream_48.iso / Atari / assemblr / timecode / timecode.man next >
Text File  |  1998-01-19  |  4KB  |  84 lines

  1. ******************************************************************************
  2. *                                                                            *
  3. *    timecode.c version 1.0 of 27 August 1988   (C) L.J.M. de Wit 1988       *
  4. *                                                                            *
  5. * This software may be used and distributed freely if not used commercially  *
  6. * and the originator (me) is mentioned.                                      *
  7. *                                                                            *
  8. ******************************************************************************
  9.  
  10.    NAME
  11.       timecode - time execution of MC68000 code
  12.   
  13.    SYNTAX
  14.       timecode [-repeat] <shorthex1> <shorthex2> ...
  15.   
  16.    DESCRIPTION
  17.       Timecode times the time needed to execute a series of MC68K instructions.
  18.       The time taken is expressed in clock ticks.
  19.       The repeat flag is optional; it is a number indicating how many times
  20.       the series will be repeated (default 100000) so that timing can be
  21.       accurate; a lower repeat count will fasten the execution but leads to
  22.       less accuracy.
  23.   
  24.       One of the advantages of timecode is that timings can be calculated
  25.       online.
  26.   
  27.    RESTRICTIONS
  28.       1) Up to 32 codes can be timed at once. This is generally no objection,
  29.          since most of the time one times only one instruction at a time.
  30.       2) When using opcodes that read from or write to memory the pointers
  31.          used will have to be prepared correctly. A convenient way is to
  32.          time the instruction to load the address register, then time both
  33.          the address register load and the instruction that references
  34.          memory via that pointer. Subtract the first from the second to
  35.          obtain the actual number of ticks for the 'mem-ref' instruction.
  36.          This whole story applies to whatever code needs proper
  37.          initialization. A safe place for memory references is the screen
  38.          memory.
  39.       3) Take care when using branches and stuff like jsr, rts etc.
  40.          Your code should handle that one way or another.
  41.       4) All registers may be used except the stack pointer. SP may be
  42.          used if it restored also. The items currently on the stack must
  43.          be left undisturbed; if you need to access (SP), first lower SP,
  44.          and increment it afterwards.
  45.   
  46.       DERIVATION OF TIMING FORMULA.
  47.   
  48.       The formula used for the calculation of the number of ticks is
  49.       (using integer division):
  50.          ticks = (7791*total + (repeat / 2))/repeat - 32;
  51.       where
  52.          ticks : # of ticks one execution of the series takes
  53.          total : # of milliseconds the complete test takes
  54.          repeat: # of repetitions of the series
  55.   
  56.       This has been derived as follows:
  57.          total # of effective ticks for the test =
  58.          (total - call) * eff * 8000 =
  59.          repeat * (ticks + extra)
  60.       where
  61.          call  : # of milliseconds lost by calling the test function
  62.                  and saving registers. This is negligable.
  63.          eff   : a coefficient (max. 1) that indicates how many ticks of
  64.                  the processor are really used - the others are lost in
  65.                  interrupt handling. Measuring gave 0.9739 as value; if the
  66.                  vbl semaphore was set it increased to 0.9863. The former
  67.                  value has been used.
  68.          extra : # of ticks needed to handle each repetition.
  69.                  For this program its value is 32.
  70.       The 8000 is in fact due to the processor's clock frequency (8Mhz);
  71.       a factor 1000 can be found in the number total, which is expressed
  72.       in milliseconds instead of seconds.
  73.       Filling in eff and extra and adding (repeat / 2) to the nominator
  74.       to achieve rounding of the integer division rather than truncating
  75.       yields the formula used.
  76.    
  77.  
  78.    Because stdio and memory allocation were not needed, the module was
  79.    linked with a different startup.bin that does not load unnecessary code.
  80.    In this way the program size has decreased from 12666 to 3391.
  81.    
  82.  
  83.  
  84.