Next: Commands, Previous: Response Structure, Up: Binary monitor [Contents][Index]

### 13.3 Example Exchange

1. Client connects to ip4://127.0.0.1:6502
2. Client sends a command to set a temporary checkpoint:
   `02 | 01 | 08 00 00 00 | ad de 34 12 | 12 | e2 fc | e3 fc | 01 | 01 | 04 | 01`
   `0x02`

     Begin command

   `0x01`

     API version 1

   `0x00000008`

     The command excluding the header is 8 bytes long.

   `0x1234dead`

     The request ID is 0x1234dead. The response will contain this ID.

   `0x12`

     See Checkpoint set (0x12).

   `0xfce2`

     The address range of the checkpoint starts at 0xfce2.

   `0xfce3`

     The address range of the checkpoint ends at 0xfce3.

   `0x01`

     The checkpoint will cause the emulator to stop.

   `0x01`

     The checkpoint is enabled.

   `0x04`

     The checkpoint will trigger on exec from 0xfce2 - 0xfce3.

   `0x01`

     The checkpoint is temporary.

3. The transmission of any command causes the emulator to stop, similar to the regular monitor. This causes the server to respond with a list of register values.
   `02 | 01 | 26 00 00 00 | 31 | 00 | ff ff ff ff | 09 00 [ 03 { 03 | cf e5 } 03 { 00 | 00 00 } ... ]`
   `0x02`

     Begin response

   `0x01`

     API Version 1

   `0x00000026`

     Response length is 38

   `0x31`

     See Register Response (0x31).

   `0x00`

     No error occurred

   `0xffffffff`

     This response was not directly triggered by a command from the client.

   `0x0009`

     The register array is 9 items long

   `PC:`
     `0x03`

       The register array item is 3 bytes long

     `0x03`

       The register is the PC (ID 3) Note: you should find the names to these IDs using the MON_CMD_REGISTERS_AVAILABLE command. See Registers available (0x83). Do not rely on them being consistent.

     `0xe5cf`

       The register value is 0xe5cf

   `A:`
     `0x03`

       The register array item is 3 bytes long

     `0x00`

       The register is A (ID 0) Note: you should find the names to these IDs using the MON_CMD_REGISTERS_AVAILABLE command. See Registers available (0x83). Do not rely on them being consistent.

     `0x0000`

       The register value is 0x0000

4. After the register information, the server sends a stopped event to indicate that the emulator is stopped.
   `02 | 01 | 02 00 00 00 | 62 | 00 | ff ff ff ff | cf e5`
   `0x02`

     Begin response

   `0x01`

     API Version 1

   `0x00000002`

     Response is two bytes long.

   `0x62`

     Response type is 0x62, MON_RESPONSE_STOPPED.

   `0xffffffff`

     This response was not directly triggered by a command from the client.

   `0xe5cf`

     The current program counter

5. The server processes the checkpoint set command, and sends a response to the client.
   `... | 11 | ... | 02 00 00 00 | 00 | e2 fc | e3 fc | 01 | 01 | 04 | 01 | 00 00 00 00 | 00 00 00 00 | 00`
   (Some response header fields are omitted (...) for brevity.)
   `0x11`

     See Checkpoint Response (0x11).

   `0x00000002`

     Checkpoint number is 2

   `0x00`

     Checkpoint was not hit (as it was just created)

   `0xfce2`

     Checkpoint start address

   `0xfce3`

     Checkpoint end address

   `0x01`

     The checkpoint will cause the emulator to stop.

   `0x01`

     The checkpoint is enabled.

   `0x04`

     The checkpoint will trigger on exec from 0xfce2 - 0xfce3.

   `0x01`

     The checkpoint is temporary.

   `0x00000000`

     The checkpoint has been hit zero times.

   `0x00000000`

     The checkpoint has been ignored zero times.

6. Client sends a command to continue:
   `... | aa`
   (Some command header fields are omitted (...) for brevity.)
   `0xaa`

     See Exit (0xaa).

7. Server acknowledges the command:
   `... | aa | ...`
   (Some response header fields are omitted (...) for brevity.)
   `0xaa`

     See Exit (0xaa).

8. Server resumes execution and sends a resume event:
   `... | 63 | ... | cf e5`
   (Some response header fields are omitted (...) for brevity.)
   `0x63`

     See Resumed Response (0x63).

   `0xe5cf`

     Program counter is currently at 0xe5cf

9. Some time later, the server hits the breakpoint. This causes it to emit a checkpoint response. This is identical to the previous checkpoint response, except that it is marked as "hit" and the hit and ignore counts are updated.
10. The server emits the register information and the stopped event when reentering the monitor, as seen previously.

Next: Commands, Previous: Response Structure, Up: Binary monitor [Contents][Index]