From: drdani Date: Mon, 7 Feb 2000 08:07:02 +0000 (+0000) Subject: ucsim-0.2.37-pre3 into cvs X-Git-Url: https://git.gag.com/?a=commitdiff_plain;ds=sidebyside;h=1854d0ec377d6032617c09d2bd31fa0866764744;p=fw%2Fsdcc ucsim-0.2.37-pre3 into cvs git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@79 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/sim/ucsim/cmd.src/(c).1 b/sim/ucsim/cmd.src/(c).1 new file mode 100644 index 00000000..d673f9fd --- /dev/null +++ b/sim/ucsim/cmd.src/(c).1 @@ -0,0 +1,25 @@ +/* + * Simulator of microcontrollers (@@F@@) + * + * Copyright (C) @@S@@,@@Y@@ Drotos Daniel, Talker Bt. + * + * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu + * + */ + +/* This file is part of microcontroller simulator: ucsim. + +UCSIM is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +UCSIM is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with UCSIM; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. */ diff --git a/sim/ucsim/cmd.src/Makefile.in b/sim/ucsim/cmd.src/Makefile.in new file mode 100644 index 00000000..09344f23 --- /dev/null +++ b/sim/ucsim/cmd.src/Makefile.in @@ -0,0 +1,117 @@ +# +# S51 mcs51/Makefile +# +# (c) Drotos Daniel, Talker Bt. 1997 +# + +STARTYEAR = 1997 + +SHELL = /bin/sh +CXX = @CXX@ +CPP = @CPP@ +CXXCPP = @CXXCPP@ +RANLIB = @RANLIB@ +INSTALL = @INSTALL@ + +PRJDIR = .. + +DEFS = $(subs -DHAVE_CONFIG_H,,@DEFS@) +CPPFLAGS = @CPPFLAGS@ -I. -I$(PRJDIR) \ + -I$(PRJDIR)/sim.src +CFLAGS = @CFLAGS@ -Wall +CXXFLAGS = @CXXFLAGS@ -Wall +M_OR_MM = @M_OR_MM@ + +prefix = @prefix@ +exec_prefix = @exec_prefix@ +bindir = @bindir@ +libdir = @libdir@ +datadir = @datadir@ +includedir = @includedir@ +mandir = @mandir@ +man1dir = $(mandir)/man1 +man2dir = $(mandir)/man2 +infodir = @infodir@ +srcdir = @srcdir@ + +OBJECTS = newcmd.o cmdutil.o cmdset.o syntax.o \ + get.o set.o timer.o bp.o info.o + + +# Compiling entire program or any subproject +# ------------------------------------------ +all: checkconf cmdlib + +cmd.src: all + + +# Compiling and installing everything and runing test +# --------------------------------------------------- +install: all installdirs + + +# Deleting all the installed files +# -------------------------------- +uninstall: + + +# Performing self-test +# -------------------- +check: + + +# Performing installation test +# ---------------------------- +installcheck: + + +# Creating installation directories +# --------------------------------- +installdirs: + + +# Creating dependencies +# --------------------- +dep: Makefile.dep + +Makefile.dep: *.cc *.h + $(CXXCPP) $(CPPFLAGS) $(M_OR_MM) *.cc >Makefile.dep + +include Makefile.dep +include clean.mk + +#parser.cc: parser.y + +#plex.cc: plex.l + +# My rules +# -------- + +cmdlib: $(PRJDIR)/libcmd.a + +$(PRJDIR)/libcmd.a: $(OBJECTS) + ar -rcu $*.a $(OBJECTS) + $(RANLIB) $*.a + +.cc.o: + $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@ + +.y.cc: + rm -f $*.cc $*.h + $(YACC) -d $< + mv y.tab.c $*.cc + mv y.tab.h $*.h + +.l.cc: + rm -f $*.cc + $(LEX) -t $< >$*.cc + + +# Remaking configuration +# ---------------------- +checkconf: + @if [ -f $(PRJDIR)/devel ]; then\ + $(MAKE) -f conf.mk srcdir="$(srcdir)" PRJDIR="$(PRJDIR)" freshconf;\ + fi + +# End of mcs51/Makefile.in diff --git a/sim/ucsim/cmd.src/bp.cc b/sim/ucsim/cmd.src/bp.cc new file mode 100644 index 00000000..e2d6fd13 --- /dev/null +++ b/sim/ucsim/cmd.src/bp.cc @@ -0,0 +1,119 @@ +/* + * Simulator of microcontrollers (bp.cc) + * + * Copyright (C) 1999,99 Drotos Daniel, Talker Bt. + * + * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu + * + */ + +/* This file is part of microcontroller simulator: ucsim. + +UCSIM is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +UCSIM is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with UCSIM; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. */ +/*@1@*/ + +#include "ddconfig.h" + +#include "stdlib.h" + +// sim +#include "brkcl.h" +#include "argcl.h" +#include "simcl.h" + +// cmd +#include "cmdsetcl.h" + + +/* + * BREAK command + */ + +int +cl_break_cmd::do_work(class cl_cmdline *cmdline, class cl_console *con) +{ + long addr; + int hit= 1; + class cl_cmd_arg *params[2]= { cmdline->param(0), + cmdline->param(1) }; + + if (params[0] == 0) + { + con->printf("Address is missing.\n"); + return(FALSE); + } + addr= (params[0])->get_address(); + if (params[1]) + hit= (params[1])->get_ivalue(); + if (hit > 99999) + { + con->printf("Hit value %d is too big.\n", hit); + return(0); + } + if (sim->uc->fbrk->bp_at(addr)) + con->printf("Breakpoint at 0x%06x is already set.\n", addr); + else + { + class cl_brk *b= new cl_fetch_brk(sim->uc->fbrk->make_new_nr(), + addr, perm, hit); + b->init(); + sim->uc->fbrk->add_bp(b); + char *s= sim->uc->disass(addr, NULL); + con->printf("Breakpoint %d at 0x%06x: %s\n", b->nr, addr, s); + free(s); + } + return(0); +} + + +/* + * CLEAR address + */ + +int +cl_clear_cmd::do_work(class cl_cmdline *cmdline, class cl_console *con) +{ + uint addr; + int idx; + class cl_brk *brk= sim->uc->fbrk->get_bp(sim->uc->PC, &idx); + + if (cmdline->param(0) == 0) + { + if (!brk) + { + con->printf("No breakpoint at this address.\n"); + return(0); + } + sim->uc->fbrk->del_bp(sim->uc->PC); + return(0); + } + + int i= 0; + class cl_cmd_arg *param; + while ((param= cmdline->param(i++))) + { + addr= param->get_ivalue(); + if (sim->uc->fbrk->bp_at(addr) == 0) + sim->cmd->printf("No breakpoint at 0x%06x\n", addr); + else + sim->uc->fbrk->del_bp(addr); + } + + return(0); +} + + +/* End of bp.cc */ diff --git a/sim/ucsim/cmd.src/clean.mk b/sim/ucsim/cmd.src/clean.mk new file mode 100644 index 00000000..68b48723 --- /dev/null +++ b/sim/ucsim/cmd.src/clean.mk @@ -0,0 +1,23 @@ +# Deleting all files created by building the program +# -------------------------------------------------- +clean: + rm -f *core *[%~] *.[oa] + rm -f .[a-z]*~ + + +# Deleting all files created by configuring or building the program +# ----------------------------------------------------------------- +distclean: clean + rm -f config.cache config.log config.status + rm -f Makefile *.dep + + +# Like clean but some files may still exist +# ----------------------------------------- +mostlyclean: clean + + +# Deleting everything that can reconstructed by this Makefile. It deletes +# everything deleted by distclean plus files created by bison, etc. +# ----------------------------------------------------------------------- +realclean: distclean diff --git a/sim/ucsim/cmd.src/cmdset.cc b/sim/ucsim/cmd.src/cmdset.cc new file mode 100644 index 00000000..8a659f68 --- /dev/null +++ b/sim/ucsim/cmd.src/cmdset.cc @@ -0,0 +1,467 @@ +/* + * Simulator of microcontrollers (cmdset.cc) + * + * Copyright (C) 1999,99 Drotos Daniel, Talker Bt. + * + * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu + * + */ + +/* This file is part of microcontroller simulator: ucsim. + +UCSIM is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +UCSIM is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with UCSIM; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. */ +/*@1@*/ + +#include "ddconfig.h" + +#include "i_string.h" + +#include "globals.h" +#include "utils.h" + +// sim +#include "simcl.h" + +// local +#include "cmdsetcl.h" + + +/* + * Command: conf + *---------------------------------------------------------------------------- + */ + +int +cl_conf_cmd::do_work(class cl_cmdline *cmdline, class cl_console *con) +{ + int i; + + con->printf("ucsim version %s\n", VERSIONSTR); + con->printf("Type of microcontroller: %s\n", sim->uc->id_string()); + con->printf("Controller has %d hardware element(s).\n", + sim->uc->hws->count); + for (i= 0; i < sim->uc->hws->count; i++) + { + class cl_hw *hw= (class cl_hw *)(sim->uc->hws->at(i)); + con->printf(" %s[%d]\n", hw->id_string, hw->id); + } + con->printf("Memories:\n"); + for (i= MEM_ROM; i < MEM_TYPES; i++) + { + class cl_mem *mem= (class cl_mem *)(sim->uc->mems->at(i)); + if (mem) + con->printf(" %s size= 0x%06x %d\n", + mem->id_string(), mem->size, mem->size); + } + return(0); +} + + +/* + * Command: state + *---------------------------------------------------------------------------- + */ + +int +cl_state_cmd::do_work(class cl_cmdline *cmdline, class cl_console *con) +{ + //con->printf("sim state= %d\n", sim->state); + con->printf("CPU state= %s PC= 0x%06x XTAL= %g\n", + get_id_string(cpu_states, sim->uc->state), + sim->uc->PC, + sim->uc->xtal); + con->printf("Total time since last reset= %g sec (%lu clks)\n", + sim->uc->get_rtime(), sim->uc->ticks->ticks); + con->printf("Time in isr = %g sec (%lu clks) %3.2g%%\n", + sim->uc->isr_ticks->get_rtime(sim->uc->xtal), + sim->uc->isr_ticks->ticks, + (sim->uc->ticks->ticks == 0)?0.0: + (100.0*((double)(sim->uc->isr_ticks->ticks)/ + (double)(sim->uc->ticks->ticks)))); + con->printf("Time in idle= %g sec (%lu clks) %3.2g%%\n", + sim->uc->idle_ticks->get_rtime(sim->uc->xtal), + sim->uc->idle_ticks->ticks, + (sim->uc->ticks->ticks == 0)?0.0: + (100.0*((double)(sim->uc->idle_ticks->ticks)/ + (double)(sim->uc->ticks->ticks)))); + con->printf("Max value of stack pointer= 0x%06x, avg= 0x%06x\n", + sim->uc->sp_max, sim->uc->sp_avg); + return(0); +} + + +/* + * Command: file + *---------------------------------------------------------------------------- + */ + +int +cl_file_cmd::do_work(class cl_cmdline *cmdline, class cl_console *con) +{ + char *fname; + long l; + + if ((cmdline->param(0) == 0) || + ((fname= cmdline->param(0)->get_svalue()) == NULL)) + { + con->printf("File name is missing.\n"); + return(0); + } + if ((l= sim->uc->read_hex_file(fname)) >= 0) + con->printf("%ld words read from %s\n", l, fname); + + return(0); +} + + +/* + * Command: download + *---------------------------------------------------------------------------- + */ + +int +cl_dl_cmd::do_work(class cl_cmdline *cmdline, class cl_console *con) +{ + long l; + + if ((l= sim->uc->read_hex_file(NULL)) >= 0) + con->printf("%ld words loaded\n", l); + + return(0); +} + + +/* + * Command: get + *---------------------------------------------------------------------------- + */ + +int +cl_get_cmd::do_work(class cl_cmdline *cmdline, class cl_console *con) +{ + char *s; + + if (cmdline->param(0) == 0) + { + con->printf("Get what?\n"); + return(0); + } + if ((s= cmdline->param(0)->get_svalue())) + { + if (strstr(s, "t") == s) + return(timer(cmdline, con)); + else + con->printf("Unknow keyword of get command\n"); + } + return(0); +} + + +/* + * Command: set + *---------------------------------------------------------------------------- + */ + + +int +cl_set_cmd::do_work(class cl_cmdline *cmdline, class cl_console *con) +{ + char *s; + + if (cmdline->param(0) == 0) + { + con->printf("Set what?\n"); + return(0); + } + if ((s= cmdline->param(0)->get_svalue())) + { + if (strstr(s, "t") == s) + return(timer(cmdline, con)); + else + con->printf("Unknow keyword of set command\n"); + } + return(0); +} + + +/* + * Command: run + *---------------------------------------------------------------------------- + */ + + +int +cl_run_cmd::do_work(class cl_cmdline *cmdline, class cl_console *con) +{ + sim->start(con); + return(0); +} + + +/* + * Command: step + *---------------------------------------------------------------------------- + */ + + +int +cl_step_cmd::do_work(class cl_cmdline *cmdline, class cl_console *con) +{ + sim->uc->do_inst(1); + sim->uc->print_regs(con); + return(0); +} + + +/* + * Command: reset + *---------------------------------------------------------------------------- + */ + + +int +cl_reset_cmd::do_work(class cl_cmdline *cmdline, class cl_console *con) +{ + sim->uc->reset(); + return(0); +} + + +/* + * Command: dump + *---------------------------------------------------------------------------- + */ + +int +cl_dump_cmd::do_work(class cl_cmdline *cmdline, class cl_console *con) +{ + class cl_mem *mem; + char *s; + long l, start= -1, end= 10*8-1, bpl= 8; + class cl_cmd_arg *params[4]= { cmdline->param(0), + cmdline->param(1), + cmdline->param(2), + cmdline->param(3) }; + + if (params[0] == 0) + { + con->printf("Memory type missing\n"); + return(0); + } + if ((s= params[0]->get_svalue())) + { + if (strstr(s, "i") == s) + mem= sim->uc->mem(MEM_IRAM); + else if (strstr(s, "x") == s) + mem= sim->uc->mem(MEM_XRAM); + else if (strstr(s, "r") == s) + mem= sim->uc->mem(MEM_ROM); + else if (strstr(s, "s") == s) + mem= sim->uc->mem(MEM_SFR); + else + { + con->printf("Unknown memory type\n"); + return(0); + } + if (!mem) + { + con->printf("No such memory\n"); + return(0); + } + } + else + { + con->printf("Wrong memory type\n"); + return(0); + } + + if (params[1]) + { + if ((start= params[1]->get_address()) >= 0) + { + end+= start; + if (params[2]) + { + if ((l= params[2]->get_address()) >= 0) + end= l; + else + { + con->printf("End address is wrong\n"); + return(0); + } + } + } + else + { + con->printf("Start address is wrong\n"); + return(0); + } + } + if (params[3] && + (l= params[3]->get_address()) >= 0) + bpl= l; + mem->dump(start, end, bpl, con); + return(0); +} + + +/* + * Command: di + *---------------------------------------------------------------------------- + */ + +int +cl_di_cmd::do_work(class cl_cmdline *cmdline, class cl_console *con) +{ + cmdline->insert_param(0, new cl_cmd_sym_arg("i")); + cl_dump_cmd::do_work(cmdline, con); + return(0); +} + + +/* + * Command: dx + *---------------------------------------------------------------------------- + */ + +int +cl_dx_cmd::do_work(class cl_cmdline *cmdline, class cl_console *con) +{ + cmdline->insert_param(0, new cl_cmd_sym_arg("x")); + cl_dump_cmd::do_work(cmdline, con); + return(0); +} + + +/* + * Command: dch + *---------------------------------------------------------------------------- + */ + +int +cl_dch_cmd::do_work(class cl_cmdline *cmdline, class cl_console *con) +{ + cmdline->insert_param(0, new cl_cmd_sym_arg("r")); + cl_dump_cmd::do_work(cmdline, con); + return(0); +} + + +/* + * Command: ds + *---------------------------------------------------------------------------- + */ + +int +cl_ds_cmd::do_work(class cl_cmdline *cmdline, class cl_console *con) +{ + cmdline->insert_param(0, new cl_cmd_sym_arg("s")); + cl_dump_cmd::do_work(cmdline, con); + return(0); +} + + +/* + * Command: dc + *---------------------------------------------------------------------------- + */ + +int +cl_dc_cmd::do_work(class cl_cmdline *cmdline, class cl_console *con) +{ + long i, l, start= last, end= -1; + class cl_cmd_arg *params[2]= { cmdline->param(0), + cmdline->param(1) }; + + if (params[0]) + { + if ((start= params[0]->get_address()) >= 0) + { + if (params[1]) + { + if ((l= params[1]->get_address()) >= 0) + end= l; + else + { + con->printf("End address is wrong\n"); + return(0); + } + } + } + else + { + con->printf("Start address is wrong\n"); + return(0); + } + } + i= 0; + for (l= start; + (end < 0 && i < 20) || l <= end; + l+= sim->uc->inst_length(sim->uc->get_mem(MEM_ROM, l)), i++) + sim->uc->print_disass(l, con); + last= l; + return(0); +} + + +/* + * Command: help + *---------------------------------------------------------------------------- + */ + +int +cl_help_cmd::do_work(class cl_cmdline */*cmdline*/, class cl_console *con) +{ + class cl_cmd *c; + int i; + + for (i= 0; i < sim->cmdset->count; i++) + { + c= (class cl_cmd *)(sim->cmdset->at(i)); + if (c->short_help) + con->printf("%s\n", c->short_help); + else + con->printf("%s\n", (char*)(c->names->at(0))); + } + return(0); +} + + +/* + * Command: quit + *---------------------------------------------------------------------------- + */ + +int +cl_quit_cmd::do_work(class cl_cmdline */*cmdline*/, class cl_console */*con*/) +{ + return(1); +} + +/* + * Command: kill + *---------------------------------------------------------------------------- + */ + +int +cl_kill_cmd::do_work(class cl_cmdline */*cmdline*/, class cl_console */*con*/) +{ + sim->state|= SIM_QUIT; + return(1); +} + + +/* End of cmdset.cc */ diff --git a/sim/ucsim/cmd.src/cmdsetcl.h b/sim/ucsim/cmd.src/cmdsetcl.h new file mode 100644 index 00000000..b6202693 --- /dev/null +++ b/sim/ucsim/cmd.src/cmdsetcl.h @@ -0,0 +1,340 @@ +/* + * Simulator of microcontrollers (cmdsetcl.h) + * + * Copyright (C) 1999,99 Drotos Daniel, Talker Bt. + * + * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu + * + */ + +/* This file is part of microcontroller simulator: ucsim. + +UCSIM is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +UCSIM is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with UCSIM; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. */ +/*@1@*/ + +#ifndef CMDSETCL_HEADER +#define CMDSETCL_HEADER + +#include "newcmdcl.h" + + +// CONF +class cl_conf_cmd: public cl_cmd +{ +public: + cl_conf_cmd(class cl_sim *asim, + char *aname, + int can_rep, + char *short_hlp, + char *long_hlp): + cl_cmd(asim, aname, can_rep, short_hlp, long_hlp) {} + virtual int do_work(class cl_cmdline *cmdline, class cl_console *con); +}; + +// STATE +class cl_state_cmd: public cl_cmd +{ +public: + cl_state_cmd(class cl_sim *asim, + char *aname, + int can_rep, + char *short_hlp, + char *long_hlp): + cl_cmd(asim, aname, can_rep, short_hlp, long_hlp) {} + virtual int do_work(class cl_cmdline *cmdline, class cl_console *con); +}; + +// FILE +class cl_file_cmd: public cl_cmd +{ +public: + cl_file_cmd(class cl_sim *asim, + char *aname, + int can_rep, + char *short_hlp, + char *long_hlp): + cl_cmd(asim, aname, can_rep, short_hlp, long_hlp) {} + virtual int do_work(class cl_cmdline *cmdline, class cl_console *con); +}; + +// DOWNLOAD +class cl_dl_cmd: public cl_cmd +{ +public: + cl_dl_cmd(class cl_sim *asim, + char *aname, + int can_rep, + char *short_hlp, + char *long_hlp): + cl_cmd(asim, aname, can_rep, short_hlp, long_hlp) {} + virtual int do_work(class cl_cmdline *cmdline, class cl_console *con); +}; + +// GET +class cl_get_cmd: public cl_cmd +{ +public: + cl_get_cmd(class cl_sim *asim, + char *aname, + int can_rep, + char *short_hlp, + char *long_hlp): + cl_cmd(asim, aname, can_rep, short_hlp, long_hlp) {} + virtual int do_work(class cl_cmdline *cmdline, class cl_console *con); + virtual int timer(class cl_cmdline *cmdline, class cl_console *con); +}; + +// SET +class cl_set_cmd: public cl_cmd +{ +public: + cl_set_cmd(class cl_sim *asim, + char *aname, + int can_rep, + char *short_hlp, + char *long_hlp): + cl_cmd(asim, aname, can_rep, short_hlp, long_hlp) {} + virtual int do_work(class cl_cmdline *cmdline, class cl_console *con); + virtual int timer(class cl_cmdline *cmdline, class cl_console *con); +}; + +// TIMER +class cl_timer_cmd: public cl_cmd +{ +public: + class cl_ticker *ticker; + int what; + char *name; + + cl_timer_cmd(class cl_sim *asim, + char *aname, + int can_rep, + char *short_hlp, + char *long_hlp): + cl_cmd(asim, aname, can_rep, short_hlp, long_hlp) {} + virtual int do_work(class cl_cmdline *cmdline, class cl_console *con); + void set_ticker(class cl_cmd_arg *param); + virtual int add(class cl_cmdline *cmdline, class cl_console *con); + virtual int del(class cl_cmdline *cmdline, class cl_console *con); + virtual int get(class cl_cmdline *cmdline, class cl_console *con); + virtual int run(class cl_cmdline *cmdline, class cl_console *con); + virtual int stop(class cl_cmdline *cmdline, class cl_console *con); + virtual int val(class cl_cmdline *cmdline, class cl_console *con); +}; + +// RUN +class cl_run_cmd: public cl_cmd +{ +public: + cl_run_cmd(class cl_sim *asim, + char *aname, + int can_rep, + char *short_hlp, + char *long_hlp): + cl_cmd(asim, aname, can_rep, short_hlp, long_hlp) {} + virtual int do_work(class cl_cmdline *cmdline, class cl_console *con); +}; + +// STEP +class cl_step_cmd: public cl_cmd +{ +public: + cl_step_cmd(class cl_sim *asim, + char *aname, + int can_rep, + char *short_hlp, + char *long_hlp): + cl_cmd(asim, aname, can_rep, short_hlp, long_hlp) {} + virtual int do_work(class cl_cmdline *cmdline, class cl_console *con); +}; + +// RESET +class cl_reset_cmd: public cl_cmd +{ +public: + cl_reset_cmd(class cl_sim *asim, + char *aname, + int can_rep, + char *short_hlp, + char *long_hlp): + cl_cmd(asim, aname, can_rep, short_hlp, long_hlp) {} + virtual int do_work(class cl_cmdline *cmdline, class cl_console *con); +}; + +// DUMP +class cl_dump_cmd: public cl_cmd +{ +public: + cl_dump_cmd(class cl_sim *asim, + char *aname, + int can_rep, + char *short_hlp, + char *long_hlp): + cl_cmd(asim, aname, can_rep, short_hlp, long_hlp) {} + //cl_dump_cmd(class cl_sim *asim): cl_cmd(asim) {} + virtual int do_work(class cl_cmdline *cmdline, class cl_console *con); +}; + +// DI +class cl_di_cmd: public cl_dump_cmd +{ +public: + cl_di_cmd(class cl_sim *asim, + char *aname, + int can_rep, + char *short_hlp, + char *long_hlp): + cl_dump_cmd(asim, aname, can_rep, short_hlp, long_hlp) {} + virtual int do_work(class cl_cmdline *cmdline, class cl_console *con); +}; + +// DX +class cl_dx_cmd: public cl_dump_cmd +{ +public: + cl_dx_cmd(class cl_sim *asim, + char *aname, + int can_rep, + char *short_hlp, + char *long_hlp): + cl_dump_cmd(asim, aname, can_rep, short_hlp, long_hlp) {} + virtual int do_work(class cl_cmdline *cmdline, class cl_console *con); +}; + +// DCH +class cl_dch_cmd: public cl_dump_cmd +{ +public: + cl_dch_cmd(class cl_sim *asim, + char *aname, + int can_rep, + char *short_hlp, + char *long_hlp): + cl_dump_cmd(asim, aname, can_rep, short_hlp, long_hlp) {} + virtual int do_work(class cl_cmdline *cmdline, class cl_console *con); +}; + +// DS +class cl_ds_cmd: public cl_dump_cmd +{ +public: + cl_ds_cmd(class cl_sim *asim, + char *aname, + int can_rep, + char *short_hlp, + char *long_hlp): + cl_dump_cmd(asim, aname, can_rep, short_hlp, long_hlp) {} + virtual int do_work(class cl_cmdline *cmdline, class cl_console *con); +}; + +// DC +class cl_dc_cmd: public cl_cmd +{ +public: + int last; +public: + cl_dc_cmd(class cl_sim *asim, + char *aname, + int can_rep, + char *short_hlp, + char *long_hlp): + cl_cmd(asim, aname, can_rep, short_hlp, long_hlp) {last=0;} + virtual int do_work(class cl_cmdline *cmdline, class cl_console *con); +}; + +// BREAK +class cl_break_cmd: public cl_cmd +{ +public: + enum brk_perm perm; +public: + cl_break_cmd(class cl_sim *asim, + char *aname, + int can_rep, + char *short_hlp, + char *long_hlp): + cl_cmd(asim, aname, can_rep, short_hlp, long_hlp) { perm= brkFIX; } + virtual int do_work(class cl_cmdline *cmdline, class cl_console *con); +}; + +// TBREAK +class cl_tbreak_cmd: public cl_break_cmd +{ +public: + cl_tbreak_cmd(class cl_sim *asim, + char *aname, + int can_rep, + char *short_hlp, + char *long_hlp): + cl_break_cmd(asim, aname, can_rep, short_hlp, long_hlp) {perm=brkDYNAMIC;} +}; + +// CLEAR +class cl_clear_cmd: public cl_cmd +{ +public: + cl_clear_cmd(class cl_sim *asim, + char *aname, + int can_rep, + char *short_hlp, + char *long_hlp): + cl_cmd(asim, aname, can_rep, short_hlp, long_hlp) {} + virtual int do_work(class cl_cmdline *cmdline, class cl_console *con); +}; + +// HELP +class cl_help_cmd: public cl_cmd +{ +public: + cl_help_cmd(class cl_sim *asim, + char *aname, + int can_rep, + char *short_hlp, + char *long_hlp): + cl_cmd(asim, aname, can_rep, short_hlp, long_hlp) {} + virtual int do_work(class cl_cmdline *cmdline, class cl_console *con); +}; + +// QUIT +class cl_quit_cmd: public cl_cmd +{ +public: + cl_quit_cmd(class cl_sim *asim, + char *aname, + int can_rep, + char *short_hlp, + char *long_hlp): + cl_cmd(asim, aname, can_rep, short_hlp, long_hlp) {} + virtual int do_work(class cl_cmdline *cmdline, class cl_console *con); +}; + +// KILL +class cl_kill_cmd: public cl_cmd +{ +public: + cl_kill_cmd(class cl_sim *asim, + char *aname, + int can_rep, + char *short_hlp, + char *long_hlp): + cl_cmd(asim, aname, can_rep, short_hlp, long_hlp) {} + virtual int do_work(class cl_cmdline *cmdline, class cl_console *con); +}; + + +#endif + +/* End of cmdsetcl.h */ diff --git a/sim/ucsim/cmd.src/cmdutil.cc b/sim/ucsim/cmd.src/cmdutil.cc new file mode 100644 index 00000000..083b8456 --- /dev/null +++ b/sim/ucsim/cmd.src/cmdutil.cc @@ -0,0 +1,286 @@ +/* + * Simulator of microcontrollers (cmdutil.cc) + * + * Copyright (C) 1999,99 Drotos Daniel, Talker Bt. + * + * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu + * + */ + +/* This file is part of microcontroller simulator: ucsim. + +UCSIM is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +UCSIM is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with UCSIM; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. */ +/*@1@*/ + +#include "ddconfig.h" + +#include +#include +#include +#include +#ifdef HAVE_SYS_SOCKET_H +# include +# include +# include +#endif +#include "i_string.h" + +#include "stypes.h" +#include "globals.h" +#include "uccl.h" + + +/* + * Making a socket which can be used to listen for a specified port + */ + +#ifdef SOCKET_AVAIL +int +make_server_socket(unsigned short int port) +{ + int sock, i; + struct sockaddr_in name; + + /* Create the socket. */ + sock= socket(PF_INET, SOCK_STREAM, 0); + if (sock < 0) + { + perror("socket"); + return(0); + } + + /* Give the socket a name. */ + i= 1; + if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char*)&i, sizeof(i)) < 0) + { + perror("setsockopt"); + } + name.sin_family = AF_INET; + name.sin_port = htons(port); + name.sin_addr.s_addr= htonl(INADDR_ANY); + if (bind(sock, (struct sockaddr *)&name, sizeof(name)) < 0) + { + perror("bind"); + return(0); + } + + return(sock); +} +#endif + + +/* + * Printing out an integer in binary format + */ + +void +print_bin(long data, int bits, FILE *f) +{ + long mask= 1; + + mask= mask << ((bits >= 1)?(bits-1):0); + while (bits--) + { + fprintf(f, "%c", (data&mask)?'1':'0'); + mask>>= 1; + } +} + + +/* + * Searching for a name in the specified table + */ + +struct name_entry * +get_name_entry(struct name_entry tabl[], char *name, class cl_uc *uc) +{ + int i= 0; + char *p; + + for (p= name; *p; *p= toupper(*p), p++); + while (tabl[i].name && + (!(tabl[i].cpu_type & uc->type) || + (strcmp(tabl[i].name, name) != 0))) + i++; + if (tabl[i].name != NULL) + return(&tabl[i]); + else + return(NULL); +} + + +/* + * Interpreting a bitname + */ + +bool +interpret_bitname(char *name, class cl_uc *uc, + uchar **cell, uchar *celladdr, + uchar *bitaddr, uchar *bitmask, + char **symname) +{ + char *dot, *p; + char *sym, bitnumstr[2]; + struct name_entry *ne; + int bitnum, i; + + if ((dot= strchr(name, '.')) != NULL) + { + *dot++= '\0'; + if ((ne= get_name_entry(uc->sfr_tbl(), name, uc)) == NULL) + { + *celladdr= strtol(name, &p, 0); + if (p && *p) + { + dot--; + *dot= '.'; + return(FALSE); + } + } + else + *celladdr= ne->addr; + if ((*celladdr < 0x20) || + ((*celladdr > 0x2f) && (*celladdr < 0x80)) || + ((*celladdr > 0x7f) && (*celladdr & 0x07))) + return(FALSE); + bitnum= strtol(dot, &p, 0); + if ((p && *p) || + (bitnum < 0) || + (bitnum > 7)) + return(FALSE); + if (*celladdr > 0x7f) + *bitaddr= *celladdr + bitnum; + else + *bitaddr= (*celladdr - 0x20)*8 + bitnum; + dot--; + *dot= '.'; + } + else + { + if ((ne= get_name_entry(uc->bit_tbl(), name, uc)) == NULL) + { + *bitaddr= strtol(name, &p, 0); + if ((p && *p) || + (*bitaddr > 0xff)) + return(FALSE); + } + else + *bitaddr= ne->addr; + if (*bitaddr > 0x7f) + *celladdr= *bitaddr & 0xf8; + else + *celladdr= (*bitaddr >> 3) + 0x20; + } + // *bitaddr, *celladdr now OK + *cell= uc->get_bit/*FIXME*/(*bitaddr); + *bitmask= BIT_MASK(*bitaddr); + // making symbolic name + if (!symname) + return(TRUE); + i= 0; + while (uc->bit_tbl()[i].name && + (uc->bit_tbl()[i].addr != *bitaddr)) + i++; + if (uc->bit_tbl()[i].name) + { + sym= strdup(uc->bit_tbl()[i].name); + *symname= sym; + return(TRUE); + } + i= 0; + while (uc->sfr_tbl()[i].name && + (uc->sfr_tbl()[i].addr != *celladdr)) + i++; + if (uc->sfr_tbl()[i].name) + sym= strdup(uc->sfr_tbl()[i].name); + else + { + sym= (char *)malloc(3); + sprintf(sym, "%02x", *celladdr); + } + sym= (char *)realloc(sym, strlen(sym)+2); + strcat(sym, "."); + sprintf(bitnumstr, "%1d", *bitaddr & 0x07); + strcat(sym, bitnumstr); + *symname= sym; + return(TRUE); +} + + +/* + * Processing escape sequencies in a string + */ + +char * +proc_escape(char *string, int *len) +{ + char spec_chars[]= "fnrtvab"; + char spec[]= "\f\n\r\t\v\a\b"; + char *s, *str, *p; + + s = string; + str= (char *)malloc(strlen(string)+1); + p = str; + while (*s) + { + char *spec_c; + + if (*s == '\\' && + *(s+1)) + { + s++; + if (*s == '0') + { + if (!isdigit(*(s+1))) + { + *p++= '\0'; + s++; + } + else + { + char *octal, *chk, data; + int i, j; + i= strspn(s, "01234567"); + octal= (char *)malloc(i+1); + j= 0; + while (*s && + (j < i)) + octal[j++]= *s++; + octal[j]= '\0'; + data= strtol(octal, &chk, 8); + if (!chk || !(*chk)) + *p++= data; + } + } + else + if ((spec_c= strchr(spec_chars, *s)) != NULL) + { + *p++= spec[spec_c-spec_chars]; + s++; + } + else + *p++= *s++; + } + else + *p++= *s++; + } + *p= '\0'; + *len= p-str; + return(str); +} + + +/* End of cmdutil.cc */ diff --git a/sim/ucsim/cmd.src/cmdutil.h b/sim/ucsim/cmd.src/cmdutil.h new file mode 100644 index 00000000..8bc02d2a --- /dev/null +++ b/sim/ucsim/cmd.src/cmdutil.h @@ -0,0 +1,50 @@ +/* + * Simulator of microcontrollers (cmdutil.h) + * + * Copyright (C) 1999,99 Drotos Daniel, Talker Bt. + * + * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu + * + */ + +/* This file is part of microcontroller simulator: ucsim. + +UCSIM is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +UCSIM is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with UCSIM; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. */ +/*@1@*/ + +#ifndef CMDUTIL_HEADER +#define CMDUTIL_HEADER + +#include "ddconfig.h" + +#include "uccl.h" + + +extern int make_server_socket(unsigned short int port); +extern void print_bin(long data, int bits, FILE *f); +extern struct name_entry *get_name_entry(struct name_entry tabl[], + char *name, + class cl_uc *uc); +extern bool interpret_bitname(char *name, class cl_uc *uc, + uchar **cell, uchar *celladdr, + uchar *bitaddr, uchar *bitmask, + char **symname); +extern char *proc_escape(char *string, int *len); + + +#endif + +/* End of cmdutil.h */ diff --git a/sim/ucsim/cmd.src/conf.mk b/sim/ucsim/cmd.src/conf.mk new file mode 100644 index 00000000..879e9bc8 --- /dev/null +++ b/sim/ucsim/cmd.src/conf.mk @@ -0,0 +1,10 @@ +# +# Makefile targets to remake configuration +# + +freshconf: Makefile + +Makefile: $(srcdir)/Makefile.in $(PRJDIR)/configure.in + cd $(PRJDIR) && $(SHELL) ./config.status + +# End of conf.mk diff --git a/sim/ucsim/cmd.src/get.cc b/sim/ucsim/cmd.src/get.cc new file mode 100644 index 00000000..ab2888bc --- /dev/null +++ b/sim/ucsim/cmd.src/get.cc @@ -0,0 +1,79 @@ +/* + * Simulator of microcontrollers (get.cc) + * + * Copyright (C) 1999,99 Drotos Daniel, Talker Bt. + * + * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu + * + */ + +/* This file is part of microcontroller simulator: ucsim. + +UCSIM is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +UCSIM is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with UCSIM; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. */ +/*@1@*/ + +#include "ddconfig.h" + +// sim +#include "simcl.h" + +// local +#include "cmdsetcl.h" + + +/* + * GET TIMER + */ + +int +cl_get_cmd::timer(class cl_cmdline *cmdline, class cl_console *con) +{ + class cl_cmd_arg *params[4]= { cmdline->param(0), + cmdline->param(1), + cmdline->param(2), + cmdline->param(3) }; + int what; + class cl_ticker *ticker; + + if (params[1] != 0) + { + what= (params[1])->get_ivalue(); + if ((ticker= sim->uc->get_counter(what)) == 0) + { + con->printf("Timer %d does not exist\n", what); + return(0); + } + con->printf("timer #%d: %g sec (%lu clks)\n", what, + ticker->get_rtime(sim->uc->xtal), ticker->ticks); + } + else + { + con->printf("time: %g sec (%lu clks)\n", + sim->uc->get_rtime(), sim->uc->ticks->ticks); + for (what= 0; what < sim->uc->counters->count; what++) + { + ticker= sim->uc->get_counter(what); + if (ticker) + con->printf("timer #%d: %g sec (%lu clks)\n", what, + ticker->get_rtime(sim->uc->xtal), ticker->ticks); + } + } + + return(0); +} + + +/* End of get.cc */ diff --git a/sim/ucsim/cmd.src/info.cc b/sim/ucsim/cmd.src/info.cc new file mode 100644 index 00000000..f53f8701 --- /dev/null +++ b/sim/ucsim/cmd.src/info.cc @@ -0,0 +1,156 @@ +/* + * Simulator of microcontrollers (info.cc) + * + * Copyright (C) 1999,99 Drotos Daniel, Talker Bt. + * + * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu + * + */ + +/* This file is part of microcontroller simulator: ucsim. + +UCSIM is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +UCSIM is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with UCSIM; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. */ +/*@1@*/ + +#include +#include "i_string.h" + +// sim.src +#include "simcl.h" + +// local +#include "infocl.h" + + +/* + * INFO BREAKPOINTS command + */ + +int +cl_info_bp_cmd::do_work(class cl_cmdline *cmdline, class cl_console *con) +{ + int i; + char *s; + + con->printf("Num Type Disp Hit Cnt Address What\n"); + for (i= 0; i < sim->uc->fbrk->count; i++) + { + class cl_brk *fb= (class cl_brk *)(sim->uc->fbrk->at(i)); + s= sim->uc->disass(fb->addr, NULL); + con->printf("%-3d %-10s %s %-5d %-5d 0x%06x %s\n", fb->nr, + "fetch", (fb->perm==brkFIX)?"keep":"del ", + fb->hit, fb->cnt, + fb->addr, s); + free(s); + } + for (i= 0; i < sim->uc->ebrk->count; i++) + { + class cl_ev_brk *eb= (class cl_ev_brk *)(sim->uc->ebrk->at(i)); + con->printf("%-3d %-10s %s %-5d %-5d 0x%06x %s\n", eb->nr, + "event", (eb->perm==brkFIX)?"keep":"del ", + eb->hit, eb->cnt, + eb->addr, eb->id); + } + /*t_addr a; + class cl_rom *r= (class cl_rom *)(sim->uc->mem(MEM_ROM)); + for (a= 0; a < sim->uc->get_mem_size(MEM_ROM); a++) + { + if (r->bp_map->get(a)) + con->printf("0x%06x\n", a); + }*/ + return(0); +} + + +/* + * INFO REGISTERS command + */ + +int +cl_info_reg_cmd::do_work(class cl_cmdline *cmdline, class cl_console *con) +{ + sim->uc->print_regs(con); + return(0); +} + + +/* + * INFO HW command + */ + +int +cl_info_hw_cmd::do_work(class cl_cmdline *cmdline, class cl_console *con) +{ + class cl_cmd_arg *params[4]= { cmdline->param(0), + cmdline->param(1), + cmdline->param(2), + cmdline->param(3) }; + char *p0; + enum hw_cath cath; + class cl_hw *hw; + int i= 0; + + if (params[0] == 0) + { + con->printf("Cathegory missing\n"); + return(0); + } + p0= (params[0])->get_svalue(); + if (strstr(p0, "t") == p0) + cath= HW_TIMER; + else if (strstr(p0, "u") == p0) + cath= HW_UART; + else if (strstr(p0, "po") == p0) + cath= HW_PORT; + else if (strstr(p0, "pc") == p0) + cath= HW_PCA; + else if (strstr(p0, "i") == p0) + cath= HW_INTERRUPT; + else if (strstr(p0, "w") == p0) + cath= HW_WDT; + else + { + con->printf("Unknown cathegory\n"); + return(0); + } + if (params[1] == 0) + { + // no ID + hw= sim->uc->get_hw(cath, &i); + while (hw) + { + hw->print_info(con); + i++; + hw= sim->uc->get_hw(cath, &i); + } + } + else + { + // ID given + int id= (params[1])->get_ivalue(); + hw= sim->uc->get_hw(cath, id, &i); + while (hw) + { + hw->print_info(con); + i++; + hw= sim->uc->get_hw(cath, id, &i); + } + } + return(0); +} + + +/* End of info.cc */ diff --git a/sim/ucsim/cmd.src/infocl.h b/sim/ucsim/cmd.src/infocl.h new file mode 100644 index 00000000..5b3af267 --- /dev/null +++ b/sim/ucsim/cmd.src/infocl.h @@ -0,0 +1,73 @@ +/* + * Simulator of microcontrollers (infocl.h) + * + * Copyright (C) 1999,99 Drotos Daniel, Talker Bt. + * + * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu + * + */ + +/* This file is part of microcontroller simulator: ucsim. + +UCSIM is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +UCSIM is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with UCSIM; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. */ +/*@1@*/ + +#ifndef INFOCL_HEADER +#define INFOCL_HEADER + +#include "newcmdcl.h" + + +class cl_info_bp_cmd: public cl_cmd +{ +public: + cl_info_bp_cmd(class cl_sim *asim, + char *aname, + int can_rep, + char *short_hlp, + char *long_hlp): + cl_cmd(asim, aname, can_rep, short_hlp, long_hlp) {} + virtual int do_work(class cl_cmdline *cmdline, class cl_console *con); +}; + +class cl_info_reg_cmd: public cl_cmd +{ +public: + cl_info_reg_cmd(class cl_sim *asim, + char *aname, + int can_rep, + char *short_hlp, + char *long_hlp): + cl_cmd(asim, aname, can_rep, short_hlp, long_hlp) {} + virtual int do_work(class cl_cmdline *cmdline, class cl_console *con); +}; + +class cl_info_hw_cmd: public cl_cmd +{ +public: + cl_info_hw_cmd(class cl_sim *asim, + char *aname, + int can_rep, + char *short_hlp, + char *long_hlp): + cl_cmd(asim, aname, can_rep, short_hlp, long_hlp) {} + virtual int do_work(class cl_cmdline *cmdline, class cl_console *con); +}; + + +#endif + +/* End of infocl.h */ diff --git a/sim/ucsim/cmd.src/newcmd.cc b/sim/ucsim/cmd.src/newcmd.cc new file mode 100644 index 00000000..90e4b028 --- /dev/null +++ b/sim/ucsim/cmd.src/newcmd.cc @@ -0,0 +1,1112 @@ +/* + * Simulator of microcontrollers (newcmd.cc) + * + * Copyright (C) 1999,99 Drotos Daniel, Talker Bt. + * + * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu + * + */ + +/* This file is part of microcontroller simulator: ucsim. + +UCSIM is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +UCSIM is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with UCSIM; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. */ +/*@1@*/ + +#include "ddconfig.h" + +#include +#include +#include +#include +#include +#ifdef HAVE_SYS_SOCKET_H +# include +# include +# include +# include +#endif +#include +#if FD_HEADER_OK +# include HEADER_FD +#endif +#include +#include "i_string.h" + +// prj +#include "globals.h" + +// sim +#include "simcl.h" +#include "argcl.h" + +// local +#include "newcmdcl.h" +#include "cmdutil.h" + + +extern "C" int vasprintf(); +extern "C" int vsnprintf(); + +static int +cmd_do_print(FILE *f, char *format, va_list ap) +{ + int ret; +#ifdef HAVE_VASPRINTF + char *msg= NULL; + vasprintf(&msg, format, ap); + ret= fprintf(f, "%s", msg); + free(msg); +#else +# ifdef HAVE_VSNPRINTF + char msg[80*25]; + vsnprintf(msg, 80*25, format, ap); + ret= fprintf(f, "%s", msg); +# else +# ifdef HAVE_VPRINTF + char msg[80*25]; + vsprintf(msg, format, ap); /* Dangerous */ + ret= fprintf(f, "%s", msg); +# else +# ifdef HAVE_DOPRNT + /* ??? */ + /*strcpy(msg, "Unimplemented printf has called.\n");*/ +# else + /*strcpy(msg, "printf can not be implemented, upgrade your libc.\n");*/ +# endif +# endif +# endif +#endif + fflush(f); + return(ret); +} + + +/* + * Command line + *____________________________________________________________________________ + */ + +cl_cmdline::cl_cmdline(char *acmd) +{ + cmd= strdup(acmd); + params= new cl_list(2, 2); + tokens= new cl_ustrings(2, 2); + name= 0; +} + +cl_cmdline::~cl_cmdline(void) +{ + if (cmd) + free(cmd); + if (name) + free(name); + delete params; + delete tokens; +} + +int +cl_cmdline::init(void) +{ + split(); + return(0); +} + +char * +cl_cmdline::skip_delims(char *start) +{ + while (*start && + strchr(" \t\v\r,", *start)) + start++; + return(start); +} + +int +cl_cmdline::split(void) +{ + char *start= cmd; + int i; + + name= 0; + if (!cmd || + !*cmd) + return(0); + start+= strspn(start, " \t\v\r,"); + if (start && + *start == '\n') + { + name= (char*)malloc(2); + strcpy(name, "\n"); + return(0); + } + if (!*start) + return(0); + i= strcspn(start, " \t\v\r,"); + if (i) + { + name= (char*)malloc(i+1); + strncpy(name, start, i); + name[i]= '\0'; + } + start+= i; + start= skip_delims(start); + // skip delimiters + while (*start) + { + char *end, *param_str; + if (*start == '"') + { + // string + start++; + end= start; + while (*end && + *end != '"') + end++; + if (*end == '"') + end--; + else + simulator->cmd->printf("Unterminated string\n"); + param_str= (char *)malloc(end-start+2); + strncpy(param_str, start, 1+end-start); + param_str[1+end-start]= '\0'; + tokens->add(strdup(param_str)); + params->add(simulator->mk_cmd_str_arg(param_str)); + free(param_str); + if (*end) + end++; + if (*end == '"') + end++; + } + else + { + char *dot; + i= strcspn(start, " \t\v\r,"); + end= start+i; + param_str= (char *)malloc(i+1); + strncpy(param_str, start, i); + param_str[i]= '\0'; + tokens->add(strdup(param_str)); + if ((dot= strchr(param_str, '.')) != NULL) + { + // bit + class cl_cmd_arg *sfr, *bit; + *dot= '\0'; + dot++; + if (strchr("0123456789", *param_str) != NULL) + sfr= simulator->mk_cmd_int_arg((long long) + strtol(param_str, 0, 0)); + else + sfr= simulator->mk_cmd_sym_arg(param_str); + if (*dot == '\0') + { + bit= 0; + simulator->cmd->printf("Uncomplete bit address\n"); + } + else + { + if (strchr("0123456789", *dot) != NULL) + bit= simulator->mk_cmd_int_arg((long long) + strtol(dot, 0, 0)); + else + bit= simulator->mk_cmd_sym_arg(dot); + } + params->add(simulator->mk_cmd_bit_arg(sfr, bit)); + } + else if (strchr("0123456789", *param_str) != NULL) + { + // number + params->add(simulator->mk_cmd_int_arg((long long) + strtol(param_str, 0, 0))); + } + else + { + // symbol + params->add(simulator->mk_cmd_sym_arg(param_str)); + } + free(param_str); + } + start= end; + start= skip_delims(start); + } + return(0); +} + +int +cl_cmdline::shift(void) +{ + char *s= skip_delims(cmd); + + free(name); + name= NULL; + if (s && *s) + { + while (*s && + strchr(" \t\v\r,", *s) == NULL) + s++; + s= skip_delims(s); + char *p= strdup(s); + free(cmd); + cmd= p; + delete params; + params= new cl_list(2, 2); + split(); + } + return(name && *name); +} + +int +cl_cmdline::repeat(void) +{ + return(name && + *name == '\n'); +} + +class cl_cmd_arg * +cl_cmdline::param(int num) +{ + if (num >= params->count) + return(0); + return((class cl_cmd_arg *)(params->at(num))); +} + +void +cl_cmdline::insert_param(int pos, class cl_cmd_arg *param) +{ + if (pos >= params->count) + params->add(param); + else + params->add_at(pos, param); +} + + +/* + * Command + *____________________________________________________________________________ + */ + +cl_cmd::cl_cmd(class cl_sim *asim, + char *aname, + int can_rep, + char *short_hlp, + char *long_hlp): + cl_base() +{ + sim= asim; + names= new cl_strings(1, 1); + names->add(aname?strdup(aname):strdup("unknown")); + can_repeat= can_rep; + short_help= short_hlp?strdup(short_hlp):NULL; + long_help= long_hlp?strdup(long_hlp):NULL; +} + +/*cl_cmd::cl_cmd(class cl_sim *asim): + cl_base() +{ + sim= asim; + name= short_help= long_help= 0; + can_repeat= 0; +}*/ + +cl_cmd::~cl_cmd(void) +{ + delete names; + if (short_help) + free(short_help); + if (long_help) + free(long_help); +} + +void +cl_cmd::add_name(char *name) +{ + if (name) + names->add(strdup(name)); +} + +int +cl_cmd::name_match(char *aname, int strict) +{ + int i; + + if (names->count == 0 && + !aname) + return(1); + if (!aname) + return(0); + if (strict) + { + for (i= 0; i < names->count; i++) + { + char *n= (char*)(names->at(i)); + if (strcmp(aname, n) == 0) + return(1); + } + } + else + { + for (i= 0; i < names->count; i++) + { + char *n= (char*)(names->at(i)); + if (strstr(n, aname) == n) + return(1); + } + } + return(0); +} + +int +cl_cmd::name_match(class cl_cmdline *cmdline, int strict) +{ + return(name_match(cmdline->name, strict)); +} + +int +cl_cmd::syntax_ok(class cl_cmdline *cmdline) +{ + return(1); +} + +int +cl_cmd::work(class cl_cmdline *cmdline, class cl_console *con) +{ + if (!syntax_ok(cmdline)) + return(0); + return(do_work(cmdline, con)); +} + +int +cl_cmd::do_work(class cl_cmdline *cmdline, class cl_console *con) +{ + con->printf("Command \"%s\" does nothing.\n", (char*)(names->at(0))); + return(0); +} + + +/* + * Set of commands + *____________________________________________________________________________ + */ + +cl_cmdset::cl_cmdset(class cl_sim *asim): + cl_list(5, 5) +{ + sim= asim; + last_command= 0; +} + +class cl_cmd * +cl_cmdset::get_cmd(class cl_cmdline *cmdline) +{ + int i; + + if (cmdline->repeat()) + { + if (last_command) + return(last_command); + else + return(0); + } + // exact match + for (i= 0; i < count; i++) + { + class cl_cmd *c= (class cl_cmd *)at(i); + if (c->name_match(cmdline, 1)) + return(c); + } + // not exact match + class cl_cmd *c_matched= 0; + for (i= 0; i < count; i++) + { + class cl_cmd *c= (class cl_cmd *)at(i); + if (c->name_match(cmdline, 0)) + { + if (!c_matched) + c_matched= c; + else + return(0); + } + } + return(c_matched); + //return(0); +} + +void +cl_cmdset::del(char *name) +{ + int i; + + if (!name) + return; + for (i= 0; i < count; i++) + { + class cl_cmd *cmd= (class cl_cmd *)(at(i)); + if (cmd->name_match(name, 1)) + free_at(i); + } +} + +void +cl_cmdset::replace(char *name, class cl_cmd *cmd) +{ + int i; + + if (!name) + return; + for (i= 0; i < count; i++) + { + class cl_cmd *c= (class cl_cmd *)(at(i)); + if (c->name_match(name, 1)) + { + delete c; + put_at(i, cmd); + } + } +} + + +/* + * Composed command: subset of commands + *____________________________________________________________________________ + */ + +cl_super_cmd::cl_super_cmd(class cl_sim *asim, + char *aname, + int can_rep, + char *short_hlp, + char *long_hlp, + class cl_cmdset *acommands): + cl_cmd(asim, aname, can_rep, short_hlp, long_hlp) +{ + commands= acommands; +} + +cl_super_cmd::~cl_super_cmd(void) +{ + if (commands) + delete commands; +} + +int +cl_super_cmd::work(class cl_cmdline *cmdline, class cl_console *con) +{ + class cl_cmd *cmd; + + if (!commands) + return(0); + + if (!cmdline->shift()) + { + int i; + con->printf("\"%s\" must be followed by the name of a subcommand\n" + "List of subcommands:\n", (char*)(names->at(0))); + for (i= 0; i < commands->count; i++) + { + cmd= (class cl_cmd *)(commands->at(i)); + con->printf("%s\n", cmd->short_help); + } + return(0); + } + if ((cmd= commands->get_cmd(cmdline)) == NULL) + { + con->printf("Undefined subcommand: \"%s\". Try \"help %s\".\n", + cmdline->name, (char*)(names->at(0))); + return(0); + } + return(cmd->work(cmdline, con)); +} + + +/* + * Command console + *____________________________________________________________________________ + */ + +cl_console::cl_console(char *fin, char *fout, class cl_sim *asim): + cl_base() +{ + FILE *f; + + last_command= NULL; + sim= asim; + in= stdin; + if (fin) + if (f= fopen(fin, "r+"), in= f?f:stdin, !f) + fprintf(stderr, "Can't open `%s': %s\n", fin, strerror(errno)); + out= stdout; + if (fout) + if (f= fopen(fout, "w+"), out= f?f:stdout, !f) + fprintf(stderr, "Can't open `%s': %s\n", fout, strerror(errno)); + prompt= 0; +} + +cl_console::cl_console(FILE *fin, FILE *fout, class cl_sim *asim): + cl_base() +{ + last_command= NULL; + sim= asim; + in = fin; + out= fout; +} + +/* + * use the port number supplied to connect to localhost for + * (by Sandeep) + */ + +#ifdef SOCKET_AVAIL +static int +connect_to_port(int portnum) +{ + int sock= socket(AF_INET,SOCK_STREAM,0); + struct sockaddr_in sin; + + sin.sin_family = AF_INET; + sin.sin_port = htons(portnum); + sin.sin_addr.s_addr = inet_addr("127.0.0.1"); + + if (connect(sock, (struct sockaddr *)&sin, sizeof(sin))) { + fprintf(stderr, "Connect to port %d: %s\n", portnum, strerror(errno)); + return -1; + } + return sock; +} + +cl_console::cl_console(int portnumber, class cl_sim *asim) +{ + int sock= connect_to_port(portnumber); + + last_command= NULL; + sim= asim; + if (!(in= fdopen(sock, "r+"))) + fprintf(stderr, "cannot open port for input\n"); + if (!(out= fdopen(sock, "w+"))) + fprintf(stderr, "cannot open port for output\n"); + //fprintf(stderr, "init socket done\n"); +} +#endif + +int +cl_console::init(void) +{ + cl_base::init(); + welcome(); + flags&= ~CONS_PROMPT; + print_prompt(); + return(0); +} + +cl_console::~cl_console(void) +{ + if (in) + fclose(in); + if (out) + { + fprintf(out, "\n"); + fflush(out); + fclose(out); + } +#ifdef SOCKET_AVAIL + /* if (sock) + { + shutdown(sock, 2); + close(sock); + }*/ +#endif +} + + +/* + * Output functions + */ + +void +cl_console::welcome(void) +{ + fprintf(out, + "ucsim %s, Copyright (C) 1997 Daniel Drotos, Talker Bt.\n" + "ucsim comes with ABSOLUTELY NO WARRANTY; for details type " + "`show w'.\n" + "This is free software, and you are welcome to redistribute it\n" + "under certain conditions; type `show c' for details.\n", + VERSIONSTR); + fflush(out); +} + +void +cl_console::print_prompt(void) +{ + char *p; + + if (flags & (CONS_PROMPT|CONS_FROZEN)) + return; + flags|= CONS_PROMPT; + if (sim->arg_avail('P')) + putc('\0', out); + else + fprintf(out, "%s", prompt?prompt: + ((p= sim->get_sarg(0, "prompt"))?p:"> ")); + fflush(out); +} + +int +cl_console::printf(char *format, ...) +{ + va_list ap; + int ret= 0; + + if (out) + { + va_start(ap, format); + ret= cmd_do_print(out, format, ap); + va_end(ap); + } + return(ret); +} + +void +cl_console::print_bin(long data, int bits) +{ + long mask= 1; + + if (!out) + return; + mask= mask << ((bits >= 1)?(bits-1):0); + while (bits--) + { + fprintf(out, "%c", (data&mask)?'1':'0'); + mask>>= 1; + } +} + +/* + * Input functions + */ + +int +cl_console::match(int fdnum) +{ + if (in && + fileno(in) == fdnum) + return(1); + return(0); +} + +int +cl_console::get_in_fd(void) +{ + return(in?fileno(in):-1); +} + +int +cl_console::input_avail(void) +{ + struct timeval tv; + int i; + + if ((i= get_in_fd()) < 0) + return(0); + fd_set s; + FD_ZERO(&s); + FD_SET(i, &s); + tv.tv_sec= tv.tv_usec= 0; + i= select(i+1, &s, NULL, NULL, &tv); + return(i); +} + +char * +cl_console::read_line(void) +{ + char *s= NULL; + +#ifdef HAVE_GETLINE + if (getline(&s, 0, in) < 0) + return(0); +#else + +# ifdef HAVE_GETDELIM + size_t n= 30; + s= (char *)malloc(n); + if (getdelim(&s, &n, '\n', in) < 0) + { + free(s); + return(0); + } +# else + +# ifdef HAVE_FGETS + s= (char *)malloc(300); + if (fgets(s, 300, in) == NULL) + { + free(s); + return(0); + } +# endif +# endif +#endif + s[strlen(s)-1]= '\0'; + if (s[strlen(s)-1] == '\r') + s[strlen(s)-1]= '\0'; + flags&= ~CONS_PROMPT; + return(s); +} + +int +cl_console::proc_input(void) +{ + int retval; + + if (feof(in)) + { + fprintf(out, "End\n"); + return(1); + } + char *cmd= read_line(); + if (!cmd) + return(1); + if (flags & CONS_FROZEN) + { + sim->stop(resUSER); + flags&= ~CONS_FROZEN; + retval= 0; + } + else + retval= sim->do_cmd(cmd, this); + if (!retval) + print_prompt(); + free(cmd); + return(retval); +} + +/* + * Old version, sim->do_cmd() falls into this if it doesn't find a new + * command object which can handle enetered command + */ + +int +cl_console::interpret(char *cmd) +{ + fprintf(out, "New interpreter does not known this command\n"); + return(0); +} + + +/* + * This console listen on a socket and can accept connection requests + */ +#ifdef SOCKET_AVAIL + +cl_listen_console::cl_listen_console(int serverport, class cl_sim *asim) +{ + last_command= NULL; + sim= asim; + if ((sock= make_server_socket(serverport)) >= 0) + { + if (listen(sock, 10) < 0) + fprintf(stderr, "Listen on port %d: %s\n", + serverport, strerror(errno)); + } + in= out= 0; +} + +int +cl_listen_console::match(int fdnum) +{ + return(sock == fdnum); +} + +int +cl_listen_console::get_in_fd(void) +{ + return(sock); +} + +int +cl_listen_console::proc_input(void) +{ + int newsock; + uint size; + struct sockaddr_in sock_addr; + + size= sizeof(struct sockaddr); + newsock= accept(sock, (struct sockaddr*)&sock_addr, &size); + if (newsock < 0) + { + perror("accept"); + return(0); + } + if (!(in= fdopen(newsock, "r+"))) + fprintf(stderr, "cannot open port for input\n"); + if (!(out= fdopen(newsock, "w+"))) + fprintf(stderr, "cannot open port for output\n"); + sim->cmd->add_console(sim->cmd->mk_console(in, out, sim)); + in= out= 0; + return(0); +} + +#endif /* SOCKET_AVAIL */ + + +/* + * Command interpreter + *____________________________________________________________________________ + */ + +cl_commander::cl_commander(class cl_sim *asim): + cl_base() +{ + cons= new cl_list(1, 1); + actual_console= frozen_console= 0; + sim= asim; +} + +int +cl_commander::init(void) +{ + cl_base::init(); + if (!sim) + return(1); + if (sim->arg_avail('c')) + { + add_console(mk_console(sim->get_sarg('c', 0), + sim->get_sarg('c', 0), sim)); + } +#ifdef SOCKET_AVAIL + if (sim->arg_avail('Z')) + { + add_console(mk_console(sim->get_iarg(0, "Zport"), sim)); + } + if (sim->arg_avail('r')) + { + add_console(mk_console(sim->get_iarg('r', 0), sim)); + } +#endif + if (cons->get_count() == 0) + { + add_console(mk_console(stdin, stdout, sim)); + } + return(0); +} + +cl_commander::~cl_commander(void) +{ + delete cons; +} + +class cl_console * +cl_commander::mk_console(char *fin, char *fout, class cl_sim *asim) +{ + return(new cl_console(fin, fout, asim)); +} + +class cl_console * +cl_commander::mk_console(FILE *fin, FILE *fout, class cl_sim *asim) +{ + return(new cl_console(fin, fout, asim)); +} + +#ifdef SOCKET_AVAIL +class cl_console * +cl_commander::mk_console(int portnumber, class cl_sim *asim) +{ + return(new cl_listen_console(portnumber, asim)); +} +#endif + +void +cl_commander::add_console(class cl_console *console) +{ + console->init(); + cons->add(console); + set_fd_set(); +} + +void +cl_commander::del_console(class cl_console *console) +{ + cons->disconn(console); + set_fd_set(); +} + +void +cl_commander::set_fd_set(void) +{ + int i; + + FD_ZERO(&read_set); + fd_num= 0; + for (i= 0; i < cons->count; i++) + { + int fd; + class cl_console *c= (class cl_console*)(cons->at(i)); + if ((fd= c->get_in_fd()) >= 0) + { + if (fd > fd_num) + fd_num= fd; + FD_SET(fd, &read_set); + } + } + fd_num++; +} + + +/* + * Printing to all consoles + */ + +int +cl_commander::all_printf(char *format, ...) +{ + va_list ap; + int i, ret= 0; + + for (i= 0; i < cons->count; i++) + { + class cl_console *c= (class cl_console*)(cons->at(i)); + if (c->out) + { + va_start(ap, format); + ret= cmd_do_print(c->out, format, ap); + va_end(ap); + } + } + return(ret); +} + +/* + * Printing to actual_console + */ + +int +cl_commander::printf(char *format, ...) +{ + va_list ap; + int ret= 0; + + if (actual_console && + actual_console->out) + { + va_start(ap, format); + ret= cmd_do_print(actual_console->out, format, ap); + va_end(ap); + } + return(ret); +} + +/* + * Printing to consoles which have CONS_DEBUG flag set + */ + +int +cl_commander::debug(char *format, ...) +{ + va_list ap; + int i, ret= 0; + + for (i= 0; i < cons->count; i++) + { + class cl_console *c= (class cl_console*)(cons->at(i)); + if (c->out && + c->flags & CONS_DEBUG) + { + va_start(ap, format); + ret= cmd_do_print(c->out, format, ap); + va_end(ap); + } + } + return(ret); +} + +int +cl_commander::flag_printf(int iflags, char *format, ...) +{ + va_list ap; + int i, ret= 0; + + for (i= 0; i < cons->count; i++) + { + class cl_console *c= (class cl_console*)(cons->at(i)); + if (c->out && + (c->flags & iflags) == iflags) + { + va_start(ap, format); + ret= cmd_do_print(c->out, format, ap); + va_end(ap); + } + } + return(ret); +} + +int +cl_commander::input_avail(void) +{ + struct timeval tv; + int i; + + tv.tv_sec= tv.tv_usec= 0; + active_set= read_set; + i= select(fd_num/*FD_SETSIZE*/, &active_set, NULL, NULL, &tv); + return(i); +} + +int +cl_commander::input_avail_on_frozen(void) +{ + if (!frozen_console) + return(0); + return(frozen_console->input_avail()); +} + +int +cl_commander::wait_input(void) +{ + int i; + + active_set= read_set; + i= select(fd_num/*FD_SETSIZE*/, &active_set, NULL, NULL, NULL); + return(i); +} + +int +cl_commander::proc_input(void) +{ + int i; + + for (i= 0; i < fd_num/*FD_SETSIZE*/; i++) + if (FD_ISSET(i, &active_set)) + { + class cl_console *c; + int j; + for (j= 0; j < cons->count; j++) + { + c= (class cl_console*)(cons->at(j)); + if (c->match(i)) + { + actual_console= c; + int retval= c->proc_input(); + if (retval) + { + del_console(c); + delete c; + } + actual_console= 0; + return(cons->count == 0); + } + } + } + return(0); +} + + +/* End of newcmd.cc */ diff --git a/sim/ucsim/cmd.src/newcmdcl.h b/sim/ucsim/cmd.src/newcmdcl.h new file mode 100644 index 00000000..d384e7fe --- /dev/null +++ b/sim/ucsim/cmd.src/newcmdcl.h @@ -0,0 +1,229 @@ +/* + * Simulator of microcontrollers (cmdcl.h) + * + * Copyright (C) 1999,99 Drotos Daniel, Talker Bt. + * + * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu + * + */ + +/* This file is part of microcontroller simulator: ucsim. + +UCSIM is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +UCSIM is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with UCSIM; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. */ +/*@1@*/ + +#ifndef CMDCL_HEADER +#define CMDCL_HEADER + + +#include "ddconfig.h" + +#include +#if FD_HEADER_OK +# include HEADER_FD +#endif + +#include "pobjcl.h" + + +/* + * Command line with parameters + */ + +class cl_cmdline: cl_base +{ +public: + char *cmd; + char *name; + class cl_list *params; + class cl_ustrings *tokens; + +public: + cl_cmdline(char *cmd); + virtual ~cl_cmdline(void); + virtual int init(void); + + virtual int split(void); + virtual int shift(void); + virtual int repeat(void); + virtual class cl_cmd_arg *param(int num); + virtual void insert_param(int pos, class cl_cmd_arg *param); +private: + char *skip_delims(char *start); +}; + + +/* + * Command and container + */ + +// simple command +class cl_cmd: public cl_base +{ +public: + class cl_sim *sim; + class cl_strings *names; + int can_repeat; + char *short_help; + char *long_help; + +public: + cl_cmd(class cl_sim *asim, + char *aname, + int can_rep, + char *short_hlp, + char *long_hlp); + ~cl_cmd(void); + + virtual void add_name(char *name); + virtual int name_match(char *aname, int strict); + virtual int name_match(class cl_cmdline *cmdline, int strict); + virtual int syntax_ok(class cl_cmdline *cmdline); + virtual int work(class cl_cmdline *cmdline, class cl_console *con); + virtual int do_work(class cl_cmdline *cmdline, class cl_console *con); +}; + +// Command set is list of cl_cmd objects +class cl_cmdset: public cl_list +{ +public: + class cl_sim *sim; + class cl_cmd *last_command; + +public: + cl_cmdset(class cl_sim *asim); + + virtual class cl_cmd *get_cmd(class cl_cmdline *cmdline); + virtual void del(char *name); + virtual void replace(char *name, class cl_cmd *cmd); +}; + +// subset of commands +class cl_super_cmd: public cl_cmd +{ +public: + class cl_cmdset *commands; + +public: + cl_super_cmd(class cl_sim *asim, + char *aname, + int can_rep, + char *short_hlp, + char *long_hlp, + class cl_cmdset *acommands); + ~cl_super_cmd(void); + + virtual int work(class cl_cmdline *cmdline, class cl_console *con); +}; + + +/* + * Command console + */ + +class cl_console: public cl_base +{ +public: + class cl_sim *sim; + FILE *in, *out; + char *last_command; + int flags; // See CONS_XXXX + char *prompt; + +public: + cl_console(): cl_base() {} + cl_console(char *fin, char *fout, class cl_sim *asim); + cl_console(FILE *fin, FILE *fout, class cl_sim *asim); +#ifdef SOCKET_AVAIL + cl_console(int portnumber, class cl_sim *asim); +#endif + ~cl_console(void); + virtual int init(void); + + virtual void welcome(void); + virtual void print_prompt(void); + virtual int printf(char *format, ...); + virtual void print_bin(long data, int bits); + virtual int match(int fdnum); + virtual int get_in_fd(void); + virtual int input_avail(void); + virtual char *read_line(void); + virtual int proc_input(void); + virtual bool interpret(char *cmd); + virtual bool old_command(class cl_cmdline *cmdline) { return(FALSE); } +}; + +#ifdef SOCKET_AVAIL +class cl_listen_console: public cl_console +{ +public: + int sock; +public: + cl_listen_console(int serverport, class cl_sim *asim); + + virtual void welcome(void) {} + virtual void prompt(void) {} + + virtual int match(int fdnum); + virtual int get_in_fd(void); + virtual int proc_input(void); +}; +#endif + + +/* + * Command interpreter + */ + +class cl_commander: public cl_base +{ +public: + class cl_list *cons; + fd_set read_set, active_set; + int fd_num; + class cl_sim *sim; + class cl_console *actual_console, *frozen_console; + +public: + cl_commander(class cl_sim *asim); + ~cl_commander(void); + virtual int init(void); + + virtual class cl_console *mk_console(char *fin, char *fout, + class cl_sim *asim); + virtual class cl_console *mk_console(FILE *fin, FILE *fout, + class cl_sim *asim); +#ifdef SOCKET_AVAIL + virtual class cl_console *mk_console(int portnumber, class cl_sim *asim); +#endif + void add_console(class cl_console *console); + void del_console(class cl_console *console); + void set_fd_set(void); + + int all_printf(char *format, ...); // print to all consoles + int printf(char *format, ...); // print to actual_console + int debug(char *format, ...); // print consoles with debug flag set + int flag_printf(int iflags, char *format, ...); + int input_avail(void); + int input_avail_on_frozen(void); + int wait_input(void); + int proc_input(void); +}; + + +#endif + +/* End of cmdcl.h */ diff --git a/sim/ucsim/cmd.src/set.cc b/sim/ucsim/cmd.src/set.cc new file mode 100644 index 00000000..26ed424b --- /dev/null +++ b/sim/ucsim/cmd.src/set.cc @@ -0,0 +1,73 @@ +/* + * Simulator of microcontrollers (set.cc) + * + * Copyright (C) 1999,99 Drotos Daniel, Talker Bt. + * + * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu + * + */ + +/* This file is part of microcontroller simulator: ucsim. + +UCSIM is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +UCSIM is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with UCSIM; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. */ +/*@1@*/ + +#include "ddconfig.h" + +// sim +#include "simcl.h" + +// local +#include "cmdsetcl.h" + + +/* + * SET TIMER + */ + +int +cl_set_cmd::timer(class cl_cmdline *cmdline, class cl_console *con) +{ + class cl_cmd_arg *params[4]= { cmdline->param(0), + cmdline->param(1), + cmdline->param(2), + cmdline->param(3) }; + int what, dir; + class cl_ticker *ticker; + + if (params[1] == 0) + { + con->printf("Timer number is missing\n"); + return(0); + } + what= (params[1])->get_ivalue(); + if ((ticker= sim->uc->get_counter(what)) != 0) + { + con->printf("Timer %d already exists\n", what); + return(0); + } + if (params[2] != 0) + dir= (params[2])->get_ivalue(); + else + dir= 1; + ticker= new cl_ticker(dir, 0, 0); + sim->uc->add_counter(ticker, what); + + return(0); +} + + +/* End of set.cc */ diff --git a/sim/ucsim/cmd.src/syntax.cc b/sim/ucsim/cmd.src/syntax.cc new file mode 100644 index 00000000..76841e25 --- /dev/null +++ b/sim/ucsim/cmd.src/syntax.cc @@ -0,0 +1,31 @@ +/* + * Simulator of microcontrollers (syntax.cc) + * + * Copyright (C) 1999,99 Drotos Daniel, Talker Bt. + * + * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu + * + */ + +/* This file is part of microcontroller simulator: ucsim. + +UCSIM is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +UCSIM is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with UCSIM; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. */ +/*@1@*/ + +// local +#include "syntaxcl.h" + +/* End of syntax.cc */ diff --git a/sim/ucsim/cmd.src/syntaxcl.h b/sim/ucsim/cmd.src/syntaxcl.h new file mode 100644 index 00000000..57a2e015 --- /dev/null +++ b/sim/ucsim/cmd.src/syntaxcl.h @@ -0,0 +1,33 @@ +/* + * Simulator of microcontrollers (syntaxcl.h) + * + * Copyright (C) 1999,99 Drotos Daniel, Talker Bt. + * + * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu + * + */ + +/* This file is part of microcontroller simulator: ucsim. + +UCSIM is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +UCSIM is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with UCSIM; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. */ +/*@1@*/ + +#ifndef SYNTAXCL_HEADER +#define SYNTAXCL_HEADER + +#endif + +/* End of syntaxcl.h */ diff --git a/sim/ucsim/cmd.src/timer.cc b/sim/ucsim/cmd.src/timer.cc new file mode 100644 index 00000000..51f88748 --- /dev/null +++ b/sim/ucsim/cmd.src/timer.cc @@ -0,0 +1,266 @@ +/* + * Simulator of microcontrollers (timer.cc) + * + * Copyright (C) 1999,99 Drotos Daniel, Talker Bt. + * + * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu + * + */ + +/* This file is part of microcontroller simulator: ucsim. + +UCSIM is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +UCSIM is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with UCSIM; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. */ +/*@1@*/ + +#include "ddconfig.h" + +#include "stdio.h" +#include "i_string.h" + +// sim +#include "simcl.h" + +// local +#include "cmdsetcl.h" +#include "newcmdcl.h" + + +/* + * Command: timer + *---------------------------------------------------------------------------- + */ + +int +cl_timer_cmd::do_work(class cl_cmdline *cmdline, class cl_console *con) +{ + char *s; + + if (cmdline->param(0) == 0) + { + if (long_help) + con->printf("%s\n", long_help); + else + con->printf("What to do?\n"); + return(0); + } + if ((s= cmdline->param(0)->get_svalue())) + { + if (cmdline->param(1) == 0) + { + con->printf("Timer number is missing\n"); + return(0); + } + set_ticker(cmdline->param(1)); + if (strstr(s, "c") == s || + strstr(s, "m") == s || + strstr(s, "a") == s) + return(add(cmdline, con)); + else if (strstr(s, "d") == s) + return(del(cmdline, con)); + else if (strstr(s, "g") == s) + return(get(cmdline, con)); + else if (strstr(s, "r") == s) + return(run(cmdline, con)); + else if (strstr(s, "s") == s) + return(stop(cmdline, con)); + else if (strstr(s, "v") == s) + return(val(cmdline, con)); + else + con->printf("Undefined timer command: \"%s\". Try \"help timer\"\n", + s); + } + return(0); +} + +void +cl_timer_cmd::set_ticker(class cl_cmd_arg *param) +{ + if ((name= param->get_svalue()) == 0) + what= param->get_ivalue(); + if (name) + ticker= sim->uc->get_counter(name); + else + ticker= sim->uc->get_counter(what); +} + +/* + * Add a new timer to the list + */ + +int +cl_timer_cmd::add(class cl_cmdline *cmdline, class cl_console *con) +{ + class cl_cmd_arg *params[4]= { cmdline->param(0), + cmdline->param(1), + cmdline->param(2), + cmdline->param(3) }; + int dir= +1, in_isr= 0; + + if (!name && + what < 1) + { + con->printf("Timer id must be greater then zero or a string\n"); + return(0); + } + if (ticker) + { + if (name) + con->printf("Timer \"%s\" already exists\n", name); + else + con->printf("Timer %d already exists\n", what); + return(0); + } + if (params[2] != 0) + dir= (params[2])->get_ivalue(); + if (params[3] != 0) + in_isr= (params[3])->get_ivalue(); + + if (name) + { + ticker= new cl_ticker(dir, in_isr, name); + sim->uc->add_counter(ticker, name); + } + else + { + ticker= new cl_ticker(dir, in_isr, 0); + sim->uc->add_counter(ticker, what); + } + + return(0); +} + +/* + * Delete a timer from the list + */ + +int +cl_timer_cmd::del(class cl_cmdline *cmdline, class cl_console *con) +{ + if (!ticker) + { + if (name) + con->printf("Timer \"%s\" does not exist\n", name); + else + con->printf("Timer %d does not exist\n", what); + return(0); + } + if (name) + sim->uc->del_counter(name); + else + sim->uc->del_counter(what); + + return(0); +} + +/* + * Get the value of just one timer or all of them + */ + +int +cl_timer_cmd::get(class cl_cmdline *cmdline, class cl_console *con) +{ + if (ticker) + ticker->dump(what, sim->uc->xtal, con); + else + { + sim->uc->ticks->dump(0, sim->uc->xtal, con); + sim->uc->isr_ticks->dump(0, sim->uc->xtal, con); + sim->uc->idle_ticks->dump(0, sim->uc->xtal, con); + for (what= 0; what < sim->uc->counters->count; what++) + { + ticker= sim->uc->get_counter(what); + if (ticker) + ticker->dump(what, sim->uc->xtal, con); + } + } + + return(0); +} + +/* + * Allow a timer to run + */ + +int +cl_timer_cmd::run(class cl_cmdline *cmdline, class cl_console *con) +{ + if (!ticker) + { + if (name) + con->printf("Timer %d does not exist\n", name); + else + con->printf("Timer %d does not exist\n", what); + return(0); + } + ticker->options|= TICK_RUN; + + return(0); +} + +/* + * Stop a timer + */ + +int +cl_timer_cmd::stop(class cl_cmdline *cmdline, class cl_console *con) +{ + if (!ticker) + { + if (name) + con->printf("Timer %d does not exist\n", name); + else + con->printf("Timer %d does not exist\n", what); + return(0); + } + ticker->options&= ~TICK_RUN; + + return(0); +} + + +/* + * Set a timer to a specified value + */ + +int +cl_timer_cmd::val(class cl_cmdline *cmdline, class cl_console *con) +{ + class cl_cmd_arg *params[4]= { cmdline->param(0), + cmdline->param(1), + cmdline->param(2), + cmdline->param(3) }; + + if (!ticker) + { + if (name) + con->printf("Timer %d does not exist\n", name); + else + con->printf("Timer %d does not exist\n", what); + return(0); + } + if (params[2] == 0) + { + con->printf("Value is missing\n"); + return(0); + } + long val= (params[2])->get_ivalue(); + ticker->ticks= val; + + return(0); +} + + +/* End of timer.cc */ diff --git a/sim/ucsim/doc/Makefile.in b/sim/ucsim/doc/Makefile.in new file mode 100644 index 00000000..37486cb5 --- /dev/null +++ b/sim/ucsim/doc/Makefile.in @@ -0,0 +1,79 @@ +# +# uCsim doc/Makefile +# +# (c) Drotos Daniel, Talker Bt. 1997 +# + +STARTYEAR = 1997 + +SHELL = /bin/sh +INSTALL = @INSTALL@ + +PRJDIR = .. + +prefix = @prefix@ +exec_prefix = @exec_prefix@ +bindir = @bindir@ +libdir = @libdir@ +datadir = @datadir@ +includedir = @includedir@ +mandir = @mandir@ +man1dir = $(mandir)/man1 +man2dir = $(mandir)/man2 +infodir = @infodir@ +srcdir = @srcdir@ +docdir = $(prefix)/doc/ucsim + + +# Compiling entire program or any subproject +# ------------------------------------------ +all: doc + +doc: checkconf + +# Compiling and installing everything and runing test +# --------------------------------------------------- +install: all installdirs + cp *.html $(docdir) + cp *.gif $(docdir) + cp *.jpg $(docdir) + cp *.fig $(docdir) + + +# Deleting all the installed files +# -------------------------------- +uninstall: + rm -f $(docdir)/* + + +# Performing self-test +# -------------------- +check: + + +# Performing installation test +# ---------------------------- +installcheck: + + +# Creating installation directories +# --------------------------------- +installdirs: + test -d $(docdir) || $(INSTALL) -d $(docdir) + + +# Creating dependencies +# --------------------- +include clean.mk + +# My rules +# -------- + +# Remaking configuration +# ---------------------- +checkconf: + @if [ -f $(PRJDIR)/devel ]; then\ + $(MAKE) -f conf.mk srcdir="$(srcdir)" PRJDIR="$(PRJDIR)" freshconf;\ + fi + +# End of s51.src/Makefile.in diff --git a/sim/ucsim/doc/UCsim.jpg b/sim/ucsim/doc/UCsim.jpg new file mode 100644 index 00000000..57ee188e Binary files /dev/null and b/sim/ucsim/doc/UCsim.jpg differ diff --git a/sim/ucsim/doc/analyzer.html b/sim/ucsim/doc/analyzer.html new file mode 100644 index 00000000..08c91d97 --- /dev/null +++ b/sim/ucsim/doc/analyzer.html @@ -0,0 +1,35 @@ + + +UCSIM: Code Analyzer + + + + +

