ANNOUNCE: C'mon, the Compact MONitor

Programming the 6502 microprocessor and its relatives in assembly and other languages.
User avatar
dclxvi
Posts: 362
Joined: 11 Mar 2004

Re: ANNOUNCE: C'mon, the Compact MONitor

Post by dclxvi »

The single step command has a bug (in the last version of C'mon that was released). There should be a CLD at STBR. If PREG bit 3 is set (i.e. the simulated instruction is executed with the D flag set) and the branch is taken, then the branch destination address is calculated using decimal arithmetic instead of binary arithmetic. Example:

Code: Select all

300@F8,18,90,9,
30D@38,
313@D8,
300$$$$
The F8 (SED) puts us in decimal mode. 18 is CLC and 90 is BCC, so the branch is taken and the destination address is calculated using decimal arithmetic: $304+$09. (Note that this is a perfectly valid BCD addition.) So it incorrecly branches to $313 instead of $30D.

Incidentally, the "old monitor" ROM in the original Apple II has this very same bug in the S (Step) command. There should be a CLD inserted at BRANCH (at $FAFD).
User avatar
BigEd
Posts: 11463
Joined: 11 Dec 2008
Location: England
Contact:

Re: ANNOUNCE: C'mon, the Compact MONitor

Post by BigEd »

That's wonderful! A fix to a really old bug, and a warning about self-emulating on processors with modes.
Post Reply