[Menu]>[Guide to use the PIC]


How to debug


The debugging is to confirm that the made software works. The work which removes blight is debugging.

To debug, there are some ways. Here, the way of executing 1 step and the way by the breakpoint(It stops processing temporarily) are explained.
I use the program which was shown by the previous example for the explanation.

Debugging by the step operation

The step debugging is the way which is convenient to confirm the operation of the software with small scale or the operation of the specific processing part.
is the step execution button. When the step button isn't displayed in the tool bar, click (Swap Toolbar).
The step debugging can make execute with Debug > Run > Step , too.

The preparation
    It had better display a listing file and a file register beforehand in the window.
    Window > Absolute Listing : The listing file display

    Window > File Registers : The file register display


The execution of the debugging

(1) The reset operation
    is a reset button. It is displayed with "Reset Processor" in the status in the lower left. When the step button isn't displayed in the tool bar, click (Swap Toolbar).
    With this operation, the simulator becomes a condition immediately after the turning on as the condition of PIC.
    The reset operation can make execute with Debug > Run > Reset , too.
    A dark bar is displayed at 0 of the program address on the listing file. In the explanation after that, I call this dark bar as "PC bar ". This bar shows the position of program counter (PC).

    Next, let's attempt to confirm the contents of the file register. 03h become 18. This addess is STATUS register. TO and PD become "1". This shows a condition immediately after the turning on.


(2) The 1 step execution
    Click the step button .
    The PC bar moves to address 1.
    The file register changes as follows.

    02h(PC)00>01The program counter changed to address 1.
    03h (STATUS)
    18>1C
    After executing CLEF, the Z flag became "1".


(3) The 1 step execution
    Click the step button .
    The PC bar moves to address 2.
    The file register changes as follows.

    02h(PC)01>02The program counter changed to address 2.
    03h(STATUS)
    1C>18
    Because the result which executed INCF was not 0, the Z flag became "0".
    0Ch

    00>01
    A target counter was counted-up.


(4) The 1 step execution
    Click the step button .
    The PC bar moves to address 1.
    The file register changes as follows.

    02h(PC)02>01After executing GOTO, the PC became 01h.


(5) The 1 step execution
    Click the step button .
    The PC bar moves to address 2.
    The file register changes as follows.

    02h(PC)01>02The program counter changed to address 2.
    0Ch

    01>02
    A target counter was counted-up.


When clicking the step button, the PC bar change address 1 and address 2 alternately.
Every time the instruction of 1 address is executed, 0Ch of the file register is updated.

As above mentioned, the operation every step can be confirmed.



Debugging by the breakpoint

This is a way of debugging by by confirming the data when stopping at the breakpoint.
Because it is possible to process at a stroke to the breakpoint, it is possible to debug efficiently.
Before executing the instruction which a breakpoint was set to, processing is stopped temporarily.

The way of setting a breakpoint
    ( Setting 1 )
    Click the step which sets a breakpoint on the listing file.
Press the right mouse button.
Click the "Break Point(s)" at the menu
The line which a breakpoint was set to changes to the red.
The breakpoint can be set to more than one line.


    ( Setting 2 )
    This is the way of making a label a breakpoint.
    A breakpoint setting dialog is displayed when pressing .
    This setting can make execute with Debug > Break Settings... , too.
    Choose the label to want to set a breakpoint by the Start item of the setting dialog.
    When clicking the "Add" button, a breakpoint is added. If a checking mark is displayed, the breakpoint is effective.


The preparation
    It had better display a listing file and a file register beforehand in the window.
    Window > Absolute Listing : The listing file display
    Window > File Registers : The file register display

The execution of the debugging

(1) The reset operation
    Click the reset button and it makes a simulator a condition immediately after the turning on as the condition of PIC.
    The PC bar is in the place of address 0.
    The file register changes as follows.

      02h (PC)00
      03h(STATUS)
      18


(2) The setting of a breakpoint
    Set a breakpoint to address 2 (GOTO) of the program.
    Set by setting 1. The line changes to the red when a breakpoint is set.

(3) The processing execution
    Click the run button . It is possible to start the processing execution in Debug > Run > Run .
    The PC bar moves to address 2.
    The file register changes as follows.

      02h(PC)00>02The program counter changed to address 2.
      0Ch

      00>01
      A target counter was counted-up.


(4) The processing execution
    Click the run button .
    The PC bar is as address 2.
    The file register changes as follows.

      0Ch

      01>02
      A target counter was counted-up.

When clicking the run button, the contents of file register 0Ch is updated.

(5) Debugging ending
    is a stop button(.Halt the processor).
    It is possible to stop the processing execution in Debug > Run > Halt .

    In the condition which stops at the breakpoint, the debugging operation continues. When ending debugging, it is necessary to make stop at the stop button.