Code analyzer

+ +This feature is included into both DOS and UNIX versions. Code +analyzer analyzes the code of the simulated program and tries to +figure out which address contains valid instruction. Analyzer starts +analyzing of the code with address 0 which always must contain an +instruction because reset of the device sets zero into program +counter. So, analyzer marks address 0 that it contains an +instruction. Then it marks the address of the next instruction and so +on. If the analyzer finds a jump instruction it continues with +destination address of the jump instruction. If it finds a +call instruction, it recursively analyzes destination address +as well as next instruction follows the call one. Analyzator +stops if it finds an address which is already marked or if it finds a +return instruction or an indirect jump which is +impossible to follow. All these mean that it is impossible to discover +all instructions of the program. + +

This problem is solved in very simple way in UNIX version. If the +execution reaches an umarked address, the analyzer is called to +analyze the code starting at actual address pointed by the PC. This +method is not included into DOS version but this re-analyzation can be +requested by pressing Ctrl-F7 at any time. + +


+ + + diff --git a/sim/ucsim/doc/burst.gif b/sim/ucsim/doc/burst.gif new file mode 100644 index 00000000..fbdcf575 Binary files /dev/null and b/sim/ucsim/doc/burst.gif differ diff --git a/sim/ucsim/doc/clean.mk b/sim/ucsim/doc/clean.mk new file mode 100644 index 00000000..74b12cbe --- /dev/null +++ b/sim/ucsim/doc/clean.mk @@ -0,0 +1,22 @@ +# Deleting all files created by building the program +# -------------------------------------------------- +clean: + rm -f *core *[%~] *.[oa] + rm -f .[a-z]*~ + + +# Deleting all files created by configuring or building the program +# ----------------------------------------------------------------- +distclean: clean + rm -f Makefile *.dep + + +# Like clean but some files may still exist +# ----------------------------------------- +mostlyclean: clean + + +# Deleting everything that can reconstructed by this Makefile. It deletes +# everything deleted by distclean plus files created by bison, etc. +# ----------------------------------------------------------------------- +realclean: distclean diff --git a/sim/ucsim/doc/cmd.html b/sim/ucsim/doc/cmd.html new file mode 100644 index 00000000..84e7ec23 --- /dev/null +++ b/sim/ucsim/doc/cmd.html @@ -0,0 +1,90 @@ + + +Commands of s51 + + + + +

