From b4fd065d774e302762226bf139e79ca4184461a6 Mon Sep 17 00:00:00 2001 From: Bdale Garbee Date: Fri, 2 May 2008 23:07:32 -0600 Subject: [PATCH 1/1] Imported Upstream version 2.3.1 --- AUTHORS | 20 + COPYING | 12 + ChangeLog | 51 + INSTALL | 9 + Makefile.am | 1 + Makefile.in | 323 ++++ NEWS | 15 + README | 12 + aclocal.m4 | 342 ++++ as31/Makefile.am | 42 + as31/Makefile.in | 363 ++++ as31/as31.1 | 379 ++++ as31/as31.c | 105 ++ as31/as31.h | 195 ++ as31/as31_gtk.c | 201 +++ as31/emitter.c | 626 +++++++ as31/lexer.c | 391 ++++ as31/parser.c | 3104 ++++++++++++++++++++++++++++++++ as31/parser.h | 184 ++ as31/parser.y | 1127 ++++++++++++ as31/run.c | 268 +++ as31/symbol.c | 433 +++++ configure | 3912 +++++++++++++++++++++++++++++++++++++++++ configure.in | 68 + examples/Makefile.am | 3 + examples/Makefile.in | 176 ++ examples/extra.asm | 2054 ++++++++++++++++++++++ examples/extra.ref | 244 +++ examples/paulmon1.asm | 1993 +++++++++++++++++++++ examples/paulmon1.ref | 490 ++++++ examples/paulmon2.asm | 2512 ++++++++++++++++++++++++++ examples/paulmon2.ref | 256 +++ install-sh | 269 +++ missing | 198 +++ mkinstalldirs | 40 + 35 files changed, 20418 insertions(+) create mode 100644 AUTHORS create mode 100644 COPYING create mode 100644 ChangeLog create mode 100644 INSTALL create mode 100644 Makefile.am create mode 100644 Makefile.in create mode 100644 NEWS create mode 100644 README create mode 100644 aclocal.m4 create mode 100644 as31/Makefile.am create mode 100644 as31/Makefile.in create mode 100644 as31/as31.1 create mode 100644 as31/as31.c create mode 100644 as31/as31.h create mode 100644 as31/as31_gtk.c create mode 100644 as31/emitter.c create mode 100644 as31/lexer.c create mode 100644 as31/parser.c create mode 100644 as31/parser.h create mode 100644 as31/parser.y create mode 100644 as31/run.c create mode 100644 as31/symbol.c create mode 100644 configure create mode 100644 configure.in create mode 100644 examples/Makefile.am create mode 100644 examples/Makefile.in create mode 100644 examples/extra.asm create mode 100644 examples/extra.ref create mode 100644 examples/paulmon1.asm create mode 100644 examples/paulmon1.ref create mode 100644 examples/paulmon2.asm create mode 100644 examples/paulmon2.ref create mode 100644 install-sh create mode 100644 missing create mode 100644 mkinstalldirs diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..85d9674 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,20 @@ + + as31 - 8031/8051 Assembler + -------------------------- + + Written by: + Ken Stauffer + Paul Stoffregen + Bernd Porr + Alexander 'E-Razor' Krause + Martin Langer + + Maintained at: + http://www.pjrc.com/tech/8051/ + http://www.cn.stir.ac.uk/~bp1/as31/ + + Please report problems to: + Paul Stoffregen + Bernd Porr + Martin Langer + diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..165736c --- /dev/null +++ b/COPYING @@ -0,0 +1,12 @@ + + as31 - 8031/8051 Assembler + -------------------------- + + The home of as31 at http://www.pjrc.com/tech/8051/ says: + + AS31 is Free Software, provided under the BSD license. + + AS31 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. + diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..adfbe85 --- /dev/null +++ b/ChangeLog @@ -0,0 +1,51 @@ + + as31 - 8031/8051 Assembler + http://wiki.erazor-zone.de/doku.php/wiki:projects:linux:as31 + -------------------------- + + REVISION HISTORY: + + Jan. 19, 1990 Created. (Ken Stauffer). + + Jan. 30, 1990 Theo played here. + + Late 1994 Paul Stoffregen updates the code + + Sept 1995 bug fixes, add obsure option for cgi + + April 2000 fix filename handling + convert everything to ANSI C and bison + properly handle 0b0h as hex 0xB0, not binary 0 + Make most errors into warning, and modify parser + to recover and continue to the end of the file + so that all warning are shown. + + March 2001 fix crash with srecord format + command line version returns non-zero on error + + July 2003 added include directive (Bernd Porr) + + March 2004 Alexander 'E-Razor' Krause : + removed bug when using more than 1 .inc + tmp filename is now as-uid-random + remove tmp_file when ready + + May 06, 2004 Alexander 'E-Razor' Krause : + compiler error on gcc < 3 solved + + May 18, 2004 Martin Langer : + (Version 2.2.1) - fixing some visible bugs + - adds the missing -s option + + Mar 09, 2005 Martin Langer : + (Version 2.3.0) - automake scripts introduced + - old static Makefile removed + - write output to custom file added, using -Ofilename + - command options -v and -h added + - I've tried to figure out the license, see NEWS + - manpage modifications + - lots of small fixes and cleanups + + Sep 05, 2005 Alexander 'E-Razor' Krause : + (Version 2.3.1) - 'Location counter overlaps' on 64bit systems solved + diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..1609ca0 --- /dev/null +++ b/INSTALL @@ -0,0 +1,9 @@ + + as31 - 8031/8051 Assembler + -------------------------- + + To build and install as31 on Linux, type + + ./configure + make + make install diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..1ba6e01 --- /dev/null +++ b/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = as31 examples diff --git a/Makefile.in b/Makefile.in new file mode 100644 index 0000000..43a81aa --- /dev/null +++ b/Makefile.in @@ -0,0 +1,323 @@ +# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am + +# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +DESTDIR = + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = . + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +CC = @CC@ +CFLAGS = @CFLAGS@ +GTK_CFLAGS = @GTK_CFLAGS@ +GTK_CONFIG = @GTK_CONFIG@ +GTK_LIBS = @GTK_LIBS@ +GUI_CFLAGS = @GUI_CFLAGS@ +GUI_LIBS = @GUI_LIBS@ +LIBS = @LIBS@ +MAKEINFO = @MAKEINFO@ +PACKAGE = @PACKAGE@ +VERSION = @VERSION@ +YACC = @YACC@ + +SUBDIRS = as31 examples +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_CLEAN_FILES = +DIST_COMMON = README AUTHORS COPYING ChangeLog INSTALL Makefile.am \ +Makefile.in NEWS aclocal.m4 configure configure.in install-sh missing \ +mkinstalldirs + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = tar +GZIP_ENV = --best +all: all-redirect +.SUFFIXES: +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) \ + && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status + +$(ACLOCAL_M4): configure.in + cd $(srcdir) && $(ACLOCAL) + +config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + $(SHELL) ./config.status --recheck +$(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES) + cd $(srcdir) && $(AUTOCONF) + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. + +@SET_MAKE@ + +all-recursive install-data-recursive install-exec-recursive \ +installdirs-recursive install-recursive uninstall-recursive \ +check-recursive installcheck-recursive info-recursive dvi-recursive: + @set fnord $(MAKEFLAGS); amf=$$2; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +mostlyclean-recursive clean-recursive distclean-recursive \ +maintainer-clean-recursive: + @set fnord $(MAKEFLAGS); amf=$$2; \ + dot_seen=no; \ + rev=''; list='$(SUBDIRS)'; for subdir in $$list; do \ + rev="$$subdir $$rev"; \ + test "$$subdir" != "." || dot_seen=yes; \ + done; \ + test "$$dot_seen" = "no" && rev=". $$rev"; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + here=`pwd` && cd $(srcdir) \ + && mkid -f$$here/ID $$unique $(LISP) + +TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || (cd $(srcdir) && etags -o $$here/TAGS $(ETAGS_ARGS) $$tags $$unique $(LISP)) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + -rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(PACKAGE)-$(VERSION) +top_distdir = $(distdir) + +# This target untars the dist file and tries a VPATH configuration. Then +# it guarantees that the distribution is self-contained by making another +# tarfile. +distcheck: dist + -rm -rf $(distdir) + GZIP=$(GZIP_ENV) $(TAR) zxf $(distdir).tar.gz + mkdir $(distdir)/=build + mkdir $(distdir)/=inst + dc_install_base=`cd $(distdir)/=inst && pwd`; \ + cd $(distdir)/=build \ + && ../configure --srcdir=.. --prefix=$$dc_install_base \ + && $(MAKE) $(AM_MAKEFLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) dvi \ + && $(MAKE) $(AM_MAKEFLAGS) check \ + && $(MAKE) $(AM_MAKEFLAGS) install \ + && $(MAKE) $(AM_MAKEFLAGS) installcheck \ + && $(MAKE) $(AM_MAKEFLAGS) dist + -rm -rf $(distdir) + @banner="$(distdir).tar.gz is ready for distribution"; \ + dashes=`echo "$$banner" | sed s/./=/g`; \ + echo "$$dashes"; \ + echo "$$banner"; \ + echo "$$dashes" +dist: distdir + -chmod -R a+r $(distdir) + GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir) + -rm -rf $(distdir) +dist-all: distdir + -chmod -R a+r $(distdir) + GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir) + -rm -rf $(distdir) +distdir: $(DISTFILES) + -rm -rf $(distdir) + mkdir $(distdir) + -chmod 777 $(distdir) + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pr $$d/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done + for subdir in $(SUBDIRS); do \ + if test "$$subdir" = .; then :; else \ + test -d $(distdir)/$$subdir \ + || mkdir $(distdir)/$$subdir \ + || exit 1; \ + chmod 777 $(distdir)/$$subdir; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir=../$(distdir) distdir=../$(distdir)/$$subdir distdir) \ + || exit 1; \ + fi; \ + done +info-am: +info: info-recursive +dvi-am: +dvi: dvi-recursive +check-am: all-am +check: check-recursive +installcheck-am: +installcheck: installcheck-recursive +install-exec-am: +install-exec: install-exec-recursive + +install-data-am: +install-data: install-data-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-recursive +uninstall-am: +uninstall: uninstall-recursive +all-am: Makefile +all-redirect: all-recursive +install-strip: + $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install +installdirs: installdirs-recursive +installdirs-am: + + +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: +mostlyclean-am: mostlyclean-tags mostlyclean-generic + +mostlyclean: mostlyclean-recursive + +clean-am: clean-tags clean-generic mostlyclean-am + +clean: clean-recursive + +distclean-am: distclean-tags distclean-generic clean-am + +distclean: distclean-recursive + -rm -f config.status + +maintainer-clean-am: maintainer-clean-tags maintainer-clean-generic \ + distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-recursive + -rm -f config.status + +.PHONY: install-data-recursive uninstall-data-recursive \ +install-exec-recursive uninstall-exec-recursive installdirs-recursive \ +uninstalldirs-recursive all-recursive check-recursive \ +installcheck-recursive info-recursive dvi-recursive \ +mostlyclean-recursive distclean-recursive clean-recursive \ +maintainer-clean-recursive tags tags-recursive mostlyclean-tags \ +distclean-tags clean-tags maintainer-clean-tags distdir info-am info \ +dvi-am dvi check check-am installcheck-am installcheck install-exec-am \ +install-exec install-data-am install-data install-am install \ +uninstall-am uninstall all-redirect all-am all installdirs-am \ +installdirs mostlyclean-generic distclean-generic clean-generic \ +maintainer-clean-generic clean mostlyclean distclean maintainer-clean + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/NEWS b/NEWS new file mode 100644 index 0000000..3401eb3 --- /dev/null +++ b/NEWS @@ -0,0 +1,15 @@ + + as31 - 8031/8051 Assembler + -------------------------- + + v2.3.0 + Martin Langer : + + ************************************************************** + + Dear original authors, + + please correct COPYING if I put the wrong license + in that file or remove these lines. Thanks. + + ************************************************************** diff --git a/README b/README new file mode 100644 index 0000000..ccf4b80 --- /dev/null +++ b/README @@ -0,0 +1,12 @@ + + as31 - 8031/8051 Assembler + -------------------------- + + This is a beta test release of AS31. + To build and install as31 on Linux, read INSTALL + + Please report any problems to + Paul Stoffregen + Martin Langer + + Thank you. We hope you find AS31 useful. diff --git a/aclocal.m4 b/aclocal.m4 new file mode 100644 index 0000000..104aba5 --- /dev/null +++ b/aclocal.m4 @@ -0,0 +1,342 @@ +dnl aclocal.m4 generated automatically by aclocal 1.4-p6 + +dnl Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without +dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A +dnl PARTICULAR PURPOSE. + +# Do all the work for Automake. This macro actually does too much -- +# some checks are only needed if your package does certain things. +# But this isn't really a big deal. + +# serial 1 + +dnl Usage: +dnl AM_INIT_AUTOMAKE(package,version, [no-define]) + +AC_DEFUN([AM_INIT_AUTOMAKE], +[AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl +AC_REQUIRE([AC_PROG_INSTALL]) +PACKAGE=[$1] +AC_SUBST(PACKAGE) +VERSION=[$2] +AC_SUBST(VERSION) +dnl test to see if srcdir already configured +if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then + AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) +fi +ifelse([$3],, +AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) +AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])) +AC_REQUIRE([AM_SANITY_CHECK]) +AC_REQUIRE([AC_ARG_PROGRAM]) +dnl FIXME This is truly gross. +missing_dir=`cd $ac_aux_dir && pwd` +AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}, $missing_dir) +AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir) +AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}, $missing_dir) +AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir) +AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir) +AC_REQUIRE([AC_PROG_MAKE_SET])]) + +# Copyright 2002 Free Software Foundation, Inc. + +# This program 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, or (at your option) +# any later version. + +# This program 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 this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + +# AM_AUTOMAKE_VERSION(VERSION) +# ---------------------------- +# Automake X.Y traces this macro to ensure aclocal.m4 has been +# generated from the m4 files accompanying Automake X.Y. +AC_DEFUN([AM_AUTOMAKE_VERSION],[am__api_version="1.4"]) + +# AM_SET_CURRENT_AUTOMAKE_VERSION +# ------------------------------- +# Call AM_AUTOMAKE_VERSION so it can be traced. +# This function is AC_REQUIREd by AC_INIT_AUTOMAKE. +AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], + [AM_AUTOMAKE_VERSION([1.4-p6])]) + +# +# Check to make sure that the build environment is sane. +# + +AC_DEFUN([AM_SANITY_CHECK], +[AC_MSG_CHECKING([whether build environment is sane]) +# Just in case +sleep 1 +echo timestamp > conftestfile +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null` + if test "[$]*" = "X"; then + # -L didn't work. + set X `ls -t $srcdir/configure conftestfile` + fi + if test "[$]*" != "X $srcdir/configure conftestfile" \ + && test "[$]*" != "X conftestfile $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken +alias in your environment]) + fi + + test "[$]2" = conftestfile + ) +then + # Ok. + : +else + AC_MSG_ERROR([newly created file is older than distributed files! +Check your system clock]) +fi +rm -f conftest* +AC_MSG_RESULT(yes)]) + +dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY) +dnl The program must properly implement --version. +AC_DEFUN([AM_MISSING_PROG], +[AC_MSG_CHECKING(for working $2) +# Run test in a subshell; some versions of sh will print an error if +# an executable is not found, even if stderr is redirected. +# Redirect stdin to placate older versions of autoconf. Sigh. +if ($2 --version) < /dev/null > /dev/null 2>&1; then + $1=$2 + AC_MSG_RESULT(found) +else + $1="$3/missing $2" + AC_MSG_RESULT(missing) +fi +AC_SUBST($1)]) + +# Configure paths for GTK+ +# Owen Taylor 97-11-3 + +dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]]) +dnl Test for GTK, and define GTK_CFLAGS and GTK_LIBS +dnl +AC_DEFUN(AM_PATH_GTK, +[dnl +dnl Get the cflags and libraries from the gtk-config script +dnl +AC_ARG_WITH(gtk-prefix,[ --with-gtk-prefix=PFX Prefix where GTK is installed (optional)], + gtk_config_prefix="$withval", gtk_config_prefix="") +AC_ARG_WITH(gtk-exec-prefix,[ --with-gtk-exec-prefix=PFX Exec prefix where GTK is installed (optional)], + gtk_config_exec_prefix="$withval", gtk_config_exec_prefix="") +AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program], + , enable_gtktest=yes) + + for module in . $4 + do + case "$module" in + gthread) + gtk_config_args="$gtk_config_args gthread" + ;; + esac + done + + if test x$gtk_config_exec_prefix != x ; then + gtk_config_args="$gtk_config_args --exec-prefix=$gtk_config_exec_prefix" + if test x${GTK_CONFIG+set} != xset ; then + GTK_CONFIG=$gtk_config_exec_prefix/bin/gtk-config + fi + fi + if test x$gtk_config_prefix != x ; then + gtk_config_args="$gtk_config_args --prefix=$gtk_config_prefix" + if test x${GTK_CONFIG+set} != xset ; then + GTK_CONFIG=$gtk_config_prefix/bin/gtk-config + fi + fi + + AC_PATH_PROG(GTK_CONFIG, gtk-config, no) + min_gtk_version=ifelse([$1], ,0.99.7,$1) + AC_MSG_CHECKING(for GTK - version >= $min_gtk_version) + no_gtk="" + if test "$GTK_CONFIG" = "no" ; then + no_gtk=yes + else + GTK_CFLAGS=`$GTK_CONFIG $gtk_config_args --cflags` + GTK_LIBS=`$GTK_CONFIG $gtk_config_args --libs` + gtk_config_major_version=`$GTK_CONFIG $gtk_config_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` + gtk_config_minor_version=`$GTK_CONFIG $gtk_config_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` + gtk_config_micro_version=`$GTK_CONFIG $gtk_config_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` + if test "x$enable_gtktest" = "xyes" ; then + ac_save_CFLAGS="$CFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $GTK_CFLAGS" + LIBS="$GTK_LIBS $LIBS" +dnl +dnl Now check if the installed GTK is sufficiently new. (Also sanity +dnl checks the results of gtk-config to some extent +dnl + rm -f conf.gtktest + AC_TRY_RUN([ +#include +#include +#include + +int +main () +{ + int major, minor, micro; + char *tmp_version; + + system ("touch conf.gtktest"); + + /* HP/UX 9 (%@#!) writes to sscanf strings */ + tmp_version = g_strdup("$min_gtk_version"); + if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { + printf("%s, bad version string\n", "$min_gtk_version"); + exit(1); + } + + if ((gtk_major_version != $gtk_config_major_version) || + (gtk_minor_version != $gtk_config_minor_version) || + (gtk_micro_version != $gtk_config_micro_version)) + { + printf("\n*** 'gtk-config --version' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n", + $gtk_config_major_version, $gtk_config_minor_version, $gtk_config_micro_version, + gtk_major_version, gtk_minor_version, gtk_micro_version); + printf ("*** was found! If gtk-config was correct, then it is best\n"); + printf ("*** to remove the old version of GTK+. You may also be able to fix the error\n"); + printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n"); + printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n"); + printf("*** required on your system.\n"); + printf("*** If gtk-config was wrong, set the environment variable GTK_CONFIG\n"); + printf("*** to point to the correct copy of gtk-config, and remove the file config.cache\n"); + printf("*** before re-running configure\n"); + } +#if defined (GTK_MAJOR_VERSION) && defined (GTK_MINOR_VERSION) && defined (GTK_MICRO_VERSION) + else if ((gtk_major_version != GTK_MAJOR_VERSION) || + (gtk_minor_version != GTK_MINOR_VERSION) || + (gtk_micro_version != GTK_MICRO_VERSION)) + { + printf("*** GTK+ header files (version %d.%d.%d) do not match\n", + GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION); + printf("*** library (version %d.%d.%d)\n", + gtk_major_version, gtk_minor_version, gtk_micro_version); + } +#endif /* defined (GTK_MAJOR_VERSION) ... */ + else + { + if ((gtk_major_version > major) || + ((gtk_major_version == major) && (gtk_minor_version > minor)) || + ((gtk_major_version == major) && (gtk_minor_version == minor) && (gtk_micro_version >= micro))) + { + return 0; + } + else + { + printf("\n*** An old version of GTK+ (%d.%d.%d) was found.\n", + gtk_major_version, gtk_minor_version, gtk_micro_version); + printf("*** You need a version of GTK+ newer than %d.%d.%d. The latest version of\n", + major, minor, micro); + printf("*** GTK+ is always available from ftp://ftp.gtk.org.\n"); + printf("***\n"); + printf("*** If you have already installed a sufficiently new version, this error\n"); + printf("*** probably means that the wrong copy of the gtk-config shell script is\n"); + printf("*** being found. The easiest way to fix this is to remove the old version\n"); + printf("*** of GTK+, but you can also set the GTK_CONFIG environment to point to the\n"); + printf("*** correct copy of gtk-config. (In this case, you will have to\n"); + printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n"); + printf("*** so that the correct libraries are found at run-time))\n"); + } + } + return 1; +} +],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + if test "x$no_gtk" = x ; then + AC_MSG_RESULT(yes) + ifelse([$2], , :, [$2]) + else + AC_MSG_RESULT(no) + if test "$GTK_CONFIG" = "no" ; then + echo "*** The gtk-config script installed by GTK could not be found" + echo "*** If GTK was installed in PREFIX, make sure PREFIX/bin is in" + echo "*** your path, or set the GTK_CONFIG environment variable to the" + echo "*** full path to gtk-config." + else + if test -f conf.gtktest ; then + : + else + echo "*** Could not run GTK test program, checking why..." + CFLAGS="$CFLAGS $GTK_CFLAGS" + LIBS="$LIBS $GTK_LIBS" + AC_TRY_LINK([ +#include +#include +], [ return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); ], + [ echo "*** The test program compiled, but did not run. This usually means" + echo "*** that the run-time linker is not finding GTK or finding the wrong" + echo "*** version of GTK. If it is not finding GTK, you'll need to set your" + echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" + echo "*** to the installed location Also, make sure you have run ldconfig if that" + echo "*** is required on your system" + echo "***" + echo "*** If you have an old version installed, it is best to remove it, although" + echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" + echo "***" + echo "*** If you have a RedHat 5.0 system, you should remove the GTK package that" + echo "*** came with the system with the command" + echo "***" + echo "*** rpm --erase --nodeps gtk gtk-devel" ], + [ echo "*** The test program failed to compile or link. See the file config.log for the" + echo "*** exact error that occured. This usually means GTK was incorrectly installed" + echo "*** or that you have moved GTK since it was installed. In the latter case, you" + echo "*** may want to edit the gtk-config script: $GTK_CONFIG" ]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + GTK_CFLAGS="" + GTK_LIBS="" + ifelse([$3], , :, [$3]) + fi + AC_SUBST(GTK_CFLAGS) + AC_SUBST(GTK_LIBS) + rm -f conf.gtktest +]) + +# Define a conditional. + +AC_DEFUN([AM_CONDITIONAL], +[AC_SUBST($1_TRUE) +AC_SUBST($1_FALSE) +if $2; then + $1_TRUE= + $1_FALSE='#' +else + $1_TRUE='#' + $1_FALSE= +fi]) + diff --git a/as31/Makefile.am b/as31/Makefile.am new file mode 100644 index 0000000..5a64881 --- /dev/null +++ b/as31/Makefile.am @@ -0,0 +1,42 @@ +# Makefile for as31 + +INCLUDES = $(GUI_CFLAGS) $(CFLAGS) + +if OPTION_GTK +AS31GTK_BIN = as31gtk +else +AS31GTK_BIN = +endif + + +bin_PROGRAMS = \ + as31 \ + $(AS31GTK_BIN) + +as31_SOURCES = \ + as31.h \ + run.c \ + lexer.c \ + parser.y \ + parser.h \ + symbol.c \ + emitter.c \ + as31.c + +as31gtk_SOURCES = \ + as31.h \ + run.c \ + lexer.c \ + parser.y \ + parser.h \ + symbol.c \ + emitter.c \ + as31_gtk.c + +as31gtk_LDADD = $(GUI_LIBS) + +man_MANS = as31.1 + +EXTRA_DIST = as31.1 +CLEANFILES = as31gtk + diff --git a/as31/Makefile.in b/as31/Makefile.in new file mode 100644 index 0000000..7c6e83d --- /dev/null +++ b/as31/Makefile.in @@ -0,0 +1,363 @@ +# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am + +# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +# Makefile for as31 + + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +DESTDIR = + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +CC = @CC@ +CFLAGS = @CFLAGS@ +GTK_CFLAGS = @GTK_CFLAGS@ +GTK_CONFIG = @GTK_CONFIG@ +GTK_LIBS = @GTK_LIBS@ +GUI_CFLAGS = @GUI_CFLAGS@ +GUI_LIBS = @GUI_LIBS@ +LIBS = @LIBS@ +MAKEINFO = @MAKEINFO@ +PACKAGE = @PACKAGE@ +VERSION = @VERSION@ +YACC = @YACC@ + +INCLUDES = $(GUI_CFLAGS) $(CFLAGS) +@OPTION_GTK_TRUE@AS31GTK_BIN = as31gtk +@OPTION_GTK_FALSE@AS31GTK_BIN = + +bin_PROGRAMS = as31 $(AS31GTK_BIN) + + +as31_SOURCES = as31.h run.c lexer.c parser.y parser.h symbol.c emitter.c as31.c + + +as31gtk_SOURCES = as31.h run.c lexer.c parser.y parser.h symbol.c emitter.c as31_gtk.c + + +as31gtk_LDADD = $(GUI_LIBS) + +man_MANS = as31.1 + +EXTRA_DIST = as31.1 +CLEANFILES = as31gtk +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_CLEAN_FILES = +PROGRAMS = $(bin_PROGRAMS) + + +DEFS = @DEFS@ -I. -I$(srcdir) +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ +as31_OBJECTS = run.o lexer.o parser.o symbol.o emitter.o as31.o +as31_LDADD = $(LDADD) +as31_DEPENDENCIES = +as31_LDFLAGS = +as31gtk_OBJECTS = run.o lexer.o parser.o symbol.o emitter.o as31_gtk.o +as31gtk_DEPENDENCIES = +as31gtk_LDFLAGS = +COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ +man1dir = $(mandir)/man1 +MANS = $(man_MANS) + +NROFF = nroff +DIST_COMMON = Makefile.am Makefile.in parser.c + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = tar +GZIP_ENV = --best +SOURCES = $(as31_SOURCES) $(as31gtk_SOURCES) +OBJECTS = $(as31_OBJECTS) $(as31gtk_OBJECTS) + +all: all-redirect +.SUFFIXES: +.SUFFIXES: .S .c .o .s .y +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps as31/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + + +mostlyclean-binPROGRAMS: + +clean-binPROGRAMS: + -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) + +distclean-binPROGRAMS: + +maintainer-clean-binPROGRAMS: + +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(bindir) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + if test -f $$p; then \ + echo " $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \ + $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + list='$(bin_PROGRAMS)'; for p in $$list; do \ + rm -f $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ + done + +.c.o: + $(COMPILE) -c $< + +.s.o: + $(COMPILE) -c $< + +.S.o: + $(COMPILE) -c $< + +mostlyclean-compile: + -rm -f *.o core *.core + +clean-compile: + +distclean-compile: + -rm -f *.tab.c + +maintainer-clean-compile: + +as31: $(as31_OBJECTS) $(as31_DEPENDENCIES) + @rm -f as31 + $(LINK) $(as31_LDFLAGS) $(as31_OBJECTS) $(as31_LDADD) $(LIBS) + +as31gtk: $(as31gtk_OBJECTS) $(as31gtk_DEPENDENCIES) + @rm -f as31gtk + $(LINK) $(as31gtk_LDFLAGS) $(as31gtk_OBJECTS) $(as31gtk_LDADD) $(LIBS) +.y.c: + $(YACC) $(AM_YFLAGS) $(YFLAGS) $< && mv y.tab.c $*.c + if test -f y.tab.h; then \ + if cmp -s y.tab.h $*.h; then rm -f y.tab.h; else mv y.tab.h $*.h; fi; \ + else :; fi +parser.h: parser.c + + +install-man1: + $(mkinstalldirs) $(DESTDIR)$(man1dir) + @list='$(man1_MANS)'; \ + l2='$(man_MANS)'; for i in $$l2; do \ + case "$$i" in \ + *.1*) list="$$list $$i" ;; \ + esac; \ + done; \ + for i in $$list; do \ + if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \ + else file=$$i; fi; \ + ext=`echo $$i | sed -e 's/^.*\\.//'`; \ + inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ + inst=`echo $$inst | sed '$(transform)'`.$$ext; \ + echo " $(INSTALL_DATA) $$file $(DESTDIR)$(man1dir)/$$inst"; \ + $(INSTALL_DATA) $$file $(DESTDIR)$(man1dir)/$$inst; \ + done + +uninstall-man1: + @list='$(man1_MANS)'; \ + l2='$(man_MANS)'; for i in $$l2; do \ + case "$$i" in \ + *.1*) list="$$list $$i" ;; \ + esac; \ + done; \ + for i in $$list; do \ + ext=`echo $$i | sed -e 's/^.*\\.//'`; \ + inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ + inst=`echo $$inst | sed '$(transform)'`.$$ext; \ + echo " rm -f $(DESTDIR)$(man1dir)/$$inst"; \ + rm -f $(DESTDIR)$(man1dir)/$$inst; \ + done +install-man: $(MANS) + @$(NORMAL_INSTALL) + $(MAKE) $(AM_MAKEFLAGS) install-man1 +uninstall-man: + @$(NORMAL_UNINSTALL) + $(MAKE) $(AM_MAKEFLAGS) uninstall-man1 + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + here=`pwd` && cd $(srcdir) \ + && mkid -f$$here/ID $$unique $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || (cd $(srcdir) && etags -o $$here/TAGS $(ETAGS_ARGS) $$tags $$unique $(LISP)) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + -rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = as31 + +distdir: $(DISTFILES) + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pr $$d/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done +as31.o: as31.c as31.h +as31_gtk.o: as31_gtk.c as31.h +emitter.o: emitter.c as31.h +lexer.o: lexer.c as31.h parser.h +parser.o: parser.c as31.h +run.o: run.c as31.h +symbol.o: symbol.c as31.h parser.h + +info-am: +info: info-am +dvi-am: +dvi: dvi-am +check-am: all-am +check: check-am +installcheck-am: +installcheck: installcheck-am +install-exec-am: install-binPROGRAMS +install-exec: install-exec-am + +install-data-am: install-man +install-data: install-data-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-am +uninstall-am: uninstall-binPROGRAMS uninstall-man +uninstall: uninstall-am +all-am: Makefile $(PROGRAMS) $(MANS) +all-redirect: all-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install +installdirs: + $(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(mandir)/man1 + + +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: + -test -z "parserhparserc" || rm -f parserh parserc +mostlyclean-am: mostlyclean-binPROGRAMS mostlyclean-compile \ + mostlyclean-tags mostlyclean-generic + +mostlyclean: mostlyclean-am + +clean-am: clean-binPROGRAMS clean-compile clean-tags clean-generic \ + mostlyclean-am + +clean: clean-am + +distclean-am: distclean-binPROGRAMS distclean-compile distclean-tags \ + distclean-generic clean-am + +distclean: distclean-am + +maintainer-clean-am: maintainer-clean-binPROGRAMS \ + maintainer-clean-compile maintainer-clean-tags \ + maintainer-clean-generic distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-am + +.PHONY: mostlyclean-binPROGRAMS distclean-binPROGRAMS clean-binPROGRAMS \ +maintainer-clean-binPROGRAMS uninstall-binPROGRAMS install-binPROGRAMS \ +mostlyclean-compile distclean-compile clean-compile \ +maintainer-clean-compile install-man1 uninstall-man1 install-man \ +uninstall-man tags mostlyclean-tags distclean-tags clean-tags \ +maintainer-clean-tags distdir info-am info dvi-am dvi check check-am \ +installcheck-am installcheck install-exec-am install-exec \ +install-data-am install-data install-am install uninstall-am uninstall \ +all-redirect all-am all installdirs mostlyclean-generic \ +distclean-generic clean-generic maintainer-clean-generic clean \ +mostlyclean distclean maintainer-clean + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/as31/as31.1 b/as31/as31.1 new file mode 100644 index 0000000..1a9a23a --- /dev/null +++ b/as31/as31.1 @@ -0,0 +1,379 @@ +.TH AS31 1 +.SH NAME +as31 - An Intel 8031/8051 assembler +.SH SYNOPSIS +.B as31 +[-h] [-l] [-s] [-v] [-Aarg] [-Ffmt] [-Ofile] +.BR infile.asm +.SH DESCRIPTION +.I As31 +assembles +.IR infile.asm +into one of several different output formats. The output +will be in a file called infile.obj. The .asm extenstion +is required. + +.SH OPTIONS +The options must appear before the input file name. Both +options are optional. The text of each flag must appear +on the same argument as the flag. For example, "-Fod" is a +valid argument, but "-F od" is not. +.TP +.B \-h +This causes the assembler to print out a verbose message describing its options. +The message is written to the standard error. +.TP +.B \-l +This option tells the assembler to also generate a listing file. +A listing will be placed in the file infile.lst. Where 'infile' is +the file that is being assembled. This option may appear +anywhere before infile.asm. The option must occur isolated on +the command line. +.IP +The listing file shows the assembler generated code in hex, and up to +60 characters are retained from the source file. +.TP +.B \-s +This causes the assembler to write output to standard output. +.TP +.B \-v +This causes the assembler to print a version number to the standard output. +.TP +.B \-Aarg +This option specifies a format specific string which is +passed to the format generator. Both format "tdr" and the srecord +formats use this option. +.TP +.B \-Fformat +This options specifies the output format that is to be used. +.IP +Currently the only options available for this are: +.RS +.IP "hex" +This format is the Intel HEX format which is expected by a +number of EPROM programmers and the PAULMON debugger. For +use with some programmers, the output file's extension may +have to be changed to .HEX to be recognized by the programmer. +No -A option is used. This format should be the +default if no -F option is used. + +.IP "tdr" +This format generates an asci file of hex digits formatted in such a +way, so that they can be read by tdr's debugger. An argument can be +specified (See -A option) which will pass a format specific string to +the format generator. In this case, the argument string represents +an offset to add to the location counter. This offset is +specified in decimal and defaults to 64*1024 (0x10000). To specify +and offset of 100, you would need "-Ftdr -A100" when invoking the +assembler. + +.IP "byte" +This format is simply an address and a byte on each line, in ascii. +No -A option is used. + +.IP "od" +This format is similar to the output from od(1). The format +consists of an address followed by sixteen hexadecimal bytes, followed +by the equivilant ASCII. No -A option is used. + +.IP "srec2, srec3, srec4" +The srecord generator is capable of generating output with any one +of 2, 3, or 4 byte addresses. The -A option can be used to set the +base address offset, the default here is 0x0000 (unlike \fBtdr\fP). +.RE +.IP +NOTE: This assembler allows for the output formats to be expanded to +include many different output formats. +.TP +.B \-Ofile +This option tells the assembler to write the output to a file. +.DE + +.SH "ASSEMBLER INSTRUCTIONS" +This assembler accepts standard 8031/8051 instruction formats. +Below is a list of instructions +and addressing modes. +.IP +.RS +.nf +.ta +1i +2i +1i +1i +INSTRUCTION BYTES CYCLES +----------- ----- ------ +ACALL addr11 2 24 +ADD A, #data8 2 12 +ADD A, @Ri 1 12 +ADD A, Rn 1 12 +ADD A, direct 2 12 +ADDC A, #data8 2 12 +ADDC A, @Ri 1 12 +ADDC A, Rn 1 12 +ADDC A, direct 2 12 +AJMP addr11 2 24 +ANL A, #data8 2 12 +ANL A, @Ri 1 12 +ANL A, Rn 1 12 +ANL A, direct 2 12 +ANL C, /bit 2 24 +ANL C, !bit 2 24 +ANL C, bit 2 24 +ANL direct, #data8 3 24 +ANL direct, A 2 12 +CJNE @Ri, #data8, rel 3 24 +CJNE A, #data8, rel 3 24 +CJNE A, direct, rel 3 24 +CJNE Rn, #data8, rel 3 24 +CLR A 1 12 +CLR C 1 12 +CLR bit 2 12 +CPL A 1 12 +CPL C 1 12 +CPL bit 2 12 +DA A 1 12 +DEC @Ri 1 12 +DEC A 1 12 +DEC DPTR 1 12 +DEC Rn 1 12 +DEC direct 2 12 +DIV AB 1 48 +DJNZ Rn, rel 2 24 +DJNZ direct, rel 3 24 +INC @Ri 1 12 +INC A 1 12 +INC DPTR 1 24 +INC Rn 1 12 +INC direct 2 12 +JB bit, rel 3 24 +JBC bit, rel 3 24 +JC relative 2 24 +JMP @A + DPTR 1 24 +JMP @DPTR + A 1 24 +JNB bit, rel 3 24 +JNC relative 2 24 +JNZ relative 2 24 +JZ relative 2 24 +LCALL addr16 3 24 +LJMP addr16 3 24 +MOV @Ri, #data8 2 12 +MOV @Ri, A 1 12 +MOV @Ri, direct 2 24 +MOV A, #data8 2 12 +MOV A, @Ri 1 12 +MOV A, Rn 1 12 +MOV A, direct 2 12 +MOV C, bit 2 12 +MOV DPTR, #data16 3 24 +MOV Rn, #data8 2 12 +MOV Rn, A 1 12 +MOV Rn, direct 2 24 +MOV bit, C 2 24 +MOV direct, #data8 3 24 +MOV direct, @Ri 2 24 +MOV direct, A 2 12 +MOV direct, Rn 2 24 +MOV direct, direct 3 24 +MOVC A, @A + DPTR 1 24 +MOVC A, @A + PC 1 24 +MOVC A, @DPTR + A 1 24 +MOVC A, @PC + A 1 24 +MOVX @DPTR, A 1 12 +MOVX @Ri, A 1 24 +MOVX A, @DPTR 1 24 +MOVX A, @Ri 1 24 +MUL AB 1 48 +NOP 1 12 +ORL A, #data8 2 12 +ORL A, @Ri 1 12 +ORL A, Rn 1 12 +ORL A, direct 2 12 +ORL C, /bit 2 24 +ORL C, !bit 2 24 +ORL C, bit 2 24 +ORL direct, #data8 3 24 +ORL direct, A 2 12 +POP direct 2 24 +PUSH direct 2 24 +RET 1 24 +RETI 1 24 +RL A 1 12 +RLC A 1 12 +RR A 1 12 +RRC A 1 12 +SETB A 1 12 +SETB bit 2 12 +SJMP relative 2 24 +SUBB A, #data8 2 12 +SUBB A, @Ri 1 12 +SUBB A, Rn 1 12 +SUBB A, direct 2 12 +SWAP A 1 12 +XCH A, #data8 2 12 +XCH A, @Ri 1 12 +XCH A, Rn 1 12 +XCH A, direct 2 12 +XCHD A, #data8 2 12 +XCHD A, @Ri 1 12 +XCHD A, Rn 1 12 +XCHD A, direct 2 12 +XRL A, #data8 2 12 +XRL A, @Ri 1 12 +XRL A, Rn 1 12 +XRL A, direct 2 12 +XRL direct, #data8 3 12 +XRL direct, A 2 12 +.fi +.RE + +.SH "ASSEMBLER DIRECTIVES" +As31 includes the following assembler directives: +.IP ".ORG expr" +Start assembling at the address specified by the expression expr. +An error occurs if the assembler starts assembling over an address +space that has previously been assembled into. + +.IP ".EQU symbol, expr" +Set symbol to the value of expr. The value for expr must be +known during the first pass, when the line containing the .EQU +is encountered. + +.IP ".BYTE expr, expr, ..." +Assemble the bytes specified by the expression into memory. A +string may also be specified with this directive. + +.IP ".WORD expr, expr, ..." +Assemble the words specified by the expression into memory. +The byte ordering used, is that used by the 8031. + +.IP ".FLAG symbol1, symbol.[0-7]" +Sets symbol1 to the bit address specified by the symbol.[0-7] +expression. Where [0-7] denotes a character between 0 and 7. +The resulting bit address is checked to see if it is a valid bit +address. + +.IP ".END" +This directive is ignored. + +.IP ".SKIP expr" +Adds the value of expr to the location counter. Used +to reserve a block of uninitialized data. Expr should +be in bytes. + +.SH "LEXICAL CONVENTIONS" +.IP "-" +All characters following a semi-colon are ignored until a newline +is encountered. + +.IP "-" +All numbers default to decimal, unless the number starts with +one of the following: +.RS +.IP "0x or 0X" +This indicates a hexadecimal number. ie. 0x00ff +.IP "0b or 0B" +This indicates a binary number. (1's and 0's). ie. 0b1100110010 +.IP "0" +This indicates an octal number. ie. 0377 +.RE +.IP "-" +All numbers default to decimal, unless the number ends with +one of the following characters: +.RS +.IP "b or B" +This indicates a binary number. Unless 0x was used above. +ie. 1010101b +.IP "h or H" +This always indicates a hex number, However the if the first +character is non-numerical, then either 0x or 0 must be specified. +This avoids confusing the assembler into thinking a hex number is +a symbol. +For example: 0ffh, 0xffh, 0XffH, 20h, 0x20 and 020h are means +to specify a valid hexdigit. But the following are not: +ffh, 0ff. +.IP "d or D" +This forces a number to decimal. Unless 0X was used. ie. 129d +.IP "o or O" +This causes the number to be interpreted as octal. ie. 377o +.RE + +.IP "-" +A character constant can be entered as 'c' where c is some +character. \\b, \\n, \\r, \\t, \\' \\0 are also valid. A character +constant can be used anywhere that an integer value can. + +.IP "-" +A string is entered as a set of characters enclosed in double quotes "". +A string is only valid with the .BYTE directive. \\b, \\n, \\r, \\t, \\" +are also valid escapes. However \\0 is not. + +.IP "-" +Instructions, directives, and the symbols: R0, R1, R2, R3, R4, R5, +R6, R7, A, AB, and C can be entered in upper or lower case without +assembler confusion. These words however cannot be defined as a user symbol. +Any user symbol may be used, and case will be preserved. So the +user symbols "foo" and "Foo" are different, but "addc" is the same +as "aDdC". + +.IP "-" +A symbol can be any alpha numerical character plus the underscore ('_'). + +.IP "-" +Expressions are accepted in most places where a value or a symbol is +needed. An expression consists of the following operators. All +operators evaulate to integer objects (higher precedence opertors listed +first): +.RS +.IP "-" +Unary minus +.IP "&" +Bit-wise AND. +.IP "|" +Bit-Wise OR. +.IP "*" +Integer multiplication. +.IP "/" +Integer division +.IP "%" +Integer modulus +.IP "+" +Integer addition. +.IP "-" +Integer subtraction. +.RE +.IP "-" +In addition to these operators, a special symbol '*' may be used +to represent the current location counter. + +.SH EXAMPLES +.IP +Below is a sample assembly program. +.RS +.nf + + .org 0 +start: mov P3, #0xff ; use alternate fns on P3 + ; leds on P1 are inverted. + setb F0 ; climbing up + mov A, #0x01 ; initial bit + +write: cpl A ; write it + mov P1, A + cpl A + acall delay + jb F0, climbup ; climbing which way? + +climbdn: rr A ; down - shift right + jnb ACC.0, write ; back for more + setb F0 + ajmp write + +climbup: rl A ; up - shift left + jnb ACC.7, write ; back for more + clr F0 + ajmp write + .end ; this directive ignored. +.fi + + +.SH AUTHORS +Ken Stauffer (University of Calgary) +.br +Martin Langer diff --git a/as31/as31.c b/as31/as31.c new file mode 100644 index 0000000..8e5580c --- /dev/null +++ b/as31/as31.c @@ -0,0 +1,105 @@ +/* ---------------------------------------------------------------------- + * FILE: as31.c + * PACKAGE: as31 - 8031/8051 Assembler. + * + * DESCRIPTION: + * The file contains main(). It handles the arguments and makes + * sure that pass 1 is done before pass 2 etc... + * + * REVISION HISTORY: + * Jan. 19, 1990 - Created. (Ken Stauffer) + * March, 2001, Paul Stoffregen: see ChangeLog for details + * July, 2003, Bernd Porr: added ".inc" to include asm files. + * March, 23, 2004, Alexander 'E-Razor' Krause: see ChangeLog for details + * May, 6, 2004, Alexander 'E-Razor' Krause: see ChangeLog for details + * May, 18, 2004, Martin Langer: see ChangeLog for details + * + * AUTHOR: + * All code in this file written by Ken Stauffer (University of Calgary). + * January, 1990. "Written by: Ken Stauffer" + */ + +#include +#include +#include + +#include "as31.h" + + + +int main(int argc, char **argv) +{ + char *dashF=NULL, *dashA=NULL, *dashO=NULL; + int use_stdout=0, do_lst=0; + int r, i; + + if (argc < 2) { + showhelp(argv[0]); + exit(1); + } + + for (i=1; i +#include + +// include directive +#define INC_CMD ".inc" + +/* ---------------------------------------------------------------------- + * user / keyword symbol structures: + */ + +struct opcode { + char *name; + int type; + unsigned char *bytes; +}; + +struct symbol { + char *name; + char predefined; + char type; + long value; + struct symbol *next; +}; + +#define UNDEF 0 +#define LABEL 1 + +/* these are unused... maybe someday the can be used and the */ +/* parser can check that each addressing mode is using the */ +/* correct type of data, or a generic LABEL type */ +#define BIT 2 +#define IMEM 3 +#define EMEM 3 +#define CONST 4 +#define REG 5 + +/* ---------------------------------------------------------------------- + * addressing mode stuff: + */ + +struct mode { + unsigned char mode; /* value to index with */ + unsigned char size; /* # of bytes used */ + unsigned char orval; /* value OR'd to obcode */ + unsigned char byte1; /* extra byte 1 */ + unsigned char byte2; /* extra byte 2 */ +}; + +#define set_md(m,a) ((m).mode=(a)) +#define set_sz(m,a) ((m).size=(a)) +#define set_ov(m,a) ((m).orval=(a)) +#define set_b1(m,a) ((m).byte1=(a)) +#define set_b2(m,a) ((m).byte2=(a)) + +#define get_md(m) ((m).mode) +#define get_sz(m) ((m).size) +#define get_ov(m) ((m).orval) +#define get_b1(m) ((m).byte1) +#define get_b2(m) ((m).byte2) + +/* ---------------------------------------------------------------------- + * yacc stack stuff: + */ + +struct value { + long v; + unsigned char d; /* expression defined flag */ +}; + +union ystack { + long value; + struct value val; + struct opcode *op; + struct symbol *sym; + struct mode mode; + char *str; +}; + +#define YYSTYPE union ystack + +/* ---------------------------------------------------------------------- + * IS_BIT_MAPPED_RAM: + * True is the byte 'a' is the byte address of a bit mapped + * RAM location. + */ +#define isbmram(a) (((a)&0xf0)==0x20) + +/* ---------------------------------------------------------------------- + * IS_BIT_MAPPED_SFR: + * True is the byte 'a' is the byte address of a bit mapped + * SPECIAL FUCTION REGISTER. + */ +#define isbmsfr(a) (((a)&0x80) && !((a) & 0x07)) + +/* ---------------------------------------------------------------------- + * isbit8, ... + * Macros to check the sizes of values and to convert + * a value to a certain, size. + * + */ +#define size8 (~0x00ff) +#define size11 (~0x07ff) +#define size13 (~0x1fff) +#define size16 (~0xffff) + +#define size10 (~0x03ff) +#define size12 (~0x0fff) +#define size15 (~0x7fff) + +#define isbit8(v) ( !( ((v)>=0) ? (v)&size8 : -(v)>=128) ) +#define isbit11(v) ( !( ((v)>=0) ? (v)&size11 : (-(v))&size10 ) ) +#define isbit13(v) ( !( ((v)>=0) ? (v)&size13 : (-(v))&size12 ) ) +#define isbit16(v) ( !( ((v)>=0) ? (v)&size16 : (-(v))&size15 ) ) + +/* ---------------------------------------------------------------------- + * Size of user hash table. Use a prime number for best performance + */ +#define HASHTABSIZE 4999 + +/* ---------------------------------------------------------------------- + * Macros to nicely test which pass we are in. + */ +#define pass1 (!pass) +#define pass2 (pass) + + + +/* from lexer.c */ +extern int yylex(void); +extern int seek_eol(void); +extern const char *get_last_token(void); +extern int lineno; + + +/* from parser.y */ +extern int yyparse(void); +extern void clear_location_counter(void); + + +/* from emitter.c */ +extern void emitusage(void); +extern const char *emit_extension(const char *ftype); +extern const char *emit_desc_lookup(int num); +extern const char *emit_desc_to_name_lookup(const char *desc); +extern int emitopen(const char *file, const char *ftype, const char *arg); +extern void emitclose(void); +extern void emitaddr(unsigned long a); +extern void emitbyte(int b); + + +/* from symbol.c */ +extern struct opcode *lookop(const char *s); +extern struct symbol *looksym(const char *s); +extern void syminit(void); +extern void freesym(void); + + +/* from run.c */ +extern int run_as31(const char *infile, int lst, int use_stdout, + const char *fmt, const char *arg, const char *customoutfile); +extern void error(const char *fmt, ...); +extern void warn(const char *fmt, ...); +extern void mesg_f(const char *fmt, ...); +extern int dashl; +extern int pass; +extern int abort_asap; +extern unsigned long lc; +extern FILE *listing; + + +/* from as31.c or as31_gtk.c */ +extern void mesg(const char *str); +extern void showhelp(const char *cmd); + diff --git a/as31/as31_gtk.c b/as31/as31_gtk.c new file mode 100644 index 0000000..b16576d --- /dev/null +++ b/as31/as31_gtk.c @@ -0,0 +1,201 @@ +/* ---------------------------------------------------------------------- + * FILE: main.c + * PACKAGE: as31 - 8031/8051 Assembler. + * + * DESCRIPTION: + * The file contains main(). It handles the arguments and makes + * sure that pass 1 is done before pass 2 etc... + * + * REVISION HISTORY: + * Jan. 19, 1990 - Created. (Ken Stauffer) + * + * AUTHOR: + * All code in this file written by Ken Stauffer (University of Calgary). + * January, 1990. "Written by: Ken Stauffer" + * + * April, 2000, Paul Stoffregen: see Makefile for details + */ + +#include +#include +#include +#include +#include +#include + +#include "as31.h" + + +void do_assemble(GtkWidget *widget, gpointer *data); +gint delete_handler(GtkWidget *widget, gpointer *data); + + +/* make all the GTK widgets global, instead of passing lots */ +/* of pointers into the callbacks, through the parser, etc */ + +GtkWidget *file_label, *file_entry, *otype_combo; +GtkWidget *list_check, *go_button; +GtkWidget *otype_label, *output_text; +GtkWidget *main_window, *main_vbox; +GtkWidget *top_hbox, *middle_hbox, *bottom_hbox; + + +int main(int argc, char **argv) +{ + GList *otypelist; + const char *desc; + int n; + + gtk_init(&argc, &argv); + + /* create all the gtk widgets... it's a pain to type in all */ + /* this stuff, maybe someday I'll have to learn about glade */ + + file_label = gtk_label_new("ASM File: "); + gtk_label_set_justify(GTK_LABEL(file_label), GTK_JUSTIFY_RIGHT); + gtk_widget_show(file_label); + + otype_label = gtk_label_new("Output Format"); + gtk_label_set_justify(GTK_LABEL(otype_label), GTK_JUSTIFY_RIGHT); + gtk_widget_show(otype_label); + + file_entry = gtk_entry_new(); + /* fill in a default filename, from a previous session ??? */ + gtk_widget_show(file_entry); + + list_check = gtk_check_button_new_with_label("Create List File"); + /* check or unchecked based on previous usage */ + gtk_widget_show(list_check); + + otype_combo = gtk_combo_new(); + otypelist = NULL; + n = 0; + while ((desc = emit_desc_lookup(n++)) != NULL) { + otypelist = g_list_append(otypelist, strdup(desc)); + } + gtk_combo_set_popdown_strings(GTK_COMBO(otype_combo), otypelist); + gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(otype_combo)->entry), + FALSE); + /* set to same output format as a previous run ?? */ + gtk_widget_show(otype_combo); + + go_button = gtk_button_new_with_label("Assemble"); + gtk_widget_show(go_button); + + output_text = gtk_text_new(NULL, NULL); + gtk_text_set_editable(GTK_TEXT(output_text), FALSE); + gtk_widget_show(output_text); + + top_hbox = gtk_hbox_new(FALSE, 2); + gtk_box_pack_start(GTK_BOX(top_hbox), file_label, FALSE, FALSE, 2); + gtk_box_pack_start(GTK_BOX(top_hbox), file_entry, TRUE, TRUE, 2); + gtk_widget_show(top_hbox); + + middle_hbox = gtk_hbox_new(FALSE, 2); + gtk_box_pack_start(GTK_BOX(middle_hbox), otype_label, FALSE, FALSE, 2); + gtk_box_pack_start(GTK_BOX(middle_hbox), otype_combo, FALSE, FALSE, 2); + gtk_widget_show(middle_hbox); + + bottom_hbox = gtk_hbox_new(FALSE, 2); + gtk_box_pack_start(GTK_BOX(bottom_hbox), go_button, FALSE, FALSE, 2); + gtk_box_pack_start(GTK_BOX(bottom_hbox), list_check, FALSE, FALSE, 2); + gtk_widget_show(bottom_hbox); + + main_vbox = gtk_vbox_new(FALSE, 2); + gtk_box_pack_start(GTK_BOX(main_vbox), top_hbox, FALSE, FALSE, 2); + gtk_box_pack_start(GTK_BOX(main_vbox), middle_hbox, FALSE, FALSE, 2); + gtk_box_pack_start(GTK_BOX(main_vbox), bottom_hbox, FALSE, FALSE, 2); + gtk_box_pack_start(GTK_BOX(main_vbox), output_text, TRUE, TRUE, 2); + gtk_widget_show(main_vbox); + + main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_container_add(GTK_CONTAINER(main_window), main_vbox); + gtk_widget_show(main_window); + + /* attach signal handlers so we can actually do something */ + + gtk_signal_connect(GTK_OBJECT(main_window), "delete_event", + GTK_SIGNAL_FUNC(delete_handler), NULL); + + gtk_signal_connect(GTK_OBJECT(go_button), "pressed", + GTK_SIGNAL_FUNC(do_assemble), NULL); + + /* that's it, everything past here is a callback from GTK */ + + mesg("WARNING: this is an alpha-quality release.\n"); + mesg("It WILL crash the second time you assemble !!\n"); + mesg("Please report any problems that occur on the\n"); + mesg("first assembly to: paul@pjrc.com\n"); + + gtk_main(); + return 0; +} + + +/* actually do the assembly. The entire assembly is done from */ +/* start to finish in this callback attached to the "assemble now" */ +/* button. It's not so nice to spend a lot of CPU time in a */ +/* callback, because all the gtk widgets stop responding until */ +/* we're done, but it keeps things simple, and at least the */ +/* window manager takes care of raise/lower and reposition, */ +/* ...unlike ms windoze where those are handled by the */ +/* application's event loop. It would be "nice" to launch a */ +/* thread that would do the assembly, but for a simple free */ +/* software project (where the assembly completes rapidly on */ +/* any modern cpu), I don't want to bother with all the unpleasant */ +/* threading issues */ + +void +do_assemble(GtkWidget *widget, gpointer *data) +{ + const char *fmt=NULL, *filename; + int r, do_lst; + + + /* collect info from the GTK widgets */ + + do_lst = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(list_check)); + + filename = gtk_entry_get_text(GTK_ENTRY(file_entry)); + if (filename == NULL || *filename == '\0') { + mesg("You need to specify the ASM file\n"); + return; + } + + fmt = emit_desc_to_name_lookup(gtk_entry_get_text( + GTK_ENTRY(GTK_COMBO(otype_combo)->entry))); + if (fmt == NULL) { + mesg("Please select a valid output type\n"); + return; + } + + /* now we can begin working like normal */ + + r = run_as31(filename, do_lst, 0, fmt, NULL, NULL); + + if (r == 0) { + mesg("Assembly complete, no errors :)\n"); + } +} + + +/* quit the program if they close it */ + +gint +delete_handler(GtkWidget *widget, gpointer *data) +{ + gtk_main_quit(); + return FALSE; +} + + +/* the assembler calls here to display any messages */ + +void mesg(const char *str) +{ + if (str == NULL) str = "(null)"; + /* printf("%s", str); */ + gtk_text_insert(GTK_TEXT(output_text), NULL, NULL, + NULL, str, strlen(str)); +} + diff --git a/as31/emitter.c b/as31/emitter.c new file mode 100644 index 0000000..4ab65a2 --- /dev/null +++ b/as31/emitter.c @@ -0,0 +1,626 @@ +/* ---------------------------------------------------------------------- + * FILE: emitter.c + * PACKAGE: as31 - 8031/8051 Assembler. + * + * DESCRIPTION: + * This file contains the code to generate various + * object code formats. Provisions exist to + * support many types of output formats within the + * same executable. + * + * REVISION HISTORY: + * Jan. 19, 1990 - Created. (Ken Stauffer) + * Jan. 29, 1990 - Added S-records (Theo Deraadt) + * + * + * AUTHOR: + * All code in this file written by Ken Stauffer (University of Calgary). + * January, 1990. + */ + +#include +#include + +#include "as31.h" + +/* ---------------------------------------------------------------------- + * DECLARE your own open(), close(), addr(), and byte() routines here. + * + */ + +static int open_tdr(const char *file, const char *ftype, const char *arg); +static void close_tdr(void); +static void addr_tdr(unsigned long a); +static void byte_tdr(unsigned char b); + +static int open_byte(const char *file, const char *ftype, const char *arg); +static void close_byte(void); +static void addr_byte(unsigned long a); +static void byte_byte(unsigned char b); + +static int open_od(const char *file, const char *ftype, const char *arg); +static void close_od(void); +static void addr_od(unsigned long a); +static void byte_od(unsigned char b); + +static int open_srec(const char *file, const char *ftype, const char *arg); +static void close_srec(void); +static void addr_srec(unsigned long a); +static void byte_srec(unsigned char b); + +static int open_hex(const char *file, const char *ftype, const char *arg); +static void close_hex(void); +static void addr_hex(unsigned long a); +static void byte_hex(unsigned char b); + +static int open_bin(const char *file, const char *ftype, const char *arg); +static void close_bin(void); +static void addr_bin(unsigned long a); +static void byte_bin(unsigned char b); + +/* ---------------------------------------------------------------------- + * ADD an entry to this table to register your + * output format routines. Give your object format + * a name to be specified with the -F option. + * + */ + +static int format; + +static struct { + char *name; + char *extension; + char *description; + int (*e_open)(const char *file, const char *ftype, const char *arg); + void (*e_close)(void); + void (*e_addr)(unsigned long a); + void (*e_byte)(unsigned char b); +} formtab[] = { + { "hex", "hex", "Intel-Hex (.hex)", open_hex, close_hex, addr_hex, byte_hex }, + { "bin", "bin", "Binary (.bin)", open_bin, close_bin, addr_bin, byte_bin }, + { "tdr", "tdr", "TDR Format (.tdr)", open_tdr, close_tdr, addr_tdr, byte_tdr }, + { "byte", "byte", "BYTE list (.byte)", open_byte, close_byte, addr_byte, byte_byte }, + { "od", "od", "Octal Dump (.od)", open_od, close_od, addr_od, byte_od }, + { "srec2", "srec", "S Record, 16 bit Address (.srec)", open_srec, close_srec, addr_srec, byte_srec }, + { "srec3", "srec", "S Record, 24 bit Address (.srec)", open_srec, close_srec, addr_srec, byte_srec }, + { "srec4", "srec", "S Record, 32 bit Address (.srec)", open_srec, close_srec, addr_srec, byte_srec } +}; + +#define FORMTABSIZE (sizeof(formtab)/sizeof(formtab[0])) + +void emitusage(void) +{ + int i; + + fprintf(stderr, "["); + for(i=0; i= 0 && num < FORMTABSIZE) + return formtab[num].description; + return NULL; +} + +const char *emit_desc_to_name_lookup(const char *desc) +{ + int i; + + if (desc) { + for(i=0; i>8)&0xff) + (addr&0xff) ; + for (i=0; i < pos; i++) { + fprintf(fout,"%02X", bytes[i] & 0xFF ); + sum += bytes[i]&0xff; + } + fprintf(fout, "%02X\n", (-sum)&0xff); + addr += pos; + pos = 0; +} + +static int open_hex(const char *file, const char *ftype, const char *arg) +{ + if (file == NULL) fout = stdout; + else fout = fopen(file, "w"); + + if( fout == NULL ) { + mesg_f("Cannot open %s for writing.\n", file); + return -1; + } + pos = 0; + return 0; +} + +static void close_hex(void) +{ + if (fout == NULL) return; + if ( pos > 0 ) hexdump(); + fprintf(fout, ":00000001FF\n"); /* end of file marker */ + fclose(fout); +} + +static void addr_hex(unsigned long a) +{ + if ( pos > 0 ) hexdump(); + addr = a; +} + +static void byte_hex(unsigned char b) +{ + bytes[pos] = b; + pos += 1; + if ( pos == 16) hexdump(); +} + + +/*----------------------------------------------------------------------- + * "bin" format. Raw binary data + */ + +static int open_bin(const char *file, const char *ftype, const char *arg) +{ + if (file == NULL) fout = stdout; + else fout = fopen(file, "w"); + + if( fout == NULL ) { + mesg_f("Cannot open %s for writing.\n", file); + return -1; + } + addr = 0; + return 0; +} + +static void close_bin(void) +{ + if (fout == NULL) return; + fclose(fout); +} + +static void addr_bin(unsigned long a) +{ + long i; + + if (fout == NULL) return; + if (a > addr) { + for (i=0; i < a - addr; i++) { + fprintf(fout, "%c", 0); + } + addr = a; + return; + } + if (a < addr) { + error("address changed to %lX, from %lX", a, addr); + error("binary output format can't write backwards"); + addr = a; + return; + } +} + +static void byte_bin(unsigned char b) +{ + if (fout == NULL) return; + fprintf(fout, "%c", b & 0xFF); + addr++; +} + + +/* ---------------------------------------------------------------------- + * "tdr" format. For tdr's 68008 system. Generates a + * script file readable by a debugger. + * [addr] : [byte] [byte] .. + * + * arg: This is a number in decimal which specifies + * the offset, -Ftdr -A0000 + * + * These options specifies the tdr format, with an argument + * of 0. This becomes the offset used in generating the + * script file. The default if no A is present is 0x10000. + * + */ + +static int open_tdr(const char *file, const char *ftype, const char *arg) +{ + if (file == NULL) fout = stdout; + else fout = fopen(file,"w"); + + if( fout == NULL ) { + mesg_f("Cannot open %s for writing.\n",file); + return -1; + } + if (arg) { + offset = atoi(arg); + } else { + offset = 0x10000; + } + return 0; +} + +static void close_tdr(void) +{ + if (fout == NULL) return; + if( pos != 15 ) fprintf(fout,"\n"); + fclose(fout); +} + +static void addr_tdr(unsigned long a) +{ + addr = a; + newaddr = 1; +} + +static void byte_tdr(unsigned char b) +{ + if (fout == NULL) return; + if( newaddr ) { + if( pos != -666 ) fprintf(fout,"\n"); + newaddr = 0; + pos = 15; + fprintf(fout,"%06lx: ", (addr + offset) & 0xFFFFFF); + } else if( pos == 15 ) { + fprintf(fout,"%06lx: ", (addr + offset) & 0xFFFFFF); + } + + fprintf(fout,"%02x ", b & 0xFF ); + + if( pos-- == 0 ) { + fprintf(fout, "\n"); + pos = 15; + } + addr += 1; +} + + +/* ---------------------------------------------------------------------- + * "byte" format. + * Like "tdr" but each byte is on a line by itself. + * This is nice for debugging. No -A is used. + */ + +static int open_byte(const char *file, const char *ftype, const char *arg) +{ + if (file == NULL) fout = stdout; + else fout = fopen(file,"w"); + + if( fout == NULL ) { + mesg_f("Cannot open %s for writing.\n", file); + return -1; + } + return 0; +} + +static void close_byte(void) +{ + if (fout == NULL) return; + fclose(fout); +} + +static void addr_byte(unsigned long a) +{ + addr = a; +} + +static void byte_byte(unsigned char b) +{ + if (fout == NULL) return; + fprintf(fout,"%04lX: %02X\n", addr & 0xFFFF, b & 0xFF ); + addr += 1; +} + + +/* ---------------------------------------------------------------------- + * "od", this format shows 16 bytes per line, with address. + * It also includes ascii on one side. + * + * The format is similar to the od(1) program under Unix. + * + */ + +static int od_pos; +static unsigned char od_buf[16]; +static unsigned long saveaddr; + +void dumpline(unsigned long a, unsigned char *b, int len) +{ + int i; + + if (fout == NULL) return; + if(len <= 0 ) return; + + fprintf(fout,"%04lx: ", a & 0xFFFF); + + for(i=0; i<8; i++ ) { + if( i <= len ) + fprintf(fout,"%02x ",b[i]); + else + fprintf(fout," "); + } + + fprintf(fout,"- "); + + for(i=8; i<16; i++ ) { + if( i <= len ) + fprintf(fout,"%02x ",b[i]); + else + fprintf(fout," "); + } + fprintf(fout," "); + + for(i=0; i<16; i++ ) { + if( i <= len ) + fprintf(fout,"%c", + (b[i]>=' ' && b[i]<='~') ? b[i] : '.' ); + else + break; + } + fprintf(fout,"\n"); +} + +static int open_od(const char *file, const char *ftype, const char *arg) +{ + if (file == NULL) fout = stdout; + else fout = fopen(file,"w"); + + if( fout == NULL ) { + mesg_f("Cannot open %s for writing.\n",file); + return -1; + } + return 0; +} + +static void close_od(void) +{ + if (fout == NULL) return; + dumpline(saveaddr, od_buf, od_pos-1); + fclose(fout); +} + +static void addr_od(unsigned long a) +{ + newaddr = 1; + addr = a; +} + +static void byte_od(unsigned char b) +{ + if( newaddr ) { + dumpline(saveaddr, od_buf, od_pos-1); + od_pos = 0; + newaddr = 0; + saveaddr = addr; + } else if( od_pos == 16 ) { + dumpline(saveaddr, od_buf, od_pos-1); + od_pos = 0; + saveaddr = addr; + } + od_buf[od_pos++] = b & 0x00ff; + + addr += 1; +} + + +/* ---------------------------------------------------------------------- + * srecord format. This is called with "-Fsrec2", "-Fsrec3", or + * "-Fsrec4"... + * + * arg: This is a number in decimal which specifies + * the offset, -Fsrec3 -A0000 + * + * These options specifies the tdr format, with an argument + * of 0. This becomes the offset used in generating the + * script file. The default if no A is present is 0x0000. + * + */ + +#define SREC_BYTESPERLINE 32 + +static int srec_format; +static int srec_check, srec_index; +static char srec_buf[SREC_BYTESPERLINE]; +static long srec_address; + +void srec_finishline(void) +{ + int i; + + if (fout == NULL) return; + srec_check = srec_index + (srec_address & 0xff) + ((srec_address>>8) & 0xff) + 4; + + switch(srec_format) { + case 2: + fprintf(fout, "S1%02X%04lX", srec_index + 4, + srec_address & 0xFFFF); + break; + case 3: + fprintf(fout, "S2%02X%06lX", srec_index + 6, + srec_address & 0xFFFFFF); + srec_check += ((srec_address>>16) & 0xff) + 2; + break; + case 4: + fprintf(fout, "S3%02X%08lX", srec_index + 8, srec_address); + srec_check += ((srec_address>>16) & 0xff) + + ((srec_address>>24) & 0xff) + 4; + break; + } + + for(i=0; i 4) { + mesg_f("Illegal S Record format %d %s (must be 2, 3, or 4)\n", + srec_format, ftype); + return -1; + } + + if (file == NULL) fout = stdout; + else fout = fopen(file,"w"); + + if( fout == NULL ) { + mesg_f("Cannot open %s for writing.\n",file); + return -1; + } + + if(arg) offset = atoi(arg); + else offset = 0; + + fprintf(fout, "S0030000%02X\n", (~3 & 0xff) ); + return 0; +} + +static void close_srec(void) +{ + if (fout == NULL) return; + if(srec_index) + srec_finishline(); + switch(srec_format) { + case 2: + fprintf(fout, "S9030000%02X\n", ~3 & 0xff); + break; + case 3: + fprintf(fout, "S804000000%02X\n", ~4 & 0xff); + break; + case 4: + fprintf(fout, "S70500000000%02X\n", ~5 & 0xff); + break; + } + fclose(fout); +} + +static void addr_srec(unsigned long a) +{ + if(srec_index>0) + srec_finishline(); + srec_address = a + offset; +} + +static void byte_srec(unsigned char b) +{ + srec_buf[srec_index++] = b; + if(srec_index==SREC_BYTESPERLINE) { + srec_finishline(); + srec_address += SREC_BYTESPERLINE; + } +} + + diff --git a/as31/lexer.c b/as31/lexer.c new file mode 100644 index 0000000..13056b0 --- /dev/null +++ b/as31/lexer.c @@ -0,0 +1,391 @@ +/* ---------------------------------------------------------------------- + * FILE: lexer.c + * PACKAGE: as31 - 8031/8051 Assembler. + * + * DESCRIPTION: + * This file contains the lexical tokenizer for the assembler. + * Since yacc is being used the lexer is called yylex(). + * + * In order to produce a listing, some record of the users + * source line must be kept. This is done by adding + * get_ch(), and unget_ch() routine which returns/ungets a character + * but also places information into a secret array. + * + * When a newline is encountered the text line is returned as + * an attribute on the '\n' character. + * + * REVISION HISTORY: + * Jan. 19, 1990 - Created. (Ken Stauffer) + * + * AUTHOR: + * All code in this file written by Ken Stauffer (University of Calgary). + * January, 1990. + * + */ + +#include +#include +#include + +#include "as31.h" +#include "parser.h" + + +int lineno; +int last_token_len=0; +char last_token[256], prev_token[256]; + +static char line[100]; +static char *lineptr=line; + +/* ---------------------------------------------------------------------- + * get_ch: + * Get a character from stdin, place char in line[] + */ + +int get_ch(void) +{ + register int c; + + c = getchar(); + if (last_token_len >=0 && last_token_len < 254 && + c != EOF && (last_token_len > 0 || !isspace(c))) { + last_token[last_token_len++] = c; + } + if( c != EOF && lineptr - line < sizeof(line) ) + *lineptr++ = c; + return(c); +} + +/* ---------------------------------------------------------------------- + * unget_ch: + * Unget a character and move lineptr back by one. + */ + +void unget_ch(int c) +{ + ungetc(c,stdin); + if( lineptr > line ) + lineptr--; +} + + + +/* when there is a parse error, yyparse should call here to */ +/* advance to the end of the current line, so we can continue */ +/* parsing the rest of the file */ + +int seek_eol(void) +{ + int c; + + last_token_len = -1; + do { + c = get_ch(); + } while (c != '\n' && c != EOF); + if (c == '\n') { + unget_ch(c); + return 1; + } + return 0; +} + +/* return a pointer to the last successfully parsed token, so */ +/* we can give a nicer error message when there is a syntax error */ + +const char *get_last_token(void) +{ + /* + if (last_token_len < 0) last_token_len = 0; + last_token[last_token_len] = '\0'; + */ + return prev_token; +} + + + +/* ---------------------------------------------------------------------- + * yylex: + * The tokens themselves are returned via return(token) + * + * Some tokens have attributes. These attributes are returned + * by setting a global variable yylval: + * + * yylval.value + * numbers (any base) + * strings (in pass 1). + * bit positions .0, .1, .2, ... + * + * yylval.str + * strings (in pass 2). + * '\n' (both passes). + * + * yylval.sym + * User defined symbols. + * + * yylval.op + * Reserved keyword (opcode/directive/misc.) + * + * No other fields in yylval are used by yylex(). + * + * Characters that do not have an attribute do + * not set anything in the yylval variable. + * + */ + + + +int yylex(void) +{ + static int nl_flag=0; /* sync. error messages and the cur. line */ + register int c; + char buf[1024]; /* temporary buffer */ + char *p; /* general pointer */ + struct symbol *sym; + struct opcode *op; + + int octal=0,hex=0,decimal=0,binary=0; + register long value = 0; + + if (last_token_len > 0) { + last_token[last_token_len] = '\0'; + strcpy(prev_token, last_token); + } else { + *prev_token = '\0'; + } + last_token_len=0; + + if( nl_flag ) { + nl_flag = 0; + lineno++; + } + +for(;;) { + c = get_ch(); + switch(c) { + case EOF: return(EOF); + case ' ': + case '\r': + case '\t': + break; + + case '\n': + nl_flag = 1; + yylval.str = line; + *lineptr = '\0'; + lineptr = line; + return('\n'); + + case ';': + while((c=get_ch()) != EOF && c!='\n'); + nl_flag= 1; + yylval.str = line; + *lineptr = '\0'; + lineptr = line; + return(c); + + case '"': + p = buf; + while((c=get_ch()) != EOF && c!='"' && c!='\n') { + if( c == '\\' ) { + switch(c=get_ch()) { + case 'n': c = '\n'; break; + case 'r': c = '\r'; break; + case 't': c = '\t'; break; + case 'b': c = '\b'; break; + case '"': c = '"'; break; + case '\\': c = '\\'; break; + default: + warn("Invalid escape character: \\%c",c); + } + } + if( p-buf='0' && c<='7' ) { + yylval.value = c-'0'; + return(BITPOS); + } + unget_ch(c); + return('.'); + + case '\'': + c = get_ch(); + if( c=='\\' ) { + switch(c=get_ch()) { + case 'n': c = '\n'; break; + case 'r': c = '\r'; break; + case 't': c = '\t'; break; + case 'b': c = '\b'; break; + case '0': c = 0; break; + case 'o': c = 0; break; + case 'O': c = 0; break; + case '\\': c = '\\'; break; + case '\'': c = '\''; break; + default: + warn("Invalid escape character: \\%c",c); + } + } + if( get_ch() != '\'' ) + warn("Missing quote in character constant"); + yylval.value = c; + return(VALUE); + + case '0': /* parse a number */ + case '1': /* could be followed by a: */ + case '2': /* 'b','B' - Binary */ + case '3': /* 'h','H' - Hex */ + case '4': /* 'd','D' - Decimal */ + case '5': /* 'o','O' - Octal */ + case '6': /* *** Numbers must start with a digit */ + case '7': /* Numbers could be also preceeded by: */ + case '8': /* 0x - Hex */ + case '9': /* 0b - binary */ + + p = buf; + do { + if( p-buf='a' && *p<='f' ) + value += *p-'a'+ 10; + else if( *p>='A' && *p<='F' ) + value += *p-'A'+ 10; + else + warn("Invalid hex digit: %c",*p); + } + yylval.value = value; + return(VALUE); + } + + if (decimal) { + if (hex) warn("ambiguous number, dec or hex"); + if (binary) warn("ambiguous number, dec or bin"); + if (octal) warn("ambiguous number, dec or oct"); + for(p=buf; *p; p++ ) { + if( isdigit(*p) ) + value = value*10 + *p-'0'; + else + warn("Invalid decimal digit: %c",*p); + } + yylval.value = value; + return(VALUE); + } + + if (octal) { + if (hex) warn("ambiguous number, oct or hex"); + if (binary) warn("ambiguous number, oct or bin"); + if (decimal) warn("ambiguous number, oct or dec"); + for(p=buf; *p; p++ ) { + if( *p>='0' && *p<='7' ) + value = (value << 3) + (*p - '0'); + else + warn("Invalid octal digit: %c",*p); + } + yylval.value = value; + return(VALUE); + } + + default: + if( isalpha(c) || c=='_' ) { + p = buf; + do { + if( p-buftype); + } + sym = looksym(buf); + yylval.sym = sym; + return(SYMBOL); + } else + return(c); + } /* switch */ +} /* for */ + +} /* yylex */ + + diff --git a/as31/parser.c b/as31/parser.c new file mode 100644 index 0000000..dd388a9 --- /dev/null +++ b/as31/parser.c @@ -0,0 +1,3104 @@ +/* A Bison parser, made by GNU Bison 1.875d. */ + +/* Skeleton parser for Yacc-like parsing with Bison, + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. + + This program 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, or (at your option) + any later version. + + This program 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 this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* Written by Richard Stallman by simplifying the original so called + ``semantic'' parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 0 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + STRING = 258, + D_ORG = 259, + D_BYTE = 260, + D_WORD = 261, + D_SKIP = 262, + D_EQU = 263, + D_FLAG = 264, + D_END = 265, + ACALL = 266, + ADD = 267, + ADDC = 268, + AJMP = 269, + ANL = 270, + CJNE = 271, + CLR = 272, + CPL = 273, + DA = 274, + DEC = 275, + DIV = 276, + DJNZ = 277, + INC = 278, + JB = 279, + JBC = 280, + JC = 281, + JMP = 282, + JNB = 283, + JNC = 284, + JNZ = 285, + JZ = 286, + LCALL = 287, + LJMP = 288, + MOV = 289, + MOVC = 290, + MOVX = 291, + NOP = 292, + MUL = 293, + ORL = 294, + POP = 295, + PUSH = 296, + RET = 297, + RETI = 298, + RL = 299, + RLC = 300, + RR = 301, + RRC = 302, + SETB = 303, + SJMP = 304, + SUBB = 305, + SWAP = 306, + XCH = 307, + XCHD = 308, + XRL = 309, + AB = 310, + A = 311, + C = 312, + PC = 313, + DPTR = 314, + BITPOS = 315, + R0 = 316, + R1 = 317, + R2 = 318, + R3 = 319, + R4 = 320, + R5 = 321, + R6 = 322, + R7 = 323, + VALUE = 324, + SYMBOL = 325 + }; +#endif +#define STRING 258 +#define D_ORG 259 +#define D_BYTE 260 +#define D_WORD 261 +#define D_SKIP 262 +#define D_EQU 263 +#define D_FLAG 264 +#define D_END 265 +#define ACALL 266 +#define ADD 267 +#define ADDC 268 +#define AJMP 269 +#define ANL 270 +#define CJNE 271 +#define CLR 272 +#define CPL 273 +#define DA 274 +#define DEC 275 +#define DIV 276 +#define DJNZ 277 +#define INC 278 +#define JB 279 +#define JBC 280 +#define JC 281 +#define JMP 282 +#define JNB 283 +#define JNC 284 +#define JNZ 285 +#define JZ 286 +#define LCALL 287 +#define LJMP 288 +#define MOV 289 +#define MOVC 290 +#define MOVX 291 +#define NOP 292 +#define MUL 293 +#define ORL 294 +#define POP 295 +#define PUSH 296 +#define RET 297 +#define RETI 298 +#define RL 299 +#define RLC 300 +#define RR 301 +#define RRC 302 +#define SETB 303 +#define SJMP 304 +#define SUBB 305 +#define SWAP 306 +#define XCH 307 +#define XCHD 308 +#define XRL 309 +#define AB 310 +#define A 311 +#define C 312 +#define PC 313 +#define DPTR 314 +#define BITPOS 315 +#define R0 316 +#define R1 317 +#define R2 318 +#define R3 319 +#define R4 320 +#define R5 321 +#define R6 322 +#define R7 323 +#define VALUE 324 +#define SYMBOL 325 + + + + +/* Copy the first part of user declarations. */ +#line 21 "parser.y" + + +#include +#include + +#define NOPE +#include "as31.h" +#undef NOPE + +#define YYSTYPE union ystack + +static unsigned char bytebuf[1024]; /* used by dumplist() */ +static int bytecount; + + +void yyerror(const char *s); +int makeop(struct opcode * op, struct mode *m, int add); +void inclc(int i); +char *padline(char *line); +void dumplist(char *txt, int show); +void genbyte(int b); +void genstr(const char *s); +void genword(unsigned long w); + +/* ------------------------ G R A M M E R ----------------------------- */ + + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) +typedef int YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ + + +/* Line 214 of yacc.c. */ +#line 255 "y.tab.c" + +#if ! defined (yyoverflow) || YYERROR_VERBOSE + +# ifndef YYFREE +# define YYFREE free +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# endif + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# define YYSTACK_ALLOC alloca +# endif +# else +# if defined (alloca) || defined (_ALLOCA_H) +# define YYSTACK_ALLOC alloca +# else +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) +# else +# if defined (__STDC__) || defined (__cplusplus) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# endif +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# endif +#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ + + +#if (! defined (yyoverflow) \ + && (! defined (__cplusplus) \ + || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + short int yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined (__GNUC__) && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + register YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (0) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (0) + +#endif + +#if defined (__STDC__) || defined (__cplusplus) + typedef signed char yysigned_char; +#else + typedef short int yysigned_char; +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 155 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 599 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 89 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 35 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 165 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 316 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 325 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const unsigned char yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 81, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 88, 2, 87, 2, 75, 77, 2, + 84, 85, 73, 71, 83, 72, 82, 74, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 80, 2, + 79, 2, 78, 2, 86, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 76, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 70 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const unsigned short int yyprhs[] = +{ + 0, 0, 3, 5, 8, 10, 14, 16, 19, 22, + 24, 25, 29, 33, 37, 41, 45, 51, 57, 60, + 62, 65, 67, 69, 71, 75, 79, 81, 83, 87, + 89, 91, 95, 98, 102, 106, 110, 114, 118, 122, + 126, 131, 136, 138, 140, 142, 145, 148, 151, 154, + 157, 160, 163, 166, 169, 172, 175, 178, 181, 184, + 187, 190, 193, 196, 199, 205, 211, 214, 216, 218, + 221, 224, 227, 230, 233, 236, 239, 242, 245, 248, + 251, 254, 257, 260, 263, 266, 269, 272, 275, 278, + 281, 284, 287, 290, 293, 296, 304, 312, 320, 328, + 334, 340, 346, 352, 356, 360, 365, 370, 374, 379, + 383, 388, 393, 397, 401, 405, 409, 413, 418, 422, + 426, 431, 436, 441, 447, 452, 456, 460, 465, 467, + 469, 471, 474, 476, 478, 480, 486, 493, 500, 508, + 510, 512, 515, 517, 519, 521, 523, 525, 527, 529, + 531, 533, 535, 537, 539, 541, 543, 545, 547, 549, + 551, 553, 555, 557, 559, 561 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yysigned_char yyrhs[] = +{ + 90, 0, -1, 91, -1, 91, 92, -1, 92, -1, + 99, 80, 93, -1, 93, -1, 95, 81, -1, 103, + 81, -1, 81, -1, -1, 1, 94, 81, -1, 82, + 4, 96, -1, 82, 5, 100, -1, 82, 6, 101, + -1, 82, 7, 96, -1, 82, 8, 99, 83, 102, + -1, 82, 9, 70, 83, 97, -1, 82, 10, -1, + 102, -1, 98, 60, -1, 70, -1, 69, -1, 70, + -1, 100, 83, 119, -1, 100, 83, 3, -1, 119, + -1, 3, -1, 101, 83, 120, -1, 120, -1, 73, + -1, 84, 102, 85, -1, 72, 102, -1, 102, 76, + 102, -1, 102, 77, 102, -1, 102, 73, 102, -1, + 102, 74, 102, -1, 102, 75, 102, -1, 102, 72, + 102, -1, 102, 71, 102, -1, 102, 78, 78, 102, + -1, 102, 79, 79, 102, -1, 70, -1, 69, -1, + 37, -1, 11, 121, -1, 14, 121, -1, 12, 104, + -1, 13, 104, -1, 50, 104, -1, 54, 104, -1, + 54, 105, -1, 15, 104, -1, 15, 105, -1, 15, + 106, -1, 39, 104, -1, 39, 105, -1, 39, 106, + -1, 52, 104, -1, 23, 110, -1, 23, 59, -1, + 20, 110, -1, 19, 56, -1, 21, 55, -1, 27, + 86, 56, 71, 59, -1, 27, 86, 59, 71, 56, + -1, 38, 55, -1, 42, -1, 43, -1, 44, 56, + -1, 45, 56, -1, 46, 56, -1, 47, 56, -1, + 51, 56, -1, 53, 104, -1, 17, 111, -1, 18, + 111, -1, 48, 111, -1, 41, 119, -1, 40, 119, + -1, 33, 122, -1, 32, 122, -1, 26, 123, -1, + 29, 123, -1, 30, 123, -1, 31, 123, -1, 49, + 123, -1, 16, 112, -1, 24, 107, -1, 28, 107, + -1, 25, 107, -1, 22, 108, -1, 34, 104, -1, + 34, 105, -1, 34, 109, -1, 35, 56, 83, 86, + 56, 71, 59, -1, 35, 56, 83, 86, 59, 71, + 56, -1, 35, 56, 83, 86, 56, 71, 58, -1, + 35, 56, 83, 86, 58, 71, 56, -1, 36, 56, + 83, 86, 118, -1, 36, 56, 83, 86, 59, -1, + 36, 86, 118, 83, 56, -1, 36, 86, 59, 83, + 56, -1, 56, 83, 117, -1, 56, 83, 119, -1, + 56, 83, 86, 118, -1, 56, 83, 87, 119, -1, + 119, 83, 56, -1, 119, 83, 87, 119, -1, 57, + 83, 115, -1, 57, 83, 74, 115, -1, 57, 83, + 88, 115, -1, 115, 83, 113, -1, 117, 83, 114, + -1, 119, 83, 113, -1, 117, 83, 56, -1, 117, + 83, 119, -1, 117, 83, 87, 119, -1, 119, 83, + 117, -1, 119, 83, 119, -1, 119, 83, 86, 118, + -1, 86, 118, 83, 56, -1, 86, 118, 83, 119, + -1, 86, 118, 83, 87, 119, -1, 59, 83, 87, + 120, -1, 57, 83, 115, -1, 119, 83, 57, -1, + 119, 60, 83, 57, -1, 56, -1, 117, -1, 119, + -1, 86, 118, -1, 56, -1, 57, -1, 115, -1, + 56, 83, 119, 83, 113, -1, 56, 83, 87, 119, + 83, 113, -1, 117, 83, 87, 119, 83, 113, -1, + 86, 118, 83, 87, 119, 83, 113, -1, 102, -1, + 102, -1, 116, 60, -1, 116, -1, 70, -1, 69, + -1, 61, -1, 62, -1, 63, -1, 64, -1, 65, + -1, 66, -1, 67, -1, 68, -1, 61, -1, 62, + -1, 63, -1, 64, -1, 65, -1, 66, -1, 67, + -1, 68, -1, 102, -1, 102, -1, 102, -1, 102, + -1, 102, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const unsigned short int yyrline[] = +{ + 0, 126, 126, 131, 132, 135, 145, 148, 153, 159, + 164, 164, 183, 190, 191, 192, 195, 204, 210, 213, + 223, 236, 242, 246, 254, 259, 270, 275, 287, 292, + 306, 309, 312, 315, 318, 321, 324, 327, 330, 333, + 336, 339, 341, 354, 366, 368, 370, 372, 374, 376, + 378, 380, 382, 384, 386, 388, 390, 392, 394, 399, + 401, 403, 405, 407, 409, 411, 413, 415, 417, 419, + 421, 423, 425, 427, 429, 433, 435, 437, 441, 450, + 459, 461, 463, 465, 467, 469, 471, 473, 475, 477, + 479, 481, 483, 485, 487, 491, 493, 495, 497, 500, + 502, 504, 506, 518, 524, 531, 537, 546, 553, 563, + 570, 577, 586, 596, 603, 613, 619, 626, 633, 640, + 648, 655, 661, 668, 675, 683, 699, 706, 725, 732, + 738, 745, 753, 759, 765, 774, 782, 790, 798, 808, + 825, 838, 851, 861, 867, 870, 871, 872, 873, 874, + 875, 876, 877, 880, 881, 882, 885, 888, 891, 894, + 897, 902, 912, 922, 937, 951 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE +/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "STRING", "D_ORG", "D_BYTE", "D_WORD", + "D_SKIP", "D_EQU", "D_FLAG", "D_END", "ACALL", "ADD", "ADDC", "AJMP", + "ANL", "CJNE", "CLR", "CPL", "DA", "DEC", "DIV", "DJNZ", "INC", "JB", + "JBC", "JC", "JMP", "JNB", "JNC", "JNZ", "JZ", "LCALL", "LJMP", "MOV", + "MOVC", "MOVX", "NOP", "MUL", "ORL", "POP", "PUSH", "RET", "RETI", "RL", + "RLC", "RR", "RRC", "SETB", "SJMP", "SUBB", "SWAP", "XCH", "XCHD", "XRL", + "AB", "A", "C", "PC", "DPTR", "BITPOS", "R0", "R1", "R2", "R3", "R4", + "R5", "R6", "R7", "VALUE", "SYMBOL", "'+'", "'-'", "'*'", "'/'", "'%'", + "'|'", "'&'", "'>'", "'<'", "':'", "'\\n'", "'.'", "','", "'('", "')'", + "'@'", "'#'", "'!'", "$accept", "program", "linelist", "line", + "linerest", "@1", "directive", "defexpr", "flag", "flagv", "undefsym", + "blist", "wlist", "expr", "instr", "two_op1", "two_op2", "two_op3", + "two_op4", "two_op5", "two_op6", "single_op1", "single_op2", "three_op1", + "rel", "rel2", "bit", "bitv", "reg", "regi", "data8", "data16", "addr11", + "addr16", "relative", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const unsigned short int yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, + 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, + 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, + 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, + 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, + 325, 43, 45, 42, 47, 37, 124, 38, 62, 60, + 58, 10, 46, 44, 40, 41, 64, 35, 33 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const unsigned char yyr1[] = +{ + 0, 89, 90, 91, 91, 92, 92, 93, 93, 93, + 94, 93, 95, 95, 95, 95, 95, 95, 95, 96, + 97, 98, 98, 99, 100, 100, 100, 100, 101, 101, + 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 102, 102, 102, 103, 103, 103, 103, 103, 103, + 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, + 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, + 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, + 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, + 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, + 103, 103, 103, 104, 104, 104, 104, 105, 105, 106, + 106, 106, 107, 108, 108, 109, 109, 109, 109, 109, + 109, 109, 109, 109, 109, 109, 109, 109, 110, 110, + 110, 110, 111, 111, 111, 112, 112, 112, 112, 113, + 114, 115, 115, 116, 116, 117, 117, 117, 117, 117, + 117, 117, 117, 118, 118, 118, 118, 118, 118, 118, + 118, 119, 120, 121, 122, 123 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const unsigned char yyr2[] = +{ + 0, 2, 1, 2, 1, 3, 1, 2, 2, 1, + 0, 3, 3, 3, 3, 3, 5, 5, 2, 1, + 2, 1, 1, 1, 3, 3, 1, 1, 3, 1, + 1, 3, 2, 3, 3, 3, 3, 3, 3, 3, + 4, 4, 1, 1, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 5, 5, 2, 1, 1, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 7, 7, 7, 7, 5, + 5, 5, 5, 3, 3, 4, 4, 3, 4, 3, + 4, 4, 3, 3, 3, 3, 3, 4, 3, 3, + 4, 4, 4, 5, 4, 3, 3, 4, 1, 1, + 1, 2, 1, 1, 1, 5, 6, 6, 7, 1, + 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const unsigned char yydefact[] = +{ + 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 44, 0, + 0, 0, 0, 67, 68, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 23, 9, 0, 0, + 0, 4, 6, 0, 0, 0, 0, 43, 42, 0, + 30, 0, 163, 45, 0, 47, 48, 46, 0, 161, + 52, 53, 54, 0, 0, 145, 146, 147, 148, 149, + 150, 151, 152, 0, 87, 0, 132, 133, 144, 143, + 75, 134, 142, 76, 62, 128, 0, 61, 129, 130, + 63, 91, 0, 0, 60, 59, 88, 0, 90, 165, + 82, 0, 89, 83, 84, 85, 164, 81, 80, 0, + 0, 0, 92, 93, 94, 0, 0, 0, 0, 0, + 66, 55, 56, 57, 79, 78, 69, 70, 71, 72, + 77, 86, 49, 73, 58, 74, 50, 51, 0, 0, + 0, 0, 0, 0, 18, 1, 3, 7, 0, 8, + 11, 32, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 153, 154, 155, 156, + 157, 158, 159, 160, 0, 0, 141, 131, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 12, 19, 27, 13, 26, 14, 162, + 29, 15, 0, 0, 5, 31, 39, 38, 35, 36, + 37, 33, 34, 0, 0, 0, 0, 103, 104, 0, + 0, 109, 107, 0, 0, 0, 0, 0, 140, 113, + 139, 114, 112, 0, 0, 125, 0, 0, 115, 0, + 116, 0, 126, 0, 118, 119, 0, 0, 0, 0, + 0, 0, 0, 0, 40, 41, 105, 106, 110, 111, + 108, 0, 0, 0, 0, 64, 65, 124, 121, 0, + 122, 117, 127, 120, 0, 0, 0, 100, 99, 102, + 101, 25, 24, 28, 16, 22, 21, 17, 0, 0, + 135, 0, 0, 123, 0, 0, 0, 20, 136, 0, + 137, 97, 95, 98, 96, 138 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const short int yydefgoto[] = +{ + -1, 49, 50, 51, 52, 56, 53, 203, 297, 298, + 54, 206, 208, 69, 55, 65, 71, 72, 106, 101, + 124, 97, 90, 84, 241, 239, 91, 92, 98, 184, + 73, 210, 63, 117, 110 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -239 +static const short int yypact[] = +{ + 370, -239, 139, -24, -24, 139, 120, 70, 15, 15, + -19, 470, -12, 292, 441, 23, 23, 139, -45, 23, + 139, 139, 139, 139, 139, 222, -9, -26, -239, 14, + 120, 139, 139, -239, -239, 19, 25, 31, 49, 15, + 139, -24, 54, -24, -24, 85, -239, -239, 440, 89, + 298, -239, -239, -27, 37, 38, 41, -239, -239, 139, + -239, 139, 513, -239, 64, -239, -239, -239, 67, 513, + -239, -239, -239, 68, 77, -239, -239, -239, -239, -239, + -239, -239, -239, 454, -239, 87, -239, -239, -239, -239, + -239, -239, 83, -239, -239, -239, 454, -239, -239, -239, + -239, -239, 90, 91, -239, -239, -239, 101, -239, 513, + -239, -30, -239, -239, -239, -239, 513, -239, -239, 102, + 108, 454, -239, -239, -239, 111, -50, 115, 124, 485, + -239, -239, -239, -239, -239, -239, -239, -239, -239, -239, + -239, -239, -239, -239, -239, -239, -239, -239, 139, 4, + 139, 139, 140, 143, -239, -239, -239, -239, 442, -239, + -239, 104, 354, 139, 139, 139, 139, 139, 139, 139, + 75, 145, 496, 126, -47, 133, -239, -239, -239, -239, + -239, -239, -239, -239, 135, 132, -239, -239, 139, 139, + 139, 154, 155, 23, 141, 144, -17, 147, 34, 146, + 148, 150, 152, -239, 513, -239, 156, -239, 158, 513, + -239, -239, 159, 160, -239, -239, 520, 520, 104, 104, + 104, 30, 30, 139, 139, 454, 139, -239, -239, 23, + 23, -239, -239, 139, 139, 162, 151, 139, 513, -239, + 513, -239, -239, 172, 190, -239, 139, 55, -239, 139, + -239, 191, -239, 454, -239, -239, 56, 511, 193, 195, + 10, 139, 139, 60, -239, -239, -239, -239, -239, -239, + -239, 164, 139, 139, 170, -239, -239, -239, -239, 139, + -239, -239, -239, -239, 183, 184, 185, -239, -239, -239, + -239, -239, -239, -239, 513, -239, -239, -239, 197, 139, + -239, 175, 139, -239, 86, 205, 206, -239, -239, 139, + -239, -239, -239, -239, -239, -239 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const short int yypgoto[] = +{ + -239, -239, -239, 214, 107, -239, -239, 116, -239, -239, + 114, -239, -239, -2, -239, 21, 33, 238, 26, -239, + -239, 255, 22, -239, -186, -239, -14, -239, -1, -85, + 3, -238, 266, 248, 28 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -3 +static const short int yytable[] = +{ + 62, 107, 107, 62, 242, 107, 85, 205, 277, 232, + 197, 187, 102, 291, 99, 109, 103, 99, 109, 109, + 109, 116, 116, 293, 125, 66, 191, 70, 126, 192, + 128, 93, 64, 198, 134, 135, 195, 94, 109, 248, + 233, 111, 108, 100, 202, 112, 122, 127, 113, 114, + 115, 131, 57, 58, 157, 59, 60, 161, 123, 162, + 129, 140, 142, 132, 144, 145, 146, 61, 141, 130, + 249, 86, 87, 57, 58, 136, 59, 60, 147, 57, + 58, 137, 59, 60, 88, 89, 300, 138, 61, 155, + 232, 252, 88, 89, 61, 75, 76, 77, 78, 79, + 80, 81, 82, 57, 58, 139, 59, 60, 170, 171, + 143, 278, 284, 308, 285, 286, 310, 158, 61, 159, + 253, 233, 160, 315, 57, 58, 74, 59, 60, 295, + 296, 75, 76, 77, 78, 79, 80, 81, 82, 61, + 266, 64, 279, 186, 311, 312, 204, 172, 209, 204, + 173, 174, 207, 223, 57, 58, 83, 59, 60, 231, + 175, 216, 217, 218, 219, 220, 221, 222, 283, 61, + 185, 227, 288, 188, 189, 228, 64, 68, 235, 245, + 168, 169, 170, 171, 190, 193, 238, 240, 240, 57, + 58, 194, 59, 60, 196, 88, 89, 254, 199, 250, + 229, 255, 57, 58, 61, 59, 60, 200, 57, 58, + 46, 59, 60, 213, 230, 268, 269, 61, 236, 237, + 234, 264, 265, 61, 224, 243, 244, 247, 246, 267, + 251, 275, 256, 258, 257, 259, 270, 271, 273, 260, + 274, 261, 262, 263, 209, 272, 276, 299, 282, 289, + 280, 290, 281, 302, 304, 305, 306, 307, 309, 209, + 294, 313, 314, 292, 156, 214, 212, 211, 133, 105, + 240, 67, 118, 0, 0, 0, 301, 0, 64, 119, + 0, 120, 303, 75, 76, 77, 78, 79, 80, 81, + 82, 57, 58, 0, 59, 60, 0, 240, -2, 1, + 240, 0, 0, 0, 0, 0, 61, 240, 121, 2, + 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, + 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, + 43, 44, 45, 75, 76, 77, 78, 79, 80, 81, + 82, 57, 58, 0, 59, 60, 0, 0, 46, 0, + 0, 1, 0, 0, 0, 0, 61, 0, 0, 47, + 48, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 163, 164, 165, 166, 167, + 168, 169, 170, 171, 0, 0, 0, 0, 0, 215, + 46, 0, 0, 1, 148, 149, 150, 151, 152, 153, + 154, 47, 48, 2, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, + 39, 40, 41, 42, 43, 44, 45, 95, 0, 0, + 104, 0, 75, 76, 77, 78, 79, 80, 81, 82, + 57, 58, 0, 59, 60, 176, 177, 178, 179, 180, + 181, 182, 183, 47, 48, 61, 95, 96, 0, 0, + 0, 75, 76, 77, 78, 79, 80, 81, 82, 57, + 58, 0, 59, 60, 201, 0, 176, 177, 178, 179, + 180, 181, 182, 183, 61, 0, 96, 75, 76, 77, + 78, 79, 80, 81, 82, 57, 58, 0, 59, 60, + 287, 0, 176, 177, 178, 179, 180, 181, 182, 183, + 61, 0, 225, 226, 163, 164, 165, 166, 167, 168, + 169, 170, 171, 165, 166, 167, 168, 169, 170, 171 +}; + +static const short int yycheck[] = +{ + 2, 15, 16, 5, 190, 19, 7, 3, 246, 56, + 60, 96, 13, 3, 11, 17, 13, 14, 20, 21, + 22, 23, 24, 261, 25, 4, 56, 6, 25, 59, + 56, 9, 56, 83, 31, 32, 121, 56, 40, 56, + 87, 86, 16, 55, 129, 19, 25, 56, 20, 21, + 22, 30, 69, 70, 81, 72, 73, 59, 25, 61, + 86, 39, 41, 30, 43, 44, 45, 84, 40, 55, + 87, 56, 57, 69, 70, 56, 72, 73, 45, 69, + 70, 56, 72, 73, 69, 70, 272, 56, 84, 0, + 56, 57, 69, 70, 84, 61, 62, 63, 64, 65, + 66, 67, 68, 69, 70, 56, 72, 73, 78, 79, + 56, 56, 56, 299, 58, 59, 302, 80, 84, 81, + 86, 87, 81, 309, 69, 70, 56, 72, 73, 69, + 70, 61, 62, 63, 64, 65, 66, 67, 68, 84, + 225, 56, 87, 60, 58, 59, 148, 83, 150, 151, + 83, 83, 149, 78, 69, 70, 86, 72, 73, 173, + 83, 163, 164, 165, 166, 167, 168, 169, 253, 84, + 83, 172, 257, 83, 83, 172, 56, 57, 175, 193, + 76, 77, 78, 79, 83, 83, 188, 189, 190, 69, + 70, 83, 72, 73, 83, 69, 70, 198, 83, 196, + 74, 198, 69, 70, 84, 72, 73, 83, 69, 70, + 70, 72, 73, 70, 88, 229, 230, 84, 83, 87, + 87, 223, 224, 84, 79, 71, 71, 83, 87, 226, + 83, 59, 86, 83, 86, 83, 233, 234, 87, 83, + 237, 83, 83, 83, 246, 83, 56, 83, 57, 56, + 247, 56, 249, 83, 71, 71, 71, 60, 83, 261, + 262, 56, 56, 260, 50, 158, 152, 151, 30, 14, + 272, 5, 24, -1, -1, -1, 273, -1, 56, 57, + -1, 59, 279, 61, 62, 63, 64, 65, 66, 67, + 68, 69, 70, -1, 72, 73, -1, 299, 0, 1, + 302, -1, -1, -1, -1, -1, 84, 309, 86, 11, + 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, + 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, + 52, 53, 54, 61, 62, 63, 64, 65, 66, 67, + 68, 69, 70, -1, 72, 73, -1, -1, 70, -1, + -1, 1, -1, -1, -1, -1, 84, -1, -1, 81, + 82, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 71, 72, 73, 74, 75, + 76, 77, 78, 79, -1, -1, -1, -1, -1, 85, + 70, -1, -1, 1, 4, 5, 6, 7, 8, 9, + 10, 81, 82, 11, 12, 13, 14, 15, 16, 17, + 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, + 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 56, -1, -1, + 59, -1, 61, 62, 63, 64, 65, 66, 67, 68, + 69, 70, -1, 72, 73, 61, 62, 63, 64, 65, + 66, 67, 68, 81, 82, 84, 56, 86, -1, -1, + -1, 61, 62, 63, 64, 65, 66, 67, 68, 69, + 70, -1, 72, 73, 59, -1, 61, 62, 63, 64, + 65, 66, 67, 68, 84, -1, 86, 61, 62, 63, + 64, 65, 66, 67, 68, 69, 70, -1, 72, 73, + 59, -1, 61, 62, 63, 64, 65, 66, 67, 68, + 84, -1, 86, 87, 71, 72, 73, 74, 75, 76, + 77, 78, 79, 73, 74, 75, 76, 77, 78, 79 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const unsigned char yystos[] = +{ + 0, 1, 11, 12, 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, + 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 70, 81, 82, 90, + 91, 92, 93, 95, 99, 103, 94, 69, 70, 72, + 73, 84, 102, 121, 56, 104, 104, 121, 57, 102, + 104, 105, 106, 119, 56, 61, 62, 63, 64, 65, + 66, 67, 68, 86, 112, 117, 56, 57, 69, 70, + 111, 115, 116, 111, 56, 56, 86, 110, 117, 119, + 55, 108, 117, 119, 59, 110, 107, 115, 107, 102, + 123, 86, 107, 123, 123, 123, 102, 122, 122, 57, + 59, 86, 104, 105, 109, 117, 119, 56, 56, 86, + 55, 104, 105, 106, 119, 119, 56, 56, 56, 56, + 111, 123, 104, 56, 104, 104, 104, 105, 4, 5, + 6, 7, 8, 9, 10, 0, 92, 81, 80, 81, + 81, 102, 102, 71, 72, 73, 74, 75, 76, 77, + 78, 79, 83, 83, 83, 83, 61, 62, 63, 64, + 65, 66, 67, 68, 118, 83, 60, 118, 83, 83, + 83, 56, 59, 83, 83, 118, 83, 60, 83, 83, + 83, 59, 118, 96, 102, 3, 100, 119, 101, 102, + 120, 96, 99, 70, 93, 85, 102, 102, 102, 102, + 102, 102, 102, 78, 79, 86, 87, 117, 119, 74, + 88, 115, 56, 87, 87, 119, 83, 87, 102, 114, + 102, 113, 113, 71, 71, 115, 87, 83, 56, 87, + 119, 83, 57, 86, 117, 119, 86, 86, 83, 83, + 83, 83, 83, 83, 102, 102, 118, 119, 115, 115, + 119, 119, 83, 87, 119, 59, 56, 120, 56, 87, + 119, 119, 57, 118, 56, 58, 59, 59, 118, 56, + 56, 3, 119, 120, 102, 69, 70, 97, 98, 83, + 113, 119, 83, 119, 71, 71, 71, 60, 113, 83, + 113, 58, 59, 56, 56, 113 +}; + +#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) +# define YYSIZE_T __SIZE_TYPE__ +#endif +#if ! defined (YYSIZE_T) && defined (size_t) +# define YYSIZE_T size_t +#endif +#if ! defined (YYSIZE_T) +# if defined (__STDC__) || defined (__cplusplus) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# endif +#endif +#if ! defined (YYSIZE_T) +# define YYSIZE_T unsigned int +#endif + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror ("syntax error: cannot back up");\ + YYERROR; \ + } \ +while (0) + +#define YYTERROR 1 +#define YYERRCODE 256 + +/* YYLLOC_DEFAULT -- Compute the default location (before the actions + are run). */ + +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + ((Current).first_line = (Rhs)[1].first_line, \ + (Current).first_column = (Rhs)[1].first_column, \ + (Current).last_line = (Rhs)[N].last_line, \ + (Current).last_column = (Rhs)[N].last_column) +#endif + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (YYLEX_PARAM) +#else +# define YYLEX yylex () +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (0) + +# define YYDSYMPRINT(Args) \ +do { \ + if (yydebug) \ + yysymprint Args; \ +} while (0) + +# define YYDSYMPRINTF(Title, Token, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yysymprint (stderr, \ + Token, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (0) + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yy_stack_print (short int *bottom, short int *top) +#else +static void +yy_stack_print (bottom, top) + short int *bottom; + short int *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (/* Nothing. */; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (0) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yy_reduce_print (int yyrule) +#else +static void +yy_reduce_print (yyrule) + int yyrule; +#endif +{ + int yyi; + unsigned int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", + yyrule - 1, yylno); + /* Print the symbols being reduced, and their result. */ + for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) + YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); + YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]); +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (Rule); \ +} while (0) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YYDSYMPRINT(Args) +# define YYDSYMPRINTF(Title, Token, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#if defined (YYMAXDEPTH) && YYMAXDEPTH == 0 +# undef YYMAXDEPTH +#endif + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined (__GLIBC__) && defined (_STRING_H) +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +static YYSIZE_T +# if defined (__STDC__) || defined (__cplusplus) +yystrlen (const char *yystr) +# else +yystrlen (yystr) + const char *yystr; +# endif +{ + register const char *yys = yystr; + + while (*yys++ != '\0') + continue; + + return yys - yystr - 1; +} +# endif +# endif + +# ifndef yystpcpy +# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +static char * +# if defined (__STDC__) || defined (__cplusplus) +yystpcpy (char *yydest, const char *yysrc) +# else +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +# endif +{ + register char *yyd = yydest; + register const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +#endif /* !YYERROR_VERBOSE */ + + + +#if YYDEBUG +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) +#else +static void +yysymprint (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE *yyvaluep; +#endif +{ + /* Pacify ``unused variable'' warnings. */ + (void) yyvaluep; + + if (yytype < YYNTOKENS) + { + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); +# ifdef YYPRINT + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# endif + } + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + switch (yytype) + { + default: + break; + } + YYFPRINTF (yyoutput, ")"); +} + +#endif /* ! YYDEBUG */ +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yydestruct (int yytype, YYSTYPE *yyvaluep) +#else +static void +yydestruct (yytype, yyvaluep) + int yytype; + YYSTYPE *yyvaluep; +#endif +{ + /* Pacify ``unused variable'' warnings. */ + (void) yyvaluep; + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +# if defined (__STDC__) || defined (__cplusplus) +int yyparse (void *YYPARSE_PARAM); +# else +int yyparse (); +# endif +#else /* ! YYPARSE_PARAM */ +#if defined (__STDC__) || defined (__cplusplus) +int yyparse (void); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + +/* The lookahead symbol. */ +int yychar; + +/* The semantic value of the lookahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +# if defined (__STDC__) || defined (__cplusplus) +int yyparse (void *YYPARSE_PARAM) +# else +int yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +# endif +#else /* ! YYPARSE_PARAM */ +#if defined (__STDC__) || defined (__cplusplus) +int +yyparse (void) +#else +int +yyparse () + +#endif +#endif +{ + + register int yystate; + register int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Lookahead token as an internal (translated) token number. */ + int yytoken = 0; + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + short int yyssa[YYINITDEPTH]; + short int *yyss = yyssa; + register short int *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + register YYSTYPE *yyvsp; + + + +#define YYPOPSTACK (yyvsp--, yyssp--) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* When reducing, the number of symbols on the RHS of the reduced + rule. */ + int yylen; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. so pushing a state here evens the stacks. + */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + short int *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow ("parser stack overflow", + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyoverflowlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyoverflowlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + short int *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyoverflowlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + +/* Do appropriate processing given the current state. */ +/* Read a lookahead token if we need one and don't already have one. */ +/* yyresume: */ + + /* First try to decide what to do without reference to lookahead token. */ + + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Shift the lookahead token. */ + YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken])); + + /* Discard the token being shifted unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + *++yyvsp = yylval; + + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + yystate = yyn; + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 2: +#line 127 "parser.y" + { +} + break; + + case 5: +#line 136 "parser.y" + { + if (abort_asap) {YYABORT;} + if( pass1 ) { + yyvsp[-2].sym->type = LABEL; + yyvsp[-2].sym->value = lc; + } + inclc(yyvsp[0].value); + bytecount = 0; +} + break; + + case 6: +#line 145 "parser.y" + { inclc(yyvsp[0].value); bytecount = 0; } + break; + + case 7: +#line 148 "parser.y" + { + yyval.value = yyvsp[-1].value; + if( dashl && pass2 ) + dumplist(yyvsp[0].str,1); + } + break; + + case 8: +#line 153 "parser.y" + { + yyval.value = yyvsp[-1].value; + if( dashl && pass2 ) + dumplist(yyvsp[0].str,1); + + } + break; + + case 9: +#line 159 "parser.y" + { + yyval.value = 0; + if( dashl && pass2 ) + dumplist(yyvsp[0].str,0); + } + break; + + case 10: +#line 164 "parser.y" + { + seek_eol(); + } + break; + + case 11: +#line 167 "parser.y" + { + yyval.value = 0; + if( dashl && pass2 ) + dumplist(yyvsp[-2].str,0); + } + break; + + case 12: +#line 184 "parser.y" + { + lc = yyvsp[0].val.v; + if( pass2 ) emitaddr(lc); + bytecount = 0; + yyval.value = 0; +} + break; + + case 13: +#line 190 "parser.y" + { yyval.value = yyvsp[0].value; } + break; + + case 14: +#line 191 "parser.y" + { yyval.value = yyvsp[0].value; } + break; + + case 15: +#line 192 "parser.y" + { yyval.value = yyvsp[0].val.v; + if( pass2 ) + emitaddr(lc+yyval.value); } + break; + + case 16: +#line 196 "parser.y" + { + if( yyvsp[0].val.d == 0 ) + warn("Expression is undefined in pass 1"); + yyvsp[-2].sym->type = LABEL; + yyvsp[-2].sym->value = yyvsp[0].val.v; + yyval.value = 0; +} + break; + + case 17: +#line 205 "parser.y" + { + yyvsp[-2].sym->type = LABEL; + yyvsp[-2].sym->value = yyvsp[0].value; + yyval.value = 0; +} + break; + + case 18: +#line 210 "parser.y" + { yyval.value = 0; } + break; + + case 19: +#line 214 "parser.y" + { + if( yyvsp[0].val.d == 0 ) + warn("Expression is undefined in pass 1"); + if( !(isbit16(yyvsp[0].val.v)) ) + warn("Value greater than 16-bits"); + yyval.value = yyvsp[0].val.v; +} + break; + + case 20: +#line 224 "parser.y" + { + if( !isbit8(yyvsp[-1].value) ) + warn("Bit address exceeds 8-bits"); + if( isbmram(yyvsp[-1].value) ) + yyval.value = (yyvsp[-1].value-0x20)*8+ yyvsp[0].value; + else if( isbmsfr(yyvsp[-1].value) ) + yyval.value = yyvsp[-1].value + yyvsp[0].value; + else + warn("Invalid bit addressable RAM location"); +} + break; + + case 21: +#line 237 "parser.y" + { + if( yyvsp[0].sym->type == UNDEF ) + warn("Symbol %s must be defined in pass 1",yyvsp[0].sym->name); + yyval.value = yyvsp[0].sym->value; +} + break; + + case 22: +#line 242 "parser.y" + { yyval.value = yyvsp[0].value; } + break; + + case 23: +#line 247 "parser.y" + { + if( yyvsp[0].sym->type != UNDEF && pass1) + warn("Attempt to redefine symbol: %s",yyvsp[0].sym->name); + yyval.sym = yyvsp[0].sym; +} + break; + + case 24: +#line 255 "parser.y" + { + if( pass2 ) genbyte(yyvsp[0].value); + yyval.value = yyvsp[-2].value + 1; +} + break; + + case 25: +#line 260 "parser.y" + { + if( pass1 ) + yyval.value = yyvsp[-2].value + yyvsp[0].value; + else { + yyval.value = yyvsp[-2].value + strlen(yyvsp[0].str); + genstr(yyvsp[0].str); + + free(yyvsp[0].str); + } +} + break; + + case 26: +#line 271 "parser.y" + { + if( pass2 ) genbyte(yyvsp[0].value); + yyval.value = 1; +} + break; + + case 27: +#line 276 "parser.y" + { + if( pass1 ) + yyval.value = yyvsp[0].value; + else { + yyval.value = strlen(yyvsp[0].str); + genstr(yyvsp[0].str); + free(yyvsp[0].str); + } +} + break; + + case 28: +#line 288 "parser.y" + { + if( pass2 ) genword(yyvsp[0].value); + yyval.value = yyvsp[-2].value + 2; +} + break; + + case 29: +#line 293 "parser.y" + { + if( pass2 ) genword(yyvsp[0].value); + yyval.value = 2; +} + break; + + case 30: +#line 306 "parser.y" + { yyval.val.v = lc; + yyval.val.d = 1; } + break; + + case 31: +#line 309 "parser.y" + { yyval.val.v = yyvsp[-1].val.v; + yyval.val.d = yyvsp[-1].val.d; } + break; + + case 32: +#line 312 "parser.y" + { yyval.val.v = -yyvsp[0].val.v; + yyval.val.d = yyvsp[0].val.d; } + break; + + case 33: +#line 315 "parser.y" + { yyval.val.v = yyvsp[-2].val.v | yyvsp[0].val.v; + yyval.val.d = yyvsp[-2].val.d && yyvsp[0].val.d; } + break; + + case 34: +#line 318 "parser.y" + { yyval.val.v = yyvsp[-2].val.v & yyvsp[0].val.v; + yyval.val.d = yyvsp[-2].val.d && yyvsp[0].val.d; } + break; + + case 35: +#line 321 "parser.y" + { yyval.val.v = yyvsp[-2].val.v * yyvsp[0].val.v; + yyval.val.d = yyvsp[-2].val.d && yyvsp[0].val.d; } + break; + + case 36: +#line 324 "parser.y" + { yyval.val.v = yyvsp[-2].val.v / yyvsp[0].val.v; + yyval.val.d = yyvsp[-2].val.d && yyvsp[0].val.d; } + break; + + case 37: +#line 327 "parser.y" + { yyval.val.v = yyvsp[-2].val.v % yyvsp[0].val.v; + yyval.val.d = yyvsp[-2].val.d && yyvsp[0].val.d; } + break; + + case 38: +#line 330 "parser.y" + { yyval.val.v = yyvsp[-2].val.v - yyvsp[0].val.v; + yyval.val.d = yyvsp[-2].val.d && yyvsp[0].val.d; } + break; + + case 39: +#line 333 "parser.y" + { yyval.val.v = yyvsp[-2].val.v + yyvsp[0].val.v; + yyval.val.d = yyvsp[-2].val.d && yyvsp[0].val.d; } + break; + + case 40: +#line 336 "parser.y" + { yyval.val.v = yyvsp[-3].val.v >> yyvsp[0].val.v; + yyval.val.d = yyvsp[-3].val.d && yyvsp[0].val.d; } + break; + + case 41: +#line 339 "parser.y" + { yyval.val.v = yyvsp[-3].val.v << yyvsp[0].val.v; + yyval.val.d = yyvsp[-3].val.d && yyvsp[0].val.d; } + break; + + case 42: +#line 342 "parser.y" + { + if( pass1 ) { + yyval.val.v = yyvsp[0].sym->value; + yyval.val.d = (yyvsp[0].sym->type != UNDEF); + } + else { + if( yyvsp[0].sym->type == UNDEF ) + warn("Undefined symbol %s",yyvsp[0].sym->name); + yyval.val.v = yyvsp[0].sym->value; + yyval.val.d = 1; + } +} + break; + + case 43: +#line 354 "parser.y" + { yyval.val.v = yyvsp[0].val.v; yyval.val.d=1; } + break; + + case 44: +#line 367 "parser.y" + { yyval.value = makeop(yyvsp[0].op,NULL,0); } + break; + + case 45: +#line 369 "parser.y" + { yyval.value = makeop(yyvsp[-1].op,&yyvsp[0].mode,0); } + break; + + case 46: +#line 371 "parser.y" + { yyval.value = makeop(yyvsp[-1].op,&yyvsp[0].mode,0); } + break; + + case 47: +#line 373 "parser.y" + { yyval.value = makeop(yyvsp[-1].op,&yyvsp[0].mode,0); } + break; + + case 48: +#line 375 "parser.y" + { yyval.value = makeop(yyvsp[-1].op,&yyvsp[0].mode,0); } + break; + + case 49: +#line 377 "parser.y" + { yyval.value = makeop(yyvsp[-1].op,&yyvsp[0].mode,0); } + break; + + case 50: +#line 379 "parser.y" + { yyval.value = makeop(yyvsp[-1].op,&yyvsp[0].mode,0); } + break; + + case 51: +#line 381 "parser.y" + { yyval.value = makeop(yyvsp[-1].op,&yyvsp[0].mode,4); } + break; + + case 52: +#line 383 "parser.y" + { yyval.value = makeop(yyvsp[-1].op,&yyvsp[0].mode,0); } + break; + + case 53: +#line 385 "parser.y" + { yyval.value = makeop(yyvsp[-1].op,&yyvsp[0].mode,4); } + break; + + case 54: +#line 387 "parser.y" + { yyval.value = makeop(yyvsp[-1].op,&yyvsp[0].mode,6); } + break; + + case 55: +#line 389 "parser.y" + { yyval.value = makeop(yyvsp[-1].op,&yyvsp[0].mode,0); } + break; + + case 56: +#line 391 "parser.y" + { yyval.value = makeop(yyvsp[-1].op,&yyvsp[0].mode,4); } + break; + + case 57: +#line 393 "parser.y" + { yyval.value = makeop(yyvsp[-1].op,&yyvsp[0].mode,6); } + break; + + case 58: +#line 395 "parser.y" + { if( get_md(yyvsp[0].mode) == 3 ) + warn("Immediate mode is illegal"); + yyval.value = makeop(yyvsp[-1].op,&yyvsp[0].mode,0); + } + break; + + case 59: +#line 400 "parser.y" + { yyval.value = makeop(yyvsp[-1].op,&yyvsp[0].mode,0); } + break; + + case 60: +#line 402 "parser.y" + { yyval.value = makeop(yyvsp[-1].op,NULL,4); } + break; + + case 61: +#line 404 "parser.y" + { yyval.value = makeop(yyvsp[-1].op,&yyvsp[0].mode,0); } + break; + + case 62: +#line 406 "parser.y" + { yyval.value = makeop(yyvsp[-1].op,NULL,0); } + break; + + case 63: +#line 408 "parser.y" + { yyval.value = makeop(yyvsp[-1].op,NULL,0); } + break; + + case 64: +#line 410 "parser.y" + { yyval.value = makeop(yyvsp[-4].op,NULL,0); } + break; + + case 65: +#line 412 "parser.y" + { yyval.value = makeop(yyvsp[-4].op,NULL,0); } + break; + + case 66: +#line 414 "parser.y" + { yyval.value = makeop(yyvsp[-1].op,NULL,0); } + break; + + case 67: +#line 416 "parser.y" + { yyval.value = makeop(yyvsp[0].op,NULL,0); } + break; + + case 68: +#line 418 "parser.y" + { yyval.value = makeop(yyvsp[0].op,NULL,0); } + break; + + case 69: +#line 420 "parser.y" + { yyval.value = makeop(yyvsp[-1].op,NULL,0); } + break; + + case 70: +#line 422 "parser.y" + { yyval.value = makeop(yyvsp[-1].op,NULL,0); } + break; + + case 71: +#line 424 "parser.y" + { yyval.value = makeop(yyvsp[-1].op,NULL,0); } + break; + + case 72: +#line 426 "parser.y" + { yyval.value = makeop(yyvsp[-1].op,NULL,0); } + break; + + case 73: +#line 428 "parser.y" + { yyval.value = makeop(yyvsp[-1].op,NULL,0); } + break; + + case 74: +#line 430 "parser.y" + { if( get_md(yyvsp[0].mode) != 2 ) + warn("Invalid addressing mode"); + yyval.value = makeop(yyvsp[-1].op,&yyvsp[0].mode,-2); } + break; + + case 75: +#line 434 "parser.y" + { yyval.value = makeop(yyvsp[-1].op,&yyvsp[0].mode,0); } + break; + + case 76: +#line 436 "parser.y" + { yyval.value = makeop(yyvsp[-1].op,&yyvsp[0].mode,0); } + break; + + case 77: +#line 438 "parser.y" + { if( get_md(yyvsp[0].mode) == 0 ) + warn("Invalid addressing mode"); + yyval.value = makeop(yyvsp[-1].op,&yyvsp[0].mode,-1); } + break; + + case 78: +#line 442 "parser.y" + { + struct mode tmp; + set_md(tmp,0); + set_ov(tmp,0); + set_sz(tmp,1); + set_b1(tmp,yyvsp[0].value); + yyval.value = makeop(yyvsp[-1].op,&tmp,0); + } + break; + + case 79: +#line 451 "parser.y" + { + struct mode tmp; + set_md(tmp,0); + set_ov(tmp,0); + set_sz(tmp,1); + set_b1(tmp,yyvsp[0].value); + yyval.value = makeop(yyvsp[-1].op,&tmp,0); + } + break; + + case 80: +#line 460 "parser.y" + { yyval.value = makeop(yyvsp[-1].op,&yyvsp[0].mode,0); } + break; + + case 81: +#line 462 "parser.y" + { yyval.value = makeop(yyvsp[-1].op,&yyvsp[0].mode,0); } + break; + + case 82: +#line 464 "parser.y" + { yyval.value = makeop(yyvsp[-1].op,&yyvsp[0].mode,0); } + break; + + case 83: +#line 466 "parser.y" + { yyval.value = makeop(yyvsp[-1].op,&yyvsp[0].mode,0); } + break; + + case 84: +#line 468 "parser.y" + { yyval.value = makeop(yyvsp[-1].op,&yyvsp[0].mode,0); } + break; + + case 85: +#line 470 "parser.y" + { yyval.value = makeop(yyvsp[-1].op,&yyvsp[0].mode,0); } + break; + + case 86: +#line 472 "parser.y" + { yyval.value = makeop(yyvsp[-1].op,&yyvsp[0].mode,0); } + break; + + case 87: +#line 474 "parser.y" + { yyval.value = makeop(yyvsp[-1].op,&yyvsp[0].mode,0); } + break; + + case 88: +#line 476 "parser.y" + { yyval.value = makeop(yyvsp[-1].op,&yyvsp[0].mode,0); } + break; + + case 89: +#line 478 "parser.y" + { yyval.value = makeop(yyvsp[-1].op,&yyvsp[0].mode,0); } + break; + + case 90: +#line 480 "parser.y" + { yyval.value = makeop(yyvsp[-1].op,&yyvsp[0].mode,0); } + break; + + case 91: +#line 482 "parser.y" + { yyval.value = makeop(yyvsp[-1].op,&yyvsp[0].mode,0); } + break; + + case 92: +#line 484 "parser.y" + { yyval.value = makeop(yyvsp[-1].op,&yyvsp[0].mode,0); } + break; + + case 93: +#line 486 "parser.y" + { yyval.value = makeop(yyvsp[-1].op,&yyvsp[0].mode,4); } + break; + + case 94: +#line 488 "parser.y" + { yyval.value = makeop(yyvsp[-1].op,&yyvsp[0].mode,6); } + break; + + case 95: +#line 492 "parser.y" + { yyval.value = makeop(yyvsp[-6].op,NULL,0); } + break; + + case 96: +#line 494 "parser.y" + { yyval.value = makeop(yyvsp[-6].op,NULL,0); } + break; + + case 97: +#line 496 "parser.y" + { yyval.value = makeop(yyvsp[-6].op,NULL,1); } + break; + + case 98: +#line 498 "parser.y" + { yyval.value = makeop(yyvsp[-6].op,NULL,1); } + break; + + case 99: +#line 501 "parser.y" + { yyval.value = makeop(yyvsp[-4].op,NULL,yyvsp[0].value); } + break; + + case 100: +#line 503 "parser.y" + { yyval.value = makeop(yyvsp[-4].op,NULL,2); } + break; + + case 101: +#line 505 "parser.y" + { yyval.value = makeop(yyvsp[-4].op,NULL,yyvsp[-2].value+3); } + break; + + case 102: +#line 507 "parser.y" + { yyval.value = makeop(yyvsp[-4].op,NULL,5); } + break; + + case 103: +#line 519 "parser.y" + { + set_md(yyval.mode,0); + set_ov(yyval.mode, yyvsp[0].value); + set_sz(yyval.mode, 0); + } + break; + + case 104: +#line 525 "parser.y" + { + set_md(yyval.mode,1); + set_ov(yyval.mode,0); + set_sz(yyval.mode,1); + set_b1(yyval.mode,yyvsp[0].value); + } + break; + + case 105: +#line 532 "parser.y" + { + set_md(yyval.mode,2); + set_ov(yyval.mode,yyvsp[0].value); + set_sz(yyval.mode,0); + } + break; + + case 106: +#line 538 "parser.y" + { + set_md(yyval.mode,3); + set_ov(yyval.mode,0); + set_sz(yyval.mode,1); + set_b1(yyval.mode,yyvsp[0].value); + } + break; + + case 107: +#line 547 "parser.y" + { + set_md(yyval.mode,0); + set_ov(yyval.mode,0); + set_sz(yyval.mode,1); + set_b1(yyval.mode,yyvsp[-2].value); + } + break; + + case 108: +#line 554 "parser.y" + { + set_md(yyval.mode,1); + set_ov(yyval.mode,0); + set_sz(yyval.mode,2); + set_b1(yyval.mode,yyvsp[-3].value); + set_b2(yyval.mode,yyvsp[0].value); + } + break; + + case 109: +#line 564 "parser.y" + { + set_md(yyval.mode,0); + set_ov(yyval.mode,0); + set_sz(yyval.mode,1); + set_b1(yyval.mode,yyvsp[0].value); + } + break; + + case 110: +#line 571 "parser.y" + { + set_md(yyval.mode,1); + set_ov(yyval.mode,0); + set_sz(yyval.mode,1); + set_b1(yyval.mode,yyvsp[0].value); + } + break; + + case 111: +#line 578 "parser.y" + { + set_md(yyval.mode,1); + set_ov(yyval.mode,0); + set_sz(yyval.mode,1); + set_b1(yyval.mode,yyvsp[0].value); + } + break; + + case 112: +#line 587 "parser.y" + { + set_md(yyval.mode,0); + set_ov(yyval.mode,0); + set_sz(yyval.mode,2); + set_b1(yyval.mode,yyvsp[-2].value); + set_b2(yyval.mode,yyvsp[0].value); + } + break; + + case 113: +#line 597 "parser.y" + { + set_md(yyval.mode,0); + set_ov(yyval.mode,yyvsp[-2].value); + set_sz(yyval.mode,1); + set_b1(yyval.mode,yyvsp[0].value); + } + break; + + case 114: +#line 604 "parser.y" + { + set_md(yyval.mode,1); + set_ov(yyval.mode,0); + set_sz(yyval.mode,2); + set_b1(yyval.mode,yyvsp[-2].value); + set_b2(yyval.mode,yyvsp[0].value); + } + break; + + case 115: +#line 614 "parser.y" + { + set_md(yyval.mode,0); + set_ov(yyval.mode,yyvsp[-2].value); + set_sz(yyval.mode,0); + } + break; + + case 116: +#line 620 "parser.y" + { + set_md(yyval.mode,1); + set_ov(yyval.mode,yyvsp[-2].value); + set_sz(yyval.mode,1); + set_b1(yyval.mode,yyvsp[0].value); + } + break; + + case 117: +#line 627 "parser.y" + { + set_md(yyval.mode,2); + set_ov(yyval.mode,yyvsp[-3].value); + set_sz(yyval.mode,1); + set_b1(yyval.mode,yyvsp[0].value); + } + break; + + case 118: +#line 634 "parser.y" + { + set_md(yyval.mode,3); + set_ov(yyval.mode,yyvsp[0].value); + set_sz(yyval.mode,1); + set_b1(yyval.mode,yyvsp[-2].value); + } + break; + + case 119: +#line 641 "parser.y" + { + set_md(yyval.mode,4); + set_ov(yyval.mode,0); + set_sz(yyval.mode,2); + set_b1(yyval.mode,yyvsp[0].value); + set_b2(yyval.mode,yyvsp[-2].value); + } + break; + + case 120: +#line 649 "parser.y" + { + set_md(yyval.mode,5); + set_ov(yyval.mode,yyvsp[0].value); + set_sz(yyval.mode,1); + set_b1(yyval.mode,yyvsp[-3].value); + } + break; + + case 121: +#line 656 "parser.y" + { + set_md(yyval.mode,6); + set_ov(yyval.mode,yyvsp[-2].value); + set_sz(yyval.mode,0); + } + break; + + case 122: +#line 662 "parser.y" + { + set_md(yyval.mode,7); + set_ov(yyval.mode,yyvsp[-2].value); + set_sz(yyval.mode,1); + set_b1(yyval.mode,yyvsp[0].value); + } + break; + + case 123: +#line 669 "parser.y" + { + set_md(yyval.mode,8); + set_ov(yyval.mode,yyvsp[-3].value); + set_sz(yyval.mode,1); + set_b1(yyval.mode,yyvsp[0].value); + } + break; + + case 124: +#line 676 "parser.y" + { + set_md(yyval.mode,9); + set_ov(yyval.mode,0); + set_sz(yyval.mode,2); + set_b1(yyval.mode, (yyvsp[0].value & 0xff00) >> 8 ); + set_b2(yyval.mode, (yyvsp[0].value & 0x00ff) ); + } + break; + + case 125: +#line 684 "parser.y" + { + set_md(yyval.mode,10); + set_ov(yyval.mode,0); + set_sz(yyval.mode,1); + set_b1(yyval.mode,yyvsp[0].value); + } + break; + + case 126: +#line 700 "parser.y" + { + set_md(yyval.mode,11); + set_ov(yyval.mode,0); + set_sz(yyval.mode,1); + set_b1(yyval.mode,yyvsp[-2].value); + } + break; + + case 127: +#line 707 "parser.y" + { + if( pass2 ) { + if( !isbit8(yyvsp[-3].value) ) + warn("Bit address exceeds 8-bits"); + if( isbmram(yyvsp[-3].value) ) + set_b1(yyval.mode, (yyvsp[-3].value-0x20)*8+ yyvsp[-2].value ); + else if( isbmsfr(yyvsp[-3].value) ) + set_b1(yyval.mode, yyvsp[-3].value + yyvsp[-2].value ); + else + warn("Invalid bit addressable RAM location"); + } + set_md(yyval.mode,11); + set_ov(yyval.mode,0); + set_sz(yyval.mode,1); +} + break; + + case 128: +#line 726 "parser.y" + { + set_md(yyval.mode,0); + set_ov(yyval.mode,0); + set_sz(yyval.mode,0); + } + break; + + case 129: +#line 733 "parser.y" + { + set_md(yyval.mode,1); + set_ov(yyval.mode,yyvsp[0].value); + set_sz(yyval.mode,0); + } + break; + + case 130: +#line 739 "parser.y" + { + set_md(yyval.mode,2); + set_ov(yyval.mode,0); + set_sz(yyval.mode,1); + set_b1(yyval.mode,yyvsp[0].value); + } + break; + + case 131: +#line 746 "parser.y" + { + set_md(yyval.mode,3); + set_ov(yyval.mode,yyvsp[0].value); + set_sz(yyval.mode,0); + } + break; + + case 132: +#line 754 "parser.y" + { + set_md(yyval.mode,0); + set_ov(yyval.mode,0); + set_sz(yyval.mode,0); + } + break; + + case 133: +#line 760 "parser.y" + { + set_md(yyval.mode,1); + set_ov(yyval.mode,0); + set_sz(yyval.mode,0); + } + break; + + case 134: +#line 766 "parser.y" + { + set_md(yyval.mode,2); + set_ov(yyval.mode,0); + set_sz(yyval.mode,1); + set_b1(yyval.mode,yyvsp[0].value); + } + break; + + case 135: +#line 775 "parser.y" + { + set_md(yyval.mode,0); + set_ov(yyval.mode,0); + set_sz(yyval.mode,2); + set_b1(yyval.mode,yyvsp[-2].value); + set_b2(yyval.mode,yyvsp[0].value); + } + break; + + case 136: +#line 783 "parser.y" + { + set_md(yyval.mode,1); + set_ov(yyval.mode,0); + set_sz(yyval.mode,2); + set_b1(yyval.mode,yyvsp[-2].value); + set_b2(yyval.mode,yyvsp[0].value); + } + break; + + case 137: +#line 791 "parser.y" + { + set_md(yyval.mode,2); + set_ov(yyval.mode,yyvsp[-5].value); + set_sz(yyval.mode,2); + set_b1(yyval.mode,yyvsp[-2].value); + set_b2(yyval.mode,yyvsp[0].value); + } + break; + + case 138: +#line 799 "parser.y" + { + set_md(yyval.mode,3); + set_ov(yyval.mode,yyvsp[-5].value); + set_sz(yyval.mode,2); + set_b1(yyval.mode,yyvsp[-2].value); + set_b2(yyval.mode,yyvsp[0].value); + } + break; + + case 139: +#line 809 "parser.y" + { + long offset; + if( pass2 ) { + offset = yyvsp[0].val.v - (lc+3); + if( offset > 127 || offset < -128 ) + warn("Relative offset exceeds -128 / +127"); + yyval.value = offset; + } +} + break; + + case 140: +#line 826 "parser.y" + { + long offset; + if( pass2 ) { + offset = yyvsp[0].val.v - (lc+2); /* different! */ + if( offset > 127 || offset < -128 ) + warn("Relative offset exceeds -128 / +127"); + yyval.value = offset; + } +} + break; + + case 141: +#line 839 "parser.y" + { + if( pass2 ) { + if( !isbit8(yyvsp[-1].value) ) + warn("Bit address exceeds 8-bits"); + if( isbmram(yyvsp[-1].value) ) + yyval.value = (yyvsp[-1].value-0x20)*8+yyvsp[0].value; + else if( isbmsfr(yyvsp[-1].value) ) + yyval.value = yyvsp[-1].value + yyvsp[0].value; + else + warn("Invalid bit addressable RAM location"); + } +} + break; + + case 142: +#line 852 "parser.y" + { + if( pass2 ) { + if( !isbit8(yyvsp[0].value) ) + warn("Bit address exceeds 8-bits"); + yyval.value = yyvsp[0].value; + } +} + break; + + case 143: +#line 862 "parser.y" + { + if( yyvsp[0].sym->type == UNDEF && pass2 ) + warn("Symbol %s undefined",yyvsp[0].sym->name); + yyval.value = yyvsp[0].sym->value; +} + break; + + case 144: +#line 867 "parser.y" + { yyval.value = yyvsp[0].value; } + break; + + case 145: +#line 870 "parser.y" + { yyval.value = 0; } + break; + + case 146: +#line 871 "parser.y" + { yyval.value = 1; } + break; + + case 147: +#line 872 "parser.y" + { yyval.value = 2; } + break; + + case 148: +#line 873 "parser.y" + { yyval.value = 3; } + break; + + case 149: +#line 874 "parser.y" + { yyval.value = 4; } + break; + + case 150: +#line 875 "parser.y" + { yyval.value = 5; } + break; + + case 151: +#line 876 "parser.y" + { yyval.value = 6; } + break; + + case 152: +#line 877 "parser.y" + { yyval.value = 7; } + break; + + case 153: +#line 880 "parser.y" + { yyval.value = 0; } + break; + + case 154: +#line 881 "parser.y" + { yyval.value = 1; } + break; + + case 155: +#line 883 "parser.y" + { yyval.value = 0; + warn("Illegal indirect register: @r2"); } + break; + + case 156: +#line 886 "parser.y" + { yyval.value = 0; + warn("Illegal indirect register: @r3"); } + break; + + case 157: +#line 889 "parser.y" + { yyval.value = 0; + warn("Illegal indirect register: @r4"); } + break; + + case 158: +#line 892 "parser.y" + { yyval.value = 0; + warn("Illegal indirect register: @r5"); } + break; + + case 159: +#line 895 "parser.y" + { yyval.value = 0; + warn("Illegal indirect register: @r6"); } + break; + + case 160: +#line 898 "parser.y" + { yyval.value = 0; + warn("Illegal indirect register: @r7"); } + break; + + case 161: +#line 903 "parser.y" + { + if( pass2 ) { + if( !isbit8(yyvsp[0].val.v) ) + warn("Expression greater than 8-bits"); + } + yyval.value = yyvsp[0].val.v; +} + break; + + case 162: +#line 913 "parser.y" + { + if( pass2 ) { + if( !isbit16(yyvsp[0].val.v) ) + warn("Expression greater than 16-bits"); + } + yyval.value = yyvsp[0].val.v; +} + break; + + case 163: +#line 923 "parser.y" + { + if( pass2 ) { + if( !isbit16(yyvsp[0].val.v) ) + warn("Address greater than 16-bits"); + if( (yyvsp[0].val.v & size11) != ((lc+2) & size11) ) + warn("Address outside current 2K page"); + } + set_md(yyval.mode,0); + set_ov(yyval.mode, (yyvsp[0].val.v&0x0700)>>3 ); + set_sz(yyval.mode,1); + set_b1(yyval.mode,yyvsp[0].val.v&0x00ff); +} + break; + + case 164: +#line 938 "parser.y" + { + if( pass2 ) { + if( !isbit16(yyvsp[0].val.v) ) + warn("Address greater than 16-bits"); + } + set_md(yyval.mode,0); + set_ov(yyval.mode, 0 ); + set_sz(yyval.mode,2); + set_b1(yyval.mode, (yyvsp[0].val.v & 0xff00 ) >> 8 ); + set_b2(yyval.mode, (yyvsp[0].val.v & 0x00ff ) ); +} + break; + + case 165: +#line 952 "parser.y" + { + long offset=0; + if( pass2 ) { + offset = yyvsp[0].val.v - (lc+2); + if( offset>127 || offset<-128 ) + warn("Relative offset exceeds -128 / +127"); + } + set_md(yyval.mode,0); + set_ov(yyval.mode,0); + set_sz(yyval.mode,1); + set_b1(yyval.mode,offset); + +} + break; + + + } + +/* Line 1010 of yacc.c. */ +#line 2717 "y.tab.c" + + yyvsp -= yylen; + yyssp -= yylen; + + + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if YYERROR_VERBOSE + yyn = yypact[yystate]; + + if (YYPACT_NINF < yyn && yyn < YYLAST) + { + YYSIZE_T yysize = 0; + int yytype = YYTRANSLATE (yychar); + const char* yyprefix; + char *yymsg; + int yyx; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 0; + + yyprefix = ", expecting "; + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]); + yycount += 1; + if (yycount == 5) + { + yysize = 0; + break; + } + } + yysize += (sizeof ("syntax error, unexpected ") + + yystrlen (yytname[yytype])); + yymsg = (char *) YYSTACK_ALLOC (yysize); + if (yymsg != 0) + { + char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); + yyp = yystpcpy (yyp, yytname[yytype]); + + if (yycount < 5) + { + yyprefix = ", expecting "; + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + yyp = yystpcpy (yyp, yyprefix); + yyp = yystpcpy (yyp, yytname[yyx]); + yyprefix = " or "; + } + } + yyerror (yymsg); + YYSTACK_FREE (yymsg); + } + else + yyerror ("syntax error; also virtual memory exhausted"); + } + else +#endif /* YYERROR_VERBOSE */ + yyerror ("syntax error"); + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* If at end of input, pop the error token, + then the rest of the stack, then return failure. */ + if (yychar == YYEOF) + for (;;) + { + YYPOPSTACK; + if (yyssp == yyss) + YYABORT; + YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); + yydestruct (yystos[*yyssp], yyvsp); + } + } + else + { + YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc); + yydestruct (yytoken, &yylval); + yychar = YYEMPTY; + + } + } + + /* Else will try to reuse lookahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + +#ifdef __GNUC__ + /* Pacify GCC when the user code never invokes YYERROR and the label + yyerrorlab therefore never appears in user code. */ + if (0) + goto yyerrorlab; +#endif + + yyvsp -= yylen; + yyssp -= yylen; + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); + yydestruct (yystos[yystate], yyvsp); + YYPOPSTACK; + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + YYDPRINTF ((stderr, "Shifting error token, ")); + + *++yyvsp = yylval; + + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*----------------------------------------------. +| yyoverflowlab -- parser overflow comes here. | +`----------------------------------------------*/ +yyoverflowlab: + yyerror ("parser stack overflow"); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif + return yyresult; +} + + +#line 967 "parser.y" + + +/* ---------------------------------------------------------------------- */ + +void yyerror(const char *s) +{ + warn("%s near \"%s\"", s, get_last_token()); +} + + +/* ---------------------------------------------------------------------- + * makeop: + * This function makes an opcode based on the instruction symbol table + * entry, and an addressing mode structure. + * This function is called from both passes, but + * only generates code in pass 2. + * + * Resultant opcode bytes are passed to genbyte(). + * + * Returns the nuumber of bytes that the instruction + * occupies. + * + */ + +int makeop(struct opcode * op, struct mode *m, int add) +{ + register unsigned int newop; + + if( m == NULL ) { + if(pass2) genbyte(op->bytes[0+add]); + return(1); + } + + if( pass2 ) { + newop = op->bytes[ get_md(*m)+add ] | get_ov(*m); + genbyte(newop); + if( get_sz(*m) > 0 ) genbyte( get_b1(*m) ); + if( get_sz(*m) > 1 ) genbyte( get_b2(*m) ); + } + return( get_sz(*m)+1 ); +} + + +/* ---------------------------------------------------------------------- + * inclc: + * Increments the Location Counter by 'i' amount. + * Check to see if 'i' overflows 64K. + * Checks to see if assembler is overlapping previous sections + * of code. (using a large bit field). + * + */ + +#define indx(a) ( (a)/(sizeof(long)*8) ) +#define bit(a) ( 1 << ((a)%(sizeof(long)*8)) ) + +#define getloc(a) (regions[indx(a)] & bit(a)) +#define setloc(a) (regions[indx(a)] |= bit(a)) + +static unsigned long regions[ 0x10000/(sizeof(long)*8) ]; + +void inclc(int i) +{ + + while (i-- > 0) { + if( pass2 && getloc(lc) ) + error("Location counter overlaps"); + if( pass2 ) setloc(lc); + lc += 1; + } + + if( lc > 0xffff ) + error("Location counter has exceeded 16-bits"); +} + +void clear_location_counter(void) +{ + memset(regions, 0, sizeof(regions)); +} + + +/* ---------------------------------------------------------------------- + * padline: + * This routine returns a new string, which is equivilant to + * 'line' except that all tabs have been expanded to spaces, and + * the total length has been truncated to 60 chars. + */ + +char *padline(char *line) +{ + static char newline[61]; + char *p1; + int pos=0,nxtpos; + + for(p1=line; pos= 4 ) { + j = 0; + fprintf(listing,"\n "); + } + } + while(++j <= 4) + fprintf(listing," "); + + fprintf(listing," %s\n",padline(txt)); +} + +/* ---------------------------------------------------------------------- + * gen* routines: + * Place information into the bytebuf[] array, and also + * call emitbyte with the byte. + * + */ + +void genbyte(int b) +{ + if( bytecount < sizeof(bytebuf) ) + bytebuf[bytecount++] = b; + emitbyte(b); +} + +void genstr(const char *s) +{ + while( *s ) + genbyte(*s++); +} + +void genword(unsigned long w) +{ + genbyte( (w & 0xff00) >> 8 ); + genbyte( (w & 0x00ff) ); +} + + + diff --git a/as31/parser.h b/as31/parser.h new file mode 100644 index 0000000..3c9bbff --- /dev/null +++ b/as31/parser.h @@ -0,0 +1,184 @@ +/* A Bison parser, made by GNU Bison 1.875d. */ + +/* Skeleton parser for Yacc-like parsing with Bison, + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. + + This program 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, or (at your option) + any later version. + + This program 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 this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + STRING = 258, + D_ORG = 259, + D_BYTE = 260, + D_WORD = 261, + D_SKIP = 262, + D_EQU = 263, + D_FLAG = 264, + D_END = 265, + ACALL = 266, + ADD = 267, + ADDC = 268, + AJMP = 269, + ANL = 270, + CJNE = 271, + CLR = 272, + CPL = 273, + DA = 274, + DEC = 275, + DIV = 276, + DJNZ = 277, + INC = 278, + JB = 279, + JBC = 280, + JC = 281, + JMP = 282, + JNB = 283, + JNC = 284, + JNZ = 285, + JZ = 286, + LCALL = 287, + LJMP = 288, + MOV = 289, + MOVC = 290, + MOVX = 291, + NOP = 292, + MUL = 293, + ORL = 294, + POP = 295, + PUSH = 296, + RET = 297, + RETI = 298, + RL = 299, + RLC = 300, + RR = 301, + RRC = 302, + SETB = 303, + SJMP = 304, + SUBB = 305, + SWAP = 306, + XCH = 307, + XCHD = 308, + XRL = 309, + AB = 310, + A = 311, + C = 312, + PC = 313, + DPTR = 314, + BITPOS = 315, + R0 = 316, + R1 = 317, + R2 = 318, + R3 = 319, + R4 = 320, + R5 = 321, + R6 = 322, + R7 = 323, + VALUE = 324, + SYMBOL = 325 + }; +#endif +#define STRING 258 +#define D_ORG 259 +#define D_BYTE 260 +#define D_WORD 261 +#define D_SKIP 262 +#define D_EQU 263 +#define D_FLAG 264 +#define D_END 265 +#define ACALL 266 +#define ADD 267 +#define ADDC 268 +#define AJMP 269 +#define ANL 270 +#define CJNE 271 +#define CLR 272 +#define CPL 273 +#define DA 274 +#define DEC 275 +#define DIV 276 +#define DJNZ 277 +#define INC 278 +#define JB 279 +#define JBC 280 +#define JC 281 +#define JMP 282 +#define JNB 283 +#define JNC 284 +#define JNZ 285 +#define JZ 286 +#define LCALL 287 +#define LJMP 288 +#define MOV 289 +#define MOVC 290 +#define MOVX 291 +#define NOP 292 +#define MUL 293 +#define ORL 294 +#define POP 295 +#define PUSH 296 +#define RET 297 +#define RETI 298 +#define RL 299 +#define RLC 300 +#define RR 301 +#define RRC 302 +#define SETB 303 +#define SJMP 304 +#define SUBB 305 +#define SWAP 306 +#define XCH 307 +#define XCHD 308 +#define XRL 309 +#define AB 310 +#define A 311 +#define C 312 +#define PC 313 +#define DPTR 314 +#define BITPOS 315 +#define R0 316 +#define R1 317 +#define R2 318 +#define R3 319 +#define R4 320 +#define R5 321 +#define R6 322 +#define R7 323 +#define VALUE 324 +#define SYMBOL 325 + + + + +#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) +typedef int YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + +extern YYSTYPE yylval; + + + diff --git a/as31/parser.y b/as31/parser.y new file mode 100644 index 0000000..e1ecb5b --- /dev/null +++ b/as31/parser.y @@ -0,0 +1,1127 @@ +/* ---------------------------------------------------------------------- + * FILE: parser.y + * PACKAGE: as31 - 8031/8051 Assembler. + * + * DESCRIPTION: + * This file contains the yacc parser for the assembler. + * Related to this are the following: + * error(), warn(), yyerror() + * genbyte(), genword(), genstr(), makeop() + * + * + * REVISION HISTORY: + * Jan. 19, 1990 - Created. (Ken Stauffer) + * + * AUTHOR: + * All code in this file written by Ken Stauffer (University of Calgary). + * January 1990. + * + */ + +%{ + +#include +#include + +#define NOPE +#include "as31.h" +#undef NOPE + +#define YYSTYPE union ystack + +static unsigned char bytebuf[1024]; /* used by dumplist() */ +static int bytecount; + + +void yyerror(const char *s); +int makeop(struct opcode * op, struct mode *m, int add); +void inclc(int i); +char *padline(char *line); +void dumplist(char *txt, int show); +void genbyte(int b); +void genstr(const char *s); +void genword(unsigned long w); + +/* ------------------------ G R A M M E R ----------------------------- */ + +%} + +%token STRING +%token D_ORG +%token D_BYTE +%token D_WORD +%token D_SKIP +%token D_EQU +%token D_FLAG +%token D_END +%token ACALL +%token ADD +%token ADDC +%token AJMP +%token ANL +%token CJNE +%token CLR +%token CPL +%token DA +%token DEC +%token DIV +%token DJNZ +%token INC +%token JB +%token JBC +%token JC +%token JMP +%token JNB +%token JNC +%token JNZ +%token JZ +%token LCALL +%token LJMP +%token MOV +%token MOVC +%token MOVX +%token NOP +%token MUL +%token ORL +%token POP +%token PUSH +%token RET +%token RETI +%token RL +%token RLC +%token RR +%token RRC +%token SETB +%token SJMP +%token SUBB +%token SWAP +%token XCH +%token XCHD +%token XRL +%token AB +%token A +%token C +%token PC +%token DPTR +%token BITPOS +%token R0 +%token R1 +%token R2 +%token R3 +%token R4 +%token R5 +%token R6 +%token R7 +%token VALUE +%token SYMBOL + +%left '+' '-' +%left '*' '/' '%' +%left '|' '&' +%left '>' '<' + +%start program + +%% +program : linelist +{ +} + ; + +linelist : linelist line + | line + ; + +line : undefsym ':' linerest +{ + if (abort_asap) {YYABORT;} + if( pass1 ) { + $1.sym->type = LABEL; + $1.sym->value = lc; + } + inclc($3.value); + bytecount = 0; +} + | linerest { inclc($1.value); bytecount = 0; } + ; + +linerest : directive '\n' { + $$.value = $1.value; + if( dashl && pass2 ) + dumplist($2.str,1); + } + | instr '\n' { + $$.value = $1.value; + if( dashl && pass2 ) + dumplist($2.str,1); + + } + | '\n' { + $$.value = 0; + if( dashl && pass2 ) + dumplist($1.str,0); + } + | error { + seek_eol(); + } + '\n' { + $$.value = 0; + if( dashl && pass2 ) + dumplist($1.str,0); + } + ; + + + + + +/* -------------------- + * DIRECTIVES: + * + */ + +directive : '.' D_ORG defexpr +{ + lc = $3.val.v; + if( pass2 ) emitaddr(lc); + bytecount = 0; + $$.value = 0; +} + | '.' D_BYTE blist { $$.value = $3.value; } + | '.' D_WORD wlist { $$.value = $3.value; } + | '.' D_SKIP defexpr { $$.value = $3.val.v; + if( pass2 ) + emitaddr(lc+$$.value); } + | '.' D_EQU undefsym ',' expr +{ + if( $5.val.d == 0 ) + warn("Expression is undefined in pass 1"); + $3.sym->type = LABEL; + $3.sym->value = $5.val.v; + $$.value = 0; +} + + | '.' D_FLAG SYMBOL ',' flag +{ + $3.sym->type = LABEL; + $3.sym->value = $5.value; + $$.value = 0; +} + | '.' D_END { $$.value = 0; } + ; + +defexpr : expr +{ + if( $1.val.d == 0 ) + warn("Expression is undefined in pass 1"); + if( !(isbit16($1.val.v)) ) + warn("Value greater than 16-bits"); + $$.value = $1.val.v; +} + ; + +flag : flagv BITPOS +{ + if( !isbit8($1.value) ) + warn("Bit address exceeds 8-bits"); + if( isbmram($1.value) ) + $$.value = ($1.value-0x20)*8+ $2.value; + else if( isbmsfr($1.value) ) + $$.value = $1.value + $2.value; + else + warn("Invalid bit addressable RAM location"); +} + ; + +flagv : SYMBOL +{ + if( $1.sym->type == UNDEF ) + warn("Symbol %s must be defined in pass 1",$1.sym->name); + $$.value = $1.sym->value; +} + | VALUE { $$.value = $1.value; } + ; + + +undefsym : SYMBOL +{ + if( $1.sym->type != UNDEF && pass1) + warn("Attempt to redefine symbol: %s",$1.sym->name); + $$.sym = $1.sym; +} + ; + +blist : blist ',' data8 +{ + if( pass2 ) genbyte($3.value); + $$.value = $1.value + 1; +} + | blist ',' STRING +{ + if( pass1 ) + $$.value = $1.value + $3.value; + else { + $$.value = $1.value + strlen($3.str); + genstr($3.str); + + free($3.str); + } +} + | data8 +{ + if( pass2 ) genbyte($1.value); + $$.value = 1; +} + | STRING +{ + if( pass1 ) + $$.value = $1.value; + else { + $$.value = strlen($1.str); + genstr($1.str); + free($1.str); + } +} + ; + +wlist : wlist ',' data16 +{ + if( pass2 ) genword($3.value); + $$.value = $1.value + 2; +} + | data16 +{ + if( pass2 ) genword($1.value); + $$.value = 2; +} + ; + + + +/* -------------------- + * EXPRESSIONS: + * + */ + +expr : '*' { $$.val.v = lc; + $$.val.d = 1; } + + | '(' expr ')' { $$.val.v = $2.val.v; + $$.val.d = $2.val.d; } + + | '-' expr %prec '*' { $$.val.v = -$2.val.v; + $$.val.d = $2.val.d; } + + | expr '|' expr { $$.val.v = $1.val.v | $3.val.v; + $$.val.d = $1.val.d && $3.val.d; } + + | expr '&' expr { $$.val.v = $1.val.v & $3.val.v; + $$.val.d = $1.val.d && $3.val.d; } + + | expr '*' expr { $$.val.v = $1.val.v * $3.val.v; + $$.val.d = $1.val.d && $3.val.d; } + + | expr '/' expr { $$.val.v = $1.val.v / $3.val.v; + $$.val.d = $1.val.d && $3.val.d; } + + | expr '%' expr { $$.val.v = $1.val.v % $3.val.v; + $$.val.d = $1.val.d && $3.val.d; } + + | expr '-' expr { $$.val.v = $1.val.v - $3.val.v; + $$.val.d = $1.val.d && $3.val.d; } + + | expr '+' expr { $$.val.v = $1.val.v + $3.val.v; + $$.val.d = $1.val.d && $3.val.d; } + + | expr '>' '>' expr { $$.val.v = $1.val.v >> $4.val.v; + $$.val.d = $1.val.d && $4.val.d; } + + | expr '<' '<' expr { $$.val.v = $1.val.v << $4.val.v; + $$.val.d = $1.val.d && $4.val.d; } + | SYMBOL +{ + if( pass1 ) { + $$.val.v = $1.sym->value; + $$.val.d = ($1.sym->type != UNDEF); + } + else { + if( $1.sym->type == UNDEF ) + warn("Undefined symbol %s",$1.sym->name); + $$.val.v = $1.sym->value; + $$.val.d = 1; + } +} + | VALUE { $$.val.v = $1.val.v; $$.val.d=1; } + ; + + + + + +/* -------------------- + * INSTRUCTIONS: + * + */ + +instr : NOP + { $$.value = makeop($1.op,NULL,0); } + | ACALL addr11 + { $$.value = makeop($1.op,&$2.mode,0); } + | AJMP addr11 + { $$.value = makeop($1.op,&$2.mode,0); } + | ADD two_op1 + { $$.value = makeop($1.op,&$2.mode,0); } + | ADDC two_op1 + { $$.value = makeop($1.op,&$2.mode,0); } + | SUBB two_op1 + { $$.value = makeop($1.op,&$2.mode,0); } + | XRL two_op1 + { $$.value = makeop($1.op,&$2.mode,0); } + | XRL two_op2 + { $$.value = makeop($1.op,&$2.mode,4); } + | ANL two_op1 + { $$.value = makeop($1.op,&$2.mode,0); } + | ANL two_op2 + { $$.value = makeop($1.op,&$2.mode,4); } + | ANL two_op3 + { $$.value = makeop($1.op,&$2.mode,6); } + | ORL two_op1 + { $$.value = makeop($1.op,&$2.mode,0); } + | ORL two_op2 + { $$.value = makeop($1.op,&$2.mode,4); } + | ORL two_op3 + { $$.value = makeop($1.op,&$2.mode,6); } + | XCH two_op1 + { if( get_md($2.mode) == 3 ) + warn("Immediate mode is illegal"); + $$.value = makeop($1.op,&$2.mode,0); + } + | INC single_op1 + { $$.value = makeop($1.op,&$2.mode,0); } + | INC DPTR + { $$.value = makeop($1.op,NULL,4); } + | DEC single_op1 + { $$.value = makeop($1.op,&$2.mode,0); } + | DA A + { $$.value = makeop($1.op,NULL,0); } + | DIV AB + { $$.value = makeop($1.op,NULL,0); } + | JMP '@' A '+' DPTR + { $$.value = makeop($1.op,NULL,0); } + | JMP '@' DPTR '+' A + { $$.value = makeop($1.op,NULL,0); } + | MUL AB + { $$.value = makeop($1.op,NULL,0); } + | RET + { $$.value = makeop($1.op,NULL,0); } + | RETI + { $$.value = makeop($1.op,NULL,0); } + | RL A + { $$.value = makeop($1.op,NULL,0); } + | RLC A + { $$.value = makeop($1.op,NULL,0); } + | RR A + { $$.value = makeop($1.op,NULL,0); } + | RRC A + { $$.value = makeop($1.op,NULL,0); } + | SWAP A + { $$.value = makeop($1.op,NULL,0); } + | XCHD two_op1 + { if( get_md($2.mode) != 2 ) + warn("Invalid addressing mode"); + $$.value = makeop($1.op,&$2.mode,-2); } + | CLR single_op2 + { $$.value = makeop($1.op,&$2.mode,0); } + | CPL single_op2 + { $$.value = makeop($1.op,&$2.mode,0); } + | SETB single_op2 + { if( get_md($2.mode) == 0 ) + warn("Invalid addressing mode"); + $$.value = makeop($1.op,&$2.mode,-1); } + | PUSH data8 + { + struct mode tmp; + set_md(tmp,0); + set_ov(tmp,0); + set_sz(tmp,1); + set_b1(tmp,$2.value); + $$.value = makeop($1.op,&tmp,0); + } + | POP data8 + { + struct mode tmp; + set_md(tmp,0); + set_ov(tmp,0); + set_sz(tmp,1); + set_b1(tmp,$2.value); + $$.value = makeop($1.op,&tmp,0); + } + | LJMP addr16 + { $$.value = makeop($1.op,&$2.mode,0); } + | LCALL addr16 + { $$.value = makeop($1.op,&$2.mode,0); } + | JC relative + { $$.value = makeop($1.op,&$2.mode,0); } + | JNC relative + { $$.value = makeop($1.op,&$2.mode,0); } + | JNZ relative + { $$.value = makeop($1.op,&$2.mode,0); } + | JZ relative + { $$.value = makeop($1.op,&$2.mode,0); } + | SJMP relative + { $$.value = makeop($1.op,&$2.mode,0); } + | CJNE three_op1 + { $$.value = makeop($1.op,&$2.mode,0); } + | JB two_op4 + { $$.value = makeop($1.op,&$2.mode,0); } + | JNB two_op4 + { $$.value = makeop($1.op,&$2.mode,0); } + | JBC two_op4 + { $$.value = makeop($1.op,&$2.mode,0); } + | DJNZ two_op5 + { $$.value = makeop($1.op,&$2.mode,0); } + | MOV two_op1 + { $$.value = makeop($1.op,&$2.mode,0); } + | MOV two_op2 + { $$.value = makeop($1.op,&$2.mode,4); } + | MOV two_op6 + { $$.value = makeop($1.op,&$2.mode,6); } + + + | MOVC A ',' '@' A '+' DPTR + { $$.value = makeop($1.op,NULL,0); } + | MOVC A ',' '@' DPTR '+' A + { $$.value = makeop($1.op,NULL,0); } + | MOVC A ',' '@' A '+' PC + { $$.value = makeop($1.op,NULL,1); } + | MOVC A ',' '@' PC '+' A + { $$.value = makeop($1.op,NULL,1); } + + | MOVX A ',' '@' regi + { $$.value = makeop($1.op,NULL,$5.value); } + | MOVX A ',' '@' DPTR + { $$.value = makeop($1.op,NULL,2); } + | MOVX '@' regi ',' A + { $$.value = makeop($1.op,NULL,$3.value+3); } + | MOVX '@' DPTR ',' A + { $$.value = makeop($1.op,NULL,5); } + ; + + + + +/* -------------------- + * ADDRESSING MODES: + * + */ + +two_op1 : A ',' reg + { + set_md($$.mode,0); + set_ov($$.mode, $3.value); + set_sz($$.mode, 0); + } + | A ',' data8 + { + set_md($$.mode,1); + set_ov($$.mode,0); + set_sz($$.mode,1); + set_b1($$.mode,$3.value); + } + | A ',' '@' regi + { + set_md($$.mode,2); + set_ov($$.mode,$4.value); + set_sz($$.mode,0); + } + | A ',' '#' data8 + { + set_md($$.mode,3); + set_ov($$.mode,0); + set_sz($$.mode,1); + set_b1($$.mode,$4.value); + } + ; + +two_op2 : data8 ',' A + { + set_md($$.mode,0); + set_ov($$.mode,0); + set_sz($$.mode,1); + set_b1($$.mode,$1.value); + } + | data8 ',' '#' data8 + { + set_md($$.mode,1); + set_ov($$.mode,0); + set_sz($$.mode,2); + set_b1($$.mode,$1.value); + set_b2($$.mode,$4.value); + } + ; + +two_op3 : C ',' bit + { + set_md($$.mode,0); + set_ov($$.mode,0); + set_sz($$.mode,1); + set_b1($$.mode,$3.value); + } + | C ',' '/' bit + { + set_md($$.mode,1); + set_ov($$.mode,0); + set_sz($$.mode,1); + set_b1($$.mode,$4.value); + } + | C ',' '!' bit + { + set_md($$.mode,1); + set_ov($$.mode,0); + set_sz($$.mode,1); + set_b1($$.mode,$4.value); + } + ; + +two_op4 : bit ',' rel + { + set_md($$.mode,0); + set_ov($$.mode,0); + set_sz($$.mode,2); + set_b1($$.mode,$1.value); + set_b2($$.mode,$3.value); + } + ; + +two_op5 : reg ',' rel2 + { + set_md($$.mode,0); + set_ov($$.mode,$1.value); + set_sz($$.mode,1); + set_b1($$.mode,$3.value); + } + | data8 ',' rel + { + set_md($$.mode,1); + set_ov($$.mode,0); + set_sz($$.mode,2); + set_b1($$.mode,$1.value); + set_b2($$.mode,$3.value); + } + ; + +two_op6 : reg ',' A + { + set_md($$.mode,0); + set_ov($$.mode,$1.value); + set_sz($$.mode,0); + } + | reg ',' data8 + { + set_md($$.mode,1); + set_ov($$.mode,$1.value); + set_sz($$.mode,1); + set_b1($$.mode,$3.value); + } + | reg ',' '#' data8 + { + set_md($$.mode,2); + set_ov($$.mode,$1.value); + set_sz($$.mode,1); + set_b1($$.mode,$4.value); + } + | data8 ',' reg + { + set_md($$.mode,3); + set_ov($$.mode,$3.value); + set_sz($$.mode,1); + set_b1($$.mode,$1.value); + } + | data8 ',' data8 + { + set_md($$.mode,4); + set_ov($$.mode,0); + set_sz($$.mode,2); + set_b1($$.mode,$3.value); + set_b2($$.mode,$1.value); + } + | data8 ',' '@' regi + { + set_md($$.mode,5); + set_ov($$.mode,$4.value); + set_sz($$.mode,1); + set_b1($$.mode,$1.value); + } + | '@' regi ',' A + { + set_md($$.mode,6); + set_ov($$.mode,$2.value); + set_sz($$.mode,0); + } + | '@' regi ',' data8 + { + set_md($$.mode,7); + set_ov($$.mode,$2.value); + set_sz($$.mode,1); + set_b1($$.mode,$4.value); + } + | '@' regi ',' '#' data8 + { + set_md($$.mode,8); + set_ov($$.mode,$2.value); + set_sz($$.mode,1); + set_b1($$.mode,$5.value); + } + | DPTR ',' '#' data16 + { + set_md($$.mode,9); + set_ov($$.mode,0); + set_sz($$.mode,2); + set_b1($$.mode, ($4.value & 0xff00) >> 8 ); + set_b2($$.mode, ($4.value & 0x00ff) ); + } + | C ',' bit + { + set_md($$.mode,10); + set_ov($$.mode,0); + set_sz($$.mode,1); + set_b1($$.mode,$3.value); + } + /* + * Following two productions cannot be represented by: + * + * bit ',' C + * + * Because yacc gives tons of reduce/reduce errors if + * that is attempted. + * + */ + | data8 ',' C + { + set_md($$.mode,11); + set_ov($$.mode,0); + set_sz($$.mode,1); + set_b1($$.mode,$1.value); + } + | data8 BITPOS ',' C +{ + if( pass2 ) { + if( !isbit8($1.value) ) + warn("Bit address exceeds 8-bits"); + if( isbmram($1.value) ) + set_b1($$.mode, ($1.value-0x20)*8+ $2.value ); + else if( isbmsfr($1.value) ) + set_b1($$.mode, $1.value + $2.value ); + else + warn("Invalid bit addressable RAM location"); + } + set_md($$.mode,11); + set_ov($$.mode,0); + set_sz($$.mode,1); +} + ; + + +single_op1 : A + { + set_md($$.mode,0); + set_ov($$.mode,0); + set_sz($$.mode,0); + } + + | reg + { + set_md($$.mode,1); + set_ov($$.mode,$1.value); + set_sz($$.mode,0); + } + | data8 + { + set_md($$.mode,2); + set_ov($$.mode,0); + set_sz($$.mode,1); + set_b1($$.mode,$1.value); + } + | '@' regi + { + set_md($$.mode,3); + set_ov($$.mode,$2.value); + set_sz($$.mode,0); + } + ; + +single_op2 : A + { + set_md($$.mode,0); + set_ov($$.mode,0); + set_sz($$.mode,0); + } + | C + { + set_md($$.mode,1); + set_ov($$.mode,0); + set_sz($$.mode,0); + } + | bit + { + set_md($$.mode,2); + set_ov($$.mode,0); + set_sz($$.mode,1); + set_b1($$.mode,$1.value); + } + ; + +three_op1 : A ',' data8 ',' rel + { + set_md($$.mode,0); + set_ov($$.mode,0); + set_sz($$.mode,2); + set_b1($$.mode,$3.value); + set_b2($$.mode,$5.value); + } + | A ',' '#' data8 ',' rel + { + set_md($$.mode,1); + set_ov($$.mode,0); + set_sz($$.mode,2); + set_b1($$.mode,$4.value); + set_b2($$.mode,$6.value); + } + | reg ',' '#' data8 ',' rel + { + set_md($$.mode,2); + set_ov($$.mode,$1.value); + set_sz($$.mode,2); + set_b1($$.mode,$4.value); + set_b2($$.mode,$6.value); + } + | '@' regi ',' '#' data8 ',' rel + { + set_md($$.mode,3); + set_ov($$.mode,$2.value); + set_sz($$.mode,2); + set_b1($$.mode,$5.value); + set_b2($$.mode,$7.value); + } + ; + +rel : expr +{ + long offset; + if( pass2 ) { + offset = $1.val.v - (lc+3); + if( offset > 127 || offset < -128 ) + warn("Relative offset exceeds -128 / +127"); + $$.value = offset; + } +} + ; + +/* + * This production differs from the above, by 1 number! + * + */ + +rel2 : expr +{ + long offset; + if( pass2 ) { + offset = $1.val.v - (lc+2); /* different! */ + if( offset > 127 || offset < -128 ) + warn("Relative offset exceeds -128 / +127"); + $$.value = offset; + } +} + ; + + +bit : bitv BITPOS +{ + if( pass2 ) { + if( !isbit8($1.value) ) + warn("Bit address exceeds 8-bits"); + if( isbmram($1.value) ) + $$.value = ($1.value-0x20)*8+$2.value; + else if( isbmsfr($1.value) ) + $$.value = $1.value + $2.value; + else + warn("Invalid bit addressable RAM location"); + } +} + | bitv +{ + if( pass2 ) { + if( !isbit8($1.value) ) + warn("Bit address exceeds 8-bits"); + $$.value = $1.value; + } +} + ; + +bitv : SYMBOL +{ + if( $1.sym->type == UNDEF && pass2 ) + warn("Symbol %s undefined",$1.sym->name); + $$.value = $1.sym->value; +} + | VALUE { $$.value = $1.value; } + ; + +reg : R0 { $$.value = 0; } + | R1 { $$.value = 1; } + | R2 { $$.value = 2; } + | R3 { $$.value = 3; } + | R4 { $$.value = 4; } + | R5 { $$.value = 5; } + | R6 { $$.value = 6; } + | R7 { $$.value = 7; } + ; + +regi : R0 { $$.value = 0; } + | R1 { $$.value = 1; } + | R2 + { $$.value = 0; + warn("Illegal indirect register: @r2"); } + | R3 + { $$.value = 0; + warn("Illegal indirect register: @r3"); } + | R4 + { $$.value = 0; + warn("Illegal indirect register: @r4"); } + | R5 + { $$.value = 0; + warn("Illegal indirect register: @r5"); } + | R6 + { $$.value = 0; + warn("Illegal indirect register: @r6"); } + | R7 + { $$.value = 0; + warn("Illegal indirect register: @r7"); } + ; + +data8 : expr +{ + if( pass2 ) { + if( !isbit8($1.val.v) ) + warn("Expression greater than 8-bits"); + } + $$.value = $1.val.v; +} + ; + +data16 : expr +{ + if( pass2 ) { + if( !isbit16($1.val.v) ) + warn("Expression greater than 16-bits"); + } + $$.value = $1.val.v; +} + ; + +addr11 : expr +{ + if( pass2 ) { + if( !isbit16($1.val.v) ) + warn("Address greater than 16-bits"); + if( ($1.val.v & size11) != ((lc+2) & size11) ) + warn("Address outside current 2K page"); + } + set_md($$.mode,0); + set_ov($$.mode, ($1.val.v&0x0700)>>3 ); + set_sz($$.mode,1); + set_b1($$.mode,$1.val.v&0x00ff); +} + ; + +addr16 : expr +{ + if( pass2 ) { + if( !isbit16($1.val.v) ) + warn("Address greater than 16-bits"); + } + set_md($$.mode,0); + set_ov($$.mode, 0 ); + set_sz($$.mode,2); + set_b1($$.mode, ($1.val.v & 0xff00 ) >> 8 ); + set_b2($$.mode, ($1.val.v & 0x00ff ) ); +} + ; + +relative : expr +{ + long offset=0; + if( pass2 ) { + offset = $1.val.v - (lc+2); + if( offset>127 || offset<-128 ) + warn("Relative offset exceeds -128 / +127"); + } + set_md($$.mode,0); + set_ov($$.mode,0); + set_sz($$.mode,1); + set_b1($$.mode,offset); + +} + ; + +%% + +/* ---------------------------------------------------------------------- */ + +void yyerror(const char *s) +{ + warn("%s near \"%s\"", s, get_last_token()); +} + + +/* ---------------------------------------------------------------------- + * makeop: + * This function makes an opcode based on the instruction symbol table + * entry, and an addressing mode structure. + * This function is called from both passes, but + * only generates code in pass 2. + * + * Resultant opcode bytes are passed to genbyte(). + * + * Returns the nuumber of bytes that the instruction + * occupies. + * + */ + +int makeop(struct opcode * op, struct mode *m, int add) +{ + register unsigned int newop; + + if( m == NULL ) { + if(pass2) genbyte(op->bytes[0+add]); + return(1); + } + + if( pass2 ) { + newop = op->bytes[ get_md(*m)+add ] | get_ov(*m); + genbyte(newop); + if( get_sz(*m) > 0 ) genbyte( get_b1(*m) ); + if( get_sz(*m) > 1 ) genbyte( get_b2(*m) ); + } + return( get_sz(*m)+1 ); +} + + +/* ---------------------------------------------------------------------- + * inclc: + * Increments the Location Counter by 'i' amount. + * Check to see if 'i' overflows 64K. + * Checks to see if assembler is overlapping previous sections + * of code. (using a large bit field). + * + */ + +#define indx(a) ( (a)/(32) ) +#define bit(a) ( 1 << ((a)%(32)) ) + +#define getloc(a) (regions[indx(a)] & bit(a)) +#define setloc(a) (regions[indx(a)] |= bit(a)) + +static unsigned long regions[ 0x10000/(32) ]; + +void inclc(int i) +{ + + while (i-- > 0) { + if( pass2 && getloc(lc) ) + error("Location counter overlaps"); + if( pass2 ) setloc(lc); + lc += 1; + } + + if( lc > 0xffff ) + error("Location counter has exceeded 16-bits"); +} + +void clear_location_counter(void) +{ + memset(regions, 0, sizeof(regions)); +} + + +/* ---------------------------------------------------------------------- + * padline: + * This routine returns a new string, which is equivilant to + * 'line' except that all tabs have been expanded to spaces, and + * the total length has been truncated to 60 chars. + */ + +char *padline(char *line) +{ + static char newline[61]; + char *p1; + int pos=0,nxtpos; + + for(p1=line; pos= 4 ) { + j = 0; + fprintf(listing,"\n "); + } + } + while(++j <= 4) + fprintf(listing," "); + + fprintf(listing," %s\n",padline(txt)); +} + +/* ---------------------------------------------------------------------- + * gen* routines: + * Place information into the bytebuf[] array, and also + * call emitbyte with the byte. + * + */ + +void genbyte(int b) +{ + if( bytecount < sizeof(bytebuf) ) + bytebuf[bytecount++] = b; + emitbyte(b); +} + +void genstr(const char *s) +{ + while( *s ) + genbyte(*s++); +} + +void genword(unsigned long w) +{ + genbyte( (w & 0xff00) >> 8 ); + genbyte( (w & 0x00ff) ); +} + diff --git a/as31/run.c b/as31/run.c new file mode 100644 index 0000000..126d3b5 --- /dev/null +++ b/as31/run.c @@ -0,0 +1,268 @@ +#define _GNU_SOURCE +#include +#include +#include +#include +#include + + +#include //for user stuff + +#include "as31.h" + + +// added ".inc" command to include header files. B.Porr + +/* global variables */ +unsigned long lc; +char *asmfile; +int fatal=0, abort_asap=0; +int pass=0; +int dashl=0; +FILE *listing=NULL, *fin=NULL; +int incLineCount=0; + + + +int run_as31(const char *infile, int lst, int use_stdout, + const char *fmt, const char *arg, const char *customoutfile) +{ + char *outfile=NULL, *lstfile=NULL; + const char *extension; + int has_dot_asm=0; + int i,len, baselen, extlen; + FILE* finPre; + char tmpName[256]; + char *lineBuffer=NULL; + int sizeBuf=0; + char *includePtr=NULL; + char *incLineBuffer=NULL; + int incSizeBuf=0; + FILE* includeFile=NULL; + + uid_t uid; + /* first, figure out all the file names */ + + dashl = lst; + extension = emit_extension(fmt); + extlen = strlen(extension); + + len = baselen = strlen(infile); + if (len >= 4 && strcasecmp(infile + len - 4, ".asm") == 0) { + has_dot_asm = 1; + baselen -= 4; + } + + asmfile = (char *)malloc(baselen + 5); + strcpy(asmfile, infile); + + if (dashl) { + lstfile = (char *)malloc(baselen + 5); + strncpy(lstfile, infile, baselen); + strcpy(lstfile + baselen, ".lst"); + } + + if (use_stdout) { + outfile = NULL; + } else { + if (customoutfile==NULL) { + outfile = (char *)malloc(baselen + extlen + 2); + strncpy(outfile, infile, baselen); + *(outfile + baselen) = '.'; + strcpy(outfile + baselen + 1, extension); + } else { + len = strlen(customoutfile); + outfile = (char *)malloc(len + 1); + strncpy(outfile, customoutfile, len); + } + } + + /* now open the files */ + + // "preprocessor" + finPre = freopen(asmfile, "r", stdin); + if (finPre == NULL) { + if (!has_dot_asm) { + strcpy(asmfile + baselen, ".asm"); + finPre = freopen(asmfile, "r", stdin); + } + if (finPre == NULL) { + mesg_f("Cannot open input file: %s\n", asmfile); + free(asmfile); + if (outfile) free(outfile); + if (lstfile) free(lstfile); + return -1; + } + } + + uid = geteuid(); + sprintf(tmpName,"/tmp/as31-%i-%ld.asm",uid,random()); + fin = fopen(tmpName, "w"); + if (fin == NULL) { + mesg_f("Cannot open temp file: %s\n",tmpName); + if (outfile) free(outfile); + if (lstfile) free(lstfile); + return -1; + } + + while (!feof(finPre)) { + getline(&lineBuffer,&sizeBuf,finPre); + if ((includePtr=strstr(lineBuffer,INC_CMD))) { + includePtr=includePtr+strlen(INC_CMD); + while ((*includePtr==' ')|| //move includePtr to filename + (*includePtr==9) || + (*includePtr=='\"')|| + (*includePtr=='\'')) + { + includePtr++; + } + i=0; + while ((includePtr[i]!=0) && + (includePtr[i]!=10) && + (includePtr[i]!=13) && + (includePtr[i]!='\"') && + (includePtr[i]!='\'')) { + i++; + } + includePtr[i]=0; + includeFile=fopen(includePtr,"r"); + mesg_f("including file: %s\n",includePtr); + if (!includeFile) { + mesg_f("Cannot open include file: %s\n",includePtr); + } else { + while (!feof(includeFile)) { + getline(&incLineBuffer,&incSizeBuf,includeFile); + fprintf(fin,"%s",incLineBuffer); + if (strlen(incLineBuffer)) { + incLineCount++; + } + } + fclose(includeFile); + if (incLineCount) { + incLineCount--; + } + } + } else { + fprintf(fin,"%s",lineBuffer); + } + } //.inc -files are now inserted + free(lineBuffer); + free(incLineBuffer); + + fclose(fin); + fin = freopen(tmpName, "r", stdin); + + if (dashl) { + listing = fopen(lstfile,"w"); + if( listing == NULL ) { + mesg_f("Cannot open file: %s for writing.\n", + lstfile); + fclose(fin); + free(asmfile); + if (outfile) free(outfile); + if (lstfile) free(lstfile); + return -1; + } + } + + /* what happens if this doesn't work */ + emitopen(outfile, fmt, arg); + + syminit(); + clear_location_counter(); + fatal = abort_asap = 0; + lineno = 1; + pass=0; + lc = 0; + + /* + ** P A S S 1 + */ + + if (!use_stdout) mesg_f("Begin Pass #1\n"); + yyparse(); + if (fatal) { + mesg_f("Errors in pass1, assembly aborted\n"); + } else { + + rewind(fin); + lineno = 1; + pass++; + lc = 0; + emitaddr(lc); + + /* + ** P A S S 2 + */ + if (!use_stdout) mesg_f("Begin Pass #2\n"); + yyparse(); + } + if (fatal) { + mesg_f("Errors in pass2, assembly aborted\n"); + } + + emitclose(); + fclose(fin); + unlink(tmpName); //delete tmpName + if (dashl) fclose(listing); + free(asmfile); + if (outfile) free(outfile); + if (lstfile) free(lstfile); + freesym(); + if (fatal) return -1; + return 0; +} + + +/* the parser, lexer and other stuff that actually do the */ +/* assembly will call to these two functions to report any */ +/* errors or warning. error() calls exit() in the command */ +/* line version, but the abort_asap flag was added, and the */ +/* parser check it at the end of every line */ + +void error(const char *fmt, ...) +{ + va_list args; + char buf[2048]; + int len; + + abort_asap++; + fatal++; + va_start(args, fmt); + + // fixme: negative line no for includes... + len = snprintf(buf, sizeof(buf), "Error, line %d, ", lineno-incLineCount); + len += vsnprintf(buf + len, sizeof(buf) - len, fmt, args); + snprintf(buf + len, sizeof(buf) - len, ".\n"); + mesg(buf); +} + + +void warn(const char *fmt, ...) +{ + va_list args; + char buf[2048]; + int len; + + fatal++; + va_start(args, fmt); + + printf("incLineCount=%d\n",incLineCount); + len = snprintf(buf, sizeof(buf), "Warning, line %d, ", lineno-incLineCount); + len += vsnprintf(buf + len, sizeof(buf) - len, fmt, args); + snprintf(buf + len, sizeof(buf) - len, ".\n"); + mesg(buf); +} + + +void mesg_f(const char *fmt, ...) +{ + va_list args; + char buf[2048]; + + va_start(args, fmt); + + vsnprintf(buf, sizeof(buf), fmt, args); + mesg(buf); +} + diff --git a/as31/symbol.c b/as31/symbol.c new file mode 100644 index 0000000..03d78f2 --- /dev/null +++ b/as31/symbol.c @@ -0,0 +1,433 @@ +/* ---------------------------------------------------------------------- + * FILE: symbol.c + * PACKAGE: as31 - 8031/8051 Assembler. + * + * DESCRIPTION: + * This file contains the symbol table search/insertion routines + * associated with user defined symbols. + * + * The reserved keyword (instructions/directives) look up routine + * is defined here. + * + * The opcode table for all of the instructions is located in this + * file. + * + * REVISION HISTORY: + * Jan. 19, 1990 - Created. (Ken Stauffer) + * + * AUTHOR: + * All code in this file written by Ken Stauffer (University of Calgary) + * January, 1990. + * + */ + +#include +#include + +/* normally in stdlib.h, but that include file also defines */ +/* "div" which conflicts with the div in this file */ +extern void *malloc(size_t size); +extern void free(void *ptr); + + +#include "as31.h" +#include "parser.h" + +#define B(a) (0xF0+(a)) +#define ACC(a) (0xE0+(a)) +#define PSW(a) (0xD0+(a)) +#define T2CON(a) (0xC8+(a)) +#define IP(a) (0xB8+(a)) +#define P3(a) (0xB0+(a)) +#define IE(a) (0xA8+(a)) +#define P2(a) (0xA0+(a)) +#define SCON(a) (0x98+(a)) +#define P1(a) (0x90+(a)) +#define TCON(a) (0x88+(a)) +#define P0(a) (0x80+(a)) + +/* ---------------------------------------------------------------------- + * sinit[] + * These symbols are not reserved keywords. + * This array contains the initial symbol table entries + * for the user symbol table. The symbols are + * basically convienient names that make writing + * in 8031/8051 bearable. + * + * The function syminit() inserts these entries into the + * symbol table. + * + */ + +static struct symbol sinit[] = { + { "AC", 1, LABEL, PSW(6), NULL }, + { "ACC", 1, LABEL, ACC(0), NULL }, + { "B", 1, LABEL, B(0), NULL }, + { "CY", 1, LABEL, PSW(7), NULL }, + { "DPH", 1, LABEL, 0x83, NULL }, + { "DPL", 1, LABEL, 0x82, NULL }, + { "EA", 1, LABEL, IE(7), NULL }, + { "ES", 1, LABEL, IE(4), NULL }, + { "ET0", 1, LABEL, IE(1), NULL }, + { "ET1", 1, LABEL, IE(3), NULL }, + { "ET2", 1, LABEL, IE(5), NULL }, + { "EX0", 1, LABEL, IE(0), NULL }, + { "EX1", 1, LABEL, IE(2), NULL }, + { "EXEN2", 1, LABEL, T2CON(3),NULL }, + { "EXF2", 1, LABEL, T2CON(6),NULL }, + { "F0", 1, LABEL, PSW(5), NULL }, + { "IE", 1, LABEL, IE(0), NULL }, + { "IE0", 1, LABEL, TCON(1),NULL }, + { "IE1", 1, LABEL, TCON(3),NULL }, + { "INT0", 1, LABEL, P3(2), NULL }, + { "INT1", 1, LABEL, P3(3), NULL }, + { "IP", 1, LABEL, IP(0), NULL }, + { "IT0", 1, LABEL, TCON(0),NULL }, + { "IT1", 1, LABEL, TCON(2),NULL }, + { "OV", 1, LABEL, PSW(2), NULL }, + { "P", 1, LABEL, PSW(0), NULL }, + { "P0", 1, LABEL, P0(0), NULL }, + { "P1", 1, LABEL, P1(0), NULL }, + { "P2", 1, LABEL, P2(0), NULL }, + { "P3", 1, LABEL, P3(0), NULL }, + { "PCON", 1, LABEL, 0x87, NULL }, + { "PS", 1, LABEL, IP(4), NULL }, + { "PSW", 1, LABEL, PSW(0), NULL }, + { "PT0", 1, LABEL, IP(1), NULL }, + { "PT1", 1, LABEL, IP(3), NULL }, + { "PT2", 1, LABEL, IP(5), NULL }, + { "PX0", 1, LABEL, IP(0), NULL }, + { "PX1", 1, LABEL, IP(2), NULL }, + { "RB8", 1, LABEL, SCON(2),NULL }, + { "RCAP2H", 1, LABEL, 0xCB, NULL }, + { "RCAP2L", 1, LABEL, 0xCA, NULL }, + { "RCLK", 1, LABEL, T2CON(5),NULL }, + { "REN", 1, LABEL, SCON(4),NULL }, + { "RD", 1, LABEL, P3(7), NULL }, + { "RI", 1, LABEL, SCON(0),NULL }, + { "RL2", 1, LABEL, T2CON(0),NULL }, + { "RS0", 1, LABEL, PSW(3), NULL }, + { "RS1", 1, LABEL, PSW(4), NULL }, + { "RXD", 1, LABEL, P3(0), NULL }, + { "SBUF", 1, LABEL, 0x99, NULL }, + { "SCON", 1, LABEL, SCON(0),NULL }, + { "SM0", 1, LABEL, SCON(7),NULL }, + { "SM1", 1, LABEL, SCON(6),NULL }, + { "SM2", 1, LABEL, SCON(5),NULL }, + { "SP", 1, LABEL, 0x81, NULL }, + { "T0", 1, LABEL, P3(4), NULL }, + { "T1", 1, LABEL, P3(5), NULL }, + { "T2", 1, LABEL, P0(0), NULL }, + { "T2CON", 1, LABEL, T2CON(0),NULL }, + { "T2EX", 1, LABEL, P0(1), NULL }, + { "TB8", 1, LABEL, SCON(3),NULL }, + { "TCLK", 1, LABEL, T2CON(4),NULL }, + { "TCON", 1, LABEL, TCON(0),NULL }, + { "TF0", 1, LABEL, TCON(5),NULL }, + { "TF1", 1, LABEL, TCON(7),NULL }, + { "TF2", 1, LABEL, T2CON(7),NULL }, + { "TH0", 1, LABEL, 0x8C, NULL }, + { "TH1", 1, LABEL, 0x8D, NULL }, + { "TH2", 1, LABEL, 0xCD, NULL }, + { "TI", 1, LABEL, SCON(1),NULL }, + { "TL0", 1, LABEL, 0x8A, NULL }, + { "TL1", 1, LABEL, 0x8B, NULL }, + { "TL2", 1, LABEL, 0xCC, NULL }, + { "TMOD", 1, LABEL, 0x89, NULL }, + { "TR0", 1, LABEL, TCON(4),NULL }, + { "TR1", 1, LABEL, TCON(6),NULL }, + { "TR2", 1, LABEL, T2CON(2),NULL }, + { "TXD", 1, LABEL, P3(1), NULL }, + { "WR", 1, LABEL, P3(6), NULL } +}; + +#define SINITSIZE (sizeof(sinit)/sizeof(sinit[0])) + +/* ---------------------------------------------------------------------- + * opcode vectors: + * These arrays contain the various opcodes for the + * various forms an instruction may take. + * + * The ordering of these opcodes is very critical to the + * proper fuctioning of the assembler. + * + * When a given form of an instruction is parsed, the parser + * indexes one of these arrays by the correct amount and thus + * obtains the correct opcode for the particular form. + * + */ + +static unsigned char acall[]= { 0x11 }; +static unsigned char add[]= { 0x28, 0x25, 0x26, 0x24 }; +static unsigned char addc[]= { 0x38, 0x35, 0x36, 0x34 }; +static unsigned char ajmp[]= { 0x01 }; +static unsigned char anl[]= { 0x58, 0x55, 0x56, 0x54, 0x52, 0x53, 0x82, + 0xb0 }; +static unsigned char cjne[]= { 0xb5, 0xb4, 0xb8, 0xb6 }; +static unsigned char clr[]= { 0xe4, 0xc3, 0xc2 }; +static unsigned char cpl[]= { 0xf4, 0xb3, 0xb2 }; +static unsigned char da[]= { 0xd4 }; +static unsigned char dec[]= { 0x14, 0x18, 0x15, 0x16 }; +static unsigned char div[]= { 0x84 }; +static unsigned char djnz[]= { 0xd8, 0xd5 }; +static unsigned char inc[]= { 0x04, 0x08, 0x05, 0x06, 0xa3 }; +static unsigned char jb[]= { 0x20 }; +static unsigned char jbc[]= { 0x10 }; +static unsigned char jc[]= { 0x40 }; +static unsigned char jmp[]= { 0x73 }; +static unsigned char jnb[]= { 0x30 }; +static unsigned char jnc[]= { 0x50 }; +static unsigned char jnz[]= { 0x70 }; +static unsigned char jz[]= { 0x60 }; +static unsigned char lcall[]= { 0x12 }; +static unsigned char ljmp[]= { 0x02 }; +static unsigned char mov[]= { 0xe8, 0xe5, 0xe6, 0x74, 0xf5, 0x75, 0xf8, + 0xa8, 0x78, 0x88, 0x85, 0x86, 0xf6, 0xa6, + 0x76, 0x90, 0xa2, 0x92 }; +static unsigned char movc[]= { 0x93, 0x83 }; +static unsigned char movx[]= { 0xe2, 0xe3, 0xe0, 0xf2, 0xf3, 0xf0 }; +static unsigned char mul[]= { 0xa4 }; +static unsigned char nop[]= { 0x00 }; +static unsigned char orl[]= { 0x48, 0x45, 0x46, 0x44, 0x42, 0x43, 0x72, + 0xa0 }; +static unsigned char pop[]= { 0xd0 }; +static unsigned char push[]= { 0xc0 }; +static unsigned char ret[]= { 0x22 }; +static unsigned char reti[]= { 0x32 }; +static unsigned char rl[]= { 0x23 }; +static unsigned char rlc[]= { 0x33 }; +static unsigned char rr[]= { 0x03 }; +static unsigned char rrc[]= { 0x13 }; +static unsigned char setb[]= { 0xd3, 0xd2 }; +static unsigned char sjmp[]= { 0x80 }; +static unsigned char subb[]= { 0x98, 0x95, 0x96, 0x94 }; +static unsigned char swap[]= { 0xc4 }; +static unsigned char xch[]= { 0xc8, 0xc5, 0xc6 }; +static unsigned char xchd[]= { 0xd6 }; +static unsigned char xrl[]= { 0x68, 0x65, 0x66, 0x64, 0x62, 0x63 }; + +/* ---------------------------------------------------------------------- + * optable[] + * This table contains opcodes, directives and a few reserved + * symbols. + * + * The second field is the keywords token value. + * + * Unless the symbol is an opcode, the third field will + * be NULL. + * + * The third field is a pointer to an array of opcode bytes. + * + * --> This list must be in order by the first field + */ + +static struct opcode optable[] = { + {"a", A, NULL }, + {"ab", AB, NULL }, + {"acall", ACALL, acall }, + {"add", ADD, add }, + {"addc", ADDC, addc }, + {"ajmp", AJMP, ajmp }, + {"anl", ANL, anl }, + {"byte", D_BYTE, NULL }, + {"c", C, NULL }, + {"cjne", CJNE, cjne }, + {"clr", CLR, clr }, + {"cpl", CPL, cpl }, + {"da", DA, da }, + {"db", D_BYTE, NULL }, + {"dec", DEC, dec }, + {"div", DIV, div }, + {"djnz", DJNZ, djnz }, + {"dptr", DPTR, NULL }, + {"dw", D_WORD, NULL }, + {"end", D_END, NULL }, + {"equ", D_EQU, NULL }, + {"flag", D_FLAG, NULL }, + {"inc", INC, inc }, + {"jb", JB, jb }, + {"jbc", JBC, jbc }, + {"jc", JC, jc }, + {"jmp", JMP, jmp }, + {"jnb", JNB, jnb }, + {"jnc", JNC, jnc }, + {"jnz", JNZ, jnz }, + {"jz", JZ, jz }, + {"lcall", LCALL, lcall }, + {"ljmp", LJMP, ljmp }, + {"mov", MOV, mov }, + {"movc", MOVC, movc }, + {"movx", MOVX, movx }, + {"mul", MUL, mul }, + {"nop", NOP, nop }, + {"org", D_ORG, NULL }, + {"orl", ORL, orl }, + {"pc", PC, NULL }, + {"pop", POP, pop }, + {"push", PUSH, push }, + {"r0", R0, NULL }, + {"r1", R1, NULL }, + {"r2", R2, NULL }, + {"r3", R3, NULL }, + {"r4", R4, NULL }, + {"r5", R5, NULL }, + {"r6", R6, NULL }, + {"r7", R7, NULL }, + {"ret", RET, ret }, + {"reti", RETI, reti }, + {"rl", RL, rl }, + {"rlc", RLC, rlc }, + {"rr", RR, rr }, + {"rrc", RRC, rrc }, + {"setb", SETB, setb }, + {"sjmp", SJMP, sjmp }, + {"skip", D_SKIP, NULL }, + {"subb", SUBB, subb }, + {"swap", SWAP, swap }, + {"word", D_WORD, NULL }, + {"xch", XCH, xch }, + {"xchd", XCHD, xchd }, + {"xrl", XRL, xrl } +}; + +#define OPTABSIZE (sizeof(optable)/sizeof(struct opcode)) + + +/* ---------------------------------------------------------------------- + * lookop: + * Do a binary search through optable[], for a matching + * symbol. Return the symbol found or NULL. + * + */ + +struct opcode *lookop(const char *s) +{ + register int low,high,mid,cond; + + low = 0; + high = OPTABSIZE-1; + while( low<=high ) { + mid = (low+high)/2; + if( (cond = strcasecmp(s,optable[mid].name)) < 0 ) + high = mid-1; + else if(cond > 0 ) + low = mid+1; + else + return(&optable[mid]); + } + return(NULL); +} + +/* ---------------------------------------------------------------------- + * symtab, hash, looksym: + * User symbol table routines. + * symtab is the hash table for the user symbols. + * (chaining is used for collision resolution). + * + */ + +static struct symbol *symtab[HASHTABSIZE]; + +int hash(const char *s) +{ + register const char *p; + register unsigned h=0, g; + + for (p=s; *p; p++) { + h = (h<<4) + toupper(*p); + if ( (g = h&0xf0000000) ) { + h = h ^ (g >> 24); + h = h ^ g; + } + } + return( h % HASHTABSIZE ); +} + +struct symbol *looksym(const char *s) +{ + register struct symbol *ptr, *prev; + char *p; + register int hv; + + hv = hash(s); + + prev = NULL; + for(ptr=symtab[hv]; ptr; ptr = ptr->next) { + if( !strcasecmp(ptr->name,s) ) { + if( prev != NULL ) { + prev->next = ptr->next; + ptr->next = symtab[hv]; + symtab[hv] = ptr; + } + return(ptr); + } + prev = ptr; + } + + if ( (p = malloc(strlen(s) + 1)) ) { + strcpy(p,s); + } else { + error("Cannot allocate %d bytes",strlen(s)+1); + } + + ptr = (struct symbol *) malloc( sizeof(struct symbol) ); + if( ptr == NULL ) + error("Cannot allocate %d bytes",sizeof(struct symbol)); + ptr->name = p; + ptr->predefined = 0; + ptr->type = UNDEF; + ptr->next = symtab[hv]; + symtab[hv] = ptr; + return(ptr); +} + +/* ---------------------------------------------------------------------- + * syminit: + * Initializes the hash table, with the initial symbols from + * sinit[] + * + */ + +// static struct symbol *symtab[HASHTABSIZE]; + +void syminit(void) +{ + register int i,hv; + + /* clear all entries in the symbol table */ + memset(symtab, 0, sizeof(struct symbol *) * HASHTABSIZE); + + /* load all the pre-defined symbols */ + for(i=0; ipredefined) { + sym = sym->next; + } else { + if (sym->name) free(sym->name); + next = sym->next; + free(sym); + sym = next; + } + } + } +} + + + diff --git a/configure b/configure new file mode 100644 index 0000000..357a127 --- /dev/null +++ b/configure @@ -0,0 +1,3912 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.59. +# +# Copyright (C) 2003 Free Software Foundation, Inc. +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then + set -o posix +fi +DUALCASE=1; export DUALCASE # for MKS sh + +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# Work around bugs in pre-3.0 UWIN ksh. +$as_unset ENV MAIL MAILPATH +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + $as_unset $as_var + fi +done + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + + +# Name of the executable. +as_me=`$as_basename "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)$' \| \ + . : '\(.\)' 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } + /^X\/\(\/\/\)$/{ s//\1/; q; } + /^X\/\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + + +# PATH needs CR, and LINENO needs CR and PATH. +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" || { + # Find who we are. Look in the path if we contain no path at all + # relative or not. + case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done + + ;; + esac + # We did not find ourselves, most probably we were run as `sh COMMAND' + # in which case we are not to be found in the path. + if test "x$as_myself" = x; then + as_myself=$0 + fi + if test ! -f "$as_myself"; then + { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2 + { (exit 1); exit 1; }; } + fi + case $CONFIG_SHELL in + '') + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for as_base in sh bash ksh sh5; do + case $as_dir in + /*) + if ("$as_dir/$as_base" -c ' + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then + $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } + $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } + CONFIG_SHELL=$as_dir/$as_base + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$0" ${1+"$@"} + fi;; + esac + done +done +;; + esac + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line before each line; the second 'sed' does the real + # work. The second script uses 'N' to pair each line-number line + # with the numbered line, and appends trailing '-' during + # substitution so that $LINENO is not a special case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) + sed '=' <$as_myself | + sed ' + N + s,$,-, + : loop + s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, + t loop + s,-$,, + s,^['$as_cr_digits']*\n,, + ' >$as_me.lineno && + chmod +x $as_me.lineno || + { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensible to this). + . ./$as_me.lineno + # Exit status is that of the last command. + exit +} + + +case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in + *c*,-n*) ECHO_N= ECHO_C=' +' ECHO_T=' ' ;; + *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; + *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +esac + +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + # We could just check for DJGPP; but this test a) works b) is more generic + # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). + if test -f conf$$.exe; then + # Don't use ln at all; we don't have any links + as_ln_s='cp -p' + else + as_ln_s='ln -s' + fi +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.file + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +as_executable_p="test -f" + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +# IFS +# We need space, tab and new line, in precisely that order. +as_nl=' +' +IFS=" $as_nl" + +# CDPATH. +$as_unset CDPATH + + +# Name of the host. +# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +exec 6>&1 + +# +# Initializations. +# +ac_default_prefix=/usr/local +ac_config_libobj_dir=. +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} + +# Maximum number of lines to put in a shell here document. +# This variable seems obsolete. It should probably be removed, and +# only ac_max_sed_lines should be used. +: ${ac_max_here_lines=38} + +# Identity of this package. +PACKAGE_NAME= +PACKAGE_TARNAME= +PACKAGE_VERSION= +PACKAGE_STRING= +PACKAGE_BUGREPORT= + +ac_unique_file="as31/as31.c" +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO SET_MAKE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT YACC GUI_LIBS GUI_CFLAGS GTK_CONFIG GTK_CFLAGS GTK_LIBS OPTION_GTK_TRUE OPTION_GTK_FALSE LIBOBJS LTLIBOBJS' +ac_subst_files='' + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +# The variables have the same names as the options, with +# dashes changed to underlines. +cache_file=/dev/null +exec_prefix=NONE +no_create= +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +verbose= +x_includes=NONE +x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datadir='${prefix}/share' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +libdir='${exec_prefix}/lib' +includedir='${prefix}/include' +oldincludedir='/usr/include' +infodir='${prefix}/info' +mandir='${prefix}/man' + +ac_prev= +for ac_option +do + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval "$ac_prev=\$ac_option" + ac_prev= + continue + fi + + ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case $ac_option in + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir=$ac_optarg ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build_alias ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build_alias=$ac_optarg ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; + + -datadir | --datadir | --datadi | --datad | --data | --dat | --da) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ + | --da=*) + datadir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/-/_/g'` + eval "enable_$ac_feature=no" ;; + + -enable-* | --enable-*) + ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/-/_/g'` + case $ac_option in + *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; + *) ac_optarg=yes ;; + esac + eval "enable_$ac_feature='$ac_optarg'" ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix=$ac_optarg ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; + + -host | --host | --hos | --ho) + ac_prev=host_alias ;; + -host=* | --host=* | --hos=* | --ho=*) + host_alias=$ac_optarg ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir=$ac_optarg ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir=$ac_optarg ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir=$ac_optarg ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir=$ac_optarg ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst \ + | --locals | --local | --loca | --loc | --lo) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* \ + | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) + localstatedir=$ac_optarg ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir=$ac_optarg ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c | -n) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir=$ac_optarg ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix=$ac_optarg ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix=$ac_optarg ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix=$ac_optarg ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name=$ac_optarg ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir=$ac_optarg ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir=$ac_optarg ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site=$ac_optarg ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir=$ac_optarg ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir=$ac_optarg ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target_alias ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target_alias=$ac_optarg ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; + + -with-* | --with-*) + ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package| sed 's/-/_/g'` + case $ac_option in + *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; + *) ac_optarg=yes ;; + esac + eval "with_$ac_package='$ac_optarg'" ;; + + -without-* | --without-*) + ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package | sed 's/-/_/g'` + eval "with_$ac_package=no" ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes=$ac_optarg ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries=$ac_optarg ;; + + -*) { echo "$as_me: error: unrecognized option: $ac_option +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; } + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 + { (exit 1); exit 1; }; } + ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` + eval "$ac_envvar='$ac_optarg'" + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} + ;; + + esac +done + +if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + { echo "$as_me: error: missing argument to $ac_option" >&2 + { (exit 1); exit 1; }; } +fi + +# Be sure to have absolute paths. +for ac_var in exec_prefix prefix +do + eval ac_val=$`echo $ac_var` + case $ac_val in + [\\/$]* | ?:[\\/]* | NONE | '' ) ;; + *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; };; + esac +done + +# Be sure to have absolute paths. +for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \ + localstatedir libdir includedir oldincludedir infodir mandir +do + eval ac_val=$`echo $ac_var` + case $ac_val in + [\\/$]* | ?:[\\/]* ) ;; + *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; };; + esac +done + +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +# FIXME: To remove some day. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: To remove some day. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used." >&2 + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi + +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null + + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then its parent. + ac_confdir=`(dirname "$0") 2>/dev/null || +$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$0" : 'X\(//\)[^/]' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$0" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + srcdir=$ac_confdir + if test ! -r $srcdir/$ac_unique_file; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r $srcdir/$ac_unique_file; then + if test "$ac_srcdir_defaulted" = yes; then + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2 + { (exit 1); exit 1; }; } + else + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 + { (exit 1); exit 1; }; } + fi +fi +(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null || + { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2 + { (exit 1); exit 1; }; } +srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'` +ac_env_build_alias_set=${build_alias+set} +ac_env_build_alias_value=$build_alias +ac_cv_env_build_alias_set=${build_alias+set} +ac_cv_env_build_alias_value=$build_alias +ac_env_host_alias_set=${host_alias+set} +ac_env_host_alias_value=$host_alias +ac_cv_env_host_alias_set=${host_alias+set} +ac_cv_env_host_alias_value=$host_alias +ac_env_target_alias_set=${target_alias+set} +ac_env_target_alias_value=$target_alias +ac_cv_env_target_alias_set=${target_alias+set} +ac_cv_env_target_alias_value=$target_alias +ac_env_CC_set=${CC+set} +ac_env_CC_value=$CC +ac_cv_env_CC_set=${CC+set} +ac_cv_env_CC_value=$CC +ac_env_CFLAGS_set=${CFLAGS+set} +ac_env_CFLAGS_value=$CFLAGS +ac_cv_env_CFLAGS_set=${CFLAGS+set} +ac_cv_env_CFLAGS_value=$CFLAGS +ac_env_LDFLAGS_set=${LDFLAGS+set} +ac_env_LDFLAGS_value=$LDFLAGS +ac_cv_env_LDFLAGS_set=${LDFLAGS+set} +ac_cv_env_LDFLAGS_value=$LDFLAGS +ac_env_CPPFLAGS_set=${CPPFLAGS+set} +ac_env_CPPFLAGS_value=$CPPFLAGS +ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set} +ac_cv_env_CPPFLAGS_value=$CPPFLAGS + +# +# Report the --help message. +# +if test "$ac_init_help" = "long"; then + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat <<_ACEOF +\`configure' configures this package to adapt to many kinds of systems. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +_ACEOF + + cat <<_ACEOF +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --datadir=DIR read-only architecture-independent data [PREFIX/share] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --infodir=DIR info documentation [PREFIX/info] + --mandir=DIR man documentation [PREFIX/man] +_ACEOF + + cat <<\_ACEOF + +Program names: + --program-prefix=PREFIX prepend PREFIX to installed program names + --program-suffix=SUFFIX append SUFFIX to installed program names + --program-transform-name=PROGRAM run sed PROGRAM on installed program names +_ACEOF +fi + +if test -n "$ac_init_help"; then + + cat <<\_ACEOF + +Optional Features: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --enable-gtk build as31 with graphical user interface (alpha) + --disable-gtktest Do not try to compile and run a test GTK program + +Optional Packages: + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --with-gtk-prefix=PFX Prefix where GTK is installed (optional) + --with-gtk-exec-prefix=PFX Exec prefix where GTK is installed (optional) + +Some influential environment variables: + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L if you have libraries in a + nonstandard directory + CPPFLAGS C/C++ preprocessor flags, e.g. -I if you have + headers in a nonstandard directory + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +_ACEOF +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + ac_popdir=`pwd` + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d $ac_dir || continue + ac_builddir=. + +if test "$ac_dir" != .; then + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi + +case $srcdir in + .) # No --srcdir option. We are building in place. + ac_srcdir=. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; +esac + +# Do not use `cd foo && pwd` to compute absolute paths, because +# the directories may not exist. +case `pwd` in +.) ac_abs_builddir="$ac_dir";; +*) + case "$ac_dir" in + .) ac_abs_builddir=`pwd`;; + [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; + *) ac_abs_builddir=`pwd`/"$ac_dir";; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_builddir=${ac_top_builddir}.;; +*) + case ${ac_top_builddir}. in + .) ac_abs_top_builddir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; + *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_srcdir=$ac_srcdir;; +*) + case $ac_srcdir in + .) ac_abs_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; + *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_srcdir=$ac_top_srcdir;; +*) + case $ac_top_srcdir in + .) ac_abs_top_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; + *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; + esac;; +esac + + cd $ac_dir + # Check for guested configure; otherwise get Cygnus style configure. + if test -f $ac_srcdir/configure.gnu; then + echo + $SHELL $ac_srcdir/configure.gnu --help=recursive + elif test -f $ac_srcdir/configure; then + echo + $SHELL $ac_srcdir/configure --help=recursive + elif test -f $ac_srcdir/configure.ac || + test -f $ac_srcdir/configure.in; then + echo + $ac_configure --help + else + echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi + cd "$ac_popdir" + done +fi + +test -n "$ac_init_help" && exit 0 +if $ac_init_version; then + cat <<\_ACEOF + +Copyright (C) 2003 Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +_ACEOF + exit 0 +fi +exec 5>config.log +cat >&5 <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by $as_me, which was +generated by GNU Autoconf 2.59. Invocation command line was + + $ $0 $@ + +_ACEOF +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +hostinfo = `(hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + echo "PATH: $as_dir" +done + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## + +_ACEOF + + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Strip out --silent because we don't want to record it for future runs. +# Also quote any args containing shell meta-characters. +# Make two passes to allow for proper duplicate-argument suppression. +ac_configure_args= +ac_configure_args0= +ac_configure_args1= +ac_sep= +ac_must_keep_next=false +for ac_pass in 1 2 +do + for ac_arg + do + case $ac_arg in + -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + continue ;; + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) + ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; + 2) + ac_configure_args1="$ac_configure_args1 '$ac_arg'" + if test $ac_must_keep_next = true; then + ac_must_keep_next=false # Got value, back to normal. + else + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac + fi + ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'" + # Get rid of the leading space. + ac_sep=" " + ;; + esac + done +done +$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } +$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +# WARNING: Be sure not to use single quotes in there, as some shells, +# such as our DU 5.0 friend, will then `close' the trap. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + { + echo + + cat <<\_ASBOX +## ---------------- ## +## Cache variables. ## +## ---------------- ## +_ASBOX + echo + # The following way of writing the cache mishandles newlines in values, +{ + (set) 2>&1 | + case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in + *ac_space=\ *) + sed -n \ + "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" + ;; + *) + sed -n \ + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + ;; + esac; +} + echo + + cat <<\_ASBOX +## ----------------- ## +## Output variables. ## +## ----------------- ## +_ASBOX + echo + for ac_var in $ac_subst_vars + do + eval ac_val=$`echo $ac_var` + echo "$ac_var='"'"'$ac_val'"'"'" + done | sort + echo + + if test -n "$ac_subst_files"; then + cat <<\_ASBOX +## ------------- ## +## Output files. ## +## ------------- ## +_ASBOX + echo + for ac_var in $ac_subst_files + do + eval ac_val=$`echo $ac_var` + echo "$ac_var='"'"'$ac_val'"'"'" + done | sort + echo + fi + + if test -s confdefs.h; then + cat <<\_ASBOX +## ----------- ## +## confdefs.h. ## +## ----------- ## +_ASBOX + echo + sed "/^$/d" confdefs.h | sort + echo + fi + test "$ac_signal" != 0 && + echo "$as_me: caught signal $ac_signal" + echo "$as_me: exit $exit_status" + } >&5 + rm -f core *.core && + rm -rf conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status + ' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -rf conftest* confdefs.h +# AIX cpp loses on an empty file, so make sure it contains at least a newline. +echo >confdefs.h + +# Predefined preprocessor variables. + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_NAME "$PACKAGE_NAME" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_VERSION "$PACKAGE_VERSION" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_STRING "$PACKAGE_STRING" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" +_ACEOF + + +# Let the site file select an alternate cache file if it wants to. +# Prefer explicitly selected file to automatically selected ones. +if test -z "$CONFIG_SITE"; then + if test "x$prefix" != xNONE; then + CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" + else + CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" + fi +fi +for ac_site_file in $CONFIG_SITE; do + if test -r "$ac_site_file"; then + { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 +echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" + fi +done + +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special + # files actually), so we avoid doing that. + if test -f "$cache_file"; then + { echo "$as_me:$LINENO: loading cache $cache_file" >&5 +echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . $cache_file;; + *) . ./$cache_file;; + esac + fi +else + { echo "$as_me:$LINENO: creating cache $cache_file" >&5 +echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in `(set) 2>&1 | + sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val="\$ac_cv_env_${ac_var}_value" + eval ac_new_val="\$ac_env_${ac_var}_value" + case $ac_old_set,$ac_new_set in + set,) + { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 +echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 +echo "$as_me: former value: $ac_old_val" >&2;} + { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 +echo "$as_me: current value: $ac_new_val" >&2;} + ac_cache_corrupted=: + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) + ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 +echo "$as_me: error: changes in the environment can compromise the build" >&2;} + { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 +echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} + { (exit 1); exit 1; }; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + + + + + + + + + + + + + + + + + +am__api_version="1.4" +ac_aux_dir= +for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do + if test -f $ac_dir/install-sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f $ac_dir/install.sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + elif test -f $ac_dir/shtool; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi +done +if test -z "$ac_aux_dir"; then + { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5 +echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;} + { (exit 1); exit 1; }; } +fi +ac_config_guess="$SHELL $ac_aux_dir/config.guess" +ac_config_sub="$SHELL $ac_aux_dir/config.sub" +ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure. + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# OS/2's system install, which has a completely different semantic +# ./install, which can be erroneously created by make from ./install.sh. +echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 +echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6 +if test -z "$INSTALL"; then +if test "${ac_cv_path_install+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in + ./ | .// | /cC/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ + /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + done + done + ;; +esac +done + + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. We don't cache a + # path for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the path is relative. + INSTALL=$ac_install_sh + fi +fi +echo "$as_me:$LINENO: result: $INSTALL" >&5 +echo "${ECHO_T}$INSTALL" >&6 + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +echo "$as_me:$LINENO: checking whether build environment is sane" >&5 +echo $ECHO_N "checking whether build environment is sane... $ECHO_C" >&6 +# Just in case +sleep 1 +echo timestamp > conftestfile +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null` + if test "$*" = "X"; then + # -L didn't work. + set X `ls -t $srcdir/configure conftestfile` + fi + if test "$*" != "X $srcdir/configure conftestfile" \ + && test "$*" != "X conftestfile $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + { { echo "$as_me:$LINENO: error: ls -t appears to fail. Make sure there is not a broken +alias in your environment" >&5 +echo "$as_me: error: ls -t appears to fail. Make sure there is not a broken +alias in your environment" >&2;} + { (exit 1); exit 1; }; } + fi + + test "$2" = conftestfile + ) +then + # Ok. + : +else + { { echo "$as_me:$LINENO: error: newly created file is older than distributed files! +Check your system clock" >&5 +echo "$as_me: error: newly created file is older than distributed files! +Check your system clock" >&2;} + { (exit 1); exit 1; }; } +fi +rm -f conftest* +echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 +test "$program_prefix" != NONE && + program_transform_name="s,^,$program_prefix,;$program_transform_name" +# Use a double $ so make ignores it. +test "$program_suffix" != NONE && + program_transform_name="s,\$,$program_suffix,;$program_transform_name" +# Double any \ or $. echo might interpret backslashes. +# By default was `s,x,x', remove it if useless. +cat <<\_ACEOF >conftest.sed +s/[\\$]/&&/g;s/;s,x,x,$// +_ACEOF +program_transform_name=`echo $program_transform_name | sed -f conftest.sed` +rm conftest.sed + +echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6 +set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,:./+-,___p_,'` +if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.make <<\_ACEOF +all: + @echo 'ac_maketemp="$(MAKE)"' +_ACEOF +# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +eval `${MAKE-make} -f conftest.make 2>/dev/null | grep temp=` +if test -n "$ac_maketemp"; then + eval ac_cv_prog_make_${ac_make}_set=yes +else + eval ac_cv_prog_make_${ac_make}_set=no +fi +rm -f conftest.make +fi +if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + SET_MAKE= +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + SET_MAKE="MAKE=${MAKE-make}" +fi + + +PACKAGE=as31 + +VERSION=2.3.0 + +if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then + { { echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5 +echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;} + { (exit 1); exit 1; }; } +fi + +cat >>confdefs.h <<_ACEOF +#define PACKAGE "$PACKAGE" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define VERSION "$VERSION" +_ACEOF + + + +missing_dir=`cd $ac_aux_dir && pwd` +echo "$as_me:$LINENO: checking for working aclocal-${am__api_version}" >&5 +echo $ECHO_N "checking for working aclocal-${am__api_version}... $ECHO_C" >&6 +# Run test in a subshell; some versions of sh will print an error if +# an executable is not found, even if stderr is redirected. +# Redirect stdin to placate older versions of autoconf. Sigh. +if (aclocal-${am__api_version} --version) < /dev/null > /dev/null 2>&1; then + ACLOCAL=aclocal-${am__api_version} + echo "$as_me:$LINENO: result: found" >&5 +echo "${ECHO_T}found" >&6 +else + ACLOCAL="$missing_dir/missing aclocal-${am__api_version}" + echo "$as_me:$LINENO: result: missing" >&5 +echo "${ECHO_T}missing" >&6 +fi + +echo "$as_me:$LINENO: checking for working autoconf" >&5 +echo $ECHO_N "checking for working autoconf... $ECHO_C" >&6 +# Run test in a subshell; some versions of sh will print an error if +# an executable is not found, even if stderr is redirected. +# Redirect stdin to placate older versions of autoconf. Sigh. +if (autoconf --version) < /dev/null > /dev/null 2>&1; then + AUTOCONF=autoconf + echo "$as_me:$LINENO: result: found" >&5 +echo "${ECHO_T}found" >&6 +else + AUTOCONF="$missing_dir/missing autoconf" + echo "$as_me:$LINENO: result: missing" >&5 +echo "${ECHO_T}missing" >&6 +fi + +echo "$as_me:$LINENO: checking for working automake-${am__api_version}" >&5 +echo $ECHO_N "checking for working automake-${am__api_version}... $ECHO_C" >&6 +# Run test in a subshell; some versions of sh will print an error if +# an executable is not found, even if stderr is redirected. +# Redirect stdin to placate older versions of autoconf. Sigh. +if (automake-${am__api_version} --version) < /dev/null > /dev/null 2>&1; then + AUTOMAKE=automake-${am__api_version} + echo "$as_me:$LINENO: result: found" >&5 +echo "${ECHO_T}found" >&6 +else + AUTOMAKE="$missing_dir/missing automake-${am__api_version}" + echo "$as_me:$LINENO: result: missing" >&5 +echo "${ECHO_T}missing" >&6 +fi + +echo "$as_me:$LINENO: checking for working autoheader" >&5 +echo $ECHO_N "checking for working autoheader... $ECHO_C" >&6 +# Run test in a subshell; some versions of sh will print an error if +# an executable is not found, even if stderr is redirected. +# Redirect stdin to placate older versions of autoconf. Sigh. +if (autoheader --version) < /dev/null > /dev/null 2>&1; then + AUTOHEADER=autoheader + echo "$as_me:$LINENO: result: found" >&5 +echo "${ECHO_T}found" >&6 +else + AUTOHEADER="$missing_dir/missing autoheader" + echo "$as_me:$LINENO: result: missing" >&5 +echo "${ECHO_T}missing" >&6 +fi + +echo "$as_me:$LINENO: checking for working makeinfo" >&5 +echo $ECHO_N "checking for working makeinfo... $ECHO_C" >&6 +# Run test in a subshell; some versions of sh will print an error if +# an executable is not found, even if stderr is redirected. +# Redirect stdin to placate older versions of autoconf. Sigh. +if (makeinfo --version) < /dev/null > /dev/null 2>&1; then + MAKEINFO=makeinfo + echo "$as_me:$LINENO: result: found" >&5 +echo "${ECHO_T}found" >&6 +else + MAKEINFO="$missing_dir/missing makeinfo" + echo "$as_me:$LINENO: result: missing" >&5 +echo "${ECHO_T}missing" >&6 +fi + + + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + CC=$ac_ct_CC +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + CC=$ac_ct_CC +else + CC="$ac_cv_prog_CC" +fi + +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$ac_ct_CC" && break +done + + CC=$ac_ct_CC +fi + +fi + + +test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&5 +echo "$as_me: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + +# Provide some information about the compiler. +echo "$as_me:$LINENO:" \ + "checking for C compiler version" >&5 +ac_compiler=`set X $ac_compile; echo $2` +{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 + (eval $ac_compiler --version &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 + (eval $ac_compiler -v &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 + (eval $ac_compiler -V &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.exe b.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 +echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6 +ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` +if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5 + (eval $ac_link_default) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # Find the output, starting from the most likely. This scheme is +# not robust to junk in `.', hence go to wildcards (a.*) only as a last +# resort. + +# Be careful to initialize this variable, since it used to be cached. +# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile. +ac_cv_exeext= +# b.out is created by i960 compilers. +for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) + ;; + conftest.$ac_ext ) + # This is the source file. + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + # FIXME: I believe we export ac_cv_exeext for Libtool, + # but it would be cool to find out if it's true. Does anybody + # maintain Libtool? --akim. + export ac_cv_exeext + break;; + * ) + break;; + esac +done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { echo "$as_me:$LINENO: error: C compiler cannot create executables +See \`config.log' for more details." >&5 +echo "$as_me: error: C compiler cannot create executables +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; } +fi + +ac_exeext=$ac_cv_exeext +echo "$as_me:$LINENO: result: $ac_file" >&5 +echo "${ECHO_T}$ac_file" >&6 + +# Check the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +echo "$as_me:$LINENO: checking whether the C compiler works" >&5 +echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6 +# FIXME: These cross compiler hacks should be removed for Autoconf 3.0 +# If not cross compiling, check that we can run a simple program. +if test "$cross_compiling" != yes; then + if { ac_try='./$ac_file' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { echo "$as_me:$LINENO: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + fi + fi +fi +echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + +rm -f a.out a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +# Check the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 +echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6 +echo "$as_me:$LINENO: result: $cross_compiling" >&5 +echo "${ECHO_T}$cross_compiling" >&6 + +echo "$as_me:$LINENO: checking for suffix of executables" >&5 +echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6 +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + export ac_cv_exeext + break;; + * ) break;; + esac +done +else + { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest$ac_cv_exeext +echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 +echo "${ECHO_T}$ac_cv_exeext" >&6 + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +echo "$as_me:$LINENO: checking for suffix of object files" >&5 +echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6 +if test "${ac_cv_objext+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 +echo "${ECHO_T}$ac_cv_objext" >&6 +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6 +if test "${ac_cv_c_compiler_gnu+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_compiler_gnu=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_compiler_gnu=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6 +GCC=`test $ac_compiler_gnu = yes && echo yes` +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +CFLAGS="-g" +echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 +echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6 +if test "${ac_cv_prog_cc_g+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cc_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_prog_cc_g=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_g" >&6 +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5 +echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6 +if test "${ac_cv_prog_cc_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_prog_cc_stdc=no +ac_save_CC=$CC +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std1 is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std1. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +# Don't try gcc -ansi; that turns off useful extensions and +# breaks some systems' header files. +# AIX -qlanglvl=ansi +# Ultrix and OSF/1 -std1 +# HP-UX 10.20 and later -Ae +# HP-UX older versions -Aa -D_HPUX_SOURCE +# SVR4 -Xc -D__EXTENSIONS__ +for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cc_stdc=$ac_arg +break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext +done +rm -f conftest.$ac_ext conftest.$ac_objext +CC=$ac_save_CC + +fi + +case "x$ac_cv_prog_cc_stdc" in + x|xno) + echo "$as_me:$LINENO: result: none needed" >&5 +echo "${ECHO_T}none needed" >&6 ;; + *) + echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6 + CC="$CC $ac_cv_prog_cc_stdc" ;; +esac + +# Some people use a C++ compiler to compile C. Since we use `exit', +# in C++ we need to declare it. In case someone uses the same compiler +# for both compiling C and C++ we need to have the C++ compiler decide +# the declaration of exit, since it's the most demanding environment. +cat >conftest.$ac_ext <<_ACEOF +#ifndef __cplusplus + choke me +#endif +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + for ac_declaration in \ + '' \ + 'extern "C" void std::exit (int) throw (); using std::exit;' \ + 'extern "C" void std::exit (int); using std::exit;' \ + 'extern "C" void exit (int) throw ();' \ + 'extern "C" void exit (int);' \ + 'void exit (int);' +do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_declaration +#include +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +continue +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_declaration +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +done +rm -f conftest* +if test -n "$ac_declaration"; then + echo '#ifdef __cplusplus' >>confdefs.h + echo $ac_declaration >>confdefs.h + echo '#endif' >>confdefs.h +fi + +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +for ac_prog in 'bison -y' byacc +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_YACC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$YACC"; then + ac_cv_prog_YACC="$YACC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_YACC="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +YACC=$ac_cv_prog_YACC +if test -n "$YACC"; then + echo "$as_me:$LINENO: result: $YACC" >&5 +echo "${ECHO_T}$YACC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$YACC" && break +done +test -n "$YACC" || YACC="yacc" + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# OS/2's system install, which has a completely different semantic +# ./install, which can be erroneously created by make from ./install.sh. +echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 +echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6 +if test -z "$INSTALL"; then +if test "${ac_cv_path_install+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in + ./ | .// | /cC/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ + /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + done + done + ;; +esac +done + + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. We don't cache a + # path for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the path is relative. + INSTALL=$ac_install_sh + fi +fi +echo "$as_me:$LINENO: result: $INSTALL" >&5 +echo "${ECHO_T}$INSTALL" >&6 + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + + +LIBS="$LIBS" +CFLAGS="$CFLAGS" + + + + +option_gtk=false +echo "$as_me:$LINENO: checking for gtk" >&5 +echo $ECHO_N "checking for gtk... $ECHO_C" >&6 +# Check whether --enable-gtk or --disable-gtk was given. +if test "${enable_gtk+set}" = set; then + enableval="$enable_gtk" + gtk="$enableval" +else + gtk="no" +fi; +case "$gtk" in + yes) + option_gtk=true + cat >>confdefs.h <<\_ACEOF +#define OPTION_GTK 1 +_ACEOF + + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + ;; + *) + cat >>confdefs.h <<\_ACEOF +#define OPTION_GTK 0 +_ACEOF + + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + ;; +esac + + +GUI_LIBS="" +GUI_CFLAGS="" + + + +if test x$option_gtk = xtrue ; then + have_gtk=false + + +# Check whether --with-gtk-prefix or --without-gtk-prefix was given. +if test "${with_gtk_prefix+set}" = set; then + withval="$with_gtk_prefix" + gtk_config_prefix="$withval" +else + gtk_config_prefix="" +fi; + +# Check whether --with-gtk-exec-prefix or --without-gtk-exec-prefix was given. +if test "${with_gtk_exec_prefix+set}" = set; then + withval="$with_gtk_exec_prefix" + gtk_config_exec_prefix="$withval" +else + gtk_config_exec_prefix="" +fi; +# Check whether --enable-gtktest or --disable-gtktest was given. +if test "${enable_gtktest+set}" = set; then + enableval="$enable_gtktest" + +else + enable_gtktest=yes +fi; + + for module in . + do + case "$module" in + gthread) + gtk_config_args="$gtk_config_args gthread" + ;; + esac + done + + if test x$gtk_config_exec_prefix != x ; then + gtk_config_args="$gtk_config_args --exec-prefix=$gtk_config_exec_prefix" + if test x${GTK_CONFIG+set} != xset ; then + GTK_CONFIG=$gtk_config_exec_prefix/bin/gtk-config + fi + fi + if test x$gtk_config_prefix != x ; then + gtk_config_args="$gtk_config_args --prefix=$gtk_config_prefix" + if test x${GTK_CONFIG+set} != xset ; then + GTK_CONFIG=$gtk_config_prefix/bin/gtk-config + fi + fi + + # Extract the first word of "gtk-config", so it can be a program name with args. +set dummy gtk-config; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_path_GTK_CONFIG+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $GTK_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_GTK_CONFIG="$GTK_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_GTK_CONFIG="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + test -z "$ac_cv_path_GTK_CONFIG" && ac_cv_path_GTK_CONFIG="no" + ;; +esac +fi +GTK_CONFIG=$ac_cv_path_GTK_CONFIG + +if test -n "$GTK_CONFIG"; then + echo "$as_me:$LINENO: result: $GTK_CONFIG" >&5 +echo "${ECHO_T}$GTK_CONFIG" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + min_gtk_version=1.0.1 + echo "$as_me:$LINENO: checking for GTK - version >= $min_gtk_version" >&5 +echo $ECHO_N "checking for GTK - version >= $min_gtk_version... $ECHO_C" >&6 + no_gtk="" + if test "$GTK_CONFIG" = "no" ; then + no_gtk=yes + else + GTK_CFLAGS=`$GTK_CONFIG $gtk_config_args --cflags` + GTK_LIBS=`$GTK_CONFIG $gtk_config_args --libs` + gtk_config_major_version=`$GTK_CONFIG $gtk_config_args --version | \ + sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\1/'` + gtk_config_minor_version=`$GTK_CONFIG $gtk_config_args --version | \ + sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\2/'` + gtk_config_micro_version=`$GTK_CONFIG $gtk_config_args --version | \ + sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\3/'` + if test "x$enable_gtktest" = "xyes" ; then + ac_save_CFLAGS="$CFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $GTK_CFLAGS" + LIBS="$GTK_LIBS $LIBS" + rm -f conf.gtktest + if test "$cross_compiling" = yes; then + echo $ac_n "cross compiling; assumed OK... $ac_c" +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +#include +#include +#include + +int +main () +{ + int major, minor, micro; + char *tmp_version; + + system ("touch conf.gtktest"); + + /* HP/UX 9 (%@#!) writes to sscanf strings */ + tmp_version = g_strdup("$min_gtk_version"); + if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { + printf("%s, bad version string\n", "$min_gtk_version"); + exit(1); + } + + if ((gtk_major_version != $gtk_config_major_version) || + (gtk_minor_version != $gtk_config_minor_version) || + (gtk_micro_version != $gtk_config_micro_version)) + { + printf("\n*** 'gtk-config --version' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n", + $gtk_config_major_version, $gtk_config_minor_version, $gtk_config_micro_version, + gtk_major_version, gtk_minor_version, gtk_micro_version); + printf ("*** was found! If gtk-config was correct, then it is best\n"); + printf ("*** to remove the old version of GTK+. You may also be able to fix the error\n"); + printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n"); + printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n"); + printf("*** required on your system.\n"); + printf("*** If gtk-config was wrong, set the environment variable GTK_CONFIG\n"); + printf("*** to point to the correct copy of gtk-config, and remove the file config.cache\n"); + printf("*** before re-running configure\n"); + } +#if defined (GTK_MAJOR_VERSION) && defined (GTK_MINOR_VERSION) && defined (GTK_MICRO_VERSION) + else if ((gtk_major_version != GTK_MAJOR_VERSION) || + (gtk_minor_version != GTK_MINOR_VERSION) || + (gtk_micro_version != GTK_MICRO_VERSION)) + { + printf("*** GTK+ header files (version %d.%d.%d) do not match\n", + GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION); + printf("*** library (version %d.%d.%d)\n", + gtk_major_version, gtk_minor_version, gtk_micro_version); + } +#endif /* defined (GTK_MAJOR_VERSION) ... */ + else + { + if ((gtk_major_version > major) || + ((gtk_major_version == major) && (gtk_minor_version > minor)) || + ((gtk_major_version == major) && (gtk_minor_version == minor) && (gtk_micro_version >= micro))) + { + return 0; + } + else + { + printf("\n*** An old version of GTK+ (%d.%d.%d) was found.\n", + gtk_major_version, gtk_minor_version, gtk_micro_version); + printf("*** You need a version of GTK+ newer than %d.%d.%d. The latest version of\n", + major, minor, micro); + printf("*** GTK+ is always available from ftp://ftp.gtk.org.\n"); + printf("***\n"); + printf("*** If you have already installed a sufficiently new version, this error\n"); + printf("*** probably means that the wrong copy of the gtk-config shell script is\n"); + printf("*** being found. The easiest way to fix this is to remove the old version\n"); + printf("*** of GTK+, but you can also set the GTK_CONFIG environment to point to the\n"); + printf("*** correct copy of gtk-config. (In this case, you will have to\n"); + printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n"); + printf("*** so that the correct libraries are found at run-time))\n"); + } + } + return 1; +} + +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +no_gtk=yes +fi +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + if test "x$no_gtk" = x ; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + have_gtk=true + else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + if test "$GTK_CONFIG" = "no" ; then + echo "*** The gtk-config script installed by GTK could not be found" + echo "*** If GTK was installed in PREFIX, make sure PREFIX/bin is in" + echo "*** your path, or set the GTK_CONFIG environment variable to the" + echo "*** full path to gtk-config." + else + if test -f conf.gtktest ; then + : + else + echo "*** Could not run GTK test program, checking why..." + CFLAGS="$CFLAGS $GTK_CFLAGS" + LIBS="$LIBS $GTK_LIBS" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +#include +#include + +int +main () +{ + return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "*** The test program compiled, but did not run. This usually means" + echo "*** that the run-time linker is not finding GTK or finding the wrong" + echo "*** version of GTK. If it is not finding GTK, you'll need to set your" + echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" + echo "*** to the installed location Also, make sure you have run ldconfig if that" + echo "*** is required on your system" + echo "***" + echo "*** If you have an old version installed, it is best to remove it, although" + echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" + echo "***" + echo "*** If you have a RedHat 5.0 system, you should remove the GTK package that" + echo "*** came with the system with the command" + echo "***" + echo "*** rpm --erase --nodeps gtk gtk-devel" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + echo "*** The test program failed to compile or link. See the file config.log for the" + echo "*** exact error that occured. This usually means GTK was incorrectly installed" + echo "*** or that you have moved GTK since it was installed. In the latter case, you" + echo "*** may want to edit the gtk-config script: $GTK_CONFIG" +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + GTK_CFLAGS="" + GTK_LIBS="" + : + fi + + + rm -f conf.gtktest + + if test x$have_gtk = xfalse ; then + option_gtk=false + else + GUI_LIBS="$GTK_LIBS" + GUI_CFLAGS="$GTK_CFLAGS" + fi +fi + + + + +if test x$option_gtk = xtrue; then + OPTION_GTK_TRUE= + OPTION_GTK_FALSE='#' +else + OPTION_GTK_TRUE='#' + OPTION_GTK_FALSE= +fi + + + ac_config_files="$ac_config_files Makefile as31/Makefile examples/Makefile" +cat >confcache <<\_ACEOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, don't put newlines in cache variables' values. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +{ + (set) 2>&1 | + case `(ac_space=' '; set | grep ac_space) 2>&1` in + *ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n \ + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + ;; + esac; +} | + sed ' + t clear + : clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + : end' >>confcache +if diff $cache_file confcache >/dev/null 2>&1; then :; else + if test -w $cache_file; then + test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file" + cat confcache >$cache_file + else + echo "not updating unwritable cache $cache_file" + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +# VPATH may cause trouble with some makes, so we remove $(srcdir), +# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=/{ +s/:*\$(srcdir):*/:/; +s/:*\${srcdir}:*/:/; +s/:*@srcdir@:*/:/; +s/^\([^=]*=[ ]*\):*/\1/; +s/:*$//; +s/^[^=]*=[ ]*$//; +}' +fi + +# Transform confdefs.h into DEFS. +# Protect against shell expansion while executing Makefile rules. +# Protect against Makefile macro expansion. +# +# If the first sed substitution is executed (which looks for macros that +# take arguments), then we branch to the quote section. Otherwise, +# look for a macro that doesn't take arguments. +cat >confdef2opt.sed <<\_ACEOF +t clear +: clear +s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\),-D\1=\2,g +t quote +s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\),-D\1=\2,g +t quote +d +: quote +s,[ `~#$^&*(){}\\|;'"<>?],\\&,g +s,\[,\\&,g +s,\],\\&,g +s,\$,$$,g +p +_ACEOF +# We use echo to avoid assuming a particular line-breaking character. +# The extra dot is to prevent the shell from consuming trailing +# line-breaks from the sub-command output. A line-break within +# single-quotes doesn't work because, if this script is created in a +# platform that uses two characters for line-breaks (e.g., DOS), tr +# would break. +ac_LF_and_DOT=`echo; echo .` +DEFS=`sed -n -f confdef2opt.sed confdefs.h | tr "$ac_LF_and_DOT" ' .'` +rm -f confdef2opt.sed + + +ac_libobjs= +ac_ltlibobjs= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_i=`echo "$ac_i" | + sed 's/\$U\././;s/\.o$//;s/\.obj$//'` + # 2. Add them. + ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext" + ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + + +: ${CONFIG_STATUS=./config.status} +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 +echo "$as_me: creating $CONFIG_STATUS" >&6;} +cat >$CONFIG_STATUS <<_ACEOF +#! $SHELL +# Generated by $as_me. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false +SHELL=\${CONFIG_SHELL-$SHELL} +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then + set -o posix +fi +DUALCASE=1; export DUALCASE # for MKS sh + +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# Work around bugs in pre-3.0 UWIN ksh. +$as_unset ENV MAIL MAILPATH +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + $as_unset $as_var + fi +done + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + + +# Name of the executable. +as_me=`$as_basename "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)$' \| \ + . : '\(.\)' 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } + /^X\/\(\/\/\)$/{ s//\1/; q; } + /^X\/\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + + +# PATH needs CR, and LINENO needs CR and PATH. +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" || { + # Find who we are. Look in the path if we contain no path at all + # relative or not. + case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done + + ;; + esac + # We did not find ourselves, most probably we were run as `sh COMMAND' + # in which case we are not to be found in the path. + if test "x$as_myself" = x; then + as_myself=$0 + fi + if test ! -f "$as_myself"; then + { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5 +echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;} + { (exit 1); exit 1; }; } + fi + case $CONFIG_SHELL in + '') + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for as_base in sh bash ksh sh5; do + case $as_dir in + /*) + if ("$as_dir/$as_base" -c ' + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then + $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } + $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } + CONFIG_SHELL=$as_dir/$as_base + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$0" ${1+"$@"} + fi;; + esac + done +done +;; + esac + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line before each line; the second 'sed' does the real + # work. The second script uses 'N' to pair each line-number line + # with the numbered line, and appends trailing '-' during + # substitution so that $LINENO is not a special case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) + sed '=' <$as_myself | + sed ' + N + s,$,-, + : loop + s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, + t loop + s,-$,, + s,^['$as_cr_digits']*\n,, + ' >$as_me.lineno && + chmod +x $as_me.lineno || + { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5 +echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;} + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensible to this). + . ./$as_me.lineno + # Exit status is that of the last command. + exit +} + + +case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in + *c*,-n*) ECHO_N= ECHO_C=' +' ECHO_T=' ' ;; + *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; + *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +esac + +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + # We could just check for DJGPP; but this test a) works b) is more generic + # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). + if test -f conf$$.exe; then + # Don't use ln at all; we don't have any links + as_ln_s='cp -p' + else + as_ln_s='ln -s' + fi +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.file + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +as_executable_p="test -f" + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +# IFS +# We need space, tab and new line, in precisely that order. +as_nl=' +' +IFS=" $as_nl" + +# CDPATH. +$as_unset CDPATH + +exec 6>&1 + +# Open the log real soon, to keep \$[0] and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. Logging --version etc. is OK. +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX +} >&5 +cat >&5 <<_CSEOF + +This file was extended by $as_me, which was +generated by GNU Autoconf 2.59. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +_CSEOF +echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5 +echo >&5 +_ACEOF + +# Files that config.status was made for. +if test -n "$ac_config_files"; then + echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_headers"; then + echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_links"; then + echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_commands"; then + echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS +fi + +cat >>$CONFIG_STATUS <<\_ACEOF + +ac_cs_usage="\ +\`$as_me' instantiates files from templates according to the +current configuration. + +Usage: $0 [OPTIONS] [FILE]... + + -h, --help print this help, then exit + -V, --version print version number, then exit + -q, --quiet do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + +Configuration files: +$config_files + +Report bugs to ." +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF +ac_cs_version="\\ +config.status +configured by $0, generated by GNU Autoconf 2.59, + with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" + +Copyright (C) 2003 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." +srcdir=$srcdir +INSTALL="$INSTALL" +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +# If no file are specified by the user, then we need to provide default +# value. By we need to know if files were specified by the user. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=*) + ac_option=`expr "x$1" : 'x\([^=]*\)='` + ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'` + ac_shift=: + ;; + -*) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + *) # This is not an option, so the user has probably given explicit + # arguments. + ac_option=$1 + ac_need_defaults=false;; + esac + + case $ac_option in + # Handling of the options. +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --vers* | -V ) + echo "$ac_cs_version"; exit 0 ;; + --he | --h) + # Conflict between --help and --header + { { echo "$as_me:$LINENO: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&5 +echo "$as_me: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&2;} + { (exit 1); exit 1; }; };; + --help | --hel | -h ) + echo "$ac_cs_usage"; exit 0 ;; + --debug | --d* | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + CONFIG_FILES="$CONFIG_FILES $ac_optarg" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + $ac_shift + CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" + ac_need_defaults=false;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&5 +echo "$as_me: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&2;} + { (exit 1); exit 1; }; } ;; + + *) ac_config_targets="$ac_config_targets $1" ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF +if \$ac_cs_recheck; then + echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 + exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion +fi + +_ACEOF + + + + + +cat >>$CONFIG_STATUS <<\_ACEOF +for ac_config_target in $ac_config_targets +do + case "$ac_config_target" in + # Handling of arguments. + "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "as31/Makefile" ) CONFIG_FILES="$CONFIG_FILES as31/Makefile" ;; + "examples/Makefile" ) CONFIG_FILES="$CONFIG_FILES examples/Makefile" ;; + *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 +echo "$as_me: error: invalid argument: $ac_config_target" >&2;} + { (exit 1); exit 1; }; };; + esac +done + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason to put it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Create a temporary directory, and hook for its removal unless debugging. +$debug || +{ + trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 + trap '{ (exit 1); exit 1; }' 1 2 13 15 +} + +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` && + test -n "$tmp" && test -d "$tmp" +} || +{ + tmp=./confstat$$-$RANDOM + (umask 077 && mkdir $tmp) +} || +{ + echo "$me: cannot create a temporary directory in ." >&2 + { (exit 1); exit 1; } +} + +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF + +# +# CONFIG_FILES section. +# + +# No need to generate the scripts if there are no CONFIG_FILES. +# This happens for instance when ./config.status config.h +if test -n "\$CONFIG_FILES"; then + # Protect against being on the right side of a sed subst in config.status. + sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g; + s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF +s,@SHELL@,$SHELL,;t t +s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t +s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t +s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t +s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t +s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t +s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t +s,@exec_prefix@,$exec_prefix,;t t +s,@prefix@,$prefix,;t t +s,@program_transform_name@,$program_transform_name,;t t +s,@bindir@,$bindir,;t t +s,@sbindir@,$sbindir,;t t +s,@libexecdir@,$libexecdir,;t t +s,@datadir@,$datadir,;t t +s,@sysconfdir@,$sysconfdir,;t t +s,@sharedstatedir@,$sharedstatedir,;t t +s,@localstatedir@,$localstatedir,;t t +s,@libdir@,$libdir,;t t +s,@includedir@,$includedir,;t t +s,@oldincludedir@,$oldincludedir,;t t +s,@infodir@,$infodir,;t t +s,@mandir@,$mandir,;t t +s,@build_alias@,$build_alias,;t t +s,@host_alias@,$host_alias,;t t +s,@target_alias@,$target_alias,;t t +s,@DEFS@,$DEFS,;t t +s,@ECHO_C@,$ECHO_C,;t t +s,@ECHO_N@,$ECHO_N,;t t +s,@ECHO_T@,$ECHO_T,;t t +s,@LIBS@,$LIBS,;t t +s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t +s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t +s,@INSTALL_DATA@,$INSTALL_DATA,;t t +s,@PACKAGE@,$PACKAGE,;t t +s,@VERSION@,$VERSION,;t t +s,@ACLOCAL@,$ACLOCAL,;t t +s,@AUTOCONF@,$AUTOCONF,;t t +s,@AUTOMAKE@,$AUTOMAKE,;t t +s,@AUTOHEADER@,$AUTOHEADER,;t t +s,@MAKEINFO@,$MAKEINFO,;t t +s,@SET_MAKE@,$SET_MAKE,;t t +s,@CC@,$CC,;t t +s,@CFLAGS@,$CFLAGS,;t t +s,@LDFLAGS@,$LDFLAGS,;t t +s,@CPPFLAGS@,$CPPFLAGS,;t t +s,@ac_ct_CC@,$ac_ct_CC,;t t +s,@EXEEXT@,$EXEEXT,;t t +s,@OBJEXT@,$OBJEXT,;t t +s,@YACC@,$YACC,;t t +s,@GUI_LIBS@,$GUI_LIBS,;t t +s,@GUI_CFLAGS@,$GUI_CFLAGS,;t t +s,@GTK_CONFIG@,$GTK_CONFIG,;t t +s,@GTK_CFLAGS@,$GTK_CFLAGS,;t t +s,@GTK_LIBS@,$GTK_LIBS,;t t +s,@OPTION_GTK_TRUE@,$OPTION_GTK_TRUE,;t t +s,@OPTION_GTK_FALSE@,$OPTION_GTK_FALSE,;t t +s,@LIBOBJS@,$LIBOBJS,;t t +s,@LTLIBOBJS@,$LTLIBOBJS,;t t +CEOF + +_ACEOF + + cat >>$CONFIG_STATUS <<\_ACEOF + # Split the substitutions into bite-sized pieces for seds with + # small command number limits, like on Digital OSF/1 and HP-UX. + ac_max_sed_lines=48 + ac_sed_frag=1 # Number of current file. + ac_beg=1 # First line for current file. + ac_end=$ac_max_sed_lines # Line after last line for current file. + ac_more_lines=: + ac_sed_cmds= + while $ac_more_lines; do + if test $ac_beg -gt 1; then + sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag + else + sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag + fi + if test ! -s $tmp/subs.frag; then + ac_more_lines=false + else + # The purpose of the label and of the branching condition is to + # speed up the sed processing (if there are no `@' at all, there + # is no need to browse any of the substitutions). + # These are the two extra sed commands mentioned above. + (echo ':t + /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed + if test -z "$ac_sed_cmds"; then + ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" + else + ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" + fi + ac_sed_frag=`expr $ac_sed_frag + 1` + ac_beg=$ac_end + ac_end=`expr $ac_end + $ac_max_sed_lines` + fi + done + if test -z "$ac_sed_cmds"; then + ac_sed_cmds=cat + fi +fi # test -n "$CONFIG_FILES" + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case $ac_file in + - | *:- | *:-:* ) # input from stdin + cat >$tmp/stdin + ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + * ) ac_file_in=$ac_file.in ;; + esac + + # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories. + ac_dir=`(dirname "$ac_file") 2>/dev/null || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + { if $as_mkdir_p; then + mkdir -p "$ac_dir" + else + as_dir="$ac_dir" + as_dirs= + while test ! -d "$as_dir"; do + as_dirs="$as_dir $as_dirs" + as_dir=`(dirname "$as_dir") 2>/dev/null || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + done + test ! -n "$as_dirs" || mkdir $as_dirs + fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 +echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} + { (exit 1); exit 1; }; }; } + + ac_builddir=. + +if test "$ac_dir" != .; then + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi + +case $srcdir in + .) # No --srcdir option. We are building in place. + ac_srcdir=. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; +esac + +# Do not use `cd foo && pwd` to compute absolute paths, because +# the directories may not exist. +case `pwd` in +.) ac_abs_builddir="$ac_dir";; +*) + case "$ac_dir" in + .) ac_abs_builddir=`pwd`;; + [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; + *) ac_abs_builddir=`pwd`/"$ac_dir";; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_builddir=${ac_top_builddir}.;; +*) + case ${ac_top_builddir}. in + .) ac_abs_top_builddir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; + *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_srcdir=$ac_srcdir;; +*) + case $ac_srcdir in + .) ac_abs_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; + *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_srcdir=$ac_top_srcdir;; +*) + case $ac_top_srcdir in + .) ac_abs_top_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; + *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; + esac;; +esac + + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_top_builddir$INSTALL ;; + esac + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + if test x"$ac_file" = x-; then + configure_input= + else + configure_input="$ac_file. " + fi + configure_input=$configure_input"Generated from `echo $ac_file_in | + sed 's,.*/,,'` by configure." + + # First look for the input files in the build tree, otherwise in the + # src tree. + ac_file_inputs=`IFS=: + for f in $ac_file_in; do + case $f in + -) echo $tmp/stdin ;; + [\\/$]*) + # Absolute (can't be DOS-style, as IFS=:) + test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + echo "$f";; + *) # Relative + if test -f "$f"; then + # Build tree + echo "$f" + elif test -f "$srcdir/$f"; then + # Source tree + echo "$srcdir/$f" + else + # /dev/null tree + { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + fi;; + esac + done` || { (exit 1); exit 1; } + + if test x"$ac_file" != x-; then + { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + rm -f "$ac_file" + fi +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF + sed "$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s,@configure_input@,$configure_input,;t t +s,@srcdir@,$ac_srcdir,;t t +s,@abs_srcdir@,$ac_abs_srcdir,;t t +s,@top_srcdir@,$ac_top_srcdir,;t t +s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t +s,@builddir@,$ac_builddir,;t t +s,@abs_builddir@,$ac_abs_builddir,;t t +s,@top_builddir@,$ac_top_builddir,;t t +s,@abs_top_builddir@,$ac_abs_top_builddir,;t t +s,@INSTALL@,$ac_INSTALL,;t t +" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out + rm -f $tmp/stdin + if test x"$ac_file" != x-; then + mv $tmp/out $ac_file + else + cat $tmp/out + rm -f $tmp/out + fi + +done +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF + +{ (exit 0); exit 0; } +_ACEOF +chmod +x $CONFIG_STATUS +ac_clean_files=$ac_clean_files_save + + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || { (exit 1); exit 1; } +fi + diff --git a/configure.in b/configure.in new file mode 100644 index 0000000..db02e3e --- /dev/null +++ b/configure.in @@ -0,0 +1,68 @@ +AC_INIT(as31/as31.c) +AM_INIT_AUTOMAKE(as31, 2.3.0) + +dnl ******************************************************************** +dnl Minimal Requirements +dnl ******************************************************************** + +AC_PROG_CC +AC_PROG_YACC +AC_PROG_INSTALL + +LIBS="$LIBS" +CFLAGS="$CFLAGS" +AC_SUBST(LIBS) +AC_SUBST(CFLAGS) + +dnl ******************************************************************** +dnl Options +dnl ******************************************************************** + +option_gtk=false +AC_MSG_CHECKING(for gtk) +AC_ARG_ENABLE(gtk, + [ --enable-gtk build as31 with graphical user interface (alpha)], + gtk="$enableval", gtk="no") +case "$gtk" in + yes) + option_gtk=true + AC_DEFINE(OPTION_GTK, 1) + AC_MSG_RESULT(yes) + ;; + *) + AC_DEFINE(OPTION_GTK, 0) + AC_MSG_RESULT(no) + ;; +esac + +dnl ******************************************************************** +dnl Check for Gtk GUI +dnl ******************************************************************** + +GUI_LIBS="" +GUI_CFLAGS="" +AC_SUBST(GUI_LIBS) +AC_SUBST(GUI_CFLAGS) + +if test x$option_gtk = xtrue ; then + have_gtk=false + AM_PATH_GTK(1.0.1, have_gtk=true) + if test x$have_gtk = xfalse ; then + option_gtk=false + else + GUI_LIBS="$GTK_LIBS" + GUI_CFLAGS="$GTK_CFLAGS" + fi +fi + +dnl ******************************************************************** +dnl Conditional +dnl ******************************************************************** + +AM_CONDITIONAL(OPTION_GTK, test x$option_gtk = xtrue) + +dnl ******************************************************************** +dnl Output +dnl ******************************************************************** + +AC_OUTPUT(Makefile as31/Makefile examples/Makefile) diff --git a/examples/Makefile.am b/examples/Makefile.am new file mode 100644 index 0000000..bead78a --- /dev/null +++ b/examples/Makefile.am @@ -0,0 +1,3 @@ +EXTRA_DIST = extra.asm extra.ref \ + paulmon1.asm paulmon1.ref \ + paulmon2.asm paulmon2.ref diff --git a/examples/Makefile.in b/examples/Makefile.in new file mode 100644 index 0000000..76d1bab --- /dev/null +++ b/examples/Makefile.in @@ -0,0 +1,176 @@ +# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am + +# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +DESTDIR = + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +CC = @CC@ +CFLAGS = @CFLAGS@ +GTK_CFLAGS = @GTK_CFLAGS@ +GTK_CONFIG = @GTK_CONFIG@ +GTK_LIBS = @GTK_LIBS@ +GUI_CFLAGS = @GUI_CFLAGS@ +GUI_LIBS = @GUI_LIBS@ +LIBS = @LIBS@ +MAKEINFO = @MAKEINFO@ +PACKAGE = @PACKAGE@ +VERSION = @VERSION@ +YACC = @YACC@ + +EXTRA_DIST = extra.asm extra.ref paulmon1.asm paulmon1.ref paulmon2.asm paulmon2.ref + +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_CLEAN_FILES = +DIST_COMMON = Makefile.am Makefile.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = tar +GZIP_ENV = --best +all: all-redirect +.SUFFIXES: +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps examples/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + +tags: TAGS +TAGS: + + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = examples + +distdir: $(DISTFILES) + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pr $$d/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done + +info-am: +info: info-am +dvi-am: +dvi: dvi-am +check-am: all-am +check: check-am +installcheck-am: +installcheck: installcheck-am +install-exec-am: +install-exec: install-exec-am + +install-data-am: +install-data: install-data-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-am +uninstall-am: +uninstall: uninstall-am +all-am: Makefile +all-redirect: all-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install +installdirs: + + +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: +mostlyclean-am: mostlyclean-generic + +mostlyclean: mostlyclean-am + +clean-am: clean-generic mostlyclean-am + +clean: clean-am + +distclean-am: distclean-generic clean-am + +distclean: distclean-am + +maintainer-clean-am: maintainer-clean-generic distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-am + +.PHONY: tags distdir info-am info dvi-am dvi check check-am \ +installcheck-am installcheck install-exec-am install-exec \ +install-data-am install-data install-am install uninstall-am uninstall \ +all-redirect all-am all installdirs mostlyclean-generic \ +distclean-generic clean-generic maintainer-clean-generic clean \ +mostlyclean distclean maintainer-clean + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/examples/extra.asm b/examples/extra.asm new file mode 100644 index 0000000..474348b --- /dev/null +++ b/examples/extra.asm @@ -0,0 +1,2054 @@ +; User installable disassembler and single-step run for paulmon2 + +; Please email comments, suggestions, bugs to paul@pjrc.com + +; This code is in the public domain. It 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. + +; For more information, please see + +; http://www.pjrc.com/tech/8051/pm2_docs/index.html + +.equ locat, 0x1000 ;location for these commands (usually 1000) +.equ paulmon2, 0x0000 ;location where paulmon2 is at (usually 0000) + +.equ phex1, 0x2E+paulmon2 +.equ cout, 0x30+paulmon2 ;send acc to uart +.equ phex, 0x34+paulmon2 ;print acc in hex +.equ phex16, 0x36+paulmon2 ;print dptr in hex +.equ pstr, 0x38+paulmon2 ;print string @dptr +.equ ghex, 0x3A+paulmon2 ;get two-digit hex (acc) +.equ ghex16, 0x3C+paulmon2 ;get four-digit hex (dptr) +.equ upper, 0x40+paulmon2 ;convert acc to uppercase +.equ newline, 0x48+paulmon2 +.equ pcstr, 0x45+paulmon2 +.equ pint, 0x50+paulmon2 +.equ smart_wr, 0x56+paulmon2 +.equ cin_filter, 0x62+paulmon2 +.equ asc2hex, 0x65+paulmon2 + + +.equ list_key, 'L' ;list (disassemble) +.equ step_key, 'S' ;single step run +.equ vtedit_key, 'E' ;memory editor + +;for testing in ram +;.equ list_key, 'K' ;list (disassemble) +;.equ step_key, 'W' ;single step run +;.equ vtedit_key, 'E' ;memory editor + + + +;location of two bytes used by single-step in internal ram which we +;hope the user's program won't write over while it's running. These +;two bytes hold the address of the previous instruction, so we can +;show the last executed instruction with the current value of the +;registers, which is much more intuitive than displaying the next +;instruction by grabbing the program counter from the stack as was +;done in PAULMON1's single step. + +.equ lastpc, 0x7C ;don't forget to update the docs below + + + +;DIS +;---------------------------------------------------------; +; ; +; list command ; +; ; +;---------------------------------------------------------; + + +.org locat +.db 0xA5,0xE5,0xE0,0xA5 ;signiture +.db 254,list_key,0,0 ;id (254=user installed command) +.db 0,0,0,0 ;prompt code vector +.dB 0,0,0,0 ;reserved +.db 0,0,0,0 ;reserved +.db 0,0,0,0 ;reserved +.db 0,0,0,0 ;user defined +.db 255,255,255,255 ;length and checksum (255=unused) +.db "List",0 + +newline_h:ljmp newline + +.org locat+64 ;executable code begins here + +; disassembler register usage +; r0 = temporary storage +; r1 = temporart storage +; r2 = first instruction byte +; r3 = second instruction byte +; r4 = third instruction byte +; r5 = line count +; r6 = program counter (lsb) +; r7 = program counter (msb) + +list: acall newline_h + mov r5, #20 + clr psw.1 ;use ordinary long format +list2: acall disasm + djnz r5, list2 + ajmp newline_h + +disasm: +;print out the memory location and fetch the next three bytes + mov a, r7 + mov dph, a + acall phex_h + mov a, r6 + mov dpl, a + acall phex_h + clr a + movc a, @a+dptr + mov r2, a + inc dptr + clr a + movc a, @a+dptr + mov r3, a + inc dptr + clr a + movc a, @a+dptr + mov r4, a + mov a, r2 + anl a, #00001000b + jnz lookup2 + +;fetch constants for instructions not using R0-R7 +lookup1: + mov a, r2 + rr a + anl a, #01111000b ;grab upper 4 bits + mov r0, a ;keep in r0 for a moment + mov a, r2 + anl a, #00000111b ;get lower 3 bits + orl a, r0 ;combine in upper 4 + mov dptr, #opot1 ;opot=operand offset table + movc a, @a+dptr + sjmp unpack + +;fetch constants for R0-R7 instructions +lookup2: + mov a, r2 + swap a + anl a, #00001111b + mov dptr, #opot2 + movc a, @a+dptr + +;now we'll unpack the operand code (# bytes and addr mode) +unpack: anl a, #00000011b + mov r0, a + +;increment the r7/r6 pointer + add a, r6 + mov r6, a + mov a, r7 + addc a, #0 + mov r7, a + +;now print the bytes and spaces (r0 has # of bytes to print) +pbytes: mov a, #':' + acall cout_h + acall space_h + jb psw.1, pmnu ;skip bytes if running single-step + mov a, r2 + acall phex_h + acall space_h + cjne r0, #1, pbytes2 + mov r1, #11 + sjmp pbytes4 +pbytes2:mov a, r3 + acall phex_h + acall space_h + cjne r0, #2, pbytes3 + mov r1, #8 + sjmp pbytes4 +pbytes3:mov a, r4 + acall phex_h + mov r1, #6 +pbytes4:acall space_h + djnz r1, pbytes4 + + +;prints the mnunonic name and spaces +pmnu: mov a, r2 + anl a, #00001000b + jnz pmnu_lookup2 +pmnu_lookup1: + mov dptr, #mnot1 ;mnot=mnunonic offset table + mov a, r2 + rr a + anl a, #01111000b ;grab upper 4 bits + mov r0, a ;keep in r0 for a moment + mov a, r2 + anl a, #00000111b ;get lower 3 bits + orl a, r0 ;combine in upper 4 + movc a, @a+dptr + mov r1, a + sjmp pmnu0 +pmnu_lookup2: + mov dptr, #mnot2 ;16 byte table for r0-r7 instructions + mov a, r2 + swap a + anl a, #00001111b + movc a, @a+dptr + mov r1, a +pmnu0: mov dptr, #mnu_tbl + mov r0, #8 + clr c +pmnu1: mov a, #' ' + jc pmnu2 + mov a, r1 + movc a, @a+dptr + inc r1 + mov c, acc.7 + anl a, #0x7F +pmnu2: acall cout_h + djnz r0, pmnu1 + + + +;print the operands + + mov a, #dasm2 & 255 ;(low) + push acc + mov a, #dasm2 >> 8 ;(high) + push acc + +am_lookup0: + mov a, r2 + anl a, #00001000b + jnz am_lookup2 + +;fetch constants for instructions not using R0-R7 +am_lookup1: + mov a, r2 + rr a + anl a, #01111000b ;grab upper 4 bits + mov r0, a ;keep in r0 for a moment + mov a, r2 + anl a, #00000111b ;get lower 3 bits + orl a, r0 ;combine in upper 4 + mov dptr, #opot1 ;opot=operand offset table + movc a, @a+dptr + sjmp am_unpack + +;fetch constants for R0-R7 instructions +am_lookup2: + mov a, r2 + swap a + anl a, #00001111b + mov dptr, #opot2 + movc a, @a+dptr + +am_unpack: + anl a, #11111100b + rr a + rr a + dec a + + mov dptr, #oprt ;oprt=operand routine table + rl a + add a, dpl + mov dpl, a + clr a + addc a, dph + mov dph, a + clr a + jmp @a+dptr +dasm2: + ajmp newline_h + + +oprt: ajmp opcd1 ;addr11 + ajmp opcd2 ;A,Rn + ajmp opcd3 ;A,direct + ajmp opcd4 ;A,@Ri + ajmp opcd5 ;A,#data + ajmp opcd6 ;direct,A + ajmp opcd7 ;direct,#data + ajmp opcd8 ;C,bit + ajmp opcd9 ;C,/bit + ajmp opcd10 ;A,direct,rel + ajmp opcd11 ;A,#data,rel + ajmp opcd12 ;Rn,#data,rel + ajmp opcd13 ;@Ri,#data,rel + ajmp pa ;A + ajmp prc ;C + ajmp pbit ;bit + ajmp pdirect ;direct + ajmp p_reg_i ;@Ri + ajmp opcd19 ;AB + ajmp opcd20 ;Rn,rel + ajmp opcd21 ;direct,rel + ajmp p_reg_n ;Rn + ajmp pdptr ;DPTR + ajmp opcd24 ;bit,rel + ajmp prel ;rel + ajmp opcd26 ;@A+DPTR + ajmp opcd27 ;addr16 + ajmp opcd28 ;Rn,A + ajmp opcd29 ;Rn,direct + ajmp opcd30 ;Rn,#data + ajmp opcd31 ;direct,Rn + ajmp opcd32 ;direct,direct + ajmp opcd33 ;direct,@Ri + ajmp opcd34 ;@Ri,A + ajmp opcd35 ;@Ri,direct + ajmp opcd36 ;@Ri,#data + ajmp opcd37 ;bit,C + ajmp opcd38 ;DPTR,#data16 + ajmp opcd39 ;A,@A+DPTR + ajmp opcd40 ;A,@A+PC + ajmp opcd41 ;A,@DPTR + ajmp opcd42 ;@DPTR,A + ret ; + + + +opcd4: ;A,@Ri done + acall pac +p_reg_i:mov a,#'@' + acall cout_h + mov a,#'R' + acall cout_h + mov a, r2 + anl a,#00000001b + ajmp phex1_h + +opcd3: ;A,direct done + acall pac +pdirect: + mov a, r3 + jb acc.7,pdir1 +pdir0: mov a, r3 + ajmp phex_h +pdir1: mov dptr,#sfrmnu +pdir2: clr a + movc a,@a+dptr + inc dptr + jz pdir0 + mov r0,a + clr c + subb a, r3 + jnz pdir3 +pstr_h: + ljmp pstr + +pdir3: clr a + movc a,@a+dptr + inc dptr + jnb acc.7,pdir3 + sjmp pdir2 + + +opcd9: ;C,/bit done + acall prc + acall pcomma + mov a, #'/' + acall cout_h +pbit: + mov a, r3 + anl a,#01111000b + rl a + swap a + mov r0,a + mov a, r3 + anl a,#10000000b + jz pbit1 + mov dptr,#bitptr ;it's a Special Function Reg. + mov a,r0 + movc a,@a+dptr + mov dptr,#bitmnu + addc a,dpl + mov dpl,a + jnc pbit0 + inc dph +pbit0: acall pstr_h + sjmp pbit2 +pbit1: mov a,r0 ;it's between 20h and 2Fh + add a,#20h + acall phex_h +pbit2: mov a,#'.' + acall cout_h + mov a, r3 + anl a,#00000111b + ajmp phex1_h + + +opcd10: ;A,direct,rel done + acall pac + acall pdirect +opcd10a:acall pcomma + mov a, r4 + mov r3, a +prel: + mov a, r3 + add a, r6 + mov dpl, a + mov a, r3 + jb acc.7, prel2 + clr a + sjmp prel3 +prel2: clr a + cpl a +prel3: addc a, r7 + mov dph, a + ljmp phex16 + + +pat: ;prints the '@' symbol + mov a,#'@' + ajmp cout_h + +pac: ;print "A," + acall pa +pcomma: ;prints a comma + mov a,#',' + acall cout_h +pspace: mov a, #' ' + ajmp cout_h + +plb: ;prints the '#' symbol + mov a,#'#' + ajmp cout_h + + +opcd6: ;direct,A done + acall pdirect + acall pcomma +pa: ;prints 'A' + mov a,#'A' + ajmp cout_h + +opcd37: ;bit,C done + acall pbit + acall pcomma +prc: ;prints 'C' + mov a,#'C' + ajmp cout_h + +opcd26: ;@A+DPTR done + acall pat + acall pa + mov a,#'+' + acall cout_h +pdptr: ;prints DPTR + mov a, #'D' + acall cout_h + mov a, #'P' + acall cout_h + mov a, #'T' + acall cout_h + mov a, #'R' +cout_h: + ljmp cout + +opcd1: mov a, r7 ;addr11 done + anl a, #11111000b + mov r0, a + mov a, r2 + swap a + rr a + anl a, #00000111b + orl a, r0 + acall phex_h + mov a, r3 + ajmp phex_h + +opcd2: ;A,Rn done + acall pac +p_reg_n:mov a,#'R' + acall cout_h + mov a, r2 + anl a,#00000111b +phex1_h: + ljmp phex1 + + + +opcd5: ;A,#data done + acall pa +pdata: acall pcomma + acall plb + mov a, r3 +phex_h: + ljmp phex + +opcd7: ;direct,#data done + acall pdirect + mov a, r4 + mov r3, a + ajmp pdata +opcd8: ;C,bit done + acall prc + acall pcomma + ajmp pbit + +opcd11: ;A,#data,rel done + acall pa +opcd11a:acall pcomma + acall plb + mov a, r3 + acall phex_h + ajmp opcd10a +opcd12: ;Rn,#data,rel done + acall p_reg_n + ajmp opcd11a +opcd13: ;@Ri,#data,rel done + acall p_reg_i + ajmp opcd11a +opcd19: ;AB done + acall pa + mov a, #'B' + ajmp cout_h +opcd20: ;Rn,rel done + acall p_reg_n + acall pcomma + ajmp prel +opcd21: ;direct,rel done + acall pdirect + ajmp opcd10a +opcd24: ;bit,rel done + acall pbit + ajmp opcd10a +opcd28: ;Rn,A done + acall p_reg_n + acall pcomma + ajmp pa +opcd29: ;Rn,direct done + acall p_reg_n + acall pcomma + ajmp pdirect +opcd30: ;Rn,#data done + acall p_reg_n + ajmp pdata +opcd31: ;direct,Rn done + acall pdirect + acall pcomma + ajmp p_reg_n +opcd32: ;direct,direct done + mov a, r3 + push acc + mov a, r4 + mov r3, a + acall pdirect + acall pcomma + pop acc + mov r3, a + ajmp pdirect +opcd33: ;direct,@Ri done + acall pdirect + acall pcomma + ajmp p_reg_i +opcd34: ;@Ri,A done + acall p_reg_i + acall pcomma + ajmp pa +opcd35: ;@Ri,direct done + acall p_reg_i + acall pcomma + ajmp pdirect +opcd36: ;@Ri,#data done + acall p_reg_i + ajmp pdata +opcd38: ;DPTR,#data16 done + acall pdptr + acall pcomma + acall plb +opcd27: mov a, r3 ;addr16 done + acall phex_h + mov a, r4 + ajmp phex_h +opcd39: ;A,@A+DPTR done + acall pac + acall pat + acall pa + mov a,#'+' + acall cout_h + ajmp pdptr +opcd40: ;A,@A+PC done + acall pac + acall pat + acall pa + mov a,#'+' + acall cout_h + mov a,#'P' + acall cout_h + ajmp prc +opcd41: ;A,@DPTR done + acall pac + acall pat + ajmp pdptr +opcd42: ;@DPTR,A done + acall pat + acall pdptr + acall pcomma + ajmp pa + + + + + +sfrmnu: .db 0xE0,"AC",'C'+128 + .db 0x81,'S','P'+128 + .db 0x82,"DP",'L'+128 + .db 0x83,"DP",'H'+128 + .db 0x80,'P','0'+128 + .db 0x90,'P','1'+128 + .db 0xA0,'P','2'+128 + .db 0xB0,'P','3'+128 + .db 0x99,"SBU",'F'+128 + .db 0xCD,"TH",'2'+128 + .db 0xC8,"T2CO",'N'+128 + .db 0xCC,"TL",'2'+128 + .db 0xCB,"RCAP2",'H'+128 + .db 0xCA,"RCAP2",'L'+128 + .db 0x8C,"TH",'0'+128 + .db 0x8A,"TL",'0'+128 + .db 0x8D,"TH",'1'+128 + .db 0x8B,"TL",'1'+128 +sfr1: .db 0xF0,'B'+128 ;5 +sfr2: .db 0xD0,"PS",'W'+128 ;7 +sfr3: .db 0xA8,'I','E'+128 +sfr4: .db 0xB8,'I','P'+128 +sfr5: .db 0x89,"TMO",'D'+128 ;8 +sfr6: .db 0x88,"TCO",'N'+128 ;8 +sfr7: .db 0x98,"SCO",'N'+128 ;8 +sfr8: .db 0x87,"PCO",'N'+128 ;8 + .db 0 ;just in case + + +opot2: .db 0x59, 0x59, 0x09, 0x09 ;inc, dec, add, addc + .db 0x09, 0x09, 0x09, 0x7A ;orl, anl, xrl, mov + .db 0x7E, 0x09, 0x76, 0x33 ;mov, subb, mov, cjne + .db 0x09, 0x52, 0x09, 0x71 ;xch, djnz, mov, mov + +bitptr: .db 0x00, 0x02, 0x06, 0x08, 0x0C, 0x0E, 0x10, 0x12 + .db 0x14, 0x16, 0x1B, 0x1E, 0x20, 0x23, 0x24, 0x25 + + +;some stuff used by single step... it's here to fill up some of +;the unused space from the end of the disassembler code and the +;beginning of the single-step header (which must begin on a 256 +;byte page boundry) + + +wr_check: ;write to memory and check that it worked. + ;acc=0 if it worked, nonzero if it didn't write + mov r0, a ;keep a copy of the data in r0 + movx @dptr, a + clr a + movc a, @a+dptr + clr c + subb a, r0 + ret + +;delay for approx 1 character transmit time +chardly:mov r1, #80 +chdly2: mov a, th1 + cpl a + inc a + mov r0, a + djnz r0, * + djnz r1, chdly2 + ret + +prcolon:acall phex_h + mov a, #':' + ajmp cout_h + +phexsp: acall phex_h +space_h: + mov a, #' ' + ajmp cout_h + + +;SINGLE +;---------------------------------------------------------; +; ; +; single step command ; +; ; +;---------------------------------------------------------; + +.org locat+0x400 +.db 0xA5,0xE5,0xE0,0xA5 ;signiture +.db 254,step_key,0,0 ;id (254=user installed command) +.db 0,0,0,0 ;prompt code vector +.dB 0,0,0,0 ;reserved +.db 0,0,0,0 ;reserved +.db 0,0,0,0 ;reserved +.db 0,0,0,0 ;user defined +.db 255,255,255,255 ;length and checksum (255=unused) +.db "Single-Step",0 +.org locat+0x440 ;executable code begins here + + + +ssrun: + ;first check to make sure they connect int1 low + jnb p3.3, ssrun2 + mov dptr, #sserr1 ;give error msg if int1 not grounded +pcstr_h: + ljmp pcstr + +ssrun2: ;make sure there's a ljmp at the int1 vector location + mov dptr, #0x0013 + clr a + movc a, @a+dptr + add a, #254 + jz ssrun3 + mov dptr, #sserr2 ;give error that paulmon2 was not found. + ajmp pcstr_h +ssrun3: ;now write an ljmp to "step" in the ram and check it. + inc dptr + movc a, @a+dptr + mov r0, a + clr a + inc dptr + movc a, @a+dptr + mov dpl, a + mov dph, r0 ;now data pointer points to int1 target + mov a, #2 + acall wr_check + jnz ssrun4 + inc dptr + mov a, #(step >> 8) + acall wr_check + jnz ssrun4 + inc dptr + mov a, #(step & 255) + acall wr_check + jz ssrun5 +ssrun4: mov r0, dpl + mov r1, dph + mov dptr, #sserr3 ;error: couldn't write to memory @xxxx + acall pcstr_h + mov a, r1 + acall phex_h + mov a, r0 + acall phex_h + ajmp newline_h +ssrun5: mov a, ip ;set to high priority interrupt + anl a, #00000100b + mov ip, a + ;let's not beat around the bush (like paulmon1), all + ;we need to know is where to jump into memory. + mov dptr, #prompt8 + acall pcstr_h + mov a, r7 + acall phex_h + mov a, r6 + acall phex_h + mov dptr,#prompt4 + acall pcstr_h + lcall ghex16 ;ask for the jump location + jb psw.5, ssrun7 + jnc ssrun6 + mov dptr,#abort + acall pstr_h + ajmp newline_h +ssrun6: mov r6, dpl ;where we'll begin executing + mov r7, dph +ssrun7: clr tcon.2 ;need low-level triggered int1 + mov dptr,#ssmsg ;tell 'em we're starting + acall pcstr_h + mov dptr,#ssnames + acall pstr_h + clr a + mov sp, #8 ;just like after a reset + push acc ;unlike a 8051 start-up, push return addr + push acc ;of 0000, just in case they end w/ ret + mov dpl, r6 ;load the program's address into dptr + mov dph, r7 + mov psw, a ;and clear everything to zero + mov r0, a + mov r1, a + mov r2, a + mov r3, a + mov r4, a + mov r5, a + mov r6, a + mov r7, a + mov b, a + mov lastpc, #ssstart & 255 + mov (lastpc+1), #ssstart >> 8 + setb ie.2 + setb ea ;turn on the interrupt +ssstart:jmp @a+dptr + + +done: acall chardly + pop acc + mov r1, a + pop acc + mov r0, a + pop dpl + pop dph + pop psw + pop acc + reti + +step: ;this is the single step interrupt service code... + push acc + push psw ;Stack Contents: (in this order) + push dph ;PC_L PC_H ACC PSW DPH DPL R0 R1 + push dpl + mov a, r0 + push acc + mov a, r1 + push acc + ;in case the previous instruction was "clr ti", we + ;must wait for a character transmit time "in case it + ;was a move to SBUF) and then set ti so that our cout + ;doesn't hang when we transmit the first character! + acall chardly + setb ti + + ;now print out a line that looks like this: + ;ACC B C DPTR R0 R1 R2 R3 R4 R5 R6 R7 SP PC Instruction + ;00 00 0 3F00 00:00:00:00:00:00:00:00 00 - 0000: LJMP 0825 + + acall space_h + acall space_h + mov a, sp + add a, #251 + mov r0, a ;r0 points to user's acc on stack + mov a, @r0 + acall phexsp ;print acc + mov a, b + acall phexsp ;print b register + inc r0 + mov a, @r0 + rl a + anl a, #1 + acall phex1_h ;print carry bit + acall space_h + inc r0 + mov a, @r0 + acall phex_h ;print dptr (msb) + inc r0 + mov a, @r0 + acall phexsp ;print dptr (lsb) + acall space_h + inc r0 + mov a, @r0 + acall prcolon ;print r0 + inc r0 + mov a, @r0 + acall prcolon ;print r1 + mov a, r2 + acall prcolon ;print r2 + mov a, r3 + acall prcolon ;print r3 + mov a, r4 + acall prcolon ;print r4 + mov a, r5 + acall prcolon ;print r5 + mov a, r6 + acall prcolon ;print r6 + mov a, r7 + acall phexsp ;print r7 + acall space_h + mov a, r0 + add a, #248 + acall phexsp ;print stack pointer + acall space_h + acall space_h + ;now the trick is to disassemble the instruction... this isn't + ;easy, since the user wants to see the last instruction that + ;just executed, but program counter on the stack points to the + ;next instruction to be executed. The dirty trick is to grab + ;the program counter from last time where we stashed it in some + ;memory that hopefully the user's program hasn't overwritten. + mov a, lastpc + mov lastpc, r6 + mov r6, a + mov a, (lastpc+1) + mov (lastpc+1), r7 + mov r7, a + mov a, r2 + push acc + mov a, r3 + push acc + mov a, r4 + push acc + setb psw.1 ;tell it to use a compact format + ;the disassembler uses quite a bit of stack space... if the + ;user didn't leave enough room for the stack to grow with + ;all this overhead, it will likely crash somewhere in the + ;disassembler... oh well, not much I can do about it. The + ;worst case stack usage for disasm is 9 bytes. We just + ;pushed 5 and 6 at the beginning of step. With the two + ;bytes for the interrupt, a total of 22 bytes of free stack + ;space must be available to use the single-step feature. + acall disasm + pop acc + mov r4, a + pop acc + mov r3, a + pop acc + mov r2, a + mov r7, (lastpc+1) + mov r6, lastpc + ;now grab the user's PC value to keep it for next time + mov a, sp + add a, #249 + mov r0, a ;r0 points to user's acc on stack + mov a, @r0 + mov lastpc, a + inc r0 + mov a, @r0 + mov (lastpc+1), a + +;SINGLE STEP + +step1: lcall cin_filter + lcall upper +step2: cjne a, #13, step7 + ajmp done +step7: cjne a, #' ', step8 ;check space + ajmp done +step8: cjne a,#'?',step10 ;check '?' + mov dptr,#help5txt + acall pcstr_h + ajmp step1 +step10: cjne a,#'Q',step11 ;check 'Q'=quit and run normal + mov dptr, #squit + acall pstr_h + clr ie.2 + acall chardly + mov 8, #0 ;force return to 0000 + mov 9, #0 + mov sp, #9 + reti +step11: + cjne a,#'H',step12 ;check 'H'=hex dump internal ram + ajmp ssdmp +step12: cjne a,#'R',step13 ;check 'R'=print out registers + ajmp ssreg +step13: cjne a,#'S',step14 ;check 'S'=skip next inst + ajmp ssskip +step14: cjne a,#'A',step15 ;check 'A'=change acc value + ajmp sschacc +step15: cjne a,#'.',step20 + mov dptr, #ssnames + acall pstr_h + ajmp step1 + +step20: ajmp step1 + + +pequal: ; prints '=' + mov a,#'=' + ajmp cout_h + +ssdmp: + mov dptr, #ssdmps1 + acall pstr_h + clr a + acall prcolon + acall space_h + mov r0, sp + dec r0 + mov a, @r0 + acall phexsp + inc r0 + mov a, @r0 + acall phex_h + mov r0, #2 + mov r1, #14 + ajmp ssdmp2 +ssdmp1: mov a, r0 + acall prcolon + mov r1, #16 +ssdmp2: acall space_h + mov a, @r0 + acall phex_h + inc r0 + djnz r1, ssdmp2 + acall newline_h + cjne r0, #0x80, ssdmp1 + acall newline_h + ajmp step1 + + +ssreg: + mov dptr, #sfr2+1 + acall pstr_h + acall pequal + mov a, sp + add a, #252 + mov r0, a + mov a, @r0 + acall phexsp ;print psw + mov dptr,#sfr3+1 + mov r0, 0xA8 + acall psfr ;print ie + mov dptr,#sfr4+1 + mov r0, 0xB8 + acall psfr ;print ip + mov dptr,#sfr5+1 + mov r0, 0x89 + acall psfr ;print tmod + mov dptr,#sfr6+1 + mov r0, 0x88 + acall psfr ;print tcon + mov dptr,#sfr7+1 + mov r0, 0x98 + acall psfr ;print smod + mov dptr,#sfr8+1 + mov r0, 0x87 + acall psfr ;print pcon + mov a, #'T' + acall cout_h + mov a, #'0' + acall cout_h + acall pequal + mov a, 8Ch + acall phex_h ;print Timer 0 + mov a, 8Ah + acall phex_h + acall space_h + mov a, #'T' + acall cout_h + mov a, #'1' + acall cout_h + acall pequal + mov a, 8Dh ;print Timer 1 + acall phex_h + mov a, 8Bh + acall phex_h + acall newline_h + ajmp step1 + +psfr: acall pstr_h + acall pequal + mov a, r0 + ajmp phexsp + + + +;skip the next instruction +ssskip: + mov r0, #23 +ssskip2:acall space_h + djnz r0, ssskip2 + mov dptr,#sskip1 + acall pstr_h + mov a, sp + add a, #249 + mov r0, a ;set r0 to point to pc on stack + mov a, @r0 + mov lastpc, r6 ;keep r6/r7 safe in lastpc + mov r6, a ;put user's pc into r6/r7 + inc r0 + mov a, @r0 + mov (lastpc+1), r7 + mov r7, a + mov a, r2 + push acc + mov a, r3 + push acc + mov a, r4 + push acc + setb psw.1 ;tell it to use a compact format + acall disasm ;run disasm to show 'em what was skipped + pop acc + mov r4, a + pop acc + mov r3, a + pop acc + mov r2, a + mov a, sp + add a, #249 + mov r0, a ;set r0 to point to pc on stack + mov a, r6 + mov r6, lastpc ;restore r6/r7 + mov lastpc, a ;update lastpc with next inst addr + mov @r0, a ;also update user's pc!! + inc r0 + mov a, r7 + mov r7, (lastpc+1) + mov (lastpc+1), a + mov @r0, a + ajmp step1 + +sschacc: + mov a, sp + add a, #251 + mov r0, a ;r0 points to acc on stack + mov dptr, #chaccs1 + acall pstr_h + lcall ghex + jc chacc2 + jb psw.5, chacc2 + mov @r0, a + acall newline_h + ajmp step1 +chacc2: mov dptr, #abort + acall pstr_h + ajmp step1 + + + + +;stuff some of the disassembler tables, strings, etc since we have a +;bit of space before the beginning of the editor command code + + + ;opcode offset table (gives #bytes for the instruction + ;and the number of the routine to print the operands) + +opot1: .db 0xAD, 0x06, 0x6F, 0x39, 0x39, 0x46, 0x49, 0x49 ;0 + .db 0x63, 0x06, 0x6F, 0x39, 0x39, 0x46, 0x49, 0x49 ;1 + .db 0x63, 0x06, 0xAD, 0x39, 0x16, 0x0E, 0x11, 0x11 ;2 + .db 0x63, 0x06, 0xAD, 0x39, 0x16, 0x0E, 0x11, 0x11 ;3 + .db 0x66, 0x06, 0x1A, 0x1F, 0x16, 0x0E, 0x11, 0x11 ;4 + .db 0x66, 0x06, 0x1A, 0x1F, 0x16, 0x0E, 0x11, 0x11 ;5 + .db 0x66, 0x06, 0x1A, 0x1F, 0x16, 0x0E, 0x11, 0x11 ;6 + .db 0x66, 0x06, 0x22, 0x69, 0x16, 0x1F, 0x92, 0x92 ;7 + .db 0x66, 0x06, 0x22, 0xA1, 0x4D, 0x83, 0x86, 0x86 ;8 + .db 0x9B, 0x06, 0x96, 0x9D, 0x16, 0x0E, 0x11, 0x11 ;9 + .db 0x26, 0x06, 0x22, 0x5D, 0x4D, 0xAD, 0x8E, 0x8E ;A + .db 0x26, 0x06, 0x42, 0x3D, 0x2F, 0x2B, 0x37, 0x37 ;B + .db 0x46, 0x06, 0x42, 0x3D, 0x39, 0x0E, 0x11, 0x11 ;C + .db 0x46, 0x06, 0x42, 0x3D, 0x39, 0x57, 0x11, 0x11 ;D + .db 0xA5, 0x06, 0x11, 0x11, 0x39, 0x0E, 0x11, 0x11 ;E + .db 0xA9, 0x06, 0x89, 0x89, 0x39, 0x1A, 0x89, 0x89 ;F + +mnot1: ;mnunonic offset table (gives offset into above table) + + .db 0x5A, 0x0E, 0x48, 0x73 ;nop, ajmp, ljmp, rr + .db 0x2B, 0x2B, 0x2B, 0x2B ;inc, inc, inc, inc + .db 0x30, 0x00, 0x43, 0x75 ;jbc, acall, lcall rrc + .db 0x21, 0x21, 0x21, 0x21 ; + + .db 0x2E, 0x0E, 0x67, 0x6E ; etc... + .db 0x06, 0x06, 0x06, 0x06 ; + .db 0x38, 0x00, 0x6A, 0x70 ; + .db 0x0A, 0x0A, 0x0A, 0x0A ; + + .db 0x33, 0x0E, 0x5D, 0x5D ; + .db 0x5D, 0x5D, 0x5D, 0x5D ; + .db 0x3B, 0x00, 0x12, 0x12 ; + .db 0x12, 0x12, 0x12, 0x12 ; + + .db 0x41, 0x0E, 0x8F, 0x8F ; + .db 0x8F, 0x8F, 0x8F, 0x8F ; + .db 0x3E, 0x00, 0x5D, 0x35 ; + .db 0x4C, 0x4C, 0x4C, 0x4C ; + + .db 0x7C, 0x0E, 0x12, 0x4F ; + .db 0x24, 0x4C, 0x4C, 0x4C ; + .db 0x4C, 0x00, 0x4C, 0x4F ; + .db 0x80, 0x80, 0x80, 0x80 ; + + .db 0x5D, 0x0E, 0x4C, 0x2B ; + .db 0x57, 0x92, 0x4C, 0x4C ; + .db 0x12, 0x00, 0x1C, 0x1C ; + .db 0x15, 0x15, 0x15, 0x15 ; + + .db 0x63, 0x0E, 0x19, 0x19 ; + .db 0x84, 0x88, 0x88, 0x88 ; + .db 0x60, 0x00, 0x78, 0x78 ; + .db 0x1F, 0x27, 0x8B, 0x8B ; + + .db 0x53, 0x0E, 0x53, 0x53 ; + .db 0x19, 0x4C, 0x4C, 0x4C ; + .db 0x53, 0x00, 0x53, 0x53 ; + .db 0x1C, 0x4C, 0x4C, 0x4C ; + + +mnot2: .db 0x2B, 0x21, 0x06, 0x0A ;inc, dec, add, addc + .db 0x5D, 0x12, 0x8F, 0x4C ;orl, anl, xlr, mov + .db 0x4C, 0x80, 0x4C, 0x15 ;mov, subb, mov, cjne + .db 0x88, 0x27, 0x4C, 0x4C ;xch, djnz, mov, mov + + +;---------------------------------------------------------; +; ; +; External Memory Editor ; +; ; +;---------------------------------------------------------; + +;register usage: +; R4, Flags: +; bit0: 0=display CODE memory, 1=display DATA memory +; bit1: 0=editing disabled, 1=editing enabled +; bit2: 0=editing in hex, 1=editing in ascii +; bit3: 0=normal, 1=in middle of hex entry (value in r5) +; R6/R7, current memory location +; + +.org locat+0x800 +.db 0xA5,0xE5,0xE0,0xA5 ;signiture +.db 254,vtedit_key,0,0 ;id (254=user installed command) +.db 0,0,0,0 ;prompt code vector +.dB 0,0,0,0 ;reserved +.db 0,0,0,0 ;reserved +.db 0,0,0,0 ;reserved +.db 0,0,0,0 ;user defined +.db 255,255,255,255 ;length and checksum (255=unused) +.db "Memory Editor (VT100)",0 + +.org locat+0x0840 ;executable code begins here + + + mov r4, #0 + acall redraw +main: + mov a, r4 + clr acc.3 + mov r4, a +main2: lcall cin_filter + acall input_ck_2nd +cmd1: cjne a, #27, cmd2 ;quit + ajmp quit +cmd2: cjne a, #11, cmd3 ;up + ajmp cmd_up +cmd3: cjne a, #10, cmd4 ;down + ajmp cmd_down +cmd4: cjne a, #8, cmd5 ;left + ajmp cmd_left +cmd5: cjne a, #21, cmd6 ;right + ajmp cmd_right +cmd6: cjne a, #12, cmd7 ;redraw + acall redraw + ajmp main +cmd7: cjne a, #17, cmd8 ;quit + ajmp quit +cmd8: cjne a, #3, cmd9 ;code memory + mov a, r4 + anl a, #11111110b + mov r4, a + acall cursor_home + mov dptr, #str_code + acall pstr_hh + acall redraw_data + ajmp main +cmd9: cjne a, #4, cmd10 ;data memory + mov a, r4 + orl a, #00000001b + mov r4, a + acall cursor_home + mov dptr, #str_data + acall pstr_hh + acall redraw_data + ajmp main +cmd10: cjne a, #7, cmd11 ;goto memory loc + ajmp cmd_goto +cmd11: cjne a, #5, cmd12 ;toggle editing + ajmp cmd_edit +cmd12: cjne a, #6, cmd13 ;fill memory + ajmp cmd_fill +cmd13: cjne a, #1, cmd14 ;edit in ascii + mov a, r4 + jnb acc.1, main + setb acc.2 + mov r4, a + acall erase_commands + acall print_commands + acall redraw_cursor + ajmp main +cmd14: cjne a, #24, cmd15 ;edit in hex + mov a, r4 + jnb acc.1, main + clr acc.2 + mov r4, a + acall erase_commands + acall print_commands + acall redraw_cursor + ajmp main +cmd15: cjne a, #25, cmd16 ;page up + ajmp cmd_pgup +cmd16: cjne a, #26, cmd17 ;page down + ajmp cmd_pgdown +cmd17: + + +cmd_data: ;the input character wasn't any particular command, so + ;maybe it's some input data being typed for edit mode + mov b, a ;keep a copy of user data in b + mov a, r4 + jb acc.1, cmd_data2 +cmd_abort: + ajmp main ;ignore if not in edit mode +cmd_data2: + jnb acc.2, input_hex +input_ascii: + mov a, b + acall ascii_only + cjne a, b, cmd_abort ;check that input is an ascii char + mov dph, r7 + mov dpl, r6 + lcall smart_wr ;write the char to memory + ajmp cmd_right + +input_hex: + mov a, b + lcall upper + lcall asc2hex + jc cmd_abort ;ignore if not hex + mov r0, a ;keep hex value of input in r0 + mov dph, r7 ;load dptr with address + mov dpl, r6 + mov a, r4 + jb acc.3, input_hex_2nd +input_hex_1st: + mov a, r0 + mov r5, a + mov a, r4 + setb acc.3 ;remember that we're waiting for 2nd char + mov r4, a + acall redraw_cursor + ajmp main2 +input_hex_2nd: + mov a, r5 ;get data from memory + swap a ;shift nibbles + anl a, #11110000b ;just in case + add a, r0 ;add in this input to lower part + lcall smart_wr ;write back to memory + mov a, r4 + clr acc.3 + mov r4, a + ajmp cmd_right + +input_ck_2nd: + ;the main input routine will always call here when a new + ;byte is entered... so we can do something special if we + ;were waiting for the second character and it is not a + ;legal hex character + push acc + mov a, r4 + jb acc.1, inck2d + ;if editing is disabled, don't do anything + clr acc.3 +inck2b: mov r4, a +inck2c: pop acc + ret +inck2d: jnb acc.3, inck2b + ;if we get here, we were actually waiting for the 2nd char + pop acc + push acc + lcall upper + lcall asc2hex + jnc inck2c ;proceed normally if it is valid + ;if we get here, we did not get a hex legal char + pop acc + push acc + cjne a, #esc_char, inck2e + mov a, r4 + clr acc.3 + mov r4, a + acall redraw_cursor + pop acc + pop acc ;don't return and do the quit cmd + pop acc ;just quit this entry and wait for next cmd + ajmp main +inck2e: mov dph, r7 ;load dptr with address + mov dpl, r6 + mov a, r5 + lcall smart_wr ;write to memory + mov a, r4 + clr acc.3 + mov r4, a + acall redraw_cursor + sjmp inck2c + +; R4, Flags: +; bit0: 0=display CODE memory, 1=display DATA memory +; bit1: 0=editing disabled, 1=editing enabled +; bit2: 0=editing in hex, 1=editing in ascii +; bit3: 0=normal, 1=in middle of hex entry (value in r5) + + +cmd_fill: + mov a, r4 + anl a, #00000010b + jnz cmd_fill_ok + ajmp main ;don't allow if not in editing mode +cmd_fill_ok: + acall erase_commands + mov a, r4 + push acc + mov dptr, #fill_prompt1 + acall pcstr_hh + lcall ghex16 + jc cmd_fill_abort + jb psw.5, cmd_fill_abort + mov r0, dpl + mov r1, dph + mov dptr, #fill_prompt2 + acall pstr_hh + lcall ghex16 + jc cmd_fill_abort + jb psw.5, cmd_fill_abort + mov r4, dpl + mov r5, dph + mov dptr, #fill_prompt3 + acall pcstr_hh + lcall ghex + jc cmd_fill_abort + jb psw.5, cmd_fill_abort + mov r2, a + mov a, r4 + mov r6, a + mov a, r5 + mov r7, a + pop acc + mov r4, a + mov dpl, r0 + mov dph, r1 + ;now r4 is restored to its normal value, dptr holds the + ;first location to fill, and r6/r7 holds the last location to + ;fill, and r2 has the fill value. +cmd_fill_loop: + mov a, r2 + lcall smart_wr + mov a, r6 + cjne a, dpl, cmd_fill_next + mov a, r7 + cjne a, dph, cmd_fill_next + ;when we get here, we're done! + acall erase_commands + acall print_commands + acall redraw_data + ajmp main +cmd_fill_next: + inc dptr + sjmp cmd_fill_loop + +cmd_fill_abort: + pop acc + mov r4, a + acall erase_commands + acall print_commands + acall redraw_cursor + ajmp main + +fill_prompt1: + .db "Fill",31,131,"; First: ",0 +fill_prompt2: + .db " Last: ",0 +fill_prompt3: + .db " ",168,": ",0 + +cmd_edit: + acall erase_commands + mov a, r4 + xrl a, #00000010b + mov r4, a + acall print_commands + acall redraw_cursor + ajmp main + +cmd_goto: + acall erase_commands + mov dptr, #goto_prompt + acall pcstr_hh + mov a, r4 + push acc + lcall ghex16 + pop acc + mov r4, a + jc cmdgt_abort + jb psw.5, cmdgt_abort + mov r6, dpl + mov r7, dph + acall cursor_home + mov a, #20 + acall cursor_down + acall print_commands + acall redraw_data + ajmp main +cmdgt_abort: + acall cursor_home + mov a, #20 + acall cursor_down + acall print_commands + acall redraw_cursor + ajmp main + + +goto_prompt: + .db 31,131,31,129,": ",0 + +cmd_up: + acall blank_it + mov a, r6 + clr c + subb a, #16 + mov r6, a + mov a, r7 + subb a, #0 + mov r7, a + mov a, r6 + cpl a + anl a, #11110000b + jz cmd_up_scroll + mov a, #1 + acall cursor_up + acall invert_it + ajmp main +cmd_up_scroll: + acall redraw_data + ajmp main + +cmd_pgup: + dec r7 + acall redraw_data + ajmp main + +cmd_pgdown: + inc r7 + acall redraw_data + ajmp main + +cmd_down: + acall blank_it + mov a, r6 + add a, #16 + mov r6, a + mov a, r7 + addc a, #0 + mov r7, a + mov a, r6 + anl a, #11110000b + jz cmd_down_scroll + mov a, #1 + acall cursor_down + acall invert_it + ajmp main +cmd_down_scroll: + acall redraw_data + ajmp main + + +cmd_left: + acall blank_it + mov a, #3 + acall cursor_left + mov a, r6 + clr c + subb a, #1 + mov r6, a + mov a, r7 + subb a, #0 + mov r7, a + mov a, r6 + orl a, #11110000b + cpl a + jz cmdlf2 + acall invert_it + ajmp main +cmdlf2: + mov a, r6 + cpl a + anl a, #11110000b + jz cmd_left_scroll + mov a, #48 + acall cursor_right + mov a, #1 + acall cursor_up + acall invert_it + ajmp main +cmd_left_scroll: + acall redraw_data + ajmp main + + +cmd_right: + acall blank_it + mov a, #3 + acall cursor_right + mov dpl, r6 + mov dph, r7 + inc dptr + mov r6, dpl + mov r7, dph + mov a, r6 + anl a, #00001111b + jz cmdrt2 + acall invert_it + ajmp main + +cmdrt2: + mov a, r6 + anl a, #11110000b + jz cmd_right_scroll + mov a, #48 + acall cursor_left + mov a, #1 + acall cursor_down + acall invert_it + ajmp main +cmd_right_scroll: + acall redraw_data + ajmp main + + +space: mov a, #' ' + ajmp cout_hh + + + +;register usage: +; R4, Flags: +; bit0: 0=display CODE memory, 1=display DATA memory +; bit1: 0=editing disabled, 1=editing enabled +; bit2: 0=editing in hex, 1=editing in ascii +; bit3: 0=normal, 1=in middle of hex entry (value in r5) +; R6/R7, current memory location +; + + +redraw: + mov dptr, #str_cl ;clear screen + acall pstr_hh + acall print_title_line + acall newline_hh + acall print_addr_line + acall newline_hh + acall print_dash_line + acall newline_hh + mov a, #16 + acall cursor_down + acall print_dash_line + acall newline_hh + acall print_commands +redraw_data: + acall cursor_home + mov a, #2 + acall cursor_down + ;compute first byte address to display on the screen + mov dpl, #0 + mov dph, r7 + ;now display the data + mov r0, #16 +rd2: acall newline_hh + lcall phex16 + mov a, #':' + acall cout_hh + mov r2, dpl + mov r3, dph +rd3: acall space + acall read_dptr + acall phex_hh + inc dptr + mov a, dpl + anl a, #00001111b + jnz rd3 + mov dpl, r2 + mov dph, r3 + acall space + acall space + acall space +rd4: acall read_dptr + acall ascii_only + acall cout_hh + inc dptr + mov a, dpl + anl a, #00001111b + jnz rd4 + djnz r0, rd2 + +redraw_cursor: + acall cursor_home + mov a, r6 + swap a + anl a, #00001111b + add a, #3 + acall cursor_down + ;make the ascii character inverse + mov a, r6 + anl a, #00001111b + add a, #56 + acall cursor_right + acall inverse_on + acall read_r6r7 + acall ascii_only + acall cout_hh + acall inverse_off + + ;now make the hex value inverse + mov a, r6 + anl a, #00001111b + rl a + cpl a + add a, #52 + acall cursor_left + acall inverse_on + acall read_r6r7 + acall phex_hh + ajmp inverse_off + + +blank_it: + mov a, r6 + anl a, #00001111b + rl a + cpl a + add a, #49 + acall cursor_right + acall read_r6r7 + acall ascii_only + acall cout_hh + mov a, r6 + anl a, #00001111b + rl a + cpl a + add a, #52 + acall cursor_left + acall read_r6r7 + ajmp phex_hh + +invert_it: + mov a, r6 + anl a, #00001111b + rl a + cpl a + add a, #49 + acall cursor_right + acall read_r6r7 + acall ascii_only + acall inverse_on + acall cout_hh + acall inverse_off + mov a, r6 + anl a, #00001111b + rl a + cpl a + add a, #52 + acall cursor_left + acall read_r6r7 + acall inverse_on + acall phex_hh + ajmp inverse_off + + + + + + +quit: mov a, r6 + anl a, #11110000b + swap a + cpl a + add a, #19 + acall cursor_down + ajmp newline_hh + + +ascii_only: + anl a, #01111111b ;avoid unprintable characters + cjne a, #127, aonly2 + mov a, #' ' + ret +aonly2: clr c + subb a, #32 + jnc aonly3 ;avoid control characters + mov a, #(' ' - 32) +aonly3: add a, #32 + ret + + + + + +read_dptr: + mov a, r4 + jb acc.0, rddptr2 + clr a + movc a, @a+dptr + ret +rddptr2:movx a, @dptr + ret + +read_r6r7: + push dph + push dpl + mov dph, r7 + mov dpl, r6 + mov a, r4 + jb acc.3, rdr6r7d + jb acc.0, rdr6r7b + clr a + movc a, @a+dptr + sjmp rdr6r7c +rdr6r7b:movx a, @dptr +rdr6r7c:pop dpl + pop dph + ret +rdr6r7d:mov a, r5 + sjmp rdr6r7c + + +.equ esc_char, 27 + +cursor_home: + acall term_esc + mov a, #'H' + ajmp cout_hh + +cursor_down: ;acc is # of lines to move down + acall term_esc + acall pint_hh + mov a, #'B' + ajmp cout_hh + +cursor_up: ;acc is # of lines to move up + acall term_esc + acall pint_hh + mov a, #'A' + ajmp cout_hh + +cursor_left: ;acc is # of characters to move left + acall term_esc + acall pint_hh + mov a, #'D' + ajmp cout_hh + +cursor_right: ;acc is # of characters to move right + acall term_esc + acall pint_hh + mov a, #'C' + ajmp cout_hh + +inverse_on: + mov dptr, #str_so + ajmp pstr_hh + +str_so: .db esc_char, "[0;7m", 0 + +inverse_off: + mov dptr, #str_se + ajmp pstr_hh + +str_se: .db esc_char, "[0m", 0 + + +term_esc: + push acc + mov a, #esc_char + acall cout_hh + mov a, #'[' + acall cout_hh + pop acc + ret + +print_addr_line: + mov dptr, #str_addr + acall pstr_hh + mov r0, #0 +paddrl: acall space + mov a, #'+' + acall cout_hh + mov a, r0 + lcall phex1 + inc r0 + cjne r0, #16, paddrl + mov dptr, #str_ascii_equiv + ajmp pstr_hh + + +print_dash_line: + mov r0, #72 +pdashl: mov a, #'-' + acall cout_hh + djnz r0, pdashl + ret + +print_title_line: + mov a, r4 + jb acc.0, ptitle2 + mov dptr, #str_code + sjmp ptitle3 +ptitle2:mov dptr, #str_data +ptitle3:acall pstr_hh + mov r0, #8 +ptitlel:acall space + djnz r0, ptitlel + mov dptr, #str_title + ajmp pcstr_hh + +erase_commands: + acall cursor_home + mov a, #20 + acall cursor_down + mov r2, #72 +ercmd2: acall space + djnz r2, ercmd2 + mov a, #72 + ajmp cursor_left + + +; R4, Flags: +; bit0: 0=display CODE memory, 1=display DATA memory +; bit1: 0=editing disabled, 1=editing enabled +; bit2: 0=editing in hex, 1=editing in ascii +; bit3: 0=normal, 1=in middle of hex entry (value in r5) + +print_commands: + mov a, r4 + jnb acc.1, pcmd_no_edit + mov dptr, #str_cmd3 + jb acc.2, pcmd_ascii + mov dptr, #str_cmd4 +pcmd_ascii: + acall pstr_hh + mov dptr, #str_cmd5 + acall pstr_hh + sjmp pcmd_finish +pcmd_no_edit: + mov dptr, #str_cmd2 + acall pstr_hh +pcmd_finish: + mov dptr, #str_cmd1 + ajmp pstr_hh + +str_cmd1: .db " ^G=Goto ^C=Code ^D=Data ^L=Redraw ^Q=Quit", 0 +str_cmd2: .db "^E-Edit",0 +str_cmd3: .db "^A=", esc_char, "[0;7m", "ASCII", esc_char, "[0m", " ^X=Hex", 0 +str_cmd4: .db "^A=ASCII ^X=", esc_char, "[0;7m", "Hex", esc_char, "[0m", 0 +str_cmd5: .db " ^F=Fill",0 + + +str_cl: .db esc_char, "[H", esc_char, "[2J", 0 + +str_addr: .db "ADDR:",0 +str_ascii_equiv: .db " ASCII EQUIVILANT",0 +str_title: .db "8051",31,154,31,131,31,216,"or,",31,248,31,254,", 1996",0 +str_code: .db "CODE",0 +str_data: .db "DATA",0 + + +cout_hh:ljmp cout +phex_hh:ljmp phex +pstr_hh:ljmp pstr +newline_hh:ljmp newline +pcstr_hh:ljmp pcstr +pint_hh:ljmp pint + + + +;---------------------------------------------------------; +; ; +; single step strings ; +; ; +;---------------------------------------------------------; + + + +prompt4:.db "), or to exit: ",0 +prompt8:.db 13,31,136,128,131,129," (",0 +abort: .db " Command Aborted.",13,10,0 + + +sserr1: .db 13,161,197," connect INT1 (pin 13) low" + .db 128,186,207,204,13,0 +sserr2: .db 148,"2",179,199,174,129," 0013",13,0 +sserr3: .db 31,184,179,255,165," vector",174," ",0 +ssmsg: .db 13,"Now",134,"ning",166,207,204," mode: " + .db "=",204,", ?= Help",13,13,0 + +sskip1: .db "Skipping Instruction-> ",0 +ssdmps1:.db 13,10,"Loc: Int RAM Memory Contents",13,10,0 +chaccs1:.db "New Acc Value: ",0 + +help5txt:.db 13 + .db 31,207,31,204,31,158,":",13 + .db " ",134,212,246,13 + .db " ",134,212,246,13 + .db " '?' ",255,142,215,13 + .db " '.' ",255,196,253,"s",13 + .db " 'R' ",255," special function",196,"s",13 + .db " 'H' ",132,219,192,146,13 + .db " 'S' ",252,212,246,13 + .db " 'A' ",240,162," Acc value",13 + .db " 'Q' ",200,207,204,13,14 + +squit: .db "Quit",13,10,0 + +ssnames:.db " ACC B C DPTR R0 R1 R2 R3 R4 R5 R6 R7 SP" + .db " Addr Instruction",13,10,0 + + +;---------------------------------------------------------; +; ; +; disassembler data ; +; ; +;---------------------------------------------------------; + + + +mnu_tbl:.db "ACAL",'L'+128 + .db 0 + .db "AD",'D'+128 + .db 0 + .db "ADD",'C'+128 + .db "AJM",'P'+128 + .db "AN",'L'+128 + .db "CJN",'E'+128 + .db "CL",'R'+128 + .db "CP",'L'+128 + .db "D",'A'+128 + .db "DE",'C'+128 + .db "DI",'V'+128 + .db "DJN",'Z'+128 + .db "IN",'C'+128 + .db "J",'B'+128 + .db "JB",'C'+128 + .db "J",'C'+128 + .db "JM",'P'+128 + .db "JN",'B'+128 + .db "JN",'C'+128 + .db "JN",'Z'+128 + .db "J",'Z'+128 + .db "LCAL",'L'+128 + .db "LJM",'P'+128 + .db "MO",'V'+128 + .db "MOV",'C'+128 + .db "MOV",'X'+128 + .db "MU",'L'+128 + .db "NO",'P'+128 + .db "OR",'L'+128 + .db "PO",'P'+128 + .db "PUS",'H'+128 + .db "RE",'T'+128 + .db "RET",'I'+128 + .db "R",'L'+128 + .db "RL",'C'+128 + .db "R",'R'+128 + .db "RR",'C'+128 + .db "SET",'B'+128 + .db "SJM",'P'+128 + .db "SUB",'B'+128 + .db "SWA",'P'+128 + .db "XC",'H'+128 + .db "XCH",'D'+128 + .db "XR",'L'+128 + .db "??",'?'+128 + + + +bitmnu: .db 'P','0'+128 + .db "TCO",'N'+128 + .db 'P','1'+128 + .db "SCO",'N'+128 + .db 'P','2'+128 + .db 'I','E'+128 + .db 'P','3'+128 + .db 'I','P'+128 + .db 'C','0'+128 + .db "T2CO",'N'+128 + .db "PS",'W'+128 + .db 'D','8'+128 + .db "AC",'C'+128 + .db 'E'+'8'+128 + .db 'B'+128 + .db 'F'+'8'+128 + + diff --git a/examples/extra.ref b/examples/extra.ref new file mode 100644 index 0000000..257c5bf --- /dev/null +++ b/examples/extra.ref @@ -0,0 +1,244 @@ +:10100000A5E5E0A5FE4C0000000000000000000087 +:10101000000000000000000000000000FFFFFFFFD4 +:081020004C69737400020048E2 +:1010400011257D14C2D1114CDDFC0125EFF5835132 +:101050004FEEF582514FE493FAA3E493FBA3E4939C +:10106000FCEA5408700FEA035478F8EA54074890F1 +:1010700016C8938008EAC4540F901362935403F87F +:101080002EFEEF3400FF743A512A719D20D121EADF +:10109000514F719DB80104790B8011EB514F719D37 +:1010A000B8020479088005EC514F7906719DD9FC8E +:1010B000EA54087010901748EA035478F8EA540785 +:1010C0004893F980099017C8EAC4540F93F9901E09 +:1010D000FE7808C374204007E99309A2E7547F51C2 +:1010E0002AD8F1741BC0E07411C0E0EA5408700FF4 +:1010F000EA035478F8EA5407489016C8938008EA3F +:10110000C4540F9013629354FC03031490111D23D5 +:101110002582F582E43583F583E4730125412D4171 +:101120003C21812172414841044152415821A22170 +:10113000D7415E4169416D4108411021AA218321B7 +:101140007441714177417D413E411C418121DF4124 +:101150001441C54185418B41914195419B41A94134 +:10116000AF41B541BB410C41BF41CB41D741E74104 +:10117000ED2231F67440512A7452512AEA54014149 +:101180004531F6EB20E703EB414F9012F5E493A3D2 +:1011900060F5F8C39B7003020038E493A330E7FACC +:1011A00080EB511031F8742F512AEB547823C4F896 +:1011B000EB54806014901372E893901F933582F57E +:1011C000825002058331978005E82420514F742E08 +:1011D000512AEB5407414531F6318331F8ECFBEBF2 +:1011E0002EF582EB20E703E48002E4F43FF583026E +:1011F00000367440412A5108742C512A7420412A27 +:101200007423412A318331F87441412A31AA31F8DB +:101210007443412A31F25108742B512A7444512AE3 +:101220007450512A7454512A7452020030EF54F809 +:10123000F8EAC403540748514FEB414F31F674525A +:10124000512AEA540702002E510831F85100EB02EE +:1012500000343183ECFB414A511031F821AA510886 +:1012600031F85100EB514F21DB513E416031744167 +:101270006051087442412A513E31F821DF31832107 +:10128000DB31AA21DB513E31F84108513E31F821D2 +:1012900083513E414A318331F8413EEBC0E0ECFBE3 +:1012A000318331F8D0E0FB2183318331F82174316F +:1012B0007431F84108317431F821833174414A5155 +:1012C0001C31F85100EB514FEC414F31F631F251E6 +:1012D00008742B512A411C31F631F25108742B51FC +:1012E0002A7450512A411031F631F2411C31F25129 +:1012F0001C31F84108E04143C38153D0824450CCB3 +:10130000834450C88050B09050B1A050B2B050B398 +:1013100099534255C6CD5448B2C85432434FCECCEF +:10132000544CB2CB5243415032C8CA52434150325E +:10133000CC8C5448B08A544CB08D5448B18B544C2A +:10134000B1F0C2D05053D7A849C5B849D089544D3F +:101350004FC48854434FCE9853434FCE8750434F8A +:10136000CE00595909090909097A7E0976330952CB +:101370000971000206080C0E101214161B1E202301 +:101380002425F8F0E493C398227950E58DF404F80D +:10139000D8FED9F722514F743A412A514F74204157 +:0113A0002A22 +:10140000A5E5E0A5FE53000000000000000000007C +:10141000000000000000000000000000FFFFFFFFD0 +:0C14200053696E676C652D537465700095 +:1014400030B306901D85020045900013E49324FEFE +:101450006005901DA88146A393F8E4A393F58288C4 +:101460008374027182700EA3741471827007A37466 +:10147000EF71826011A882A983901DB59146E95150 +:101480004FE8514F0125E5B85404F5B8901D689117 +:1014900046EF514FEE514F901D52914612003C20A5 +:1014A000D50D5007901D7131970125AE82AF83C2D3 +:1014B0008A901DC49146901EBC3197E4758108C086 +:1014C000E0C0E08E828F83F5D0F8F9FAFBFCFDFED8 +:1014D000FFF5F0757CDD757D14D2AAD2AF737189EA +:1014E000D0E0F9D0E0F8D082D083D0D0D0E032C0C4 +:1014F000E0C0D0C083C082E8C0E0E9C0E07189D21A +:1015000099719D719DE58124FBF8E6719BE5F07171 +:101510009B08E62354015145719D08E6514F08E6AA +:10152000719B719D08E6719508E67195EA7195EBDE +:101530007195EC7195ED7195EE7195EF719B719DC3 +:10154000E824F8719B719D719DE57C8E7CFEE57DA4 +:101550008F7DFFEAC0E0EBC0E0ECC0E0D2D1114CDF +:10156000D0E0FCD0E0FBD0E0FAAF7DAE7CE581249A +:10157000F9F8E6F57C08E6F57D120062120040B449 +:101580000D0281DEB4200281DEB43F07901E35914A +:1015900046A179B45113901EB53197C2AA718975CD +:1015A000080075090075810932B44802A1CDB45212 +:1015B00002A1FDB45302C167B44102C1AAB42E070F +:1015C000901EBC3197A179A179743D412A901E03E8 +:1015D0003197E47195719DA88118E6719B08E651D9 +:1015E0004F7802790EA1ECE871957910719DE65162 +:1015F0004F08D9F81125B880EE1125A17990134430 +:101600003197B1C9E58124FCF8E6719B901348A895 +:10161000A8D16090134BA8B8D16090134EA889D17F +:1016200060901353A888D160901358A898D1609007 +:10163000135DA887D1607454512A7430512AB1C9FE +:10164000E58C514FE58A514F719D7454512A743184 +:10165000512AB1C9E58D514FE58B514F1125A17923 +:101660003197B1C9E8619B7817719DD8FC901DEB4B +:101670003197E58124F9F8E68E7CFE08E68F7DFF40 +:10168000EAC0E0EBC0E0ECC0E0D2D1114CD0E0FC0D +:10169000D0E0FBD0E0FAE58124F9F8EEAE7CF57CF1 +:1016A000F608EFAF7DF57DF6A179E58124FBF89092 +:1016B0001E25319712003A400820D505F61125A1C4 +:1016C00079901D713197A179AD066F393946494935 +:1016D00063066F39394649496306AD39160E111153 +:1016E0006306AD39160E111166061A1F160E11117A +:1016F00066061A1F160E111166061A1F160E111114 +:1017000066062269161F9292660622A14D8386867E +:101710009B06969D160E11112606225D4DAD8E8EEE +:101720002606423D2F2B37374606423D390E111112 +:101730004606423D39571111A5061111390E1111F6 +:10174000A9068989391A89895A0E48732B2B2B2BA4 +:1017500030004375212121212E0E676E06060606F4 +:1017600038006A700A0A0A0A330E5D5D5D5D5D5DD0 +:101770003B00121212121212410E8F8F8F8F8F8F19 +:101780003E005D354C4C4C4C7C0E124F244C4C4C66 +:101790004C004C4F808080805D0E4C2B57924C4CFF +:1017A00012001C1C15151515630E191984888888DC +:1017B000600078781F278B8B530E5353194C4C4C79 +:1017C000530053531C4C4C4C2B21060A5D128F4C7A +:0817D0004C804C1588274C4C9D +:10180000A5E5E0A5FE450000000000000000000086 +:10181000000000000000000000000000FFFFFFFFCC +:101820004D656D6F727920456469746F722028561A +:06183000543130302900A4 +:101840007C0051C6ECC2E3FC1200623119B41B02E9 +:10185000618DB40B024124B40A02414BB408024129 +:1018600066B415024195B40C0451C60144B411028A +:10187000618DB4030FEC54FEFC71CF901D36B14660 +:1018800051E10144B4040FEC4401FC71CF901D3BC5 +:10189000B14651E10144B4070221ECB4050221E054 +:1018A000B406022159B4010FEC30E198D2E2FC9168 +:1018B00054916471210144B4180FEC30E186C2E206 +:1018C000FC9154916471210144B419024141B41A4C +:1018D000024146F5F0EC20E102014430E210E5F06F +:1018E0007198B5F0F48F838E821200564195E5F021 +:1018F00012004012006540E1F88F838E82EC20E3F5 +:101900000AE8FDECD2E3FC71210148EDC454F02853 +:10191000120056ECC2E3FC4195C0E0EC20E106C2A7 +:10192000E3FCD0E02230E3F9D0E0C0E01200401246 +:10193000006550EED0E0C0E0B41B0EECC2E3FC71D9 +:1019400021D0E0D0E0D0E001448F838E82ED120000 +:1019500056ECC2E3FC712180C9EC540270020144D0 +:101960009154ECC0E09019C2B14C12003C404820A8 +:10197000D545A882A9839019D2B14612003C4037C0 +:1019800020D534AC82AD839019DBB14C12003A40C3 +:101990002620D523FAECFEEDFFD0E0FC8882898377 +:1019A000EA120056EEB5820CEFB5830891549164AB +:1019B00051E10144A380E9D0E0FC9154916471218C +:1019C000014446696C6C1F833B2046697273743A0C +:1019D000200020204C6173743A200020A83A200097 +:1019E0009154EC6402FC9164712101449154901A69 +:1019F0001DB14CECC0E012003CD0E0FC401320D5FF +:101A000010AE82AF8371CF741471D5916451E1012E +:101A10004471CF741471D59164712101441F831FE7 +:101A2000813A2000714DEEC39410FEEF9400FFEE5A +:101A3000F454F06008740171DD7169014451E101F1 +:101A4000441F51E101440F51E10144714DEE241056 +:101A5000FEEF3400FFEE54F06008740171D5716937 +:101A6000014451E10144714D740371E5EEC39401E9 +:101A7000FEEF9400FFEE44F0F4600471690144EE5F +:101A8000F454F0600C743071ED740171DD71690112 +:101A90004451E10144714D740371ED8E828F83A333 +:101AA000AE82AF83EE540F600471690144EE54F0CE +:101AB000600C743071E5740171D57169014451E1B4 +:101AC00001447420A140901CFCB146913BB1499166 +:101AD00018B1499132B149741071D59132B149911F +:101AE0006471CF740271D57582008F837810B1490B +:101AF000120036743AB140AA82AB8351C271AAB1C6 +:101B000043A3E582540F70F38A828B8351C251C282 +:101B100051C271AA7198B140A3E582540F70F3D8F5 +:101B2000CD71CFEEC4540F240371D5EE540F243879 +:101B300071ED71F571B37198B1409101EE540F23BD +:101B4000F4243471E571F571B3B1438101EE540FA2 +:101B500023F4243171ED71B37198B140EE540F2329 +:101B6000F4243471E571B3A143EE540F23F424310E +:101B700071ED71B3719871F5B1409101EE540F237D +:101B8000F4243471E571B371F5B1438101EE54F081 +:101B9000C4F4241371D5A149547FB47F0374202267 +:101BA000C3942050027400242022EC20E003E4932C +:101BB00022E022C083C0828F838E82EC20E30D203E +:101BC000E004E4938001E0D082D08322ED80F8919C +:101BD0000B7448A140910BB14F7442A140910BB1DD +:101BE0004F7441A140910BB14F7444A140910BB18E +:101BF0004F7443A140901BFAA1461B5B303B376DED +:101C000000901C06A1461B5B306D00C0E0741BB148 +:101C100040745BB140D0E022901D04B14678005181 +:101C2000C2742BB140E812002E08B810F2901D0AC1 +:101C3000A1467848742DB140D8FA22EC20E00590F6 +:101C40001D368003901D3BB146780851C2D8FC90E8 +:101C50001D1EA14C71CF741471D57A4851C2DAFCA3 +:101C6000744861E5EC30E112901CBC20E203901C4A +:101C7000D7B146901CF2B1468005901CB4B1469095 +:101C80001C84A14620205E473D476F746F20205E74 +:101C9000433D436F646520205E443D446174612090 +:101CA000205E4C3D52656472617720205E513D514B +:101CB000756974005E452D45646974005E413D1B85 +:101CC0005B303B376D41534349491B5B306D2020EE +:101CD0005E583D486578005E413D41534349492087 +:101CE000205E583D1B5B303B376D4865781B5B3091 +:101CF0006D0020205E463D46696C6C001B5B481BF6 +:101D00005B324A00414444523A0020202041534370 +:101D10004949204551554956494C414E54003830A7 +:101D200035311F9A1F831FD86F722C1FF81FFE2C8E +:101D3000203139393600434F444500444154410075 +:101D4000020030020034020038020048020045025E +:101D50000050292C206F72203C4553433E20746F65 +:101D600020657869743A20000D1F888083812028BF +:101D70000020436F6D6D616E642041626F72746507 +:101D8000642E0D0A000DA1C520636F6E6E6563742D +:101D900020494E5431202870696E20313329206C3F +:101DA0006F7780BACFCC0D009432B3C7AE812030AC +:101DB0003031330D001FB8B3FFA520766563746F13 +:101DC00072AE20000D4E6F77866E696E67A6CFCC1F +:101DD000206D6F64653A20203C5245543E3DCC2C2A +:101DE000203F3D2048656C700D0D00536B6970708D +:101DF000696E6720496E737472756374696F6E2DB6 +:101E00003E20000D0A4C6F633A2020496E74205228 +:101E1000414D204D656D6F727920436F6E74656E14 +:101E200074730D0A004E6577204163632056616C20 +:101E300075653A20000D1FCF1FCC1F9E3A0D3C52F6 +:101E400045543E2086D4F60D203C53503E2086D487 +:101E5000F60D20273F272020FF8ED70D20272E2785 +:101E60002020FFC4FD730D202752272020FF207360 +:101E700070656369616C2066756E6374696F6EC4AA +:101E8000730D20274827202084DBC0920D20275384 +:101E9000272020FCD4F60D202741272020F0A22067 +:101EA0004163632076616C75650D202751272020E2 +:101EB000C8CFCC0D0E517569740D0A002020414326 +:101EC000432042204320445054522020523020527C +:101ED0003120523220523320523420523520523693 +:101EE000205237202053502020204164647220204B +:101EF000496E737472756374696F6E0D0A004143A5 +:101F0000414CCC004144C400414444C3414A4DD0FB +:101F1000414ECC434A4EC5434CD24350CC44C144BD +:101F200045C34449D6444A4EDA494EC34AC24A429E +:101F3000C34AC34A4DD04A4EC24A4EC34A4EDA4AF9 +:101F4000DA4C43414CCC4C4A4DD04D4FD64D4F56B8 +:101F5000C34D4F56D84D55CC4E4FD04F52CC504F0D +:101F6000D0505553C85245D4524554C952CC524C06 +:101F7000C352D25252C3534554C2534A4DD0535503 +:101F800042C2535741D05843C8584348C45852CC12 +:101F90003F3FBF50B054434FCE50B153434FCE504C +:101FA000B249C550B349D043B05432434FCE5053D9 +:091FB000D744B84143C3FDC2FE51 +:00000001FF diff --git a/examples/paulmon1.asm b/examples/paulmon1.asm new file mode 100644 index 0000000..5950c5f --- /dev/null +++ b/examples/paulmon1.asm @@ -0,0 +1,1993 @@ +; PAULMON 8051 Debugger by Paul Stoffregen +; Please distribute freely -- may not be sold, period. + +; .command +h58 ;set page height to 58 in listing file... + + .equ start,0000h ;address for start of EPROM (0000h) + .equ program,2000h ;address for program loading location + + .ORG start +rst: lJMP poweron + + .org start+3 ;ext int #0 + LJMP program+3 + .org start+11 ;timer #0 + LJMP program+11 + .org start+13h ;external interrupt routine #1 + jnb tcon.2,intr0 + ljmp program+13h ;don't do ssrun if edge trigger'd +intr0: ajmp step ;but do ssrun if level trigger'd + .org start+1bh ;timer #1 + ljmp program+1bh + .org start+23h ;serial port + ljmp program+23h + .org start+2bh ;timer #2 (8052 only) + ljmp program+2bh + + + .org start+30h ;the jump table + ajmp cout + ajmp cin + ajmp phex + ajmp phex16 + ajmp pstr + ajmp ghex + ajmp ghex16 + ajmp esc + ajmp upper + ljmp init + +step: ;this is the single step interrupt processor code... + push psw ;better save these while we still can + push acc + clr psw.3 ;gotta be set to bank zero... + clr psw.4 +step1: acall cin + acall upper +step2: cjne a,#13,step7 + ajmp status +step7: cjne a,#32,step8 ;check space + ajmp done +step8: cjne a,#'?',step10 ;check '?' + acall sshelp + ajmp step1 +step10: cjne a,#'Q',step11 ;check 'Q'=quit and run normal + push dpl + push dph + mov dptr,#squit + acall pstr + pop dph + pop dpl + clr ie.2 + ajmp done +step11: cjne a,#'H',step12 ;check 'H'=hex dump internal ram + acall ssdmp + ajmp step1 +step12: cjne a,#'R',step13 ;check 'R'=print out registers + ajmp ssreg +step13: cjne a,#'S',step14 ;check 'S'=skip this inst + ajmp skip0 +step14: cjne a,#'A',step20 ;check 'A'=change acc value + ajmp chacc + +step20: ajmp step1 + +pequal: ; prints '=' + mov a,#'=' + acall cout + ret + +status: ;prints two-line status during single step run + mov a,r0 + push acc + acall space + mov a,#'S' + acall cout + mov a,#'P' + acall cout + acall pequal + mov r0,sp + push b + acall phex + dec r0 + acall space + lcall pa + acall pequal + mov a,@r0 + acall phex + dec r0 + acall space + lcall prc + acall pequal + mov a,@r0 + mov c,acc.7 + clr a + rlc a + acall phex1 + acall space + lcall pdptr + acall pequal + mov a,dph + acall phex + mov a,dpl + acall phex + clr a + acall pregsn + mov r0,sp + dec r0 + mov a,@r0 + acall phex + mov a,#1 + acall pregsn + mov a,r1 + acall phex + mov a,#2 + acall pregsn + mov a,r2 + acall phex + mov a,#3 + acall pregsn + mov a,r3 + acall phex + mov a,#4 + acall pregsn + mov a,r4 + acall phex + mov a,#5 + acall pregsn + mov a,r5 + acall phex + mov a,#6 + acall pregsn + mov a,r6 + acall phex + mov a,#7 + acall pregsn + mov a,r7 + acall phex + acall newline + acall space ;now begin printing the 2nd line + mov a,#'P' + acall cout + lcall prc + acall pequal + clr c + mov a,sp + subb a,#4 + mov r0,a + push dpl + push dph + lcall inst + pop dph + pop dpl + pop b + pop acc + mov r0,a +done: pop acc + pop psw + reti + + +sshelp: push dpl + push dph + acall newline + mov dptr,#help5txt + acall pstr + pop dph + pop dpl + ret + +pregsn: push acc + acall space + mov a,#'R' + acall cout + pop acc + acall phex1 + acall pequal + ret + +ssdmp: ;. + push 0 + push 1 + push b + push dpl + push dph + mov dptr,#ssdmps1 + acall pstr + pop dph + pop dpl + clr a + acall phex + mov a,#':' + acall cout + acall space + mov a,r0 + acall phex + acall space + mov a,r1 + acall phex + mov r0,#2 + mov r1,#14 + ajmp ssdmp2 +ssdmp1: mov a,r0 + acall phex + mov a,#':' + acall cout + mov r1,#16 +ssdmp2: acall space + mov a,@r0 + acall phex + inc r0 + djnz r1,ssdmp2 + acall newline + cjne r0,#80h,ssdmp1 + acall newline + pop b + pop 1 + pop 0 + ret + +ssreg: + push b ;. + acall space + mov a,#'B' + acall cout + acall pequal + mov a,b + acall phex + acall space + mov a,#'P' + acall cout + mov a,#'S' + acall cout + mov a,#'W' + acall cout + acall pequal + mov a,r0 + push acc + mov r0,sp + dec r0 + dec r0 + dec r0 + mov a,@r0 + acall phex + acall space + push dpl + push dph + mov dptr,#sfr3+1 + mov r0,0xA8 + acall psfr + mov dptr,#sfr4+1 + mov r0,0xB8 + acall psfr + mov dptr,#sfr5+1 + mov r0,0x89 + acall psfr + mov dptr,#sfr6+1 + mov r0,0x88 + acall psfr + mov dptr,#sfr7+1 + mov r0,0x98 + acall psfr + mov dptr,#sfr8+1 + mov r0,0x87 + acall psfr + mov a,#'T' + acall cout + mov a,#'0' + acall cout + acall pequal + mov a,8Ch + acall phex + mov a,8Ah + acall phex + acall space + mov a,#'T' + acall cout + mov a,#'1' + acall cout + acall pequal + mov a,8Dh + acall phex + mov a,8Bh + acall phex + acall newline + pop dph + pop dpl + pop acc + mov r0,a + pop b + ajmp step1 + +psfr: acall pstr + acall pequal + mov a,r0 + acall phex + acall space + ret + +skip0: ;. + push b + mov a,r0 + push acc + mov a,sp + clr c + subb a,#4 + mov r0,a + push dpl + push dph + mov dptr,#sskip1 + acall pstr + lcall inst ;print skipped instruction r0 points to pc + mov a,sp + clr c + subb a,#6 + mov r0,a + mov @r0,dph ;actually change the pc! + dec r0 + mov @r0,dpl + mov dptr,#sskip2 + acall pstr + inc r0 + lcall inst ;print new instruction + pop dph + pop dpl + pop acc + mov r0,a + pop b + ajmp step1 + +chacc: + mov a,r0 + push acc + push b + mov r0,sp + dec r0 + dec r0 + push dpl + push dph + mov dptr,#chaccs1 + acall pstr + acall ghex + jc chacc2 + mov @r0,a + acall newline + pop dph + pop dpl + pop b + pop acc + mov r0,a + ajmp step1 +chacc2: mov dptr,#abort + acall pstr + pop dph + pop dpl + pop b + pop acc + mov r0,a + ajmp step1 + +DownLoad: ;Note, this is a modified version of the + ;auto baud rate detection routine from + ;MDP/51. Thank You, Kei-Yong Khoo (3-31-87) + push dpl + push dph + mov dptr,#dwlds1 + acall pstr ;"begin sending file to abort" +dwld0a: aCALL cin + CJNE A, #27, DWLD0 ; Test for escape +dwldesc:mov dptr,#dwlds2 + acall pstr ;"download aborted." + pop dph + pop dpl + ret +DWLD0: + CJNE a, #0x3A, DWLD0a ; wait for ':' + ACALL ghex + jc dwldesc + MOV R0, A ; R0 = # of data bytes + ACALL ghex + jc dwldesc + MOV DPH, A ; High byte of load address + ACALL ghex + jc dwldesc + MOV DPL, A ; Low byte of load address + ACALL ghex ; Record type + jc dwldesc + CJNE A, #1, DWLD1 ; End record? + mov dptr,#dwlds3 + acall pstr ;"download went ok..." + pop dph + pop dpl + ret +DWLD1: INC R0 ; adjust for repeat loop + AJMP DWLD3 +DWLD2: ACALL ghex ; Get data byte + jc dwldesc + MOVX @DPTR, A + INC DPTR +DWLD3: DJNZ R0, DWLD2 + ACALL ghex ; Discard checksum + jc dwldesc + aJMP DWLD0a + +INIT: ;Note, this is a modified version of the + ;auto baud rate detection routine from + ;MDP/51. Thank You, Kei-Yong Khoo (3-31-87) + orl PCON,#10000000b ; set double baud rate + MOV TMOD,#00010001b + MOV SCON,#01010000b ; Set Serial for mode 1 & + ; Enable reception + ORL TCON,#01010010b ; Start timer 1 both timer + mov a,7Bh + mov r1,7Ah + mov r2,79h + mov r3,78h + xrl 1,#01010101b + xrl 2,#11001100b + xrl 3,#00011101b + cjne a,1,auto + cjne a,2,auto + cjne a,3,auto + sjmp autoend ;baud rate is known from last time... +AUTO: CLR TR1 ; Stop timer 1 + MOV TH1, #0 ; Clear timer 1 + MOV TL1, #0 + JB RXD, * ; Wait for start bit + JB RXD,AUTO ; make sure it's not just noise + JB RXD,AUTO + JB RXD,AUTO + JB RXD,AUTO + JNB RXD, * ; skip start bit + SETB TR1 + JB RXD, * + JNB RXD, * + JB RXD, * + JNB RXD, * ; Count 3 more bits + CLR TR1 + ; Compute baud rate + MOV A, TL1 ; divide TH1-TL1 by 128 + RLC A + MOV A, TH1 + RLC A + CPL A + INC A ; 2's complement + mov b,a ; store the reload value four times + mov 7Bh,a ;so that it might be there later + xrl a,#01010101b ;we'll store the reload value + mov 7Ah,a ;four times, just to be safe + mov a,b + xrl a,#11001100b + mov 79h,a + mov a,b + xrl a,#00011101b + mov 78h,a + mov a,b +autoend:MOV TH1,A + mov tmod,#00100001b ;now it's 8 bit auto-reload + SETB TR1 + RET + +HELP: + push dpl + push dph + MOV DPTR,#HELP1txt + ACALL PSTR + mov dptr,#cmd_tbl + clr a +help0: movc a,@a+dptr + jz help_2 + inc dptr + acall space + acall cout + mov r0,#4 +help1: acall space + djnz r0,help1 + clr a + movc a,@a+dptr ;(high) + mov b,a + inc dptr + clr a + movc a,@a+dptr ;(low) + inc dptr + inc dptr + inc dptr + push dpl + push dph + mov dpl,a + mov dph,b + clr a + acall pstr + acall newline + pop dph + pop dpl + sjmp help0 +help_2: mov dptr,#help2txt + acall pstr + pop dph + pop dpl + RET + +run: + push dpl + push dph + mov dptr,#prompt6 + acall pstr + acall cin + acall upper + cjne a,#27,run1 + mov dptr,#abort ;if they press + acall pstr + pop dph + pop dpl + ret +run1: cjne a,#'?',run3 + mov dptr,#help3txt ;if they pressed ? + acall pstr + mov dptr,#prompt7 + acall pstr + acall cin + cjne a,#27,run2 + pop dph + pop dpl + ret +run2: mov dptr,#help4txt + acall pstr + mov dptr,#help5txt + acall pstr + pop dph + pop dpl + ret +run3: cjne a,#'S',run4 + mov dptr,#runss + acall pstr + ajmp ssrun +run4: mov dptr,#runstd + acall pstr + mov dptr,#prompt8 ;run the user's program + acall pstr + pop dph + pop dpl + acall phex16 + push dpl + push dph + mov dptr,#prompt4 + acall pstr + pop dph + pop dpl + acall ghex16 + jnc run5 + mov dptr,#abort + acall pstr + ret +run5: mov a,#'\r' + acall cout + push dpl + push dph + mov dptr,#runs1 + acall pstr + pop dph + pop dpl + mov a,#rst & 0xFF + push acc + mov a,#rst + push acc + push dpl + push dph + ret ;<-- actually jumps to user's program + + +ssrun: mov dptr,#prompt8 ;run single step + acall pstr + pop dph + pop dpl + push dpl + push dph + acall phex16 + mov dptr,#prompt4 + acall pstr + pop dph + pop dpl + acall ghex16 + push dpl + push dph + jnc ssrun1 + mov dptr,#abort + acall pstr + acall newline + pop dph + pop dpl + ret +ssrun1: clr tcon.2 + jnb p3.3,ssrun2 + mov dptr,#sserr1 ;give error msg if int1 not grounded + acall pstr + pop dph + pop dpl + ret +ssrun2: mov dptr,#prompt9 ;ask for priority + acall pstr + acall cin + acall upper + cjne a,#27,ssrun3 + mov dptr,#abort + acall pstr + pop dph + pop dpl + ret +ssrun3: cjne a,#'L',ssrun4 + mov ip,#00000000b + sjmp ssrun5 +ssrun4: mov ip,#00000100b +ssrun5: mov dptr,#ssmsg ;tell 'em it now time, remind to + acall pstr ;to hit for next inst + pop dph + pop dpl + mov sp,#38h + mov a,#rst & 0xFF + push acc + mov a,#0 + push acc + clr a + clr c + mov r0,#0 + mov r1,#1 + mov r2,#0 + mov r3,#0 + mov r4,#0 + mov r5,#0 + mov r6,#0 + mov r7,#0 + clr tcon.2 + setb p3.3 + mov ie,#10000100b + jmp @a+dptr + + + + +dump: + mov r2,#16 ;number of lines to print + acall newline +dump1: mov r0,#20h ;pointer to memory to store bytes + acall phex16 + mov a,#':' + acall cout + mov a,#' ' + acall cout +dump2: clr A ;<--acquire 16 bytes + movc a,@a+dptr ;and store from 20 to 2F + mov @r0,a + acall phex + mov a,#' ' + acall cout + inc dptr + inc r0 + cjne r0,#30h,dump2 + acall cout + mov r0,#20h ;now we'll print it in ascii +dump3: mov a,@r0 + anl a,#01111111b ;avoid unprintable characters + mov b,a + clr c + subb a,#20h + jnc dump4 + mov b,#' ' +dump4: mov a,b + acall cout + inc r0 + cjne r0,#30h,dump3 + acall newline + acall esc + jc dump5 + djnz r2,dump1 ;loop back up to print next line +dump5: acall newline + ret + + +new_loc:push dph + push dpl + acall newline + mov dptr,#prompt5 + acall pstr + pop dpl + pop dph + push dph + push dpl + acall ghex16 + acall newline + jc newloc1 + acall newline + pop acc + pop acc + ret +newloc1:mov dptr,#abort + acall pstr + pop dpl + pop dph + acall newline + ret + +edit: ;edit external ram... + push dpl + push dph + mov dptr,#edits1 + acall pstr + pop dph + pop dpl +edit1: acall phex16 + mov a,#':' + acall cout + acall space + mov a,#'(' + acall cout + movx a,@dptr + acall phex + push dpl + push dph + mov dptr,#prompt10 + acall pstr + acall ghex + jb psw.5,edit2 + jc edit2 + pop dph + pop dpl + movx @dptr,a + acall newline + inc dptr + ajmp edit1 +edit2: mov dptr,#edits2 + acall pstr + pop dph + pop dpl + ret + +list: ;prints out dis-assembly list of memory + mov r2,#18 ;# of lines to list + acall newline +list1: mov a,r2 + push acc + acall disasm ;this obviously does all the work + pop acc + mov r2,a + acall esc + jc list2 + djnz r2,list1 +list2: acall newline + ret + + + +CIN: + JNB RI,cin ; wait for character + CLR RI + MOV A,SBUF + RET + +COUT: ;note, improved... much faster transmission + jnb ti,* ;wait if a character is still sending + MOV SBUF,A + CLR TI ;note: hardware will set ti when the + RET ; character finishes sending... + +esc: ;checks to see if is waiting on serial port. + ;C=clear if no , C=set if pressed, buffer flushed + push acc + clr c + jnb ri,esc1 + mov a,sbuf + cjne a,#27,esc1 + setb c + clr ri +esc1: pop acc + ret + +NEWLINE: + PUSH ACC + MOV A,#'\r' + ACALL COUT + POP ACC + RET + +g1hex: ;gets one character. Converts to hex and places in Acc + ;C=1 if pressed, 0 otherwise + ;PSW.5=1 if pressed, 0 otherwise + ;PSW.2=1 if backspace or delete, 0 otherwise (not yet) + acall cin + acall upper + clr c + clr psw.5 + clr psw.2 + cjne a,#13,g1hex2 + setb psw.5 + ret +g1hex2: cjne a,#27,g1hex2a + cpl c + ret +g1hex2a:cjne a,#8,g1hex2c +g1hex2b:setb psw.2 + ret +g1hex2c:cjne a,#127,g1hex3 + sjmp g1hex2b +g1hex3: push b + mov b,a + acall asc2hex + jc g1hex4 ;they typed a bad char, so go back + xch a,b + acall cout + xch a,b + pop b + ret +g1hex4: pop b + sjmp g1hex + +ghex: ; gets an 8-bit hex value from keyboard, returned in A. + ; C=1 if pressed, 0 otherwise + ; PSW.5 if pressed w/ no input, 0 otherwise + acall g1hex + jnb psw.5,ghex1 + ret +ghex1: jnc ghex2 + ret +ghex2: swap a + mov b,a +ghex3: acall g1hex + jb psw.2,ghex6 + jnb psw.5,ghex4 + clr psw.5 + mov a,b + swap a + ret +ghex4: jnc ghex5 + ret +ghex5: orl a,b + ret +ghex6: mov a,#8 + acall cout + sjmp ghex + + + + +ghex16: ; gets a 16-bit hex value from keyboard, returned in DPTR. + ; C=0 if normal , C=1 if pressed + + push acc + mov a,r0 + push acc + mov a,r1 + push acc + mov a,r2 + push acc + mov a,r3 + push acc +ghex16a:acall g1hex ;get first character + mov r0,a + jc ghex16z + jb psw.5,ghex16z + jb psw.2,ghex16a +ghex16e:acall g1hex ;get second character + mov r1,a + jc ghex16z + jb psw.5,ghex16s + jnb psw.2,ghex16i + mov a,#8 + acall cout + sjmp ghex16a +ghex16i:acall g1hex ;get third character + mov r2,a + jc ghex16z + jb psw.5,ghex16t + jnb psw.2,ghex16m + mov a,#8 + acall cout + sjmp ghex16e +ghex16m:acall g1hex ;get fourth character + mov r3,a + jc ghex16z + jb psw.5,ghex16u + jnb psw.2,ghex16v + mov a,#8 + acall cout + sjmp ghex16i +ghex16s:mov dph,#0 ;one digit entered + mov dpl,r0 + sjmp ghex16z +ghex16t:mov dph,#0 ;two digit entered + mov a,r0 + swap a + orl a,r1 + mov dpl,a + sjmp ghex16z +ghex16u:mov dph,r0 ;three digit entered + mov a,r1 + swap a + orl a,r2 + mov dpl,a + sjmp ghex16z +ghex16v:mov a,r0 ;all four digit entered + swap a + orl a,r1 + mov dph,a + mov a,r2 + swap a + orl a,r3 + mov dpl,a +ghex16z:pop acc ;exit, at last... + mov r3,a + pop acc + mov r2,a + pop acc + mov r1,a + pop acc + mov r0,a + pop acc + ret + + + +PHEX: + PUSH ACC + SWAP A + ACALL PHEX1 + POP ACC + ACALL PHEX1 + RET +PHEX1: ANL A,#0FH + ADD A,#3 + MOVC A,@A+PC + ACALL COUT + RET + .DB "0123456789ABCDEF" + +asc2hex: ;carry set if invalid input + clr c + push b + subb a,#'0' + mov b,a + subb a,#10 + jc a2h1 + mov a,b + subb a,#7 + mov b,a +a2h1: mov a,b + clr c + anl a,#11110000b ;just in case... + jz a2h2 + setb c +a2h2: mov a,b + pop b + ret + +upper: ;converts the ascii code in Acc to uppercase, if it is lowercase + push b + mov b,a + clr c + subb a,#61h + jc upper1; not a lowercase character + subb a,#26 + jnc upper1 + clr c + mov a,b + subb a,#20h + mov b,a +upper1: mov a,b + pop b + ret + +space: push acc + mov a,#' ' + acall cout + pop acc + ret + + +PHEX16: + PUSH ACC + MOV A,DPH + ACALL PHEX + MOV A,DPL + ACALL PHEX + POP ACC + RET + +PSTR: ;print string + PUSH ACC +PSTR1: CLR A + MOVC A,@A+DPTR + jb ri,pstr3 + JZ PSTR2 + mov c,acc.7 + anl a,#01111111b + jnb ti,* ;wait for last character to finish sending + mov sbuf,a + clr ti + Jc pstr2 + inc dptr + SJMP PSTR1 +PSTR2: POP ACC + RET +pstr3: clr ri + mov a,sbuf + cjne a,#27,pstr1 + mov a,#13 + acall cout + sjmp pstr2 + +disasm: ;prints out instruction @dptr, and advances dptr + acall phex16 ;they'd like to know the address... + clr a + movc a,@a+dptr + inc dptr + mov r3,a + push dph + push dpl + mov dptr,#mnot ;mnot=mnunonic offset table + movc a,@a+dptr + mov r2,a + mov a,r3 + mov dptr,#opot ;opot=operand offset table + movc a,@a+dptr + mov r6,a ;these 2 tables are a bitch to enter!!! + anl a,#11111100b + rr a + rr a + mov r7,a + mov a,r6 + anl a,#00000011b + pop dpl + pop dph + mov r6,a + dec a + jz disasm1 + push acc + clr a + movc a,@a+dptr ;fetch 2nd byte (if nec) + inc dptr + mov r4,a + pop acc + dec a + jz disasm1 + clr a + movc a,@a+dptr ;fetch 3rd byte (if nec) + inc dptr + mov r5,a +disasm1:acall disasm4 ;prints the bytes+spaces + push dpl + push dph + mov dptr,#mnu_tbl ;mnu_tlb: table with actual text... + acall disasm5 ;prints the mnenonic+spaces + mov a,r7 + mov r0,a + pop acc + pop b + push b + push acc + mov r6,a ;(high) in case of ajmp or acall or rel + mov a,b + mov r7,a ;(low) + mov a,r0 + dec a + clr c + rlc a + mov b,#dasm2 & 0xff ;(low) + push b + mov b,#dasm2 / 256 ;(high) + push b + mov dptr,#oprt ;oprt=operand routine table + jmp @a+dptr +dasm2: pop dph + pop dpl + acall newline + ret + +disasm4:mov a,#':' ;print bytes and some punctuation + acall cout + acall space + mov a,r3 + acall phex + acall space + cjne r6,#1,dis4a + mov r1,#11 + sjmp dis4c +dis4a: mov a,r4 + acall phex + acall space + cjne r6,#2,dis4b + mov r1,#8 + sjmp dis4c +dis4b: mov a,r5 + acall phex + mov r1,#6 +dis4c: acall space + djnz r1,dis4c + ret + +disasm5:mov r0,#7+1 ;prints the mnunonic+spaces +dis5a: mov a,r2 + MOVC A,@A+DPTR + INC r2 + dec r0 + mov c,acc.7 + anl a,#01111111b + acall cout + Jc dis5b + SJMP dis5a +dis5b: acall space + djnz r0,dis5b + RET + + +;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-; +; 2k page boundry must exist between these dividers ; +;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-; + + +prompt1:.db ">Loc=",0 +prompt2:.db ": (Version 1.0) Command>",0 +prompt3:.db "Location (",0 +prompt4:.db "=Default): ",0 +prompt5:.db "New memory pointer location: ",0 +prompt6:.db "\rS=Single Step, N=Normal (default), ?=Help >",0 +prompt7:.db "Press any key: ",0 +prompt8:.db "\r\rRun from memory loaction (",0 +prompt9:.db "\r\rInterrupt priority> " + .db "L=Low, H=High (default): ",0 +prompt10:.db ") New Value: ",0 +abort: .db " Command Aborted!\r",0 + + +;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-; +; 2k page boundry must exist between these dividers ; +;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-; + + +oprt: ajmp opcd1 ;addr11 + ajmp opcd2 ;A,Rn + ajmp opcd3 ;A,direct + ajmp opcd4 ;A,@Ri + ajmp opcd5 ;A,#data + ajmp opcd6 ;direct,A + ajmp opcd7 ;direct,#data + ajmp opcd8 ;C,bit + ajmp opcd9 ;C,/bit + ajmp opcd10 ;A,direct,rel + ajmp opcd11 ;A,#data,rel + ajmp opcd12 ;Rn,#data,rel + ajmp opcd13 ;@Ri,#data,rel + ajmp opcd14 ;A + ajmp opcd15 ;C + ajmp opcd16 ;bit + ajmp opcd17 ;direct + ajmp opcd18 ;@Ri + ajmp opcd19 ;AB + ajmp opcd20 ;Rn,rel + ajmp opcd21 ;direct,rel + ajmp opcd22 ;Rn + ajmp opcd23 ;DPTR + ajmp opcd24 ;bit,rel + ajmp opcd25 ;rel + ajmp opcd26 ;@A+DPTR + ajmp opcd27 ;addr16 + ajmp opcd28 ;Rn,A + ajmp opcd29 ;Rn,direct + ajmp opcd30 ;Rn,#data + ajmp opcd31 ;direct,Rn + ajmp opcd32 ;direct,direct + ajmp opcd33 ;direct,@Ri + ajmp opcd34 ;@Ri,A + ajmp opcd35 ;@Ri,direct + ajmp opcd36 ;@Ri,#data + ajmp opcd37 ;bit,C + ajmp opcd38 ;DPTR,#data16 + ajmp opcd39 ;A,@A+DPTR + ajmp opcd40 ;A,@A+PC + ajmp opcd41 ;A,@DPTR + ajmp opcd42 ;@DPTR,A + ajmp opcd43 ; + +p_reg_n:mov a,#'R' + lcall cout + mov a,r3 + anl a,#00000111b + lcall phex1 + ret + +p_reg_i:mov a,#'@' + lcall cout + mov a,#'R' + lcall cout + mov a,r3 + anl a,#00000001b + lcall phex1 + ret + +pdirect: + mov a,r4 + jb acc.7,pdir1 +pdir0: mov a,r4 + lcall phex + ret +pdir1: mov dptr,#sfrmnu +pdir2: clr a + movc a,@a+dptr + inc dptr + jz pdir0 + mov r0,a + clr c + subb a,r4 + jnz pdir3 + lcall pstr + ret +pdir3: clr a + movc a,@a+dptr + inc dptr + jnb acc.7,pdir3 + sjmp pdir2 + +pbit: + mov a,r4 + anl a,#01111000b + rl a + swap a + mov r0,a + mov a,r4 + anl a,#10000000b + jz pbit1 + mov dptr,#bitptr ;it's a Special Function Reg. + mov a,r0 + movc a,@a+dptr + mov dptr,#bitmnu + addc a,dpl + mov dpl,a + jnc pbit0 + inc dph +pbit0: lcall pstr + sjmp pbit2 +pbit1: mov a,r0 ;it's between 20h and 2Fh + add a,#20h + lcall phex +pbit2: mov a,#'.' + lcall cout + mov a,r4 + anl a,#00000111b + lcall phex1 + ret +prel: + mov a,r4 + jb acc.7,prel4 + clr c + addc a,r7 + mov r7,a + jnc prel8 + inc r6 + sjmp prel8 +prel4: cpl a + inc a + mov r4,a + mov a,r7 + clr c + subb a,r4 + mov r7,a + jnc prel8 + dec r6 +prel8: mov a,r6 + lcall phex + mov a,r7 + lcall phex + ret + + +opcd1: mov a,r6 ;addr11 done + anl a,#11111000b + mov r0,a + mov a,r3 + swap a + rr a + anl a,#00000111b + orl a,r0 + lcall phex + mov a,r4 + lcall phex + ret +opcd2: ;A,Rn done + acall pac + acall p_reg_n + ret +opcd3: ;A,direct done + acall pac + acall pdirect + ret +opcd4: ;A,@Ri done + acall pac + acall p_reg_i + ret +opcd5: ;A,#data done + acall pa +pdata: acall pcomma + acall plb + mov a,r4 + lcall phex + ret +opcd6: ;direct,A done + acall pdirect + acall pcomma + acall pa + ret +opcd7: ;direct,#data done + acall pdirect + mov a,r5 + mov r4,a + ajmp pdata +opcd8: ;C,bit done + acall prc + acall pcomma + acall pbit + ret +opcd9: ;C,/bit done + acall prc + acall pcomma + mov a,#'/' + lcall cout + acall pbit + ret +opcd10: ;A,direct,rel done + acall pac + acall pdirect +opcd10a:acall pcomma + mov a,r5 + mov r4,a + acall prel + ret +opcd11: ;A,#data,rel done + acall pa +opcd11a:acall pcomma + acall plb + mov a,r4 + lcall phex + ajmp opcd10a +opcd12: ;Rn,#data,rel done + acall p_reg_n + ajmp opcd11a +opcd13: ;@Ri,#data,rel done + acall p_reg_i + ajmp opcd11a +opcd14: ;A done + acall pa + ret +opcd15: ;C done + acall prc + ret +opcd16: ;bit done + acall pbit + ret +opcd17: ;direct done + acall pdirect + ret +opcd18: ;@Ri done + acall p_reg_i + ret +opcd19: ;AB done + acall pa + mov a,#'B' + lcall cout + ret +opcd20: ;Rn,rel done + acall p_reg_n + acall pcomma + acall prel + ret +opcd21: ;direct,rel done + acall pdirect + ajmp opcd10a +opcd22: ;Rn done + acall p_reg_n + ret +opcd23: ;DPTR done + acall pdptr + ret +opcd24: ;bit,rel done + acall pbit + ajmp opcd10a +opcd25: ;rel done + acall prel + ret +opcd26: ;@A+DPTR done + acall pat + acall pa + mov a,#'+' + lcall cout + acall pdptr + ret +opcd28: ;Rn,A done + acall p_reg_n + acall pcomma + acall pa + ret +opcd29: ;Rn,direct done + acall p_reg_n + acall pcomma + acall pdirect + ret +opcd30: ;Rn,#data done + acall p_reg_n + ajmp pdata +opcd31: ;direct,Rn done + acall pdirect + acall pcomma + acall p_reg_n + ret +opcd32: ;direct,direct done + mov a,r4 + push acc + mov a,r5 + mov r4,a + acall pdirect + acall pcomma + pop acc + mov r4,a + acall pdirect + ret +opcd33: ;direct,@Ri done + acall pdirect + acall pcomma + acall p_reg_i + ret +opcd34: ;@Ri,A done + acall p_reg_i + acall pcomma + acall pa + ret +opcd35: ;@Ri,direct done + acall p_reg_i + acall pcomma + acall pdirect + ret +opcd36: ;@Ri,#data done + acall p_reg_i + ajmp pdata +opcd37: ;bit,C done + acall pbit + acall pcomma + acall prc + ret +opcd38: ;DPTR,#data16 done + acall pdptr + acall pcomma + acall plb +opcd27: mov a,r4 ;addr16 done + lcall phex + mov a,r5 + lcall phex + ret +opcd39: ;A,@A+DPTR done + acall pac + acall pat + acall pa + mov a,#'+' + lcall cout + acall pdptr + ret +opcd40: ;A,@A+PC done + acall pac + acall pat + acall pa + mov a,#'+' + lcall cout + mov a,#'P' + lcall cout + acall prc + ret +opcd41: ;A,@DPTR done + acall pac + acall pat + acall pdptr + ret +opcd42: ;@DPTR,A done + acall pat + acall pdptr + acall pcomma + acall pa +opcd43: ret ; done + +pat: ;prints the '@' symbol + mov a,#'@' + lcall cout + ret +pcomma: ;prints a comma + mov a,#',' + lcall cout + lcall space + ret +plb: ;prints the '#' symbol + mov a,#'#' + lcall cout + ret +pa: ;prints 'A' + mov a,#'A' + lcall cout + ret +prc: ;prints 'C' + mov a,#'C' + lcall cout + ret +pac: ;print "A," + acall pa + acall pcomma + ret +pdptr: ;prints DPTR + push dph + push dpl + mov dptr,#sdptr + lcall pstr + pop dpl + pop dph + ret + +poweron: + MOV SP,#30H + clr psw.3 ;set for register bank 0 (init needs it) + clr psw.4 + LCALL INIT + setb ti ;ti is normally set in this program + clr ri ;ri is normallt cleared + mov r0,#8 + lcall newline + djnz r0,* + MOV DPTR,#logon + lCALL PSTR + mov dptr,#program + +MENU: + PUSH DPL + PUSH DPH + MOV DPTR,#PROMPT1 + lCALL PSTR + POP DPH + POP DPL + lCALL PHEX16 + PUSH DPL + PUSH DPH + MOV DPTR,#PROMPT2 + lCALL PSTR + lCALL CIN ;GET THE INPUT CHARACTER + lcall upper + .equ char, 0x20 + MOV CHAR,A + MOV DPTR,#CMD_TBL ;BEGIN SEARCH THRU THE TABLE +MENU1: CLR A + MOVC A,@A+DPTR + JZ MENU3 ;JUMP IF END OF TABLE REACHED + CJNE A,CHAR,MENU2 ;JUMP IF THIS IS NOT THE COMMAND TYPED + INC DPTR ;OK, SO THIS IS THE RIGHT ONE... + CLR A + MOVC A,@A+DPTR + PUSH Acc + INC DPTR + CLR A + MOVC A,@A+DPTR + pop b + push dpl + push dph + MOV DPL,A + mov DPH,b + lCALL PSTR ;PRINT THE COMMAND NAME + lCALL NEWLINE + pop dph + pop dpl + INC DPTR + CLR A + MOVC A,@A+DPTR + MOV 22h,A + CLR A + INC DPTR + MOVC A,@A+DPTR + mov 21h,a + POP 23h + POP 24h + mov dptr,#menu + push dpl + push dph + mov dpl,24h + mov dph,23h + PUSH 21h + PUSH 22h + RET ;SIMULATED CALL TO THE ROUTINE + lJMP MENU +MENU2: INC DPTR ;SKIP THIS TABLE ENTRY + INC DPTR + INC DPTR + INC DPTR + INC DPTR + lJMP MENU1 +MENU3: POP DPH ;NOW WE TELL 'EM THEY TYPED + POP DPL ;AN ILLEGAL CHARACTER + lCALL NEWLINE + lJMP MENU + + + ;this prints the instructions for status and skip in single-step +inst: mov a,r1 ;r0 must point to pc + push acc + mov a,r2 + push acc + mov a,r3 + push acc + mov a,r4 + push acc + mov a,r5 + push acc + mov a,r6 + push acc + mov a,r7 + push acc + mov dph,@r0 ;put pc into dptr for disasm + dec r0 + mov dpl,@r0 + lcall disasm + pop acc + mov r7,a + pop acc + mov r6,a + pop acc + mov r5,a + pop acc + mov r4,a + pop acc + mov r3,a + pop acc + mov r2,a + pop acc + mov r1,a + ret + + + + +;---------------------------------------------------------; +; ; +; Here begins the data tables and strings: ; +; ; +;---------------------------------------------------------; + +logon: .db "\r \r " + .db 12,"Welcome to the new and possibly even " + .db "improved 8031 monitor/debugger\r" + .db "by Paul Stoffregen on 14-OCT-91 " + .db "for no good reason whatsoever...\r\r" + ;columbs 1234567890123456789012345678901234567890 + .db "These are some of the features offered " + .db "by this particular debugger:\r\r" + .db " Download programs from PC " + .db "User-Friendliness!!!!!\r" + .db " Run Program " + .db "Uses no external RAM\r" + .db " (Normal, or single-step) " + .db " key is supported\r" + .db " List assemble code from memory " + .db "automatic baud rate detection\r" + .db " Hex Dump and Edit external RAM " + .db "On-line help (type '?')\r" + .db "\rHowever, you don't get somethin' for " + .db "nothin'... The code for this debugger\r" + .db "requires quite a bit more room than is " + .db "typical for a debugger, but it will all\r" + .db "fit into a 2764 (8K x 8) EPROM.\r" + .db "\rNO Copyright!! Please distribute freely. " + .db "Make as many copies as you want.\r\r\r",0 + +mnu_tbl:.db "ACAL",'L'+128 ;comma is ok + .db "AD",'D'+128,' ' + .db "ADD",'C'+128 + .db "AJM",'P'+128 + .db "AN",'L'+128 + .DB "CJN",'E'+128 + .DB "CL",'R'+128 + .DB "CP",'L'+128 + .DB "D",'A'+128 + .DB "DE",'C'+128 + .DB "DI",'V'+128 + .DB "DJN",'Z'+128 + .DB "IN",'C'+128 + .DB "J",'B'+128 + .DB "JB",'C'+128 + .DB "J",'C'+128 + .DB "JM",'P'+128 + .DB "JN",'B'+128 + .DB "JN",'C'+128 + .DB "JN",'Z'+128 + .DB "J",'Z'+128 + .DB "LCAL",'L'+128 + .DB "LJM",'P'+128 + .DB "MO",'V'+128 + .DB "MOV",'C'+128 + .DB "MOV",'X'+128 + .DB "MU",'L'+128 + .DB "NO",'P'+128 + .DB "OR",'L'+128 + .DB "PO",'P'+128 + .DB "PUS",'H'+128 + .DB "RE",'T'+128 + .DB "RET",'I'+128 + .DB "R",'L'+128 + .DB "RL",'C'+128 + .DB "R",'R'+128 + .DB "RR",'C'+128 + .DB "SET",'B'+128 + .DB "SJM",'P'+128 + .DB "SUB",'B'+128 + .DB "SWA",'P'+128 + .DB "XC",'H'+128 + .DB "XCH",'D'+128 + .DB "XR",'L'+128 + .DB "??",'?'+128,0 + +bitmnu: .db 'P','0'+128 + .db "TCO",'N'+128 + .db 'P','1'+128 + .db "SCO",'N'+128 + .DB 'P','2'+128 + .DB 'I','E'+128 + .DB 'P','3'+128 + .DB 'I','P'+128 + .DB 'C','0'+128 + .DB "T2CO",'N'+128 + .DB "PS",'W'+128 + .DB 'D','8'+128 + .DB "AC",'C'+128 + .DB 'E'+'8'+128 + .DB 'B'+128 + .DB 'F'+'8'+128 + .DB 0 + +sfrmnu: .db 0xE0,"AC",'C'+128 + .db 0x81,'S','P'+128 + .DB 0x82,"DP",'L'+128 + .DB 0x83,"DP",'H'+128 + .DB 0x80,'P','0'+128 + .DB 0x90,'P','1'+128 + .DB 0xA0,'P','2'+128 + .DB 0xB0,'P','3'+128 + .DB 0x99,"SBU",'F'+128 + .DB 0xCD,"TH",'2'+128 + .DB 0xC8,"T2CO",'N'+128 + .DB 0xCC,"TL",'2'+128 + .DB 0xCB,"RCAP2",'H'+128 + .DB 0xCA,"RCAP2",'L'+128 + .DB 0x8C,"TH",'0'+128 + .DB 0x8A,"TL",'0'+128 + .DB 0x8D,"TH",'1'+128 + .DB 0x8B,"TL",'1'+128 +sfr1: .db 0xF0,'B'+128 ;5 +sfr2: .db 0xD0,"PS",'W'+128 ;7 +sfr3: .DB 0xA8,'I','E'+128 +sfr4: .DB 0xB8,'I','P'+128 +sfr5: .DB 0x89,"TMO",'D'+128 ;8 +sfr6: .DB 0x88,"TCO",'N'+128 ;8 +sfr7: .DB 0x98,"SCO",'N'+128 ;8 +sfr8: .DB 0x87,"PCO",'N'+128 ;8 + .DB 0 + + +mnot: ;mnunonic offset table (gives offset into above table) + + .db 5Ah,0Eh,48h,73h,2Bh,2Bh,2Bh,2Bh + .DB 2Bh,2Bh,2Bh,2Bh,2Bh,2Bh,2Bh,2Bh ;INC + .DB 30h,00h,43h,75h,21h,21h,21h,21h + .DB 21h,21h,21h,21h,21h,21h,21h,21h ;DEC + .DB 2Eh,0Eh,67h,6Eh,06h,06h,06h,06h + .DB 06h,06h,06h,06h,06h,06h,06h,06h ;ADD + .DB 38h,00h,6Ah,70h,0Ah,0Ah,0Ah,0Ah + .DB 0Ah,0Ah,0Ah,0Ah,0Ah,0Ah,0Ah,0Ah ;ADDC + .DB 33h,0Eh,5Dh,5Dh,5Dh,5Dh,5Dh,5Dh + .DB 5Dh,5Dh,5Dh,5Dh,5Dh,5Dh,5Dh,5Dh ;ORL + .DB 3Bh,00h,12h,12h,12h,12h,12h,12h + .DB 12h,12h,12h,12h,12h,12h,12h,12h ;ANL + .DB 41h,0Eh,8Fh,8Fh,8Fh,8Fh,8Fh,8Fh + .DB 8Fh,8Fh,8Fh,8Fh,8Fh,8Fh,8Fh,8Fh ;XLR + .DB 3Eh,00h,5Dh,35h,4Ch,4Ch,4Ch,4Ch + .DB 4Ch,4Ch,4Ch,4Ch,4Ch,4Ch,4Ch,4Ch ;MOV + .DB 7Ch,0Eh,12h,4Fh,24h,4Ch,4Ch,4Ch + .DB 4Ch,4Ch,4Ch,4Ch,4Ch,4Ch,4Ch,4Ch ;MOV + .DB 4Ch,00h,4Ch,4Fh,80h,80h,80h,80h + .DB 80h,80h,80h,80h,80h,80h,80h,80h ;SUBB + .DB 5Dh,0Eh,4Ch,2Bh,57h,92h,4Ch,4Ch + .DB 4Ch,4Ch,4Ch,4Ch,4Ch,4Ch,4Ch,4Ch ;MOV + .DB 12h,00h,1Ch,1Ch,15h,15h,15h,15h + .DB 15h,15h,15h,15h,15h,15h,15h,15h ;CJNE + .DB 63h,0Eh,19h,19h,84h,88h,88h,88h + .DB 88h,88h,88h,88h,88h,88h,88h,88h ;XCH + .DB 60h,00h,78h,78h,1Fh,27h,8Bh,8Bh + .DB 27h,27h,27h,27h,27h,27h,27h,27h ;DJNZ + .DB 53h,0Eh,53h,53h,19h,4Ch,4Ch,4Ch + .DB 4Ch,4Ch,4Ch,4Ch,4Ch,4Ch,4Ch,4Ch ;MOV + .DB 53h,00h,53h,53h,1Ch,4Ch,4Ch,4Ch + .DB 4Ch,4Ch,4Ch,4Ch,4Ch,4Ch,4Ch,4Ch ;MOV + +bitptr: .db 00h,02h,06h,08h,0Ch,0Eh,10h,12h + .db 14h,16h,1Bh,1Eh,20h,23h,24h,25h + +opot: ;opcode offset table (gives #bytes for the instruction + ;and the number of the routine to print the operands) + + .db 43*4+1,1*4+2,27*4+3,14*4+1 ;00 + .db 14*4+1,17*4+2,18*4+1,18*4+1 + .db 89,89,89,89,89,89,89,89 ;inc + .db 24*4+3,1*4+2,27*4+3,14*4+1 ;10 + .db 14*4+1,17*4+2,18*4+1,18*4+1 + .db 89,89,89,89,89,89,89,89 ;dec + .db 24*4+3,1*4+2,43*4+1,14*4+1 ;20 + .db 5*4+2,3*4+2,4*4+1,4*4+1 + .db 9,9,9,9,9,9,9,9 ;add + .db 24*4+3,1*4+2,43*4+1,14*4+1 ;30 + .db 5*4+2,3*4+2,4*4+1,4*4+1 + .db 9,9,9,9,9,9,9,9 ;addc + .db 25*4+2,1*4+2,6*4+2,7*4+3 ;40 + .db 5*4+2,3*4+2,4*4+1,4*4+1 + .db 9,9,9,9,9,9,9,9 ;orl + .db 25*4+2,1*4+2,6*4+2,7*4+3 ;50 + .db 5*4+2,3*4+2,4*4+1,4*4+1 + .db 9,9,9,9,9,9,9,9 ;anl + .db 25*4+2,1*4+2,6*4+2,7*4+3 ;60 + .db 5*4+2,3*4+2,4*4+1,4*4+1 + .db 9,9,9,9,9,9,9,9 ;xrl + .db 25*4+2,1*4+2,8*4+2,26*4+1 ;70 + .db 5*4+2,7*4+3,36*4+2,33*4+2 + .db 122,122,122,122,122,122,122,122 ;mov + .db 25*4+2,1*4+2,34,40*4+1 ;80 + .db 19*4+1,32*4+3,33*4+2,33*4+2 + .db 126,126,126,126,126,126,126,126 ;mov + .db 38*4+3,1*4+2,37*4+2,39*4+1 ;90 + .db 5*4+2,3*4+2,4*4+1,4*4+1 + .db 9,9,9,9,9,9,9,9 ;subb + .db 9*4+2,1*4+2,8*4+2,23*4+1 ;A0 + .db 19*4+1,43*4+1,35*4+2,35*4+2 + .db 118,118,118,118,118,118,118,118 ;mov + .db 9*4+2,1*4+2,16*4+2,15*4+1 ;B0 + .db 11*4+3,10*4+3,13*4+3,13*4+3 + .db 51,51,51,51,51,51,51,51 ;cjne + .db 17*4+2,1*4+2,16*4+2,15*4+1 ;C0 + .db 14*4+1,3*4+2,4*4+1,4*4+1 + .db 9,9,9,9,9,9,9,9 ;xch + .db 17*4+2,1*4+2,16*4+2,15*4+1 ;D0 + .db 14*4+1,21*4+3,4*4+1,4*4+1 + .db 82,82,82,82,82,82,82,82 ;djnz + .db 41*4+1,1*4+2,4*4+1,4*4+1 ;E0 + .db 14*4+1,3*4+2,4*4+1,4*4+1 + .db 9,9,9,9,9,9,9,9 ;mov + .db 42*4+1,1*4+2,34*4+1,34*4+1 ;F0 + .db 14*4+1,6*4+2,34*4+1,34*4+1 + .db 113,113,113,113,113,113,113,113 ;mov + +edits1: .db "\rEditing External RAM... to quit\r",0 +edits2: .db " Editing finished, this location unchanged\r\r",0 +dwlds1: .db "\r\rBegin ascii transmission of " + .db "Intel HEX format file, " + .db "or to abort\r\r",0 +dwlds2: .db "Download aborted by user\r\r",0 +dwlds3: .db "\r\r\r\rDownload completed\r\r",0 +runstd: .db "Run normally",0 +runs1: .db "\rNow running the program...\r\r",0 +runss: .db "Run in single step mode",0 +sserr1: .db "\r\rThe single step run feature will not function" + .db " unless INT1 (pin #13) is\r" + .db "connected to ground or otherwise held low.\r\r",0 +ssmsg: .db "\rNow running in single step mode: " + .db "=default, ?=Help\r\r",0 +sskip1: .db "Skipping ------>",0 +sskip2: .db "Next will be -->",0 +ssdmps1:.db "\rLoc: Internal Ram Memory Contents\r",0 +chaccs1:.db "New Acc Value: ",0 +squit: .db "\rQuit single step mode, now running normally.\r\r",0 +sdptr: .db "DPTR",0 +CMD_TBL:.DB '?' + .DW CMD_hlp + .DW HELP + .db 'R' + .dw CMD_run + .dw run + .db 'D' + .dw CMD_dwl + .dw download + .db 'N' + .dw CMD_new + .dw new_loc + .db 'H' + .dw CMD_dmp + .dw dump + .db 'L' + .dw CMD_lst + .dw list + .db 'E' + .dw CMD_edt + .dw edit + .DB 00h +CMD_run:.db " Run program",0 +CMD_new:.db " New memory location",0 +CMD_dmp:.db " HEX Dump Memory to the Screen",0 +CMD_lst:.db " List assembly code",0 +CMD_hlp:.DB " Help???",0 +CMD_dwl:.Db " Download program from PC",0 +CMD_edt:.db " Edit external ram",0 +Help1txt: + .db 12,"These commands are currently " + .db "supported:\r\r",0 +help2txt: + ; 1234567890123456789012345678901234567890 + .db "\rAll numerical values are shown in hex. " + + .db "Pressing key will exit the\r" + .db "current command, even while listing/dumping. " + .db "Most prompts require a\r" + .db "single character, typically the first letter " + .db "of the desired option.\r\rFor information " + .db "regarding the single-step run feature,\r" + .db "type '?' when asked 'Single-step/Normal' " + .db "before running the program.\r\r",0 +Help3txt: + ; 1234567890123456789012345678901234567890 + .db 12,"The single step run feature allows you " + .db "to execute your program from memory\r" ;1 + .db "one instruction at a time, while monitoring " + .db "the registers and instructions.\r" ;2 + .db "It it NOT a simulation, the program is " + .db "executed by the 8031/51 processor.\r" ;3 + .db "External Interrupt #1 must be held low " + .db "to make the single step function.\r" ;4 + .db "\r" ;5 + .db "Despite attempts to make the single " + .db "step run compatible with all programs,\r" ;6 + .db "there will always be some basic limitations " + .db "due to its nature:\r\r" ;7 8 + .db " 1- External Interrupt #1 must not be" + .db " disabled, e.g. MOV IE,#81h\r" ;9 + .db " 2- Timer #1 must be correctly generating " + .db " the baud rate for the serial port\r" ;10 + .db " 3- TI and RI will not work normally, " + .db "e.g. 2003: JNB RI,2003, use skip...\r" ;11 + .db " 4- Interrupts will not get service " + .db "or will interrupt the single step\r" ;12 + .db " 5- About 30 bytes of space must be " + .db "left available on the stack!\r" ;13 + .db " 6- ??? Other problems may also " + .db "exist, (this program is FREE, you know)\r" ;14 + ; 1234567890123456789012345678901234567890 + .db "\r" ;15 + .db "Perhaps the worst limitation of the " + .db "single step run is that it takes a\r" ;16 + .db "very long time to execute even short " + .db "pieces of code. It is recommended that\r" ;17 + .db "a normal run be attempted first to " + .db "estimate where the program goes astray,\r" ;18 + .db "the attempt a single step at the beginning " + .db "of the questionable code, with a\r" ;19 + .db "hardcopy of the assembly listing file " + .db "on-hand for memory location reference.\r\r",0 ;20 21 + + + ; 1234567890123456789012345678901234567890 +Help4txt: + .db 12,"Between steps, the monitor uses absolutely " + .db "NO internal or external memory.\r" + .db "However, about 30 bytes of stack space " + .db "must be left available...\r\r" + .db "During a single step run, pressing RETURN " + .db "repeatedly will be the usual course\r" + .db "of action. However, other options are " + .db "available.\r\r" + .db " " + .db "Typing '?' will display this help screen\r\r",0 + +Help5txt: + .db "Single Step Commands:\r\r" + .db " Print Status and execute " + .db "the next instruction\r" + .db " Execute next instruction w/out status lines\r" + .db " '?' Display this on-line help\r" + .db " 'R' Print out Special Function Registers\r" + .db " 'H' Hex dump internal ram\r" + .db " 'S' Skip this instruction\r" + .db " 'A' Change the Accumulator's value\r" + .db " 'Q' Quit Single Step, continue executing normally\r" + .db "\r",0 + diff --git a/examples/paulmon1.ref b/examples/paulmon1.ref new file mode 100644 index 0000000..99b6d70 --- /dev/null +++ b/examples/paulmon1.ref @@ -0,0 +1,490 @@ +:03000000020B08E8 +:03000300022003D5 +:03000B0002200BC5 +:08001300308A030220130145AD +:03001B0002201BA5 +:0300230002202395 +:03002B0002202B85 +:10003000A188A180C183C1E5C1F2A1DEC104A19064 +:10004000C1C30202E9C0D0C0E0C2D3C2D4B180D1E2 +:10005000C3B40D020193B42002212EB43F04313306 +:10006000014DB45111C082C083901454D1F2D08399 +:10007000D082C2AA212EB448043152014DB452029A +:10008000219BB453024131B441024167014D743D9B +:10009000B18822E8C0E0D1DC7453B1887450B188D3 +:1000A000118EA881C0F0D18318D1DC120AE8118E1C +:1000B000E6D18318D1DC120AEE118EE6A2E7E43312 +:1000C000D18DD1DC120AF9118EE583D183E582D17D +:1000D00083E43143A88118E6D18374013143E9D127 +:1000E0008374023143EAD18374033143EBD18374C7 +:1000F000043143ECD18374053143EDD1837406316F +:1001000043EED18374073143EFD183B1A1D1DC74C5 +:1001100050B188120AEE118EC3E5819404F8C082B2 +:10012000C083120BA5D083D082D0F0D0E0F8D0E00D +:10013000D0D032C082C083B1A1901CD5D1F2D0837F +:10014000D08222C0E0D1DC7452B188D0E0D18D11D0 +:100150008E22C000C001C0F0C082C08390141FD1A5 +:10016000F2D083D082E4D183743AB188D1DCE8D173 +:1001700083D1DCE9D1837802790E2185E8D18374BB +:100180003AB1887910D1DCE6D18308D9F8B1A1B8A9 +:1001900080EAB1A1D0F0D001D00022C0F0D1DC744F +:1001A00042B188118EE5F0D183D1DC7450B18874EE +:1001B00053B1887457B188118EE8C0E0A88118182F +:1001C00018E6D183D1DCC082C08390100DA8A8515D +:1001D00027901010A8B85127901013A88951279084 +:1001E0001018A888512790101DA898512790102208 +:1001F000A88751277454B1887430B188118EE58C6A +:10020000D183E58AD183D1DC7454B1887431B1884B +:10021000118EE58DD183E58BD183B1A1D083D082BE +:10022000D0E0F8D0F0014DD1F2118EE8D183D1DCCD +:1002300022C0F0E8C0E0E581C39404F8C082C08326 +:100240009013FDD1F2120BA5E581C39406F8A683A5 +:1002500018A68290140ED1F208120BA5D083D0827A +:10026000D0E0F8D0F0014DE8C0E0C0F0A881181847 +:10027000C082C083901444D1F2B1DE400EF6B1A129 +:10028000D083D082D0F0D0E0F8014D9008ABD1F20D +:10029000D083D082D0F0D0E0F8014DC082C08390EE +:1002A000128CD1F2B180B41B0A9012D5D1F2D08356 +:1002B000D08222B43AEEB1DE40EFF8B1DE40EAF58A +:1002C00083B1DE40E4F582B1DE40DEB4010A901273 +:1002D000F0D1F2D083D082220841E1B1DE40CAF0F1 +:1002E000A3D8F8B1DE40C241A44387807589117557 +:1002F0009850438852E57BA97AAA79AB7863015577 +:100300006302CC63031DB50108B50205B503028085 +:1003100048C28E758D00758B0020B0FD20B0F22094 +:10032000B0EF20B0EC20B0E930B0FDD28E20B0FDAF +:1003300030B0FD20B0FD30B0FDC28EE58B33E58DD1 +:1003400033F404F5F0F57B6455F57AE5F064CCF50B +:1003500079E5F0641DF578E5F0F58D758921D28E8B +:1003600022C082C083901538D1F2901489E4936042 +:1003700029A3D1DCB1887804D1DCD8FCE493F5F072 +:10038000A3E493A3A3A3C082C083F58285F083E492 +:10039000D1F2B1A1D083D08280D4901563D1F2D0B4 +:1003A00083D08222C082C083900812D1F2B180D162 +:1003B000C3B41B0A9008ABD1F2D083D08222B43FE1 +:1003C000239016B5D1F290083FD1F2B180B41B054D +:1003D000D083D08222901B8FD1F2901CD5D1F2D045 +:1003E00083D08222B45307901334D1F28133901317 +:1003F00009D1F290084FD1F2D083D082D1E5C082EA +:10040000C0839007E8D1F2D083D082D10450069007 +:1004100008ABD1F222740DB188C082C0839013164C +:10042000D1F2D083D0827400C0E07400C0E0C082FA +:10043000C0832290084FD1F2D083D082C082C08383 +:10044000D1E59007E8D1F2D083D082D104C082C038 +:1004500083500C9008ABD1F2B1A1D083D08222C2DC +:100460008A30B30A90134CD1F2D083D08222900804 +:100470006CD1F2B180D1C3B41B0A9008ABD1F2D0D9 +:1004800083D08222B44C0575B800800375B80490FF +:1004900013C2D1F2D083D0827581387400C0E07469 +:1004A00000C0E0E4C3780079017A007B007C007D25 +:1004B000007E007F00C28AD2B375A884737A10B11F +:1004C000A17820D1E5743AB1887420B188E493F61C +:1004D000D1837420B188A308B830F2B1887820E6BF +:1004E000547FF5F0C39420500375F020E5F0B188F7 +:1004F00008B830EBB1A1B1904002DAC5B1A122C079 +:1005000083C082B1A19007F4D1F2D082D083C0839E +:10051000C082D104B1A14007B1A1D0E0D0E02290C7 +:1005200008ABD1F2D082D083B1A122C082C0839027 +:100530001237D1F2D083D082D1E5743AB188D1DCC0 +:100540007428B188E0D183C082C08390089CD1F226 +:10055000B1DE20D50C400AD083D082F0B1A1A3A196 +:100560003890125ED1F2D083D082227A12B1A1EA01 +:10057000C0E0F11BD0E0FAB1904002DAF2B1A12262 +:100580003098FDC298E599223099FDF599C29922DB +:10059000C0E0C3309808E599B41B03D3C298D0E0FB +:1005A00022C0E0740DB188D0E022B180D1C3C3C2B3 +:1005B000D5C2D2B40D03D2D522B41B02B322B408E3 +:1005C00003D2D222B47F0280F8C0F0F5F0D1A5406A +:1005D00009C5F0B188C5F0D0F022D0F080CCB1AA26 +:1005E00030D50122500122C4F5F0B1AA20D20F303B +:1005F000D506C2D5E5F0C42250012245F022740888 +:10060000B18880DAC0E0E8C0E0E9C0E0EAC0E0EB31 +:10061000C0E0B1AAF8405D20D55A20D2F5B1AAF9C0 +:10062000405220D52B30D2067408B18880E4B1AA9C +:10063000FA404120D52130D2067408B18880DEB15D +:10064000AAFB403020D51A30D2207408B18880DE51 +:100650007583008882801D758300E8C449F5828017 +:10066000138883E9C44AF582800AE8C449F583EA1D +:10067000C44BF582D0E0FBD0E0FAD0E0F9D0E0F84E +:10068000D0E022C0E0C4D18DD0E0D18D22540F241F +:100690000383B1882230313233343536373839412B +:1006A0004243444546C3C0F09430F5F0940A4006F6 +:1006B000E5F09407F5F0E5F0C354F06001D3E5F000 +:1006C000D0F022C0F0F5F0C39461400B941A5007AB +:1006D000C3E5F09420F5F0E5F0D0F022C0E07420FE +:1006E000B188D0E022C0E0E583D183E582D183D018 +:1006F000E022C0E0E4932098156010A2E7547F3018 +:1007000099FDF599C2994003A380E9D0E022C298EF +:10071000E599B41BDF740DB18880F0D1E5E493A3B3 +:10072000FBC083C08290102793FAEB90113793FEA1 +:1007300054FC0303FFEE5403D082D083FE14600FF9 +:10074000C0E0E493A3FCD0E0146004E493A3FDF1C3 +:1007500081C082C083900EFEF1A9EFF8D0E0D0F006 +:10076000C0F0C0E0FEE5F0FFE814C33375F07AC0D6 +:10077000F075F007C0F09008BF73D083D082B1A1AC +:1007800022743AB188D1DCEBD183D1DCBE0104798B +:100790000B8011ECD183D1DCBE020479088005ED19 +:1007A000D1837906D1DCD9FC227808EA930A18A211 +:1007B000E7547FB188400280F2D1DCD8FC223E4C65 +:1007C0006F633D003A202856657273696F6E203161 +:1007D0002E302920436F6D6D616E643E004C6F6357 +:1007E0006174696F6E2028003D44656661756C74A4 +:1007F000293A20004E6577206D656D6F7279207003 +:100800006F696E746572206C6F636174696F6E3AA4 +:1008100020000D533D53696E676C652053746570FD +:100820002C204E3D4E6F726D616C202864656661B0 +:10083000756C74292C203F3D48656C70203E00503B +:100840007265737320616E79206B65793A20000DB3 +:100850000D52756E2066726F6D206D656D6F7279C9 +:10086000206C6F616374696F6E2028000D0D496EF6 +:1008700074657272757074207072696F72697479C0 +:100880003E204C3D4C6F772C20483D4869676820DE +:100890002864656661756C74293A20002920204E11 +:1008A00065772056616C75653A20002020436F6D96 +:1008B0006D616E642041626F72746564210D002168 +:1008C000A521B721BC21C121C621D121D821DE21FA +:1008D000E521F121FC4108410C4110411341164131 +:1008E00019411C411F4127412E41324135413841B8 +:1008F0003C413F4199414B41524159415D41644125 +:1009000073417A41814188418C419341A241B04178 +:10091000C341CA41D27452120588EB540712068DA6 +:100920002274401205887452120588EB5401120695 +:100930008D22EC20E705EC12068322900FBAE49397 +:10094000A360F3F8C39C70041206F222E493A33070 +:10095000E7FA80EAEC547823C4F8EC5480601590F0 +:100960001127E893900F933582F582500205831288 +:1009700006F28006E82420120683742E120588EC05 +:10098000540712068D22EC20E708C33FFF500D0EDE +:10099000800AF404FCEFC39CFF50011EEE12068394 +:1009A000EF12068322EE54F8F8EBC4035407481202 +:1009B0000683EC1206832251F431152251F43132B0 +:1009C0002251F431212251E851D951E2EC1206832F +:1009D00022313251D951E8223132EDFC21C851EE99 +:1009E00051D931542251EE51D9742F120588315406 +:1009F0002251F4313251D9EDFC31862251E851D9DE +:100A000051E2EC12068321F5311521FE312121FE40 +:100A100051E82251EE223154223132223121225129 +:100A2000E8744212058822311551D93186223132BB +:100A300021F531152251F922315421F53186225107 +:100A4000D351E8742B12058851F922311551D9512F +:100A5000E822311551D9313222311521C8313251B4 +:100A6000D9311522ECC0E0EDFC313251D9D0E0FC97 +:100A7000313222313251D9312122312151D951E83B +:100A800022312151D9313222312121C8315451D959 +:100A900051EE2251F951D951E2EC120683ED1206C2 +:100AA000832251F451D351E8742B12058851F92255 +:100AB00051F451D351E8742B1205887450120588F3 +:100AC00051EE2251F451D351F92251D351F951D958 +:100AD00051E822744012058822742C1205881206EF +:100AE000DC22742312058822744112058822744383 +:100AF0001205882251E851D922C083C08290148403 +:100B00001206F2D082D08322758130C2D3C2D412B1 +:100B100002E9D299C29878081205A1D8FE900BD8A4 +:100B20001206F2902000C082C0839007BE1206F227 +:100B3000D083D0821206E5C082C0839007C412061B +:100B4000F21205801206C3F520901489E493604BDD +:100B5000B52040A3E493C0E0A3E493D0F0C082C0EA +:100B600083F58285F0831206F21205A1D083D0822C +:100B7000A3E493F522E4A393F521D023D024900B92 +:100B800026C082C083852482852383C021C022227F +:100B9000020B26A3A3A3A3A3020B4CD083D08212E3 +:100BA00005A1020B26E9C0E0EAC0E0EBC0E0ECC022 +:100BB000E0EDC0E0EEC0E0EFC0E086831886821270 +:100BC000071BD0E0FFD0E0FED0E0FDD0E0FCD0E09D +:100BD000FBD0E0FAD0E0F9220D2020200D202020CB +:100BE00020202020200C57656C636F6D6520746F8A +:100BF00020746865206E657720616E6420706F7365 +:100C00007369626C79206576656E20696D70726FAC +:100C10007665642038303331206D6F6E69746F7281 +:100C20002F64656275676765720D62792050617522 +:100C30006C2053746F6666726567656E206F6E20F8 +:100C400031342D4F43542D393120666F72206E6F31 +:100C500020676F6F6420726561736F6E20776861C3 +:100C600074736F657665722E2E2E0D0D5468657344 +:100C7000652061726520736F6D65206F66207468F2 +:100C800065206665617475726573206F666665724E +:100C90006564206279207468697320706172746978 +:100CA00063756C61722064656275676765723A0D81 +:100CB0000D2020202020446F776E6C6F61642070BF +:100CC000726F6772616D732066726F6D2050432082 +:100CD000202020202020202020557365722D467270 +:100CE00069656E646C696E65737321212121210D24 +:100CF000202020202052756E2050726F6772616D27 +:100D000020202020202020202020202020202020E3 +:100D1000202020202020202055736573206E6F2016 +:100D200065787465726E616C2052414D0D202020F3 +:100D300020202020284E6F726D616C2C206F722055 +:100D400073696E676C652D7374657029202020208F +:100D500020202020203C4553433E206B65792069AC +:100D60007320737570706F727465640D202020207D +:100D7000204C69737420617373656D626C652063C8 +:100D80006F64652066726F6D206D656D6F7279207E +:100D9000202020206175746F6D6174696320626129 +:100DA0007564207261746520646574656374696F2D +:100DB0006E0D20202020204865782044756D70201D +:100DC000616E6420456469742065787465726E6133 +:100DD0006C2052414D20202020204F6E2D6C696EDA +:100DE000652068656C7020287479706520273F271E +:100DF000290D0D486F77657665722C20796F752007 +:100E0000646F6E27742067657420736F6D657468F6 +:100E1000696E2720666F72206E6F7468696E272E68 +:100E20002E2E202054686520636F646520666F72E3 +:100E300020746869732064656275676765720D72F6 +:100E400065717569726573207175697465206120BB +:100E5000626974206D6F726520726F6F6D207468A7 +:100E6000616E206973207479706963616C20666FAC +:100E70007220612064656275676765722C206275F7 +:100E8000742069742077696C6C20616C6C0D6669E4 +:100E90007420696E746F2061203237363420283810 +:100EA0004B2078203829204550524F4D2E0D0D4EA5 +:100EB0004F20436F70797269676874212120205038 +:100EC0006C656173652064697374726962757465B9 +:100ED00020667265656C792E20204D616B652061FE +:100EE00073206D616E7920636F7069657320617323 +:100EF00020796F752077616E742E0D0D0D004143C2 +:100F0000414CCC4144C420414444C3414A4DD041AA +:100F10004ECC434A4EC5434CD24350CC44C14445C9 +:100F2000C34449D6444A4EDA494EC34AC24A42C330 +:100F30004AC34A4DD04A4EC24A4EC34A4EDA4ADAF2 +:100F40004C43414CCC4C4A4DD04D4FD64D4F56C3DF +:100F50004D4F56D84D55CC4E4FD04F52CC504FD010 +:100F6000505553C85245D4524554C952CC524CC323 +:100F700052D25252C3534554C2534A4DD053554294 +:100F8000C2535741D05843C8584348C45852CC3F25 +:100F90003FBF0050B054434FCE50B153434FCE509B +:100FA000B249C550B349D043B05432434FCE5053E9 +:100FB000D744B84143C3FDC2FE00E04143C381535F +:100FC000D0824450CC834450C88050B09050B1A0DF +:100FD00050B2B050B399534255C6CD5448B2C854DC +:100FE00032434FCECC544CB2CB5243415032C8CA9C +:100FF0005243415032CC8C5448B08A544CB08D543A +:1010000048B18B544CB1F0C2D05053D7A849C5B8A1 +:1010100049D089544D4FC48854434FCE9853434FC1 +:10102000CE8750434FCE005A0E48732B2B2B2B2BC1 +:101030002B2B2B2B2B2B2B300043752121212121F6 +:10104000212121212121212E0E676E06060606068A +:101050000606060606060638006A700A0A0A0A0A22 +:101060000A0A0A0A0A0A0A330E5D5D5D5D5D5D5D6E +:101070005D5D5D5D5D5D5D3B00121212121212122C +:1010800012121212121212410E8F8F8F8F8F8F8FAA +:101090008F8F8F8F8F8F8F3E005D354C4C4C4C4C1B +:1010A0004C4C4C4C4C4C4C7C0E124F244C4C4C4CED +:1010B0004C4C4C4C4C4C4C4C004C4F8080808080B5 +:1010C000808080808080805D0E4C2B57924C4C4CF1 +:1010D0004C4C4C4C4C4C4C12001C1C151515151549 +:1010E00015151515151515630E1919848888888826 +:1010F00088888888888888600078781F278B8B2765 +:1011000027272727272727530E5353194C4C4C4C7E +:101110004C4C4C4C4C4C4C530053531C4C4C4C4C76 +:101120004C4C4C4C4C4C4C000206080C0E1012144B +:10113000161B1E20232425AD066F3939464949590F +:101140005959595959595963066F393946494959B5 +:10115000595959595959596306AD39160E11110982 +:10116000090909090909096306AD39160E111109A2 +:101170000909090909090966061A1F160E1111093C +:101180000909090909090966061A1F160E1111092C +:101190000909090909090966061A1F160E1111091C +:1011A0000909090909090966062269161F92867A42 +:1011B0007A7A7A7A7A7A7A660622A14D8386867E50 +:1011C0007E7E7E7E7E7E7E9B06969D160E1111098A +:1011D000090909090909092606225D4DAD8E8E7699 +:1011E000767676767676762606423D2F2B3737331F +:1011F000333333333333334606423D390E1111094D +:10120000090909090909094606423D3957111152D0 +:1012100052525252525252A5061111390E11110951 +:1012200009090909090909A9068989391A898971E8 +:10123000717171717171710D45646974696E6720A6 +:1012400045787465726E616C2052414D2E2E2E3C95 +:101250004553433E20746F20717569740D00202042 +:1012600045646974696E672066696E697368656450 +:101270002C2074686973206C6F636174696F6E20D1 +:10128000756E6368616E6765640D0D000D0D4265D6 +:1012900067696E206173636969207472616E736D32 +:1012A000697373696F6E206F6620496E74656C2078 +:1012B00048455820666F726D61742066696C652CB4 +:1012C000206F72203C4553433E20746F2061626F53 +:1012D00072740D0D00446F776E6C6F6164206162F3 +:1012E0006F7274656420627920757365720D0D00EC +:1012F0000D0D0D0D446F776E6C6F616420636F6D23 +:10130000706C657465640D0D0052756E206E6F72A1 +:101310006D616C6C79000D4E6F772072756E6E6921 +:101320006E67207468652070726F6772616D2E2E13 +:101330002E0D0D0052756E20696E2073696E676CFC +:10134000652073746570206D6F6465000D0D5468C1 +:10135000652073696E676C652073746570207275A3 +:101360006E20666561747572652077696C6C206E9D +:101370006F742066756E6374696F6E20756E6C6530 +:10138000737320494E5431202870696E2023313305 +:10139000292069730D636F6E6E65637465642074D4 +:1013A0006F2067726F756E64206F72206F7468654E +:1013B00072776973652068656C64206C6F772E0D99 +:1013C0000D000D4E6F772072756E6E696E67206925 +:1013D0006E2073696E676C652073746570206D6F25 +:1013E00064653A20203C5245543E3D646566617513 +:1013F0006C742C203F3D48656C700D0D00536B697B +:101400007070696E67202D2D2D2D2D2D3E004E659F +:1014100078742077696C6C206265202D2D3E000D5C +:101420004C6F633A2020496E7465726E616C205275 +:10143000616D204D656D6F727920436F6E74656EBE +:1014400074730D004E6577204163632056616C759F +:10145000653A20000D517569742073696E676C657B +:101460002073746570206D6F64652C206E6F77201B +:1014700072756E6E696E67206E6F726D616C6C79DD +:101480002E0D0D0044505452003F150203615214BA +:10149000AD03A444150B029B4E14BA04FF4814CFAD +:1014A00004BD4C14EE056B451525052B0020527527 +:1014B0006E2070726F6772616D00204E6577206DCF +:1014C000656D6F7279206C6F636174696F6E002057 +:1014D0004845582044756D70204D656D6F727920B8 +:1014E000746F207468652053637265656E00204CCC +:1014F00069737420617373656D626C7920636F64C6 +:1015000065002048656C703F3F3F0020446F776E58 +:101510006C6F61642070726F6772616D2066726FAC +:101520006D205043002045646974206578746572AD +:101530006E616C2072616D000C5468657365206388 +:101540006F6D6D616E647320617265206375727278 +:10155000656E746C7920737570706F727465643A1F +:101560000D0D000D416C6C206E756D6572696361C7 +:101570006C2076616C756573206172652073686F8D +:10158000776E20696E206865782E20205072657312 +:1015900073696E67203C4553433E206B6579207725 +:1015A000696C6C2065786974207468650D63757268 +:1015B00072656E7420636F6D6D616E642C2065764C +:1015C000656E207768696C65206C697374696E67F5 +:1015D0002F64756D70696E672E20204D6F737420B7 +:1015E00070726F6D707473207265717569726520A9 +:1015F000610D73696E676C65206368617261637405 +:1016000065722C207479706963616C6C79207468E0 +:1016100065206669727374206C6574746572206FDE +:1016200066207468652064657369726564206F70F4 +:1016300074696F6E2E0D0D466F7220696E666F7243 +:101640006D6174696F6E20726567617264696E673F +:10165000207468652073696E676C652D737465709E +:101660002072756E20666561747572652C0D7479D3 +:10167000706520273F27207768656E2061736B6552 +:1016800064202753696E676C652D737465702F4EE7 +:101690006F726D616C27206265666F72652072756E +:1016A0006E6E696E67207468652070726F67726114 +:1016B0006D2E0D0D000C5468652073696E676C65A6 +:1016C00020737465702072756E2066656174757222 +:1016D0006520616C6C6F777320796F7520746F2053 +:1016E0006578656375746520796F75722070726FA7 +:1016F0006772616D2066726F6D206D656D6F7279B6 +:101700000D6F6E6520696E737472756374696F6EA8 +:1017100020617420612074696D652C207768696C84 +:1017200065206D6F6E69746F72696E67207468658D +:101730002072656769737465727320616E642069D5 +:101740006E737472756374696F6E732E0D497420B5 +:101750006974204E4F5420612073696D756C6174FB +:10176000696F6E2C207468652070726F6772616D8E +:1017700020697320657865637574656420627920DB +:1017800074686520383033312F35312070726F63C3 +:101790006573736F722E0D45787465726E616C207F +:1017A000496E74657272757074202331206D757383 +:1017B000742062652068656C64206C6F7720746F9C +:1017C000206D616B65207468652073696E676C6558 +:1017D00020737465702066756E6374696F6E2E0D6C +:1017E0000D4465737069746520617474656D7074FF +:1017F0007320746F206D616B652074686520736958 +:101800006E676C6520737465702072756E20636FEF +:101810006D70617469626C65207769746820616CB1 +:101820006C2070726F6772616D732C0D74686572D5 +:10183000652077696C6C20616C77617973206265D3 +:1018400020736F6D65206261736963206C696D69D7 +:10185000746174696F6E732064756520746F20699C +:101860007473206E61747572653A0D0D20312D20F0 +:1018700045787465726E616C20496E74657272751C +:101880007074202331206D757374206E6F74206224 +:10189000652064697361626C65642C20652E672E17 +:1018A000204D4F562049452C233831680D20322DCC +:1018B0002054696D6572202331206D757374206228 +:1018C0006520636F72726563746C792067656E65FD +:1018D000726174696E672020746865206261756446 +:1018E000207261746520666F72207468652073656C +:1018F0007269616C20706F72740D20332D20544911 +:1019000020616E642052492077696C6C206E6F7480 +:1019100020776F726B206E6F726D616C6C792C200A +:10192000652E672E20323030333A204A4E42205204 +:10193000492C323030332C2075736520736B6970FD +:101940002E2E2E0D20342D20496E74657272757006 +:1019500074732077696C6C206E6F742067657420D7 +:1019600073657276696365206F722077696C6C208D +:10197000696E74657272757074207468652073691D +:101980006E676C6520737465700D20352D20416283 +:101990006F7574203330206279746573206F662010 +:1019A0007370616365206D757374206265206C656A +:1019B000667420617661696C61626C65206F6E206F +:1019C00074686520737461636B210D20362D203F90 +:1019D0003F3F20204F746865722070726F626C65A3 +:1019E0006D73206D617920616C736F206578697308 +:1019F000742C2028746869732070726F6772616D2F +:101A000020697320465245452C20796F75206B6EF6 +:101A10006F77290D0D506572686170732074686569 +:101A200020776F727374206C696D69746174696F6B +:101A30006E206F66207468652073696E676C652020 +:101A4000737465702072756E206973207468617498 +:101A50002069742074616B657320610D76657279FD +:101A6000206C6F6E672074696D6520746F206578D7 +:101A70006563757465206576656E2073686F727432 +:101A800020706965636573206F6620636F64652EDF +:101A900020204974206973207265636F6D6D656ED7 +:101AA00064656420746861740D61206E6F726D618D +:101AB0006C2072756E20626520617474656D70743F +:101AC000656420666972737420746F20657374692D +:101AD0006D61746520776865726520746865207033 +:101AE000726F6772616D20676F65732061737472C6 +:101AF00061792C0D74686520617474656D70742053 +:101B0000612073696E676C65207374657020617401 +:101B10002074686520626567696E6E696E67206F04 +:101B20006620746865207175657374696F6E616293 +:101B30006C6520636F64652C207769746820610D83 +:101B400068617264636F7079206F662074686520C5 +:101B5000617373656D626C79206C697374696E670B +:101B60002066696C65206F6E2D68616E6420666FFB +:101B700072206D656D6F7279206C6F636174696F2F +:101B80006E207265666572656E63652E0D0D000CC4 +:101B90004265747765656E2073746570732C20746C +:101BA0006865206D6F6E69746F7220757365732040 +:101BB0006162736F6C7574656C79204E4F20696E2D +:101BC0007465726E616C206F722065787465726ED8 +:101BD000616C206D656D6F72792E0D486F7765763B +:101BE00065722C2061626F757420333020627974C5 +:101BF0006573206F6620737461636B20737061631B +:101C000065206D757374206265206C656674206153 +:101C10007661696C61626C652E2E2E0D0D447572B5 +:101C2000696E6720612073696E676C6520737465E7 +:101C3000702072756E2C207072657373696E6720E8 +:101C400052455455524E2072657065617465646CDE +:101C5000792077696C6C20626520746865207573E3 +:101C600075616C20636F757273650D6F66206163BB +:101C700074696F6E2E2020486F77657665722C2010 +:101C80006F74686572206F7074696F6E7320617213 +:101C90006520617661696C61626C652E0D0D202096 +:101CA00020202020202020202020547970696E6779 +:101CB00020273F272077696C6C20646973706C6102 +:101CC0007920746869732068656C7020736372652D +:101CD000656E0D0D0053696E676C652053746570F9 +:101CE00020436F6D6D616E64733A0D0D203C52455B +:101CF000543E202020205072696E74205374617409 +:101D0000757320616E6420657865637574652074F1 +:101D10006865206E65787420696E7374727563747B +:101D2000696F6E0D203C53504143453E202045785D +:101D30006563757465206E65787420696E7374725E +:101D4000756374696F6E20772F6F7574207374617B +:101D5000747573206C696E65730D2020273F2720F2 +:101D600020202020446973706C6179207468697345 +:101D7000206F6E2D6C696E652068656C700D20207B +:101D800027522720202020205072696E74206F7502 +:101D900074205370656369616C2046756E63746965 +:101DA0006F6E205265676973746572730D2020270A +:101DB000482720202020204865782064756D7020F9 +:101DC000696E7465726E616C2072616D0D202027E2 +:101DD00053272020202020536B697020746869737A +:101DE00020696E737472756374696F6E0D2020279D +:101DF000412720202020204368616E676520746899 +:101E00006520416363756D756C61746F7227732013 +:101E100076616C75650D2020275127202020202019 +:101E2000517569742053696E676C652053746570D1 +:101E30002C20636F6E74696E7565206578656375B7 +:101E400074696E67206E6F726D616C6C790D0D0038 +:00000001FF diff --git a/examples/paulmon2.asm b/examples/paulmon2.asm new file mode 100644 index 0000000..679bf56 --- /dev/null +++ b/examples/paulmon2.asm @@ -0,0 +1,2512 @@ +; PAULMON2, a user-friendly 8051 monitor, by Paul Stoffregen +; Please email comments, suggestions, bugs to paul@pjrc.com + +; It's free. PAULMON2 is in the public domain. You may copy +; sections of code from PAULMON2 into your own programs, even +; for commercial purposes. PAULMON2 should only be distributed +; free of charge, but may be bundled as 'value-added' with other +; products, such as development boards, CDROMs, etc. Please +; distribute the PAULMON2.DOC file and other files, not just +; the object code! + +; The PAULMON2.EQU and PAULMON2.HDR files contain valuable +; information that could help you to write programs for use +; with PAULMON2. + +; PAULMON2 is in the public domain. PAULMON2 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. + + +; You are probably reading this code to see what it looks like +; and possibly learn something, or to modify it for some reason. +; Either is ok, but please remember that this code uses a number +; of tricks to cram all the functionality into just 4k. As a +; result, the code can be difficult to read, and adding new +; features can be very difficult without growing beyond 4k. To +; add or modify commands in PAULMON2, please consider using the +; "external command" functionality. It is easier to develop +; new commands this way, and you can distribute them to other +; users. Email paul@pjrc.com if you have new PAULMON2 +; commands to contribute to others. Details about adding new +; commands to PAULMON2 (with examples) can be found at: + +; http://www.pjrc.com/tech/8051/pm2_docs/addons.html + + +;---------------------------------------------------------; +; ; +; PAULMON2's default configuration ; +; ; +;---------------------------------------------------------; + +; PAULMON2 should be assembled using the modified AS31 assembler, +; originally written by Ken Stauffer, many small changes by Paul +; Stoffregen. This free assembler is available on the web at +; http://www.pjrc.com/tech/8051/index.html +; As well, these web pages have a fill-out form which makes it +; very easy to custom configure PAULMON2. Using this form will +; edit the code for you, run the AS31 assmebler, and send you the +; object code to program into your chip. + + +; These two parameters control where PAULMON2 will be assembled, +; and where it will attempt to LJMP at the interrupt vector locations. + +.equ base, 0x0000 ;location for PAULMON2 +.equ vector, 0x2000 ;location to LJMP interrupt vectors + +; These three parameters tell PAULMON2 where the user's memory is +; installed. "bmem" and "emem" define the space that will be searched +; for program headers, user installed commands, start-up programs, etc. +; "bmem" and "emem" should be use so they exclude memory areas where +; perphreal devices may be mapped, as reading memory from an io chip +; may reconfigure it unexpectedly. If flash rom is used, "bmem" and "emem" +; should also include the space where the flash rom is mapped. + +.equ pgm, 0x2000 ;default location for the user program +.equ bmem, 0x1000 ;where is the beginning of memory +.equ emem, 0xFFFF ;end of the memory + +; Flash ROM parameters. If "has_flash" is set to zero, all flash rom +; features are turned off, otherwise "bflash" and "eflash" should specify +; the memory range which is flash rom. Though AMD doesn't suggest it, +; you may be able to map only a part of the flash rom with your address +; decoder logic (and not use the rest), but you should be careful that +; "bflash" and "eflash" don't include and memory which is NOT flash rom +; so that the erase algorithm won't keep applying erase pulses until it +; finally gives up (which will stress the thin oxide and degrade the +; flash rom's life and reliability). "erase_pin" allows you to specify +; the bit address for a pin which (if held low) will tell PAULMON2 to +; erase the flash rom chip when it starts up. This is useful if you +; download programs with the "start-up" headers on them and the code you've +; put in the flash rom crashes! + +.equ has_flash, 0 ;set to non-zero value if flash installed +.equ bflash, 0x8000 ;first memory location of Flash ROM +.equ eflash, 0xFFFF ;last memory location of Flash ROM +.equ erase_pin, 0 ;00 = disable erase pin feature +;.equ erase_pin, 0xB5 ;B5 = pin 15, P3.5 (T1) + +; Please note... much of the memory management code only looks at the +; upper 8 bits of an address, so it's not a good idea to somehow map +; your memory chips (with complex address decoding logic) into chunks +; less than 256 bytes. In other words, only using a piece of a flash +; rom chip and mapping it between C43A to F91B would confuse PAULMON2 +; (as well as require quit a bit of address decoding logic circuitry) + + +; To set the baud rate, use this formula or set to 0 for auto detection +; baud_const = 256 - (crystal / (12 * 16 * baud)) + +.equ baud_const, 0 ;automatic baud rate detection +;.equ baud_const, 255 ;57600 baud w/ 11.0592 MHz +;.equ baud_const, 253 ;19200 baud w/ 11.0592 MHz +;.equ baud_const, 252 ;19200 baud w/ 14.7456 MHz +;.equ baud_const, 243 ;4808 baud w/ 12 MHz + +.equ line_delay, 6 ;num of char times to pause during uploads + +; About download speed: when writing to ram, PAULMON2 can accept data +; at the maximum baud rate (baud_const=255 or 57600 baud w/ 11.0592 MHz). +; Most terminal emulation programs introduce intentional delays when +; sending ascii data, which you would want to turn off for downloading +; larger programs into ram. For Flash ROM, the maximum speed is set by +; the time it takes to program each location... 9600 baud seems to work +; nicely for the AMD 28F256 chip. The "character pacing" delay in a +; terminal emulation program should be sufficient to download to flash +; rom and any baud rate. Some flash rom chips can write very quickly, +; allowing high speed baud rates, but other chips can not. You milage +; will vary... + + +; Several people didn't like the key definations in PAULMON1. +; Actually, I didn't like 'em either, but I never took the time +; to change it. Eventually I got used to them, but now it's +; really easy to change which keys do what in PAULMON2. You +; can guess what to do below, but don't use lowercase. + +.equ help_key, '?' ;help screen +.equ dir_key, 'M' ;directory +.equ run_key, 'R' ;run program +.equ dnld_key, 'D' ;download +.equ upld_key, 'U' ;upload +.equ nloc_key, 'N' ;new memory location +.equ jump_key, 'J' ;jump to memory location +.equ dump_key, 'H' ;hex dump memory +.equ intm_key, 'I' ;hex dump internal memory +.equ edit_key, 'E' ;edit memory +.equ clrm_key, 'C' ;clear memory +.equ erfr_key, 'Z' ;erase flash rom + +; timing parameters for AMD Flash ROM 28F256. These parameters +; and pretty conservative and they seem to work with crystals +; between 6 MHz to 24 MHz... (tested with AMD 28F256 chips only) +; unless you know this is a problem, it is probably not a good +; idea to fiddle with these. + +;.equ pgmwait, 10 ;22.1184 MHz crystal assumed +.equ pgmwait, 19 ;11.0592 MHz +.equ verwait, 5 +;.equ erwait1, 40 ;fourty delays @22.1184 +.equ erwait1, 20 ;twenty delays for 11.0592 MHz +.equ erwait2, 229 ;each delay .5 ms @22.1184MHz + + + +; These symbols configure paulmon2's internal memory usage. +; It is usually not a good idea to change these unless you +; know that you really have to. + +.equ psw_init, 0 ;value for psw (which reg bank to use) +.equ dnld_parm, 0x10 ;block of 16 bytes for download +.equ stack, 0x30 ;location of the stack +.equ baud_save, 0x78 ;save baud for warm boot, 4 bytes + +;---------------------------------------------------------; +; ; +; Interrupt Vectors ; +; (and little bits of code crammed in the empty spaces) ; +; ; +;---------------------------------------------------------; + + .org base + ljmp poweron ;reset vector + + .org base+3 + ljmp vector+3 ;ext int0 vector + +r6r7todptr: + mov dpl, r6 + mov dph, r7 + ret + + .org base+11 + ljmp vector+11 ;timer0 vector + +dptrtor6r7: + mov r6, dpl + mov r7, dph + ret + + .org base+19 + ljmp vector+19 ;ext int1 vector + +dash: mov a, #'-' ;seems kinda trivial, but each time + ajmp cout ;this appears in code, it takes 4 + nop ;bytes, but an acall takes only 2 + + .org base+27 + ljmp vector+27 ;timer1 vector + +cout_sp:acall cout + ajmp space + nop + + .org base+35 + ljmp vector+35 ;uart vector + +dash_sp:acall dash + ajmp space + nop + + .org base+43 + ljmp vector+43 ;timer2 vector (8052) + + +;---------------------------------------------------------; +; ; +; The jump table for user programs to call ; +; subroutines within PAULMON ; +; ; +;---------------------------------------------------------; + +.org base+46 ;never change this line!! Other + ;programs depend on these locations + ;to access paulmon2 functions + + ajmp phex1 ;2E + ajmp cout ;30 + ajmp cin ;32 + ajmp phex ;34 + ajmp phex16 ;36 + ajmp pstr ;38 + ajmp ghex ;3A + ajmp ghex16 ;3C + ajmp esc ;4E + ajmp upper ;40 + ljmp autobaud ;42 +pcstr_h:ljmp pcstr ;45 + ajmp newline ;48 + ljmp lenstr ;4A + ljmp pint8u ;4D + ljmp pint8 ;50 + ljmp pint16u ;53 + ljmp smart_wr ;56 + ljmp prgm ;59 + ljmp erall ;5C + ljmp find ;5F +cin_filter_h: + ljmp cin_filter ;62 + ajmp asc2hex ;64 + + +;---------------------------------------------------------; +; ; +; Subroutines for serial I/O ; +; ; +;---------------------------------------------------------; + + +cin: jnb ri, cin + clr ri + mov a, sbuf + ret + +dspace: acall space +space: mov a, #' ' +cout: jnb ti, cout + clr ti ;clr ti before the mov to sbuf! + mov sbuf, a + ret + +;clearing ti before reading sbuf takes care of the case where +;interrupts may be enabled... if an interrupt were to happen +;between those two instructions, the serial port will just +;wait a while, but in the other order and the character could +;finish transmitting (during the interrupt routine) and then +;ti would be cleared and never set again by the hardware, causing +;the next call to cout to hang forever! + +newline2: ;print two newlines + acall newline +newline:push acc ;print one newline + mov a, #13 + acall cout + mov a, #10 + acall cout + pop acc + ret + + ;get 2 digit hex number from serial port + ; c = set if ESC pressed, clear otherwise + ; psw.5 = set if return w/ no input, clear otherwise +ghex: +ghex8: clr psw.5 +ghex8c: + acall cin_filter_h ;get first digit + acall upper + cjne a, #27, ghex8f +ghex8d: setb c + clr a + ret +ghex8f: cjne a, #13, ghex8h + setb psw.5 + clr c + clr a + ret +ghex8h: mov r2, a + acall asc2hex + jc ghex8c + xch a, r2 ;r2 will hold hex value of 1st digit + acall cout +ghex8j: + acall cin_filter_h ;get second digit + acall upper + cjne a, #27, ghex8k + sjmp ghex8d +ghex8k: cjne a, #13, ghex8m + mov a, r2 + clr c + ret +ghex8m: cjne a, #8, ghex8p +ghex8n: acall cout + sjmp ghex8c +ghex8p: cjne a, #21, ghex8q + sjmp ghex8n +ghex8q: mov r3, a + acall asc2hex + jc ghex8j + xch a, r3 + acall cout + mov a, r2 + swap a + orl a, r3 + clr c + ret + + + + + ;carry set if esc pressed + ;psw.5 set if return pressed w/ no input +ghex16: + mov r2, #0 ;start out with 0 + mov r3, #0 + mov r4, #4 ;number of digits left + clr psw.5 + +ghex16c: + acall cin_filter_h + acall upper + cjne a, #27, ghex16d + setb c ;handle esc key + clr a + mov dph, a + mov dpl, a + ret +ghex16d:cjne a, #8, ghex16f + sjmp ghex16k +ghex16f:cjne a, #127, ghex16g ;handle backspace +ghex16k:cjne r4, #4, ghex16e ;have they entered anything yet? + sjmp ghex16c +ghex16e:acall cout + acall ghex16y + inc r4 + sjmp ghex16c +ghex16g:cjne a, #13, ghex16i ;return key + mov dph, r3 + mov dpl, r2 + cjne r4, #4, ghex16h + clr a + mov dph, a + mov dpl, a + setb psw.5 +ghex16h:clr c + ret +ghex16i:mov r5, a ;keep copy of original keystroke + acall asc2hex + jc ghex16c + xch a, r5 + lcall cout + mov a, r5 + push acc + acall ghex16x + pop acc + add a, r2 + mov r2, a + clr a + addc a, r3 + mov r3, a + djnz r4, ghex16c + clr c + mov dpl, r2 + mov dph, r3 + ret + +ghex16x: ;multiply r3-r2 by 16 (shift left by 4) + mov a, r3 + swap a + anl a, #11110000b + mov r3, a + mov a, r2 + swap a + anl a, #00001111b + orl a, r3 + mov r3, a + mov a, r2 + swap a + anl a, #11110000b + mov r2, a + ret + +ghex16y: ;divide r3-r2 by 16 (shift right by 4) + mov a, r2 + swap a + anl a, #00001111b + mov r2, a + mov a, r3 + swap a + anl a, #11110000b + orl a, r2 + mov r2, a + mov a, r3 + swap a + anl a, #00001111b + mov r3, a + ret + + + ;carry set if invalid input +asc2hex: + clr c + add a, #208 + jnc hex_not + add a, #246 + jc hex_maybe + add a, #10 + clr c + ret +hex_maybe: + add a, #249 + jnc hex_not + add a, #250 + jc hex_not + add a, #16 + clr c + ret +hex_not:setb c + ret + + + +phex: +phex8: + push acc + swap a + anl a, #15 + add a, #246 + jnc phex_b + add a, #7 +phex_b: add a, #58 + acall cout + pop acc +phex1: push acc + anl a, #15 + add a, #246 + jnc phex_c + add a, #7 +phex_c: add a, #58 + acall cout + pop acc + ret + + +phex16: + push acc + mov a, dph + acall phex + mov a, dpl + acall phex + pop acc + ret + + +;a not so well documented feature of pstr is that you can print +;multiple consecutive strings without needing to reload dptr +;(which takes 3 bytes of code!)... this is useful for inserting +;numbers or spaces between strings. + +pstr: push acc +pstr1: clr a + movc a, @a+dptr + inc dptr + jz pstr2 + mov c, acc.7 + anl a, #0x7F + acall cout + jc pstr2 + sjmp pstr1 +pstr2: pop acc + ret + + +upper: ;converts the ascii code in Acc to uppercase, if it is lowercase + push acc + clr c + subb a, #97 + jc upper2 ;is it a lowercase character + subb a, #26 + jnc upper2 + pop acc + add a, #224 ;convert to uppercase + ret +upper2: pop acc ;don't change anything + ret + + +lenstr: mov r0, #0 ;returns length of a string in r0 + push acc +lenstr1:clr a + movc a,@a+dptr + jz lenstr2 + mov c,acc.7 + inc r0 + Jc lenstr2 + inc dptr + sjmp lenstr1 +lenstr2:pop acc + ret + + +esc: ;checks to see if is waiting on serial port + ;C=clear if no , C=set if pressed + ;buffer is flushed + push acc + clr c + jnb ri,esc2 + mov a,sbuf + cjne a,#27,esc1 + setb c +esc1: clr ri +esc2: pop acc + ret + + +;---------------------------------------------------------; +; ; +; The 'high-level' stuff to interact with the user ; +; ; +;---------------------------------------------------------; + + +menu: ;first we print out the prompt, which isn't as simple + ;as it may seem, since external code can add to the + ;prompt, so we've got to find and execute all of 'em. + mov dptr, #prompt1 ;give 'em the first part of prompt + acall pcstr_h + mov a, r7 + acall phex + mov a, r6 + acall phex + ;mov dptr, #prompt2 + acall pstr + +;now we're finally past the prompt, so let's get some input + acall cin_filter_h ;get the input, finally + acall upper + +;push return address onto stack so we can just jump to the program + mov b, #(menu & 255) ;we push the return address now, + push b ;to save code later... + mov b, #(menu >> 8) ;if bogus input, just ret for + push b ;another prompt. + + + +;first we'll look through memory for a program header that says +;it's a user installed command which matches what the user pressed + +;user installed commands need to avoid changing R6/R7, which holds +;the memory pointer. The stack pointer can't be changed obviously. +;all the other general purpose registers should be available for +;user commands to alter as they wish. + +menux: mov b, a ;now search for external commands... + mov dptr, #bmem +menux1: acall find + jnc menuxend ;searched all the commands? + mov dpl, #4 + clr a + movc a,@a+dptr + cjne a, #254, menux2 ;only FE is an ext command + inc dpl + clr a + movc a,@a+dptr + cjne a, b, menux2 ;only run if they want it + acall space + mov dpl, #32 + acall pstr ;print command name + acall newline + mov dpl, #64 + clr a + jmp @a+dptr ;take a leap of faith and jump to it! +menux2: inc dph + mov a, dph + cjne a, #((emem+1) >> 8) & 255, menux1 +menuxend: + mov a, b + + +;since we didn't find a user installed command, use the builtin ones + +menu1a: cjne a, #help_key, menu1b + mov dptr, #help_cmd2 + acall pcstr_h + ajmp help +menu1b: cjne a, #dir_key, menu1c + mov dptr, #dir_cmd + acall pcstr_h + ajmp dir +menu1c: cjne a, #run_key, menu1d + mov dptr, #run_cmd + acall pcstr_h + ajmp run +menu1d: cjne a, #dnld_key, menu1e + mov dptr, #dnld_cmd + acall pcstr_h + ajmp dnld +menu1e: cjne a, #upld_key, menu1f + mov dptr, #upld_cmd + acall pcstr_h + ajmp upld +menu1f: cjne a, #nloc_key, menu1g + mov dptr, #nloc_cmd + acall pcstr_h + ajmp nloc +menu1g: cjne a, #jump_key, menu1h + mov dptr, #jump_cmd + acall pcstr_h + ajmp jump +menu1h: cjne a, #dump_key, menu1i + mov dptr, #dump_cmd + acall pcstr_h + ajmp dump +menu1i: cjne a, #edit_key, menu1j + mov dptr, #edit_cmd + acall pcstr_h + ajmp edit +menu1j: cjne a, #clrm_key, menu1k + mov dptr, #clrm_cmd + acall pcstr_h + ajmp clrm +menu1k: cjne a, #erfr_key, menu1l + mov a, #has_flash + jz menu_end + mov dptr, #erfr_cmd + acall pcstr_h + ajmp erfr +menu1l: cjne a, #intm_key, menu1m + mov dptr, #intm_cmd + acall pcstr_h + ljmp intm +menu1m: + + ;invalid input, no commands to run... +menu_end: ;at this point, we have not found + ajmp newline ;anything to run, so we give up. + ;remember, we pushed menu, so newline + ;will just return to menu. + +;.......................................................... + +;---------------------------------------------------------; + +;dnlds1 = "Begin sending Intel HEX format file to abort" +;dnlds2 = "Download aborted" +;dnlds3 = "Download completed" + + +;16 byte parameter table: (eight 16 bit values) +; * 0 = lines received +; * 1 = bytes received +; * 2 = bytes written +; * 3 = bytes unable to write +; * 4 = incorrect checksums +; * 5 = unexpected begin of line +; * 6 = unexpected hex digits (while waiting for bol) +; * 7 = unexpected non-hex digits (in middle of a line) + +dnld: + mov dptr, #dnlds1 + acall pcstr_h ;"begin sending file to abort" + mov r0, #dnld_parm + mov r2, #16 +dnld0: mov @r0, #0 ;initialize all parameters to 0 + inc r0 + djnz r2, dnld0 + + ;look for begining of line marker ':' +dnld1: acall cin + cjne a, #27, dnld2 ;Test for escape + sjmp dnld_esc +dnld2: cjne a, #':', dnld2b + mov r1, #0 + acall dnld_inc + sjmp dnld3 +dnld2b: ;check to see if it's a hex digit, error if it is + acall asc2hex + jc dnld1 + mov r1, #6 + acall dnld_inc + sjmp dnld1 + ;begin taking in the line of data +dnld3: mov a, #'.' + acall cout + mov r4, #0 ;r4 will count up checksum + acall dnld_ghex + mov r0, a ;R0 = # of data bytes + acall dnld_ghex + mov dph, a ;High byte of load address + acall dnld_ghex + mov dpl, a ;Low byte of load address + acall dnld_ghex ;Record type + cjne a, #1, dnld4 ;End record? + sjmp dnld_end +dnld4: jnz dnld_unknown ;is it a unknown record type??? +dnld5: mov a, r0 + jz dnld_get_cksum + acall dnld_ghex ;Get data byte + mov r2, a + mov r1, #1 + acall dnld_inc ;count total data bytes received + mov a, r2 + lcall smart_wr ;c=1 if an error writing + clr a + addc a, #2 + mov r1, a +; 2 = bytes written +; 3 = bytes unable to write + acall dnld_inc + inc dptr + djnz r0, dnld5 +dnld_get_cksum: + acall dnld_ghex ;get checksum + mov a, r4 + jz dnld1 ;should always add to zero +dnld_sumerr: + mov r1, #4 + acall dnld_inc ;all we can do it count # of cksum errors + sjmp dnld1 + +dnld_unknown: ;handle unknown line type + mov a, r0 + jz dnld_get_cksum ;skip data if size is zero +dnld_ukn2: + acall dnld_ghex ;consume all of unknown data + djnz r0, dnld_ukn2 + sjmp dnld_get_cksum + +dnld_end: ;handles the proper end-of-download marker + mov a, r0 + jz dnld_end_3 ;should usually be zero +dnld_end_2: + acall dnld_ghex ;consume all of useless data + djnz r0, dnld_ukn2 +dnld_end_3: + acall dnld_ghex ;get the last checksum + mov a, r4 + jnz dnld_sumerr + acall dnld_dly + mov dptr, #dnlds3 + acall pcstr_h ;"download went ok..." + ;consume any cr or lf character that may have been + ;on the end of the last line + jnb ri, dnld_sum + acall cin + sjmp dnld_sum + + + +dnld_esc: ;handle esc received in the download stream + acall dnld_dly + mov dptr, #dnlds2 + acall pcstr_h ;"download aborted." + sjmp dnld_sum + +dnld_dly: ;a short delay since most terminal emulation programs + ;won't be ready to receive anything immediately after + ;they've transmitted a file... even on a fast Pentium(tm) + ;machine with 16550 uarts! + mov r0, #0 +dnlddly2:mov r1, #0 + djnz r1, * ;roughly 128k cycles, appox 0.1 sec + djnz r0, dnlddly2 + ret + +dnld_inc: ;increment parameter specified by R1 + ;note, values in Acc and R1 are destroyed + mov a, r1 + anl a, #00000111b ;just in case + rl a + add a, #dnld_parm + mov r1, a ;now r1 points to lsb + inc @r1 + mov a, @r1 + jnz dnldin2 + inc r1 + inc @r1 +dnldin2:ret + +dnld_gp: ;get parameter, and inc to next one (@r1) + ;carry clear if parameter is zero. + ;16 bit value returned in dptr + setb c + mov dpl, @r1 + inc r1 + mov dph, @r1 + inc r1 + mov a, dpl + jnz dnldgp2 + mov a, dph + jnz dnldgp2 + clr c +dnldgp2:ret + + + +;a spacial version of ghex just for the download. Does not +;look for carriage return or backspace. Handles ESC key by +;poping the return address (I know, nasty, but it saves many +;bytes of code in this 4k ROM) and then jumps to the esc +;key handling. This ghex doesn't echo characters, and if it +;sees ':', it pops the return and jumps to an error handler +;for ':' in the middle of a line. Non-hex digits also jump +;to error handlers, depending on which digit. + +dnld_ghex: +dnldgh1:acall cin + acall upper + cjne a, #27, dnldgh3 +dnldgh2:pop acc + pop acc + sjmp dnld_esc +dnldgh3:cjne a, #':', dnldgh5 +dnldgh4:mov r1, #5 ;handle unexpected beginning of line + acall dnld_inc + pop acc + pop acc + ajmp dnld3 ;and now we're on a new line! +dnldgh5:acall asc2hex + jnc dnldgh6 + mov r1, #7 + acall dnld_inc + sjmp dnldgh1 +dnldgh6:mov r2, a ;keep first digit in r2 +dnldgh7:acall cin + acall upper + cjne a, #27, dnldgh8 + sjmp dnldgh2 +dnldgh8:cjne a, #':', dnldgh9 + sjmp dnldgh4 +dnldgh9:acall asc2hex + jnc dnldghA + mov r1, #7 + acall dnld_inc + sjmp dnldgh7 +dnldghA:xch a, r2 + swap a + orl a, r2 + mov r2, a + add a, r4 ;add into checksum + mov r4, a + mov a, r2 ;return value in acc + ret + +;dnlds4 = "Summary:" +;dnlds5 = " lines received" +;dnlds6a = " bytes received" +;dnlds6b = " bytes written" + +dnld_sum: ;print out download summary + mov a, r6 + push acc + mov a, r7 + push acc + mov dptr, #dnlds4 + acall pcstr_h + mov r1, #dnld_parm + mov r6, #dnlds5 & 255 + mov r7, #dnlds5 >> 8 + acall dnld_i0 + mov r6, #dnlds6a & 255 + mov r7, #dnlds6a >> 8 + acall dnld_i0 + mov r6, #dnlds6b & 255 + mov r7, #dnlds6b >> 8 + acall dnld_i0 + +dnld_err: ;now print out error summary + mov r2, #5 +dnlder2:acall dnld_gp + jc dnlder3 ;any errors? + djnz r2, dnlder2 + ;no errors, so we print the nice message + mov dptr, #dnlds13 + acall pcstr_h + sjmp dlnd_sum_done + +dnlder3: ;there were errors, so now we print 'em + mov dptr, #dnlds7 + acall pcstr_h + ;but let's not be nasty... only print if necessary + mov r1, #(dnld_parm+6) + mov r6, #dnlds8 & 255 + mov r7, #dnlds8 >> 8 + acall dnld_item + mov r6, #dnlds9 & 255 + mov r7, #dnlds9 >> 8 + acall dnld_item + mov r6, #dnlds10 & 255 + mov r7, #dnlds10 >> 8 + acall dnld_item + mov r6, #dnlds11 & 255 + mov r7, #dnlds11 >> 8 + acall dnld_item + mov r6, #dnlds12 & 255 + mov r7, #dnlds12 >> 8 + acall dnld_item +dlnd_sum_done: + pop acc + mov r7, a + pop acc + mov r6, a + ajmp newline + +dnld_item: + acall dnld_gp ;error conditions + jnc dnld_i3 +dnld_i2:acall space + lcall pint16u + acall r6r7todptr + acall pcstr_h +dnld_i3:ret + +dnld_i0:acall dnld_gp ;non-error conditions + sjmp dnld_i2 + + +;dnlds7: = "Errors:" +;dnlds8: = " bytes unable to write" +;dnlds9: = " incorrect checksums" +;dnlds10: = " unexpected begin of line" +;dnlds11: = " unexpected hex digits" +;dnlds12: = " unexpected non-hex digits" +;dnlds13: = "No errors detected" + + + +;---------------------------------------------------------; + + +jump: + mov dptr, #prompt8 + acall pcstr_h + acall r6r7todptr + acall phex16 + mov dptr, #prompt4 + acall pcstr_h + acall ghex16 + jb psw.5, jump3 + jnc jump2 + ajmp abort2 +jump2: + acall dptrtor6r7 +jump3: acall newline + mov dptr, #runs1 + acall pcstr_h + acall r6r7todptr + +jump_doit: ;jump to user code @dptr (this used by run command also) + clr a + mov psw, a + mov b, a + mov r0, a + mov r1, a + mov r2, a + mov r3, a + mov r4, a + mov r5, a + mov r6, a + mov r7, a + mov sp, #8 ;start w/ sp=7, like a real reset + push acc ;unlike a real reset, push 0000 + push acc ;in case they end with a RET + jmp @a+dptr + + +;---------------------------------------------------------; + +dump: + mov r2, #16 ;number of lines to print + acall newline2 +dump1: acall r6r7todptr + acall phex16 ;tell 'em the memory location + mov a,#':' + acall cout_sp + mov r3, #16 ;r3 counts # of bytes to print + acall r6r7todptr +dump2: clr a + movc a, @a+dptr + inc dptr + acall phex ;print each byte in hex + acall space + djnz r3, dump2 + acall dspace ;print a couple extra space + mov r3, #16 + acall r6r7todptr +dump3: clr a + movc a, @a+dptr + inc dptr + anl a, #01111111b ;avoid unprintable characters + cjne a, #127, dump3b + clr a ;avoid 127/255 (delete/rubout) char +dump3b: add a, #224 + jc dump4 + clr a ;avoid control characters +dump4: add a, #32 + acall cout + djnz r3, dump3 + acall newline + acall line_dly + acall dptrtor6r7 + acall esc + jc dump5 + djnz r2, dump1 ;loop back up to print next line +dump5: ajmp newline + +;---------------------------------------------------------; + +edit: ;edit external ram... + mov dptr, #edits1 + acall pcstr_h + acall r6r7todptr +edit1: acall phex16 + mov a,#':' + acall cout_sp + mov a,#'(' + acall cout + acall dptrtor6r7 + clr a + movc a, @a+dptr + acall phex + mov dptr,#prompt10 + acall pcstr_h + acall ghex + jb psw.5,edit2 + jc edit2 + acall r6r7todptr + lcall smart_wr + acall newline + acall r6r7todptr + inc dptr + acall dptrtor6r7 + ajmp edit1 +edit2: mov dptr,#edits2 + ajmp pcstr_h + +;---------------------------------------------------------; + +dir: + mov dptr, #prompt9 + acall pcstr_h + mov r0, #21 +dir0a: acall space + djnz r0, dir0a + ;mov dptr, #prompt9b + acall pcstr_h + + mov dph, #(bmem >> 8) +dir1: acall find ;find the next program in memory + jc dir2 +dir_end:ajmp newline ;we're done if no more found +dir2: + acall dspace + mov dpl, #32 ;print its name + acall pstr + mov dpl, #32 ;how long is the name + acall lenstr + mov a, #33 + clr c + subb a, r0 + mov r0, a + mov a, #' ' ;print the right # of spaces +dir3: acall cout + djnz r0, dir3 + mov dpl, #0 + acall phex16 ;print the memory location + mov r0, #6 + mov a, #' ' +dir4: acall cout + djnz r0, dir4 + mov dpl, #4 ;now figure out what type it is + clr a + movc a, @a+dptr + mov r2, dph ;save this, we're inside a search + +dir5: cjne a, #254, dir5b + mov dptr, #type1 ;it's an external command + sjmp dir7 +dir5b: cjne a, #253, dir5c +dir5bb: mov dptr, #type4 ;it's a startup routine + sjmp dir7 +dir5c: cjne a, #35, dir5d + mov dptr, #type2 ;it's an ordinary program + sjmp dir7 +dir5d: cjne a, #249, dir5e + sjmp dir5bb +dir5e: +dir6: mov dptr, #type5 ;who knows what the hell it is + +dir7: acall pcstr_h ;print out the type + mov dph, r2 ;go back and find the next one + acall newline + mov a, #(emem >> 8) + cjne a, dph, dir8 ;did we just print the last one? + ajmp dir_end +dir8: inc dph + mov a, dph + cjne a, #((emem+1) >> 8) & 255, dir1 + ajmp dir_end + + +;type1=Ext Command +;type4=Startup +;type2=Program +;type5=??? + +;---------------------------------------------------------; + + +run: + acall newline2 + mov r2, #255 ;first print the menu, count items + mov dptr, #bmem + dec dph +run2: inc dph + mov a, dph + cjne a, #((emem+1) >> 8) & 255, run2b + sjmp run3 +run2b: acall find + jnc run3 ;have we found 'em all?? + mov dpl, #4 + clr a + movc a, @a+dptr + orl a, #00000011b + cpl a + jz run2 ;this one doesn't run... find next + acall dspace + inc r2 + mov a, #'A' ;print the key to press + add a, r2 + acall cout_sp + acall dash_sp + mov dpl, #32 + acall pstr ;and the command name + acall newline + ajmp run2 ;and continue doing this +run3: cjne r2, #255, run4 ;are there any to run?? + mov dptr, #prompt5 + ajmp pcstr_h +run4: mov dptr, #prompt3 ;ask the big question! + acall pcstr_h + mov a, #'A' + acall cout + acall dash + mov a, #'A' ;such user friendliness... + add a, r2 ;even tell 'em the choices + acall cout + mov dptr, #prompt4 + acall pcstr_h + acall cin_filter_h + cjne a, #27, run4aa ;they they hit + ajmp newline +run4aa: mov r3, a + mov a, #31 + clr c + subb a, r2 + mov a, r3 + jc run4a + acall upper +run4a: acall cout + mov r3, a + acall newline + ;check to see if it's under 32, if so convert to uppercase + mov a, r3 + clr c + subb a, #'A' + jc run4 ;if they typed less than 'A' + mov r3, a ;R3 has the number they typed + mov a, r2 ;A=R2 has the maximum number + clr c + subb a, r3 + jc run4 ;if they typed over the max + inc r3 + mov dptr, #bmem + dec dph +run5: inc dph + mov a, dph + cjne a, #((emem+1) >> 8) & 255, run5b + sjmp run8 +run5b: acall find + jnc run8 ;Shouldn't ever do this jump! + mov dpl, #4 + clr a + movc a, @a+dptr + orl a, #00000011b + cpl a + jz run5 ;this one doesn't run... find next + djnz r3, run5 ;count til we find the one they want + acall newline + mov dpl, #64 + ajmp jump_doit +run8: ret + +;---------------------------------------------------------; + +help: + mov dptr, #help1txt + acall pcstr_h + mov r4, #help_key + mov dptr, #help_cmd + acall help2 + mov r4, #dir_key + ;mov dptr, #dir_cmd + acall help2 + mov r4, #run_key + ;mov dptr, #run_cmd + acall help2 + mov r4, #dnld_key + ;mov dptr, #dnld_cmd + acall help2 + mov r4, #upld_key + ;mov dptr, #upld_cmd + acall help2 + mov r4, #nloc_key + ;mov dptr, #nloc_cmd + acall help2 + mov r4, #jump_key + ;mov dptr, #jump_cmd + acall help2 + mov r4, #dump_key + ;mov dptr, #dump_cmd + acall help2 + mov r4, #intm_key + ;mov dptr, #intm_cmd + acall help2 + mov r4, #edit_key + ;mov dptr, #edit_cmd + acall help2 + mov r4, #clrm_key + ;mov dptr, #clrm_cmd + acall help2 + mov a, #has_flash + jz help_skerfm + mov r4, #erfr_key + ;mov dptr, #erfr_cmd + acall help2 +help_skerfm: + mov dptr, #help2txt + acall pcstr_h + mov dptr, #bmem +help3: acall find + jnc help4 + mov dpl, #4 + clr a + movc a,@a+dptr + cjne a, #254, help3a ;only FE is an ext command + acall dspace + inc dpl + clr a + movc a,@a+dptr + acall cout + acall dash_sp + mov dpl, #32 + acall pstr + acall newline +help3a: inc dph + mov a, dph + cjne a, #((emem+1) >> 8) & 255, help3 +help4: + ajmp newline + +help2: ;print 11 standard lines + acall dspace ;given key in R4 and name in dptr + mov a, r4 + acall cout + acall dash_sp + acall pcstr_h + ajmp newline + +;---------------------------------------------------------; + +upld: + + acall get_mem + ;assume we've got the beginning address in r3/r2 + ;and the final address in r5/r4 (r4=lsb)... + + ;print out what we'll be doing + mov dptr, #uplds3 + acall pcstr_h + mov a, r3 + acall phex + mov a, r2 + acall phex + ;mov dptr, #uplds4 + acall pcstr_h + mov a, r5 + acall phex + mov a, r4 + acall phex + acall newline + + ;need to adjust end location by 1... + mov dph, r5 + mov dpl, r4 + inc dptr + mov r4, dpl + mov r5, dph + + mov dptr, #prompt7 + acall pcstr_h + acall cin + cjne a, #27, upld2e + ajmp abort_it +upld2e: acall newline + mov dpl, r2 + mov dph, r3 + +upld3: mov a, r4 ;how many more bytes to output?? + clr c + subb a, dpl + mov r2, a + mov a, r5 + subb a, dph + jnz upld4 ;if >256 left, then do next 16 + mov a, r2 + jz upld7 ;if we're all done + anl a, #11110000b + jnz upld4 ;if >= 16 left, then do next 16 + sjmp upld5 ;otherwise just finish it off +upld4: mov r2, #16 +upld5: mov a, #':' ;begin the line + acall cout + mov a, r2 + acall phex ;output # of data bytes + acall phex16 ;output memory location + mov a, dph + add a, dpl + add a, r2 + mov r3, a ;r3 will become checksum + clr a + acall phex ;output 00 code for data +upld6: clr a + movc a, @a+dptr + acall phex ;output each byte + add a, r3 + mov r3, a + inc dptr + djnz r2, upld6 ;do however many bytes we need + mov a, r3 + cpl a + inc a + acall phex ;and finally the checksum + acall newline + acall line_dly + acall esc + jnc upld3 ;keep working if no esc pressed + sjmp abort_it +upld7: mov a, #':' + acall cout + clr a + acall phex + acall phex + acall phex + inc a + acall phex + mov a, #255 + acall phex +upld8: ajmp newline2 + + +line_dly: ;a brief delay between line while uploading, so the + ;receiving host can be slow (i.e. most windows software) + mov a, r0 + push acc + mov r0, #line_delay*2 +line_d2:mov a, th0 ;get baud rate const +line_d3:inc a + nop + nop + jnz line_d3 + djnz r0, line_d2 + pop acc + mov r0, a + ret + +;---------------------------------------------------------; + +get_mem: ;this thing gets the begin and end locations for + ;a few commands. If an esc or enter w/ no input, + ;it pops it's own return and returns to the menu + ;(nasty programming, but we need tight code for 4k rom) + acall newline2 + mov dptr, #beg_str + acall pcstr_h + acall ghex16 + jc pop_it + jb psw.5, pop_it + push dph + push dpl + acall newline + mov dptr, #end_str + acall pcstr_h + acall ghex16 + mov r5, dph + mov r4, dpl + pop acc + mov r2, a + pop acc + mov r3, a + jc pop_it + jb psw.5, pop_it + ajmp newline + +pop_it: pop acc + pop acc +abort_it: + acall newline +abort2: mov dptr, #abort + ajmp pcstr_h + + +clrm: + acall get_mem + mov dptr, #sure + acall pcstr_h + acall cin_filter_h + acall upper + cjne a, #'Y', abort_it + acall newline2 + ;now we actually do it + +clrm2: mov dph, r3 + mov dpl, r2 +clrm3: clr a + lcall smart_wr + mov a, r5 + cjne a, dph, clrm4 + mov a, r4 + cjne a, dpl, clrm4 + ret +clrm4: inc dptr + sjmp clrm3 + +;---------------------------------------------------------; + +nloc: + mov dptr, #prompt6 + acall pcstr_h + acall ghex16 + jc abort2 + jb psw.5, abort2 + acall dptrtor6r7 + ajmp newline2 + +;---------------------------------------------------------; + +erfr: + acall newline2 + mov dptr, #erfr_cmd + acall pcstr_h + mov a, #',' + acall cout_sp + mov dptr, #sure + acall pcstr_h + acall cin_filter_h + acall upper + cjne a, #'Y', abort_it + acall newline2 + lcall erall + mov dptr, #erfr_ok + jnc erfr_end + mov dptr, #erfr_err +erfr_end: + ajmp pcstr_h + + + +;---------------------------------------------------------; + +intm: acall newline + mov r0, #0 +intm2: acall newline + cjne r0, #0x80, intm3 + ajmp newline +intm3: mov a, r0 + acall phex + mov a, #':' + acall cout +intm4: acall space + mov a, @r0 + acall phex + inc r0 + mov a, r0 + anl a, #00001111b + jnz intm4 + sjmp intm2 + + + + + +;************************************************************** +;************************************************************** +;***** ***** +;***** 2k page boundry is somewhere near here ***** +;***** (no ajmp or acall past this point) ***** +;***** ***** +;************************************************************** +;************************************************************** + + + +;---------------------------------------------------------; +; ; +; Subroutines for memory managment and non-serial I/O ; +; ; +;---------------------------------------------------------; + + +;finds the next header in the external memory. +; Input DPTR=point to start search (only MSB used) +; Output DPTR=location of next module +; C=set if a header found, C=clear if no more headers +find: mov dpl, #0 + clr a + movc a, @a+dptr + cjne a, #0xA5, find3 + inc dptr + clr a + movc a, @a+dptr + cjne a, #0xE5, find3 + inc dptr + clr a + movc a, @a+dptr + cjne a, #0xE0, find3 + inc dptr + clr a + movc a, @a+dptr + cjne a, #0xA5, find3 + mov dpl, #0 ;found one here! + setb c + ret +find3: mov a, #(emem >> 8) + cjne a, dph, find4 ;did we just check the end + clr c + ret +find4: inc dph ;keep on searching + sjmp find + + + +;routine that erases the whole flash rom! C=1 if failure, C=0 if ok + +erall: mov a, #has_flash + jz erallno + mov dptr, #bflash ;is it already erased ?? +erall0: clr a + movc a, @a+dptr + cpl a + jnz erall_b ;do actual erase if any byte not 255 + inc dptr + mov a, #((eflash+1) & 255) + cjne a, dpl, erall0 + mov a, #(((eflash+1) >> 8) & 255) + cjne a, dph, erall0 + ;if we get here, the entire chip was already erased, + ;so there is no need to do anything + clr c + ret +erall_b: + mov dptr, #bflash ;first program to all 00's +erall1: clr a + movc a, @a+dptr + jz erall2 ;don't waste time! + clr a + lcall prgm ;ok, program this byte + ;if the program operation failed... we should abort because + ;they are all likely to fail and it will take a long time... + ;which give the appearance that the program has crashed, + ;when it's really following the flash rom algorithm + ;correctly and getting timeouts. + jc erallno + ;mov a, #'.' + ;lcall cout +erall2: inc dptr + mov a, #((eflash+1) & 255) + cjne a, dpl, erall1 + mov a, #(((eflash+1) >> 8) & 255) + cjne a, dph, erall1 ;after this it's all 00's + mov dptr, #bflash ;beginning address + mov r4, #232 ;max # of trials, lsb + mov r5, #4 ;max # of trials, msb-1 +erall3: + ;mov a, #'#' + ;lcall cout + djnz r4, erall3a + djnz r5, erall3a +erallno:setb c + ret ;if it didn't work! +erall3a:mov a, #0x20 + mov c, ea ;- ;turn off all interrupts!! + mov psw.1, c + clr ea + movx @dptr, a ;send the erase setup + movx @dptr, a ;and begin the erase + mov r3, #erwait1 +erwt: mov r2, #erwait2 ;now wait 10ms... + djnz r2, * + djnz r3, erwt +erall4: mov a, #0xA0 + movx @dptr, a ;send erase verify + mov r2, #verwait ;wait for 6us + djnz r2, * + clr a + movc a, @a+dptr + mov c, psw.1 + mov ea, c ;- ;turn interrupts back on + cpl a + jnz erall3 ;erase again if not FF + inc dptr + mov a, #(((eflash+1) >> 8) & 255) ;verify whole array + cjne a, dph, erall4 + mov a, #((eflash+1) & 255) + cjne a, dpl, erall4 + mov a, #255 + mov dptr, #bflash + movx @dptr, a ;reset the flash rom + clr a + movx @dptr, a ;and go back to read mode + clr c + ret + + + + +;a routine that writes ACC to into flash memory at DPTR +; assumes that Vpp is active and stable already. +; C is set if error occurs, C is clear if it worked + +prgm: mov b, a + mov a, r2 + push acc + mov a, r3 + push acc + mov r2, #25 ;try to program 25 times if needed +prgm2: mov a, #40h + mov c, ea ;- ;turn off all interrupts!! + mov psw.1, c + clr ea + movx @dptr, a ;send setup programming command + mov a, b + movx @dptr, a ;write to the cell + mov r3, #pgmwait ;now wait for 10us + djnz r3, * + mov a, #0xC0 + movx @dptr, a ;send program verify command + mov r3, #verwait ;wait 6us while it adds margin + djnz r3, * + clr a + movc a, @a+dptr + mov c, psw.1 + mov ea, c ;- ;turn interrupts back on + clr c + subb a, b + jz prgmok ;note, C is still clear is ACC=0 + djnz r2, prgm2 +prgmbad:setb c ;it gets here if programming failure +prgmok: clr a + movx @dptr, a ;and go back into read mode + pop acc + mov r3, a + pop acc + mov r2, a + mov a, b ;restore ACC to original value + ret + + + +;************************************ +;To make PAULMON2 able to write to other +;types of memory than RAM and flash rom, +;modify this "smart_wr" routine. This +;code doesn't accept any inputs other +;that the address (dptr) and value (acc), +;so this routine must know which types +;of memory are in what address ranges +;************************************ + + +;Write to Flash ROM or ordinary RAM. Carry bit will indicate +;if the value was successfully written, C=1 if not written. + + +smart_wr: + push acc + push b + mov b, a + ;do we even have a flash rom? + mov a, #has_flash + jz wr_ram + ;there is a flash rom, but is this address in it? + mov a, dph + cjne a, #(eflash >> 8), isfl3 + sjmp wr_flash +isfl3: jnc wr_ram + cjne a, #(bflash >> 8), isfl4 + sjmp wr_flash +isfl4: jnc wr_flash + sjmp wr_ram + +wr_flash: + mov a, b + acall prgm + pop b + pop acc + ret + +wr_ram: mov a, b + movx @dptr, a ;write the value to memory + clr a + movc a, @a+dptr ;read it back from code memory + clr c + subb a, b + jz smwrok + movx a, @dptr ;read it back from data memory + clr c + subb a, b + jz smwrok +smwrbad:setb c + sjmp smwrxit +smwrok: clr c +smwrxit:pop b + pop acc + ret + + + + +;---------------------------------------------------------; +; ; +; Power-On initialization code and such... ; +; ; +;---------------------------------------------------------; + +;first the hardware has to get initialized. + +intr_return: + reti + +poweron: + clr a + mov ie, a ;all interrupts off + mov ip, a + mov psw, #psw_init + ;clear any interrupt status, just in case the user put + ;"ljmp 0" inside their interrupt service code. + acall intr_return + acall intr_return + cpl a + mov p0, a + mov p1, a + mov p2, a + mov p3, a + mov sp, #stack + +;Before we start doing any I/O, a short delay is required so +;that any external hardware which may be in "reset mode" can +;initialize. This is typically a problem when a 82C55 chip +;is used and its reset line is driven from the R-C reset +;circuit used for the 8051. Because the 82C55 reset pin +;switches from zero to one at a higher voltage than the 8051, +;any 82C55 chips would still be in reset mode right now... + +rst_dly: + mov r1, #200 ;approx 100000 cycles +rdly2: mov r2, #249 ;500 cycles + djnz r2, * + djnz r1, rdly2 + +;Check for the Erase-on-startup signal and erase Flash ROM +;if it's there. + + mov a, #has_flash + jz skip_erase + mov a, #erase_pin + jz skip_erase + mov r0, #250 ;check it 250 times, just to be sure +chk_erase: + mov c, erase_pin + mov r1, #200 + djnz r1, * ;short delay + jc skip_erase ;skip erase if this bit is not low + djnz r0, chk_erase + lcall erall ;and this'll delete the flash rom +skip_erase: + +;run any user initialization programs in external memory + mov b, #249 + acall stcode + +;initialize the serial port, auto baud detect if necessary + acall autobaud ;set up the serial port + ;mov a, th1 + ;lcall phex + +;run the start-up programs in external memory. + mov b, #253 + acall stcode + +;now print out the nice welcome message + +welcome: + mov r0, #24 +welcm2: lcall newline + djnz r0, welcm2 + mov r0, #15 + mov a, #' ' +welcm4: lcall cout + djnz r0, welcm4 + mov dptr, #logon1 + lcall pcstr + mov dptr, #logon2 + lcall pcstr + lcall dir + mov r6, #(pgm & 255) + mov r7, #(pgm >> 8) + ljmp menu + + +stcode: mov dptr, #bmem ;search for startup routines +stcode2:lcall find + jnc stcode5 + mov dpl, #4 + clr a + movc a, @a+dptr + cjne a, b, stcode4 ;only startup code if matches B + push b + push dph + mov a, #(stcode3 & 255) + push acc + mov a, #(stcode3 >> 8) + push acc + mov dpl, #64 + clr a + jmp @a+dptr ;jump to the startup code +stcode3:pop dph ;hopefully it'll return to here + pop b +stcode4:inc dph + mov a, dph + cjne a, #((emem+1) >> 8) & 255, stcode2 +stcode5:ret ;now we've executed all of 'em + + +;to do automatic baud rate detection, we assume the user will +;press the carriage return, which will cause this bit pattern +;to appear on port 3 pin 0 (CR = ascii code 13, assume 8N1 format) +; +; 0 1 0 1 1 0 0 0 0 1 +; | | | | +; start bit----+ +--lsb msb--+ +----stop bit +; +;we'll start timer #1 in 16 bit mode at the transition between the +;start bit and the LSB and stop it between the MBS and stop bit. +;That will give approx the number of cpu cycles for 8 bits. Divide +;by 8 for one bit and by 16 since the built-in UART takes 16 timer +;overflows for each bit. We need to be careful about roundoff during +;division and the result has to be inverted since timer #1 counts up. Of +;course, timer #1 gets used in 8-bit auto reload mode for generating the +;built-in UART's baud rate once we know what the reload value should be. + + +autobaud: + mov a, #baud_const ;skip if user supplied baud rate constant + jnz autoend_jmp + mov a, baud_save+3 ;is there a value from a previous boot? + xrl baud_save+2, #01010101b + xrl baud_save+1, #11001100b + xrl baud_save+0, #00011101b + cjne a, baud_save+2, autob1 + cjne a, baud_save+1, autob1 + cjne a, baud_save+0, autob1 +autoend_jmp: + ajmp autoend + +autob1: ;wait for inactivity + + mov pcon, #0x80 ;configure uart, fast baud + mov scon, #0x42 ;configure uart, but receive disabled + mov tmod, #0x11 ;get timers ready for action (16 bit mode) + clr a + mov tcon, a + mov tl0, a + mov th0, a + mov tl1, a + mov th1, a + + ;make sure there is no activity on the line + ;before we actually begin looking for the carriage return + mov r0, #200 +autob1b:mov r1, #30 +autob1c:jnb p3.0, autob1 + djnz r1, autob1c + djnz r0, autob1b + +autob2: ;look for the bits of the carriage return + jb p3.0, autob2 ;wait for start bit + jb p3.0, autob2 + jb p3.0, autob2 ; check it a few more times to make + jb p3.0, autob2 ; sure we don't trigger on some noise + jb p3.0, autob2 +autob2b:jnb p3.0, autob2b ;wait for bit #0 to begin + setb tr1 ;and now we're timing it +autob2c:jb tf1, autob1 ;check for timeout while waiting + jb p3.0, autob2c ;wait for bit #1 to begin +autob2d:jb tf1, autob1 ;check for timeout while waiting + jnb p3.0, autob2d ;wait for bit #2 to begin +autob2e:jb tf1, autob1 ;check for timeout while waiting + jb p3.0, autob2e ;wait for bit #4 to begin + setb tr0 ;start timing last 4 bits +autob2f:jb tf1, autob1 ;check for timeout while waiting + jnb p3.0, autob2f ;wait for stop bit to begin + clr tr1 ;stop timing (both timers) + clr tr0 + + jb tf1, autob1 ;check for timeout one last time + + ;compute the baud rate based on timer1 + mov a, tl1 + rlc a + mov b, a + mov a, th1 + rlc a + jc autob1 ;error if timer0 > 32767 + mov c, b.7 + addc a, #0 + cpl a + inc a ;now a has the value to load into th1 + jz autob1 ;error if baud rate too fast + + ;after we get the carriage return, we need to make sure there + ;isn't any "crap" on the serial line, as there is in the case + ;were we get the letter E (and conclude the wrong baud rate). + ;unfortunately the simple approach of just looking at the line + ;for silence doesn't work, because we have to accept the case + ;where the user's terminal emulation is configured to send a + ;line feed after the carriage return. The best thing to do is + ;use the uart and look see if it receives anything + +autob3: mov th1, a ;config timer1 + mov tl1, #255 ;start asap! + mov tmod, #0x21 ;autoreload mode + setb ren ;turn on the uart + setb tr1 ;turn on timer1 for its clock + + mov a, th1 + cpl a + inc a + mov r1, a +autob3b:mov r0, #255 +autob3c:djnz r0, autob3c + djnz r1, autob3b + + jnb ri, autob4 + ;if we got here, there was some stuff after the carriage + ;return, so we'll read it and see if it was the line feed + clr ri + mov a, sbuf + anl a, #01111111b + add a, #246 + jz autob4 ;ok if 0A, the line feed character + add a, #5 + jz autob4 ;of if 05, since we may have missed start bit +autob1_jmp: + ljmp autob1 +autob4: + ;compute the baud rate based on timer0, check against timer1 value + mov a, tl0 + rlc a + mov r0, a + mov a, th0 + rlc a + mov r1, a + jc autob1_jmp ;error if timer0 > 32767 + mov a, r0 + rlc a + mov b, a + mov a, r1 + rlc a + mov c, b.7 + addc a, #0 + jz autob1_jmp ;error if baud too fast! + cpl a + inc a + cjne a, th1, autob1_jmp + ;acc has th1 value at this point + +autoend:mov baud_save+3, a + mov baud_save+2, a ;store the baud rate for next warm boot. + mov baud_save+1, a + mov baud_save+0, a + xrl baud_save+2, #01010101b + xrl baud_save+1, #11001100b + xrl baud_save+0, #00011101b + mov th1, a + mov tl1, a + mov tmod, #0x21 ;set timer #1 for 8 bit auto-reload + mov pcon, #0x80 ;configure built-in uart + mov scon, #0x52 + setb tr1 ;start the baud rate timer + ret + + + +;---------------------------------------------------------; +; ; +; More subroutines, but less frequent used, so ; +; they're down here in the second 2k page. ; +; ; +;---------------------------------------------------------; + + + +;this twisted bit of code looks for escape sequences for +;up, down, left, right, pageup, and pagedown, as well +;as ordinary escape and ordinary characters. Escape +;sequences are required to arrive with each character +;nearly back-to-back to the others, otherwise the characters +;are treated as ordinary user keystroaks. cin_filter +;returns a single byte when it sees the multi-byte escape +;sequence, as shown here. + +; return value key escape sequence +; 11 (^K) up 1B 5B 41 +; 10 (^J) down 1B 5B 42 +; 21 (^U) right 1B 5B 43 +; 8 (^H) left 1B 5B 44 +; 25 (^Y) page up 1B 5B 35 7E +; 26 (^Z) page down 1B 5B 36 7E + +.equ esc_char, 27 + +cin_filter: + jnb ri, cinf1 + lcall cin + cjne a, #esc_char, cinf_end + ;if esc was already in sbuf, just ignore it +cinf1: lcall cin + cjne a, #esc_char, cinf_end +cinf2: acall cinf_wait + jb ri, cinf4 + mov a, #esc_char + ret ;an ordinary ESC + +cinf4: ;if we get here, it's a control code, since a character + ;was received shortly after receiving an ESC character + lcall cin + cjne a, #'[', cinf_consume + acall cinf_wait + jnb ri, cin_filter + lcall cin +cinf5a: cjne a, #'A', cinf5b + mov a, #11 + ret +cinf5b: cjne a, #'B', cinf5c + mov a, #10 + ret +cinf5c: cjne a, #'C', cinf5d + mov a, #21 + ret +cinf5d: cjne a, #'D', cinf5e + mov a, #8 + ret +cinf5e: cjne a, #0x35, cinf5f + sjmp cinf8 +cinf5f: cjne a, #0x36, cinf5g + sjmp cinf8 +cinf5g: sjmp cinf_consume ;unknown escape sequence + +cinf8: ;when we get here, we've got the sequence for pageup/pagedown + ;but there's one more incoming byte to check... + push acc + acall cinf_wait + jnb ri, cinf_restart + lcall cin + cjne a, #0x7E, cinf_notpg + pop acc + add a, #228 +cinf_end: ret +cinf_restart: + pop acc + sjmp cin_filter +cinf_notpg: + pop acc +;unrecognized escape... eat up everything that's left coming in +;quickly, then begin looking again +cinf_consume: + acall cinf_wait + jnb ri, cin_filter + lcall cin + cjne a, #esc_char, cinf_consume + sjmp cinf2 + +;this thing waits for a character to be received for approx +;4 character transmit time periods. It returns immedately +;or after the entire wait time. It does not remove the character +;from the buffer, so ri should be checked to see if something +;actually did show up while it was waiting + .equ char_delay, 4 ;number of char xmit times to wait +cinf_wait: + mov a, r2 + push acc + mov r2, #char_delay*5 +cinfw2: mov a, th0 +cinfw3: jb ri, cinfw4 + inc a + jnz cinfw3 + djnz r2, cinfw2 +cinfw4: pop acc + mov r2, a + ret + + + + +pint8u: ;prints the unsigned 8 bit value in Acc in base 10 + push b + push acc + sjmp pint8b + +pint8: ;prints the signed 8 bit value in Acc in base 10 + push b + push acc + jnb acc.7, pint8b + mov a, #'-' + lcall cout + pop acc + push acc + cpl a + add a, #1 +pint8b: mov b, #100 + div ab + setb f0 + jz pint8c + clr f0 + add a, #'0' + lcall cout +pint8c: mov a, b + mov b, #10 + div ab + jnb f0, pint8d + jz pint8e +pint8d: add a, #'0' + lcall cout +pint8e: mov a, b + add a, #'0' + lcall cout + pop acc + pop b + ret + + + + ;print 16 bit unsigned integer in DPTR, using base 10. +pint16u: ;warning, destroys r2, r3, r4, r5, psw.5 + push acc + mov a, r0 + push acc + clr psw.5 + mov r2, dpl + mov r3, dph + +pint16a:mov r4, #16 ;ten-thousands digit + mov r5, #39 + acall pint16x + jz pint16b + add a, #'0' + lcall cout + setb psw.5 + +pint16b:mov r4, #232 ;thousands digit + mov r5, #3 + acall pint16x + jnz pint16c + jnb psw.5, pint16d +pint16c:add a, #'0' + lcall cout + setb psw.5 + +pint16d:mov r4, #100 ;hundreds digit + mov r5, #0 + acall pint16x + jnz pint16e + jnb psw.5, pint16f +pint16e:add a, #'0' + lcall cout + setb psw.5 + +pint16f:mov a, r2 ;tens digit + mov r3, b + mov b, #10 + div ab + jnz pint16g + jnb psw.5, pint16h +pint16g:add a, #'0' + lcall cout + +pint16h:mov a, b ;and finally the ones digit + mov b, r3 + add a, #'0' + lcall cout + + pop acc + mov r0, a + pop acc + ret + +;ok, it's a cpu hog and a nasty way to divide, but this code +;requires only 21 bytes! Divides r2-r3 by r4-r5 and leaves +;quotient in r2-r3 and returns remainder in acc. If Intel +;had made a proper divide, then this would be much easier. + +pint16x:mov r0, #0 +pint16y:inc r0 + clr c + mov a, r2 + subb a, r4 + mov r2, a + mov a, r3 + subb a, r5 + mov r3, a + jnc pint16y + dec r0 + mov a, r2 + add a, r4 + mov r2, a + mov a, r3 + addc a, r5 + mov r3, a + mov a, r0 + ret + + + +;pcstr prints the compressed strings. A dictionary of 128 words is +;stored in 4 bit packed binary format. When pcstr finds a byte in +;a string with the high bit set, it prints the word from the dictionary. +;A few bytes have special functions and everything else prints as if +;it were an ordinary string. + +; special codes for pcstr: +; 0 = end of string +; 13 = CR/LF +; 14 = CR/LF and end of string +; 31 = next word code should be capitalized + +pcstr: push acc + mov a, r0 + push acc + mov a, r1 + push acc + mov a, r4 + push acc + setb psw.1 + setb psw.5 +pcstr1: clr a + movc a, @a+dptr + inc dptr + jz pcstr2 + jb acc.7, decomp + anl a, #0x7F +pcstrs1:cjne a, #13, pcstrs2 + lcall newline + setb psw.1 + sjmp pcstr1 +pcstrs2:cjne a, #31, pcstrs3 + clr psw.5 + sjmp pcstr1 +pcstrs3:cjne a, #14, pcstrs4 + lcall newline + sjmp pcstr2 +pcstrs4: + clr psw.1 + lcall cout + sjmp pcstr1 +pcstr2: pop acc + mov r4, a + pop acc + mov r1, a + pop acc + mov r0, a + pop acc + ret + +;dcomp actually takes care of printing a word from the dictionary + +; dptr = position in packed words table +; r4=0 if next nibble is low, r4=255 if next nibble is high + +decomp: anl a, #0x7F + mov r0, a ;r0 counts which word + jb psw.1, decomp1 ;avoid leading space if first word + lcall space +decomp1:clr psw.1 + push dpl + push dph + mov dptr, #words + mov r4, #0 + mov a, r0 + jz dcomp3 + ;here we must seek past all the words in the table + ;that come before the one we're supposed to print + mov r1, a +dcomp2: acall get_next_nibble + jnz dcomp2 + ;when we get here, a word has been skipped... keep doing + ;this until we're pointing to the correct one + djnz r1, dcomp2 +dcomp3: ;now we're pointing to the correct word, so all we have + ;to do is print it out + acall get_next_nibble + jz dcomp_end + cjne a, #15, dcomp4 + ;the character is one of the 12 least commonly used + acall get_next_nibble + inc a + movc a, @a+pc + sjmp dcomp5 + .db "hfwgybxvkqjz" +dcomp4: ;the character is one of the 14 most commonly used + inc a + movc a, @a+pc + sjmp dcomp5 + .db "etarnisolumpdc" +dcomp5: ;decide if it should be uppercase or lowercase + mov c, psw.5 + mov acc.5, c + setb psw.5 + cjne r0, #20, dcomp6 + clr acc.5 +dcomp6: cjne r0, #12, dcomp7 + clr acc.5 +dcomp7: lcall cout + sjmp dcomp3 +dcomp_end: + pop dph + pop dpl + ajmp pcstr1 + +get_next_nibble: ;...and update dptr and r4, of course + clr a + movc a, @a+dptr + cjne r4, #0, gnn2 + mov r4, #255 + anl a, #00001111b + ret +gnn2: mov r4, #0 + inc dptr + swap a + anl a, #00001111b + ret + + +;---------------------------------------------------------; +; ; +; Here begins the data tables and strings ; +; ; +;---------------------------------------------------------; + +;this is the dictionary of 128 words used by pcstr. + +words: + .db 0x82, 0x90, 0xE8, 0x23, 0x86, 0x05, 0x4C, 0xF8 + .db 0x44, 0xB3, 0xB0, 0xB1, 0x48, 0x5F, 0xF0, 0x11 + .db 0x7F, 0xA0, 0x15, 0x7F, 0x1C, 0x2E, 0xD1, 0x40 + .db 0x5A, 0x50, 0xF1, 0x03, 0xBF, 0xBA, 0x0C, 0x2F + .db 0x96, 0x01, 0x8D, 0x3F, 0x95, 0x38, 0x0D, 0x6F + .db 0x5F, 0x12, 0x07, 0x71, 0x0E, 0x56, 0x2F, 0x48 + .db 0x3B, 0x62, 0x58, 0x20, 0x1F, 0x76, 0x70, 0x32 + .db 0x24, 0x40, 0xB8, 0x40, 0xE1, 0x61, 0x8F, 0x01 + .db 0x34, 0x0B, 0xCA, 0x89, 0xD3, 0xC0, 0xA3, 0xB9 + .db 0x58, 0x80, 0x04, 0xF8, 0x02, 0x85, 0x60, 0x25 + .db 0x91, 0xF0, 0x92, 0x73, 0x1F, 0x10, 0x7F, 0x12 + .db 0x54, 0x93, 0x10, 0x44, 0x48, 0x07, 0xD1, 0x26 + .db 0x56, 0x4F, 0xD0, 0xF6, 0x64, 0x72, 0xE0, 0xB8 + .db 0x3B, 0xD5, 0xF0, 0x16, 0x4F, 0x56, 0x30, 0x6F + .db 0x48, 0x02, 0x5F, 0xA8, 0x20, 0x1F, 0x01, 0x76 + .db 0x30, 0xD5, 0x60, 0x25, 0x41, 0xA4, 0x2C, 0x60 + .db 0x05, 0x6F, 0x01, 0x3F, 0x26, 0x1F, 0x30, 0x07 + .db 0x8E, 0x1D, 0xF0, 0x63, 0x99, 0xF0, 0x42, 0xB8 + .db 0x20, 0x1F, 0x23, 0x30, 0x02, 0x7A, 0xD1, 0x60 + .db 0x2F, 0xF0, 0xF6, 0x05, 0x8F, 0x93, 0x1A, 0x50 + .db 0x28, 0xF0, 0x82, 0x04, 0x6F, 0xA3, 0x0D, 0x3F + .db 0x1F, 0x51, 0x40, 0x23, 0x01, 0x3E, 0x05, 0x43 + .db 0x01, 0x7A, 0x01, 0x17, 0x64, 0x93, 0x30, 0x2A + .db 0x08, 0x8C, 0x24, 0x30, 0x99, 0xB0, 0xF3, 0x19 + .db 0x60, 0x25, 0x41, 0x35, 0x09, 0x8E, 0xCB, 0x19 + .db 0x12, 0x30, 0x05, 0x1F, 0x31, 0x1D, 0x04, 0x14 + .db 0x4F, 0x76, 0x12, 0x04, 0xAB, 0x27, 0x90, 0x56 + .db 0x01, 0x2F, 0xA8, 0xD5, 0xF0, 0xAA, 0x26, 0x20 + .db 0x5F, 0x1C, 0xF0, 0xF3, 0x61, 0xFE, 0x01, 0x41 + .db 0x73, 0x01, 0x27, 0xC1, 0xC0, 0x84, 0x8F, 0xD6 + .db 0x01, 0x87, 0x70, 0x56, 0x4F, 0x19, 0x70, 0x1F + .db 0xA8, 0xD9, 0x90, 0x76, 0x02, 0x17, 0x43, 0xFE + .db 0x01, 0xC1, 0x84, 0x0B, 0x15, 0x7F, 0x02, 0x8B + .db 0x14, 0x30, 0x8F, 0x63, 0x39, 0x6F, 0x19, 0xF0 + .db 0x11, 0xC9, 0x10, 0x6D, 0x02, 0x3F, 0x91, 0x09 + .db 0x7A, 0x41, 0xD0, 0xBA, 0x0C, 0x1D, 0x39, 0x5F + .db 0x07, 0xF2, 0x11, 0x17, 0x20, 0x41, 0x6B, 0x35 + .db 0x09, 0xF7, 0x75, 0x12, 0x0B, 0xA7, 0xCC, 0x48 + .db 0x02, 0x3F, 0x64, 0x12, 0xA0, 0x0C, 0x27, 0xE3 + .db 0x9F, 0xC0, 0x14, 0x77, 0x70, 0x11, 0x40, 0x71 + .db 0x21, 0xC0, 0x68, 0x25, 0x41, 0xF0, 0x62, 0x7F + .db 0xD1, 0xD0, 0x21, 0xE1, 0x62, 0x58, 0xB0, 0xF3 + .db 0x05, 0x1F, 0x73, 0x30, 0x77, 0xB1, 0x6F, 0x19 + .db 0xE0, 0x19, 0x43, 0xE0, 0x58, 0x2F, 0xF6, 0xA4 + .db 0x14, 0xD0, 0x23, 0x03, 0xFE, 0x31, 0xF5, 0x14 + .db 0x30, 0x99, 0xF8, 0x03, 0x3F, 0x64, 0x22, 0x51 + .db 0x60, 0x25, 0x41, 0x2F, 0xE3, 0x01, 0x56, 0x27 + .db 0x93, 0x09, 0xFE, 0x11, 0xFE, 0x79, 0xBA, 0x60 + .db 0x75, 0x42, 0xEA, 0x62, 0x58, 0xA0, 0xE5, 0x1F + .db 0x53, 0x4F, 0xD1, 0xC0, 0xA3, 0x09, 0x42, 0x53 + .db 0xF7, 0x12, 0x04, 0x62, 0x1B, 0x30, 0xF5, 0x05 + .db 0xF7, 0x69, 0x0C, 0x35, 0x1B, 0x70, 0x82, 0x2F + .db 0x2F, 0x14, 0x4F, 0x51, 0xC0, 0x64, 0x25, 0x00 + +;STR + +logon1: .db "Welcome",128,148,"2, by",31,248,31,254,13,14 +logon2: .db 32,32,"See",148,"2.DOC,",148,"2.EQU",164 + .db 148,"2.HDR",180,213,141,".",14 +abort: .db " ",31,158,31,160,"!",13,14 +prompt1:.db 148,"2 Loc:",0 +prompt2:.db " >", 160 ;must follow after prompt1 +prompt3:.db 134,202,130,'(',0 +prompt4:.db "),",149,140,128,200,": ",0 +prompt5:.db 31,151,130,195,"s",199,166,131,"," + .db 186," JUMP",128,134,161,"r",130,13,14 +prompt6:.db 13,13,31,135,131,129,": ",0 +prompt7:.db 31,228,251," key: ",0 +prompt8:.db 13,13,31,136,128,131,129," (",0 +prompt9:.db 13,13,31,130,31,253,0 +prompt9b:.db 31,129,32,32,32,32,32,31,201,14 ;must follow prompt9 +prompt10:.db ") ",31,135,31,178,": ",0 +beg_str:.db "First",31,129,": ",0 +end_str:.db "Last",31,129,":",32,32,0 +sure: .db 31,185,161," sure?",0 +edits1: .db 13,13,31,156,154,146,",",140,128,200,14 +edits2: .db " ",31,156,193,",",142,129,247,13,14 +dnlds1: .db 13,13,31,159," ascii",249,150,31,152,132,137 + .db ",",149,140,128,160,13,14 +dnlds2: .db 13,31,138,160,"ed",13,14 +dnlds3: .db 13,31,138,193,"d",13,14 +dnlds4: .db "Summary:",14 +dnlds5: .db " ",198,"s",145,"d",14 +dnlds6a:.db " ",139,145,"d",14 +dnlds6b:.db " ",139," written",14 +dnlds7: .db 31,155,":",14 +dnlds8: .db " ",139," unable",128," write",14 +dnlds9: .db 32,32,"bad",245,"s",14 +dnlds10:.db " ",133,159,150,198,14 +dnlds11:.db " ",133,132,157,14 +dnlds12:.db " ",133," non",132,157,14 +dnlds13:.db 31,151,155," detected",13,14 +runs1: .db 13,134,"ning",130,":",13,14 +uplds3: .db 13,13,"Sending",31,152,132,137,172,32,32,0 +uplds4: .db " ",128,32,32,0 ;must follow uplds3 +help1txt:.db 13,13,"Standard",31,158,"s",14 +help2txt:.db 31,218,31,244,"ed",31,158,"s",14 +type1: .db 31,154,158,0 +type2: .db 31,130,0 +type4: .db 31,143,31,226,31,170,0 +type5: .db "???",0 +help_cmd2:.db 31,215,0 +help_cmd: .db 31,142,215,209,0 ;these 11 _cmd string must be in order +dir_cmd: .db 31,209,130,"s",0 +run_cmd: .db 31,134,130,0 +dnld_cmd: .db 31,138,0 +upld_cmd: .db 31,147,0 +nloc_cmd: .db 31,135,129,0 +jump_cmd: .db 31,136,128,131,129,0 +dump_cmd: .db 31,132,219,154,131,0 +intm_cmd: .db 31,132,219,192,131,0 +edit_cmd: .db 31,156,154,146,0 +clrm_cmd: .db 31,237,131,0 +erfr_cmd: .db 31,203,153,144,0 +erfr_ok: .db 31,153,144,203,'d',13,14 +erfr_err: .db 31,133,155,13,14 + + diff --git a/examples/paulmon2.ref b/examples/paulmon2.ref new file mode 100644 index 0000000..19b8a7f --- /dev/null +++ b/examples/paulmon2.ref @@ -0,0 +1,256 @@ +:030000000208A44F +:080003000220038E828F83228C +:08000B0002200BAE82AF83223C +:08001300022013742D0173009B +:08001B0002201B1173017100AA +:080023000220231116017100F7 +:03002B0002202B85 +:10002E00217601730167216521872194018A01CE12 +:10003E0021CE21A802093A020B59017D0201BB0211 +:10004E000AA2020AA8020AE602086502082B0207A3 +:10005E00B602078C020A21214A3098FDC298E59912 +:10006E0022117174203099FDC299F59922117DC02B +:10007E00E0740D1173740A1173D0E022C2D51162AF +:10008E0031A8B41B03D3E422B40D05D2D5C3E422A8 +:10009E00FA314A40E9CA1173116231A8B41B0280C9 +:1000AE00E4B40D03EAC322B40804117380D0B4156E +:1000BE000280F7FB314A40E0CB1173EAC44BC322F6 +:1000CE007A007B007C04C2D5116231A8B41B07D321 +:1000DE00E4F583F58222B408028003B47F0CBC04DD +:1000EE000280E5117331390C80DEB40D108B838ADA +:1000FE0082BC0407E4F583F582D2D5C322FD314AD2 +:10010E0040C6CD120073EDC0E03128D0E02AFAE4EB +:10011E003BFBDCB4C38A828B8322EBC454F0FBEA34 +:10012E00C4540F4BFBEAC454F0FA22EAC4540FFA3B +:10013E00EBC454F04AFAEBC4540FFB22C324D05044 +:10014E001424F64004240AC32224F9500824FA4049 +:10015E00042410C322D322C0E0C4540F24F650024C +:10016E002407243A1173D0E0C0E0540F24F6500255 +:10017E002407243A1173D0E022C0E0E5833165E50F +:10018E00823165D0E022C0E0E493A3600AA2E75476 +:10019E007F1173400280F1D0E022C0E0C394614031 +:1001AE0009941A5005D0E024E022D0E0227800C055 +:1001BE00E0E4936008A2E7084003A380F4D0E022B5 +:1001CE00C0E0C3309808E599B41B01D3C298D0E0C3 +:1001DE0022900DF51145EF3165EE316531941162C6 +:1001EE0031A875F0DFC0F075F001C0F0F5F0901099 +:1001FE0000F18C5024758204E493B4FE150582E45C +:10020E0093B5F00E11717582203194117D75824077 +:10021E00E4730583E583B400D8E5F0B43F07900F8F +:10022E005D1145A1D0B44D07900F65114581C0B445 +:10023E005207900F6A1145A137B44407900F6E1103 +:10024E004541A8B45507900F711145C145B44E07ED +:10025E00900F741145E137B44A07900F781145811C +:10026E0012B44807900F7E11458149B44507900F8F +:10027E008A1145818AB44307900F8F1145E113B45B +:10028E005A0B74006012900F931145E147B4490860 +:10029E00900F84114502076D017D900E8F114578E8 +:1002AE00107A10760008DAFB1167B41B028072B464 +:1002BE003A0679007141800A314A40EC7906714163 +:1002CE0080E6742E11737C007160F87160F5837195 +:1002DE0060F5827160B40102802D7022E8601471A5 +:1002EE0060FA79017141EA120865E43402F971414C +:1002FE00A3D8E97160EC60B07904714180AAE8601E +:10030E00F27160D8FC80ECE860047160D8F3716023 +:10031E00EC70E57138900EAE114530987A11678009 +:10032E00767138900EA61145806D78007900D9FE51 +:10033E00D8FA22E95407232410F907E770020907B7 +:10034E0022D3878209878309E5827005E5837001D0 +:10035E00C322116731A8B41B06D0E0D0E080C2B42E +:10036E003A0A79057141D0E0D0E041D0314A5006C9 +:10037E007907714180DCFA116731A8B41B0280D96C +:10038E00B43A0280DD314A50067907714180E8CADD +:10039E00C44AFA2CFCEA22EEC0E0EFC0E0900EB5A3 +:1003AE00114579107EBE7F0E910E7EC47F0E910E8A +:1003BE007EC97F0E910E7A05714F4009DAFA900FC1 +:1003CE000511458025900ED4114579167ED87F0EE5 +:1003DE0091007EE97F0E91007EF17F0E91007EF7F7 +:1003EE007F0E91007EFC7F0E9100D0E0FFD0E0FEEC +:1003FE00017D714F50091171120AE6110611452245 +:10040E00714F80F2900E37114511063187900E050F +:10041E00114511CE20D5065002E10E110E117D9020 +:10042E000F1311451106E4F5D0F5F0F8F9FAFBFCBF +:10043E00FDFEFF758108C0E0C0E0737A10117B11DC +:10044E00063187743A111E7B101106E493A33165B1 +:10045E001171DBF7116F7B101106E493A3547FB477 +:10046E007F01E424E04001E424201173DBEC117DD4 +:10047E00D1CA110E31CE4002DAC5017D900E79112E +:10048E004511063187743A111E74281173110EE44A +:10049E00933165900E521145118A20D510400E11E0 +:1004AE0006120865117D1106A3110E8191900E841E +:1004BE000145900E41114578151171D8FC11457505 +:1004CE008310F18C4002017D116F7582203194757D +:1004DE00822031BB7421C398F874201173D8FC7537 +:1004EE0082003187780674201173D8FC758204E47B +:1004FE0093AA83B4FE05900F4B8018B4FD05900FA0 +:10050E00528010B42305900F4F8008B4F90280EE8C +:10051E00900F5911458A83117D74FFB5830281D4E2 +:10052E000583E583B4009B81D4117B7AFF90100084 +:10053E0015830583E583B400028021F18C501D756F +:10054E008204E4934403F460E9116F0A74412A11A2 +:10055E001E11267582203194117DA140BAFF05909F +:10056E000E0E0145900E0011457441117311167453 +:10057E00412A1173900E0511451162B41B02017DC3 +:10058E00FB741FC39AEB400231A81173FB117DEB74 +:10059E00C3944140CFFBEAC39B40C90B901000159A +:1005AE00830583E583B400028017F18C50137582A6 +:1005BE0004E4934403F460E9DBE7117D7582408126 +:1005CE003422900F3311457C3F900F60D13A7C4D11 +:1005DE00D13A7C52D13A7C44D13A7C55D13A7C4EB8 +:1005EE00D13A7C4AD13A7C48D13A7C49D13A7C45C1 +:1005FE00D13A7C43D13A740060047C5AD13A900FC0 +:10060E00411145901000F18C5020758204E493B492 +:10061E00FE11116F0582E49311731126758220313C +:10062E0094117D0583E583B400DC017D116FEC111F +:10063E007311261145017DD1DC900F1D1145EB3153 +:10064E0065EA31651145ED3165EC3165117D8D83BE +:10065E008C82A3AC82AD83900E2D11451167B41B15 +:10066E0002E10C117D8A828B83ECC39582FAED95A3 +:10067E00837009EA603254F0700280027A10743A84 +:10068E001173EA31653187E58325822AFBE43165F2 +:10069E00E49331652BFBA3DAF7EBF4043165117D9E +:1006AE00D1CA31CE50C38056743A1173E4316531DC +:1006BE0065316504316574FF3165017BE8C0E07812 +:1006CE000CE58C04000070FBD8F7D0E0F822117B0B +:1006DE00900E5B114511CE402120D51EC083C082E5 +:1006EE00117D900E65114511CEAD83AC82D0E0FA2E +:1006FE00D0E0FB400520D502017DD0E0D0E0117D99 +:10070E00900DED0145D1DC900E6F1145116231A8AF +:10071E00B459EB117B8B838A82E4120865EDB583A5 +:10072E0005ECB5820122A380F0900E24114511CE66 +:10073E0040CE20D5CB110E017B117B900F9311452E +:10074E00742C111E900E6F1145116231A8B459AE62 +:10075E00117B1207B6900F985003900F9F01451111 +:10076E007D7800117DB88002017DE83165743A1103 +:10077E00731171E6316508E8540F70F580E57582E6 +:10078E0000E493B4A517A3E493B4E511A3E493B4E2 +:10079E00E00BA3E493B4A505758200D32274FFB5D4 +:1007AE008302C322058380D674006038908000E4F3 +:1007BE0093F4700DA37400B582F57400B583F0C385 +:1007CE0022908000E4936006E412082B4016A37476 +:1007DE0000B582F07400B583EB9080007CE87D0458 +:1007EE00DC04DD02D3227420A2AF92D1C2AFF0F0AE +:1007FE007B147AE5DAFEDBFA74A0F07A05DAFEE411 +:10080E0093A2D192AFF470D8A37400B583EA7400AA +:10081E00B582E574FF908000F0E4F0C322F5F0EAB3 +:10082E00C0E0EBC0E07A197440A2AF92D1C2AFF033 +:10083E00E5F0F07B13DBFE74C0F07B05DBFEE4938A +:10084E00A2D192AFC395F06003DADCD3E4F0D0E02E +:10085E00FBD0E0FAE5F022C0E0C0F0F5F0740060E5 +:10086E001BE583B4FF02800B5012B480028004504B +:10087E00028009E5F0112BD0F0D0E022E5F0F0E493 +:10088E0093C395F06009E0C395F06003D38001C374 +:10089E00D0F0D0E02232E4F5A8F5B875D00011A35F +:1008AE0011A3F4F580F590F5A0F5B075813079C8F7 +:1008BE007AF9DAFED9FA740060137400600F78FAD0 +:1008CE00A20079C8D9FE4005D8F61207B675F0F920 +:1008DE00310D313A75F0FD310D781812007DD8FBCF +:1008EE00780F7420120073D8FB900DBB120B599029 +:1008FE000DCF120B591204C07E007F200201DF9033 +:10090E00100012078C5024758204E493B5F015C0C4 +:10091E00F0C083742EC0E07409C0E0758240E473A9 +:10092E00D083D0F00583E583B400D7227400701411 +:10093E00E57B637A556379CC63781DB57A08B57912 +:10094E0005B578024100758780759842758911E466 +:10095E00F588F58AF58CF58BF58D78C8791E30B053 +:10096E00E5D9FBD8F720B0FD20B0FA20B0F720B0C3 +:10097E00F420B0F130B0FDD28E208FCA20B0FA2014 +:10098E008FC430B0FA208FBE20B0FAD28C208FB632 +:10099E0030B0FAC28EC28C208FACE58B33F5F0E509 +:1009AE008D3340A2A2F73400F404609AF58D758B56 +:1009BE00FF758921D29CD28EE58DF404F978FFD88B +:1009CE00FED9FA309811C298E599547F24F6600743 +:1009DE0024056003020954E58A33F8E58C33F940A7 +:1009EE00F3E833F5F0E933A2F7340060E7F404B529 +:1009FE008DE2F57BF57AF579F578637A556379CCE6 +:100A0E0063781DF58DF58B758921758780759852E4 +:100A1E00D28E22309806120067B41B51120067B4B2 +:100A2E001B4B518F209803741B22120067B45B443A +:100A3E00518F3098DE120067B44103740B22B4421A +:100A4E0003740A22B44303741522B44403740822B7 +:100A5E00B435028007B4360280028018C0E0518F90 +:100A6E0030980B120067B47E09D0E024E422D0E067 +:100A7E0080A1D0E0518F30989A120067B41BF58098 +:100A8E00A1EAC0E07A14E58C2098050470FADAF633 +:100A9E00D0E0FA22C0F0C0E08013C0F0C0E030E732 +:100AAE000C742D120073D0E0C0E0F4240175F064D4 +:100ABE0084D2D56007C2D52430120073E5F075F0EC +:100ACE000A8430D50260052430120073E5F024301C +:100ADE00120073D0E0D0F022C0E0E8C0E0C2D5AA88 +:100AEE0082AB837C107D2771446007243012007323 +:100AFE00D2D57CE87D037144700330D507243012C3 +:100B0E000073D2D57C647D007144700330D5072408 +:100B1E0030120073D2D5EAABF075F00A8470033050 +:100B2E00D5052430120073E5F08BF02430120073DB +:100B3E00D0E0F8D0E022780008C3EA9CFAEB9DFBE7 +:100B4E0050F618EA2CFAEB3DFBE822C0E0E8C0E0D4 +:100B5E00E9C0E0ECC0E0D2D1D2D5E493A360252069 +:100B6E00E72E547FB40D0712007DD2D180ECB41F56 +:100B7E0004C2D580E5B40E0512007D8007C2D112E5 +:100B8E00007380D6D0E0FCD0E0F9D0E0F8D0E022BF +:100B9E00547FF820D103120071C2D1C082C083905D +:100BAE000C137C00E86007F9910270FCD9FA9102EF +:100BBE00603CB40F1291020483801E6866776779D9 +:100BCE006278766B716A7A0483800E657461726ED8 +:100BDE0069736F6C756D706463A2D592E5D2D5B8EA +:100BEE001402C2E5B80C02C2E512007380C0D083B5 +:100BFE00D0826168E493BC00057CFF540F227C0018 +:100C0E00A3C4540F228290E82386054CF844B3B057 +:100C1E00B1485FF0117FA0157F1C2ED1405A50F1C4 +:100C2E0003BFBA0C2F96018D3F95380D6F5F1207DB +:100C3E00710E562F483B6258201F7670322440B8F2 +:100C4E0040E1618F01340BCA89D3C0A3B958800427 +:100C5E00F80285602591F092731F107F1254931045 +:100C6E00444807D126564FD0F66472E0B83BD5F013 +:100C7E00164F56306F48025FA8201F017630D560A0 +:100C8E002541A42C60056F013F261F30078E1DF0F5 +:100C9E006399F042B8201F2330027AD1602FF0F60C +:100CAE00058F931A5028F082046FA30D3F1F5140F9 +:100CBE0023013E0543017A01176493302A088C24E0 +:100CCE003099B0F31960254135098ECB19123005D4 +:100CDE001F311D04144F761204AB279056012FA816 +:100CEE00D5F0AA26205F1CF0F361FE0141730127A7 +:100CFE00C1C0848FD6018770564F19701FA8D99026 +:100D0E0076021743FE01C1840B157F028B14308FC0 +:100D1E0063396F19F011C9106D023F91097A41D0F4 +:100D2E00BA0C1D395F07F2111720416B3509F775A3 +:100D3E00120BA7CC48023F6412A00C27E39FC014ED +:100D4E00777011407121C0682541F0627FD1D021AA +:100D5E00E16258B0F3051F733077B16F19E0194394 +:100D6E00E0582FF6A414D02303FE31F5143099F871 +:100D7E00033F6422516025412FE30156279309FE5C +:100D8E0011FE79BA607542EA6258A0E51F534FD141 +:100D9E00C0A3094253F71204621B30F505F7690C24 +:100DAE00351B70822F2F144F51C064250057656C70 +:100DBE00636F6D658094322C2062791FF81FFE0DD3 +:100DCE000E202053656594322E444F432C94322EC0 +:100DDE00455155A494322E484452B4D58D2E0E2032 +:100DEE001F9E1FA0210D0E9432204C6F633A0020DF +:100DFE003EA086CA822800292C958C80C83A2000F5 +:100E0E001F9782C373C7A6832CBA204A554D5080B4 +:100E1E0086A172820D0E0D0D1F8783813A20001F51 +:100E2E00E4FB206B65793A20000D0D1F88808381CD +:100E3E002028000D0D1F821FFD001F812020202065 +:100E4E00201FC90E29201F871FB23A200046697243 +:100E5E0073741F813A20004C6173741F813A2020F5 +:100E6E00001FB9A120737572653F000D0D1F9C9A6E +:100E7E00922C8C80C80E20201F9CC12C8E81F70DC9 +:100E8E000E0D0D1F9F206173636969F9961F98847B +:100E9E00892C958C80A00D0E0D1F8AA065640D0EF9 +:100EAE000D1F8AC1640D0E53756D6D6172793A0E08 +:100EBE0020C67391640E208B91640E208B20777266 +:100ECE00697474656E0E1F9B3A0E208B20756E61D1 +:100EDE00626C65802077726974650E202062616491 +:100EEE00F5730E20859F96C60E2085849D0E208557 +:100EFE00206E6F6E849D0E1F979B206465746563D4 +:100F0E007465640D0E0D866E696E67823A0D0E0D58 +:100F1E000D53656E64696E671F988489AC2020003E +:100F2E0020802020000D0D5374616E646172641F69 +:100F3E009E730E1FDA1FF465641F9E730E1F9A9E1A +:100F4E00001F82001F8F1FE21FAA003F3F3F001F9E +:100F5E00D7001F8ED7D1001FD18273001F8682004B +:100F6E001F8A001F93001F8781001F8880838100C6 +:100F7E001F84DB9A83001F84DBC083001F9C9A9220 +:100F8E00001FED83001FCB9990001F9990CB640D2D +:060F9E000E1F859B0D0EE5 +:00000001FF diff --git a/install-sh b/install-sh new file mode 100644 index 0000000..d4744f0 --- /dev/null +++ b/install-sh @@ -0,0 +1,269 @@ +#!/bin/sh +# +# install - install a program, script, or datafile +# +# This originates from X11R5 (mit/util/scripts/install.sh), which was +# later released in X11R6 (xc/config/util/install.sh) with the +# following copyright and license. +# +# Copyright (C) 1994 X Consortium +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- +# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +# Except as contained in this notice, the name of the X Consortium shall not +# be used in advertising or otherwise to promote the sale, use or other deal- +# ings in this Software without prior written authorization from the X Consor- +# tium. +# +# +# FSF changes to this file are in the public domain. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# `make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. It can only install one file at a time, a restriction +# shared with many OS's install programs. + + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit="${DOITPROG-}" + + +# put in absolute paths if you don't have them in your path; or use env. vars. + +mvprog="${MVPROG-mv}" +cpprog="${CPPROG-cp}" +chmodprog="${CHMODPROG-chmod}" +chownprog="${CHOWNPROG-chown}" +chgrpprog="${CHGRPPROG-chgrp}" +stripprog="${STRIPPROG-strip}" +rmprog="${RMPROG-rm}" +mkdirprog="${MKDIRPROG-mkdir}" + +transformbasename="" +transform_arg="" +instcmd="$mvprog" +chmodcmd="$chmodprog 0755" +chowncmd="" +chgrpcmd="" +stripcmd="" +rmcmd="$rmprog -f" +mvcmd="$mvprog" +src="" +dst="" +dir_arg="" + +while [ x"$1" != x ]; do + case $1 in + -c) instcmd="$cpprog" + shift + continue;; + + -d) dir_arg=true + shift + continue;; + + -m) chmodcmd="$chmodprog $2" + shift + shift + continue;; + + -o) chowncmd="$chownprog $2" + shift + shift + continue;; + + -g) chgrpcmd="$chgrpprog $2" + shift + shift + continue;; + + -s) stripcmd="$stripprog" + shift + continue;; + + -t=*) transformarg=`echo $1 | sed 's/-t=//'` + shift + continue;; + + -b=*) transformbasename=`echo $1 | sed 's/-b=//'` + shift + continue;; + + *) if [ x"$src" = x ] + then + src=$1 + else + # this colon is to work around a 386BSD /bin/sh bug + : + dst=$1 + fi + shift + continue;; + esac +done + +if [ x"$src" = x ] +then + echo "install: no input file specified" + exit 1 +else + true +fi + +if [ x"$dir_arg" != x ]; then + dst=$src + src="" + + if [ -d $dst ]; then + instcmd=: + chmodcmd="" + else + instcmd=mkdir + fi +else + +# Waiting for this to be detected by the "$instcmd $src $dsttmp" command +# might cause directories to be created, which would be especially bad +# if $src (and thus $dsttmp) contains '*'. + + if [ -f $src -o -d $src ] + then + true + else + echo "install: $src does not exist" + exit 1 + fi + + if [ x"$dst" = x ] + then + echo "install: no destination specified" + exit 1 + else + true + fi + +# If destination is a directory, append the input filename; if your system +# does not like double slashes in filenames, you may need to add some logic + + if [ -d $dst ] + then + dst="$dst"/`basename $src` + else + true + fi +fi + +## this sed command emulates the dirname command +dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` + +# Make sure that the destination directory exists. +# this part is taken from Noah Friedman's mkinstalldirs script + +# Skip lots of stat calls in the usual case. +if [ ! -d "$dstdir" ]; then +defaultIFS=' +' +IFS="${IFS-${defaultIFS}}" + +oIFS="${IFS}" +# Some sh's can't handle IFS=/ for some reason. +IFS='%' +set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` +IFS="${oIFS}" + +pathcomp='' + +while [ $# -ne 0 ] ; do + pathcomp="${pathcomp}${1}" + shift + + if [ ! -d "${pathcomp}" ] ; + then + $mkdirprog "${pathcomp}" + else + true + fi + + pathcomp="${pathcomp}/" +done +fi + +if [ x"$dir_arg" != x ] +then + $doit $instcmd $dst && + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi +else + +# If we're going to rename the final executable, determine the name now. + + if [ x"$transformarg" = x ] + then + dstfile=`basename $dst` + else + dstfile=`basename $dst $transformbasename | + sed $transformarg`$transformbasename + fi + +# don't allow the sed command to completely eliminate the filename + + if [ x"$dstfile" = x ] + then + dstfile=`basename $dst` + else + true + fi + +# Make a temp file name in the proper directory. + + dsttmp=$dstdir/#inst.$$# + +# Move or copy the file name to the temp name + + $doit $instcmd $src $dsttmp && + + trap "rm -f ${dsttmp}" 0 && + +# and set any options; do chmod last to preserve setuid bits + +# If any of these fail, we abort the whole thing. If we want to +# ignore errors from any of these, just make sure not to ignore +# errors from the above "$doit $instcmd $src $dsttmp" command. + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && + +# Now rename the file to the real destination. + + $doit $rmcmd -f $dstdir/$dstfile && + $doit $mvcmd $dsttmp $dstdir/$dstfile + +fi && + + +exit 0 diff --git a/missing b/missing new file mode 100644 index 0000000..22e101a --- /dev/null +++ b/missing @@ -0,0 +1,198 @@ +#! /bin/sh +# Common stub for a few missing GNU programs while installing. +# Copyright (C) 1996, 1997, 2001, 2002 Free Software Foundation, Inc. +# Franc,ois Pinard , 1996. + +# This program 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, or (at your option) +# any later version. + +# This program 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 this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +if test $# -eq 0; then + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 +fi + +# In the cases where this matters, `missing' is being run in the +# srcdir already. +if test -f configure.in; then + configure_ac=configure.ac +else + configure_ac=configure.in +fi + +case "$1" in + + -h|--h|--he|--hel|--help) + echo "\ +$0 [OPTION]... PROGRAM [ARGUMENT]... + +Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an +error status if there is no known handling for PROGRAM. + +Options: + -h, --help display this help and exit + -v, --version output version information and exit + +Supported PROGRAM values: + aclocal touch file \`aclocal.m4' + autoconf touch file \`configure' + autoheader touch file \`config.h.in' + automake touch all \`Makefile.in' files + bison create \`y.tab.[ch]', if possible, from existing .[ch] + flex create \`lex.yy.c', if possible, from existing .c + lex create \`lex.yy.c', if possible, from existing .c + makeinfo touch the output file + yacc create \`y.tab.[ch]', if possible, from existing .[ch]" + ;; + + -v|--v|--ve|--ver|--vers|--versi|--versio|--version) + echo "missing - GNU libit 0.0" + ;; + + -*) + echo 1>&2 "$0: Unknown \`$1' option" + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 + ;; + + aclocal*) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified \`acinclude.m4' or \`$configure_ac'. You might want + to install the \`Automake' and \`Perl' packages. Grab them from + any GNU archive site." + touch aclocal.m4 + ;; + + autoconf) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified \`$configure_ac'. You might want to install the + \`Autoconf' and \`GNU m4' packages. Grab them from any GNU + archive site." + touch configure + ;; + + autoheader) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified \`acconfig.h' or \`$configure_ac'. You might want + to install the \`Autoconf' and \`GNU m4' packages. Grab them + from any GNU archive site." + files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' $configure_ac` + test -z "$files" && files="config.h" + touch_files= + for f in $files; do + case "$f" in + *:*) touch_files="$touch_files "`echo "$f" | + sed -e 's/^[^:]*://' -e 's/:.*//'`;; + *) touch_files="$touch_files $f.in";; + esac + done + touch $touch_files + ;; + + automake*) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified \`Makefile.am', \`acinclude.m4' or \`$configure_ac'. + You might want to install the \`Automake' and \`Perl' packages. + Grab them from any GNU archive site." + find . -type f -name Makefile.am -print | + sed 's/\.am$/.in/' | + while read f; do touch "$f"; done + ;; + + bison|yacc) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified a \`.y' file. You may need the \`Bison' package + in order for those modifications to take effect. You can get + \`Bison' from any GNU archive site." + rm -f y.tab.c y.tab.h + if [ $# -ne 1 ]; then + eval LASTARG="\${$#}" + case "$LASTARG" in + *.y) + SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" y.tab.c + fi + SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" y.tab.h + fi + ;; + esac + fi + if [ ! -f y.tab.h ]; then + echo >y.tab.h + fi + if [ ! -f y.tab.c ]; then + echo 'main() { return 0; }' >y.tab.c + fi + ;; + + lex|flex) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified a \`.l' file. You may need the \`Flex' package + in order for those modifications to take effect. You can get + \`Flex' from any GNU archive site." + rm -f lex.yy.c + if [ $# -ne 1 ]; then + eval LASTARG="\${$#}" + case "$LASTARG" in + *.l) + SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" lex.yy.c + fi + ;; + esac + fi + if [ ! -f lex.yy.c ]; then + echo 'main() { return 0; }' >lex.yy.c + fi + ;; + + makeinfo) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified a \`.texi' or \`.texinfo' file, or any other file + indirectly affecting the aspect of the manual. The spurious + call might also be the consequence of using a buggy \`make' (AIX, + DU, IRIX). You might want to install the \`Texinfo' package or + the \`GNU make' package. Grab either from any GNU archive site." + file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` + if test -z "$file"; then + file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` + file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file` + fi + touch $file + ;; + + *) + echo 1>&2 "\ +WARNING: \`$1' is needed, and you do not seem to have it handy on your + system. You might have modified some files without having the + proper tools for further handling them. Check the \`README' file, + it often tells you about the needed prerequirements for installing + this package. You may also peek at any GNU archive site, in case + some other package would contain this missing \`$1' program." + exit 1 + ;; +esac + +exit 0 diff --git a/mkinstalldirs b/mkinstalldirs new file mode 100644 index 0000000..4f58503 --- /dev/null +++ b/mkinstalldirs @@ -0,0 +1,40 @@ +#! /bin/sh +# mkinstalldirs --- make directory hierarchy +# Author: Noah Friedman +# Created: 1993-05-16 +# Public domain + +# $Id: mkinstalldirs,v 1.13 1999/01/05 03:18:55 bje Exp $ + +errstatus=0 + +for file +do + set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` + shift + + pathcomp= + for d + do + pathcomp="$pathcomp$d" + case "$pathcomp" in + -* ) pathcomp=./$pathcomp ;; + esac + + if test ! -d "$pathcomp"; then + echo "mkdir $pathcomp" + + mkdir "$pathcomp" || lasterr=$? + + if test ! -d "$pathcomp"; then + errstatus=$lasterr + fi + fi + + pathcomp="$pathcomp/" + done +done + +exit $errstatus + +# mkinstalldirs ends here -- 2.30.2