[comp.sys.m6809] Single Stepping a 6809

has@ukc.ac.uk (H.A.Shaw) (03/25/90)

I am developing a micro-computer for teaching technician grade students at a
Technicial College here in Canterbury.  At the moment they use a single board
6502 based system with HEX keypad, 7-segment displays, cassette port, 2K RAM
and 4K Monitor ROM.  They hand assemble 6502 code to control various addons
that are available for the board, such as A/D and D/A boards, stepping motors,
strain gauges, a 5-axis robot arm, and even a set of traffic lights.
The micor-computer costs around 300 pounds each to buy, which is far to much
for what they provide.
I have designed and have a prototype replacement computer based on a 6809 with
8K RAM and 8K ROM, RS232 and lots of digital I/O lines.

That was the background, now the problem...
The 6502 system can single step through a program.  If a switch is thrown then
the registers are displayed after each instruction is performed, and a key must
be pressed to get the next instruction to be performed.  On a 6502 this magic
can be done by controlling the interrupt line from the SYNC output and writting
the right interrupt code.  How is this done on a 6809?  I assume that the BA
and BS outputs are used in some way, together with an interrupt input.  I have
been involved with 6809s for about 6 years now, but have never bothered with
the BA and BS outputs before.  Could someone please mail me with any answer
they might have since I do not often read this newsgroup (maybe I should).

	Ta very much,


Email: has@ukc.ac.uk                         | Howard Allan Shaw.
Phone: +44 227 764000 Extn: 3834             | Room 111A, Physics Laboratory,
                                             | The University,
                                             | Canterbury, England.  CT2 7NR

koonce@brahms.berkeley.edu (tim koonce) (03/28/90)

In article <4267@harrier.ukc.ac.uk> has@ukc.ac.uk (H.A.Shaw) asks about
single-stepping a 6809 processor.

   I'm not a hardware type, but I see two possible approaches.  One is
to have an interrupt fire after the first clock cycle of the instruction.
The interrupt will be serviced as soon as the instruction is finished,
providing an effective single-step.
   Another more software-oriented approach is to determine the
instruction length, and set a breakpoint (SWI) after the instruction.
The only special cases are branch and jump instructions, returns,
interrupt instructions (i.e. SWI, RTI), and exchanges involving the
PC.  The flow-of control instructions can be handled by setting two
breakpoints, one after the instruction, and one at the branch target.
When the single-step key is pressed, just set the breakpoints,
execute, and remove the breakpoints.  This is simplified by the fact
that you don't need a full disassembly of the current instruction, you
just need the instruction length, and whether it's in one of the
special cases above.  Assuming that you can handle breakpoints, this
provides a way to extend that to get single-step ability.  The obvious
disadvantage is that you can't single-step through ROM this way.

					 - Tim Koonce

ww0n+@andrew.cmu.edu (Walter Lloyd Wimer III) (03/28/90)

Excerpts from netnews.comp.os.os9: 27-Mar-90 Re: Single Stepping a 6809
Philip Brown@headcrash.B (439)


> What you do is get a hold of Tandy's Edtasm+, and take a look at their ZBUG
> code (Using ZBUG, incidentally!).  ZBUG porvides the userthe ability to
> single-step through any ML routine, using the "," command directive
>    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 

>            Philip Brown       pbrown@ocf.berkeley.edu
> "I'm living on borrowed RAM"  - Jon Aldrich
>         ***********************************************


ZBUG accomplishes single stepping by replacing the next instruction with
an SWI instruction (breakpoint) right before continuing execution.  This
might fill the bill or it might not.  Obviously you can't use this
mechanism to single-step through ROM routines.  The hardware approach is
certainly the ultimate in control and flexibility.  (If I knew the
details on how to get hardware single-stepping to work, I'd gladly post
them; I could probably figure it out given the Motorola docs and enough
time, but. . . .  Hmmm, since you're supposed to be guaranteed execution
of one instruction before an interrupt vector is taken, perhaps just
tying, say, the NMI line to E would work. . .  Then just execute an RTI
each time you want to single step to the next instruction.  There might
be problems with trying to single-step through regular IRQ
interrupt-handlers, though. . . )

ZBUG is a pretty decent debug monitor, though, by the way.


Good luck,

Walt Wimer