Command reference of ucsim

+ +General commands and information + + + +Execution + + + +Breakpoints + + + +Dump commands + + + +Set commands + + + +
+ + + diff --git a/sim/ucsim/doc/cmd_bp.html b/sim/ucsim/doc/cmd_bp.html new file mode 100644 index 00000000..ca7cefec --- /dev/null +++ b/sim/ucsim/doc/cmd_bp.html @@ -0,0 +1,206 @@ + + +Breakpoints commands of uCsim + + + + + + +

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
+> 
+ + +
+ + + diff --git a/sim/ucsim/doc/cmd_dump.html b/sim/ucsim/doc/cmd_dump.html new file mode 100644 index 00000000..3859e1e2 --- /dev/null +++ b/sim/ucsim/doc/cmd_dump.html @@ -0,0 +1,390 @@ + + +Dump commands of uCsim + + + + + + +

Dump commands of uCsim

+ +

[Repeatable] dis +[start [offset [lines]]]

+ +Disassemble code. This command can be used to list disassembled +instructions which discovered by the code analyzer. First two +parameters specify the address where the list starts. First parameter +is address where the command starts to search an instruction. This +search goes forward. When the first instruction marked by code +analyzer found the simulator skips as many instructions as you specify +in second parameter. If offset is negative the simulator goes +backward and skips specified number of instructions. Default value of +start parameter is last address which was listed by previous +dis command and default value of offset is -1. It means +you can make continuous list repeating parameterless dis +command. + +

