Hi Bryan
Here's a simulation which should help. Breaking down the URL, we have:
Code:
http://www.visual6502.org/JSSim/expert.html?
graphics=f& # suppress the chip layout image
a=0& # place the following code at address 0000
d=a9c16912f8a9126934e933ea& # our test program
steps=28& # run for 28 steps (14 clock cycles)
logmore=idb,sb,alua,alub,alu,dasb,dpc18_~DAA,dpc22_~DSA,DPControl # trace these signals (and a pseudo-signal)
As you note, the decimal control signals DAA and DSA are only active in the single cycle after an add or subtract respectively. As they are active-low, they have a prefix of # or ~. We chose # at first, and then added ~ as an alias because of difficulty putting # in a URL.
These signals appear in the 'DPControl' collection. It's a bug that both of the aliases are listed.
The actual names of the signals is more obscure: there's a prefix. A good resource here is the nodenames.js which is loaded by the simulator:
http://www.visual6502.org/JSSim/nodenames.jswhere we see comments for many of the signals together with their full names:
Code:
"dpc18_#DAA": 1201, // decimal related (inverted)
"dpc18_~DAA": 1201, // automatic alias replacing hash with tilde
"dpc22_#DSA": 725, // decimal related/SBC only (inverted)
"dpc22_~DSA": 725, // automatic alias replacing hash with tilde
Note the 'dasb' is the decimally adjusted special bus:
Code:
// datapath signal: decimally adjusted special bus
dasb0: 54, // same node as sb0
dasb1: 1009,
dasb2: 450,
dasb3: 1475,
dasb4: 1405, // same node as sb4
dasb5: 263,
dasb6: 679,
dasb7: 1494,
Finally, then, we can look at the tabulation, which shows the values passing over the various busses and landing in the appropriate registers:
Code:
cycle ab db rw Fetch pc a x y s p idb sb alua alub alu dasb dpc18_~DAA dpc22_~DSA
0 0000 a9 1 LDA # 0000 aa 00 00 fd nv‑BdIZc 00 ff ff 00 00 ff 1 1
0 0000 a9 1 LDA # 0000 aa 00 00 fd nv‑BdIZc ff ff ff 00 ff ff 1 1
1 0001 c1 1 0001 aa 00 00 fd nv‑BdIZc ff ff ff ff ff ff 1 1
1 0001 c1 1 0001 aa 00 00 fd nv‑BdIZc ff ff ff ff fe ff 1 1
2 0002 69 1 ADC # 0002 c1 00 00 fd Nv‑BdIzc c1 c1 c1 c1 fe c1 1 1
2 0002 69 1 ADC # 0002 c1 00 00 fd Nv‑BdIzc 82 82 c1 c1 82 82 1 1
3 0003 12 1 0003 c1 00 00 fd Nv‑BdIzc 82 82 82 82 82 82 1 1
3 0003 12 1 0003 c1 00 00 fd Nv‑BdIzc ff ff 82 82 04 ff 1 1
4 0004 f8 1 SED 0004 c1 00 00 fd Nv‑BdIzc 12 c1 c1 12 04 c1 1 1
4 0004 f8 1 SED 0004 c1 00 00 fd Nv‑BdIzc d3 d3 c1 12 d3 d3 1 1
5 0005 a9 1 0005 d3 00 00 fd Nv‑BdIzc d3 d3 d3 d3 d3 d3 1 1
5 0005 a9 1 0005 d3 00 00 fd Nv‑BdIzc ff ff d3 d3 a6 ff 1 1
6 0005 a9 1 LDA # 0005 d3 00 00 fd Nv‑BDIzc ff ff ff ff a6 ff 1 1
6 0005 a9 1 LDA # 0005 d3 00 00 fd Nv‑BDIzc fe fe ff ff fe fe 1 1
7 0006 12 1 0006 d3 00 00 fd Nv‑BDIzc fe fe fe fe fe fe 1 1
7 0006 12 1 0006 d3 00 00 fd Nv‑BDIzc ff ff fe fe fc ff 1 1
8 0007 69 1 ADC # 0007 12 00 00 fd nv‑BDIzc 12 12 12 12 fc 12 1 1
8 0007 69 1 ADC # 0007 12 00 00 fd nv‑BDIzc 24 24 12 12 24 24 1 1
9 0008 34 1 0008 12 00 00 fd nv‑BDIzc 24 24 24 24 24 24 1 1
9 0008 34 1 0008 12 00 00 fd nv‑BDIzc ff ff 24 24 48 ff 1 1
10 0009 e9 1 SBC # 0009 12 00 00 fd nv‑BDIzc 34 12 12 34 48 12 0 1
10 0009 e9 1 SBC # 0009 12 00 00 fd nv‑BDIzc 46 46 12 34 46 46 0 1
11 000a 33 1 000a 46 00 00 fd nv‑BDIzc 46 46 46 46 46 46 1 1
11 000a 33 1 000a 46 00 00 fd nv‑BDIzc ff ff 46 46 8c ff 1 1
12 000b ea 1 NOP 000b 46 00 00 fd nv‑BDIzc 33 46 46 cc 8c 46 1 0
12 000b ea 1 NOP 000b 46 00 00 fd nv‑BDIzc 12 12 46 cc 12 12 1 0
13 000c 00 1 000c 12 00 00 fd nv‑BDIzC 12 12 12 12 12 12 1 1
13 000c 00 1 000c 12 00 00 fd nv‑BDIzC ff ff 12 12 24 ff 1 1
The test program:
Code:
Address Hexdump Dissassembly
-------------------------------
$0000 a9 c1 LDA #$c1
$0002 69 12 ADC #$12
$0004 f8 SED
$0005 a9 12 LDA #$12
$0007 69 34 ADC #$34
$0009 e9 33 SBC #$33
$000b ea NOP