• Please review our updated Terms and Rules here

TI-74 BASIC profiler

JGardner

Experienced Member
Joined
Jun 14, 2009
Messages
200
Ever wonder how you might break down where your code is
spending time, or how long an individual task takes?

If you have access to a scope, or better yet a logic analyzer, it's
easy (A cheap PC-based logic analyzer works great.)

The idea is to toggle a pin in the Dock-Bus I/O port when the
routine you're interested in executes, and toggle it again when
the routine completes.

The following assumes your pgm is running in System RAM, not
cartridge memory - If you want to run your pgm in cartridge RAM
you'll need to adjust the POKE & EXEC addresses.

100 DATA 1234
110 CALL POKE(16370,165,1,15,10) ! replace DATA statement bytes w/ executable code

... code - When you get to what you want to measure, insert the following:

200 CALL EXEC(16370) ! Execute the DATA code in place, toggle HSK & trigger your scope/logic analyzer.
...
... routine you are measuring...
...

300 CALL EXEC(16370) ! Toggles HSK again at end of routine.

The pulse length on the scope, minus the execution time of the two
EXEC statements, is how long your routine takes - You can measure
EXEC time by executing two consecutive EXECs - It's close to 10 ms.
on my BASICALC!

FWIW, the asm code is:

xorp %>01,P15 ; toggle HSK
rets ; return to BASIC

Turning the '74 around & looking into the I/O port, counting from
left to right, ground is pin 10, & HSK is pin 7.


Jack
 
Back
Top