In third parameter you can specify how many instructions you want +to list. Default value is 20. + +

+$ 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
+> bs f 0x180
+> bs d 0x189
+> dis 0x180 -3 10
+   000178 d9 fa    DJNZ  R1,0174
+   00017a 75 0b 00 MOV   0b,#00
+   00017d 75 0c 00 MOV   0c,#00
+F  000180 02 02 2a LJMP  022a
+   000183 78 22    MOV   R0,#22
+   000185 76 00    MOV   @R0,#00
+   000187 d8 fc    DJNZ  R0,0185
+D  000189 22       RET
+   00018a 90 09 ec MOV   DPTR,#09ec
+   00018d ae 83    MOV   R6,DPH
+> 
+ +If there is an F or D character at the beginning of the +line, it means that there is a fix or dynamic fetch breakpoint at +listed address. Next element on the list can be an asterix (*) +which means that the listed address is not marked by the code +analyzer. dis lists marked instructions only so asterix never +appears in the list. Next element of the list is address displayed as +six digit hexadecimal number. Address is followed by hexadecimal dump +of instruction's code. Last element of the list is disassembled +instruction. Every number appeared on the list is hexadecimal number. + + +

[Repeatable] dc +[start [stop]]

+ +Disassembled dump of code memory area. This command simply produces +disassambled list of memory area specified by the parameters. Default +value of start parameter is last address listed by previous +dc command. If stop parameter is not given 20 lines are +listed. + +
+$ 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
+> dc
+   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
+ * 000011 ff       MOV   R7,A
+ * 000012 ff       MOV   R7,A
+ * 000013 02 00 ac LJMP  00ac
+ * 000016 ff       MOV   R7,A
+ * 000017 ff       MOV   R7,A
+ * 000018 ff       MOV   R7,A
+ * 000019 ff       MOV   R7,A
+ * 00001a ff       MOV   R7,A
+ * 00001b ff       MOV   R7,A
+ * 00001c ff       MOV   R7,A
+> 
+ + +

[Repeatable] dch +[start [stop]]

+ +Hexadecimal dump of code memory area from address start to +address stop. Default value of start address is address of +following memory cell which was dumped by previous dch +command. If stop parameter is not given dch command +lists 10 lines 8 bytes per line. + +
+$ s51 remo.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
+> wc remo
+0013da 52 65 6d 6f             Remo
+> dch 0x13da
+0013da 52 65 6d 6f 20 00 56 65 Remo .Ve
+0013e2 72 73 69 6f 6e 20 31 2e rsion 1.
+0013ea 30 20 00 43 6f 70 79 72 0 .Copyr
+0013f2 69 67 68 74 20 28 63 29 ight (c)
+0013fa 20 00 31 39 39 34 2c 39  .1994,9
+001402 35 20 00 54 61 6c 6b 65 5 .Talke
+00140a 72 20 42 74 2e 00 53 75 r Bt..Su
+001412 6e 64 61 79 2e 00 4d 6f nday..Mo
+00141a 6e 64 61 79 2e 00 54 68 nday..Th
+001422 75 65 73 64 61 79 2e 00 uesday..
+> 
+ +First element in every lines is address of first byte dumped out in +the line. Next elements are hexadecimal values of bytes followed by +ASCII charactes of bytes dumped out in the line. If value of the +memory cell is not printable than a dot is dumped out. + + +

[Repeatable] di +[start [stop]]

+ +Hexadecimal dump of internal RAM area from address start to +address stop. Default value of start address is address of +following memory cell which was dumped by previous di +command. If stop parameter is not given di command +lists 10 lines 8 bytes per line. + +
+$ 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
+> sopt stopit 1
+> g
+Simulation started, PC=0x000000
+Stop at 000023: (5) Interrupt
+F 000023
+> di
+000000 18 02 16 ba 00 02 00 0a ........
+000008 00 00 00 00 00 00 00 00 ........
+000010 00 00 00 00 00 00 00 00 ........
+000018 4a 00 00 00 00 00 00 00 J.......
+000020 bc 27 06 2d 02 ee 35 8f .'.-..5.
+000028 31 e7 42 01 0e 01 0b 00 1.B.....
+000030 ec 0b 7f 10 7f a9 7e 08 ......~.
+000038 fe 03 09 00 00 00 af 08 ........
+000040 af 08 00 00 00 00 00 00 ........
+000048 00 00 00 00 00 00 00 00 ........
+> 
+ + +

[Repeatable] dx +[start [stop]]

+ +Hexadecimal dump of external RAM area from address start to +address stop. Default value of start address is address of +following memory cell which was dumped by previous dx +command. If stop parameter is not given dx command +lists 10 lines 8 bytes per line. + +
+$ 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
+> sopt stopit 1
+> g
+Simulation started, PC=0x000000
+Stop at 000023: (5) Interrupt
+F 000023
+> dx 0x100
+000100 00 00 00 00 00 00 00 00 ........
+000108 00 00 00 00 00 00 00 00 ........
+000110 00 00 00 00 00 00 00 00 ........
+000118 00 00 00 00 00 00 00 00 ........
+000120 00 00 00 00 00 00 00 00 ........
+000128 00 00 00 00 00 00 00 44 .......D
+000130 61 6e 69 00 00 00 02 02 ani.....
+000138 07 00 00 ff 00 00 07 cb ........
+000140 08 0c 32 00 07 cb 06 05 ..2.....
+000148 02 00 24 00 00 00 00 00 ..$.....
+> 
+ + +

dp

+ +Dump out ports. This command shows actual value of ports. + +
+$ 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
+> sopt stopit 1
+> g
+5
+ * 000023 02 01 1c LJMP  011c
+> dp
+P0    11111111 0xff 255 .    P1    11111110 0xfe 254 .
+Pin0  11111111 0xff 255 .    Pin1  11111111 0xff 255 .
+Port0 11111111 0xff 255 .    Port1 11111110 0xfe 254 .
+
+P2    11111111 0xff 255 .    P3    11111111 0xff 255 .
+Pin2  11111111 0xff 255 .    Pin3  11111111 0xff 255 .
+Port2 11111111 0xff 255 .    Port3 11111111 0xff 255 .
+> 
+ +First lines on the list (labeled with Px) are value of SFRs which are +internal latch registers. Second lines (labeled with Pinx) are outputs +of external devices connected to port pins of the +microcontroller. These values can be set by you using sp command. Third lines (labeled with Portx) +show actual values can be measured on pins of the device. These values +are calculated with following pseudo formula: + +

Portx= Px AND Pinx + +

All three values are displayed in binary, hexadecimal, decimal form +and then the ASCII character of the value is shown. + + +

ds [addr...]

+ +Print out SFR. This command can be used to get value of all or some +SFRs. If you do not specify any parameter the ds command simply +dumps out full SFR area 16 bytes per line. + +
+$ 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
+> sopt stopit 1
+> g
+5
+ * 000023 02 01 1c LJMP  011c
+> ds
+000080 ff 2a ba 16 00 00 00 00 55 a1 d7 fe 50 fd 00 00 .*......U...P...
+000090 fe 00 00 00 00 00 00 00 7e 00 00 00 00 00 00 00 ........~.......
+0000a0 ff 00 00 00 00 00 00 00 97 00 00 00 00 00 00 00 ................
+0000b0 ff 00 00 00 00 00 00 00 15 00 00 00 00 00 00 00 ................
+0000c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+0000d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+0000e0 0a 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+0000f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+> ds p1 0x87
+    P1 fe 254 .
+000087 00   0 .
+> ds p2 ip scon
+    P2 ff 255 .
+    IP 15  21 .
+  SCON 7e 126 ~
+> 
+ +If you specify one or more parameter the ds command prints out +value of registers specified by parameters. Parameter can be an +address or a symbolic name of the register. Note that the simulator +implements a register at all address in the address space which is not +true in real microcontroller where reading of an unimplemented +register gets undefined value. Value of the registers printed out in +hexadecimal, decimal, and ASCII form. + +

Note that different type of controllers can implement different +registers: + +

+$ s51
+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.
+> ds rcap2l
+> q
+$ s51 -t 52
+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.
+> ds rcap2l
+RCAP2L 00   0 .
+> 
+ + +

[Repeatable] db +addr...

+ +Dump bits. This command can be used to get value of bits. At least one +parameter must be given. Bit address can be specified in three +forms. First of all name of the bit can be used if it has any. Direct +bit address is accepted too and it can be specified by address of IRAM +or SFR which contains the bit and bit number within the byte separated +by a dot. If the requested bit is in an SFR the address of the +register can be specified by its name. + +
+$ s51
+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.
+> db it1 0x20.3 0x43 p2.5
+000088    IT1 0
+000020   20.3 0
+000028   28.3 0
+0000a0   P2.5 1
+> 
+ +Value of bits are printed out one per line. The list starts direct +address of the bit followed by bit name or address of the memory cell +or SFR which contains the displayed bit and bit number within the byte +separated by a dot. At last the value of the bit is shown. Displaying +a port bit you get value of SFR latch: + +
+> sp 1 0x0f
+> ss p1 0x55
+000090 55                                              U
+> dp
+P0    11111111 0xff 255 .    P1    01010101 0x55  85 U
+Pin0  11111111 0xff 255 .    Pin1  00001111 0x0f  15 .
+Port0 11111111 0xff 255 .    Port1 00000101 0x05   5 .
+
+P2    11111111 0xff 255 .    P3    11111111 0xff 255 .
+Pin2  11111111 0xff 255 .    Pin3  11111111 0xff 255 .
+Port2 11111111 0xff 255 .    Port3 11111111 0xff 255 .
+> db p1.2 p1.3 p1.4 p1.5 p1.6
+000090   P1.2 1
+000090   P1.3 0
+000090   P1.4 1
+000090   P1.5 0
+000090   P1.6 1
+> 
+ + +
+ + + diff --git a/sim/ucsim/doc/cmd_exec.html b/sim/ucsim/doc/cmd_exec.html new file mode 100644 index 00000000..624daa46 --- /dev/null +++ b/sim/ucsim/doc/cmd_exec.html @@ -0,0 +1,227 @@ + + +Execution commands of uCsim + + + + + +

Execution commands of uCsim

+ + +

g [start [stop]]

+ +Go, start execution. Parameters are optional. First parameter +specifies start address of the execution. By default execution starts +at address specified by actual value of the PC. This can be overridden +by first parameter. If second parameter is specified it places a +dynamic breakpoint at specified address which stops the execution. If +stop address is not given the simulator stops if it reaches a +breakpoint, or the CPU accepts an interrupt and stopit option +is TRUE, or fatal error occures or stop command is +used. Note that first instruction is executed without effect of +breakpoints. It means that if there is a breakpoint at start address +then it will not be hit. + +
+$ 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.
+55755 bytes read from remoansi.hex
+> b 0x187
+> sopt stopit y
+> g
+Simulation started, PC=0x000000
+Stop at 000187: (4) Breakpoint
+F 000187
+> 
+ +After execution is started the Simulaton started message +appears with value of PC where the execution started and the simulator +is ready to accept other commands while the simulation is running in +background. + + + + +

stop

+ +This command stops the simulation, it freezes the CPU and all the +peripherials. + +
+$ 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
+> g
+Simulation started
+> dr
+000000 00 01 00 14 00 00 5a 47 ......ZG
+000000 00 .  ACC= 0x47  71 G  B= 0x01   DPTR= 0x001c @DPTR= 0x47  71 G
+000001 01 .  PSW= 0x00 CY=0 AC=0 OV=0 P=0
+   006f02 90 00 1e MOV   DPTR,#001e
+> stop
+   006ac5 24 a5    ADD   A,#a5
+> 
+
+ +Simulated program is executed in background and the simulator accepts +commands. If it stopped by the stop command the instruction pointed by +PC is dissassembled, see the dis command for +description of disassembled form. + + +

[Repeatable] s +[step]

+ +Step command. It executes one instruction without effect of +breakpoints. Optional parameter can specify number of requested +steps. + +
+$ 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
+> s
+000000 00 00 00 00 00 00 00 00 ........
+000000 00 .  ACC= 0x00   0 .  B= 0x00   DPTR= 0x0000 @DPTR= 0x00   0 .
+000000 00 .  PSW= 0x00 CY=0 AC=0 OV=0 P=0
+   000160 c2 90    CLR   P1.0
+> s 2
+000000 00 00 00 00 00 00 00 00 ........
+000000 00 .  ACC= 0x00   0 .  B= 0x00   DPTR= 0x0000 @DPTR= 0x00   0 .
+000000 00 .  PSW= 0x00 CY=0 AC=0 OV=0 P=0
+   000162 c2 97    CLR   P1.7
+000000 00 00 00 00 00 00 00 00 ........
+000000 00 .  ACC= 0x00   0 .  B= 0x00   DPTR= 0x0000 @DPTR= 0x00   0 .
+000000 00 .  PSW= 0x00 CY=0 AC=0 OV=0 P=0
+   000164 d2 b5    SETB  P3.5
+> 
+ +After execution of actual instruction pointed by PC the step +command executes dr command. + + +

[Repeatable] n +[step]

+ +Execute until next instruction is reached. This command is similar to +step command described above but if actual +instruction to execute is a subroutine call the next command +places a dynamic breakpoint after the call instruction and starts to +execute the subroutine. If the subroutine is infinite the breakpoint +set by next will never reached. It can be a dangerous situation +because the executeion started by the next command can not be +stopped interactively. But it can be stopped by other breakpoints. + +
+$ 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
+> g 0 0x172
+4
+   000172 79 04    MOV   R1,#04
+> dis 0x172 0 5
+   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
+> n 3
+000000 00 04 00 00 00 00 00 00 ........
+000000 00 .  ACC= 0x00   0 .  B= 0x00   DPTR= 0x0000 @DPTR= 0x00   0 .
+000004 00 .  PSW= 0x00 CY=0 AC=0 OV=0 P=0
+   000174 12 0d b8 LCALL 0db8
+000000 00 04 00 00 00 00 00 00 ........
+000000 00 .  ACC= 0x00   0 .  B= 0x00   DPTR= 0x0167 @DPTR= 0x00   0 .
+000004 00 .  PSW= 0x00 CY=0 AC=0 OV=0 P=0
+   000177 0f       INC   R7
+000000 00 04 00 00 00 00 00 01 ........
+000000 00 .  ACC= 0x00   0 .  B= 0x00   DPTR= 0x0167 @DPTR= 0x00   0 .
+000004 00 .  PSW= 0x00 CY=0 AC=0 OV=0 P=0
+   000178 d9 fa    DJNZ  R1,0174
+> 
+ + +

pc [address]

+ +Using this command without any parameter it simply dumps out +instruction pointed by the PC. Specify address if you want to set the +PC. + +
+$ s51
+S51 0.1.5, Copyright (C) 1997 Daniel Drotos, Talker Bt.
+S51 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.
+> pc
+ * 000000 ff       MOV   R7,A
+> pc 123
+ * 00007b ff       MOV   R7,A
+> sopt debug t  
+> pc 32
+Warning: maybe not instruction at 000020
+ * 000020 ff       MOV   R7,A
+> 
+ + +

run

+ +This command starts the execution of the simulated program. + + +
+ + + diff --git a/sim/ucsim/doc/cmd_general.html b/sim/ucsim/doc/cmd_general.html new file mode 100644 index 00000000..b7031cc7 --- /dev/null +++ b/sim/ucsim/doc/cmd_general.html @@ -0,0 +1,659 @@ + + +General commands of uCsim + + + + +

General commands of uCsim

+ + + +Some commands can be repeated by entering an empty command (just +pressing ENTER if command console is interactive). This repeats the +full command entered previously precisely including parameters +of the command. Repeatable commands are signed with [Repeatable] icon. + +

Some commands accept parameters which in most cases can be +numbers. Numbers can be entered in C-style form. If the number begins +whith 0x or 0X it is interpreted as a +hexadecimal number. If it begins with 0 followed by +digits it is interpreted as octal number. In other cases it is +interpreted as decimal number. + +

Every command which changes content of ROM area such as l, dl or sc deletes result of code analyzer and causes to +re-analyze the code. + + +

show c|w

+ +This command can be used to list licensing information. If c +option has given, the license is listed. It is first 10 point of the +version 2 of GNU Genral Public License. Using w parameter the +command prints out last 2 point of the license ("NO WARRANTY" +message). If you do not accept GPL simply do not use the program. + + +

download,dl

+ +Download command. It is same as load above but it +reads information from command console which is standard input by +default. This command stops read records when it detects an "END" +record which is normaly the last record. This command has two +equivalent forms download and dl. + +
+$ s51 -V
+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.
+> do
+:03000000020003F8
+:1000030075812078207600D8FC900000AE83AF8203
+:100013009000001200416005E4F0A380F690009F79
+:1000230012004A9000A312004A9000A712006890A1
+:1000330000AD12006875D0001200B50200B3EF6581
+:10004300827003EE658322E493F8740193F97402DA
+:1000530093FE740393F5828E83E869700122E4931F
+:10006300F6A30880F4E493FC740193FD740293FEF9
+:10007300740393FF740493F8740593F582888312D1
+:100083000041700122E493A3A883A9828C838D820B
+:10009300F0A3AC83AD828883898280E3212100B5FC
+:1000A300212100B5000000B500B5000000B500B582
+:0200B30080FECD
+:1000B5007520117501AA850120750102850120228F
+:00000001FF
+197 bytes loaded
+> 
+ + +

quit

+ +Quit. This command terminates actual console, it does not ask you to +confirm your intention. Simulator always reads commands from a file so +end of file condition finishes too. If command console is on standard +input/output, pressing the CTRL-D will quit just like the quit +command. + +

Note that if -Z option was used at +invokation then the quit command does not terminate the simulator +program. In this case kill command can be used to +terminate the simulator. See for more information about using multiple consoles. + +

$ s51
+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.
+> q
+$ 
+ + +

kill

+ +This kommand terminates the simulator. It does not ask for +confirmation. It doesn't matter how many consoles are used and what +commands are running on them. + + +

help,?

+ +Help command. It prints out short description of the commands. + + +

reset

+ +Reset command. It resets the microcontroller. It has same effect as +active signal on the RST pin. + +
+$ s51 -V 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
+> dr
+000000 00 00 00 00 00 00 00 00 ........
+000000 00 .  ACC= 0x00   0 .  B= 0x00   DPTR= 0x0000 @DPTR= 0x00   0 .
+000000 00 .  PSW= 0x00 CY=0 AC=0 OV=0 P=0
+   000000 02 01 60 LJMP  0160
+> s 2
+000000 00 00 00 00 00 00 00 00 ........
+000000 00 .  ACC= 0x00   0 .  B= 0x00   DPTR= 0x0000 @DPTR= 0x00   0 .
+000000 00 .  PSW= 0x00 CY=0 AC=0 OV=0 P=0
+   000160 c2 90    CLR   P1.0
+000000 00 00 00 00 00 00 00 00 ........
+000000 00 .  ACC= 0x00   0 .  B= 0x00   DPTR= 0x0000 @DPTR= 0x00   0 .
+000000 00 .  PSW= 0x00 CY=0 AC=0 OV=0 P=0
+   000162 c2 97    CLR   P1.7
+> res
+> dr
+000000 00 00 00 00 00 00 00 00 ........
+000000 00 .  ACC= 0x00   0 .  B= 0x00   DPTR= 0x0000 @DPTR= 0x00   0 .
+000000 00 .  PSW= 0x00 CY=0 AC=0 OV=0 P=0
+   000000 02 01 60 LJMP  0160
+> 
+ + +

wi,Wi string

