home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dream 48
/
Amiga_Dream_48.iso
/
Atari
/
assemblr
/
timecode
/
timecode.man
next >
Wrap
Text File
|
1998-01-19
|
4KB
|
84 lines
******************************************************************************
* *
* timecode.c version 1.0 of 27 August 1988 (C) L.J.M. de Wit 1988 *
* *
* This software may be used and distributed freely if not used commercially *
* and the originator (me) is mentioned. *
* *
******************************************************************************
NAME
timecode - time execution of MC68000 code
SYNTAX
timecode [-repeat] <shorthex1> <shorthex2> ...
DESCRIPTION
Timecode times the time needed to execute a series of MC68K instructions.
The time taken is expressed in clock ticks.
The repeat flag is optional; it is a number indicating how many times
the series will be repeated (default 100000) so that timing can be
accurate; a lower repeat count will fasten the execution but leads to
less accuracy.
One of the advantages of timecode is that timings can be calculated
online.
RESTRICTIONS
1) Up to 32 codes can be timed at once. This is generally no objection,
since most of the time one times only one instruction at a time.
2) When using opcodes that read from or write to memory the pointers
used will have to be prepared correctly. A convenient way is to
time the instruction to load the address register, then time both
the address register load and the instruction that references
memory via that pointer. Subtract the first from the second to
obtain the actual number of ticks for the 'mem-ref' instruction.
This whole story applies to whatever code needs proper
initialization. A safe place for memory references is the screen
memory.
3) Take care when using branches and stuff like jsr, rts etc.
Your code should handle that one way or another.
4) All registers may be used except the stack pointer. SP may be
used if it restored also. The items currently on the stack must
be left undisturbed; if you need to access (SP), first lower SP,
and increment it afterwards.
DERIVATION OF TIMING FORMULA.
The formula used for the calculation of the number of ticks is
(using integer division):
ticks = (7791*total + (repeat / 2))/repeat - 32;
where
ticks : # of ticks one execution of the series takes
total : # of milliseconds the complete test takes
repeat: # of repetitions of the series
This has been derived as follows:
total # of effective ticks for the test =
(total - call) * eff * 8000 =
repeat * (ticks + extra)
where
call : # of milliseconds lost by calling the test function
and saving registers. This is negligable.
eff : a coefficient (max. 1) that indicates how many ticks of
the processor are really used - the others are lost in
interrupt handling. Measuring gave 0.9739 as value; if the
vbl semaphore was set it increased to 0.9863. The former
value has been used.
extra : # of ticks needed to handle each repetition.
For this program its value is 32.
The 8000 is in fact due to the processor's clock frequency (8Mhz);
a factor 1000 can be found in the number total, which is expressed
in milliseconds instead of seconds.
Filling in eff and extra and adding (repeat / 2) to the nominator
to achieve rounding of the integer division rather than truncating
yields the formula used.
Because stdio and memory allocation were not needed, the module was
linked with a different startup.bin that does not load unnecessary code.
In this way the program size has decreased from 12666 to 3391.