Si Owen wrote: >I might have to look more closely to see what the LineCycleCounter value is >throughout the loop, but it seems like a strange coincidence that the raw >values give the correct 0xc0c0 result! Are the instruction times always >going to be 4 t-state rounded?
Not quite that simple :) INs and OUTs are a bit awkward. First of all, INs and OUTs take differing numbers of t-states depending on whether the port is an internal SAM port (HMPR, etc) or an external one (Quazar etc). For internal ports the number of t-states used depends on when the instruction occurs. IN A,(n) and OUT (n),A takes 12 *OR* 16 t-states and IN r,(C) and OUT (C),r takes 16 *OR* 20 t-states. The number of t-states since some fixed point (beginning of the frame?) after the instruction seems to be rounded up to the nearest multiple of 8. For example the timings for the following code would be: 12/16 IN A,(STAT) ;Depends on where we've started from! 16 IN A,(STAT) 4 NOP 12 IN A,(STAT) 16 IN A,(C) 4 NOP 20 IN A,(C) All other versions of IN and OUT also vary by 4 t-states in the same way. *However* :) For external ports this rounding to the nearest 8 since some fixed point doesn't seem to occur. Also, IIRC, IN A,(n) and IN r,(C) both take the same time for external ports (12 t-states). Well, that should keep you going for a while :) David Laundon.