+ +Searching for specified string in internal RAM area. String is +interpreted from first non-space sharacter until end of the command +including spaces. wi command makes case insensitive search and +Wi can be used to make case sensitive search. Result is a hexa +dump of memory areas that match with specified string. Most of C-style +escape sequences can be used in the string: \f, \n, +\r, \t, \v, \a, \b, +\0, and \0xxx where xxx is an octadecimal +number of the code of the character. + +
+$ 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
+> g
+Simulation started, PC=0x000000
+
+Stop at 00019c: (7) User stopped
+F 00019c
+> si 20 Dani DAni
+000014 44 61 6e 69 44 41 6e 69                         DaniDAni
+> wi dani
+000014 44 61 6e 69             Dani
+000018 44 41 6e 69             DAni
+> Wi Dani
+000014 44 61 6e 69             Dani
+> wi dani\0
+000018 44 41 6e 69 00          DAni.
+> 
+ + +

wx,Wx string

+ +Search commands. These commands are similar to wi, +Wi commands the only difference is that wx,Wx are used +to search for a string in external memory. + + +

wc,Wc string

+ +Search commands. These commands are similar to wi, +Wi commands the only difference is that wx,Wx are used +to search for a string in code memory area. + + +

gopt [opt]

+ +Get actual value of option(s). Some options can be set by sopt to modify behavior of the +simulator. Using gopt you can get actual value of these +options. If you use this command without parameter you get list of all +options known by the program. In this way you can figure out which +options can be used. + +
+$ s51 -V
+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.
+> gopt
+verbose TRUE Verbose flag.
+stopit FALSE Stop if interrupt accepted.
+debug FALSE Debug flag.
+> gopt stopit
+stopit FALSE Stop if interrupt accepted.
+> 
+ +This version of the simulator knows about three options. First element +of the list is name of the option (verbose, debug and +stopit). This name can be used to identify the option in +gopt and sopt command. Second +element of the list is the value of the option. In this case type of +both options is boolean, their value can be TRUE or FALSE. Third +element is a short description of the option. + +
verbose
? + +
debug
Debug flag can be set by -V option of the +program to TRUE otherwise its default value is FALSE. If it is TRUE, +the simulator prints out short messages about important events. + +
stopit
Setting this option to TRUE (default value is +FALSE) forces execution to stop every time when CPU accepts an +interrupt. You do not have to use breakpoints to inspect interrupts. + +
+ + +

sopt opt value

+ +Set option value. Options described at previous command (gopt) can be set using this command. First +parameter must be an option name and second the new +value. Interpretation of the value depends on type of the +option. Value for a boolean type of option interpreted as follows: if +first character of the value is one of 1, t, +T, y, Y then value will be TRUE otherwise +it will be FALSE. + +
+$ s51 -V
+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.
+> gopt
+verbose TRUE Verbose flag.
+stopit FALSE Stop if interrupt accepted.
+debug FALSE Debug messages appears on this console.
+> sopt debug t
+> gopt
+verbose TRUE Verbose flag.
+stopit FALSE Stop if interrupt accepted.
+debug TRUE Debug messages appears on this console.
+> 
+ + +

conf

+ +This command prints out configuration of the simulator: + +
+> conf
+ucsim version 0.2.37
+Type of microcontroller: 51 CMOS
+Controller has 8 hardware element(s).
+  timer0[0]
+  timer1[1]
+  uart[0]
+  port[0]
+  port[1]
+  port[2]
+  port[3]
+  irq[0]
+Memories:
+  ROM  size= 0x010000 65536
+  XRAM size= 0x010000 65536
+  IRAM size= 0x000100 256
+  SFR  size= 0x000100 256
+> 
+
+ +First line contains version number of the program. Second line informs +about type of the simulated microcontroller. Third line prints out how +many hardware elements are simulated. Following lines contain +information about memories. Note that size of the simulated memory +segment can be bigger than size of addressable part of the memory as +you see above SFR type of the memory has bigger simulated than +addressable size. + + +

state

+ +State of the simulator and the simulated microcontroller: + +
+> state
+CPU state= OK PC= 0x004349 XTAL= 1.10592e+07
+Total time since last reset= 0.614873 sec (6800004 clks)
+Time in isr = 0.0144227 sec (159504 clks) 2.3%
+Time in idle= 0 sec (0 clks)   0%
+Max value of stack pointer= 0x000049, avg= 0x000026
+> 
+
+ +The "CPU state" in the first line is an internal information. PC is +value of the program counter. First line shows XTAL frequency too. + +

Following lines contain information about simulated time. First, +full simulated time (elapsed from last reset) is printed out in +seconds and number of clock periods then same data is printed out +about time spent in interrupt service routines as well as in idle +mode. Last data in lines of ISR and IDLE time shows ratio of ISRs, +Idle times and main program. + +

Last line infroms about maximum value of the stack pointer and a +"not very well" calculated average value of it. + + +

file,load "FILE"

+ +Loads file named FILE into the simulated code memory. File must +contain data in Intel HEX format. + +
+> file "../../remo.hex"
+55470 words read from ../../remo.hex
+> 
+
+ +Don't forget to enclose file name in quotes to make the parameter to +be a string. + + +

info

+ +This command prints out information about different things which must +be specified as paramater to the command. Following subcommands are +known: + +

info breakpoints +
info registers +
info hardware + + +

info breakpoints

+ +This subcommand prints out information about breakpoints: + +
+> b 12
+Breakpoint 1 at 0x00000c: MOV   R7,A
+> tb 43
+Breakpoint 2 at 0x00002b: MOV   R7,A
+> bse ws f 0x80
+> i b
+Num Type       Disp Hit   Cnt   Address  What
+1   fetch      keep 1     1     0x00000c MOV   R7,A
+2   fetch      del  1     1     0x00002b MOV   R7,A
+1   event      keep 1     1     0x000080 ws
+> 
+
+ +As you see above, the command can be shortened to "i b". The list of +breakpoints contains 7 columns: + +
Num
Number of the breakpoint. Normal and event +breakpoints are numbered separately. + +
Type
This column shows type of the breakpoint. It can +be fetch for normal breakpoints or event for event +breakpoints. First the normal breakpoints are listed and then the +event breakpoints. + +
Disp
This shows if the breakpoint is temporary +(del) or not (keep). + +
Hit
How many times the breakpoint must be hit before it +really stops the program. + +
Cnt
Counter of breakpint hits. This counter decrements +and the breakpoint is activated if it reaches zero. + +
Address
Address where the breakpoint is set. + +
What
For normal breakpoints this field contains +disassembled instruction where the breakpoint is set. For event +breakpoints it contains type of event. + +
+ +

info registers

+ +This subcommand prints out full register set of the CPU. Output of +this command depends of type of CPU. + +
Registers of MCS51 family
+ +
+$ 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
+> sopt stopit 1
+> g
+5
+ * 000023 02 01 1c LJMP  011c
+> i r
+000000 18 02 16 ba 00 02 00 0a ........
+000018 4a J  ACC= 0x0a  10 .  B= 0x00   DPTR= 0x16ba @DPTR= 0x00   0 .
+000002 16 .  PSW= 0x00 CY=0 AC=0 OV=0 P=0
+ * 000023 02 01 1c LJMP  011c
+> 
+ +In first line the actual register bank is dumped out. Register banks +reside in internal RAM, address at the begining of the line shows +start address of actual register bank selected by RS0 and RS1 bits of +PSW register. + +

Next two lines begin with value of indirectly addressed internal +RAM cells. Second line shows IRAM cell pointed by R0 while third line +shows IRAM addressed by R1. + +

Second line displays some important registers. First one is the +accumulator. Its value dumped out in hexadecimal, decimal form and +then the ASCII character of its value. It is followed by value of the +B register which is dumped out in hexadecimal form only. Next is DPTR +register in hexadecimal and then external RAM cell which is addressed +by DPTR. This is dumped out in hexadecimal, decimal and ASCII too. + +

In third line you find program status word in hexadecimal and then +some flag bits of PSW register. Last line is disassembled instruction +at PC. + +

Registers of AVR family
+ +
+$ savr test_arith.hex
+ucsim 0.2.37, 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.
+> 83 words read from test_arith.hex
+83 words read from test_arith.hex
+> run
+
+Stop at 0x000047: (105) User stopped
+F 0x000047
+> i r
+000000 00 2c 21 23 20 35 19 14 03 00 00 00 00 00 00 00 .,!# 5..........
+000010 00 01 1e 89 01 00 10 e2 14 00 01 10 00 00 00 00 ................
+ITHSVNZC  SREG= 0x03   3 .
+00000011  SP  = 0x000000
+X= 0x1001 [X]= 0x00   0 .  Y= 0x0000 [Y]= 0x00   0 .  Z= 0x0000 [Z]= 0x00   0 .
+ * 000047 940c 0047 jmp   0x000047
+> 
+
+ +First two lines show first 32 bytes of internal RAM which is the +register set of AVR controllers. + +

At the beginning of next two lines bits of status register are +printed. These lines present hexadecimal, decimal and ASCII values of +the status register too, and value of the stack pointer. + +

Following line shows indirect addressing registers X, Y, and Z as +well as pointed memory values. + +

Last line is disassembled instruction ap PC. + +

info hardware|hw cathegory [id]

+ +This subcommand prints out information about a unit of the +controller. Cathegory can be: + +
  • timer +
  • uart +
  • port +
  • pca +
  • interrupt +
  • wdt +
+ +Ouput format of this command depends on CPU family and type of the CPU +too because requested unit can be different in different type of +controller even in the same CPU family. + +
+$ s51 -t 51
+ucsim 0.2.36, 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.
+> i h t
+timer0[0] 0x0000 13 bit timer OFF irq=0 dis prio=0
+timer1[1] 0x0000 13 bit timer OFF irq=0 dis prio=0
+> 
+
+ +Timer #2 differs a little bit from other timers of MCS51: + +
+$ s51 -t 52
+ucsim 0.2.36, 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.
+> i h t
+timer0[0] 0x0000 13 bit timer OFF irq=0 dis prio=0
+timer1[1] 0x0000 13 bit timer OFF irq=0 dis prio=0
+timer2[2] 0x0000 reload 0x0000 timer OFF irq=0 dis prio=0
+> 
+
+ +

If the controller contains more than one unit of a cathegory, then +optional id parameter can be used to select a specific one. If +id is not used then information is printed about all units +belonging to specified cathegory. + +

+> i h t 1
+timer1[1] 0x0000 13 bit timer OFF irq=0 dis prio=0
+> 
+
+ +It is possible that there is no unit belonging to some cathegory. It +is also possible that the specific unit exists but information command +of that unit is not implemented, in this case you have to check SFRs +of the unit... + +
+> i h pca
+> 
+
+ +Information you can get about units of MCS51 controllers: + +
+$ s51 -t 251 
+ucsim 0.2.37, 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.
+> g
+Simulation started, PC=0x000000
+
+Stop at 0x000023: (105) User stopped
+F 0x000023
+> i h t
+timer0[0] 0xaa8d 16 bit timer ON irq=0 en prio=0
+timer1[1] 0xfdff 8 bit autoreload timer ON irq=1 dis prio=0
+timer2[2] 0x0000 reload 0x0000 timer OFF irq=0 dis prio=0
+> i h u
+uart[0] 8 bit UART timer clocked MultiProc=none irq=en prio=1
+Receiver ON RB8=1 irq=0
+Transmitter TB8=1 irq=1
+> i h po
+port[0]
+P0    11111111 0xff 255 . (Value in SFR register)
+Pin0  11111111 0xff 255 . (Output of outside circuits)
+Port0 11111111 0xff 255 . (Value on the port pins)
+port[1]
+P1    11111111 0xff 255 . (Value in SFR register)
+Pin1  11111111 0xff 255 . (Output of outside circuits)
+Port1 11111111 0xff 255 . (Value on the port pins)
+port[2]
+P2    11111111 0xff 255 . (Value in SFR register)
+Pin2  11111111 0xff 255 . (Output of outside circuits)
+Port2 11111111 0xff 255 . (Value on the port pins)
+port[3]
+P3    11111111 0xff 255 . (Value in SFR register)
+Pin3  11111111 0xff 255 . (Output of outside circuits)
+Port3 11111111 0xff 255 . (Value on the port pins)
+> i h i
+Interrupts are enabled. Interrupt sources:
+  Handler  En  Pr Req Act Name
+  0x000003 en   1 no  act external #0
+  0x00000b en   0 no  act timer #0
+  0x000013 en   1 no  act external #1
+  0x00001b dis  0 YES act timer #1
+  0x000033 dis  0 no  act PCA counter
+  0x000033 dis  0 no  act PCA module #0
+  0x000033 dis  0 no  act PCA module #1
+  0x000033 dis  0 no  act PCA module #2
+  0x000033 dis  0 no  act PCA module #3
+  0x000033 dis  0 no  act PCA module #4
+  0x000023 en   1 YES act serial transmit
+  0x000023 en   1 no  act serial receive
+  0x00002b dis  0 no  act timer #2 TF2
+  0x00002b dis  0 no  act timer #2 EXF2
+Active interrupt service(s):
+  Pr Handler  PC       Source
+   1 0x000023 0x003672 serial transmit
+>
+
+ + +

timer a|d|g|r|s|v id [value]

+ +Handling of timers. First parameter of timer command determines the +operation which can be + +
add (or simply a)
to create a new timer. New timers +are turned ON by default and initialized to value 0. + +
del (or simply d)
to remove a timer if you don't need +it any more. + +
get (or simply g)
to get value of timers. See comment +below. + +
run (or simply r)
to turn a timer ON. + +
stop (or simply s)
to turn a timer OFF. It still exist +but doesn't count xtal periods. + +
value (or simply v)
to set value of the timer (number +of xtal periods). `param' is the new value. + +
+ +id can be a number or a string. Timers are numbered from 1. You +can use any number greater than 0 to identify a timer. Or you can use +a simbolic name, in this case simulator uses the first unused number +to allocate a new timer: + +
+> tim a 3
+> tim g 0
+timer #0("time") ON: 0.463255 sec (5123232 clks)
+timer #0("isr") ON: 0.0051888 sec (57384 clks)
+timer #3("unnamed") ON: 0 sec (0 clks)
+> tim a "a"
+> tim g 0
+timer #0("time") ON: 0.463255 sec (5123232 clks)
+timer #0("isr") ON: 0.0051888 sec (57384 clks)
+timer #1("a") ON: 0 sec (0 clks)
+timer #3("unnamed") ON: 0 sec (0 clks)
+> 
+
+ +If you use 0 as timer id in "get" operation, simulator prints out +value of all timers including predefined ones. + +
+ + + diff --git a/sim/ucsim/doc/cmd_set.html b/sim/ucsim/doc/cmd_set.html new file mode 100644 index 00000000..e062d772 --- /dev/null +++ b/sim/ucsim/doc/cmd_set.html @@ -0,0 +1,203 @@ + + +Set commands of uCsim + + + + + + +

Set commands

+ +Set commands can be used to set value of memory cells, bits, or port +pins. Those commands that set value of memory interpret their command +lines a litle bit different than other commands. First parameter is +always the start address of the memory area which is being set. This +parameter is followed by a list of data parameters. Data can be +specified by a number. Numbers must begin with a digit. Each number +specifies one byte of data. If the parameter begins with a non-digit +character, it is interpreted as string of characters and this kind of +parameter specifies as many bytes as many characters the string +has. Strings can contain escape sequencies (see description of wi command where escape +sequencies are discussed) but they can not contain spaces because +space characters (space, tabulator and vertical tabulator) separates +parameters. Spaces can be specified as escape sequences or separated +number parameters if needed. Only space characters separate data +parameters while normaly comma (,) and semicolon (;) +are interpreted as separator characters too. + +

si addr data...

+ +Write data into internal RAM area. First parameter specifies start +address of memory area to set and other parameters are data to set. + +
+$ s51
+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.
+> si 10 dani\040hej-ho
+00000a 64 61 6e 69 20 68 65 6a 2d 68 6f                dani hej-ho
+> 
+ +Result of the command is a memory dump of area which has been modified +by the command. If there is syntax error in a data parameter then +remaining parameters are dropped out. + +
+> si 20 1 2 0xi 3 4
+Bad data 0xi
+000014 01 02                                           ..
+> 
+ + +

sx addr data...

+ +This command is similar to si command +described above but it is used to modify external RAM. + + +

sc addr data...

+ +This command is similar to si command +described above but it is used to modify code memory area (ROM). + + +

ss addr data...

+ +This command is similar to si command +described above but it is used to modify SFR. Other difference is that +first parameter (start address) can be specified by name of SFR +not by address only. + +
+$ s51
+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.
+> ss p1 0
+000090 00                                              .
+> 
+ + +

sb addr data...

+ +Modify bit(s). First parameter is address of first bit to modify. See +description of db command how bit address can +be specified. If first character of data parameter is 0 it +means zero otherwise it means one. + +
+$ s51
+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.
+> sb 0x23.5 1
+> db 0x23.5
+000023   23.5 1
+> sb p3.3 0
+> dp
+P0    11111111 0xff 255 .    P1    11111111 0xff 255 .
+Pin0  11111111 0xff 255 .    Pin1  11111111 0xff 255 .
+Port0 11111111 0xff 255 .    Port1 11111111 0xff 255 .
+
+P2    11111111 0xff 255 .    P3    11110111 0xf7 247 .
+Pin2  11111111 0xff 255 .    Pin3  11111111 0xff 255 .
+Port2 11111111 0xff 255 .    Port3 11110111 0xf7 247 .
+> sb tr1 0
+> db tr1
+000088    TR1 0
+> sb tr1 1
+> db tr1
+000088    TR1 1
+> 
+ + +

sp port data

+ +This command can be used to sep up output values of external circuits +connected to port pins. If a port bit is used as output to drive +external circuits, do not set corresponding pin bit to zero because +read back value of the port can be false. First parameter must be +number of the port between 0 and 3. + +
+$ s51
+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.
+> dp
+P0    11111111 0xff 255 .    P1    11111111 0xff 255 .
+Pin0  11111111 0xff 255 .    Pin1  11111111 0xff 255 .
+Port0 11111111 0xff 255 .    Port1 11111111 0xff 255 .
+
+P2    11111111 0xff 255 .    P3    11111111 0xff 255 .
+Pin2  11111111 0xff 255 .    Pin3  11111111 0xff 255 .
+Port2 11111111 0xff 255 .    Port3 11111111 0xff 255 .
+> ss p1 0x55
+000090 55                                              U
+> sp 1 0x0f
+> dp
+P0    11111111 0xff 255 .    P1    01010101 0x55  85 U
+Pin0  11111111 0xff 255 .    Pin1  00001111 0x0f  15 .
+Port0 11111111 0xff 255 .    Port1 00000101 0x05   5 .
+
+P2    11111111 0xff 255 .    P3    11111111 0xff 255 .
+Pin2  11111111 0xff 255 .    Pin3  11111111 0xff 255 .
+Port2 11111111 0xff 255 .    Port3 11111111 0xff 255 .
+> 
+ + +

fi start stop data

+ +Fill command. It can be used to fill up an area of internal RAM with a +specified data. + +
+$ s51
+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.
+> fi 11 0x34 44
+> di
+000000 00 00 00 00 00 00 00 00 ........
+000008 00 00 00 2c 2c 2c 2c 2c ...,,,,,
+000010 2c 2c 2c 2c 2c 2c 2c 2c ,,,,,,,,
+000018 2c 2c 2c 2c 2c 2c 2c 2c ,,,,,,,,
+000020 2c 2c 2c 2c 2c 2c 2c 2c ,,,,,,,,
+000028 2c 2c 2c 2c 2c 2c 2c 2c ,,,,,,,,
+000030 2c 2c 2c 2c 2c 00 00 00 ,,,,,...
+000038 00 00 00 00 00 00 00 00 ........
+000040 00 00 00 00 00 00 00 00 ........
+000048 00 00 00 00 00 00 00 00 ........
+> 
+ + +

fx start stop data

+ +Fill command. It works similar to fi but it +puts data into external RAM instead of internal RAM. + + +

fs start stop data

+ +Fill command. It works similar to fi but it +puts data into SFR instead of internal RAM. + + +

fc start stop data

+ +Fill command. It works similar to fi but it +puts data into code memory (ROM) instead of internal RAM. + + +
+ + + diff --git a/sim/ucsim/doc/commref.html b/sim/ucsim/doc/commref.html new file mode 100644 index 00000000..f50252cc --- /dev/null +++ b/sim/ucsim/doc/commref.html @@ -0,0 +1,83 @@ + + +UCSIM: Command Reference + + + + +

Command reference

+ + +

The simulator can be controlled with a simple monitor program which +uses the command console to read commands and print out results. After +starting the program you see a prompt on the command console and you +can write in commands after the prompt: + +

+g [start [stop]]   Go
+stop               Stop
+pc [address]       Get/set content of PC
+s [step]           Step
+n [step]           Next
+bse wi|ri|wx|rx|ws|rs|rc f|d addr [hit]
+                   Set EVENT Breakpoint
+bde wi|ri|wx|rx|ws|rs|rc addr
+                   Delete EVENT Breakpoint
+ba                 Delete all breakpoints
+dis [start [offset [lines]]]
+                   Disassemble code
+dp                 Dump ports
+ds [addr...]       Dump SFR
+db addr...         Dump bit
+si addr data...    Set Internal RAM
+sx addr data...    Set External RAM
+sc addr data...    Set code (ROM)
+ss addr data...    Set SFR area
+sb addr data...    Set bit
+sp port data       Set port pins
+fi start stop data Fill IRAM area with `data'
+fx start stop data Fill XRAM area with `data'
+fs start stop data Fill SFR area with `data'
+fc start stop data Fill ROM area with `data'
+wi,Wi string       Search for `string' in IRAM (Wi case sensitive)
+wx,Wx string       Search for `string' in XRAM (Wx case sensitive)
+wc,Wc string       Search for `string' in ROM (Wc case sensitive)
+sopt opt value     Set value of option
+gopt [opt]         Get value of option(s)
+show c|w           Show licensing information
+----
+Set of new commands:
+conf               Configuration
+state              State of simulator
+file,load "FILE"   Load FILE into ROM
+download,dl        Download (intel hex) data
+info               Information
+get                Get
+set                Set
+timer a|d|g|r|s|v id [value]
+                   Timer add|del|get|run|stop|value
+run                Go
+step               Step
+reset              Reset
+dump i|x|r|s [start [stop]]
+                   Dump memory
+di [start [stop]]  Dump Internal RAM
+dx [start [stop]]  Dump External RAM
+dch [start [stop]] Dump code in hex form
+dc [start [stop]]  Dump code in disass form
+break addr [hit]   Set fix breakpoint
+tbreak addr [hit]  Set temporary breakpoint
+clear [addr...]    Clear fix breakpoint
+help,?             Help about commands
+quit               Quit
+kill               Shut down the simulator
+
+ +In command reference you can find more +information about breakpoints and execution of the simulated program. + + +
+ + + diff --git a/sim/ucsim/doc/conf.mk b/sim/ucsim/doc/conf.mk new file mode 100644 index 00000000..879e9bc8 --- /dev/null +++ b/sim/ucsim/doc/conf.mk @@ -0,0 +1,10 @@ +# +# Makefile targets to remake configuration +# + +freshconf: Makefile + +Makefile: $(srcdir)/Makefile.in $(PRJDIR)/configure.in + cd $(PRJDIR) && $(SHELL) ./config.status + +# End of conf.mk diff --git a/sim/ucsim/doc/cpu.gif b/sim/ucsim/doc/cpu.gif new file mode 100644 index 00000000..a14fbb66 Binary files /dev/null and b/sim/ucsim/doc/cpu.gif differ diff --git a/sim/ucsim/doc/cpu.html b/sim/ucsim/doc/cpu.html new file mode 100644 index 00000000..679f818c --- /dev/null +++ b/sim/ucsim/doc/cpu.html @@ -0,0 +1,59 @@ + + +Simulator for MCS51 + + + + +

Software simulator for MCS51

+ +This screeshot demonstrates CPU window of the simulator. The CPU +window contains five different panes. Active pane can be changed by +pressing TAB and Shift-TAB keys. First pane contains disassembled code +of the program. Instructions found by the code analyzer appear on the +list only. Some of instructions can be highlighted in different +ways. First highlighted instruction on the list (instruction at +0x4386) is highlighted because there is a breakpoint specified at that +address. Second highlighted instruction (at 0x438A) shows a dynamic +breakpoint. Third highlighted line contains the cursor which can be +moved by pressing up and down arrow keys. Because the pane lists +analyzed instructions only, the list can be scrolled backward as well +as forward. + +

+ +

Second pane which is under disass pane is a memory dump pane which +shows content of internal RAM. Activating this pane the cursor appears +in the pane and the memory content can be changed simply by entering +new value at requested location. Cursor can be moved by cursor keys. + +

Next pane shows content of registers: accumulators, program status +word, general purpose registers, indirectly addressed memory +locations, data pointer, and stack pointer, program counter. Note that +changing content of PC can be dangerous. If you set new value to PC +and this address is not found by code analyzer as instruction, +disassembled list disappears from disass pane and an error message `PC +is at invalid address' appears. If you are sure that PC is at an +instruction (remember that code analyzer is unable to locate every +instructions of the program) you can "validate" actual address by +pressing Ctrl-F7 keys. + +

Next pane shows values of ports. P0 and P2 is disabled if simulated +microcontroller is a 8X31 which needs P0 and P2 for multiplexed +address/data bus. + +

Last pane is a passive pane, it can not be activated. It shows time +elapsed since last reset. First line contains number of number of +cycles (in hex) and second line the cycles that the CPU spent in +interrupt routines. Last line is calculated dependent of specified +XTAL frequency and it shows `real time' (symulated time) elapsed since +reset (in microseconds). + +

At right side of menu bar there is an indicator which shows status +of the simulation (CPU Stopped, Symulation Running). The screenshot +shows some menus as well. + +


+ + + diff --git a/sim/ucsim/doc/cpu_types.html b/sim/ucsim/doc/cpu_types.html new file mode 100644 index 00000000..d546f37f --- /dev/null +++ b/sim/ucsim/doc/cpu_types.html @@ -0,0 +1,184 @@ + + +UCSIM: CPU types + + + + +

Select type of CPU

+ +The simulator supports following type of microprocessors from MCS51 +family: + +

8051/8031 + +
8052/8032 + +
8051R + +
89C51R + +
80251 + + +

8051/8031

+ +You can select this type of microcontroller using one of the following +parameter for -t option: + +
  • 51 (HMOS type) + +
  • 8051 (HMOS type) + +
  • 8751 (HMOS type) + +
  • C51 (CMOS type) + +
  • 80C51 (CMOS type) + +
  • 87C51 (CMOS type) + +
  • 31 (HMOS type) + +
  • 8031 (HMOS type) + +
  • C31 (CMOS type) + +
  • 80C31 (CMOS type) + +
