2 * Simulator of microcontrollers (cmd_brk.cc)
4 * Copyright (C) 1999,99 Drotos Daniel, Talker Bt.
6 * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu
10 /* This file is part of microcontroller simulator: ucsim.
12 UCSIM is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
17 UCSIM is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with UCSIM; see the file COPYING. If not, write to the Free
24 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
37 #include "uc51cl.h" //FIXME
42 * BREAKPOINT SET f|d addr [hit]
46 cmd_brk_setf(char *cmd, class t_uc51 *uc, class cl_sim *sim)
54 if ((s= strtok(NULL, delimiters)) == NULL)
56 sim->cmd->printf("Permanency has not given\n");
68 sim->cmd->printf("Unknow permanency\n");
71 if ((s= strtok(NULL, delimiters)) == NULL)
73 sim->cmd->printf("Address has not given\n");
76 addr= (uint)strtol(s, NULL, 0);
77 if ((s= strtok(NULL, delimiters)) != NULL)
78 hit= strtol(s, NULL, 0);
79 if (uc->fbrk_at(addr))
80 sim->cmd->printf("Breakpoint at %06x is already set.\n", addr);
83 b= new cl_fetch_brk(addr, perm, hit);
91 * BREAKPOINT SET EVENT wi|ri|wx|rx|ws|rs|rc f|d addr [hit]
95 cmd_brk_sete(char *cmd, class t_uc51 *uc, class cl_sim *sim)
102 class cl_ev_brk *b= NULL;
104 if ((id= strtok(NULL, delimiters)) == NULL)
106 sim->cmd->printf("Event has not given.\n");
109 if ((s= strtok(NULL, delimiters)) == NULL)
111 sim->cmd->printf("Permanency has not given\n");
123 sim->cmd->printf("Unknow permanency\n");
126 if ((s= strtok(NULL, delimiters)) == NULL)
128 sim->cmd->printf("Address has not given\n");
131 addr= (uint)strtol(s, NULL, 0);
132 if ((s= strtok(NULL, delimiters)) != NULL)
133 hit= strtol(s, NULL, 0);
136 if (!strcmp(id, "wi"))
137 b= new cl_wi_brk(uc->ebrk->make_new_nr(), addr, perm, hit);
138 else if (!strcmp(id, "ri"))
139 b= new cl_ri_brk(uc->ebrk->make_new_nr(), addr, perm, hit);
140 else if (!strcmp(id, "wx"))
141 b= new cl_wx_brk(uc->ebrk->make_new_nr(), addr, perm, hit);
142 else if (!strcmp(id, "rx"))
143 b= new cl_rx_brk(uc->ebrk->make_new_nr(), addr, perm, hit);
144 else if (!strcmp(id, "ws"))
145 b= new cl_ws_brk(uc->ebrk->make_new_nr(), addr, perm, hit);
146 else if (!strcmp(id, "rs"))
147 b= new cl_rs_brk(uc->ebrk->make_new_nr(), addr, perm, hit);
148 else if (!strcmp(id, "rc"))
149 b= new cl_rc_brk(uc->ebrk->make_new_nr(), addr, perm, hit);
151 sim->cmd->printf("Event %s is unknown.\n", id);
160 * BREAKPOINT DELETE addr
164 cmd_brk_delf(char *cmd, class t_uc51 *uc, class cl_sim *sim)
169 if ((s= strtok(NULL, delimiters)) == NULL)
170 sim->cmd->printf("Address has not given.\n");
173 addr= (uint)strtol(s, NULL, 0);
174 if (uc->fbrk_at(addr) == NULL)
175 sim->cmd->printf("No breakpoint at %06x\n", addr);
177 uc->fbrk->del_bp(addr);
184 * BREAKPOINT DELETE EVENT wi|ri|wx|rx|ws|rs|rc addr
188 cmd_brk_dele(char *cmd, class t_uc51 *uc, class cl_sim *sim)
193 if ((id= strtok(NULL, delimiters)) == NULL)
195 fprintf(sim->cmd_out(), "Event has not given.\n");
198 if ((s= strtok(NULL, delimiters)) == NULL)
199 fprintf(sim->cmd_out(), "Address has not given.\n");
202 addr= (uint)strtol(s, NULL, 0);
203 if (uc->ebrk_at(addr, id) == NULL)
204 fprintf(sim->cmd_out(), "No %s breakpoint at %06x\n", id, addr);
206 uc->rm_ebrk(addr, id);
213 * BREAKPOINT DELETE ALL
217 cmd_brk_delall(char *cmd, class t_uc51 *uc, class cl_sim *sim)
219 while (uc->fbrk->count)
221 class cl_brk *brk= (class cl_brk *)(uc->fbrk->at(0));
222 uc->fbrk->del_bp(brk->addr);
224 while (uc->ebrk->count)
225 uc->ebrk->free_at(0);
235 cmd_brk_lst(char *cmd, class t_uc51 *uc, class cl_sim *sim)
237 class cl_fetch_brk *fb;
242 for (i= 0; i < uc->fbrk->count; i++)
244 fb= (class cl_fetch_brk *)(uc->fbrk->at(i));
245 s = uc->disass(fb->addr, NULL);
246 fprintf(sim->cmd_out(), "%c %d(%d) %06x %02x %s\n",
247 (fb->perm==brkFIX)?'F':'D',
249 fb->addr, uc->get_mem(MEM_ROM, fb->addr), s);
252 for (i= 0; i < uc->ebrk->count; i++)
254 eb= (class cl_ev_brk *)(uc->ebrk->at(i));
255 fprintf(sim->cmd_out(), "%c %d(%d) %06x %s\n",
256 (eb->perm==brkFIX)?'F':'D',
264 /* End of s51.src/cmd_brk.cc */