



















                                     MON11

                                       A
                             Software Debug Monitor

                                 For the 68HC11










                          Dunfield Development Systems
                          ----------------------------
                             High quality tools for
                              Embedded Development
                                 at low prices.

                            http://www.dunfield.com


                       ?COPY.TXT 1991-2007 Dave Dunfield
                              **See COPY.TXT**



                                     MON11

                               TABLE OF CONTENTS


                                                                         Page

     1. INTRODUCTION                                                        1


     2. USING MON11                                                         2

        2.1 Operand format                                                  2
        2.2 Monitor Commands                                                2
        2.3 Display Output                                                  6
        2.4 Breakpoints                                                     6
        2.5 Interrupts                                                      7

     3. MON11 INTERNALS                                                     8

        3.1 Reserved Memory Locations                                       8
        3.2 I/O Configuration Control Byte                                  8
    MON11                                                            Page: 1


    1. INTRODUCTION

          MON11 is an interactive software  debugger  and  machine  language
       monitor  for  the  motorola  68HC11   microprocessor.   It   contains
       display/alter memory/register facilities,  as well as a  full  68HC11
       disassembler, breakpoint, and software single step functions.

          MON11  requires  no  hardware  assist,  all  functions   including
       single-step are implemented in the MON11 firmware. MON11 communicates
       with the user  via  the  internal  SCI  serial  port  of  the  68HC11
       microcontroller,  although the  RDCHR  and  WRCHR  subroutines  could
       easily be modified to support communications through an external UART
       device.

          MON11 requires 128 bytes of read/write memory,  for  stack,  local
       variables,  buffers etc,  and about 5100 bytes of ROM memory for  the
       program.  If MON11 is placed in an 8K (2764 or compatable) rom,  this
       will leave over 2k of space for the user I/O routines.  The MON11 rom
       must be at the top of the 68HC11 memory map, as it has to control the
       68HC11 interrupt vectors.

          MON11 preserves the entire content of registers  and  user  memory
       when passing control back and forth to the user program.  This allows
       the user program to  operate  as  if  it  were  running  "standalone"
       without fear of conflicting with MON11.
    MON11                                                            Page: 2


    2. USING MON11

       2.1 Operand format

        Anywhere that MON11 expects an 8 bit value, you may use:

            Two HEX digits                              Eg: 1F
            A QUOTE followed by an ASCII character      Eg: 'a

        Anywhere that MON11 expects a 16 bit value, you may use:

            Four HEX digits                             Eg: 09AB
            ASCII characters preceeded by quotes        Eg: 'a'b
            X, Y, P, or S for current CPU register      Eg: X

       2.2 Monitor Commands

             The following commands are implemented in the monitor.

               B <breakpoint#> <address>

                  Set breakpoint at specified address. Breakpoint is removed
                  if address is 0000.  There can be up to eight breakpoints,
                  which are referenced by the numbers 0 to 7.

               CR <register> <value>

                  Changes 68HC11 registers  values.  Register  is  a  single
                  character, which may be as follows:

                  A   - Set A accumulator (8 bit value).
                  B   - Set B accumulator (8 bit value).
                  C   - Set condition code register (8 bit value).
                  D   - Set D (A:B) accumlator (16 bit value)
                  X   - Set X register (16 bit value).
                  Y   - Set Y register (16 bit value).
                  S   - Set system stack pointer (16 bit value).
                  P   - Set program counter (16 bit value).
    MON11                                                            Page: 3


               CV <vector> <address>

                     Changes the interrupt  vector  handler  addresses.  The
                  vectors are as follows:

                  00 - SCI
                  01 - SPI
                  02 - Pulse ACC Input
                  03 - Pulse ACC overflow
                  04 - Timer overflow
                  05 - Timer IC4/OC5
                  06 - Timer output compare 4
                  06 - Timer output compare 3
                  08 - Timer output compare 2
                  09 - Timer output compare 1
                  0A - Timer input compare 3
                  0B - Timer input compare 2
                  0C - Timer input compare 1
                  0D - Real-Time
                  0E - IRQ
                  0F - XIRQ
                  10 - SWI
                  11 - Illegal opcode

               DB

                  Displays the current breakpoint settings.

               DI <start>,<end>

                  Disassembles memory,  starting at  indicated  address.  If
                  SPACE  is  entered  for  <end>  address,   assumes   FFFF.
                  Disassembler output contains address, opcodes bytes, ASCII
                  equivalent of  opcode  bytes,  instruction  neumonic,  and
                  operands to instruction.

               DM <start>,<end>

                  Displays memory, in HEX/ASCII dump format, starting at the
                  indicated  address.  If  a  SPACE  is  entered  for  <end>
                  address, assumes FFFF.

               DR

                  Displays the values of the 68HC11 registers.

               DV

                  Display the current interrupt vector address assignments.
    MON11                                                            Page: 4


               E <address>

                  Edit's memory,  Address and contents are displayed,  Enter
                  two hex digits to change value, or a single quote followed
                  by a character. Entering SPACE skips to the next location,
                  BACKSPACE  backups  to  the  previous  location.  CARRIAGE
                  RETURN terminates the edit command.

               FM <start>,<end> <value>

                  Fill's memory from <start> to <end> with the byte <value>.

               G <address>

                  Begins execution at the indicated address.  If a SPACE  is
                  entered instead of an address,  begins  execution  at  the
                  address in the saved 68HC11 program counter.

               L

                  Downloads data from the console  port,  which  may  be  in
                  either MOTOROLA or INTEL hex format.

                  If you accidently enter this command, you may enter either
                  'S9'  or ':00'  to signify a null download file and return
                  to the command prompt.

               MM <start>,<end> <destination>

                  Move's memory  from  <start>  to  <end>,  placeing  it  at
                  <destination>.

               MT <start>,<end>

                  Performs a memory test on memory from  <start>  to  <end>.
                  Pass number is displayed,  First two digits indicate total
                  number completed tests,  last two digits indicate  current
                  pass  (value)  within the  test.  Each  value  is  written
                  sequentially to memory,  insuring that previous  data  has
                  not changed before the new value is written.  To exit  the
                  test, press the escape key.

               RR <address>

                  This command loops,  performing a read  of  the  specified
                  address until it is terminated by the escape key.

               RW <address> <value>

                  This  command  loops,  writing  the  given  value  to  the
                  specified address until it is  terminated  by  the  escape
                  key.
    MON11                                                            Page: 5


               S <address>

                  Begins single-stepping at  the  indicated  address.  If  a
                  SPACE is entered for  the  address,  then  single-stepping
                  begins at the address in the saved 68HC11 program counter.
                  Disassembled instruction is displayed on the terminal, and
                  MON11 waits for a  key  to  be  pressed.  If  a  SPACE  is
                  entered,  steps to the next instruction.  CARRIAGE  RETURN
                  toggles the automatic display of registers.  '?'  displays
                  the register values, and escape terminates the single-step
                  command.

               W <address> <value>

                  Performs  a  single  write  of  the  given  value  to  the
                  specified address in memory.

               + <value>+<value>

                  Performs 16 bit addition of the values,  and displays  the
                  result.

               - <value>-<Value>

                  Performs 16 bit subtraction of the  values,  and  displays
                  the result.

               ?

                  Displays a short help summary of the commands.
    MON11                                                            Page: 6


       2.3 Display Output

             In order to maintain the maximum amount of data on the terminal
          screen during the debugging session,  MON11 has been  designed  to
          minimize the number of screen lines in any display.  All  commands
          which output only one line of data (such as 'DB' 'DR'), will do so
          on the same line on which the command is issued  (To the right  of
          the command).

             For commands which output larger amounts of data (such as 'DI',
          'DM'),  pressing the SPACE key during the display  will  halt  the
          display on the next line. Each subsequent SPACE entered will cause
          one more line of data be displayed.  Pressing CARRIAGE RETURN will
          allow the display to continue at full speed.

             The escape key may be used to cancel command output, and return
          to the '*' prompt.

       2.4 Breakpoints

             MON11 allows breakpoints to be  placed  in  the  program  under
          test, which when encountered during the execution of that program,
          cause the program to interrupt, and MON11 is entered. Up to 8 such
          breakpoints (numbered from 0 to 7) may be placed in the program at
          any one time.

             When entered from a breakpoint,  MON11  will  first  display  a
          message  indicating  the  number  of  the  breakpoint  which   was
          encountered,  followed by the  processor  registers,  after  which
          MON11 enters command mode.

             Once MON11 has been entered from a breakpoint, the registers of
          the program under test are saved.  Note that the  address  of  the
          breakpoint is in the saved 68HC11 program counter,  and  therefore
          using a SPACE as the operand to a 'G'  or  'S'  command will allow
          execution or single stepping to continue from the breakpoint.

             Breakpoints are entirely transparent,  and will remain  in  the
          program until explicitly removed.
    MON11                                                            Page: 7


       2.5 Interrupts

             MON11 re-vectors all interrupts though a vector table which may
          be written by the user program.  When an interrupt  occurs,  MON11
          will transfer  control  to  the  corresponding  address  from  the
          interrupt vector table (See 'CV' and 'DV' commands).

             If MON11 finds that the vector table  entry  for  an  interrupt
          that it is servicing is  set  to  zero  (uninitialized),  it  will
          perform processing similar to a breakpoint,  issuing  the  message
          "Unexpected interrupt:",  followed by the  interrupt  name,  after
          which it will re-enter command mode.

             Execution following such an interrupt can be resumed by using a
          SPACE as the operand to the 'G'  or 'S'  commands,  exactly as you
          would after a breakpoint.  NOTE that if  the  interrupt  was  "BAD
          OPCODE",  MON11 will not allow 'G'  or 'S'  at that address unless
          you replace the invalid opcode with a valid one.

             A useful debugging aid is to connect a debounced push button to
          the XIRQ interrupt line,  allowing you to re-gain MON11 control at
          any time simply by pressing the button.
    MON11                                                            Page: 8


    3. MON11 INTERNALS

       3.1 Reserved Memory Locations

             The following locations are located in the 128 bytes of  memory
          which are reserved for MON11:

    Offset|Size|  Name  |                   Description
    ------+----+--------+------------------------------------------------
     0000 | 36 | INTVEC | Vectors for the first 18 68HC11 interrupts.
    ------+----+--------+------------------------------------------------
     0024 | 01 | IOCTL  | MON11 I/O control byte 
    ------+----+--------+------------------------------------------------
     0025 | 01 | SAVCC  | MON11's saved Condition Code register.
    ------+----+--------+------------------------------------------------
     0026 | 01 |  SAVA  | MON11's saved A Accumulator register.
    ------+----+--------+------------------------------------------------
     0027 | 01 |  SAVB  | MON11's saved B Accumulator register.
    ------+----+--------+------------------------------------------------
     0028 | 02 |  SAVX  | MON11's saved X Index register.
    ------+----+--------+------------------------------------------------
     002A | 02 |  SAVY  | MON11's saved Y Index register.
    ------+----+--------+------------------------------------------------
     002C | 02 | SAVPC  | MON11's saved System Stack Pointer.
    ------+----+--------+------------------------------------------------
     002E | 02 | SAVSP  | MON11's saved Program Counter.

       3.2 I/O Configuration Control Byte

             MON11 maintains a control  byte,  which  controls  the  console
          serial port. The definition of bits in this byte is as follows:

         Bit#    7   - Indicates that output is inhibited.
                 6   - Indicates that output is paused (via space)
                 5   - Indicates that regs are NOT dumped during single-step
               4-0   - Unused