+ +It includes core 51 features: + +
  • 64k external RAM + +
  • 64k ROM + +
  • 128 byte internal RAM + +
  • 2 timers (timer #0, timer #1) + +
  • Serial interface + +
  • 4 8-bit quazi bi-directional ports + +
+ +CMOS types also include: + +
  • Idle mode + +
  • Power down mode + +
+ + +

8052/8032

+ +You can select this type of microcontroller using one of the following +parameter for -t option: + +
  • 52 (HMOS type) + +
  • 8052 (HMOS type) + +
  • 8752 (HMOS type) + +
  • C52 (CMOS type) + +
  • 80C52 (CMOS type) + +
  • 87C52 (CMOS type) + +
  • 32 (HMOS type) + +
  • 8032 (HMOS type) + +
  • C32 (CMOS type) + +
  • 80C32 (CMOS type) + +
+ +It includes same features as 8051/8031 +microcontrollers and additionaly: + +
  • 3 timers (timer #0, timer #1, timer #2) + +
  • 256 bytes of internal RAM + +
+ + +

8051R

+ +You can select this type of microcontroller using one of the following +parameter for -t option (all are CMOS types): + +
  • 51R + +
  • 51RA + +
  • 51RB + +
  • 51RC + +
  • C51RA + +
  • C51RB + +
  • C51RC + +
+ +It includes all features that 8052/8032 does and +additionaly: + +
  • Extended interrupt priority system (4 priority levels) + +
  • Extended serial line interface (automatic address recognition) + +
  • Watchdog timer + +
+ + +

89C51R

+ +You can select this type of microcontroller using 89C51R +parameter for -t option (this CPU is always CMOS). This is a Philips +clone, excluding duplicated DPTR it is similar to 8051XR from Intel. + +

It includes all features that 8051R does and +additionaly: + +

  • PCA (Programmable Counter Array): 5 16-bit counter, one of +them can act as watchdog timer. + +
  • Duplicated DPTR. + +
+ + +

80251

+ +You can select this type of microcontroller using one of the following +parameter for -t option (all are CMOS types): + +
  • 251 + +
  • C251 + +
+ +

It includes all features that 89C51R does +and additionaly: + +

  • Nothing implemented yet. + +
+ +
+ + + diff --git a/sim/ucsim/doc/index.html b/sim/ucsim/doc/index.html new file mode 100644 index 00000000..61ffb9c5 --- /dev/null +++ b/sim/ucsim/doc/index.html @@ -0,0 +1,156 @@ + + +Mikrocontroller Simulator + + + + +[ Download ] + +[ Installation ] + +[ Usage ] + +[ Mail to +developer ] + +

+ +

Software simulator for microcontrollers

+ +uCsim can be used to simulate microcontrollers. It +supports MCS51 family. AVR and Z80 support is under development. + +

Download

+ +Simulator is available for two platforms: DOS and UNIX but DOS version +is not supported any more. DOS version is not finished so I call it +demo version and it is available in binary only. Limitations of DOS +version are: + +
  • There is no built in help available; + +
  • Some of the utilities are not working, for example calculator, bit +simulator; + +
  • Serial line works in mode 1 independently of mode bits.
+ +I used this simulator to verify my applications and I never used +missing feautres mentioned above, so I think that this "demo" version +can be usefull anyway. + +

Download +now + + + + +

How to install

+ +DOS version + +

Get the ZIP file and unzip it. ZIP file contains three files: +s51.exe the executable itself, dpmi16bi.ovl and +rtm.exe. Last two files are required because s51.exe is +a DOS protected mode program. Put these files in a directory which is +in the PATH or keep them together with the s51.exe. + +

UNIX version + +

UNIX version is distributed in source. + +

  1. Get archive file, uncompress and untar it. These steps will +produce a directory ucsim-X.Y.Z where X.Y.Z is the version +number. + +
  2. Go to the directory and configure the package. Issue +configure command. It will determine your system and +make Makefile. Installation directory can be specified with +--prefix=dir option to the +configure. Default directory is +/usr/local. Executable file will be placed in bin +subdirectory. + +
  3. Compile the package with make command. + +
  4. Install executable s51 to any directory you want. It can be +done with make install command which will place files +in installation directory specified with --prefix=dir option of +configure. Note that you may have to have special +privilege to do this if installation directory is not writable by you. + +
+ + + + +

How to use

+ +

DOS version

+ +S51 for DOS has been written in Borland Pascal using Turbo Vision to +produce menu driven, multiwindow user interface which is very easy to +use. The program can be started using following command: + +

C:\> s51 [input file] + +

Parameter is optional. If it specified it must be the name of an +Intel hex file. Some screenshots of the program and short descriptions +of them: + +

+ + +

UNIX version

+ +Invokation.
Starting the simulator +program. + +

Features of the simulator + +

    + +
  • Code analyzer.
    The simulator tries +to figure out places of valid instructions in code area. This feature +included in both DOS and UNIX versions. + +
  • Processor types.
    The simulator can +simulate different type of microcontrollers. + +
  • Multiple consoles.
    The simulator can +handle more than one command consoles and accepts command from +multiple sources. It also can be driven by other programs such as +debugger interfaces. + +
  • Serial interfaces.
    The simulator can +virtually connect a terminal to serial interface of the simulated CPU. + +
  • Command reference. (Now updated up to +0.2.37)
    The simulator can be controlled via a command line +interface. It accepts simple commands. + +
+ +
+ + + + + +
© 1997,99 Dániel Drótos, Talker Bt.
drdani@mazsola.iit.uni-miskolc.hu
+ + + diff --git a/sim/ucsim/doc/interrupt.gif b/sim/ucsim/doc/interrupt.gif new file mode 100644 index 00000000..4e146f5d Binary files /dev/null and b/sim/ucsim/doc/interrupt.gif differ diff --git a/sim/ucsim/doc/interrupt.html b/sim/ucsim/doc/interrupt.html new file mode 100644 index 00000000..98a9c6af --- /dev/null +++ b/sim/ucsim/doc/interrupt.html @@ -0,0 +1,27 @@ + + +Simulator for MCS51 + + + + +

Software simulator for MCS51

+ +This screenshot demonstrates window which displays interrupt system of +the microcontroller. Interrupt enable register and priority register +as well as interrupt request bits are displayed in this window. Note +that if you set some request bit during simulation and interrupt is +enabled, the CPU will accept the interrupt and responding to it by +starting the service routine. + +

+ +

The `Interrupt/program rate' pane shows ratio of execution time of +main program and interrupt service routines. Content of this pane is +not saved if you close tha window which means that measure of the +ratio is restarted every time you reopen the window. + +


+ + + diff --git a/sim/ucsim/doc/invoke.html b/sim/ucsim/doc/invoke.html new file mode 100644 index 00000000..ff6cceb9 --- /dev/null +++ b/sim/ucsim/doc/invoke.html @@ -0,0 +1,124 @@ + + +UCSIM: Invokation + + + + +

Starting the simulator

+ +There are separate programs to simulate different microcontroller +families: + +

MCS51 family is simulated by s51 +
AVR family is simulated by savr +
Z80 processor is simulated by sz80 + +

You can select + +

The simulator can be started in the following way: + +

$ s51 [-hHVvP] [-p prompt] [-t CPU] +[-X freq[k|M]] [-c file] [-s file] [-S optionlist] [-Z portnum] +[files...] + +

Specified files must be names of Intel hex files. Simulator loads +them in specified order into the ROM of the simulated system. + +

Options: + +

-t CPU + +
Type of CPU. Recognized types are: 51, 8051, 8751, C51, 80C51, +87C51, 31, 8031, C31, 80C31, 52, 8052, 8752, C52, 80C52, 87C52, 32, +8032, C32, 80C32, 51R, 51RA, 51RB, 51RC, C51R, C51RA, C51RB, C51RC, +89C51R, 251, C251. Note that recongition of a CPU type as option does +not mean that the simulator can simulate that kind of CPU. Default +type is C51. + +
See how to select CPU type. + +
-X freq[k|M] + +
XTAL frequency is freq Hertz. k or M can be +used to specify frequency in kHZ or MHz. Space is not allowed between +the number and the k or M. Default value is 11059200 Hz. + +
-c file + +
Open command console on file. Command consoles are on +standard input and output by default. Using this option the console +can be opened on any file for example on the serial interface of the +computer. + +
-Z portnum + +
Listen for incoming connections on port portnum. Using this +option uCsim can serve multiple consoles. You can get a console +by simply telnet into machine running uCsim to port +portnumber. This option is not available on platforms which +doesn't support BSD networking. + +
See how to use multiple consoles. + +
-s file + +
Connect serial interface of the simulated microcontroller to the +file. Nothing is used by default which means that characters +transmitted by serial interface of the simulated microcontroller go to +nowhere and it will never receive anything. If you are going to +communicate with serial interface interactively the best idea is to +specify a teminal with -s option. + +
-S in=file,out=file + +
Using this option you can specify different files for input and +output streams that uCsim uses to simulate microprocessor's +serial interface. + +
See more about serial interface +simulation. + +
-p prompt + +
Using this option you can specify any string to be the prompt of +command interpreter, for example: + +
$ s51 -p "s51> "
+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.
+s51> 
+ +
-P + +
Prompt will be a null ('\0') character. This feature can be +useful for programs which controlls simulator through a pipe. + +
-V + +
Verbose mode. The simulator notifies you about some kind of +internal actions for example interrupts. Messages are printed on +command console. + +
-v + +
Print out version number and stop. + +
-H + +
Print out types of known CPUs. Names printed out by this option +can be used to determine CPU type using -t option. + +
-h + +
Print out a short help about the options and stop. + +
+ + +
+ + + diff --git a/sim/ucsim/doc/mulcons.html b/sim/ucsim/doc/mulcons.html new file mode 100644 index 00000000..771c47c5 --- /dev/null +++ b/sim/ucsim/doc/mulcons.html @@ -0,0 +1,115 @@ + + +UCSIM: Multiple Consoles + + + + +

Using multiple consoles

+ +

Why?

+ +Using more than one console can be useful if you want to issue a +command during the simulated program is executed. + + +

How?

+ +

To get multiple consoles you have to execute the simulator in the +background like daemons run in UNIX systems. The simulator +then will listen and wait for network connection requests and provide +console functions for network connections. + +

To run uCsim in the background you have to use -Z option for the simulator: + +

+pigmy$ s51 -Z 5555 foo.hex
+
+ +In this case s51 runs in forground in your command interpreters point +of view. Of course you can run the program really in the background: + +
+pigmy$ s51 -Z 5555 foo.hex &
+
+ +The parameter of the -Z option is a +port number. This can be number of any unused port of your machine. If +the specified port is already occupied then following message appears: + +
+pigmy$ s51 -Z 5555
+bind: Address already in use
+
+ +In this case you have to use an other number. + +

Let's suppose you have found a free port number and the simulator +listens on it. Now go to somewhere else, at least to an other window +and connect to the simulator: + +

+other_machine$ telnet pigmy 5555
+
+ +First parameter to the telnet command is the name of the machine where +the simulator is running on. It can be localhost if you are +on the same machine or the fully qualified host name if you are at the +other end of the world. Second parameter is the number of the port +where the simulator is listening. It must be the same number which was +specified as parameter of the -Z +option when the simulator was started (see above). + +

Connecting to the simulator you get a command console: + +

+pigmy$ telnet pigmy 5555
+Trying 127.0.0.1...
+Connected to pigmy.talker.bt.
+Escape character is '^]'.
+ucsim 0.2.21, 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.
+>
+ 
+
+ + +

What to do with it?

+ +Obviously you can telnet into the simulator as many times as many +command consoles you want. You can start the execution using one +console and while the program is executed you can, for example, modify +ports on the other console. + + +

Stop

+ +Using quit (q) command you can not stop the +simulator. It just stops the actual console and the simulator +continues to listen for incoming network connections. + +

To stop the simulator completely you have to use kill command. Note that if you stop the +simulator then all the active network connections (all other consoles) +will stop. + + +

Tricks

+ +You can get a console on the terminal where you started the +simulator. To do this you must explicitly ask the simulator to open a +console on the standard input/output. You can do this using -c option and specify the actual +terminal as parameter for it: + +
+pigmy$ s51 -Z 5555 foo.hex -c /dev/tty
+
+ +
+ + + diff --git a/sim/ucsim/doc/new.gif b/sim/ucsim/doc/new.gif new file mode 100644 index 00000000..892616ff Binary files /dev/null and b/sim/ucsim/doc/new.gif differ diff --git a/sim/ucsim/doc/obsolete.html b/sim/ucsim/doc/obsolete.html new file mode 100644 index 00000000..2afd2280 --- /dev/null +++ b/sim/ucsim/doc/obsolete.html @@ -0,0 +1,25 @@ +

bl

+ +List breakpoints. This command prints out information about every +fetch and then event breakpoints. + +
+> bl
+F 1(1) 000160 c2 CLR   P1.0
+D 2(2) 000180 02 LJMP  022a
+F 1(1) 000006 wi
+> 
+ +First character on the list shows permanency of the +breakpoint. F means fix and D means dynamic. Second item +on the list is the hit number associated to breakpoint. After that +between the parentheses there is the actual value of the hit +counter. If hit counter reaches zero, breakpoint is activated and hit +counter is preset with value of hit number. Next item is the +address. Next items are different for fetch and event breakpoints. + +

Fetch breakpoints list hexadecimal code of instruction at +breakpoint's address and then dissassembled instruction. + +

Event breakpoints list identification of the event's type. + diff --git a/sim/ucsim/doc/post.jpg b/sim/ucsim/doc/post.jpg new file mode 100644 index 00000000..acd6eba5 Binary files /dev/null and b/sim/ucsim/doc/post.jpg differ diff --git a/sim/ucsim/doc/serial.html b/sim/ucsim/doc/serial.html new file mode 100644 index 00000000..7707d7cb --- /dev/null +++ b/sim/ucsim/doc/serial.html @@ -0,0 +1,135 @@ + + +UCSIM: Serial Interafces + + + + +

Using serial interfaces

+ +

Connecting a terminal

+ +You can easily connect a terminal to the serial interface of the +simulated microcontroller. This terminal is just a file so it can be +anything which is represented as a file. It can be a real serial line +of the computer: + +
+$ s51 -s/dev/ttyS1
+
+ +Of course you must use the actual device name of your operating +system. Device name ttyS1 above is used in Linux +systems. Your system can use other names. + +

You can use a terminal of your system. It can be a virtual console +if your system provides such as Linux does for example. On X Windows +you can use xterm windows as terminals, one for running the +simulator and one as a terminal on CPU's serial line. Here is a sample +how to do this: + +

  1. Prepare the terminal window which will be connected to the +serial line: + +

    • Check the device name which represents the terminal: + +
      +$ tty
      +/dev/ttyp1
      +
      + +
    • Disconnect the shell from the terminal. Usualy I use the +tail command and any existing text file: + +
      +$ tail -f $HOME/.profile
      +
      + +
    + +
  2. Run the simulator in the other window: + +
    +$ s51 -s/dev/ttyp1 program.hex
    +
    + +Use the output of the tty command above as the parameter of the +-s option. + +
+ +Every character sent out by the simulated program +appears in the "terminal" window and every charater you type in there +will be received by the simulated controller's serial line. + + +

Connecting two instances of simulator

+ +Executing two instances of the simulator, serial lines of two +simulators (micros) can be connected together so they can talk to +each other over their serial interface. It is because you can specify +separate files for serial input and output. For example you run two +simulators "1" and "2", here is the sample how to connect them: + +

+ +

  1. Make two FIFOs to represent physical wires in serial cable +connecting two micros: + +
    +$ mkfifo 1-2 2-1 # 1-2: 1->2  and 2-1: 2->1
    +
    + +
  2. Start two simulators and specify the FIFOs as input and output of +serial interface: + +
    +term1 $ # start sim "1"
    +term1 $ s51 -Sin=2-1,out=1-2 program_1_.hex
    +term2 $ # start sim "2"
    +term2 $ s51 -Sout=2-1,in=1-2 program_2_.hex
    +
    + +Because opening a pipe blocks the program until other direction is +opened, the order of arguments above is important! + +

    + +

  3. Debug programs as usual. + +
+ +Using the most usefull unix commands cat and tee and +just some more FIFOs you can monitor serial communication, here is a +sample: + +

+ +

  1. Make some FIFOs to use between simulators and tee "monitors": + +
    +$ mkfifo 1_tee tee_2 2_tee tee_2
    +
    + +
  2. Run monitoring programs (in two xterms for example): + +
    +xterm1 $ cat 1_tee|tee /dev/tty >tee_2 # monitor 1->2
    +xterm2 $ cat 2_tee|tee /dev/tty >tee_1 # monitor 2->1
    +
    + +
  3. Now you can start simulators (on two other terminals:) + +
    +xterm3 $ s51 -Sin=tee_1,out=1_tee program_1_.hex
    +xterm4 $ s51 -Sin=tee_2,out=2_tee program_2_.hex
    +
    + +
  4. Start your apps and listen what they are talking about. + +
+ +
+ + + diff --git a/sim/ucsim/doc/serial1.fig b/sim/ucsim/doc/serial1.fig new file mode 100644 index 00000000..ad24a87f --- /dev/null +++ b/sim/ucsim/doc/serial1.fig @@ -0,0 +1,53 @@ +#FIG 3.2 +Landscape +Center +Inches +Letter +100.00 +Single +-2 +1200 2 +6 3750 2250 5175 2550 +5 1 0 1 0 7 0 0 -1 0.000 0 0 0 0 4912.500 2400.000 5025 2250 5100 2400 5025 2550 +1 2 0 1 0 0 0 0 20 0.000 1 0.0000 3825 2400 75 150 3750 2400 3900 2400 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 3825 2250 5025 2250 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 3825 2550 5025 2550 +-6 +6 3900 5625 5325 5925 +5 1 0 1 0 7 0 0 -1 0.000 0 0 0 0 5062.500 5775.000 5175 5625 5250 5775 5175 5925 +1 2 0 1 0 0 0 0 20 0.000 1 0.0000 3975 5775 75 150 3900 5775 4050 5775 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 3975 5625 5175 5625 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 3975 5925 5175 5925 +-6 +2 1 0 1 4 7 0 0 -1 0.000 0 0 -1 0 1 2 + 0 0 1.00 60.00 120.00 + 2250 3450 3675 2475 +2 1 0 1 4 7 0 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 6300 3675 5250 2475 +2 1 0 1 2 7 0 0 -1 0.000 0 0 -1 0 1 2 + 0 0 1.00 60.00 120.00 + 6975 3975 5400 5775 +2 1 0 1 2 7 0 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 3000 3675 3825 5775 +2 2 0 1 9 7 0 0 -1 0.000 0 0 -1 0 0 5 + 825 3225 3900 3225 3900 2925 825 2925 825 3225 +2 2 0 1 9 7 0 0 -1 0.000 0 0 7 0 0 5 + 825 3225 3900 3225 3900 4875 825 4875 825 3225 +2 2 0 1 9 7 0 0 -1 0.000 0 0 7 0 0 5 + 4800 3600 7875 3600 7875 5250 4800 5250 4800 3600 +2 2 0 1 9 7 0 0 -1 0.000 0 0 7 0 0 5 + 4800 3600 7875 3600 7875 3300 4800 3300 4800 3600 +4 1 0 0 0 16 12 0.0000 4 135 330 4425 2175 2-1\001 +4 1 0 0 0 16 12 0.0000 4 135 330 4575 5550 1-2\001 +4 1 9 0 0 18 12 0.0000 4 135 525 6375 3525 term2\001 +4 1 9 0 0 18 12 0.0000 4 135 525 2325 3150 term1\001 +4 0 1 0 0 12 12 0.0000 4 150 2520 900 3600 $ s51 -Sin=2-1,out=1-2 \\\001 +4 0 1 0 0 12 12 0.0000 4 180 1470 900 3810 program_1_.hex\001 +4 0 1 0 0 12 12 0.0000 4 180 1470 4950 4125 program_2_.hex\001 +4 0 1 0 0 12 12 0.0000 4 150 2520 4950 3900 $ s51 -Sout=2-1,in=1-2 \\\001 diff --git a/sim/ucsim/doc/serial1.gif b/sim/ucsim/doc/serial1.gif new file mode 100644 index 00000000..dc8a0c0f Binary files /dev/null and b/sim/ucsim/doc/serial1.gif differ diff --git a/sim/ucsim/doc/serial2.fig b/sim/ucsim/doc/serial2.fig new file mode 100644 index 00000000..81beaef7 --- /dev/null +++ b/sim/ucsim/doc/serial2.fig @@ -0,0 +1,97 @@ +#FIG 3.2 +Landscape +Center +Inches +Letter +100.00 +Single +-2 +1200 2 +6 7125 2325 7425 3825 +5 1 0 1 0 7 0 0 -1 0.000 0 0 0 0 7275.000 3563.000 7425 3675 7275 3750 7125 3675 +1 2 0 1 0 0 0 0 20 0.000 1 4.7124 7275 2475 75 150 7275 2400 7275 2550 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 7125 2475 7125 3675 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 7425 2475 7425 3675 +-6 +6 2475 2400 2775 3900 +5 1 0 1 0 7 0 0 -1 0.000 0 0 0 0 2625.000 3638.000 2775 3750 2625 3825 2475 3750 +1 2 0 1 0 0 0 0 20 0.000 1 4.7124 2625 2550 75 150 2625 2475 2625 2625 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 2475 2550 2475 3750 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 2775 2550 2775 3750 +-6 +6 5175 6750 6675 7050 +5 1 0 1 0 7 0 0 -1 0.000 0 0 0 0 5437.000 6900.000 5325 7050 5250 6900 5325 6750 +1 2 0 1 0 0 0 0 20 0.000 1 3.1416 6525 6900 75 150 6600 6900 6450 6900 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 6525 6750 5325 6750 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 6525 7050 5325 7050 +-6 +6 4200 5700 4500 7200 +5 1 0 1 0 7 0 0 -1 0.000 0 0 0 0 4350.000 6938.000 4500 7050 4350 7125 4200 7050 +1 2 0 1 0 0 0 0 20 0.000 1 4.7124 4350 5850 75 150 4350 5775 4350 5925 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 4200 5850 4200 7050 +2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 2 + 4500 5850 4500 7050 +-6 +2 1 0 1 4 7 0 0 -1 0.000 0 0 -1 0 1 2 + 0 0 1.00 60.00 120.00 + 4275 1725 2700 2400 +2 1 0 1 2 7 0 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 4350 5700 2550 5025 +2 2 0 1 9 7 0 0 -1 0.000 0 0 7 0 0 5 + 4875 4950 7950 4950 7950 6600 4875 6600 4875 4950 +2 2 0 1 9 7 0 0 -1 0.000 0 0 7 0 0 5 + 4875 4950 7950 4950 7950 4650 4875 4650 4875 4950 +2 1 0 1 4 7 0 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 3450 4725 2625 3900 +2 2 0 1 9 7 0 0 -1 0.000 0 0 -1 0 0 5 + 3450 1350 6525 1350 6525 1050 3450 1050 3450 1350 +2 2 0 1 9 7 0 0 -1 0.000 0 0 7 0 0 5 + 3450 1350 6525 1350 6525 3000 3450 3000 3450 1350 +2 2 0 1 9 7 0 0 -1 0.000 0 0 -1 0 0 5 + 2775 8325 5850 8325 5850 8025 2775 8025 2775 8325 +2 2 0 1 9 7 0 0 -1 0.000 0 0 7 0 0 5 + 2775 8325 5850 8325 5850 9975 2775 9975 2775 8325 +2 2 0 1 9 7 0 0 -1 0.000 0 0 -1 0 0 5 + 900 4575 3975 4575 3975 4275 900 4275 900 4575 +2 2 0 1 9 7 0 0 -1 0.000 0 0 7 0 0 5 + 900 4575 3975 4575 3975 6225 900 6225 900 4575 +2 1 0 1 4 7 0 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 5550 1875 7200 2325 +2 1 0 1 4 7 0 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 7275 3825 6375 5100 +2 1 0 1 2 7 0 0 -1 0.000 0 0 -1 1 0 2 + 0 0 1.00 60.00 120.00 + 4575 8700 4350 7275 +2 1 0 1 2 7 0 0 -1 0.000 0 0 -1 0 1 2 + 0 0 1.00 60.00 120.00 + 6675 6900 7500 5325 +2 1 0 1 2 7 0 0 -1 0.000 0 0 -1 0 1 2 + 0 0 1.00 60.00 120.00 + 3675 8475 5175 6900 +4 1 9 0 0 18 12 0.0000 4 135 630 6450 4875 xterm4\001 +4 0 1 0 0 12 12 0.0000 4 180 2940 975 4950 $ s51 -Sin=tee_1,out=1_tee \\\001 +4 0 1 0 0 12 12 0.0000 4 180 1470 975 5160 program_1_.hex\001 +4 1 9 0 0 18 12 0.0000 4 135 630 4950 1275 xterm1\001 +4 1 9 0 0 18 12 0.0000 4 135 630 4275 8250 xterm2\001 +4 1 9 0 0 18 12 0.0000 4 135 630 2400 4500 xterm3\001 +4 0 1 0 0 12 12 0.0000 4 180 2940 4950 5250 $ s51 -Sin=tee_2,out=2_tee \\\001 +4 0 1 0 0 12 12 0.0000 4 180 1470 4950 5475 program_2_.hex\001 +4 0 1 0 0 12 12 0.0000 4 180 1365 3525 1650 $ cat 1_tee|\\\001 +4 0 1 0 0 12 12 0.0000 4 180 1995 3525 1875 tee /dev/tty >tee_2\001 +4 0 1 0 0 12 12 0.0000 4 180 1365 2850 8625 $ cat 2_tee|\\\001 +4 0 1 0 0 12 12 0.0000 4 180 1995 2850 8850 tee /dev/tty >tee_1\001 +4 0 0 0 0 16 12 0.0000 4 165 465 2850 3600 1_tee\001 +4 0 0 0 0 16 12 0.0000 4 165 465 6600 3525 tee_2\001 +4 0 0 0 0 16 12 0.0000 4 165 465 3675 6825 tee_1\001 +4 0 0 0 0 16 12 0.0000 4 165 465 5700 7275 2_tee\001 diff --git a/sim/ucsim/doc/serial2.gif b/sim/ucsim/doc/serial2.gif new file mode 100644 index 00000000..6fbb1db1 Binary files /dev/null and b/sim/ucsim/doc/serial2.gif differ diff --git a/sim/ucsim/doc/term_cpuopt.gif b/sim/ucsim/doc/term_cpuopt.gif new file mode 100644 index 00000000..0d9006da Binary files /dev/null and b/sim/ucsim/doc/term_cpuopt.gif differ diff --git a/sim/ucsim/doc/term_cpuopt.html b/sim/ucsim/doc/term_cpuopt.html new file mode 100644 index 00000000..feadb152 --- /dev/null +++ b/sim/ucsim/doc/term_cpuopt.html @@ -0,0 +1,27 @@ + + +Simulator for MCS51 + + + + +

Software simulator for MCS51

+ +This screenshot demonstrates one of option dialog boxes and the +terminal window. Terminal window simulates a terminal which is +connected to the serial interface of the simulated +microcontroller. Every character sent by the CPU is printed out in the +terminal window (it does not matter if it is opened or not) and every +time when you press a key in the terminal window the character will be +received by the serial interface of the CPU (when the simulation is +running obviously). During receiving of the character the cursor +disappears from the terminal window and reappears when receive is +completed. Echo is turned off in the terminal window which means that +only simulated program can "write" into the window. + +

+ +


+ + + diff --git a/sim/ucsim/doc/timers.gif b/sim/ucsim/doc/timers.gif new file mode 100644 index 00000000..7fc39317 Binary files /dev/null and b/sim/ucsim/doc/timers.gif differ diff --git a/sim/ucsim/doc/timers.html b/sim/ucsim/doc/timers.html new file mode 100644 index 00000000..48753754 --- /dev/null +++ b/sim/ucsim/doc/timers.html @@ -0,0 +1,22 @@ + + +Simulator for MCS51 + + + + +

Software simulator for MCS51

+ +This screenshot demonstrates timer/counter window. The window displays +value of the timer and control bits related to the timer/counter +unit. Different windows can be opened to display information about +different timers. Note that Timer2 of 8X52 is not implemented. Value +of the timer or control bits can be changed using these windows or SFR +window. + +

+ +


+ + + diff --git a/sim/ucsim/doc/wins.gif b/sim/ucsim/doc/wins.gif new file mode 100644 index 00000000..086b54fa Binary files /dev/null and b/sim/ucsim/doc/wins.gif differ diff --git a/sim/ucsim/doc/wins.html b/sim/ucsim/doc/wins.html new file mode 100644 index 00000000..f467c36f --- /dev/null +++ b/sim/ucsim/doc/wins.html @@ -0,0 +1,21 @@ + + +Simulator for MCS51 + + + + +

Software simulator for MCS51

+ +This screenshot demonstrates some kind of windows that can be opened +using commands in View menu. Every windows including CPU window +can be resized and moved on the desktop area. Every windows are active +which means that value of displayed data can be changed at any time +including execution of the simulated program. + +

+ +


+ + + diff --git a/sim/ucsim/gui.src/(c).1 b/sim/ucsim/gui.src/(c).1 new file mode 100644 index 00000000..d673f9fd --- /dev/null +++ b/sim/ucsim/gui.src/(c).1 @@ -0,0 +1,25 @@ +/* + * Simulator of microcontrollers (@@F@@) + * + * Copyright (C) @@S@@,@@Y@@ Drotos Daniel, Talker Bt. + * + * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu + * + */ + +/* This file is part of microcontroller simulator: ucsim. + +UCSIM is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +UCSIM is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with UCSIM; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. */ diff --git a/sim/ucsim/gui.src/Makefile.in b/sim/ucsim/gui.src/Makefile.in new file mode 100644 index 00000000..69f892f4 --- /dev/null +++ b/sim/ucsim/gui.src/Makefile.in @@ -0,0 +1,141 @@ +# +# uCsim gui.src/Makefile +# +# (c) Drotos Daniel, Talker Bt. 1999 +# + +SHELL = /bin/sh +CXX = @CXX@ +CPP = @CPP@ +CXXCPP = @CXXCPP@ +RANLIB = @RANLIB@ +INSTALL = @INSTALL@ + +PRJDIR = .. + +DEFS = $(subs -DHAVE_CONFIG_H,,@DEFS@) +CPPFLAGS = @CPPFLAGS@ -I. -I$(PRJDIR) +CFLAGS = @CFLAGS@ -Wall +CXXFLAGS = @CXXFLAGS@ -Wall +M_OR_MM = @M_OR_MM@ + +LIBS = @LIBS@ -L$(PRJDIR) -lutil -lsim -lcmd + +curses_ok = @curses_ok@ + +prefix = @prefix@ +exec_prefix = @exec_prefix@ +bindir = @bindir@ +libdir = @libdir@ +datadir = @datadir@ +includedir = @includedir@ +mandir = @mandir@ +man1dir = $(mandir)/man1 +man2dir = $(mandir)/man2 +infodir = @infodir@ +srcdir = @srcdir@ + +PKGS = serio.src portmon.src + +LOBJECTS = event.o \ + view.o frame.o bg.o label.o \ + group.o win.o desk.o app.o + + +# Compiling entire program or any subproject +# ------------------------------------------ +all: gui.src + +libs: guilib + +ifeq ($(curses_ok),yes) +gui.src: checkconf guilib a +else +gui.src: checkconf guilib +endif + @for pkg in $(PKGS); do\ + $(MAKE) -C $$pkg $$pkg ;\ + done + +a: a.o + $(CXX) $(LDFLAGS) $(LIBS) a.o -o $@ + + +# Compiling and installing everything and runing test +# --------------------------------------------------- +install: + @for pkg in $(PKGS); do\ + cd $$pkg && $(MAKE) install ; cd ..;\ + done + + +# Deleting all the installed files +# -------------------------------- +uninstall: + @for pkg in $(PKGS); do\ + cd $$pkg && $(MAKE) uninstall ; cd ..;\ + done + + +# Performing self-test +# -------------------- +check: + @for pkg in $(PKGS); do\ + cd $$pkg && $(MAKE) check ; cd ..;\ + done + + +# Performing installation test +# ---------------------------- +installcheck: + @for pkg in $(PKGS); do\ + cd $$pkg && $(MAKE) installcheck ; cd ..;\ + done + + +# Creating installation directories +# --------------------------------- +installdirs: + @for pkg in $(PKGS); do\ + cd $$pkg && $(MAKE) installdirs ; cd ..;\ + done + + +# Creating dependencies +# --------------------- +dep: Makefile.dep + +Makefile.dep: *.cc *.h + $(CXXCPP) $(CPPFLAGS) $(M_OR_MM) *.cc >Makefile.dep + +include Makefile.dep +include clean.mk + +#parser.cc: parser.y + +#plex.cc: plex.l + +# My rules +# -------- +ifeq ($(curses_ok),yes) +guilib: libgui.a +else +guilib: +endif + +libgui.a: $(LOBJECTS) + ar -rcu $*.a $(LOBJECTS) + $(RANLIB) $*.a + +.cc.o: + $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@ + + +# Remaking configuration +# ---------------------- +checkconf: + @if [ -f $(PRJDIR)/devel ]; then\ + $(MAKE) -f conf.mk srcdir="$(srcdir)" PRJDIR="$(PRJDIR)" freshconf;\ + fi + +# End of gui.src/Makefile diff --git a/sim/ucsim/gui.src/a.cc b/sim/ucsim/gui.src/a.cc new file mode 100644 index 00000000..81d62c3f --- /dev/null +++ b/sim/ucsim/gui.src/a.cc @@ -0,0 +1,87 @@ +#include +#include + +int sfr[4]; +int port[4]; + +void +init_panel(PANEL *p) +{ + int mask, x, y; + int na, ha; + int cursor= 2; + WINDOW *w= panel_window(p); + + if (has_colors()) + { + na= COLOR_PAIR(1); + ha= COLOR_PAIR(2); + } + else + { + na= A_NORMAL; + ha= A_STANDOUT; + } + //wattron(w, COLOR_PAIR); + x= 0; + for (mask= 1, y= 0; mask < 0x100; mask<<= 1,y++) + { + wattrset(w, (y==cursor)?ha:na); + mvwprintw(w, y,x, "%s", (sfr[0]&mask)?"High":" Low"); + } +} + +wchar_t +wait_input(PANEL *p) +{ + WINDOW *w= panel_window(p); + wchar_t c; + + c= wgetch(w); + printw("%d 0x%x\n",c,c); + return(c); +} + +int +main(int argc, char *argv[]) +{ + wchar_t c; + + initscr(); /* initialize the curses library */ + keypad(stdscr, TRUE); /* enable keyboard mapping */ + nonl(); /* tell curses not to do NL->CR/NL on output */ + cbreak(); /* take input chars one at a time, no wait for \n */ + noecho(); /* don't echo input */ + if (has_colors()) + { + start_color(); + printw("has %d colors and %d pairs\n", COLORS, COLOR_PAIRS); + init_pair(1, COLOR_WHITE, COLOR_BLUE); + init_pair(2, COLOR_WHITE, COLOR_RED); + } + if (has_key(KEY_UP)) + printw("has UP KEY_UP=0x%x\n",KEY_UP); + else + printf("has no UP\n"); + c= getch(); + printw("got %d %x\n",c,c); + + WINDOW *w= newwin(10,10, 3,3); + keypad(w, TRUE); + PANEL *p= new_panel(w); + + sfr[0]= 0x5a; + init_panel(p); + update_panels(); + doupdate(); + c= wait_input(p); + //c= getch(); + + endwin(); + if (c==KEY_UP) + printf("got UP\n"); + else if (c==KEY_DOWN) + printf("got DOWN\n"); + else + printf("got \"%d\"\n", c); +} diff --git a/sim/ucsim/gui.src/app.cc b/sim/ucsim/gui.src/app.cc new file mode 100644 index 00000000..309497b9 --- /dev/null +++ b/sim/ucsim/gui.src/app.cc @@ -0,0 +1,171 @@ +/* + * Simulator of microcontrollers (app.cc) + * + * Copyright (C) 1999,99 Drotos Daniel, Talker Bt. + * + * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu + * + */ + +/* This file is part of microcontroller simulator: ucsim. + +UCSIM is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +UCSIM is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with UCSIM; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. */ +/*@1@*/ + +#include + +#include "appcl.h" +#include "deskcl.h" + + +cl_app::cl_app(char *iname): + cl_group(iname, this) +{ + drawn= 0; +} + +cl_app::~cl_app(void) +{ + endwin(); +} + +int +cl_app::init(void) +{ + initscr(); + keypad(stdscr, TRUE); + nonl(); + cbreak(); + noecho(); + + pos= new cl_box(0,0, COLS, LINES); + cl_view::init(); + state|= SF_SELECTED;//select(); + class cl_box b(*pos); + //b.move_rel(0,1); + //b.grow(0,-2); + if ((desk= mk_desk(&b))) + insert(desk); + desk->select(); + mk_views(desk); + + //update(); + update_panels(); + doupdate(); + return(0); +} + +class cl_gin * +cl_app::mk_input(void) +{ + class cl_gin *i= new cl_gin(); + i->init(); + i->add_input(stdin, 0); + return(i); +} + +int * +cl_app::mk_palette(void) +{ + int *p, i; + int colors; + + colors= 64; + p= (int*)malloc(colors * sizeof(int)); + if (has_colors()) + { + start_color(); + + init_pair(i= C_WIN+C_WIN_NORMAL, COLOR_YELLOW, COLOR_BLUE); + p[i]= COLOR_PAIR(i)|A_BOLD; + for (i= 1; i < colors; i++) + p[i]= p[C_WIN+C_WIN_NORMAL]; + // desktop + init_pair(i= C_DSK_BG, COLOR_BLACK, COLOR_WHITE); + p[i]= COLOR_PAIR(i); + // menus and status bar + init_pair(i= C_DSK_NORMAL, COLOR_WHITE, COLOR_BLUE); + p[i]= COLOR_PAIR(i)|A_BOLD; + init_pair(i= C_DSK_DISABLED, COLOR_WHITE, COLOR_BLUE); + p[i]= COLOR_PAIR(i); + // window + init_pair(i= C_WIN+C_WIN_FPASSIVE, COLOR_WHITE, COLOR_BLUE); + p[i]= COLOR_PAIR(i); + init_pair(i= C_WIN+C_WIN_FACTIVE, COLOR_WHITE, COLOR_BLUE); + p[i]= COLOR_PAIR(i)|A_BOLD; + init_pair(i= C_WIN+C_WIN_SELECTED, COLOR_YELLOW, COLOR_RED); + p[i]= COLOR_PAIR(i)|A_BOLD; + } + else + { + for (i= 0; i < colors; i++) + p[i]= A_NORMAL; + p[C_WIN+C_WIN_FACTIVE]|= A_BOLD; + p[C_WIN+C_WIN_SELECTED]|= A_REVERSE; + } + return(p); +} + +class cl_group * +cl_app::mk_desk(class cl_box *ipos) +{ + class cl_group *d= new cl_desk(ipos, "desktop", this); + d->init(); + return(d); +} + + +int +cl_app::handle_event(struct t_event *event) +{ + if (!cl_group::handle_event(event)) + { + if (event->what == EV_KEY) + switch (event->event.key) + { + case KEY_BREAK: case KEY_EXIT: + event->what= EV_COMMAND; + event->event.msg.cmd= CMD_QUIT; + break; + } + } + return(0); +} + +int +cl_app::run(void) +{ + struct t_event event; + + drawn= 0; + while (get_event(&event)) + { + if (!handle_event(&event)) + { + if (event.what == EV_COMMAND && + event.event.msg.cmd == CMD_QUIT) + return(0); + unhandled(&event); + } + if (drawn) + update(); + drawn= 0; + } + return(0); +} + + +/* End of gui.src/app.cc */ diff --git a/sim/ucsim/gui.src/appcl.h b/sim/ucsim/gui.src/appcl.h new file mode 100644 index 00000000..92a80c9d --- /dev/null +++ b/sim/ucsim/gui.src/appcl.h @@ -0,0 +1,54 @@ +/* + * Simulator of microcontrollers (appcl.h) + * + * Copyright (C) 1999,99 Drotos Daniel, Talker Bt. + * + * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu + * + */ + +/* This file is part of microcontroller simulator: ucsim. + +UCSIM is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +UCSIM is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with UCSIM; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. */ +/*@1@*/ + +#ifndef APPCL_HEADER +#define APPCL_HEADER + +#include "groupcl.h" + + +class cl_app: public cl_group +{ +public: + class cl_group *desk; + int drawn; +public: + cl_app(char *iname); + ~cl_app(void); + virtual int init(void); + virtual class cl_gin *mk_input(void); + virtual int *mk_palette(void); + virtual class cl_group *mk_desk(class cl_box *ipos); + + virtual int handle_event(struct t_event *event); + virtual int run(void); +}; + + +#endif + +/* End of gui.src/appcl.h */ diff --git a/sim/ucsim/gui.src/bg.cc b/sim/ucsim/gui.src/bg.cc new file mode 100644 index 00000000..d854d307 --- /dev/null +++ b/sim/ucsim/gui.src/bg.cc @@ -0,0 +1,63 @@ +/* + * Simulator of microcontrollers (bg.cc) + * + * Copyright (C) 1999,99 Drotos Daniel, Talker Bt. + * + * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu + * + */ + +/* This file is part of microcontroller simulator: ucsim. + +UCSIM is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +UCSIM is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with UCSIM; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. */ +/*@1@*/ + +#include + +#include "bgcl.h" + + +cl_bg::cl_bg(class cl_box *ipos, char *iname, class cl_app *iapp): + cl_view(ipos, iname, iapp) +{ + options&= ~OF_SELECTABLE; +} + +int * +cl_bg::mk_palette(void) +{ + int *p; + + p= (int*)malloc(1*sizeof(int)); + p[0]= C_DSK_BG; + return(p); +} + +int +cl_bg::draw(void) +{ + int x, y, color= get_color(0); + + wmove(window, 0, 0); + wattrset(window, color); + for (y= 0; y < pos->h; y++) + for (x= 0; x < pos->w; x++) + waddch(window, ACS_CKBOARD); + return(0); +} + + +/* End of gui.src/bg.cc */ diff --git a/sim/ucsim/gui.src/bgcl.h b/sim/ucsim/gui.src/bgcl.h new file mode 100644 index 00000000..968ed819 --- /dev/null +++ b/sim/ucsim/gui.src/bgcl.h @@ -0,0 +1,47 @@ +/* + * Simulator of microcontrollers (bgcl.h) + * + * Copyright (C) 1999,99 Drotos Daniel, Talker Bt. + * + * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu + * + */ + +/* This file is part of microcontroller simulator: ucsim. + +UCSIM is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +UCSIM is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with UCSIM; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. */ +/*@1@*/ + +#ifndef BGCL_HEADER +#define BGCL_HEADER + + +#include "viewcl.h" +#include "appcl.h" + + +class cl_bg: public cl_view +{ +public: + cl_bg(class cl_box *ipos, char *iname, class cl_app *iapp); + virtual int *mk_palette(void); + virtual int draw(void); +}; + + +#endif + +/* End of gui.src/bgcl.h */ diff --git a/sim/ucsim/gui.src/clean.mk b/sim/ucsim/gui.src/clean.mk new file mode 100644 index 00000000..bd548323 --- /dev/null +++ b/sim/ucsim/gui.src/clean.mk @@ -0,0 +1,45 @@ +# uCsim gui.src/clean.mk + +PKGS = serio.src portmon.src + +# Deleting all files created by building the program +# -------------------------------------------------- +clean_local: + rm -f *core *[%~] *.[oa] a + rm -f .[a-z]*~ + +clean: clean_local + @for pkg in $(PKGS); do\ + cd $$pkg && $(MAKE) -f clean.mk clean; cd ..;\ + done + + +# Deleting all files created by configuring or building the program +# ----------------------------------------------------------------- +distclean_local: clean_local + rm -f config.cache config.log config.status + rm -f Makefile *.dep + +distclean: distclean_local + @for pkg in $(PKGS); do\ + cd $$pkg && $(MAKE) -f clean.mk distclean; cd ..;\ + done + + +# Like clean but some files may still exist +# ----------------------------------------- +mostlyclean: clean_local + @for pkg in $(PKGS); do\ + cd $$pkg && $(MAKE) -f clean.mk mostlyclean; cd ..;\ + done + + +# Deleting everything that can reconstructed by this Makefile. It deletes +# everything deleted by distclean plus files created by bison, etc. +# ----------------------------------------------------------------------- +realclean: distclean_local + @for pkg in $(PKGS); do\ + cd $$pkg && $(MAKE) -f clean.mk realclean; cd ..;\ + done + +# End of gui.src/clean.mk diff --git a/sim/ucsim/gui.src/conf.mk b/sim/ucsim/gui.src/conf.mk new file mode 100644 index 00000000..5c33eb3d --- /dev/null +++ b/sim/ucsim/gui.src/conf.mk @@ -0,0 +1,12 @@ +# uCsim gui.src/conf.mk + +# +# Makefile targets to remake configuration +# + +freshconf: Makefile + +Makefile: $(srcdir)/Makefile.in $(PRJDIR)/configure.in + cd $(PRJDIR) && $(SHELL) ./config.status + +# End of gui.src/conf.mk diff --git a/sim/ucsim/gui.src/desk.cc b/sim/ucsim/gui.src/desk.cc new file mode 100644 index 00000000..6808cd7c --- /dev/null +++ b/sim/ucsim/gui.src/desk.cc @@ -0,0 +1,58 @@ +/* + * Simulator of microcontrollers (desk.cc) + * + * Copyright (C) 1999,99 Drotos Daniel, Talker Bt. + * + * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu + * + */ + +/* This file is part of microcontroller simulator: ucsim. + +UCSIM is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +UCSIM is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with UCSIM; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. */ +/*@1@*/ + +#include "deskcl.h" +#include "bgcl.h" + + +int +cl_desk::handle_event(struct t_event *event) +{ + if (cl_group::handle_event(event)) + return(1); + if (event->what == EV_KEY && + event->event.key == KEY_F(6)) + { + select_next(); + return(1); + } + return(0); +} + +int +cl_desk::mk_views(class cl_group *ins_to) +{ + class cl_box b(*pos); + + b.move_rel(0,1); + b.grow(0,-2); + insert(new cl_bg(&b, "background", app)); + return(0); +} + + +/* End of gui.src/desk.cc */ diff --git a/sim/ucsim/gui.src/deskcl.h b/sim/ucsim/gui.src/deskcl.h new file mode 100644 index 00000000..b3346b72 --- /dev/null +++ b/sim/ucsim/gui.src/deskcl.h @@ -0,0 +1,42 @@ +/* + * Simulator of microcontrollers (deskcl.h) + * + * Copyright (C) 1999,99 Drotos Daniel, Talker Bt. + * + * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu + * + */ + +/* This file is part of microcontroller simulator: ucsim. + +UCSIM is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +UCSIM is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with UCSIM; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. */ +/*@1@*/ + +#include "groupcl.h" + + +class cl_desk: public cl_group +{ +public: + cl_desk(class cl_box *ipos, char *iname, class cl_app *iapp): + cl_group(ipos, iname, iapp) {} + virtual int mk_views(class cl_group *ins_to); + + virtual int handle_event(struct t_event *event); +}; + + +/* End of gui.src/deskcl.h */ diff --git a/sim/ucsim/gui.src/event.cc b/sim/ucsim/gui.src/event.cc new file mode 100644 index 00000000..32075897 --- /dev/null +++ b/sim/ucsim/gui.src/event.cc @@ -0,0 +1,126 @@ +/* + * Simulator of microcontrollers (event.cc) + * + * Copyright (C) 1999,99 Drotos Daniel, Talker Bt. + * + * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu + * + */ + +/* This file is part of microcontroller simulator: ucsim. + +UCSIM is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +UCSIM is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with UCSIM; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. */ +/*@1@*/ + +#include "ddconfig.h" + +#include + +//#include + +#include "eventcl.h" + + +cl_input_src::cl_input_src(FILE *ifile, class cl_view *iview) +{ + file= ifile; + view= iview; +} + + +cl_gin::cl_gin(void) +{ + FD_ZERO(&in_set); + max_fdes= 0; + inputs= new cl_list(1, 1); +} + +cl_gin::~cl_gin(void) +{ + delete inputs; +} + + +int +cl_gin::add_input(FILE *ifile, class cl_view *iview) +{ + int d= fileno(ifile); + + inputs->add(new cl_input_src(ifile, iview)); + if (d > max_fdes) + max_fdes= d; + FD_SET(d, &in_set); + return(0); +} + +class cl_input_src * +cl_gin::get_input_src(int fdes) +{ + int i; + + for (i= 0; i < inputs->count; i++) + { + class cl_input_src *s= (class cl_input_src *)(inputs->at(i)); + if (fileno(s->file) == fdes) + return(s); + } + return(0); +} + +int +cl_gin::get_event(struct t_event *event) +{ + fd_set set; + //static struct timeval timeout= {0,0}; + wchar_t c; + + //FD_ZERO(&set); + set= in_set; + //FD_SET(fileno(stdin), &set); + if(::select(/*fileno(stdin)*/max_fdes+1, + &set, NULL, NULL, + NULL/*&timeout*/) > 0) + { + int i; + for (i= 0; i < inputs->count; i++) + { + class cl_input_src *s= (class cl_input_src *)(inputs->at(i)); + if (!s->file || + !(FD_ISSET(fileno(s->file), &set))) + continue; + if (s->view) + { + if (s->file) + { + c= fgetc(s->file); + return(s->view->mk_event(event, s->file, c)); + } + } + else + if ((c= getch()) > 0) + { + event->what= EV_KEY; + event->event.key= c; + return(1); + } + } + } + + return(0); +} + + +/* End of gui.src/event.cc */ diff --git a/sim/ucsim/gui.src/eventcl.h b/sim/ucsim/gui.src/eventcl.h new file mode 100644 index 00000000..4077a72f --- /dev/null +++ b/sim/ucsim/gui.src/eventcl.h @@ -0,0 +1,96 @@ +/* + * Simulator of microcontrollers (eventcl.h) + * + * Copyright (C) 1999,99 Drotos Daniel, Talker Bt. + * + * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu + * + */ + +/* This file is part of microcontroller simulator: ucsim. + +UCSIM is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +UCSIM is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with UCSIM; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. */ +/*@1@*/ + +#ifndef EVENTCL_HEADER +#define EVENTCL_HEADER + +#include "ddconfig.h" + +#if FD_HEADER_OK +# include HEADER_FD +#endif + +#include "pobjcl.h" + +#include "viewcl.h" + + +#define EV_NOTHING 0x0000 +#define EV_MOUSE_DOWN 0x0001 +#define EV_MOUSE_UP 0x0002 +#define EV_MOUSE_MOVE 0x0004 +#define EV_MOUSE_AUTO 0x0008 +#define EV_KEY 0x0010 +#define EV_COMMAND 0x0100 +#define EV_BROADCAST 0x0200 + +// cathegories +#define EV_MOUSE (EV_MOUSE_DOWN|EV_MOUSE_UP|EV_MOUSE_MOVE|EV_MOUSE_AUTO) +#define EV_KEYBOARD EV_KEY +#define EV_MESSAGE 0xff00 + +#define CMD_QUIT 0 + +struct t_event { + int what; + union { + wchar_t key; + struct { + int cmd; + long param; + } msg; + } event; +}; + + +class cl_input_src: public cl_base +{ +public: + FILE *file; + class cl_view *view; + cl_input_src(FILE *ifile, class cl_view *iview); +}; + +class cl_gin: public cl_base +{ +public: + fd_set in_set; + int max_fdes; + cl_list *inputs; +public: + cl_gin(void); + ~cl_gin(void); + + virtual int add_input(FILE *ifile, class cl_view *iview); + virtual class cl_input_src *get_input_src(int fdes); + virtual int get_event(struct t_event *event); +}; + + +#endif + +/* End of gui.src/eventcl.h */ diff --git a/sim/ucsim/gui.src/frame.cc b/sim/ucsim/gui.src/frame.cc new file mode 100644 index 00000000..b6b00e8d --- /dev/null +++ b/sim/ucsim/gui.src/frame.cc @@ -0,0 +1,76 @@ +/* + * Simulator of microcontrollers (frame.cc) + * + * Copyright (C) 1999,99 Drotos Daniel, Talker Bt. + * + * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu + * + */ + +/* This file is part of microcontroller simulator: ucsim. + +UCSIM is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +UCSIM is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with UCSIM; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. */ +/*@1@*/ + +#include "ddconfig.h" + +#include +#include "i_string.h" + +#include "framecl.h" +#include "wincl.h" + + +cl_frame::cl_frame(class cl_box *ipos, class cl_view *iwindow, char *iname, + class cl_app *iapp): + cl_view(ipos, iname, iapp) +{ + win= iwindow; + options&= ~OF_SELECTABLE; +} + +int * +cl_frame::mk_palette(void) +{ + int *p; + + p= (int*)malloc(2*sizeof(int)); + p[0]= C_WIN_FPASSIVE; + p[1]= C_WIN_FACTIVE; + return(p); +} + +int +cl_frame::draw(void) +{ + char *t; + int color; + + color= get_color((win && (win->state&SF_SELECTED))?1:0); + wattrset(window, color); + box(window, ACS_VLINE, ACS_HLINE); + if (!(t= strdup(((class cl_win *)win)->get_title()))) + return(0); + if ((signed)strlen(t) > (pos->w)-4) + t[(pos->w)-4]= '\0'; + mvwprintw(window, 0,((pos->w)-strlen(t))/2, "[%s]", t); + free(t); + app->drawn++; + return(0); +} + + +/* End of gui.src/frame.cc */ diff --git a/sim/ucsim/gui.src/framecl.h b/sim/ucsim/gui.src/framecl.h new file mode 100644 index 00000000..6a3c06a1 --- /dev/null +++ b/sim/ucsim/gui.src/framecl.h @@ -0,0 +1,48 @@ +/* + * Simulator of microcontrollers (framecl.h) + * + * Copyright (C) 1999,99 Drotos Daniel, Talker Bt. + * + * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu + * + */ + +/* This file is part of microcontroller simulator: ucsim. + +UCSIM is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +UCSIM is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with UCSIM; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. */ +/*@1@*/ + +#ifndef FRAMELCL_HEADER +#define FRAMELCL_HEADER + +#include "viewcl.h" +#include "appcl.h" + + +class cl_frame: public cl_view +{ + class cl_view *win; +public: + cl_frame(class cl_box *ipos, class cl_view *iwindow, char *iname, + class cl_app *iapp); + virtual int *mk_palette(void); + virtual int draw(void); +}; + + +#endif + +/* End of gui.src/framecl.h */ diff --git a/sim/ucsim/gui.src/group.cc b/sim/ucsim/gui.src/group.cc new file mode 100644 index 00000000..45bb0e4f --- /dev/null +++ b/sim/ucsim/gui.src/group.cc @@ -0,0 +1,393 @@ +/* + * Simulator of microcontrollers (group.cc) + * + * Copyright (C) 1999,99 Drotos Daniel, Talker Bt. + * + * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu + * + */ + +/* This file is part of microcontroller simulator: ucsim. + +UCSIM is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +UCSIM is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with UCSIM; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. */ +/*@1@*/ + +#include "groupcl.h" +#include "appcl.h" + + +cl_group::cl_group(class cl_box *ipos, char *iname, class cl_app *iapp): + cl_view(ipos, iname, iapp) +{ + current= 0; +} + +cl_group::cl_group(char *iname, class cl_app *iapp): + cl_view(iname, iapp) +{ + current= 0; +} + +cl_group::~cl_group(void) +{} + +int +cl_group::init(void) +{ + cl_view::init(); + mk_views(this); + return(0); +} + +int +cl_group::mk_views(class cl_group *ins_to) +{ + return(0); +} + + +/* + * Make output by drawing all subviews + */ + +static void do_draw_view(class cl_view *view) +{ + view->draw(); +} + +int +cl_group::draw(void) +{ + /*int i; + + for (i= 0; i < views->count; i++) + { + class cl_view *v= (class cl_view *)(views->at(i)); + v->draw(); + app->drawn++; + }*/ + for_each(do_draw_view); + return(0); +} + +/*int +cl_group::update(void) +{ + draw(); + update_panels(); + doupdate(); +}*/ + + +int +cl_group::handle_event(struct t_event *event) +{ + int handled= 0; + + if (event->what & (EV_KEY|EV_COMMAND)) + { + if (current) + handled= current->handle_event(event); + } + else if (event->what & EV_MESSAGE) + { + class cl_view *v= last; + do + { + handled= v->handle_event(event); + v= v->next; + } + while (! handled && + v != last); + } + return(handled); +} + + +/* + * Managing views + */ + +//class cl_view * +void +cl_group::insert(class cl_view *view) +{ + /*if (view && + view->ok()) + { + views->add_at(0, view); + view->parent= this; + view->select(); + //view->draw(); + return(view); + } + return(0);*/ + insert_before(view, first()); + if (view->options & OF_SELECTABLE) + view->select(); + draw(); +} + +void +cl_group::insert_before(class cl_view *view, class cl_view *target) +{ + unsigned int ss; + + if (view && + !(view->parent) && + (!target || + target->parent == this)) + { + ss= view->state; + //view->hide(); + insert_view(view, target); + /*if (ss & SF_VISIBLE) + view->show();*/ + if (state & SF_ACTIVE) + view->change_state(SF_ACTIVE, 1); + } +} + +void +cl_group::insert_view(class cl_view *view, class cl_view *target) +{ + view->parent= this; + if (target) + { + target= target->prev(); + view->next= target->next; + target->next= view; + } + else + { + if (!last) + view->next= view; + else + { + view->next= last->next; + last->next= view; + } + last= view; + } +} + +class cl_view * +cl_group::first(void) +{ + if (!last) + return(0); + return(last->next); +} + + +/*class cl_view * +cl_group::get_by_state(unsigned int what, int enabled) +{ + int i; + + for (i= 0; i < views->count; i++) + { + class cl_view *v= (class cl_view *)(views->at(i)); + if ((enabled && + (state&what)) + || + (!enabled && + ((~state)&what)) + ) + return(v); + } + return(0); +}*/ + +/*int +cl_group::select(void) +{ +}*/ + +/*int +cl_group::unselect(void) +{ +}*/ + +int +cl_group::select_next() +{ + /* int start, i; + class cl_view *v; + + if (views->count <= 1) + return(1); + if (current) + start= views->index_of(current); + else + if ((v= get_by_state(SF_SELECTED, 1))) + start= views->index_of(v); + else + if ((v= get_by_state(SF_FOCUSED, 1))) + start= views->index_of(v); + else + start= 0; + i= (start+1)%(views->count); + while (i != start) + { + v= (class cl_view *)(views->at(i)); + if ((v->options & OF_SELECTABLE) && + v->select()) + { + //update(); + return(1); + } + i= (i+1)%(views->count); + }*/ + return(0); +} + +int +cl_group::select_prev() +{ + /* int start, i; + class cl_view *v; + + if (views->count <= 1) + return(1); + if (current) + start= views->index_of(current); + else + if ((v= get_by_state(SF_SELECTED, 1))) + start= views->index_of(v); + else + if ((v= get_by_state(SF_FOCUSED, 1))) + start= views->index_of(v); + else + start= 0; + i= start-1; if (i < 0) i= views->count-1; + while (i != start) + { + v= (class cl_view *)(views->at(i)); + if ((v->options & OF_SELECTABLE) && + v->select()) + { + //update(); + return(1); + } + i= start-1; if (i < 0) i= views->count-1; + }*/ + return(0); +} + +class cl_view * +cl_group::current_sub_view(void) +{ + return(current); +} + +void +cl_group::for_each(void (*func)(class cl_view *view)) +{ + class cl_view *v; + + if (!last) + return; + v= last->next; + do + { + func(v); + v= v->next; + } + while (v != last); +} + +void +cl_group::set_current(class cl_view *view) +{ + //current= view; + if (current == view) + return; + //lock(); + /*focus_view(view, 0);*/ + if ((state & SF_FOCUSED) && + (current != 0)) + current->change_state(SF_FOCUSED, 0); + //if (mode!=ENTER_SELECT) select_view(current, 0); + if (current) + current->change_state(SF_SELECTED, 0); + //if (mode!=LEAVE_SELECT) select_view(view, 1); + if (view) + view->change_state(SF_SELECTED, 1); + //focuse_view(view, 1); + if ((state & SF_FOCUSED) && + (view != 0)) + view->change_state(SF_SELECTED, 1); + current= view; + //unlock(); +} + +/*int +cl_group::terminal_view(void) +{ + return(views->count == 0); +}*/ + +static unsigned int grp_what, grp_en; + +static void +do_set_state(class cl_view *v) +{ + v->change_state(grp_what, grp_en); +} + +void +cl_group::change_state(unsigned int what, int enable) +{ + cl_view::change_state(what, enable); + /*if (enable && + (what & SF_SELECTED)) + { + class cl_view *v= get_by_state(SF_SELECTED, 1); + if (v) + { + current= v; + current->change_state(SF_FOCUSED, 1); + current->change_state(SF_SELECTED, 1); + } + else + { + if ((v= get_by_state(SF_FOCUSED, 1))) + { + current= v; + current->change_state(SF_SELECTED, 1); + } + } + }*/ + switch (what) + { + case SF_ACTIVE: + //lock(); + grp_what= what; + grp_en= enable; + for_each(do_set_state); + //unlock(); + break; + case SF_FOCUSED: + if (current) + current->change_state(SF_FOCUSED, enable); + break; + } + draw(); +} + + +/* End of gui.src/group.cc */ diff --git a/sim/ucsim/gui.src/groupcl.h b/sim/ucsim/gui.src/groupcl.h new file mode 100644 index 00000000..87f0ba88 --- /dev/null +++ b/sim/ucsim/gui.src/groupcl.h @@ -0,0 +1,70 @@ +/* + * Simulator of microcontrollers (groupcl.h) + * + * Copyright (C) 1999,99 Drotos Daniel, Talker Bt. + * + * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu + * + */ + +/* This file is part of microcontroller simulator: ucsim. + +UCSIM is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +UCSIM is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with UCSIM; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. */ +/*@1@*/ + +#ifndef GROUPCL_HEADER +#define GROUPCL_HEADER + +#include "viewcl.h" + +class cl_group: public cl_view +{ +public: + class cl_view *current; + +public: + cl_group(class cl_box *ipos, char *iname, class cl_app *iapp); + cl_group(char *iname, class cl_app *iapp); + ~cl_group(void); + virtual int init(void); + virtual int mk_views(class cl_group *ins_to); + virtual int is_group(void) {return(1);} + + virtual int draw(void); + //virtual int update(void); + + virtual int handle_event(struct t_event *event); + + virtual /*class cl_view **/void insert(class cl_view *view); + virtual void insert_before(class cl_view *view, class cl_view *target); + virtual void insert_view(class cl_view *view, class cl_view *target); + virtual class cl_view *first(void); + virtual void for_each(void (*func)(class cl_view *view)); + //virtual class cl_view *get_by_state(unsigned int what, int enabled); + //virtual int select(void); + //virtual int unselect(void); + virtual int select_next(); + virtual int select_prev(); + virtual class cl_view *current_sub_view(void); + virtual void set_current(class cl_view *view); + //virtual int terminal_view(void); + virtual void change_state(unsigned int what, int enable); +}; + + +#endif + +/* End of gui.src/groupcl.h */ diff --git a/sim/ucsim/gui.src/label.cc b/sim/ucsim/gui.src/label.cc new file mode 100644 index 00000000..90c54a36 --- /dev/null +++ b/sim/ucsim/gui.src/label.cc @@ -0,0 +1,74 @@ +/* + * Simulator of microcontrollers (label.cc) + * + * Copyright (C) 1999,99 Drotos Daniel, Talker Bt. + * + * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu + * + */ + +/* This file is part of microcontroller simulator: ucsim. + +UCSIM is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +UCSIM is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with UCSIM; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. */ +/*@1@*/ + +#include "ddconfig.h" + +#include +#include "i_string.h" + +#include "labelcl.h" + + +cl_label::cl_label(class cl_box *ipos, class cl_app *iapp, char *ilabel): + cl_view(ipos, "label", iapp) +{ + options&= ~OF_SELECTABLE; + if (!ilabel || + !(*ilabel)) + label= strdup(""); + else + label= strdup(ilabel); +} + +cl_label::~cl_label(void) +{ + free(label); +} + +int * +cl_label::mk_palette(void) +{ + int *p; + + p= (int*)malloc(1*sizeof(int)); + p[0]= C_WIN_NORMAL; + return(p); +} + +int +cl_label::draw(void) +{ + int color= get_color(0); + + cl_view::draw(); + wattrset(window, color); + mvwprintw(window, 0,0, "%s", label); + return(0); +} + + +/* End of gui.src/label.cc */ diff --git a/sim/ucsim/gui.src/labelcl.h b/sim/ucsim/gui.src/labelcl.h new file mode 100644 index 00000000..79d62886 --- /dev/null +++ b/sim/ucsim/gui.src/labelcl.h @@ -0,0 +1,50 @@ +/* + * Simulator of microcontrollers (labelcl.h) + * + * Copyright (C) 1999,99 Drotos Daniel, Talker Bt. + * + * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu + * + */ + +/* This file is part of microcontroller simulator: ucsim. + +UCSIM is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +UCSIM is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with UCSIM; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. */ +/*@1@*/ + +#ifndef LABELCL_HEADER +#define LABELCL_HEADER + + +#include "viewcl.h" +#include "appcl.h" + + +class cl_label: public cl_view +{ +public: + char *label; +public: + cl_label(class cl_box *ipos, class cl_app *iapp, char *ilabel); + ~cl_label(void); + virtual int *mk_palette(void); + virtual int draw(void); +}; + + +#endif + +/* End of gui.src/labelcl.h */ diff --git a/sim/ucsim/gui.src/palette.h b/sim/ucsim/gui.src/palette.h new file mode 100644 index 00000000..6f9d383f --- /dev/null +++ b/sim/ucsim/gui.src/palette.h @@ -0,0 +1,44 @@ +/* + * Simulator of microcontrollers (palette.h) + * + * Copyright (C) 1999,99 Drotos Daniel, Talker Bt. + * + * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu + * + */ + +/* This file is part of microcontroller simulator: ucsim. + +UCSIM is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +UCSIM is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with UCSIM; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. */ +/*@1@*/ + +#ifndef PALETTE_HEADER +#define PALETTE_HEADER + + +#define C_DSK_BG 1 +#define C_DSK_NORMAL 2 +#define C_DSK_DISABLED 3 + +#define C_WIN 8 +#define C_WIN_FPASSIVE 0 +#define C_WIN_FACTIVE 1 +#define C_WIN_NORMAL 5 +#define C_WIN_SELECTED 6 + +#endif + +/* End of gui.src/palette.h */ diff --git a/sim/ucsim/gui.src/view.cc b/sim/ucsim/gui.src/view.cc new file mode 100644 index 00000000..9ead6f48 --- /dev/null +++ b/sim/ucsim/gui.src/view.cc @@ -0,0 +1,356 @@ +/* + * Simulator of microcontrollers (view.cc) + * + * Copyright (C) 1999,99 Drotos Daniel, Talker Bt. + * + * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu + * + */ + +/* This file is part of microcontroller simulator: ucsim. + +UCSIM is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +UCSIM is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with UCSIM; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. */ +/*@1@*/ + +#include "ddconfig.h" + +#include +#include "i_string.h" + +#include "appcl.h" + + +/* + * Box + */ + +cl_box::cl_box(int ix, int iy, int iw, int ih): + cl_base() +{ + x= ix; + y= iy; + w= iw; + h= ih; +} + +void +cl_box::set(int ix, int iy, int iw, int ih) +{ + x= ix; + y= iy; + w= iw; + h= ih; +} + +void +cl_box::move_rel(int dx, int dy) +{ + x+= dx; + y+= dy; +} + +void +cl_box::grow(int dw, int dh) +{ + w+= dw; + h+= dh; +} + + +/* + * Astbract of a viewer + ****************************************************************************** + */ + +cl_view::cl_view(class cl_box *ipos, char *iname, class cl_app *iapp): + cl_base() +{ + pos= new cl_box(ipos->x,ipos->y, ipos->w,ipos->h); + if ((window= newwin(pos->h,pos->w, pos->y,pos->x))) + { + leaveok(window, TRUE); + panel= new_panel(window); + } + else + { + panel= 0; + delwin(window); + window= 0; + } + parent= 0; + next= last= 0; + app= iapp; + state= SF_NOTHING; + options= OF_SELECTABLE; + if (!iname || + !(*iname)) + { + name= (char*)malloc(100); + sprintf(name, "view%p", this); + } + else + name= strdup(iname); +} + +cl_view::cl_view(char *iname, class cl_app *iapp): + cl_base() +{ + window= 0; + panel= 0; + parent= 0; + next= last= 0; + app= iapp; + state= SF_NOTHING; + options= OF_SELECTABLE; + if (!iname || + !(*iname)) + { + name= (char*)malloc(100); + sprintf(name, "view%p", this); + } + else + name= strdup(iname); +} + +cl_view::~cl_view(void) +{ + if (panel) + del_panel(panel); + if (window) + delwin(window); + if (palette) + free(palette); + if (name) + free(name); +} + +int +cl_view::init(void) +{ + input= mk_input(); + palette= mk_palette(); + //draw(); + return(0); +} + +class cl_gin * +cl_view::mk_input(void) +{ + return(0); +} + +int * +cl_view::mk_palette(void) +{ + return(0); +} + +int +cl_view::ok(void) +{ + return(window && panel); +} + + +/* + * Make output into the view + */ + +int +cl_view::draw(void) +{ + int color, x, y; + + color= get_color(palette?0:C_WIN_NORMAL); + + wattrset(window, color); + for (y= 0; y < pos->h; y++) + for (x= 0; x < pos->w; x++) + mvwaddch(window, y,x, ' '); + app->drawn++; + + return(0); +} + +int +cl_view::update(void) +{ + draw(); + update_panels(); + doupdate(); + return(0); +} + +int +cl_view::get_color(int color) +{ + int *p; + class cl_view *v; + + v= this; + while (v) + { + p= v->get_palette(); + if (p) + color= p[color]; + v= v->parent; + } + return(color); +} + +int * +cl_view::get_palette(void) +{ + return(palette); +} + + +/* + * Event handling + */ + +int +cl_view::get_event(struct t_event *event) +{ + if (parent) + return(parent->get_event(event)); + if (input) + return(input->get_event(event)); + return(0); +} + +int +cl_view::handle_event(struct t_event *event) +{ + return(0); +} + +int +cl_view::unhandled(struct t_event *event) +{ + return(0); +} + +int +cl_view::mk_event(struct t_event *event, FILE *f, int key) +{ + event->what= EV_KEY; + event->event.key= key; + return(1); +} + + +class cl_view * +cl_view::prev(void) +{ + class cl_view *v; + + v= next; + while (v != this) + v= v->next; + return(v); +} + +class cl_view * +cl_view::prev_view(void) +{ + if (parent && + parent->first() == this) + return(0); + else + return(prev()); +} + + +int +cl_view::select(void) +{ + /* class cl_view *v; + + if (!(options & OF_SELECTABLE)) + return(0); + if (state & SF_SELECTED) + return(1); + if (parent && + !(parent->select())) + return(0); + if (parent) + { + v= parent->current_sub_view(); + if (v && + v != this) + v->unselect(); + parent->set_current(this); + } + change_state(SF_FOCUSED, 1); + change_state(SF_SELECTED, 1); + draw(); + return(1);*/ + if (options & OF_SELECTABLE) + if (parent) + parent->set_current(this); + return(1); +} + +int +cl_view::unselect(void) +{ + class cl_view *csv= current_sub_view(); + if (csv && + !(csv->unselect())) + return(0); + if (!terminal_view()) + change_state(SF_FOCUSED, 0); + change_state(SF_SELECTED, 0); + draw(); + return(1); +} + +class cl_view * +cl_view::current_sub_view(void) +{ + return(0); +} + +int +cl_view::terminal_view(void) +{ + return(1); +} + +void +cl_view::change_state(unsigned int what, int enable) +{ + if (enable) + state|= what; + else + state&= ~what; + if (parent) + { + switch (what) + { + case SF_FOCUSED: + //reset_cursor(); + /*message(parent, EV_BROADCAST, + (enable)?CM_RECEIVED_FOCUS:CM_RELEASED_FOCUS, this);*/ + break; + } + } + draw(); +} + + +/* End of gui.src/view.cc */ diff --git a/sim/ucsim/gui.src/viewcl.h b/sim/ucsim/gui.src/viewcl.h new file mode 100644 index 00000000..668fee16 --- /dev/null +++ b/sim/ucsim/gui.src/viewcl.h @@ -0,0 +1,118 @@ +/* + * Simulator of microcontrollers (viewcl.h) + * + * Copyright (C) 1999,99 Drotos Daniel, Talker Bt. + * + * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu + * + */ + +/* This file is part of microcontroller simulator: ucsim. + +UCSIM is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +UCSIM is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with UCSIM; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. */ +/*@1@*/ + +#ifndef VIEWCL_HEADER +#define VIEWCL_HEADER + +#include +#include + +#include "pobjcl.h" + +#include "palette.h" +#include "eventcl.h" + + +// Status flags +#define SF_NOTHING 0x0000 +#define SF_SELECTED 0x0001 +#define SF_FOCUSED 0x0002 +#define SF_ACTIVE 0x0004 + +// Option flags +#define OF_NOTHING 0x0000 +#define OF_SELECTABLE 0x0001 + + +class cl_box: public cl_base +{ +public: + int x, y; + int w, h; +public: + cl_box(int ix, int iy, int iw, int ih); + void set(int ix, int iy, int iw, int ih); + void move_rel(int dx, int dy); + void grow(int dw, int dh); +}; + + +class cl_app; +class cl_group; + +class cl_view: public cl_base +{ +public: + char *name; + WINDOW *window; + PANEL *panel; + class cl_group *parent; + class cl_view *next, *last; + class cl_app *app; + class cl_gin *input; + class cl_box *pos; + int *palette; + unsigned int state; // See SF_XXXX + unsigned int options; // See OF_XXXX +public: + cl_view(class cl_box *ipos, char *iname, class cl_app *iapp); + cl_view(char *name, class cl_app *iapp); + ~cl_view(void); + virtual int init(void); + virtual class cl_gin *mk_input(void); + virtual int *mk_palette(void); + virtual int is_group(void) {return(0);} + + virtual int ok(void); + virtual int draw(void); + virtual int update(void); + virtual int get_color(int color); + virtual int *get_palette(void); + + virtual int get_event(struct t_event *event); + virtual int handle_event(struct t_event *event); + virtual int unhandled(struct t_event *event); + virtual int mk_event(struct t_event *event, FILE *f, int key); + + virtual class cl_view *prev(void); + virtual class cl_view *prev_view(void); + + virtual int select(void); + virtual int unselect(void); + virtual class cl_view *get_by_state(unsigned int what, int enabled) + {return(0);} + virtual int select_next() {return(0);} + virtual class cl_view *current_sub_view(void); + virtual void set_current(class cl_view *view) {} + virtual int terminal_view(void); + virtual void change_state(unsigned int what, int enable); +}; + + +#endif + +/* End of gui.src/viewcl.h */ diff --git a/sim/ucsim/gui.src/win.cc b/sim/ucsim/gui.src/win.cc new file mode 100644 index 00000000..b5a9a927 --- /dev/null +++ b/sim/ucsim/gui.src/win.cc @@ -0,0 +1,111 @@ +/* + * Simulator of microcontrollers (win.cc) + * + * Copyright (C) 1999,99 Drotos Daniel, Talker Bt. + * + * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu + * + */ + +/* This file is part of microcontroller simulator: ucsim. + +UCSIM is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +UCSIM is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with UCSIM; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. */ +/*@1@*/ + +#include "ddconfig.h" + +#include +#include "i_string.h" + +#include "wincl.h" + + +cl_win::cl_win(class cl_box *ipos, char *ititle, class cl_app *iapp): + cl_group(ipos, 0, iapp) +{ + title= strdup(ititle); + free(name); + if (!ititle || + !(*ititle)) + { + name= (char*)malloc(100); + sprintf(name, "win%p", this); + } + else + name= strdup(ititle); +} + +cl_win::~cl_win(void) +{ + if (frame) + delete frame; + if (title) + free(title); +} + +int +cl_win::init(void) +{ + cl_group::init(); + if ((frame= mk_frame(pos))) + insert(frame); + class cl_box *b= new cl_box(pos->x,pos->y, pos->w,pos->h); + b->move_rel(1,1); + b->grow(-2,-2); + if ((intern= mk_intern(b))) + insert(intern); + //draw(); + delete b; + return(0); +} + +int * +cl_win::mk_palette(void) +{ + int *p= (int*)malloc(8*sizeof(int)), i; + for (i= 0; i < 8; i++) + p[i]= i+C_WIN; + return(p); +} + +class cl_frame * +cl_win::mk_frame(class cl_box *ipos) +{ + char n[100]= ""; + + sprintf(n, "frameof_\"%s\"", name); + class cl_frame *f= new cl_frame(ipos, this, n, app); + f->init(); + return(f); +} + +class cl_view * +cl_win::mk_intern(class cl_box *ipos) +{ + class cl_view *v= new cl_view(ipos, 0, app); + v->init(); + v->options&= ~OF_SELECTABLE; + return(v); +} + +char * +cl_win::get_title(void) +{ + return(title); +} + + +/* End of gui.src/win.cc */ diff --git a/sim/ucsim/gui.src/wincl.h b/sim/ucsim/gui.src/wincl.h new file mode 100644 index 00000000..ddbd0a9e --- /dev/null +++ b/sim/ucsim/gui.src/wincl.h @@ -0,0 +1,55 @@ +/* + * Simulator of microcontrollers (wincl.h) + * + * Copyright (C) 1999,99 Drotos Daniel, Talker Bt. + * + * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu + * + */ + +/* This file is part of microcontroller simulator: ucsim. + +UCSIM is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +UCSIM is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with UCSIM; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. */ +/*@1@*/ + +#ifndef WINCL_HEADER +#define WINCL_HEADER + +#include "groupcl.h" +#include "framecl.h" + + +class cl_win: public cl_group +{ +public: + class cl_view *frame; + class cl_view *intern; + char *title; +public: + cl_win(class cl_box *ipos, char *ititle, class cl_app *iapp); + ~cl_win(void); + virtual int init(void); + virtual int *mk_palette(void); + virtual class cl_frame *mk_frame(class cl_box *ipos); + virtual class cl_view *mk_intern(class cl_box *ipos); + + virtual char *get_title(void); +}; + + +#endif + +/* End of gui.src/wincl.h */