--- /dev/null
+/*
+ * 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. */
--- /dev/null
+#
+# 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
--- /dev/null
+/*
+ * 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 */
--- /dev/null
+# 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
--- /dev/null
+/*
+ * 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 */
--- /dev/null
+/*
+ * 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 */
--- /dev/null
+/*
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <sys/types.h>
+#ifdef HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+# include <netinet/in.h>
+# include <arpa/inet.h>
+#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 */
--- /dev/null
+/*
+ * 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 */
--- /dev/null
+#
+# Makefile targets to remake configuration
+#
+
+freshconf: Makefile
+
+Makefile: $(srcdir)/Makefile.in $(PRJDIR)/configure.in
+ cd $(PRJDIR) && $(SHELL) ./config.status
+
+# End of conf.mk
--- /dev/null
+/*
+ * 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 */
--- /dev/null
+/*
+ * 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 <stdlib.h>
+#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 */
--- /dev/null
+/*
+ * 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 */
--- /dev/null
+/*
+ * 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 <stdio.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#ifdef HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+# include <netinet/in.h>
+# include <arpa/inet.h>
+# include <netdb.h>
+#endif
+#include <sys/time.h>
+#if FD_HEADER_OK
+# include HEADER_FD
+#endif
+#include <unistd.h>
+#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 */
--- /dev/null
+/*
+ * 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 <stdio.h>
+#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 */
--- /dev/null
+/*
+ * 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 */
--- /dev/null
+/*
+ * 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 */
--- /dev/null
+/*
+ * 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 */
--- /dev/null
+/*
+ * 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 */
--- /dev/null
+#
+# 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
--- /dev/null
+<html>
+<head>
+<title>UCSIM: Code Analyzer</title>
+</head>
+
+<body bgcolor="white">
+
+<h1>Code analyzer</h1>
+
+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 <i>jump</i> instruction it continues with
+destination address of the <i>jump</i> instruction. If it finds a
+<i>call</i> instruction, it recursively analyzes destination address
+as well as next instruction follows the <i>call</i> one. Analyzator
+stops if it finds an address which is already marked or if it finds a
+<i>return</i> instruction or an indirect <i>jump</i> which is
+impossible to follow. All these mean that it is impossible to discover
+all instructions of the program.
+
+<p>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.
+
+<hr>
+
+</body>
+</html>
--- /dev/null
+# 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
--- /dev/null
+<html>
+<head>
+<title>Commands of s51</title>
+</head>
+
+<body bgcolor="white">
+
+<h1>Command reference of ucsim</h1>
+
+<a href="cmd_general.html">General commands and information</a>
+
+<ul><li><a href="cmd_general.html#h"><b>help,?</b> Help about commands</a>
+<li><a href="cmd_general.html#show"><b>show</b> Show licensing information</a> (<font color="#ff2211">since 0.1.3</font>)
+<li><a href="cmd_general.html#file"><b>file,load FILE</b> Load FILE into ROM</a> (<font
+color="#ff2211">since 0.2.24</font>)<img src="new.gif">
+<li><a href="cmd_general.html#dl"><b>download,dl</b> Download (intel hex) data</a>
+<li><a href="cmd_general.html#q"><b>quit</b> Quit</a>
+(<font color="cmd_general.html#ff2211">changed 0.2.12</font>)
+<li><a href="cmd_general.html#kill"><b>kill</b> Shut down the simulator</a>
+(<font color="#ff2211">since 0.2.12</font>)
+<li><a href="cmd_general.html#reset"><b>reset</b> Reset</a>
+<li><a href="cmd_general.html#wi"><b>wi,Wi</b> Search for string in Internal RAM</a>
+<li><a href="cmd_general.html#wi"><b>wx,Wx</b> Search for string in External RAM</a>
+<li><a href="cmd_general.html#wi"><b>wc,Wc</b> Search for string in ROM</a>
+<li><a href="cmd_general.html#gopt"><b>gopt</b> Get value of option(s)</a>
+<li><a href="cmd_general.html#sopt"><b>sopt</b> Set value of option</a>
+<li><a href="cmd_general.html#conf"><b>conf</b> Configuration</a> (<font color="#ff2211">since 0.2.20</font>)<img src="new.gif">
+<li><a href="cmd_general.html#state"><b>state</b> State of simulator</a> (<font color="#ff2211">since 0.2.19</font>)<img src="new.gif">
+<li><a href="cmd_general.html#info"><b>info</b> Information</a> (<font color="#ff2211">since 0.2.20</font>)<img src="new.gif">
+<li><a href="cmd_general.html#timer"><b>timer a|d|g|r|s|v id [value]</b> Timer add|del|get|run|stop|value</a> (<font color="#ff2211">since 0.2.19</font>)<img src="new.gif">
+</ul>
+
+<a href="cmd_exec.html">Execution</a>
+
+<ul><li><a href="cmd_exec.html#g"><b>g</b> Go</a> (<font color="#ff2211">changed 0.2.12</font>)
+<li><a href="cmd_exec.html#stop"><b>stop</b> Stop</a> (<font color="#ff2211">since 0.2.12</font>)
+<li><a href="cmd_exec.html#s"><b>s</b> Step</a>
+<li><a href="cmd_exec.html#n"><b>n</b> Next</a>
+<li><a href="cmd_exec.html#pc"><b>pc</b> Set/get PC</a> (<font color="#ff2211">since 0.1.5</font>)
+<li><a href="cmd_exec.html#run"><b>run</b> Go</a> (<font color="#ff2211">since 0.2.20</font>)<img src="new.gif">
+</ul>
+
+<a href="cmd_bp.html">Breakpoints</a>
+
+<ul><li><b>bs</b> Set FETCH Breakpoint (<font color="#ff2211">removed
+0.2.20, use <a href="cmd_bp.html#break">break</a> or <a href="cmd_bp.html#tbreak">tbreak</a>
+instead</font>)
+<li><a href="cmd_bp.html#bse"><b>bse</b> Set EVENT Breakpoint</a>
+<li><b>bd</b> Delete FETCH Breakpoint (<font color="#ff2211">removed
+0.2.20</font>, use <a href="cmd_bp.html#clear">clear</a> instead)
+<li><a href="cmd_bp.html#bde"><b>bde</b> Delete EVENT Breakpoint</a>
+<li><a href="cmd_bp.html#ba"><b>ba</b> Delete all breakpoints</a>
+<li><b>bl</b> List Breakpoints (<font color="#ff2211">removed 0.2.20,
+use <a href="cmd_bp.html#info">info breakpoints</a> instead</font>)
+<li><a href="cmd_bp.html#break"><b>break</b> Set fix breakpoint</a> (<font color="#ff2211">since 0.2.20</font>)<img src="new.gif">
+<li><a href="cmd_bp.html#tbreak"><b>tbreak</b> Set fix breakpoint</a> (<font color="#ff2211">since 0.2.20</font>)<img src="new.gif">
+<li><a href="cmd_bp.html#clear"><b>clear</b> Clear fix breakpoint</a> (<font color="#ff2211">since 0.2.20</font>)<img src="new.gif">
+</ul>
+
+<a href="cmd_dump.html">Dump commands</a>
+
+<ul><li><a href="cmd_dump.html#dis"><b>dis</b> Disassemble</a>
+<li><a href="cmd_dump.html#dc"><b>dc</b> Dump code in disass format</a>
+<li><a href="cmd_dump.html#dch"><b>dch</b> Dump code in hex format</a>
+<li><a href="cmd_dump.html#di"><b>di</b> Dump Internal RAM</a>
+<li><a href="cmd_dump.html#dx"><b>dx</b> Dump External RAM</a>
+<li>dr Dump registers</a> (<font color="#ff2211">removed
+0.2.37</font>, use <a href="cmd_general.html#info_reg">info registers</a> instead)
+<li><a href="cmd_dump.html#dp"><b>dp</b> Dump ports</a>
+<li><a href="cmd_dump.html#ds"><b>ds</b> Dump SFR</a>
+<li><a href="cmd_dump.html#db"><b>db</b> Dump bit</a></ul>
+
+<a href="cmd_set.html">Set commands</a>
+
+<ul><li><a href="cmd_set.html#si"><b>si</b> Set Internal RAM</a>
+<li><a href="cmd_set.html#sx"><b>sx</b> Set External RAM</a>
+<li><a href="cmd_set.html#sc"><b>sc</b> Set code (ROM)</a>
+<li><a href="cmd_set.html#ss"><b>ss</b> Set SFR area</a>
+<li><a href="cmd_set.html#sb"><b>sb</b> Set bit</a>
+<li><a href="cmd_set.html#sp"><b>sp</b> Set port pins</a>
+<li><a href="cmd_set.html#fi"><b>fi</b> Fill IRAM area with data</a>
+<li><a href="cmd_set.html#fx"><b>fx</b> Fill XRAM area with data</a>
+<li><a href="cmd_set.html#fs"><b>fs</b> Fill SFR area with data</a>
+<li><a href="cmd_set.html#fc"><b>fc</b> Fill ROM area with data</a>
+</ul>
+
+<hr>
+
+</body>
+</html>
--- /dev/null
+<html>
+<head>
+<title>Breakpoints commands of uCsim</title>
+</head>
+
+<body bgcolor="white">
+
+ <!-- BREAKPOINTS -->
+
+<h2>Commands of uCsim to manage breakpoints</h2>
+
+Two kind of breakpoints can be used: fetch and event
+breakpoint. <B>Fetch</b> 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 <i>before</i> the instruction at location specified by the
+breakpoint would be executed.
+
+<p><b>Event</b> breakpoints are special onces. They cause stop of
+execution if event specified by the breakpoint occures. Events are:
+
+<dl><dt><b>wi</b> <dd>writing into internal RAM at specified location;
+
+<dt><b>ri</b> <dd>reading from internal RAM at specified address;
+
+<dt><b>wx</b> <dd>writing into external RAM at specified location
+(MOVX instruction);
+
+<dt><b>rx</b> <dd>reading from external RAM at specified address (MOVX
+instruction);
+
+<dt><b>ws</b> <dd>writing into SFR area at specified location;
+
+<dt><b>rs</b> <dd>reading from SFR area at specified address;
+
+<dt><b>rc</b> <dd>reading from code memory at specified location (MOVC
+instruction).</dl>
+
+Event breakpoint stops execution <i>after</i> specified event occured.
+
+<p>Every breakpoint can be <b>fix</b> (permanent) or <b>dynamic</b>
+(temporary). Dynamic breakpoints are automatically removed when they
+reached. Some commands place dynamic fetch breakpoints into the code,
+for example <a href="#g"><b>go</b></a> or <a
+href="#n"><b>next</b></a>.
+
+<p>A <b>hit number</b> 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.
+
+
+<a name="break"><h3>break addr [hit]</h3></a>
+<a name="tbreak"><h3>tbreak addr [hit]</h3></a>
+
+Set fetch breakpoint. The command specifies if the breakpoint will be
+fix (<b>break</b>) or dynamic (temporary) (<b>tbreak</b>). First
+parameter specifies address where the breakpoint must be placed to. It
+should be address of an instruction.
+
+<p>Second parameter is optional and it specifies the hit number. It is
+1 by default.
+
+<pre>
+$ <font color="#118811">s51 remoansi.hex</font>
+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
+> <font color="#118811">dc 0 0x10</font>
+ 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
+> <font color="#118811">break 0x160</font>
+Breakpoint 1 at 0x000160: CLR P1.0
+> <font color="#118811">tbreak 8 2</font>
+Breakpoint 2 at 0x000008: MOV R7,A
+> <font color="#118811">g</font>
+Simulation started, PC=0x000000
+Stop at 000160: (4) Breakpoint
+F 000160
+> </pre>
+
+
+<a name="bse"><h3>bse wi|ri|wx|rx|ws|rs|rc f|d addr [hit]</h3></a>
+
+Set event breakpoint. First parameter specifies type of event. See <a
+href="#breakpoints">general description of event breakpoints</a> above
+about meaning of event identifiers. Second parameter specify if the
+breakpoint will be fix (<b>f</b>) or dynamic (<b>d</b>). Third
+parameter specifies address. Remember that this is not an instruction
+address, it is address of the memory cell where specified event should
+occur.
+
+<p>Forth parameter is optional and it specifies the hit number. It is
+1 by default.
+
+<pre>
+$ <font color="#118811">s51 remoansi.hex</font>
+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
+> <font color="#118811">dis</font>
+ 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
+> <font color="#118811">bse wi f 6</font>
+> <font color="#118811">g</font>
+4
+ 000170 7f 00 MOV R7,#00
+> </pre>
+
+
+<a name="clear"><h3>clear [addr...]</h3></a>
+
+Delete fetch breakpoint. Parameter specifies address of breakpoint. If
+there is no breakpoint specified at given address this command prints
+out a warning message.
+
+<p>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.
+
+<pre>
+> <font color="#118811">i b</font>
+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
+> <font color="#118811">clear 160</font>
+No breakpoint at 0000a0
+> <font color="#118811">clear 0x160</font>
+> <font color="#118811">i b</font>
+Num Type Disp Hit Cnt Address What
+2 fetch del 1 1 0x000180 LJMP 022a
+1 event keep 1 1 0x000006 wi
+> </pre>
+
+
+<a name="bde"><h3>bde wi|ri|wx|rx|ws|rs|rc addr</h3></a>
+
+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:
+
+<pre>
+> <font color="#118811">bl</font>
+D 2(2) 000180 02 LJMP 022a
+F 1(1) 000006 wi
+> <font color="#118811">bde ri 6</font>
+No ri breakpoint at 000006
+> <font color="#118811">bde wi 6</font>
+> <font color="#118811">bl</font>
+D 2(2) 000180 02 LJMP 022a
+> </pre>
+
+
+<a name="ba"><h3>ba</h3></a>
+
+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.
+
+<pre>
+> <font color="#118811">bl</font>
+F 1(1) 000160 c2 CLR P1.0
+D 2(2) 000180 02 LJMP 022a
+F 1(1) 000006 wi
+> <font color="#118811">ba</font>
+> <font color="#118811">bl</font>
+> </pre>
+
+
+<hr>
+
+</body>
+</html>
--- /dev/null
+<html>
+<head>
+<title>Dump commands of uCsim</title>
+</head>
+
+<body bgcolor="white">
+
+ <!-- DUMP -->
+
+<h2>Dump commands of uCsim</h2>
+
+<a name="dis"><h3><img src="burst.gif" alt="[Repeatable]"> dis
+[start [offset [lines]]]</h3></a>
+
+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 <b>offset</b> is negative the simulator goes
+backward and skips specified number of instructions. Default value of
+<b>start</b> parameter is last address which was listed by previous
+<b>dis</b> command and default value of <b>offset</b> is -1. It means
+you can make continuous list repeating parameterless <b>dis</b>
+command.
+
+<p>In third parameter you can specify how many instructions you want
+to list. Default value is 20.
+
+<pre>
+$ <font color="#118811">s51 remoansi.hex</font>
+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
+> <font color="#118811">dis</font>
+ 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
+> <font color="#118811">bs f 0x180</font>
+> <font color="#118811">bs d 0x189</font>
+> <font color="#118811">dis 0x180 -3 10</font>
+ 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
+> </pre>
+
+If there is an <b>F</b> or <b>D</b> 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 (<b>*</b>)
+which means that the listed address is not marked by the code
+analyzer. <b>dis</b> 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.
+
+
+<a name="dc"><h3><img src="burst.gif" alt="[Repeatable]"> dc
+[start [stop]]</h3></a>
+
+Disassembled dump of code memory area. This command simply produces
+disassambled list of memory area specified by the parameters. Default
+value of <b>start</b> parameter is last address listed by previous
+<b>dc</b> command. If <b>stop</b> parameter is not given 20 lines are
+listed.
+
+<pre>
+$ <font color="#118811">s51 remoansi.hex</font>
+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
+> <font color="#118811">dc</font>
+ 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
+> </pre>
+
+
+<a name="dch"><h3><img src="burst.gif" alt="[Repeatable]"> dch
+[start [stop]]</h3></a>
+
+Hexadecimal dump of code memory area from address <b>start</b> to
+address <b>stop</b>. Default value of start address is address of
+following memory cell which was dumped by previous <b>dch</b>
+command. If <b>stop</b> parameter is not given <b>dch</b> command
+lists 10 lines 8 bytes per line.
+
+<pre>
+$ <font color="#118811">s51 remo.hex</font>
+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
+> <font color="#118811">wc remo</font>
+0013da 52 65 6d 6f Remo
+> <font color="#118811">dch 0x13da</font>
+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..
+> </pre>
+
+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.
+
+
+<a name="di"><h3><img src="burst.gif" alt="[Repeatable]"> di
+[start [stop]]</h3></a>
+
+Hexadecimal dump of internal RAM area from address <b>start</b> to
+address <b>stop</b>. Default value of start address is address of
+following memory cell which was dumped by previous <b>di</b>
+command. If <b>stop</b> parameter is not given <b>di</b> command
+lists 10 lines 8 bytes per line.
+
+<pre>
+$ <font color="#118811">s51 remoansi.hex</font>
+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
+> <font color="#118811">sopt stopit 1</font>
+> <font color="#118811">g</font>
+Simulation started, PC=0x000000
+Stop at 000023: (5) Interrupt
+F 000023
+> <font color="#118811">di</font>
+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 ........
+> </pre>
+
+
+<a name="dx"><h3><img src="burst.gif" alt="[Repeatable]"> dx
+[start [stop]]</h3></a>
+
+Hexadecimal dump of external RAM area from address <b>start</b> to
+address <b>stop</b>. Default value of start address is address of
+following memory cell which was dumped by previous <b>dx</b>
+command. If <b>stop</b> parameter is not given <b>dx</b> command
+lists 10 lines 8 bytes per line.
+
+<pre>
+$ <font color="#118811">s51 remoansi.hex</font>
+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
+> <font color="#118811">sopt stopit 1</font>
+> <font color="#118811">g</font>
+Simulation started, PC=0x000000
+Stop at 000023: (5) Interrupt
+F 000023
+> <font color="#118811">dx 0x100</font>
+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 ..$.....
+> </pre>
+
+
+<a name="dp"><h3>dp</h3></a>
+
+Dump out ports. This command shows actual value of ports.
+
+<pre>
+$ <font color="#118811">s51 remoansi.hex</font>
+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
+> <font color="#118811">sopt stopit 1</font>
+> <font color="#118811">g</font>
+5
+ * 000023 02 01 1c LJMP 011c
+> <font color="#118811">dp</font>
+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 .
+> </pre>
+
+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 <a
+href="#sp"><b>sp</b></a> 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:
+
+<p><tt>Portx= Px AND Pinx</tt>
+
+<p>All three values are displayed in binary, hexadecimal, decimal form
+and then the ASCII character of the value is shown.
+
+
+<a name="ds"><h3>ds [addr...]</h3></a>
+
+Print out SFR. This command can be used to get value of all or some
+SFRs. If you do not specify any parameter the <b>ds</b> command simply
+dumps out full SFR area 16 bytes per line.
+
+<pre>
+$ <font color="#118811">s51 remoansi.hex</font>
+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
+> <font color="#118811">sopt stopit 1</font>
+> <font color="#118811">g</font>
+5
+ * 000023 02 01 1c LJMP 011c
+> <font color="#118811">ds</font>
+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 ................
+> <font color="#118811">ds p1 0x87</font>
+ P1 fe 254 .
+000087 00 0 .
+> <font color="#118811">ds p2 ip scon</font>
+ P2 ff 255 .
+ IP 15 21 .
+ SCON 7e 126 ~
+> </pre>
+
+If you specify one or more parameter the <b>ds</b> 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.
+
+<p>Note that different type of controllers can implement different
+registers:
+
+<pre>
+$ <font color="#118811">s51</font>
+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.
+> <font color="#118811">ds rcap2l</font>
+> <font color="#118811">q</font>
+$ <font color="#118811">s51 -t 52</font>
+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.
+> <font color="#118811">ds rcap2l</font>
+RCAP2L 00 0 .
+> </pre>
+
+
+<a name="db"><h3><img src="burst.gif" alt="[Repeatable]"> db
+addr...</h3></a>
+
+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.
+
+<pre>
+$ <font color="#118811">s51</font>
+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.
+> <font color="#118811">db it1 0x20.3 0x43 p2.5</font>
+000088 IT1 0
+000020 20.3 0
+000028 28.3 0
+0000a0 P2.5 1
+> </pre>
+
+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:
+
+<pre>
+> <font color="#118811">sp 1 0x0f</font>
+> <font color="#118811">ss p1 0x55</font>
+000090 55 U
+> <font color="#118811">dp</font>
+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 .
+> <font color="#118811">db p1.2 p1.3 p1.4 p1.5 p1.6</font>
+000090 P1.2 1
+000090 P1.3 0
+000090 P1.4 1
+000090 P1.5 0
+000090 P1.6 1
+> </pre>
+
+
+<hr>
+
+</body>
+</html>
--- /dev/null
+<html>
+<head>
+<title>Execution commands of uCsim</title>
+</head>
+
+<body bgcolor="white">
+
+ <!-- EXEC -->
+<h2>Execution commands of uCsim</h2>
+
+
+<a name="g"><h3>g [start [stop]]</h3></a>
+
+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 <b>stopit</b> option
+is TRUE, or fatal error occures or <a href="#stop">stop</a> 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.
+
+<pre>
+$ <font color="#118811">s51 remoansi.hex</font>
+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
+> <font color="#118811">b 0x187</font>
+> <font color="#118811">sopt stopit y</font>
+> <font color="#118811">g</font>
+Simulation started, PC=0x000000
+Stop at 000187: (4) Breakpoint
+F 000187
+> </pre>
+
+After execution is started the <tt>Simulaton started</tt> 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.
+
+<!--If execution stops the simulator first writes out a number which is
+the reason of the stop (this is a diagnostic feature, it will be
+improved in future versions). Reason can be:
+
+<dl><dt>0
+
+<dd>There is no reason to stop. This number should never appear.
+
+<dt>1
+
+<dd>Serious error for example unknown instruction code which is
+impossible to execute.
+
+<dt>2
+
+<dd>Invalid address used in an instruction. For example indirect
+address is bigger then 127 in 51 type of controller. Execution can be
+continued but result will be undefined.
+
+<dt>3
+
+<dd>Stack overflow. Execution can be continued but result will be
+undefined.
+
+<dt>4
+
+<dd>Breakpoint has been reached.
+
+<dt>5
+
+<dd>Interrupt accepted. It only stops the execution if <b>stopit</b>
+option is set to TRUE. See <a href="#sopt">sopt</a> command.
+
+</dl>
+
+After this diagnostic message the simulator prints out intruction at
+the PC in disassembled form. See <a href="#dis"><b>dis</b></a>
+commands for description of disassembled form.
+-->
+
+
+<a name="stop"><h3>stop</h3></a>
+
+This command stops the simulation, it freezes the CPU and all the
+peripherials.
+
+<pre>
+$ <font color="#118811">s51 remoansi.hex</font>
+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
+> <font color="#118811">g</font>
+Simulation started
+> <font color="#118811">dr</font>
+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
+> <font color="#118811">stop</font>
+ 006ac5 24 a5 ADD A,#a5
+>
+</pre>
+
+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 <a href="#dis"><b>dis</b></a> command for
+description of disassembled form.
+
+
+<a name="s"><h3><img src="burst.gif" alt="[Repeatable]"> s
+[step]</h3></a>
+
+Step command. It executes one instruction without effect of
+breakpoints. Optional parameter can specify number of requested
+steps.
+
+<pre>
+$ <font color="#118811">s51 remoansi.hex</font>
+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
+> <font color="#118811">s</font>
+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
+> <font color="#118811">s 2</font>
+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
+> </pre>
+
+After execution of actual instruction pointed by PC the <b>step</b>
+command executes <a href="#dr"><b>dr</b></a> command.
+
+
+<a name="n"><h3><img src="burst.gif" alt="[Repeatable]"> n
+[step]</h3></a>
+
+Execute until next instruction is reached. This command is similar to
+<a href="#s"><b>step</b></a> command described above but if actual
+instruction to execute is a subroutine call the <b>next</b> command
+places a dynamic breakpoint after the call instruction and starts to
+execute the subroutine. If the subroutine is infinite the breakpoint
+set by <b>next</b> will never reached. It can be a dangerous situation
+because the executeion started by the <b>next</b> command can not be
+stopped interactively. But it can be stopped by other breakpoints.
+
+<pre>
+$ <font color="#118811">s51 remoansi.hex</font>
+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
+> <font color="#118811">g 0 0x172</font>
+4
+ 000172 79 04 MOV R1,#04
+> <font color="#118811">dis 0x172 0 5</font>
+ 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
+> <font color="#118811">n 3</font>
+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
+> </pre>
+
+
+<a name="pc"><h3>pc [address]</h3></a>
+
+Using this command without any parameter it simply dumps out
+instruction pointed by the PC. Specify address if you want to set the
+PC.
+
+<pre>
+$ 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.
+> <font color="#118811">pc</font>
+ * 000000 ff MOV R7,A
+> <font color="#118811">pc 123</font>
+ * 00007b ff MOV R7,A
+> <font color="#118811">sopt debug t </font>
+> <font color="#118811">pc 32</font>
+Warning: maybe not instruction at 000020
+ * 000020 ff MOV R7,A
+> </pre>
+
+
+<a name="run"><h3>run</h3></a>
+
+This command starts the execution of the simulated program.
+
+
+<hr>
+
+</body>
+</html>
--- /dev/null
+<html>
+<head>
+<title>General commands of uCsim</title>
+</head>
+
+<body bgcolor="white">
+
+<h2>General commands of uCsim</h2>
+
+ <!-- GENERAL -->
+
+Some commands can be repeated by entering an empty command (just
+pressing ENTER if command console is interactive). This repeats the
+<b>full</b> command entered previously precisely including parameters
+of the command. Repeatable commands are signed with <img
+src="burst.gif" alt="[Repeatable]"> icon.
+
+<p>Some commands accept parameters which in most cases can be
+numbers. Numbers can be entered in C-style form. If the number begins
+whith <tt><b>0x</b></tt> or <tt><b>0X</b></tt> it is interpreted as a
+hexadecimal number. If it begins with <tt><b>0</b></tt> followed by
+digits it is interpreted as octal number. In other cases it is
+interpreted as decimal number.
+
+<p>Every command which changes content of ROM area such as <b><a
+href="#l">l</a></b>, <b><a href="#dl">dl</a></b> or <b><a
+href="#sc">sc</a></b> deletes result of code analyzer and causes to
+re-analyze the code.
+
+
+<a name="show"><h3>show c|w</h3></a>
+
+This command can be used to list licensing information. If <b>c</b>
+option has given, the license is listed. It is first 10 point of the
+version 2 of GNU Genral Public License. Using <b>w</b> 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.
+
+
+<a name="dl"><h3>download,dl</h3></a>
+
+Download command. It is same as <a href="#l">load</a> 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 <b>download</b> and <b>dl</b>.
+
+<pre>
+$ <font color="#118811">s51 -V</font>
+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.
+> <font color="#118811">do
+:03000000020003F8
+:1000030075812078207600D8FC900000AE83AF8203
+:100013009000001200416005E4F0A380F690009F79
+:1000230012004A9000A312004A9000A712006890A1
+:1000330000AD12006875D0001200B50200B3EF6581
+:10004300827003EE658322E493F8740193F97402DA
+:1000530093FE740393F5828E83E869700122E4931F
+:10006300F6A30880F4E493FC740193FD740293FEF9
+:10007300740393FF740493F8740593F582888312D1
+:100083000041700122E493A3A883A9828C838D820B
+:10009300F0A3AC83AD828883898280E3212100B5FC
+:1000A300212100B5000000B500B5000000B500B582
+:0200B30080FECD
+:1000B5007520117501AA850120750102850120228F
+:00000001FF</font>
+197 bytes loaded
+> </pre>
+
+
+<a name="q"><h3>quit</h3></a>
+
+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.
+
+<p>Note that if <a href="invoke.html#Zoption">-Z option</a> was used at
+invokation then the quit command does not terminate the simulator
+program. In this case <a href="#kill">kill</a> command can be used to
+terminate the simulator. See for more information about <a
+href="mulcons.html">using multiple consoles</a>.
+
+<pre>$ <font color="#118811">s51</font>
+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.
+> <font color="#118811">q</font>
+$ </pre>
+
+
+<a name="kill"><h3>kill</h3></a>
+
+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.
+
+
+<a name="h"><h3>help,?</h3></a>
+
+Help command. It prints out short description of the commands.
+
+
+<a name="reset"><h3>reset</h3></a>
+
+Reset command. It resets the microcontroller. It has same effect as
+active signal on the RST pin.
+
+<pre>
+$ <font color="#118811">s51 -V remoansi.hex</font>
+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
+> <font color="#118811">dr</font>
+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
+> <font color="#118811">s 2</font>
+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
+> <font color="#118811">res</font>
+> <font color="#118811">dr</font>
+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
+> </pre>
+
+
+<a name="wi"><h3>wi,Wi string</h3></a>
+
+Searching for specified string in internal RAM area. String is
+interpreted from first non-space sharacter until end of the command
+including spaces. <b>wi</b> command makes case insensitive search and
+<b>Wi</b> 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: <tt>\f</tt>, <tt>\n</tt>,
+<tt>\r</tt>, <tt>\t</tt>, <tt>\v</tt>, <tt>\a</tt>, <tt>\b</tt>,
+<tt>\0</tt>, and <tt>\0xxx</tt> where <tt>xxx</tt> is an octadecimal
+number of the code of the character.
+
+<pre>
+$ <font color="#118811">s51 remoansi.hex</font>
+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
+> <font color="#118811">g</font>
+Simulation started, PC=0x000000
+
+Stop at 00019c: (7) User stopped
+F 00019c
+> <font color="#118811">si 20 Dani DAni</font>
+000014 44 61 6e 69 44 41 6e 69 DaniDAni
+> <font color="#118811">wi dani</font>
+000014 44 61 6e 69 Dani
+000018 44 41 6e 69 DAni
+> <font color="#118811">Wi Dani</font>
+000014 44 61 6e 69 Dani
+> <font color="#118811">wi dani\0</font>
+000018 44 41 6e 69 00 DAni.
+> </pre>
+
+
+<a name="wx"><h3>wx,Wx string</h3></a>
+
+Search commands. These commands are similar to <a href="#wi"><b>wi,
+Wi</b></a> commands the only difference is that <b>wx,Wx</b> are used
+to search for a string in external memory.
+
+
+<a name="wc"><h3>wc,Wc string</h3></a>
+
+Search commands. These commands are similar to <a href="#wi"><b>wi,
+Wi</b></a> commands the only difference is that <b>wx,Wx</b> are used
+to search for a string in code memory area.
+
+
+<a name="gopt"><h3>gopt [opt]</h3></a>
+
+Get actual value of option(s). Some options can be set by <a
+href="#sopt"><b>sopt</b></a> to modify behavior of the
+simulator. Using <b>gopt</b> 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.
+
+<pre>
+$ <font color="#118811">s51 -V</font>
+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.
+> <font color="#118811">gopt</font>
+verbose TRUE Verbose flag.
+stopit FALSE Stop if interrupt accepted.
+debug FALSE Debug flag.
+> <font color="#118811">gopt stopit</font>
+stopit FALSE Stop if interrupt accepted.
+> </pre>
+
+This version of the simulator knows about three options. First element
+of the list is name of the option (<b>verbose</b>, <b>debug</b> and
+<b>stopit</b>). This name can be used to identify the option in
+<b>gopt</b> and <a href="#sopt"><b>sopt</b></a> 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.
+
+<dl><dt><b>verbose</b> <dd>?
+
+<dt><b>debug</b> <dd>Debug flag can be set by <b>-V</b> 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.
+
+<dt><b>stopit</b> <dd>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.
+
+</dl>
+
+
+<a name="sopt"><h3>sopt opt value</h3></a>
+
+Set option value. Options described at previous command (<a
+href="#gopt"><b>gopt</b></a>) 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 <tt>1</tt>, <tt>t</tt>,
+<tt>T</tt>, <tt>y</tt>, <tt>Y</tt> then value will be TRUE otherwise
+it will be FALSE.
+
+<pre>
+$ <font color="#118811">s51 -V</font>
+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.
+> <font color="#118811">gopt</font>
+verbose TRUE Verbose flag.
+stopit FALSE Stop if interrupt accepted.
+debug FALSE Debug messages appears on this console.
+> <font color="#118811">sopt debug t</font>
+> <font color="#118811">gopt</font>
+verbose TRUE Verbose flag.
+stopit FALSE Stop if interrupt accepted.
+debug TRUE Debug messages appears on this console.
+> </pre>
+
+
+<a name="conf"><h3>conf </h3></a>
+
+This command prints out configuration of the simulator:
+
+<pre>
+> <font color="#118811">conf</font>
+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
+>
+</pre>
+
+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.
+
+
+<a name="state"><h3>state</h3></a>
+
+State of the simulator and the simulated microcontroller:
+
+<pre>
+> <font color="#118811">state</font>
+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
+>
+</pre>
+
+The "CPU state" in the first line is an internal information. PC is
+value of the program counter. First line shows XTAL frequency too.
+
+<p>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.
+
+<p>Last line infroms about maximum value of the stack pointer and a
+"not very well" calculated average value of it.
+
+
+<a name="file"><h3>file,load "FILE"</h3></a>
+
+Loads file named FILE into the simulated code memory. File must
+contain data in Intel HEX format.
+
+<pre>
+> <font color="#118811">file "../../remo.hex"</font>
+55470 words read from ../../remo.hex
+>
+</pre>
+
+Don't forget to enclose file name in quotes to make the parameter to
+be a string.
+
+
+<a name="info"><h3>info</h3></a>
+
+This command prints out information about different things which must
+be specified as paramater to the command. Following subcommands are
+known:
+
+<p>info <a href="#info_bp">breakpoints</a>
+<br>info <a href="#info_reg">registers</a>
+<br>info <a href="#info_hw">hardware</a>
+
+
+<a name="info_bp"><h4>info breakpoints</h4></a>
+
+This subcommand prints out information about breakpoints:
+
+<pre>
+> <font color="#118811">b 12</font>
+Breakpoint 1 at 0x00000c: MOV R7,A
+> <font color="#118811">tb 43</font>
+Breakpoint 2 at 0x00002b: MOV R7,A
+> <font color="#118811">bse ws f 0x80</font>
+> <font color="#118811">i b</font>
+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
+>
+</pre>
+
+As you see above, the command can be shortened to "i b". The list of
+breakpoints contains 7 columns:
+
+<dl><dt><b>Num</b> <dd>Number of the breakpoint. Normal and event
+breakpoints are numbered separately.
+
+<dt><b>Type</b> <dd>This column shows type of the breakpoint. It can
+be <i>fetch</i> for normal breakpoints or <i>event</i> for event
+breakpoints. First the normal breakpoints are listed and then the
+event breakpoints.
+
+<dt><b>Disp</b> <dd>This shows if the breakpoint is temporary
+(<i>del</i>) or not (<i>keep</i>).
+
+<dt><b>Hit</b> <dd>How many times the breakpoint must be hit before it
+really stops the program.
+
+<dt><b>Cnt</b> <dd>Counter of breakpint hits. This counter decrements
+and the breakpoint is activated if it reaches zero.
+
+<dt><b>Address</b> <dd>Address where the breakpoint is set.
+
+<dt><b>What</b> <dd>For normal breakpoints this field contains
+disassembled instruction where the breakpoint is set. For event
+breakpoints it contains type of event.
+
+</dl>
+
+<a name="info_reg"><h4>info registers</h4></a>
+
+This subcommand prints out full register set of the CPU. Output of
+this command depends of type of CPU.
+
+<h5>Registers of MCS51 family</h5>
+
+<pre>
+$ <font color="#118811">s51 remoansi.hex</font>
+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
+> <font color="#118811">sopt stopit 1</font>
+> <font color="#118811">g</font>
+5
+ * 000023 02 01 1c LJMP 011c
+> <font color="#118811">i r</font>
+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
+> </pre>
+
+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.
+
+<p>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.
+
+<p>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.
+
+<p>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.
+
+<h5>Registers of AVR family</h5>
+
+<pre>
+$ <font color="#118811">savr test_arith.hex</font>
+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
+> <font color="#118811">run</font>
+
+Stop at 0x000047: (105) User stopped
+F 0x000047
+> <font color="#118811">i r</font>
+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
+>
+</pre>
+
+First two lines show first 32 bytes of internal RAM which is the
+register set of AVR controllers.
+
+<p>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.
+
+<p>Following line shows indirect addressing registers X, Y, and Z as
+well as pointed memory values.
+
+<p>Last line is disassembled instruction ap PC.
+
+<a name="info_hw"><h4>info hardware|hw cathegory [id]</h4></a>
+
+This subcommand prints out information about a unit of the
+controller. Cathegory can be:
+
+<ul><li>timer
+<li>uart
+<li>port
+<li>pca
+<li>interrupt
+<li>wdt
+</ul>
+
+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.
+
+<pre>
+$ <font color="#118811">s51 -t 51</font>
+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.
+> <font color="#118811">i h t</font>
+timer0[0] 0x0000 13 bit timer OFF irq=0 dis prio=0
+timer1[1] 0x0000 13 bit timer OFF irq=0 dis prio=0
+>
+</pre>
+
+Timer #2 differs a little bit from other timers of MCS51:
+
+<pre>
+$ <font color="#118811">s51 -t 52</font>
+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.
+> <font color="#118811">i h t</font>
+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
+>
+</pre>
+
+<p>If the controller contains more than one unit of a cathegory, then
+optional <b>id</b> parameter can be used to select a specific one. If
+<b>id</b> is not used then information is printed about all units
+belonging to specified cathegory.
+
+<pre>
+> <font color="#118811">i h t 1</font>
+timer1[1] 0x0000 13 bit timer OFF irq=0 dis prio=0
+>
+</pre>
+
+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...
+
+<pre>
+> <font color="#118811">i h pca</font>
+>
+</pre>
+
+Information you can get about units of MCS51 controllers:
+
+<pre>
+$ <font color="#118811">s51 -t 251</font>
+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.
+> <font color="#118811">g</font>
+Simulation started, PC=0x000000
+
+Stop at 0x000023: (105) User stopped
+F 0x000023
+> <font color="#118811">i h t</font>
+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
+> <font color="#118811">i h u</font>
+uart[0] 8 bit UART timer clocked MultiProc=none irq=en prio=1
+Receiver ON RB8=1 irq=0
+Transmitter TB8=1 irq=1
+> <font color="#118811">i h po</font>
+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)
+> <font color="#118811">i h i</font>
+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
+>
+</pre>
+
+
+<a name="timer"><h3>timer a|d|g|r|s|v id [value]</h3></a>
+
+Handling of timers. First parameter of timer command determines the
+operation which can be
+
+<dl><dt><b>add (or simply a)</b> <dd>to create a new timer. New timers
+are turned ON by default and initialized to value 0.
+
+<dt><b>del (or simply d)</b> <dd>to remove a timer if you don't need
+it any more.
+
+<dt><b>get (or simply g)</b> <dd>to get value of timers. See comment
+below.
+
+<dt><b>run (or simply r)</b> <dd>to turn a timer ON.
+
+<dt><b>stop (or simply s)</b> <dd>to turn a timer OFF. It still exist
+but doesn't count xtal periods.
+
+<dt><b>value (or simply v)</b> <dd>to set value of the timer (number
+of xtal periods). `param' is the new value.
+
+</dl>
+
+<b>id</b> 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:
+
+<pre>
+> <font color="#118811">tim a 3</font>
+> <font color="#118811">tim g 0</font>
+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)
+> <font color="#118811">tim a "a"</font>
+> <font color="#118811">tim g 0</font>
+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)
+>
+</pre>
+
+If you use 0 as timer id in "get" operation, simulator prints out
+value of all timers including predefined ones.
+
+<hr>
+
+</body>
+</html>
--- /dev/null
+<html>
+<head>
+<title>Set commands of uCsim</title>
+</head>
+
+<body bgcolor="white">
+
+ <!-- SET -->
+
+<h2>Set commands</h2>
+
+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 <a
+href="cmd_general.html#wi"><b>wi</b></a> 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 (<tt>,</tt>) and semicolon (<tt>;</tt>)
+are interpreted as separator characters too.
+
+<a name="si"><h3>si addr data...</h3></a>
+
+Write data into internal RAM area. First parameter specifies start
+address of memory area to set and other parameters are data to set.
+
+<pre>
+$ <font color="#118811">s51</font>
+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.
+> <font color="#118811">si 10 dani\040hej-ho</font>
+00000a 64 61 6e 69 20 68 65 6a 2d 68 6f dani hej-ho
+> </pre>
+
+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.
+
+<pre>
+> <font color="#118811">si 20 1 2 0xi 3 4</font>
+Bad data 0xi
+000014 01 02 ..
+> </pre>
+
+
+<a name="sx"><h3>sx addr data...</h3></a>
+
+This command is similar to <a href="#si"><b>si</b></a> command
+described above but it is used to modify external RAM.
+
+
+<a name="sc"><h3>sc addr data...</h3></a>
+
+This command is similar to <a href="#si"><b>si</b></a> command
+described above but it is used to modify code memory area (ROM).
+
+
+<a name="ss"><h3>ss addr data...</h3></a>
+
+This command is similar to <a href="#si"><b>si</b></a> command
+described above but it is used to modify SFR. Other difference is that
+first parameter (<b>start</b> address) can be specified by name of SFR
+not by address only.
+
+<pre>
+$ <font color="#118811">s51</font>
+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.
+> <font color="#118811">ss p1 0</font>
+000090 00 .
+> </pre>
+
+
+<a name="sb"><h3>sb addr data...</h3></a>
+
+Modify bit(s). First parameter is address of first bit to modify. See
+description of <a href="#db"><b>db</b></a> command how bit address can
+be specified. If first character of data parameter is <tt>0</tt> it
+means <i>zero</i> otherwise it means <i>one</i>.
+
+<pre>
+$ <font color="#118811">s51</font>
+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.
+> <font color="#118811">sb 0x23.5 1</font>
+> <font color="#118811">db 0x23.5</font>
+000023 23.5 1
+> <font color="#118811">sb p3.3 0</font>
+> <font color="#118811">dp</font>
+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 .
+> <font color="#118811">sb tr1 0</font>
+> <font color="#118811">db tr1</font>
+000088 TR1 0
+> <font color="#118811">sb tr1 1</font>
+> <font color="#118811">db tr1</font>
+000088 TR1 1
+> </pre>
+
+
+<a name="sp"><h3>sp port data</h3></a>
+
+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.
+
+<pre>
+$ <font color="#118811">s51</font>
+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.
+> <font color="#118811">dp</font>
+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 .
+> <font color="#118811">ss p1 0x55</font>
+000090 55 U
+> <font color="#118811">sp 1 0x0f</font>
+> <font color="#118811">dp</font>
+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 .
+> </pre>
+
+
+<a name="fi"><h3>fi start stop data</h3></a>
+
+Fill command. It can be used to fill up an area of internal RAM with a
+specified data.
+
+<pre>
+$ <font color="#118811">s51</font>
+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.
+> <font color="#118811">fi 11 0x34 44</font>
+> <font color="#118811">di</font>
+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 ........
+> </pre>
+
+
+<a name="fx"><h3>fx start stop data</h3></a>
+
+Fill command. It works similar to <a href="#fi"><b>fi</b></a> but it
+puts data into external RAM instead of internal RAM.
+
+
+<a name="fs"><h3>fs start stop data</h3></a>
+
+Fill command. It works similar to <a href="#fi"><b>fi</b></a> but it
+puts data into SFR instead of internal RAM.
+
+
+<a name="fc"><h3>fc start stop data</h3></a>
+
+Fill command. It works similar to <a href="#fi"><b>fi</b></a> but it
+puts data into code memory (ROM) instead of internal RAM.
+
+
+<hr>
+
+</body>
+</html>
--- /dev/null
+<html>
+<head>
+<title>UCSIM: Command Reference</title>
+</head>
+
+<body bgcolor="white">
+
+<h1>Command reference</h1>
+
+
+<p>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:
+
+<a name="help_example"><pre>
+<a href="cmd.html#g">g</a> [start [stop]] Go
+<a href="cmd.html#stop">stop</a> Stop
+<a href="cmd.html#pc">pc [address]</a> Get/set content of PC
+<a href="cmd.html#s">s [step]</a> Step
+<a href="cmd.html#n">n [step]</a> Next
+<a href="cmd.html#bse">bse wi|ri|wx|rx|ws|rs|rc f|d addr [hit]</a>
+ Set EVENT Breakpoint
+<a href="cmd.html#bde">bde wi|ri|wx|rx|ws|rs|rc addr</a>
+ Delete EVENT Breakpoint
+<a href="cmd.html#ba">ba</a> Delete all breakpoints
+<a href="cmd.html#dis">dis [start [offset [lines]]]</a>
+ Disassemble code
+<a href="cmd.html#dp">dp</a> Dump ports
+<a href="cmd.html#ds">ds [addr...]</a> Dump SFR
+<a href="cmd.html#db">db addr...</a> Dump bit
+<a href="cmd.html#si">si addr data...</a> Set Internal RAM
+<a href="cmd.html#sx">sx addr data...</a> Set External RAM
+<a href="cmd.html#sc">sc addr data...</a> Set code (ROM)
+<a href="cmd.html#ss">ss addr data...</a> Set SFR area
+<a href="cmd.html#sb">sb addr data...</a> Set bit
+<a href="cmd.html#sp">sp port data</a> Set port pins
+<a href="cmd.html#fi">fi start stop data</a> Fill IRAM area with `data'
+<a href="cmd.html#fx">fx start stop data</a> Fill XRAM area with `data'
+<a href="cmd.html#fs">fs start stop data</a> Fill SFR area with `data'
+<a href="cmd.html#fc">fc start stop data</a> Fill ROM area with `data'
+<a href="cmd.html#wi">wi,Wi string</a> Search for `string' in IRAM (Wi case sensitive)
+<a href="cmd.html#wx">wx,Wx string</a> Search for `string' in XRAM (Wx case sensitive)
+<a href="cmd.html#wc">wc,Wc string</a> Search for `string' in ROM (Wc case sensitive)
+<a href="cmd.html#sopt">sopt opt value</a> Set value of option
+<a href="cmd.html#gopt">gopt [opt]</a> Get value of option(s)
+<a href="cmd.html#show">show c|w</a> Show licensing information
+----
+Set of new commands:
+<a href="cmd.html#conf">conf</a> Configuration<img src="new.gif">
+<a href="cmd.html#state">state</a> State of simulator<img src="new.gif">
+<a href="cmd.html#file">file,load "FILE"</a> Load FILE into ROM<img src="new.gif">
+<a href="cmd.html#dl">download,dl</a> Download (intel hex) data
+<a href="cmd.html#info">info</a> Information<img src="new.gif">
+get Get
+set Set
+<a href="cmd.html#timer">timer a|d|g|r|s|v id [value]</a>
+ Timer add|del|get|run|stop|value<img src="new.gif">
+<a href="cmd.html#run">run</a> Go<img src="new.gif">
+step Step
+<a href="cmd.html#reset">reset</a> Reset
+dump i|x|r|s [start [stop]]
+ Dump memory
+<a href="cmd.html#di">di [start [stop]]</a> Dump Internal RAM
+<a href="cmd.html#dx">dx [start [stop]]</a> Dump External RAM
+<a href="cmd.html#dch">dch [start [stop]]</a> Dump code in hex form
+<a href="cmd.html#dc">dc [start [stop]]</a> Dump code in disass form
+<a href="cmd.html#break">break addr [hit]</a> Set fix breakpoint<img src="new.gif">
+<a href="cmd.html#tbreak">tbreak addr [hit]</a> Set temporary breakpoint<img src="new.gif">
+<a href="cmd.html#clear">clear [addr...]</a> Clear fix breakpoint<img src="new.gif">
+<a href="cmd.html#h">help,?</a> Help about commands
+<a href="cmd.html#q">quit</a> Quit
+<a href="cmd.html#kill">kill</a> Shut down the simulator
+</pre></a>
+
+In <a href="cmd.html">command reference</a> you can find more
+information about breakpoints and execution of the simulated program.
+
+
+<hr>
+
+</body>
+</html>
--- /dev/null
+#
+# Makefile targets to remake configuration
+#
+
+freshconf: Makefile
+
+Makefile: $(srcdir)/Makefile.in $(PRJDIR)/configure.in
+ cd $(PRJDIR) && $(SHELL) ./config.status
+
+# End of conf.mk
--- /dev/null
+<html>
+<head>
+<title>Simulator for MCS51</title>
+</head>
+
+<body bgcolor="#f0f0ff">
+
+<h1>Software simulator for MCS51</h1>
+
+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.
+
+<p><img src="cpu.gif">
+
+<p>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.
+
+<p>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.
+
+<p>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.
+
+<p>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).
+
+<p>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.
+
+<hr>
+
+</body>
+</html>
--- /dev/null
+<html>
+<head>
+<title>UCSIM: CPU types</title>
+</head>
+
+<body bgcolor="white">
+
+<h1>Select type of CPU</h1>
+
+The simulator supports following type of microprocessors from MCS51
+family:
+
+<p><a href="#51">8051/8031</a>
+
+<br><a href="#52">8052/8032</a>
+
+<br><a href="#51r">8051R</a>
+
+<br><a href="#89c51r">89C51R</a>
+
+<br><a href="#251">80251</a>
+
+
+<a name="51"><h3>8051/8031</h3></a>
+
+You can select this type of microcontroller using one of the following
+parameter for -t option:
+
+<ul><li>51 (HMOS type)
+
+<li>8051 (HMOS type)
+
+<li>8751 (HMOS type)
+
+<li>C51 (CMOS type)
+
+<li>80C51 (CMOS type)
+
+<li>87C51 (CMOS type)
+
+<li>31 (HMOS type)
+
+<li>8031 (HMOS type)
+
+<li>C31 (CMOS type)
+
+<li>80C31 (CMOS type)
+
+</ul>
+
+It includes core 51 features:
+
+<ul><li>64k external RAM
+
+<li>64k ROM
+
+<li>128 byte internal RAM
+
+<li>2 timers (timer #0, timer #1)
+
+<li>Serial interface
+
+<li>4 8-bit quazi bi-directional ports
+
+</ul>
+
+CMOS types also include:
+
+<ul><li>Idle mode
+
+<li>Power down mode
+
+</ul>
+
+
+<a name="52"><h3>8052/8032</h3></a>
+
+You can select this type of microcontroller using one of the following
+parameter for -t option:
+
+<ul><li>52 (HMOS type)
+
+<li>8052 (HMOS type)
+
+<li>8752 (HMOS type)
+
+<li>C52 (CMOS type)
+
+<li>80C52 (CMOS type)
+
+<li>87C52 (CMOS type)
+
+<li>32 (HMOS type)
+
+<li>8032 (HMOS type)
+
+<li>C32 (CMOS type)
+
+<li>80C32 (CMOS type)
+
+</ul>
+
+It includes same features as <a href="#51">8051/8031</a>
+microcontrollers and additionaly:
+
+<ul><li>3 timers (timer #0, timer #1, timer #2)
+
+<li>256 bytes of internal RAM
+
+</ul>
+
+
+<a name="51r"><h3>8051R</h3></a>
+
+You can select this type of microcontroller using one of the following
+parameter for -t option (all are CMOS types):
+
+<ul><li>51R
+
+<li>51RA
+
+<li>51RB
+
+<li>51RC
+
+<li>C51RA
+
+<li>C51RB
+
+<li>C51RC
+
+</ul>
+
+It includes all features that <a href="#52">8052/8032</a> does and
+additionaly:
+
+<ul><li>Extended interrupt priority system (4 priority levels)
+
+<li>Extended serial line interface (automatic address recognition)
+
+<li>Watchdog timer
+
+</ul>
+
+
+<a name="89c51r"><h3>89C51R</h3></a>
+
+You can select this type of microcontroller using <tt>89C51R</tt>
+parameter for -t option (this CPU is always CMOS). This is a Philips
+clone, excluding duplicated DPTR it is similar to 8051XR from Intel.
+
+<p>It includes all features that <a href="#51r">8051R</a> does and
+additionaly:
+
+<ul><li>PCA (Programmable Counter Array): 5 16-bit counter, one of
+them can act as watchdog timer.
+
+<li>Duplicated DPTR.
+
+</ul>
+
+
+<a name="251"><h3>80251</h3></a>
+
+You can select this type of microcontroller using one of the following
+parameter for -t option (all are CMOS types):
+
+<ul><li>251
+
+<li>C251
+
+</ul>
+
+<p>It includes all features that <a href="#89c51r">89C51R</a> does
+and additionaly:
+
+<ul><li>Nothing implemented yet.
+
+</ul>
+
+<hr>
+
+</body>
+</html>
--- /dev/null
+<html>
+<head>
+<title>Mikrocontroller Simulator</title>
+</head>
+
+<body bgcolor="white">
+
+[ <a href="#download">Download</a> ]
+
+[ <a href="#install">Installation</a> ]
+
+[ <a href="#use">Usage</a> ]
+
+[ <a href="mailto:drdani@mazsola.iit.uni-miskolc.hu">Mail to
+developer</a> ]
+
+<p><img src="UCsim.jpg">
+
+<h1>Software simulator for microcontrollers</h1>
+
+<b><i>uCsim</i></b> can be used to simulate microcontrollers. It
+supports MCS51 family. AVR and Z80 support is under development.
+
+<a name="download"><h2>Download</h2></a>
+
+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:
+
+<ul><li>There is no built in help available;
+
+<li>Some of the utilities are not working, for example calculator, bit
+simulator;
+
+<li>Serial line works in mode 1 independently of mode bits.</ul>
+
+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.
+
+<p><a
+href="http://mazsola.iit.uni-miskolc.hu/~drdani/embedded/s51/download">Download
+now</a>
+
+
+<!-- INSTALL -->
+
+<a name="install"><h2>How to install</h2></a>
+
+<b>DOS version</b>
+
+<p>Get the ZIP file and unzip it. ZIP file contains three files:
+<b>s51.exe</b> the executable itself, <b>dpmi16bi.ovl</b> and
+<b>rtm.exe</b>. Last two files are required because <b>s51.exe</b> is
+a DOS protected mode program. Put these files in a directory which is
+in the PATH or keep them together with the <b>s51.exe</b>.
+
+<p><b>UNIX version</b>
+
+<p>UNIX version is distributed in source.
+
+<ol><li>Get archive file, uncompress and untar it. These steps will
+produce a directory <b>ucsim-X.Y.Z</b> where X.Y.Z is the version
+number.
+
+<li>Go to the directory and configure the package. Issue
+<tt><b>configure</b></tt> command. It will determine your system and
+make <b>Makefile</b>. Installation directory can be specified with
+<b><tt>--<!-- -- -->prefix=<i>dir</i></tt></b> option to the
+<tt><b>configure</b></tt>. Default directory is
+<tt>/usr/local</tt>. Executable file will be placed in <tt>bin</tt>
+subdirectory.
+
+<li>Compile the package with <tt><b>make</b></tt> command.
+
+<li>Install executable <b>s51</b> to any directory you want. It can be
+done with <tt><b>make install</b></tt> command which will place files
+in installation directory specified with <tt><b>--<!-- --
+-->prefix=<i>dir</i></b></tt> option of
+<tt><b>configure</b></tt>. Note that you may have to have special
+privilege to do this if installation directory is not writable by you.
+
+</ol>
+
+
+<!-- USE -->
+
+<a name="use"><h2>How to use</h2></a>
+
+<h4>DOS version</h4>
+
+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:
+
+<p><tt>C:\> s51 [input file]</tt>
+
+<p>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:
+
+<ul><li><a href="cpu.html">CPU window</a>
+
+<li><a href="wins.html">Different kind of windows</a>
+
+<li><a href="timers.html">Timer/Counters</a>
+
+<li><a href="interrupt.html">Interrupt system</a>
+
+<li><a href="term_cpuopt.html">Terminal window and CPU option dialog
+box</a></ul>
+
+
+<h4>UNIX version</h4>
+
+<a href="invoke.html">Invokation</a>. <br>Starting the simulator
+program.
+
+<p><b>Features of the simulator</b>
+
+<ul>
+
+<li><a href="analyzer.html">Code analyzer</a>. <br>The simulator tries
+to figure out places of valid instructions in code area. This feature
+included in both DOS and UNIX versions.
+
+<li><a href="cpu_types.html">Processor types</a>. <br>The simulator can
+simulate different type of microcontrollers.
+
+<li><a href="mulcons.html">Multiple consoles</a>. <br>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.
+
+<li><a href="serial.html">Serial interfaces</a>. <br>The simulator can
+virtually connect a terminal to serial interface of the simulated CPU.
+
+<li><a href="cmd.html">Command reference</a>. <i>(Now updated up to
+0.2.37)</i> <br>The simulator can be controlled via a command line
+interface. It accepts simple commands.
+
+</ul>
+
+<hr>
+
+<table border="0">
+<tr><td><a href="mailto:drdani@mazsola.iit.uni-miskolc.hu"><img
+src="post.jpg" align="top" border="0"></a></td>
+
+<td><i>© 1997,99 Dániel Drótos, Talker Bt.</i> <br><a
+href="mailto:drdani@mazsola.iit.uni-miskolc.hu">drdani@mazsola.iit.uni-miskolc.hu</a></td></tr>
+</table>
+
+</body>
+</html>
--- /dev/null
+<html>
+<head>
+<title>Simulator for MCS51</title>
+</head>
+
+<body bgcolor="#f0f0ff">
+
+<h1>Software simulator for MCS51</h1>
+
+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.
+
+<p><img src="interrupt.gif">
+
+<p>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.
+
+<hr>
+
+</body>
+</html>
--- /dev/null
+<html>
+<head>
+<title>UCSIM: Invokation</title>
+</head>
+
+<body bgcolor="white">
+
+<h1>Starting the simulator</h1>
+
+There are separate programs to simulate different microcontroller
+families:
+
+<p>MCS51 family is simulated by <b>s51</b>
+<br>AVR family is simulated by <b>savr</b>
+<br>Z80 processor is simulated by <b>sz80</b>
+
+<p>You can select
+
+<p>The simulator can be started in the following way:
+
+<p><tt><font color="blue">$</font> s51 [-hHVvP] [-p prompt] [-t CPU]
+[-X freq[k|M]] [-c file] [-s file] [-S optionlist] [-Z portnum]
+[files...]</tt>
+
+<p>Specified files must be names of Intel hex files. Simulator loads
+them in specified order into the ROM of the simulated system.
+
+<p>Options:
+
+<dl><dt><tt><b>-t CPU</b></tt>
+
+<dd>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.
+
+<br>See <a href="cpu_types.html">how to select CPU type</a>.
+
+<dt><tt><b>-X freq[k|M]</b></tt>
+
+<dd>XTAL frequency is <b>freq</b> Hertz. <b>k</b> or <b>M</b> can be
+used to specify frequency in kHZ or MHz. Space is not allowed between
+the number and the <b>k</b> or <b>M</b>. Default value is 11059200 Hz.
+
+<a name="coption"><dt><tt><b>-c file</b></tt></a>
+
+<dd>Open command console on <b>file</b>. 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.
+
+<a name="Zoption"><dt><tt><b>-Z portnum</b></tt></a>
+
+<dd>Listen for incoming connections on port <b>portnum</b>. Using this
+option <i>uCsim</i> can serve multiple consoles. You can get a console
+by simply telnet into machine running <i>uCsim</i> to port
+<b>portnumber</b>. This option is not available on platforms which
+doesn't support BSD networking.
+
+<br>See <a href="mulcons.html">how to use multiple consoles</a>.
+
+<dt><tt><b>-s file</b></tt>
+
+<dd>Connect serial interface of the simulated microcontroller to the
+<b>file</b>. 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.
+
+<dt><tt><b>-S in=file,out=file</b></tt>
+
+<dd>Using this option you can specify different files for input and
+output streams that <i>uCsim</i> uses to simulate microprocessor's
+serial interface.
+
+<br>See <a href="serial.html">more about serial interface
+simulation</a>.
+
+<dt><tt><b>-p prompt</b></tt>
+
+<dd>Using this option you can specify any string to be the prompt of
+command interpreter, for example:
+
+<pre><font color="blue">$</font> s51 -p "s51> "
+<font color="green">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> </font></pre>
+
+<dt><tt><b>-P</b></tt>
+
+<dd>Prompt will be a null ('\0') character. This feature can be
+useful for programs which controlls simulator through a pipe.
+
+<dt><tt><b>-V</b></tt>
+
+<dd>Verbose mode. The simulator notifies you about some kind of
+internal actions for example interrupts. Messages are printed on
+command console.
+
+<dt><tt><b>-v</b></tt>
+
+<dd>Print out version number and stop.
+
+<dt><tt><b>-H</b></tt>
+
+<dd>Print out types of known CPUs. Names printed out by this option
+can be used to determine CPU type using <tt><b>-t</b></tt> option.
+
+<dt><tt><b>-h</b></tt>
+
+<dd>Print out a short help about the options and stop.
+
+</dl>
+
+
+<hr>
+
+</body>
+</html>
--- /dev/null
+<html>
+<head>
+<title>UCSIM: Multiple Consoles</title>
+</head>
+
+<body bgcolor="white">
+
+<h1>Using multiple consoles</h1>
+
+<h3>Why?</h3>
+
+Using more than one console can be useful if you want to issue a
+command during the simulated program is executed.
+
+
+<h3>How?</h3>
+
+<p>To get multiple consoles you have to execute the simulator in the
+<i>background</i> like daemons run in UNIX systems. The simulator
+then will listen and wait for network connection requests and provide
+console functions for network connections.
+
+<p>To run <i>uCsim</i> in the background you have to use <a
+href="invoke.html#Zoption">-Z</a> option for the simulator:
+
+<pre>
+<font color="blue">pigmy$</font> s51 -Z 5555 foo.hex
+</pre>
+
+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:
+
+<pre>
+<font color="blue">pigmy$</font> s51 -Z 5555 foo.hex &
+</pre>
+
+The parameter of the <a href="invoke.html#Zoption">-Z</a> 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:
+
+<pre>
+<font color="blue">pigmy$</font> s51 -Z 5555
+<font color="red">bind: Address already in use</font>
+</pre>
+
+In this case you have to use an other number.
+
+<p>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:
+
+<pre>
+<font color="blue">other_machine$</font> telnet pigmy 5555
+</pre>
+
+First parameter to the telnet command is the name of the machine where
+the simulator is running on. It can be <tt>localhost</tt> 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 <a href="invoke.html#Zoption">-Z</a>
+option when the simulator was started (see above).
+
+<p>Connecting to the simulator you get a command console:
+
+<pre>
+<font color="blue">pigmy$</font> telnet pigmy 5555
+<font color="green">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.
+>
+</font>
+</pre>
+
+
+<h3>What to do with it?</h3>
+
+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.
+
+
+<h3>Stop</h3>
+
+Using <a href="cmd.html#q">quit (q)</a> command you can not stop the
+simulator. It just stops the actual console and the simulator
+continues to listen for incoming network connections.
+
+<p>To stop the simulator completely you have to use <a
+href="cmd.html#kill">kill</a> command. Note that if you stop the
+simulator then all the active network connections (all other consoles)
+will stop.
+
+
+<h3>Tricks</h3>
+
+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 <a
+href="invoke.html#coption">-c</a> option and specify the actual
+terminal as parameter for it:
+
+<pre>
+<font color="blue">pigmy$</font> s51 -Z 5555 foo.hex -c /dev/tty
+</pre>
+
+<hr>
+
+</body>
+</html>
--- /dev/null
+<a name="bl"><h3>bl</h3></a>
+
+List breakpoints. This command prints out information about every
+fetch and then event breakpoints.
+
+<pre>
+> <font color="#118811">bl</font>
+F 1(1) 000160 c2 CLR P1.0
+D 2(2) 000180 02 LJMP 022a
+F 1(1) 000006 wi
+> </pre>
+
+First character on the list shows permanency of the
+breakpoint. <b>F</b> means fix and <b>D</b> 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.
+
+<p>Fetch breakpoints list hexadecimal code of instruction at
+breakpoint's address and then dissassembled instruction.
+
+<p>Event breakpoints list identification of the event's type.
+
--- /dev/null
+<html>
+<head>
+<title>UCSIM: Serial Interafces</title>
+</head>
+
+<body bgcolor="white">
+
+<h1>Using serial interfaces</h1>
+
+<h3>Connecting a terminal</h3>
+
+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:
+
+<pre>
+<font color="blue">$</font> s51 -s/dev/ttyS1
+</pre>
+
+Of course you must use the actual device name of your operating
+system. Device name <tt>ttyS1</tt> above is used in Linux
+systems. Your system can use other names.
+
+<p>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 <b>xterm</b> 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:
+
+<ol><li>Prepare the terminal window which will be connected to the
+serial line:
+
+<p><ul><li>Check the device name which represents the terminal:
+
+<pre>
+<font color="blue">$</font> tty
+<font color="green">/dev/ttyp1</font>
+</pre>
+
+<li>Disconnect the shell from the terminal. Usualy I use the
+<b>tail</b> command and any existing text file:
+
+<pre>
+<font color="blue">$</font> tail -f $HOME/.profile
+</pre>
+
+</ul>
+
+<li>Run the simulator in the other window:
+
+<pre>
+<font color="blue">$</font> s51 -s/dev/ttyp1 program.hex
+</pre>
+
+Use the output of the <b>tty</b> command above as the parameter of the
+<tt>-s</tt> option.
+
+</ol>
+
+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.
+
+
+<h3>Connecting two instances of simulator</h3>
+
+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:
+
+<p><img src="serial1.gif">
+
+<ol><li>Make two FIFOs to represent physical wires in serial cable
+connecting two micros:
+
+<pre>
+<font color="blue">$</font> mkfifo 1-2 2-1 <font color="magenta"># 1-2: 1->2 and 2-1: 2->1</font>
+</pre>
+
+<li>Start two simulators and specify the FIFOs as input and output of
+serial interface:
+
+<pre>
+<font color="blue">term1 $</font> <font color="magenta"># start sim "1"</font>
+<font color="blue">term1 $</font> s51 -Sin=2-1,out=1-2 program_1_.hex
+<font color="blue">term2 $</font> <font color="magenta"># start sim "2"</font>
+<font color="blue">term2 $</font> s51 -Sout=2-1,in=1-2 program_2_.hex
+</pre>
+
+Because opening a pipe blocks the program until other direction is
+opened, the order of arguments above is <b>important</b>!
+
+<p>
+
+<li>Debug programs as usual.
+
+</ol>
+
+Using the most usefull unix commands <b>cat</b> and <b>tee</b> and
+just some more FIFOs you can monitor serial communication, here is a
+sample:
+
+<p><img src="serial2.gif">
+
+<ol><li>Make some FIFOs to use between simulators and tee "monitors":
+
+<pre>
+<font color="blue">$</font> mkfifo 1_tee tee_2 2_tee tee_2
+</pre>
+
+<li>Run monitoring programs (in two xterms for example):
+
+<pre>
+<font color="blue">xterm1 $</font> cat 1_tee|tee /dev/tty >tee_2 # monitor 1->2
+<font color="blue">xterm2 $</font> cat 2_tee|tee /dev/tty >tee_1 # monitor 2->1
+</pre>
+
+<li>Now you can start simulators (on two other terminals:)
+
+<pre>
+<font color="blue">xterm3 $</font> s51 -Sin=tee_1,out=1_tee program_1_.hex
+<font color="blue">xterm4 $</font> s51 -Sin=tee_2,out=2_tee program_2_.hex
+</pre>
+
+<li>Start your apps and listen what they are talking about.
+
+</ol>
+
+<hr>
+
+</body>
+</html>
--- /dev/null
+#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
--- /dev/null
+#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
--- /dev/null
+<html>
+<head>
+<title>Simulator for MCS51</title>
+</head>
+
+<body bgcolor="#f0f0ff">
+
+<h1>Software simulator for MCS51</h1>
+
+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.
+
+<p><img src="term_cpuopt.gif">
+
+<hr>
+
+</body>
+</html>
--- /dev/null
+<html>
+<head>
+<title>Simulator for MCS51</title>
+</head>
+
+<body bgcolor="#f0f0ff">
+
+<h1>Software simulator for MCS51</h1>
+
+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.
+
+<p><img src="timers.gif">
+
+<hr>
+
+</body>
+</html>
--- /dev/null
+<html>
+<head>
+<title>Simulator for MCS51</title>
+</head>
+
+<body bgcolor="#f0f0ff">
+
+<h1>Software simulator for MCS51</h1>
+
+This screenshot demonstrates some kind of windows that can be opened
+using commands in <b>View</b> 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.
+
+<p><img src="wins.gif">
+
+<hr>
+
+</body>
+</html>
--- /dev/null
+/*
+ * 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. */
--- /dev/null
+#
+# 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
--- /dev/null
+#include <curses.h>
+#include <panel.h>
+
+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);
+}
--- /dev/null
+/*
+ * 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 <stdlib.h>
+
+#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 */
--- /dev/null
+/*
+ * 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 */
--- /dev/null
+/*
+ * 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 <stdlib.h>
+
+#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 */
--- /dev/null
+/*
+ * 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 */
--- /dev/null
+# 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
--- /dev/null
+# 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
--- /dev/null
+/*
+ * 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 */
--- /dev/null
+/*
+ * 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 */
--- /dev/null
+/*
+ * 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 <curses.h>
+
+//#include <stdio.h>
+
+#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 */
--- /dev/null
+/*
+ * 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 */
--- /dev/null
+/*
+ * 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 <stdlib.h>
+#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 */
--- /dev/null
+/*
+ * 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 */
--- /dev/null
+/*
+ * 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 */
--- /dev/null
+/*
+ * 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 */
--- /dev/null
+/*
+ * 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 <stdlib.h>
+#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 */
--- /dev/null
+/*
+ * 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 */
--- /dev/null
+/*
+ * 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 */
--- /dev/null
+/*
+ * 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 <stdlib.h>
+#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 */
--- /dev/null
+/*
+ * 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 <curses.h>
+#include <panel.h>
+
+#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 */
--- /dev/null
+/*
+ * 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 <stdlib.h>
+#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 */
--- /dev/null
+/*
+ * 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 */