mirror of
https://github.com/specht/champ.git
synced 2025-08-08 07:25:03 +00:00
documentation for subroutine cycle watches
This commit is contained in:
41
README.md
41
README.md
@@ -63,7 +63,7 @@ You can watch registers or variables at certain program counter addresses by ins
|
|||||||
FOO EQU $8000
|
FOO EQU $8000
|
||||||
|
|
||||||
JSR TEST
|
JSR TEST
|
||||||
RTS
|
BRK
|
||||||
|
|
||||||
TEST LDA #64 ; load 64 into accumulator
|
TEST LDA #64 ; load 64 into accumulator
|
||||||
ASL ; multiply by two @Au
|
ASL ; multiply by two @Au
|
||||||
@@ -94,7 +94,7 @@ In addition to watching individual registers, you can also watch global variable
|
|||||||
FOO EQU $8000 ; @u16
|
FOO EQU $8000 ; @u16
|
||||||
|
|
||||||
JSR TEST
|
JSR TEST
|
||||||
RTS
|
BRK
|
||||||
|
|
||||||
TEST LDA #0
|
TEST LDA #0
|
||||||
STA FOO
|
STA FOO
|
||||||
@@ -114,10 +114,10 @@ Here's another example with some more interesting plots ([example03.yaml](exampl
|
|||||||
MX %11
|
MX %11
|
||||||
ORG $6000
|
ORG $6000
|
||||||
|
|
||||||
FOO EQU $8000
|
FOO EQU $8000 ; @u8
|
||||||
|
|
||||||
JSR TEST
|
JSR TEST
|
||||||
RTS
|
BRK
|
||||||
|
|
||||||
TEST LDX #$FF
|
TEST LDX #$FF
|
||||||
LDA #1
|
LDA #1
|
||||||
@@ -130,8 +130,9 @@ LOOP TAY
|
|||||||
TYA
|
TYA
|
||||||
CLC
|
CLC
|
||||||
ADC FOO ; @Au(post)
|
ADC FOO ; @Au(post)
|
||||||
DEX ; @Xu(post)
|
DEX ; @Xu(post) @Au,FOO(post)
|
||||||
BNE LOOP
|
BNE LOOP
|
||||||
|
RTS
|
||||||
```
|
```
|
||||||
|
|
||||||
This is a small program which lets the accumulator grow exponentially while X decreases linearly:
|
This is a small program which lets the accumulator grow exponentially while X decreases linearly:
|
||||||
@@ -151,6 +152,36 @@ This will plot FOO against X:
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
### Subroutine cycle watches
|
||||||
|
|
||||||
|
If you want to know the distribution of cycles spent in certain subroutines, use the `@cycles` directive to add a watch for this information:
|
||||||
|
|
||||||
|
```
|
||||||
|
DSK test
|
||||||
|
MX %11
|
||||||
|
ORG $6000
|
||||||
|
|
||||||
|
LDX #$20
|
||||||
|
JSR COUNT
|
||||||
|
LDX #$30
|
||||||
|
JSR COUNT
|
||||||
|
LDX #$40
|
||||||
|
JSR COUNT
|
||||||
|
|
||||||
|
BRK
|
||||||
|
|
||||||
|
COUNT DEX ; @Xu(post) @cycles
|
||||||
|
BNE COUNT
|
||||||
|
RTS
|
||||||
|
```
|
||||||
|
|
||||||
|
This programm calls the `COUNT` subroutine three times with different X arguments, and we get both X and the number of cycles spent in `COUNT`:
|
||||||
|
|
||||||
|

|
||||||
|

|
||||||
|
|
||||||
|
We see the three incantations of `COUNT` with `X` decreasing to 0 each time, and at the end of every loop, the amount of cycles spent in `COUNT`.
|
||||||
|
|
||||||
### Disabling watches
|
### Disabling watches
|
||||||
|
|
||||||
To disable a watch, add a `;` right behind the `@`:
|
To disable a watch, add a `;` right behind the `@`:
|
||||||
|
2
champ.rb
2
champ.rb
@@ -584,7 +584,7 @@ class Champ
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if @cycles_per_function.include?(watch[:pc])
|
if (!@watch_values.include?(index)) && @cycles_per_function.include?(watch[:pc])
|
||||||
max_cycle_count_for_function = @cycles_per_function[watch[:pc]].map do |x|
|
max_cycle_count_for_function = @cycles_per_function[watch[:pc]].map do |x|
|
||||||
x[:call_cycles]
|
x[:call_cycles]
|
||||||
end.max
|
end.max
|
||||||
|
BIN
doc/example04_1.gif
Normal file
BIN
doc/example04_1.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.7 KiB |
BIN
doc/example04_2.gif
Normal file
BIN
doc/example04_2.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
@@ -5,7 +5,7 @@
|
|||||||
FOO EQU $8000
|
FOO EQU $8000
|
||||||
|
|
||||||
JSR TEST
|
JSR TEST
|
||||||
RTS
|
BRK
|
||||||
|
|
||||||
TEST LDA #64 ; load 64 into accumulator
|
TEST LDA #64 ; load 64 into accumulator
|
||||||
ASL ; multiply by two @Au
|
ASL ; multiply by two @Au
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
FOO EQU $8000 ; @u16
|
FOO EQU $8000 ; @u16
|
||||||
|
|
||||||
JSR TEST
|
JSR TEST
|
||||||
RTS
|
BRK
|
||||||
|
|
||||||
TEST LDA #0
|
TEST LDA #0
|
||||||
STA FOO
|
STA FOO
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
FOO EQU $8000 ; @u8
|
FOO EQU $8000 ; @u8
|
||||||
|
|
||||||
JSR TEST
|
JSR TEST
|
||||||
RTS
|
BRK
|
||||||
|
|
||||||
TEST LDX #$FF
|
TEST LDX #$FF
|
||||||
LDA #1
|
LDA #1
|
||||||
@@ -20,3 +20,4 @@ LOOP TAY
|
|||||||
ADC FOO ; @Au(post)
|
ADC FOO ; @Au(post)
|
||||||
DEX ; @Xu(post) @Au,FOO(post)
|
DEX ; @Xu(post) @Au,FOO(post)
|
||||||
BNE LOOP
|
BNE LOOP
|
||||||
|
RTS
|
||||||
|
16
examples/example04.s
Normal file
16
examples/example04.s
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
DSK test
|
||||||
|
MX %11
|
||||||
|
ORG $6000
|
||||||
|
|
||||||
|
LDX #$20
|
||||||
|
JSR COUNT
|
||||||
|
LDX #$30
|
||||||
|
JSR COUNT
|
||||||
|
LDX #$40
|
||||||
|
JSR COUNT
|
||||||
|
|
||||||
|
BRK
|
||||||
|
|
||||||
|
COUNT DEX ; @Xu(post) @cycles
|
||||||
|
BNE COUNT
|
||||||
|
RTS
|
3
examples/example04.yaml
Normal file
3
examples/example04.yaml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
load:
|
||||||
|
0x6000: example04.s
|
||||||
|
entry: 0x6000
|
Reference in New Issue
Block a user