View Single Post
Old 14 October 2015, 12:30   #12
Join Date: Jul 2008
Location: Sweden
Posts: 2,265
Using the timers is not overkill if you want accuracte measurements, but if you care that much about accuracy then you can look up the cycle counts in the M68K User's Manual, then you'll know exactly how much time a piece of code will need.

But IMO skip the timers and the interrupts, and definitely skip membership in the "Cycle Counter Party", and just run your code multiple times and use the TOD clocks instead. You'll never have an error greater than about 64 ┬Ás, which means your result will be accurate within 0.01% even if you only measure over a single second.

EDIT: Example. Divide the result by the horizontal scan frequency if you want the time in seconds:
    (make sure the system interrupts are disabled while you run this)

    moveq   #0, d1
    move.b  CIABTODHI, d1
    swap    d1
    move.b  CIABTODMID, d1
    lsl.w   #8, d1
    move.b  CIABTODLO, d1

    (your code here)

    moveq   #0, d0
    move.b  CIABTODHI, d0
    swap    d0
    move.b  CIABTODMID, d0
    lsl.w   #8, d0
    move.b  CIABTODLO, d0

    sub.l   d1, d0
    bpl     .1
    add.l   #1<<24, d0

.1  (result in D0)

Last edited by Leffmann; 14 October 2015 at 12:43.
Leffmann is offline  
Page generated in 0.04343 seconds with 11 queries