cycle counts in AppleWin [message #387026] |
Fri, 13 September 2019 22:05 |
Vince Weaver
Messages: 136 Registered: April 2013
Karma: 0
|
Senior Member |
|
|
Is it possible to get cycle counts in the AppleWin debugger?
Not the profiling info, but ideally an incrementing count
as you step through the program?
I'm tracking a weird problem where if I call a function most of
the time it takes 64 cycles but occasionally it's 65 and I can't
figure out why (it's not crossing a page boundary anywhere that I can
see).
The help makes it sound like "TL" might do something relevant but
it doesn't seem to when I try to use it.
Vince
|
|
|
|
Re: cycle counts in AppleWin [message #387033 is a reply to message #387026] |
Sat, 14 September 2019 03:23 |
TomCh
Messages: 242 Registered: November 2012
Karma: 0
|
Senior Member |
|
|
On Saturday, 14 September 2019 03:05:13 UTC+1, vi...@pianoman.cluster.toy wrote:
> Is it possible to get cycle counts in the AppleWin debugger?
>
> Not the profiling info, but ideally an incrementing count
> as you step through the program?
>
No, there's currently no visible cycle count as you step.
You can trace to a file using TF with the 'v' option to get video scanner info:
tf "file.txt" v
eg:
Vert Horz Addr Data A: X: Y: SP: Flags Addr:Opcode Mnemonic
0001 001A 0400 FF 08 FF 08 01F8 ..RB.I.C C10F:48 PHA
0001 001D 0403 00 08 FF 08 01F7 ..RB.I.C C110:20 24 CB JSR $CB24
0001 0023 0409 FF 08 FF 08 01F5 ..RB.I.C CB24:AD 1C C0 LDA $C01C
0001 0027 040D FF 0D FF 08 01F5 ..RB.I.C CB27:0A ASL
Then you'd have to diff the Horz value to get the cycle count.
But this is a pretty poor solution for getting opcode cycle counts!
tip: use CD command to display & set the current directory for the output trace file.
re. TL
Currently (from a quick code inspection) TL is the same the T command, where 'T <n>' just steps 'n' times. There looks to be some intent to do something with cycles but it doesn't appear to be implemented.
Tom
|
|
|
Re: cycle counts in AppleWin [message #387044 is a reply to message #387026] |
Sat, 14 September 2019 18:49 |
|
Originally posted by: James Davis
On Friday, September 13, 2019 at 7:05:13 PM UTC-7, vi...@pianoman.cluster.toy wrote:
> Is it possible to get cycle counts in the AppleWin debugger?
>
> Not the profiling info, but ideally an incrementing count
> as you step through the program?
>
> I'm tracking a weird problem where if I call a function most of
> the time it takes 64 cycles but occasionally it's 65 and I can't
> figure out why (it's not crossing a page boundary anywhere that I can
> see).
>
> The help makes it sound like "TL" might do something relevant but
> it doesn't seem to when I try to use it.
>
> Vince
You might just have to do it the hard way, manually, by looking up the opcodes in "Zaks' 'Programming the 6502'," or on the opcode chart (e.g., hex (hi/low-nibble) <-/-> opcode -> additional data about it).
|
|
|
Re: cycle counts in AppleWin [message #387046 is a reply to message #387026] |
Sat, 14 September 2019 22:46 |
Michael J. Mahon
Messages: 1767 Registered: October 2012
Karma: 0
|
Senior Member |
|
|
<vince@pianoman.cluster.toy> wrote:
> Is it possible to get cycle counts in the AppleWin debugger?
>
> Not the profiling info, but ideally an incrementing count
> as you step through the program?
>
> I'm tracking a weird problem where if I call a function most of
> the time it takes 64 cycles but occasionally it's 65 and I can't
> figure out why (it's not crossing a page boundary anywhere that I can
> see).
>
> The help makes it sound like "TL" might do something relevant but
> it doesn't seem to when I try to use it.
>
> Vince
>
Don’t forget that indexing across a page boundary can add a cycle, too.
--
-michael - NadaNet 3.1 and AppleCrate II: http://michaeljmahon.com
|
|
|
Re: cycle counts in AppleWin [message #387053 is a reply to message #387026] |
Sun, 15 September 2019 10:52 |
|
Originally posted by: fadden
If you want more eyes on your code, may I suggest:
(1) Open the binary file with SourceGen.
(2) Turn on display of cycle counts.
(3) Select the relevant lines, hit Ctrl+C to copy them, and paste them here..
SourceGen's cycle count annotator tracks the status flags, so it knows if e..g. branches are branch-never, branch-always, or branch-maybe. It's based on object code so it can see when branches cross page boundaries. Barring errors on my part, all knowable adjustments will be made correctly, and all unknowables will be indicated with a '+' next to the cycle count. (In the app, clicking on an instruction shows a list of cycle count modifiers in the Info window.)
(I wrote a regression test for it last night, so it's on my mind. :-) )
10f2: 80 14 bra L1108 ;4
10f4: 00 00 00 00+ .fill 20,$00
1108: 80 00 L1108 bra L110A ;3
110a: a9 00 L110A lda #$00 ;2
110c: f0 02 beq L1110 ;3
110e: 00 .dd1 $00
110f: 00 .dd1 $00
1110: d0 fe L1110 bne L1110 ;2
1112: ad 34 12 lda $1234 ;4
1115: f0 02 beq L1119 ;2+
[...]
All cycle counts are based on information from Eyes & Lichty, which comes from the CPU data sheets. I don't know if there's errata that needs to be applied.
The trouble with pasting stuff in Usenet groups is that modern viewers get all proportionally fonted and make the code hard to read unless you copy it somewhere else.
|
|
|
cycle counts in AppleWin [message #387056 is a reply to message #387026] |
Sun, 15 September 2019 15:15 |
Michael AppleWin Debu
Messages: 1262 Registered: March 2013
Karma: 0
|
Senior Member |
|
|
Hi Vince
> Is it possible to get cycle counts in the AppleWin debugger?
Yes with the PROFILE command.
i.e.
PROFILE RESET
PROFILE LIST
PROFILE SAVE
"PROFILE RESET" will clear the counter. You can manually step though code with "P" or "T", and then you can dump the current cycle count with "PROFILE LIST" (as many times as you want.)
e.g.
profile reset
p
p
profile list
NOTE: There is a bug with "P" that it may not return to the caller if too many instructions are executed.
> Not the profiling info, but ideally an incrementing count
> as you step through the program?
The last line of "profile list" will show the elapsed total cycles (since the last profile reset).
Will this do the trick or do you need something else?
> I'm tracking a weird problem where if I call a function most of
> the time it takes 64 cycles but occasionally it's 65 and I can't
> figure out why (it's not crossing a page boundary anywhere that I can
> see).
In AppleWin's source code look for where uExtraCycles is changed.
i.e. These files:
* https://github.com/AppleWin/AppleWin/blob/master/source/CPU/ cpu6502.h
* https://github.com/AppleWin/AppleWin/blob/master/source/CPU/ cpu_general.inl
> The help makes it sound like "TL" might do something relevant but
> it doesn't seem to when I try to use it.
Sorry that the built-in help is still garbage for this command. :-/
Michael
|
|
|
|