Using Timers

WinAPE Breakpoints allow two Timer functions to be used in the breakpoint condition. They are timer_start and timer_stop. The functions have a single parameter which is a unique identifier (word), and measure the time in microseconds between a timer_start and the each subsequent timer_stop.

The same timer identifier can be used multiple times, allowing multiple sections to be timed using the same timer, or multiple exit points to be set for a routine.

Timer functions can also be used in breakpoints set in the Assembler window.

The timer_start function always returns zero, so the breakpoint won't trigger unless you use an expression to make the result evaluate to non-zero (eg. timer_start(1) = 0), but the timer will always reset, regardless of the result of the condition.

The timer_stop function returns the number of cycles since the last timer_start with the same identifier, up to a maximum of 65535. This will always be non-zero, so the breakpoint will always be triggered unless an expression is used to make sure it isn't (eg. timer_stop(1) and 0). It is not good practice to use the not operator since it is a bitwise operator, so if the result of timer_stop(1) was 66 (#0042), then not timer_stop(1) would evaluate to -67 (#ffbd), which is still non-zero and treated as a true value.

By clicking the button in the main debugger window, you will be able to view the current state of all timers in the Timers window.

This window shows the identifier of the Timer, the number of times the timer has been triggered, the number of microseconds last time it was triggered, along with the minimum, maximum and average times in microseconds.