CPX m_ChannelDimValue:8; BNE testCh9; ORA #1; testCh9: CPX m_ChannelDimValue:9; BNE testCh10; ORA #2; testCh10: CPX m_ChannelDimValue:10; BNE testCh11; ORA #4;
778: CPX m_ChannelDimValue:8; 003f c30008 [4] CPX m_ChannelDimValue:8 779: BNE testCh9; 0042 2602 [3] BNE L46 ;abs = 0046 780: ORA #1; 0044 aa01 [2] ORA #1 0046 [5] L46: 781: testCh9: 782: CPX m_ChannelDimValue:9; 0046 c30009 [4] CPX m_ChannelDimValue:9 783: BNE testCh10; 0049 2602 [3] BNE L4D ;abs = 004d 784: ORA #2; 004b aa02 [2] ORA #2 004d [5] L4D: 785: testCh10: 786: CPX m_ChannelDimValue:10; 004d c3000a [4] CPX m_ChannelDimValue:10 787: BNE testCh11; 0050 2602 [3] BNE L54 ;abs = 0054 788: ORA #4; 0052 aa04 [2] ORA #4 0054 [5] L54:
解決済! 解決策の投稿を見る。
CPX m_ChannelDimValue:9
CompilerGuru wrote:
Hmm. not so sureCPX m_ChannelDimValue:9
is not indexed at all, it is extended (EXT).
LDX m_DimmerCount ; 3 CLRA ; 1 CPX m_ChannelDimValue:0 ; 4 BNE testCh1 ; 3 ORA #1 ; 2 testCh1: CPX m_ChannelDimValue:1 ; 4 BNE testCh2 ; 3 ORA #2 ; 2 testCh2: CPX m_ChannelDimValue:2 ; 4 BNE testCh3 ; 3 ORA #4 ; 2 testCh3: CPX m_ChannelDimValue:3 ; 4 BNE testCh4 ; 3 ORA #8 ; 2 testCh4: CPX m_ChannelDimValue:4 ; 4 BNE testCh5 ; 3 ORA #16 ; 2 testCh5: CPX m_ChannelDimValue:5 ; 4 BNE testCh6 ; 3 ORA #32 ; 2 testCh6: CPX m_ChannelDimValue:6 ; 4 BNE testCh7 ; 3 ORA #64 ; 2 testCh7: CPX m_ChannelDimValue:7 ; 4 BNE writePortA ; 3 ORA #128 ; 2 writePortA: STA _PTAD ; 3 ; ;-- ; =63 cycles + 2 cycles for each light that comes on
; ; Index through the table, checking each value. ; LDA m_DimmerCount ; 3 LDHX m_ChannelDimValue ; 3 ; CBEQ X+,on1 ; 4 do2: CBEQ X+,on2 ; 4 do3: CBEQ X+,on3 ; 4 do4: CBEQ X+,on4 ; 4 do5: CBEQ X+,on5 ; 4 do6: CBEQ X+,on6 ; 4 do7: CBEQ X+,on7 ; 4 do8: CBEQ X+,on8 ; 4 done: RTN ? ; ;-- ; =38 cycles + 7 cycles for each light that comes on ; ; Each one of these turns a light on. ; on1: BSET 0,_PTAD ; 4 BRA do2 ; 3 ; on2: BSET 1,_PTAD ; 4 BRA do3 ; 3 ; on3: BSET 2,_PTAD ; 4 BRA do4 ; 3 ; on4: BSET 3,_PTAD ; 4 BRA do5 ; 3 ; on5: BSET 4,_PTAD ; 4 BRA do6 ; 3 ; on6: BSET 5,_PTAD ; 4 BRA do7 ; 3 ; on7: BSET 6,_PTAD ; 4 BRA do8 ; 3 ; on8: BSET 7,_PTAD ; 4 BRA done ; 3
LDHX m_ChannelDimValue ; 3should be:
LDHX #m_ChannelDimValue ; 3We want to load the ADDRESS of "m_ChannelDimValue" into the H:X register (immediate addressing), and not the 16-bit value at "m_ChannelDimValue" (direct addressing). The cycle count was correct, as I knew what I wanted, but I neglected the number-sign, as I often do in real life.
CLR _PTAD ; 3That would add 3 cycles, making it 41 cycles per iteration when no triacs are triggered.
LDX m_DimmerCount; CLRA; CPX m_ChannelDimValue:0; BNE testCh1; ORA #1; testCh1: CPX m_ChannelDimValue:1; BNE testCh2; ORA #2; testCh2: CPX m_ChannelDimValue:2; BNE testCh3; ORA #4; testCh3: CPX m_ChannelDimValue:3; BNE testCh4; ORA #8; testCh4: CPX m_ChannelDimValue:4; BNE testCh5; ORA #16; testCh5: CPX m_ChannelDimValue:5; BNE testCh6; ORA #32; testCh6: CPX m_ChannelDimValue:6; BNE testCh7; ORA #64; testCh7: CPX m_ChannelDimValue:7; BNE writePortA; ORA #128; writePortA: STA _PTAD;