Commands of uCsim to manage breakpoints

Two kind of breakpoints can be used: fetch and event breakpoint. Fetch breakpoints are classical breakpoints. They can be placed at any instruction in the code memory. Breakpoint will be hit if CPU fetches instruction code from the memory location specified by the breakpoint. Only fetching of first byte of the instruction hits the breakpoint. If the execution reaches a breakpoint it stops before the instruction at location specified by the breakpoint would be executed.

Event breakpoints are special onces. They cause stop of execution if event specified by the breakpoint occures. Events are:

wi
writing into internal RAM at specified location;
ri
reading from internal RAM at specified address;
wx
writing into external RAM at specified location (MOVX instruction);
rx
reading from external RAM at specified address (MOVX instruction);
ws
writing into SFR area at specified location;
rs
reading from SFR area at specified address;
rc
reading from code memory at specified location (MOVC instruction).
Event breakpoint stops execution after specified event occured.

Every breakpoint can be fix (permanent) or dynamic (temporary). Dynamic breakpoints are automatically removed when they reached. Some commands place dynamic fetch breakpoints into the code, for example go or next.

A hit number can be associated to any breakpoint. This hit number specifies how many times the breakpoint must be hit before it causes the execution to stop. This hit number is 1 by default.

break addr [hit]

tbreak addr [hit]

Set fetch breakpoint. The command specifies if the breakpoint will be fix (break) or dynamic (temporary) (tbreak). First parameter specifies address where the breakpoint must be placed to. It should be address of an instruction.

Second parameter is optional and it specifies the hit number. It is 1 by default.

$ s51 remoansi.hex
ucsim 0.2.24, Copyright (C) 1997 Daniel Drotos, Talker Bt.
ucsim comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
58659 bytes read from remoansi.hex
> dc 0 0x10
   000000 02 01 60 LJMP  0160
 * 000003 02 00 3c LJMP  003c
 * 000006 ff       MOV   R7,A
 * 000007 ff       MOV   R7,A
 * 000008 ff       MOV   R7,A
 * 000009 ff       MOV   R7,A
 * 00000a ff       MOV   R7,A
 * 00000b 02 3b e0 LJMP  3be0
 * 00000e ff       MOV   R7,A
 * 00000f ff       MOV   R7,A
 * 000010 ff       MOV   R7,A
> break 0x160
Breakpoint 1 at 0x000160: CLR   P1.0
> tbreak 8 2
Breakpoint 2 at 0x000008: MOV   R7,A
> g
Simulation started, PC=0x000000
Stop at 000160: (4) Breakpoint
F 000160
> 

bse wi|ri|wx|rx|ws|rs|rc f|d addr [hit]

Set event breakpoint. First parameter specifies type of event. See general description of event breakpoints above about meaning of event identifiers. Second parameter specify if the breakpoint will be fix (f) or dynamic (d). Third parameter specifies address. Remember that this is not an instruction address, it is address of the memory cell where specified event should occur.

Forth parameter is optional and it specifies the hit number. It is 1 by default.

$ s51 remoansi.hex
ucsim 0.2.12, Copyright (C) 1997 Daniel Drotos, Talker Bt.
ucsim comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
58659 bytes read from remoansi.hex
> dis
   00d47e 22       RET
   000000 02 01 60 LJMP  0160
   000160 c2 90    CLR   P1.0
   000162 c2 97    CLR   P1.7
   000164 d2 b5    SETB  P3.5
   000166 d2 b4    SETB  P3.4
   000168 75 81 22 MOV   SP,#22
   00016b 75 d0 00 MOV   PSW,#00
   00016e 7e 00    MOV   R6,#00
   000170 7f 00    MOV   R7,#00
   000172 79 04    MOV   R1,#04
   000174 12 0d b8 LCALL 0db8
   000177 0f       INC   R7
   000178 d9 fa    DJNZ  R1,0174
   00017a 75 0b 00 MOV   0b,#00
   00017d 75 0c 00 MOV   0c,#00
   000180 02 02 2a LJMP  022a
   000183 78 22    MOV   R0,#22
   000185 76 00    MOV   @R0,#00
   000187 d8 fc    DJNZ  R0,0185
> bse wi f 6
> g
4
   000170 7f 00    MOV   R7,#00
> 

clear [addr...]

Delete fetch breakpoint. Parameter specifies address of breakpoint. If there is no breakpoint specified at given address this command prints out a warning message.

If parameter is not given then breakpoint at current PC will be deleted if it exists. If more than one address is specified then all breakpoints at specified addresses will be deleted.

> i b
Num Type       Disp Hit   Cnt   Address  What
1   fetch      keep 1     1     0x000160 CLR   P1.0
2   fetch      del  1     1     0x000180 LJMP  022a
1   event      keep 1     1     0x000006 wi
> clear 160
No breakpoint at 0000a0
> clear 0x160
> i b
Num Type       Disp Hit   Cnt   Address  What
2   fetch      del  1     1     0x000180 LJMP  022a
1   event      keep 1     1     0x000006 wi
> 

bde wi|ri|wx|rx|ws|rs|rc addr

Delete event breakpoint. First parameter must be given to specify type of event. Second parameter is address of memory cell which the breakpoint is associated to. Continuing example given above:
> bl
D 2(2) 000180 02 LJMP  022a
F 1(1) 000006 wi
> bde ri 6
No ri breakpoint at 000006
> bde wi 6
> bl
D 2(2) 000180 02 LJMP  022a
> 

ba

Delete all breakpoints. This command deletes all fetch as well as event breakpoints. Be carefull because it does not ask you to confirm your intention.
> bl
F 1(1) 000160 c2 CLR   P1.0
D 2(2) 000180 02 LJMP  022a
F 1(1) 000006 wi
> ba
> bl
>