Counting T states in Excel

The place for codemasters or beginners to talk about programming any language for the Spectrum.
User avatar
arkannoyed
Manic Miner
Posts: 366
Joined: Mon Feb 05, 2018 9:56 am

Re: Counting T states in Excel

Post by arkannoyed » Tue May 21, 2019 9:47 am

I seem to recall an ancient thread on WOS many years ago, where a useful utility that went by the name of 'Ticks' or something similar could be used to give accurate T-state timings for a piece of assembly code. Googling it though, I can't find it now.
0 x

User avatar
djnzx48
Manic Miner
Posts: 563
Joined: Wed Dec 06, 2017 2:13 am
Location: New Zealand

Re: Counting T states in Excel

Post by djnzx48 » Tue May 21, 2019 9:52 am

Is this it? ticks.0.15.zip
2 x

User avatar
Ast A. Moore
Dynamite Dan
Posts: 1222
Joined: Mon Nov 13, 2017 3:16 pm

Re: Counting T states in Excel

Post by Ast A. Moore » Tue May 21, 2019 10:03 am

djnzx48 wrote:
Tue May 21, 2019 8:21 am
I'm pretty sure it would be possible. Since the machine behaviour is deterministic, you could just have another emulation running ahead of the main one that remembers the instruction timings.
Generally, true. The problem is mostly with branching and conditionals.

Most debuggers display the current number of T states elapsed since the beginning of the frame, anyway. Most of the time, that’s enough. If I optimize my routines, I simply put the number of T states for each instruction in square brackets in the code’s commentary and calculate them manually. However, I still mostly use my gut feeling and experience for optimization. Seems to work best.
0 x
Every man should plant a tree, build a house, and write a ZX Spectrum game.

Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.

User avatar
arkannoyed
Manic Miner
Posts: 366
Joined: Mon Feb 05, 2018 9:56 am

Re: Counting T states in Excel

Post by arkannoyed » Tue May 21, 2019 10:18 am

djnzx48 wrote:
Tue May 21, 2019 9:52 am
Is this it? ticks.0.15.zip
Thats the one, though I've not much of in idea for how to use it though?
0 x

User avatar
djnzx48
Manic Miner
Posts: 563
Joined: Wed Dec 06, 2017 2:13 am
Location: New Zealand

Re: Counting T states in Excel

Post by djnzx48 » Tue May 21, 2019 10:22 am

OK, I just found some basic instructions here:
https://github.com/z88dk/z88dk/wiki/Tool---ticks

Edit: I just read that apparently ticks does not support contention. So it may not be the best choice for accurate measurements.
2 x

User avatar
arkannoyed
Manic Miner
Posts: 366
Joined: Mon Feb 05, 2018 9:56 am

Re: Counting T states in Excel

Post by arkannoyed » Tue May 21, 2019 10:28 am

Ah yes, good find, those might help
0 x

AndyC
Manic Miner
Posts: 251
Joined: Mon Nov 13, 2017 5:12 am

Re: Counting T states in Excel

Post by AndyC » Tue May 21, 2019 5:20 pm

Contention makes things harder on the Speccy because it isn't just about what instruction you are executing, but when you are executing it. The same instruction within a loop might not always take the same length of time. I can't say I've ever entirely got my head around the various descriptions of it.

Contrast this with say the Amstrad CPC where contention is universally applied and highly predictable, then it is really just a case of having a slightly different list of instruction timings to check against.
0 x

User avatar
RMartins
Manic Miner
Posts: 392
Joined: Thu Nov 16, 2017 3:26 pm

Re: Counting T states in Excel

Post by RMartins » Mon Jul 08, 2019 1:53 pm

The Zero emulator has an interesting trace feature (but it does make the emulator a bit slower), which allows you to track the instructions that are executing, while keeping a log of them.

This has proven useful to check timings of loop code, since you can check the T-State count, on start, during stepping and on exit.
1 x

Post Reply