* src/*.c, src/pic16/{gen.c,glue.c,main.c}: applied Vangelis
authortecodev <tecodev@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 10 Aug 2005 10:53:34 +0000 (10:53 +0000)
committertecodev <tecodev@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 10 Aug 2005 10:53:34 +0000 (10:53 +0000)
  Rokas' patch to add the new fixed point type "__fixed16x16"
* device/lib/pic16/libsdcc/fixed16x16: added Vangelis' support
  functions for __fixed16x16 arithmetics
* device/lib/pic16: reimplemented the build system to support
  a separate build directory, better handling of libio (create
  the library in a separate subdir for each architecture) and
  easier configuration (centralized in Makefile.common)

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3838 4a8a32a2-be11-0410-ad9d-d568d2c75423

78 files changed:
ChangeLog
device/lib/Makefile.in
device/lib/pic16/COPYING [new file with mode: 0644]
device/lib/pic16/Makefile
device/lib/pic16/Makefile.common.in
device/lib/pic16/Makefile.rules [new file with mode: 0644]
device/lib/pic16/Makefile.subdir [new file with mode: 0644]
device/lib/pic16/configure
device/lib/pic16/configure.in
device/lib/pic16/debug/Makefile
device/lib/pic16/debug/Makefile.rules [deleted file]
device/lib/pic16/debug/gstack/Makefile
device/lib/pic16/libc/Makefile
device/lib/pic16/libc/Makefile.rules [deleted file]
device/lib/pic16/libc/ctype/Makefile
device/lib/pic16/libc/delay/Makefile
device/lib/pic16/libc/stdio/Makefile
device/lib/pic16/libc/stdlib/Makefile
device/lib/pic16/libc/string/Makefile
device/lib/pic16/libc/utils/Makefile
device/lib/pic16/libdev/Makefile
device/lib/pic16/libio/Makefile
device/lib/pic16/libio/Makefile.rules [deleted file]
device/lib/pic16/libio/adc/Makefile
device/lib/pic16/libio/i2c/Makefile
device/lib/pic16/libio/usart/Makefile
device/lib/pic16/libm/Makefile
device/lib/pic16/libsdcc/Makefile
device/lib/pic16/libsdcc/Makefile.rules [deleted file]
device/lib/pic16/libsdcc/char/Makefile
device/lib/pic16/libsdcc/fixed16x16/Makefile [new file with mode: 0644]
device/lib/pic16/libsdcc/fixed16x16/fps16x162schar.S [new file with mode: 0644]
device/lib/pic16/libsdcc/fixed16x16/fps16x162sfloat.c [new file with mode: 0644]
device/lib/pic16/libsdcc/fixed16x16/fps16x162sint.S [new file with mode: 0644]
device/lib/pic16/libsdcc/fixed16x16/fps16x162slong.S [new file with mode: 0644]
device/lib/pic16/libsdcc/fixed16x16/fps16x162uchar.S [new file with mode: 0644]
device/lib/pic16/libsdcc/fixed16x16/fps16x162uint.S [new file with mode: 0644]
device/lib/pic16/libsdcc/fixed16x16/fps16x162ulong.S [new file with mode: 0644]
device/lib/pic16/libsdcc/fixed16x16/fps16x16_add.c [new file with mode: 0644]
device/lib/pic16/libsdcc/fixed16x16/fps16x16_div.c [new file with mode: 0644]
device/lib/pic16/libsdcc/fixed16x16/fps16x16_eq.c [new file with mode: 0644]
device/lib/pic16/libsdcc/fixed16x16/fps16x16_gt.c [new file with mode: 0644]
device/lib/pic16/libsdcc/fixed16x16/fps16x16_gteq.c [new file with mode: 0644]
device/lib/pic16/libsdcc/fixed16x16/fps16x16_lt.c [new file with mode: 0644]
device/lib/pic16/libsdcc/fixed16x16/fps16x16_lteq.c [new file with mode: 0644]
device/lib/pic16/libsdcc/fixed16x16/fps16x16_mul.c [new file with mode: 0644]
device/lib/pic16/libsdcc/fixed16x16/fps16x16_neq.c [new file with mode: 0644]
device/lib/pic16/libsdcc/fixed16x16/fps16x16_sub.c [new file with mode: 0644]
device/lib/pic16/libsdcc/fixed16x16/schar2fps16x16.S [new file with mode: 0644]
device/lib/pic16/libsdcc/fixed16x16/sint2fps16x16.S [new file with mode: 0644]
device/lib/pic16/libsdcc/fixed16x16/slong2fps16x16.S [new file with mode: 0644]
device/lib/pic16/libsdcc/fixed16x16/uchar2fps16x16.S [new file with mode: 0644]
device/lib/pic16/libsdcc/fixed16x16/uint2fps16x16.S [new file with mode: 0644]
device/lib/pic16/libsdcc/fixed16x16/ulong2fps16x16.S [new file with mode: 0644]
device/lib/pic16/libsdcc/float/Makefile
device/lib/pic16/libsdcc/gptr/Makefile
device/lib/pic16/libsdcc/int/Makefile
device/lib/pic16/libsdcc/long/Makefile
device/lib/pic16/libsdcc/lregs/Makefile
device/lib/pic16/startup/Makefile
src/SDCC.lex
src/SDCC.y
src/SDCCast.c
src/SDCCcse.c
src/SDCCdwarf2.c
src/SDCCicode.c
src/SDCCopt.c
src/SDCCsymt.c
src/SDCCsymt.h
src/SDCCutil.c
src/SDCCutil.h
src/SDCCval.c
src/SDCCval.h
src/altlex.c
src/cdbFile.c
src/pic16/gen.c
src/pic16/glue.c
src/pic16/main.c

index abd4d0ad2959f3aca479dee80350bfb968cb2a43..3f29f0ff37545005c8412c1ffa5334c812a1c9e5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2005-08-10 Raphael Neider <rneider AT web.de>
+
+       * src/*.c, src/pic16/{gen.c,glue.c,main.c}: applied Vangelis
+         Rokas' patch to add the new fixed point type "__fixed16x16"
+       * device/lib/pic16/libsdcc/fixed16x16: added Vangelis' support
+         functions for __fixed16x16 arithmetics
+       * device/lib/pic16: reimplemented the build system to support
+         a separate build directory, better handling of libio (create
+         the library in a separate subdir for each architecture) and
+         easier configuration (centralized in Makefile.common)
+
 2005-08-07 Raphael Neider <rneider AT web.de>
 
        * src/pic16/gen.c (genrshTwo): fixed sign extension
index eb14b70b997221f1692924a95c7e3c0fdf05431b..f935e987a302a74d488fdf32e76791fc74ba0cc3 100644 (file)
@@ -237,7 +237,7 @@ objects-hc08: build-dir $(HC08OBJECTS) port-specific-objects clean_intermediate
 model-pic16:
        if [ "`grep pic16 ../../ports.build`" = pic16 ]; then \
          $(MAKE) MODELFLAGS="-mpic16" PORT=pic16 OEXT=.lib objects-pic16; \
-         fi
+       fi
 
 objects-pic16: build-dir port-specific-objects-pic16 clean_intermediate-pic16
        cd $(PORTDIR); ls *$(OEXT) > $(PORT).lib
@@ -258,7 +258,7 @@ port-specific-objects-pic16:
        if [ -d $(PORT) ]; then \
          mkdir -p $(PORT)/bin; \
          $(MAKE) -C $(PORT); \
-         cp -f $(PORT)/bin/*.* $(PORTDIR); \
+         cp -f $(PORT)/bin/* $(PORTDIR); \
        fi
 
 lib-files:
diff --git a/device/lib/pic16/COPYING b/device/lib/pic16/COPYING
new file mode 100644 (file)
index 0000000..916d1f0
--- /dev/null
@@ -0,0 +1,339 @@
+                   GNU GENERAL PUBLIC LICENSE
+                      Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                           Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+\f
+                   GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+\f
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+\f
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+\f
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+                           NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+                    END OF TERMS AND CONDITIONS
+\f
+       Appendix: How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) 19yy  <name of author>
+
+    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 of the License, 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
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) 19yy name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Library General
+Public License instead of this License.
index ba6de15e2540df18d9c373851d6c3c2a8d02d181..ad27fa232dad638d18b110910b6a59650faa8bf6 100644 (file)
@@ -1,60 +1,43 @@
-#
-# Makefile - toplevel makefile that builds everything
-#
-# This file is part of the GNU PIC Library.
-#
-# January, 2004
-# The GNU PIC Library is maintained by,
-#      Vangelis Rokas <vrokas@otenet.gr>
-#
-# $Id$
-#
-#
+###########################################################
+### Makefile for the GNU PIC Library
+###
+### Copyright (C) 2005 by Raphael Neider <rneider@web.de>
+###
+### The GNU PIC Library was originally designed and
+### implemented by
+###    Vangelis Rokas <vrokas@otenet.gr>
+###
+### It is currently maintained by
+###    Raphael Neider <rneider@web.de>
+###
+### This file may be distributed under the terms of the the
+### GNU General Public License (GPL). See COPYING for details.
+###
+### $Id$
+###
 
+topsrcdir = .
 
-include ./Makefile.common
+include $(topsrcdir)/Makefile.common
 
+SUBDIRS           = debug libc libdev libio libm libsdcc startup
+builddir   = build
+installdir = bin
+export installdir
 
-DIRS   =       startup \
-               libdev  \
-               libsdcc \
-               libc \
-               libm \
-               debug
-               
-#              libio 
+C_SRC = $(wildcard *.c)
+S_SRC = $(wildcard *.S)
+OBJS = $(C_SRC:.c=.o) $(S_SRC:.S=.o)
 
+.PHONY : all clean clean-intermediate recurse
 
-all: build-all-libraries
+all : install
 
-build-all-libraries:
-       @for temp in $(DIRS) ; do \
-               $(MAKE) -C $$temp MODELFLAGS=$(MODELFLAGS) ; \
-       done
+install : builddir recurse
 
+clean : recurse
+       $(Q)-$(RMDIR) "$(topsrcdir)/$(builddir)";
 
-lib-io:
-       $(MAKE) -C libio MODELFLAGS=$(MODELFLAGS)
+clean-intermediate : recurse
 
-clean: all-clean
-       $(RM) -f bin/*.*
-
-
-
-all-clean:
-       @for temp in $(DIRS) ; do \
-               $(MAKE) -C $$temp clean ; \
-       done
-
-clean-intermediate:
-       @for temp in $(DIRS) ; do \
-               $(MAKE) -C $$temp clean-intermediate ; \
-       done
-
-
-dep: all-dep
-
-all-dep:
-       for temp in $(DIRS) ; do \
-               $(MAKE) -C $$temp dep ; \
-       done
+include $(topsrcdir)/Makefile.rules
index b90c055965994c38a6ea4a3e9adb26326c1b7d01..35b7736b9813cdab4885b7ef5574756b784f4fff 100644 (file)
@@ -1,39 +1,93 @@
-#
-# Makefile.common - common variables makefile
-#
-# This file is part of the GNU PIC Library.
-#
-# January, 2004
-# The GNU PIC Library is maintained by,
-#      Vangelis Rokas <vrokas@otenet.gr>
-#
-# $Id$
-#
-#
-
-CC     = $(PRJDIR)/bin/sdcc
-CPP    = $(PRJDIR)/bin/sdcpp
+###########################################################
+### Makefile.common.in for the GNU PIC Library
+###
+### Copyright (C) 2005 by Raphael Neider <rneider@web.de>
+###
+### The GNU PIC Library was originally designed and
+### implemented by
+###    Vangelis Rokas <vrokas@otenet.gr>
+###
+### It is currently maintained by
+###    Raphael Neider <rneider@web.de>
+###
+### This file may be distributed under the terms of the the
+### GNU General Public License (GPL). See COPYING for details.
+###
+### $Id$
+###
 
-AS     = @GPASM@
-LD     = @GPLINK@
-AR     = @GPLIB@
+#################################################
+### verboseness
+#Q     ?=              # be verbose
+Q      ?= @            # be quiet
+# be really quiet (suppress "Entering/Leaving directory...")
+MAKEFLAGS := $(filter-out -s,$(MAKEFLAGS)) -s
+
+#################################################
+### compiler switches
+ARCH   ?= 452          # might be overwritten in libio
+
+CFLAGS ?=
+CFLAGS += -mpic16 -p18f$(ARCH)
+CFLAGS += --std-c99
+CFLAGS += -I. -I$(topsrcdir)/../../include/pic16
+
+#################################################
+### optimization flags
+CFLAGS += --fommit-frame-pointer
+CFLAGS += --obanksel=9
+CFLAGS += --denable-peeps
+CFLAGS += --optimize-goto
+CFLAGS += --optimize-cmp
+CFLAGS += --optimize-df
+
+#################################################
+### debugging PIC16 port
+#CFLAGS += --debug-ralloc
+#CFLAGS += --debug-xtra
+#CFLAGS += --pcode-verbose
+CFLAGS += --i-code-in-asm
 
-RM     = @RM@
-CP     = @CP@
-MV     = @MV@
-LS     = @LS@
-SED    = @SED@
+#################################################
+### debugging SDCC's optimizations
+#CFLAGS += --nooverlay
+#CFLAGS += --nogcse
+#CFLAGS += --nolabelopt
+#CFLAGS += --noinvariant
+#CFLAGS += --noinduction
+#CFLAGS += --nojtbound
+#CFLAGS += --noloopreverse
 
-# Quick+dirty fix: this should be defined elsewhere,
-# but it's needed for `make clean`; Bernhard
-MM = -MM
+#################################################
+### assembler switches
+ASFLAGS ?=
+ASFLAGS += -pp18f$(ARCH)
+ASFLAGS += -I$(topsrcdir)/../../include/pic16
+
+#################################################
+### linker switches
+LDFLAGS ?=
+LDFLAGS += -m -l -w
+
+#################################################
+### librarian switches
+LIBFLAGS ?=
+LIBFLAGS += -c
+
+#################################################
+### programs to use
+CPP    = $(topsrcdir)/../../../bin/sdcpp
+CC     = $(topsrcdir)/../../../bin/sdcc
+AS     = @GPASM@
+LD     = @GPLINK@
+LIB    = @GPLIB@
 
-CSTD    = --std-c99
+SED    ?= @SED@
+GREP   ?= @EGREP@
 
-MODELFLAGS      = -mpic16
+MKDIR  ?= @MKDIR@
+RMDIR  ?= @RMDIR@
+CP     ?= @CP@
+MV     ?= @MV@
+RM     ?= @RM@
 
-OPT_FLAGS      += --denable-peeps
-OPT_FLAGS      += --obanksel=9
-OPT_FLAGS      += --optimize-goto
-OPT_FLAGS      += --optimize-df
-OPT_FLAGS      += --i-code-in-asm
diff --git a/device/lib/pic16/Makefile.rules b/device/lib/pic16/Makefile.rules
new file mode 100644 (file)
index 0000000..e36ebe6
--- /dev/null
@@ -0,0 +1,58 @@
+###########################################################
+### Makefile.rules for the GNU PIC Library
+###
+### Copyright (C) 2005 by Raphael Neider <rneider@web.de>
+###
+### The GNU PIC Library was originally designed and
+### implemented by
+###    Vangelis Rokas <vrokas@otenet.gr>
+###
+### It is currently maintained by
+###    Raphael Neider <rneider@web.de>
+###
+### This file may be distributed under the terms of the the
+### GNU General Public License (GPL). See COPYING for details.
+###
+### $Id$
+###
+
+# update dependencies
+$(topsrcdir)/$(builddir)/%.d : %.c
+       @echo "[  CPP  ] ==> $(patsubst $(topsrcdir)/%,%,$@)";
+       $(Q)$(CPP) $CPPFLAGS) -o "$@" "$<";
+
+# assemble
+$(topsrcdir)/$(builddir)/%.o : %.S
+       @echo "[  AS   ] ==> $(patsubst $(topsrcdir)/%,%,$@)";
+       $(Q)$(AS) $(ASFLAGS) -o "$@" -c "$<";
+
+# compile
+$(topsrcdir)/$(builddir)/%.o : %.c
+       @echo "[  CC   ] ==> $(patsubst $(topsrcdir)/%,%,$@)";
+       $(Q)$(CC) $(CFLAGS) -o "$@" -c "$<";
+
+# create library
+ifneq (,$(strip $(LIB_O)))
+%.lib : $(LIB_O)
+       @echo "[  LIB  ] $(patsubst $(topsrcdir)/%,%,$@) <== $(patsubst $(topsrcdir)/$(builddir)/%,%,$^)";
+       $(Q)$(RM) "$@"; $(LIB) $(LIBFLAGS) "$@" $^;
+else
+%.lib : force
+       @echo "[  LIB  ] $(patsubst $(topsrcdir)/%,%,$@) <== **/*.o";
+       $(Q)$(RM) "$@"; LIB_O=`find "$(topsrcdir)/$(builddir)" -name "*.o"`; [ "x$${LIB_O}" = "x" ] || $(LIB) $(LIBFLAGS) "$@" $${LIB_O};
+endif
+
+.PHONY : builddir recurse force
+
+# create builddir
+builddir : force
+       $(Q)[ -d "$(topsrcdir)/$(builddir)" ] || $(MKDIR) "$(topsrcdir)/$(builddir)";
+
+# build sub-directories
+recurse : force
+       $(Q)for DIR in $(SUBDIRS) . ; do \
+               [ "$${DIR}" = "." ] || $(GREP) "^$${ARCH}$$" "$${DIR}.ignore" &> /dev/null || $(MAKE) -C "$${DIR}" builddir="$(builddir)/$${DIR}" $(MAKECMDGOALS) || exit 1; \
+       done
+
+# target to force remaking of (seemingly) independent targets
+force :
diff --git a/device/lib/pic16/Makefile.subdir b/device/lib/pic16/Makefile.subdir
new file mode 100644 (file)
index 0000000..1e97bab
--- /dev/null
@@ -0,0 +1,65 @@
+###########################################################
+### Makefile.subdir for the GNU PIC Library
+###
+### Copyright (C) 2005 by Raphael Neider <rneider@web.de>
+###
+### The GNU PIC Library was originally designed and
+### implemented by
+###    Vangelis Rokas <vrokas@otenet.gr>
+###
+### It is currently maintained by
+###    Raphael Neider <rneider@web.de>
+###
+### This file may be distributed under the terms of the the
+### GNU General Public License (GPL). See COPYING for details.
+###
+### $Id$
+###
+
+include $(topsrcdir)/Makefile.common
+
+SUBDIRS ?= 
+MKLIB  ?= 
+
+# fallback: if builddir is not specified via the command line...
+builddir ?= build/$(patsubst $(shell cd $(topsrcdir); pwd)/%,%,$(CURDIR))
+
+C_SRC  ?= $(wildcard *.c)
+S_SRC  ?= $(wildcard *.S)
+OBJS   ?= $(addprefix $(topsrcdir)/$(builddir)/,$(C_SRC:.c=.o) $(S_SRC:.S=.o))
+LIB_O  ?= $(OBJS)
+
+ifneq (,$(strip $(MKLIB)))
+LIB_LIB = $(topsrcdir)/$(builddir)/$(MKLIB)
+TARGETS ?= $(LIB_LIB)
+else
+LIB_LIB = 
+#TARGETS ?= $(OBJS)
+endif
+
+all : install
+
+ifneq (,$(strip $(TARGETS)))
+# usually install $(LIB_LIB) or $(OBJS)
+install : builddir recurse $(OBJS) $(LIB_LIB)
+       @[ -d "$(topsrcdir)/$(installdir)" ] || $(MKDIR) "$(topsrcdir)/$(installdir)";
+       @echo "[INSTALL] $(patsubst $(topsrcdir)/$(builddir)/%,%,$(TARGETS))";
+       $(Q)$(CP) $(TARGETS) "$(topsrcdir)/$(installdir)"
+else
+# used in subdirs like libc/ctype whose files
+# are contained in a parent's library
+install : builddir recurse $(OBJS) $(LIB_LIB)
+endif
+
+clean : recurse
+       @-echo "dummy" > .dummy
+       $(Q)-$(RM) .dummy $(foreach suf,asm d p lst hex cod sym hex,$(OBJS:.o=.$(suf)))
+       @-echo "dummy" > .dummy
+       $(Q)-$(RM) .dummy $(OBJS) $(LIB_LIB)
+       $(Q)-[ ! -d "$(topsrcdir)/$(builddir)" ] || $(RMDIR) "$(topsrcdir)/$(builddir)"
+
+clean-intermediate : recurse
+       @-echo "dummy" > .dummy
+       $(Q)-$(RM) .dummy $(foreach suf,asm d p lst hex cod sym hex,$(OBJS:.o=.$(suf)))
+       
+include $(topsrcdir)/Makefile.rules
index fcef71c7e2c420a1464c142479155352d9f99dce..cfd0e02312c9342f6f87368e664a81a688d20ded 100755 (executable)
@@ -1,9 +1,8 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.57.
+# Generated by GNU Autoconf 2.59.
 #
-# Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002
-# Free Software Foundation, Inc.
+# 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.
 ## --------------------- ##
@@ -20,9 +19,10 @@ if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
 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 (FOO=FOO; unset FOO) >/dev/null 2>&1; then
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
   as_unset=unset
 else
   as_unset=false
@@ -41,7 +41,7 @@ for as_var in \
   LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
   LC_TELEPHONE LC_TIME
 do
-  if (set +x; test -n "`(eval $as_var=C; export $as_var) 2>&1`"); then
+  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
@@ -218,16 +218,17 @@ 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="sed y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g"
+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="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g"
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
 
 
 # IFS
@@ -270,7 +271,7 @@ PACKAGE_VERSION=
 PACKAGE_STRING=
 PACKAGE_BUGREPORT=
 
-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 GPASM GPLINK GPLIB RM CP MV LS SED LIBOBJS LTLIBOBJS'
+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 GPASM GPLINK GPLIB RM CP MV LS SED EGREP MKDIR RMDIR SET_MAKE LIBOBJS LTLIBOBJS'
 ac_subst_files=''
 
 # Initialize some variables set by options.
@@ -629,7 +630,7 @@ done
 
 # Be sure to have absolute paths.
 for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \
-              localstatedir libdir includedir oldincludedir infodir mandir
+             localstatedir libdir includedir oldincludedir infodir mandir
 do
   eval ac_val=$`echo $ac_var`
   case $ac_val in
@@ -669,10 +670,10 @@ if test -z "$srcdir"; then
   # 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 ||
+        X"$0" : 'X\(//\)[^/]' \| \
+        X"$0" : 'X\(//\)$' \| \
+        X"$0" : 'X\(/\)' \| \
+        .     : '\(.\)' 2>/dev/null ||
 echo X"$0" |
     sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
          /^X\(\/\/\)[^/].*/{ s//\1/; q; }
@@ -744,9 +745,9 @@ _ACEOF
   cat <<_ACEOF
 Installation directories:
   --prefix=PREFIX         install architecture-independent files in PREFIX
-                          [$ac_default_prefix]
+                         [$ac_default_prefix]
   --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
-                          [PREFIX]
+                         [PREFIX]
 
 By default, \`make install' will install all the files in
 \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc.  You can specify
@@ -811,12 +812,45 @@ case $srcdir in
     ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
     ac_top_srcdir=$ac_top_builddir$srcdir ;;
 esac
-# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be
-# absolute.
-ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd`
-ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd`
-ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd`
-ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd`
+
+# 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.
@@ -827,7 +861,7 @@ ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd`
       echo
       $SHELL $ac_srcdir/configure  --help=recursive
     elif test -f $ac_srcdir/configure.ac ||
-           test -f $ac_srcdir/configure.in; then
+          test -f $ac_srcdir/configure.in; then
       echo
       $ac_configure --help
     else
@@ -841,8 +875,7 @@ test -n "$ac_init_help" && exit 0
 if $ac_init_version; then
   cat <<\_ACEOF
 
-Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002
-Free Software Foundation, Inc.
+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
@@ -854,7 +887,7 @@ 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.57.  Invocation command line was
+generated by GNU Autoconf 2.59.  Invocation command line was
 
   $ $0 $@
 
@@ -931,19 +964,19 @@ do
     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.
+       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
+       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.
@@ -977,12 +1010,12 @@ _ASBOX
     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"
+       "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"
+       "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
       ;;
     esac;
 }
@@ -1011,7 +1044,7 @@ _ASBOX
       for ac_var in $ac_subst_files
       do
        eval ac_val=$`echo $ac_var`
-        echo "$ac_var='"'"'$ac_val'"'"'"
+       echo "$ac_var='"'"'$ac_val'"'"'"
       done | sort
       echo
     fi
@@ -1030,7 +1063,7 @@ _ASBOX
       echo "$as_me: caught signal $ac_signal"
     echo "$as_me: exit $exit_status"
   } >&5
-  rm -f core core.* *.core &&
+  rm -f core *.core &&
   rm -rf conftest* confdefs* conf$$* $ac_clean_files &&
     exit $exit_status
      ' 0
@@ -1110,7 +1143,7 @@ fi
 # 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
+              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"
@@ -1127,13 +1160,13 @@ echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
     ,);;
     *)
       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:$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:$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:$LINENO:   current value: $ac_new_val" >&5
 echo "$as_me:   current value: $ac_new_val" >&2;}
-        ac_cache_corrupted=:
+       ac_cache_corrupted=:
       fi;;
   esac
   # Pass precious variables to config.status.
@@ -1182,7 +1215,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 
-#AC_DEFUN(AC_CONFIG_SRCDIR)
+
 #AC_DEFUN(AC_CONFIG_FILES)
 
 # Checks for programs.
@@ -1312,7 +1345,7 @@ do
   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_RM="rm"
+    ac_cv_prog_RM="rm -f"
     echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
@@ -1475,6 +1508,123 @@ else
 echo "${ECHO_T}no" >&6
 fi
 
+echo "$as_me:$LINENO: checking for egrep" >&5
+echo $ECHO_N "checking for egrep... $ECHO_C" >&6
+if test "${ac_cv_prog_egrep+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if echo a | (grep -E '(a|b)') >/dev/null 2>&1
+    then ac_cv_prog_egrep='grep -E'
+    else ac_cv_prog_egrep='egrep'
+    fi
+fi
+echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5
+echo "${ECHO_T}$ac_cv_prog_egrep" >&6
+ EGREP=$ac_cv_prog_egrep
+
+
+# Extract the first word of "mkdir", so it can be a program name with args.
+set dummy mkdir; 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_MKDIR+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$MKDIR"; then
+  ac_cv_prog_MKDIR="$MKDIR" # 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_MKDIR="mkdir -p"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+  test -z "$ac_cv_prog_MKDIR" && ac_cv_prog_MKDIR=":"
+fi
+fi
+MKDIR=$ac_cv_prog_MKDIR
+if test -n "$MKDIR"; then
+  echo "$as_me:$LINENO: result: $MKDIR" >&5
+echo "${ECHO_T}$MKDIR" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+# Extract the first word of "rmdir", so it can be a program name with args.
+set dummy rmdir; 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_RMDIR+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$RMDIR"; then
+  ac_cv_prog_RMDIR="$RMDIR" # 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_RMDIR="rmdir"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+  test -z "$ac_cv_prog_RMDIR" && ac_cv_prog_RMDIR=":"
+fi
+fi
+RMDIR=$ac_cv_prog_RMDIR
+if test -n "$RMDIR"; then
+  echo "$as_me:$LINENO: result: $RMDIR" >&5
+echo "${ECHO_T}$RMDIR" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+
+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
+
 
 # Checks for libraries.
 
@@ -1484,7 +1634,7 @@ fi
 
 # Checks for library functions.
 
-cp pics.all pics.build
+$CP pics.all pics.build
 
           ac_config_files="$ac_config_files Makefile.common"
 
@@ -1516,13 +1666,13 @@ _ACEOF
       # `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"
+       "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"
+       "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
       ;;
     esac;
 } |
@@ -1552,13 +1702,13 @@ test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
 # 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[        ]*=/{
+  ac_vpsub='/^[         ]*VPATH[        ]*=/{
 s/:*\$(srcdir):*/:/;
 s/:*\${srcdir}:*/:/;
 s/:*@srcdir@:*/:/;
-s/^\([^=]*=[   ]*\):*/\1/;
+s/^\([^=]*=[    ]*\):*/\1/;
 s/:*$//;
-s/^[^=]*=[     ]*$//;
+s/^[^=]*=[      ]*$//;
 }'
 fi
 
@@ -1572,13 +1722,13 @@ fi
 cat >confdef2opt.sed <<\_ACEOF
 t clear
 : clear
-s,^[   ]*#[    ]*define[       ][      ]*\([^  (][^    (]*([^)]*)\)[   ]*\(.*\),-D\1=\2,g
+s,^[    ]*#[    ]*define[       ][      ]*\([^  (][^    (]*([^)]*)\)[   ]*\(.*\),-D\1=\2,g
 t quote
-s,^[   ]*#[    ]*define[       ][      ]*\([^  ][^     ]*\)[   ]*\(.*\),-D\1=\2,g
+s,^[    ]*#[    ]*define[       ][      ]*\([^  ][^     ]*\)[   ]*\(.*\),-D\1=\2,g
 t quote
 d
 : quote
-s,[    `~#$^&*(){}\\|;'"<>?],\\&,g
+s,[     `~#$^&*(){}\\|;'"<>?],\\&,g
 s,\[,\\&,g
 s,\],\\&,g
 s,\$,$$,g
@@ -1600,7 +1750,7 @@ 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$//'`
+        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'
@@ -1644,9 +1794,10 @@ if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
 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 (FOO=FOO; unset FOO) >/dev/null 2>&1; then
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
   as_unset=unset
 else
   as_unset=false
@@ -1665,7 +1816,7 @@ for as_var in \
   LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
   LC_TELEPHONE LC_TIME
 do
-  if (set +x; test -n "`(eval $as_var=C; export $as_var) 2>&1`"); then
+  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
@@ -1844,16 +1995,17 @@ 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="sed y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g"
+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="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g"
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
 
 
 # IFS
@@ -1880,7 +2032,7 @@ _ASBOX
 cat >&5 <<_CSEOF
 
 This file was extended by $as_me, which was
-generated by GNU Autoconf 2.57.  Invocation command line was
+generated by GNU Autoconf 2.59.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
   CONFIG_HEADERS  = $CONFIG_HEADERS
@@ -1924,7 +2076,7 @@ Usage: $0 [OPTIONS] [FILE]...
   -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
+                  instantiate the configuration file FILE
 
 Configuration files:
 $config_files
@@ -1935,11 +2087,10 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF
 ac_cs_version="\\
 config.status
-configured by $0, generated by GNU Autoconf 2.57,
+configured by $0, generated by GNU Autoconf 2.59,
   with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
 
-Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
-Free Software Foundation, Inc.
+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
@@ -2129,6 +2280,10 @@ s,@CP@,$CP,;t t
 s,@MV@,$MV,;t t
 s,@LS@,$LS,;t t
 s,@SED@,$SED,;t t
+s,@EGREP@,$EGREP,;t t
+s,@MKDIR@,$MKDIR,;t t
+s,@RMDIR@,$RMDIR,;t t
+s,@SET_MAKE@,$SET_MAKE,;t t
 s,@LIBOBJS@,$LIBOBJS,;t t
 s,@LTLIBOBJS@,$LTLIBOBJS,;t t
 CEOF
@@ -2160,9 +2315,9 @@ _ACEOF
       (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"
+       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"
+       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
@@ -2180,21 +2335,21 @@ 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,:.*,,'` ;;
+       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=`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 ||
+        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; }
@@ -2210,10 +2365,10 @@ echo X"$ac_file" |
       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 ||
+        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; }
@@ -2251,12 +2406,45 @@ case $srcdir in
     ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
     ac_top_srcdir=$ac_top_builddir$srcdir ;;
 esac
-# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be
-# absolute.
-ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd`
-ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd`
-ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd`
-ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd`
+
+# 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
 
 
 
@@ -2274,7 +2462,7 @@ echo "$as_me: creating $ac_file" >&6;}
     configure_input="$ac_file.  "
   fi
   configure_input=$configure_input"Generated from `echo $ac_file_in |
-                                     sed 's,.*/,,'` by configure."
+                                    sed 's,.*/,,'` by configure."
 
   # First look for the input files in the build tree, otherwise in the
   # src tree.
@@ -2283,24 +2471,24 @@ echo "$as_me: creating $ac_file" >&6;}
       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
+        # 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;;
+        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
+        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;;
+        fi;;
       esac
     done` || { (exit 1); exit 1; }
 _ACEOF
index 160347650f9917be2930910beb87c337cec0186f..ac9b28eb276356e08643cc6c894c114f1f326ce6 100644 (file)
@@ -15,7 +15,7 @@
 AC_PREREQ(2.57)
 AC_INIT
 
-#AC_DEFUN(AC_CONFIG_SRCDIR)
+AC_DEFUN(AC_CONFIG_SRCDIR)
 #AC_DEFUN(AC_CONFIG_FILES)
 
 # Checks for programs.
@@ -23,11 +23,16 @@ AC_CHECK_PROG(GPASM,        gpasm,  gpasm, :)
 AC_CHECK_PROG(GPLINK,  gplink, gplink, :)
 AC_CHECK_PROG(GPLIB,   gplib,  gplib, :)
 
-AC_CHECK_PROG(RM,      rm,     rm, :)
+AC_CHECK_PROG(RM,      rm,     [rm -f], :)
 AC_CHECK_PROG(CP,      cp,     cp, :)
 AC_CHECK_PROG(MV,      mv,     mv, :)
 AC_CHECK_PROG(LS,      ls,     ls, :)
 AC_CHECK_PROG(SED,     sed,    sed, :)
+AC_PROG_EGREP
+AC_CHECK_PROG(MKDIR,   mkdir,  [mkdir -p], :)
+AC_CHECK_PROG(RMDIR,   rmdir,  rmdir, :)
+
+AC_PROG_MAKE_SET
 
 # Checks for libraries.
 
@@ -37,7 +42,7 @@ AC_CHECK_PROG(SED,    sed,    sed, :)
 
 # Checks for library functions.
 
-cp pics.all pics.build
+$CP pics.all pics.build
 
 AC_CONFIG_FILES([Makefile.common])
 AC_OUTPUT
index 231e9d7e7ea9d54ffeb7bed7f99dcc2f4217f556..ce9d253b60cfca3477549fcd8064781e5e4aa2e6 100644 (file)
@@ -1,54 +1,6 @@
-#
-# Makefile - Makefile to build pic16 debug library
-#
-# This file is part of the GNU PIC Library.
-#
-# January, 2004
-# The GNU PIC Library is maintained by,
-#      Vangelis Rokas <vrokas@otenet.gr>
-#
-# $Id$
-#
-#
+topsrcdir=..
 
+SUBDIRS = gstack
+MKLIB = libdebug.lib
 
-DIRS   =       gstack
-
-
-LIB    = libdebug.lib
-
-all: build-libraries
-
-make-target: build-libraries
-
-build-libraries:
-       for dir in $(DIRS) ; do  \
-               $(MAKE) -C $$dir ; \
-       done;
-       gplib -c $(LIB) gstack/*.o
-       mv -v $(LIB) ../bin
-       
-
-clean-intermediate:
-       @for dir in $(DIRS) ; do \
-               $(MAKE) -C $$dir clean-intermediate ; \
-       done ;
-       
-clean:
-       for dir in $(DIRS) ; do \
-               $(MAKE) -C $$dir clean; \
-       done ;
-       rm -fv $(LIB)
-
-
-real-clean: clean
-       find -name *.adb -print | xargs -- rm -fv ;
-       find -name *.p -print | xargs -- rm -fv ;
-       find -name *.d -print | xargs -- rm -fv ;
-       find -name *.dump* -print | xargs -- rm -fv ;
-       
-
-dep:
-       for dir in $(DIRS) ; do \
-               $(MAKE) -C $$dir dep; \
-       done
+include $(topsrcdir)/Makefile.subdir
diff --git a/device/lib/pic16/debug/Makefile.rules b/device/lib/pic16/debug/Makefile.rules
deleted file mode 100644 (file)
index b1048c9..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-#
-# Makefile.rules - Common Makefile rules to build pic16
-#                  debug library
-#
-# This file is part of the GNU PIC Library.
-#
-# January, 2004
-# The GNU PIC Library is maintained by,
-#      Vangelis Rokas <vrokas@otenet.gr>
-#
-# $Id$
-#
-#
-
-
-include ../../Makefile.common
-
-PRJDIR = ../../../../..
-
-LIBC_INC_DIR   = $(PRJDIR)/device/include/pic16
-
-COMPILE_FLAGS  += $(MODELFLAGS) $(OPT_FLAGS)
-
-CPPFLAGS        := -nostdinc -I$(LIBC_INC_DIR)
-CFLAGS  += --nostdinc -I$(LIBC_INC_DIR)
-
-CFILES = $(patsubst %,%.c,$(SRCS))
-OFILES = $(patsubst %.c,%.o,$(CFILES))
-
-%.o: %.c
-       $(CC) $(CFLAGS) $(COMPILE_FLAGS) -c $<
-
-
-all: build-library
-
-clean-intermediate:
-       $(RM) -f *.lst *.asm *.dump* *.p *.d *.adb
-
-
-clean: clean-intermediate
-       $(RM) -f $(LIB) *.o
-
-dep .depend:
-       rm -f .depend
-       for temp in $(CFILES); do \
-               $(CPP) $(MM) $(CPPFLAGS) $$temp > .tmpdepend; \
-               $(SED) s/.rel/.o/g .tmpdepend >> .depend; \
-               $(RM) -f .tmpdepend; \
-       done;
-
-include .depend
index 3925e4bfb03ec7a59585dd30e8b048060b2d4d51..87adf7fc6be7e77be8abf57e03a0807d2a1bc795 100644 (file)
@@ -1,23 +1,5 @@
-#
-# Makefile - Makefile to build pic16 stack tracing support function
-#
-# This file is part of the GNU PIC Library.
-#
-# January, 2004
-# The GNU PIC Library is maintained by,
-#      Vangelis Rokas <vrokas@otenet.gr>
-#
-# $Id$
-#
-#
+topsrcdir=../..
 
+SUBDIRS = 
 
-SRCS   =       gstack
-
-
-include ../Makefile.rules
-
-
-all: build-library
-
-build-library: $(OFILES)
+include $(topsrcdir)/Makefile.subdir
index 4f12f23a29e26c0452d077507e0fb11b3b774b2c..9e58f46c0efface2e5b1d4a537ebc403a8097ee3 100644 (file)
@@ -1,60 +1,6 @@
-#
-# Makefile - Makefile to build pic16 support libraries
-#
-# This file is part of the GNU PIC Library.
-#
-# January, 2004
-# The GNU PIC Library is maintained by,
-#      Vangelis Rokas <vrokas@otenet.gr>
-#
-# $Id$
-#
-#
+topsrcdir=..
 
+SUBDIRS = ctype delay stdio stdlib utils
+MKLIB  = libc18f.lib
 
-DIRS   =       ctype \
-               delay \
-               stdlib \
-               stdio \
-               string \
-               utils
-
-LOBJS  = $(patsubst %,%/*.o,$(DIRS))
-
-LIB    = libc18f.lib
-
-all: build-libraries
-
-make-target: build-libraries
-
-build-libraries:
-       for dir in $(DIRS) ; do  \
-               $(MAKE) -C $$dir ; \
-       done;
-       gplib -c $(LIB) $(LOBJS)
-       mv -v $(LIB) ../bin
-       
-
-clean-intermediate:
-       @for dir in $(DIRS) ; do \
-               $(MAKE) -C $$dir clean-intermediate ; \
-       done ;
-       
-clean:
-       for dir in $(DIRS) ; do \
-               $(MAKE) -C $$dir clean; \
-       done ;
-       rm -fv $(LIB)
-
-
-real-clean: clean
-       find -name *.adb -print | xargs -- rm -fv ;
-       find -name *.p -print | xargs -- rm -fv ;
-       find -name *.d -print | xargs -- rm -fv ;
-       find -name *.dump* -print | xargs -- rm -fv ;
-       
-
-dep:
-       for dir in $(DIRS) ; do \
-               $(MAKE) -C $$dir dep; \
-       done
+include $(topsrcdir)/Makefile.subdir
diff --git a/device/lib/pic16/libc/Makefile.rules b/device/lib/pic16/libc/Makefile.rules
deleted file mode 100644 (file)
index 78e04f1..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-#
-# Makefile.rules - Common Makefile rules to build pic16 C Library
-#
-# This file is part of the GNU PIC Library.
-#
-# January, 2004
-# The GNU PIC Library is maintained by,
-#      Vangelis Rokas <vrokas@otenet.gr>
-#
-# $Id$
-#
-#
-
-
-include ../../Makefile.common
-
-PRJDIR = ../../../../..
-
-LIBC_INC_DIR   = $(PRJDIR)/device/include/pic16
-
-#OPT_FLAGS     += --pstack-model=large
-#OPT_FLAGS     += --stack-auto
-
-COMPILE_FLAGS  += $(MODELFLAGS)
-COMPILE_FLAGS   += $(OPT_FLAGS)
-COMPILE_FLAGS   += $(CSTD)
-
-
-CFLAGS = -I$(LIBC_INC_DIR)
-
-CFILES = $(patsubst %,%.c,$(SRCS))
-COFILES        = $(patsubst %.c,%.o,$(CFILES))
-
-ASFLAGS        = -I$(LIBC_INC_DIR) -p18f452 -D__18F452
-
-SFILES = $(patsubst %,%.S,$(S_SRCS))
-SOFILES        = $(patsubst %.S,%.o,$(SFILES))
-
-OFILES = $(COFILES) $(SOFILES)
-
-.c.o:
-       $(CC) $(CFLAGS) $(COMPILE_FLAGS) -c $<
-
-.S.o:
-       $(AS) $(ASFLAGS) -c $<
-
-all: build-library clean-intermediate-no-asm
-
-clean-intermediate:
-       $(RM) -f *.lst *.asm *.dump* *.p *.d *.adb
-
-clean-intermediate-no-asm:
-       $(RM) -f *.lst *.dump* *.p *.d *.adb
-
-
-clean: clean-intermediate
-       $(RM) -f $(LIB) *.o
-
-dep .depend:
-       rm -f .depend
-       for temp in $(CFILES); do \
-               $(CPP) $(MM) $(CFLAGS) $$temp > .tmpdepend; \
-               $(SED) s/.rel/.o/g .tmpdepend >> .depend; \
-               $(RM) -f .tmpdepend; \
-       done;
-       if [ ! -e .depend ]; then touch .depend; fi;
-
-include .depend
index 19a7382d8ac733699c7d84b45aa5e109be546bda..c682cda9d53db79c1d0581c0d7de83df26011aba 100644 (file)
@@ -1,42 +1,5 @@
-#
-# Makefile - Makefile to build pic16 C Library
-#
-# This file is part of the GNU PIC Library.
-#
-# January, 2004
-# The GNU PIC Library is maintained by,
-#      Vangelis Rokas <vrokas@otenet.gr>
-#
-# $Id$
-#
-#
+topsrcdir=../..
 
-include ../Makefile.rules
-
-SRCS    =       iscntrl \
-                isdigit \
-                isgraph \
-                islower \
-                isprint \
-                ispunct \
-                isspace \
-                isupper \
-                isxdigit
-
-
-CFILES = $(patsubst %,%.c,$(SRCS))
-OFILES = $(patsubst %.c,%.o,$(CFILES))
-
-
-DEBUG=
-#COMPILE_FLAGS   += --pomit-config-words --pomit-ivt --denable-peeps --optimize-goto --obanksel=2
-COMPILE_FLAGS  += $(DEBUG)
-
-CFILES = $(patsubst %,%.c,$(SRCS))
-OFILES = $(patsubst %.c,%.o,$(CFILES))
-
-%.o: %.c
-       $(CC) $(CFLAGS) $(COMPILE_FLAGS) -c $<
-
-build-library: $(OFILES)
+SUBDIRS =
 
+include $(topsrcdir)/Makefile.subdir
index a8ac5e5ec3f770e2f8b3814674b33bf0fe708182..c196350c8fdf5ad5d88fbb0a82eec6f1b1854056 100644 (file)
@@ -1,52 +1,6 @@
-#
-# Makefile - Makefile to build pic16 C Library
-#
-# This file is part of the GNU PIC Library.
-#
-# January, 2004
-# The GNU PIC Library is maintained by,
-#      Vangelis Rokas <vrokas@otenet.gr>
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Library General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This library 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.
-#
-#
-# $Id$
-#
-#
+topsrcdir=../..
 
-include ../Makefile.rules
-
-CSRCS  =
-
-S_SRCS =       delay10tcy \
-                delay100tcy \
-                delay1ktcy \
-                delay10ktcy \
-                delay100ktcy \
-                delay1mtcy
-
-
-SRCS   = $(CSRCS)
-
-
-DEBUG=
-#COMPILE_FLAGS   += --pomit-config-words --pomit-ivt --denable-peeps --optimize-goto --obanksel=2
-COMPILE_FLAGS  += $(DEBUG)
-
-
-#all: build-library
-
-build-library: $(OFILES)
+SUBDIRS =
+TARGETS =
 
+include $(topsrcdir)/Makefile.subdir
index 6f96ab722394b4b8c98a24240400ff2e438401f7..c196350c8fdf5ad5d88fbb0a82eec6f1b1854056 100644 (file)
@@ -1,46 +1,6 @@
-#
-# Makefile - Makefile to build pic16 C Library
-#
-# This file is part of the GNU PIC Library.
-#
-# January, 2004
-# The GNU PIC Library is maintained by,
-#      Vangelis Rokas <vrokas@otenet.gr>
-#
-# $Id$
-#
-#
+topsrcdir=../..
 
-include ../Makefile.rules
-
-SRCS   =       printf_tiny \
-               printf_small \
-               printf \
-               sprintf \
-               fprintf \
-               vprintf \
-               vsprintf \
-               vfprintf \
-               strmusart \
-               strmmssp \
-               strmgpsim \
-               strmputchar \
-               streams
-
-
-CFILES = $(patsubst %,%.c,$(SRCS))
-OFILES = $(patsubst %.c,%.o,$(CFILES))
-
-
-DEBUG=
-#COMPILE_FLAGS   += --pomit-config-words --pomit-ivt --no-peep
-COMPILE_FLAGS  += $(DEBUG)
-
-CFILES = $(patsubst %,%.c,$(SRCS))
-OFILES = $(patsubst %.c,%.o,$(CFILES))
-
-%.o: %.c
-       $(CC) $(CFLAGS) $(COMPILE_FLAGS) -c $<
-
-build-library: $(OFILES)
+SUBDIRS =
+TARGETS =
 
+include $(topsrcdir)/Makefile.subdir
index 07ba9c16339561ff0f1a9eafee6e13f8031db53e..c196350c8fdf5ad5d88fbb0a82eec6f1b1854056 100644 (file)
@@ -1,51 +1,6 @@
-#
-# Makefile - Makefile to build pic16 C Library
-#
-# This file is part of the GNU PIC Library.
-#
-# January, 2004
-# The GNU PIC Library is maintained by,
-#      Vangelis Rokas <vrokas@otenet.gr>
-#
-# $Id$
-#
-#
+topsrcdir=../..
 
-include ../Makefile.rules
-
-SRCS   =       atof \
-               atoi \
-               atol \
-               calloc \
-               free \
-               itoa \
-               ltoa \
-               malloc \
-               memfree \
-               memfreemax \
-               memmisc \
-               realloc \
-               x_ftoa \
-               putchar \
-               rand \
-               crc16
-
-S_SRCS = g_ftoa
-
-#CFILES        = $(patsubst %,%.c,$(SRCS))
-#OFILES        = $(patsubst %.c,%.o,$(CFILES))
-
-#OPT_FLAGS     += --stack-auto
-
-DEBUG=
-#COMPILE_FLAGS   += --pomit-config-words --pomit-ivt --denable-peeps --optimize-goto --obanksel=2
-COMPILE_FLAGS  += $(DEBUG)
-
-#CFILES        = $(patsubst %,%.c,$(SRCS))
-#OFILES        = $(patsubst %.c,%.o,$(CFILES))
-
-#.c.o
-#      $(CC) $(CFLAGS) $(COMPILE_FLAGS) -c $<
-
-build-library: $(OFILES)
+SUBDIRS =
+TARGETS =
 
+include $(topsrcdir)/Makefile.subdir
index 4ce5b8a0d29ab14ab784c63d7584ab02092f1deb..c196350c8fdf5ad5d88fbb0a82eec6f1b1854056 100644 (file)
@@ -1,60 +1,6 @@
-#
-# Makefile - Makefile to build pic16 C Library
-#
-# This file is part of the GNU PIC Library.
-#
-# January, 2004
-# The GNU PIC Library is maintained by,
-#      Vangelis Rokas <vrokas@otenet.gr>
-#
-# $Id$
-#
-#
+topsrcdir=../..
 
-include ../Makefile.rules
-
-SRCS   =       memchr  \
-               memcmp  \
-               memcpy  \
-               memccpy \
-               memmove \
-               memrchr \
-               memset  \
-               strcat  \
-               strchr  \
-               strcmp  \
-               strcpy  \
-               strcspn \
-               strlen  \
-               strlwr  \
-               strncat \
-               strncmp \
-               strncpy \
-               strpbrk \
-               strrchr \
-               strspn  \
-               strstr  \
-               strtok  \
-               strupr  \
-               memchrpgm \
-               memchrram \
-               memcpypgm2ram \
-               memcpyram2ram \
-
-
-CFILES = $(patsubst %,%.c,$(SRCS))
-OFILES = $(patsubst %.c,%.o,$(CFILES))
-
-
-DEBUG=
-#COMPILE_FLAGS   += --pomit-config-words --pomit-ivt --denable-peeps --optimize-goto --obanksel=2
-COMPILE_FLAGS  += $(DEBUG)
-
-CFILES = $(patsubst %,%.c,$(SRCS))
-OFILES = $(patsubst %.c,%.o,$(CFILES))
-
-%.o: %.c
-       $(CC) $(CFLAGS) $(COMPILE_FLAGS) -c $<
-
-build-library: $(OFILES)
+SUBDIRS =
+TARGETS =
 
+include $(topsrcdir)/Makefile.subdir
index 6d399da42c1bab4d2dde9f26e8026926522cacf7..c196350c8fdf5ad5d88fbb0a82eec6f1b1854056 100644 (file)
@@ -1,48 +1,6 @@
-#
-# Makefile - Makefile to build pic16 C Library
-#
-# This file is part of the GNU PIC Library.
-#
-# January, 2004
-# The GNU PIC Library is maintained by,
-#      Vangelis Rokas <vrokas@otenet.gr>
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Library General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This library 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.
-#
-#
-# $Id$
-#
-#
+topsrcdir=../..
 
-include ../Makefile.rules
-
-CSRCS  =
-
-S_SRCS =       cnvfrac \
-               cnvint \
-               cvtdec
-
-SRCS   = $(CSRCS)
-
-
-DEBUG=
-#COMPILE_FLAGS   += --pomit-config-words --pomit-ivt --denable-peeps --optimize-goto --obanksel=2
-COMPILE_FLAGS  += $(DEBUG)
-
-
-#all: build-library
-
-build-library: $(OFILES)
+SUBDIRS =
+TARGETS =
 
+include $(topsrcdir)/Makefile.subdir
index 0cb604e041b343c4b75d9cb59964fd575a24c732..804ed151d263605c069424b4cb3e1a8715417fbd 100644 (file)
-#
-# Makefile  - Makefile to build device libraries
-#
-# This file is part of the GNU PIC Library.
-#
-# January, 2004
-# The GNU PIC Library is maintained by,
-#      Vangelis Rokas <vrokas@otenet.gr>
-#
-# $Id$
-#
-#
-
-include ../Makefile.common
-
-# The SDCC project directory
-PRJDIR = ../../../..
-
-# headers directory
-INCDIR = $(PRJDIR)/device/include
-
-
-# MCUs to build
-MCUS   = $(shell cat ../pics.build)
-
-# Supported devices
-DEVS   = $(patsubst    %,18f%,$(MCUS))
-
-#DEVS  =       18f242 \
-#              18f248 \
-#              18f252 \
-#              18f258 \
-#              18f442 \
-#              18f448 \
-#              18f452 \
-#              18f458 \
-#              18f1220 \
-#              18f2220 \
-#              18f6520 \
-#              18f6620 \
-#              18f6680 \
-#              18f6720 \
-#              18f8520 \
-#              18f8620 \
-#              18f8680 \
-#              18f8720
-
-
-# pic16 port specific headers
-PIC16_INCDIR   = $(INCDIR)/pic16
-
-CFLAGS = -I$(PIC16_INCDIR)
-
-#COMPILE_FLAGS = --pomit-config-words --pomit-ivt --denable-peeps --optimize-goto --obanksel=2
-COMPILE_FLAGS  += $(MODELFLAGS) --nostdinc
-
-
-CFILES = $(patsubst %,pic%.c, $(DEVS))
-OFILES = $(patsubst %.c,%.o,$(CFILES))
-LFILES = $(patsubst %.c,%.lib,$(CFILES))
-
-PFILE  = $(patsubst pic%.c,%,$<)
-LFILE  = $(patsubst %.c,%.lib,$<)
-
-
-.c.o:
-       $(CC) -p$(PFILE) $(CFLAGS) $(COMPILE_FLAGS) -c $<
-
-%.lib: %.o
-       $(AR) -c $@ $<
-       
-all: make-lib
-
-make-lib: $(LFILES) clean-intermediate-no-asm
-       @$(MV) -v $(LFILES) ../bin
-       
-$(LFILES): $(OFILES)
-
-$(OFILES): $(CFILES)
-
-
-clean-intermediate:
-       $(RM) -f *.lst *.asm *.dump*
-
-clean-intermediate-no-asm:
-       $(RM) -f *.lst *.dump*
-       
-clean: clean-intermediate
-       $(RM) -f *.o
-
-real-clean: clean
-       $(RM) -f .depend
-
-dep .depend:
-       rm -f .depend
-       for temp in $(CFILES); do               \
-               $(CPP) $(MM) $(CFLAGS) $$temp > .tmpdepend;     \
-               $(SED) s/.rel/.o/g .tmpdepend >> .depend;       \
-               $(RM) -f .tmpdepend;    \
-       done
-       
-include .depend
+###########################################################
+### Makefile for the GNU PIC Library
+###
+### Copyright (C) 2005 by Raphael Neider <rneider@web.de>
+###
+### The GNU PIC Library was originally designed and
+### implemented by
+###    Vangelis Rokas <vrokas@otenet.gr>
+###
+### It is currently maintained by
+###    Raphael Neider <rneider@web.de>
+###
+### This file may be distributed under the terms of the the
+### GNU General Public License (GPL). See COPYING for details.
+###
+### $Id$
+###
+
+topsrcdir=..
+
+SUBDIRS = 
+MKLIB  = device_libs
+C_FILES = $(wildcard *.c)
+TARGETS = $(OBJS:.o=.lib)
+
+# allow invoking make without arguments (otherwise
+# [...]/devicelibs would be the default target)
+suball : all
+
+.PHONY : $(topsrcdir)/$(builddir)/device_libs 
+
+$(topsrcdir)/$(builddir)/device_libs :
+       $(Q)$(foreach dev,$(C_FILES:.c=),make $(topsrcdir)/$(builddir)/$(dev).lib LIB_O=$(topsrcdir)/$(builddir)/$(dev).o;)
+
+include $(topsrcdir)/Makefile.subdir
index 6e9e72fc67c8d038b89b63cb3e5621aa6270d558..3c999bc47469121e5df8aca09de4a219df6d6f19 100644 (file)
@@ -1,71 +1,45 @@
-#
-# Makefile - Makefile to build pic16 support libraries
-#
-# This file is part of the GNU PIC Library.
-#
-# January, 2004
-# The GNU PIC Library is maintained by,
-#      Vangelis Rokas <vrokas@otenet.gr>
-#
-# $Id$
-#
-#
-
-MCUS   = $(shell cat ../pics.build)
-
-PROCESSORS     = $(MCUS)
-
-
-DIRS   = adc i2c usart
-
-LOBJS  = $(patsubst %,%/*.o,$(DIRS))
-
-# library name example libio18f8720.lib
-LIB    = libio18f$(MMCU).lib
-
-all: build-libraries
-
-make-target: build-libraries
-
-build-libraries:
-       for proc in $(PROCESSORS) ; do \
-               echo "Building libraries for processor pic18f $$proc" ; \
-               $(MAKE) -C . build-processor-library MMCU=$$proc ;  \
-       done ;
-
-# Should have externally specified PROC
-build-processor-library:
-       for dir in $(DIRS) ; do  \
-               $(MAKE) -C $$dir clean ; \
-               grep $(MMCU) "$${dir}.ignore" > /dev/null 2>&1 || $(MAKE) -C $$dir build-io-lib MCU=18f$(MMCU); \
-       done;
-       make invoke-gplib
-       mv -v $(LIB) ../bin
+###########################################################
+### Makefile for the GNU PIC Library
+###
+### Copyright (C) 2005 by Raphael Neider <rneider@web.de>
+###
+### The GNU PIC Library was originally designed and
+### implemented by
+###    Vangelis Rokas <vrokas@otenet.gr>
+###
+### It is currently maintained by
+###    Raphael Neider <rneider@web.de>
+###
+### This file may be distributed under the terms of the the
+### GNU General Public License (GPL). See COPYING for details.
+###
+### $Id$
+###
+
+topsrcdir=..
+
+SUBDIRS = adc i2c usart
+
+ifeq ($(origin IO_ARCH),undefined)
+include $(topsrcdir)/Makefile.common
+
+all clean clean-intermediate install : builddir
+       $(Q)cat $(topsrcdir)/pics.build \
+               | $(SED) -e "s,[ \t]*#.*$$,," \
+               | $(GREP) -v "^[ \t]*$$" \
+               | while read arch; do \
+                       [ "x$${arch}" = "x" ] \
+                       || MKLIB=libio18f$${arch}.lib $(MAKE) builddir=$(builddir)/$${arch} ARCH=$${arch} IO_ARCH=$${arch} $(MAKECMDGOALS) \
+                       || exit 1; \
+       done
 
-# needed so that make updates the list of .o files correctly...
-invoke-gplib:
-       gplib -c $(LIB) $(foreach dir,$(DIRS),$(wildcard $(dir)/*.o))
+include $(topsrcdir)/Makefile.rules
 
-clean-intermediate:
-       @for dir in $(DIRS) ; do \
-               $(MAKE) -C $$dir clean-intermediate ; \
-       done ;
-       
-clean:
-       for dir in $(DIRS) ; do \
-               $(MAKE) -C $$dir clean; \
-       done ;
-       rm -fv $(LIB)
+else
 
+include $(topsrcdir)/Makefile.subdir
 
-real-clean: clean
-       find -name *.adb -print | xargs -- rm -fv ;
-       find -name *.p -print | xargs -- rm -fv ;
-       find -name *.d -print | xargs -- rm -fv ;
-       find -name *.dump* -print | xargs -- rm -fv ;
-       
+# prevent library to be build in $(SUBDIRS) as well
+unexport MKLIB
 
-dep:
-       for dir in $(DIRS) ; do \
-               $(MAKE) -C $$dir dep; \
-       done
+endif
diff --git a/device/lib/pic16/libio/Makefile.rules b/device/lib/pic16/libio/Makefile.rules
deleted file mode 100644 (file)
index c208e7e..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-#
-# Makefile.rules - Common Makefile rules to build pic16 C Library
-#
-# This file is part of the GNU PIC Library.
-#
-# January, 2004
-# The GNU PIC Library is maintained by,
-#      Vangelis Rokas <vrokas@otenet.gr>
-#
-# $Id$
-#
-#
-
-
-include ../../Makefile.common
-
-PRJDIR = ../../../../..
-
-LIBC_INC_DIR   = $(PRJDIR)/device/include/pic16
-
-
-COMPILE_FLAGS  += $(MODELFLAGS)
-COMPILE_FLAGS  += -p$(MCU)
-COMPILE_FLAGS  += $(OPT_FLAGS)
-#COMPILE_FLAGS += --i-code-in-asm
-COMPILE_FLAGS   += $(CSTD)
-
-OPT_FLAGS2      +=
-
-CFLAGS = -I$(LIBC_INC_DIR) $(OPT_FLAGS2)
-
-
-CFILES = $(patsubst %,%.c,$(SRCS))
-OFILES = $(patsubst %.c,%.o,$(CFILES))
-
-%.o: %.c
-       $(CC) $(CFLAGS) $(COMPILE_FLAGS) -c $<
-
-all:
-       @echo "Please make target \`build-io-lib' setting"
-       @echo "MCU= to the target device (i.e. MCU=18f452)"
-
-
-build-io-lib: build-library clean-intermediate-no-asm
-
-clean-intermediate:
-       $(RM) -f *.lst *.asm *.dump* *.p *.d *.adb
-
-clean-intermediate-no-asm:
-       $(RM) -f *.lst *.dump* *.p *.d *.adb
-
-
-clean: clean-intermediate
-       $(RM) -f $(LIB) *.o
-
-ttest:
-        $(MAKE) -C ./ build-io-lib MCU=18f452
-
-dep .depend:
-       rm -f .depend
-       for temp in $(CFILES); do \
-               $(CPP) $(MM) $(CFLAGS) $$temp > .tmpdepend; \
-               $(SED) s/.rel/.o/g .tmpdepend >> .depend; \
-               $(RM) -f .tmpdepend; \
-       done;
-
-include .depend
index 93470da29a7a37f3bfb7c7a5fcecaaaf2452ea65..287b76fd25be5c95b91d9b3cb7eddd2a9a5e4e42 100644 (file)
@@ -1,53 +1,6 @@
-#
-# Makefile - Makefile to build pic16 AD convertion library
-#
-# This file is part of the GNU PIC Library.
-#
-# January, 2004
-# The GNU PIC Library is maintained by,
-#      Vangelis Rokas <vrokas@otenet.gr>
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Library General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This library 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.
-#
-#
-# $Id$
-#
+topsrcdir=../..
 
-include ../Makefile.rules
-
-SRCS   =       adcbusy \
-               adcclose \
-               adcconv \
-               adcopen \
-               adcread \
-               adcsetch
-
-
-CFILES = $(patsubst %,%.c,$(SRCS))
-OFILES = $(patsubst %.c,%.o,$(CFILES))
-
-
-DEBUG=
-#COMPILE_FLAGS   += --pomit-config-words --pomit-ivt --denable-peeps --optimize-goto --obanksel=2
-COMPILE_FLAGS  += $(DEBUG)
-
-CFILES = $(patsubst %,%.c,$(SRCS))
-OFILES = $(patsubst %.c,%.o,$(CFILES))
-
-%.o: %.c
-       $(CC) $(CFLAGS) $(COMPILE_FLAGS) -c $<
-
-build-library: $(OFILES)
+SUBDIRS =
+TARGETS = 
 
+include $(topsrcdir)/Makefile.subdir
index 7ad6f9406261ae359d553522aa1aa034c1c42a3b..26ecac5c13bf777d4573bb767a1dab6ca0ffa1f9 100644 (file)
@@ -1,46 +1,6 @@
-#
-# Makefile - Makefile to build pic16 C Library
-#
-# This file is part of the GNU PIC Library.
-#
-# January, 2004
-# The GNU PIC Library is maintained by,
-#      Vangelis Rokas <vrokas@otenet.gr>
-#
-# $Id$
-#
-#
+topsrcdir=../..
 
-include ../Makefile.rules
-
-SRCS   =       i2cack \
-               i2cclose \
-               i2cdrdy \
-               i2cidle \
-               i2cnack \
-               i2copen \
-               i2creadc \
-               i2creads \
-               i2crestart \
-               i2cstart \
-               i2cstop \
-               i2cwritec \
-               i2cwrites
-
-
-CFILES = $(patsubst %,%.c,$(SRCS))
-OFILES = $(patsubst %.c,%.o,$(CFILES))
-
-
-DEBUG=
-#COMPILE_FLAGS   += --pomit-config-words --pomit-ivt --no-peep
-COMPILE_FLAGS  += $(DEBUG)
-
-CFILES = $(patsubst %,%.c,$(SRCS))
-OFILES = $(patsubst %.c,%.o,$(CFILES))
-
-%.o: %.c
-       $(CC) $(CFLAGS) $(COMPILE_FLAGS) -c $<
-
-build-library: $(OFILES)
+SUBDIRS = 
+TARGETS = 
 
+include $(topsrcdir)/Makefile.subdir
index 03c49fb0beb70b404624da119d89f95f001692c8..287b76fd25be5c95b91d9b3cb7eddd2a9a5e4e42 100644 (file)
@@ -1,58 +1,6 @@
-#
-# Makefile - Makefile to build pic16 USART communications library
-#
-# This file is part of the GNU PIC Library.
-#
-# January, 2005
-# The GNU PIC Library is maintained by,
-#      Vangelis Rokas <vrokas@otenet.gr>
-#
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Library General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This library 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.
-#
-#
-# $Id$
-#
+topsrcdir=../..
 
-include ../Makefile.rules
-
-SRCS   =       uclose \
-               ugetc \
-               uopen \
-               usartd \
-               ubusy \
-               udrdy \
-               ugets \
-               uputc \
-               uputs
-
-#ubaud 
-
-CFILES = $(patsubst %,%.c,$(SRCS))
-OFILES = $(patsubst %.c,%.o,$(CFILES))
-
-
-DEBUG=
-#COMPILE_FLAGS   += --pomit-config-words --pomit-ivt --no-peep
-COMPILE_FLAGS  += $(DEBUG)
-
-CFILES = $(patsubst %,%.c,$(SRCS))
-OFILES = $(patsubst %.c,%.o,$(CFILES))
-
-%.o: %.c
-       $(CC) $(CFLAGS) $(COMPILE_FLAGS) -c $<
-
-build-library: $(OFILES)
+SUBDIRS =
+TARGETS = 
 
+include $(topsrcdir)/Makefile.subdir
index 652092450c1c248e28745af622fbe94f7dfac96f..da39ef732e13175e2218540a344e5272ae34cac3 100644 (file)
@@ -1,111 +1,6 @@
-#
-# Makefile - Makefile to build pic16 Math Library
-#
-# This file is part of the GNU PIC Library.
-#
-# January, 2004
-# The GNU PIC Library is maintained by,
-#      Vangelis Rokas <vrokas@otenet.gr>
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Library General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This library 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.
-#
-#
-# $Id$
-#
-#
+topsrcdir=..
 
-include ../Makefile.common
-
-PRJDIR = ../../../..
-
-LIB    = libm18f.lib
-
-SRCS   =       acosf  \
-               asincosf  \
-               asinf  \
-               atan2f  \
-               atanf  \
-               ceilf  \
-               cosf  \
-               coshf  \
-               cotf  \
-               errno  \
-               expf  \
-               fabsf  \
-               floorf  \
-               frexpf  \
-               ldexpf  \
-               log10f  \
-               logf  \
-               modff  \
-               powf  \
-               sincosf  \
-               sincoshf  \
-               sinf  \
-               sinhf  \
-               sqrtf  \
-               tancotf  \
-               tanf  \
-               tanhf
-
-COMPILE_FLAGS  += $(MODELFLAGS) $(OPT_FLAGS)
-COMPILE_FLAGS   += $(CSTD)
-
-CFLAGS  += -I $(PRJDIR)/device/include/pic16
-
-
-CFILES = $(patsubst %,%.c,$(SRCS))
-OFILES = $(patsubst %.c,%.o,$(CFILES))
-
-%.o: %.c
-       $(CC) $(CFLAGS) $(COMPILE_FLAGS) -c $<
-
-all: build-library
-
-build-library: $(LIB)
-
-$(LIB): $(OFILES)
-       @echo Creating $(LIB) ...
-       @for object in $(OFILES) ; do \
-               if [ ! -e $(LIB) ]; then \
-                       $(AR) -c $(LIB) $$object ; \
-               else \
-                       $(AR) -r $(LIB) $$object ; \
-               fi; \
-               echo -n "$$object " ; \
-       done ;
-       @echo
-       @mv -v $(LIB) ../bin
-
-
-all-clean: clean
-
-clean-intermediate:
-       @echo Removing intermediate files ...
-       $(RM) -f *.lst *.asm
-
-clean: clean-intermediate
-       $(RM) -f $(LIB) *.o
-
-dep .depend:
-       -rm .depend
-       @for source in $(CFILES); do                            \
-               $(CC) $(MM) $(CFLAGS) $$source > .tmpdepend ;   \
-               $(SED) s/.rel/.o/g .tmpdepend >> .depend ;      \
-               $(RM) -f .tmpdepend;                            \
-       done
-
-include .depend
+SUBDIRS = 
+MKLIB = libm18f.lib
 
+include $(topsrcdir)/Makefile.subdir
index 5aed8cd23da14f92a9d734fd7a8c8ca03920cc32..b43473ee04e343fba2ecd3f92f0e599cb85ad456 100644 (file)
@@ -1,62 +1,7 @@
-#
-# Makefile - Makefile to build pic16 support libraries
-#
-# This file is part of the GNU PIC Library.
-#
-# January, 2004
-# The GNU PIC Library is maintained by,
-#      Vangelis Rokas <vrokas@otenet.gr>
-#
-# $Id$
-#
-#
+topsrcdir=..
 
+SUBDIRS = char fixed16x16 float gptr int long 
+       # lregs
+MKLIB = libsdcc.lib
 
-DIRS   =       char \
-               int \
-               long \
-               float \
-               gptr
-
-#              lregs
-#              fixed16_16
-
-LOBJS  = $(patsubst %,%/*.o,$(DIRS))
-
-LIB    = libsdcc.lib
-
-all: build-libraries
-
-make-target: build-libraries
-
-build-libraries:
-       for dir in $(DIRS) ; do  \
-               $(MAKE) -C $$dir ; \
-       done;
-       gplib -c $(LIB) $(LOBJS)
-       mv -v $(LIB) ../bin
-       
-
-clean-intermediate:
-       @for dir in $(DIRS) ; do \
-               $(MAKE) -C $$dir clean-intermediate ; \
-       done ;
-       
-clean:
-       for dir in $(DIRS) ; do \
-               $(MAKE) -C $$dir clean; \
-       done ;
-       rm -fv $(LIB)
-
-
-real-clean: clean
-       find -name *.adb -print | xargs -- rm -fv ;
-       find -name *.p -print | xargs -- rm -fv ;
-       find -name *.d -print | xargs -- rm -fv ;
-       find -name *.dump* -print | xargs -- rm -fv ;
-       
-
-dep:
-       for dir in $(DIRS) ; do \
-               $(MAKE) -C $$dir dep; \
-       done
+include $(topsrcdir)/Makefile.subdir
diff --git a/device/lib/pic16/libsdcc/Makefile.rules b/device/lib/pic16/libsdcc/Makefile.rules
deleted file mode 100644 (file)
index 3e0bec8..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-#
-# Makefile.rules - Common Makefile rules to build pic16
-#                  support libraries
-#
-# This file is part of the GNU PIC Library.
-#
-# January, 2004
-# The GNU PIC Library is maintained by,
-#      Vangelis Rokas <vrokas@otenet.gr>
-#
-# $Id$
-#
-#
-
-
-include ../../Makefile.common
-
-PRJDIR = ../../../../..
-
-LIBC_INC_DIR   = $(PRJDIR)/device/include/pic16
-
-DEBUG  =
-
-OPT_FLAGS      += --optimize-cmp
-#OPT_FLAGS     += --stack-auto
-
-COMPILE_FLAGS  += $(MODELFLAGS)
-COMPILE_FLAGS   += $(OPT_FLAGS) $(DEBUG)
-COMPILE_FLAGS   += $(CSTD)
-
-CPPFLAGS        := -nostdinc $(CFLAGS) -I$(LIBC_INC_DIR)
-
-CFLAGS += --nostdinc -I$(LIBC_INC_DIR)
-
-
-CFILES = $(patsubst %,%.c,$(SRCS))
-COFILES        = $(patsubst %.c,%.o,$(CFILES))
-
-SFILES = $(patsubst %,%.S,$(AS_SRCS))
-SOFILES        = $(patsubst %.S,%.o,$(SFILES))
-
-OFILES = $(COFILES) $(SOFILES)
-
-%.o: %.c
-       $(CC) $(CFLAGS) $(COMPILE_FLAGS) -c $<
-
-.S.o:
-       $(AS) -I $(LIBC_INC_DIR) -c $<
-
-
-all: build-library clean-intermediate-no-asm
-
-clean-intermediate:
-       $(RM) -f *.lst *.asm *.dump* *.p *.d *.adb
-
-clean-intermediate-no-asm:
-       $(RM) -f *.lst *.dump* *.p *.d *.adb
-
-clean: clean-intermediate
-       $(RM) -f $(LIB) *.o
-
-dep .depend:
-       rm -f .depend
-       for temp in $(CFILES); do \
-               $(CPP) $(MM) $(CPPFLAGS) $$temp > .tmpdepend; \
-               $(SED) s/.rel/.o/g .tmpdepend >> .depend; \
-               $(RM) -f .tmpdepend; \
-       done;
-       if [ ! -e .depend ]; then touch .depend ; fi ;
-include .depend
index 518459374a24c4299c4ded941ba35631acd7d8de..87adf7fc6be7e77be8abf57e03a0807d2a1bc795 100644 (file)
@@ -1,49 +1,5 @@
-#
-# Makefile - Makefile to build pic16 char support library
-#
-# This file is part of the GNU PIC Library.
-#
-# January, 2004
-# The GNU PIC Library is maintained by,
-#      Vangelis Rokas <vrokas@otenet.gr>
-#
-# $Id$
-#
-#
+topsrcdir=../..
 
+SUBDIRS = 
 
-LIB    = sdccchar.lib
-
-SRCS   =       divschar \
-               divuchar \
-               modschar \
-               moduchar
-
-#SRCS  =       
-
-#              modschar \
-#              moduchar
-
-#AS_SRCS       =       divchar \
-#              modchar
-
-
-include ../Makefile.rules
-
-
-all: build-library
-
-build-library: $(LIB)
-
-$(LIB): $(OFILES)
-       @echo Creating $(LIB) ...
-       @for object in $(OFILES) ; do \
-               if [ ! -e $(LIB) ]; then \
-                       $(AR) -c $(LIB) $$object ; \
-               else \
-                       $(AR) -r $(LIB) $$object ; \
-               fi; \
-               echo -n "$$object " ; \
-       done ;
-       @echo
-       
\ No newline at end of file
+include $(topsrcdir)/Makefile.subdir
diff --git a/device/lib/pic16/libsdcc/fixed16x16/Makefile b/device/lib/pic16/libsdcc/fixed16x16/Makefile
new file mode 100644 (file)
index 0000000..87adf7f
--- /dev/null
@@ -0,0 +1,5 @@
+topsrcdir=../..
+
+SUBDIRS = 
+
+include $(topsrcdir)/Makefile.subdir
diff --git a/device/lib/pic16/libsdcc/fixed16x16/fps16x162schar.S b/device/lib/pic16/libsdcc/fixed16x16/fps16x162schar.S
new file mode 100644 (file)
index 0000000..e12d982
--- /dev/null
@@ -0,0 +1,49 @@
+
+;
+; fps16x162schar.S - convert fixed16x16 to signed char
+;
+; written by Vangelis Rokas, 2004 <vrokas AT otenet.gr>
+;
+;
+; $Id$
+;
+
+       radix dec
+
+;--------------------------------------------------------
+; public variables in this module
+;--------------------------------------------------------
+       global ___fps16x162schar
+
+;--------------------------------------------------------
+;      Equates to used internal registers
+;--------------------------------------------------------
+STATUS equ     0xfd8
+WREG   equ     0xfe8
+FSR0L  equ     0xfe9
+FSR1L  equ     0xfe1
+FSR2L  equ     0xfd9
+POSTDEC1       equ     0xfe5
+PREINC1        equ     0xfe4
+PLUSW1 equ     0xfe3
+PRODL  equ     0xff3
+PRODH  equ     0xff4
+
+
+S_fps16x162schar____fps16x162schar     code
+___fps16x162schar:
+
+       movlw   0x04
+       movff   PLUSW1, PRODL
+
+       movlw   0x03
+       movf    PLUSW1, w
+
+       btfss   PRODL, 7
+       bra     @1
+       negf    WREG
+
+@1:
+       return
+
+       end
diff --git a/device/lib/pic16/libsdcc/fixed16x16/fps16x162sfloat.c b/device/lib/pic16/libsdcc/fixed16x16/fps16x162sfloat.c
new file mode 100644 (file)
index 0000000..b305580
--- /dev/null
@@ -0,0 +1,21 @@
+
+float __fps16x162sfloat(__fixed16x16 fixd)
+{
+  union {
+    __fixed16x16 fix;
+    unsigned long value;
+  } u;
+  float tmp=0, exp=2;
+
+    u.fix = fixd;
+    tmp = (u.value & 0xffff0000) >> 16;
+
+    while(u.value) {
+      u.value &= 0xffff;
+      if(u.value & 0x8000)tmp += 1/exp;
+      exp *= 2;
+      u.value <<= 1;
+    }
+
+  return (tmp);
+}
diff --git a/device/lib/pic16/libsdcc/fixed16x16/fps16x162sint.S b/device/lib/pic16/libsdcc/fixed16x16/fps16x162sint.S
new file mode 100644 (file)
index 0000000..1debd57
--- /dev/null
@@ -0,0 +1,56 @@
+
+;
+; fps16x162sint.S - convert fixed16x16 to signed char
+;
+; written by Vangelis Rokas, 2004 <vrokas AT otenet.gr>
+;
+;
+; $Id$
+;
+
+       radix dec
+
+;--------------------------------------------------------
+; public variables in this module
+;--------------------------------------------------------
+       global ___fps16x162sint
+
+;--------------------------------------------------------
+;      Equates to used internal registers
+;--------------------------------------------------------
+STATUS equ     0xfd8
+WREG   equ     0xfe8
+FSR0L  equ     0xfe9
+FSR1L  equ     0xfe1
+FSR2L  equ     0xfd9
+POSTDEC1       equ     0xfe5
+PREINC1        equ     0xfe4
+PLUSW2 equ     0xfdb
+PLUSW1 equ     0xfe3
+PRODL  equ     0xff3
+PRODH  equ     0xff4
+
+
+S_fps16x162sint____fps16x162sint       code
+___fps16x162sint:
+
+       movlw   0x04
+       movff   PLUSW1, PRODL
+
+       movlw   0x03
+       movf    PLUSW1, w
+
+       btfss   PRODL, 7
+       bra     @1
+
+       bcf     PRODL, 7
+
+       comf    WREG, f
+       comf    PRODL, f
+       infsnz  WREG, f
+       incf    PRODL, f
+
+@1:
+       return
+
+       end
diff --git a/device/lib/pic16/libsdcc/fixed16x16/fps16x162slong.S b/device/lib/pic16/libsdcc/fixed16x16/fps16x162slong.S
new file mode 100644 (file)
index 0000000..2e2fff5
--- /dev/null
@@ -0,0 +1,74 @@
+
+;
+; fps16x162slong.S - convert fixed16x16 to signed char
+;
+; written by Vangelis Rokas, 2004 <vrokas AT otenet.gr>
+;
+;
+; $Id$
+;
+
+       radix dec
+
+;--------------------------------------------------------
+; public variables in this module
+;--------------------------------------------------------
+       global ___fps16x162slong
+
+;--------------------------------------------------------
+;      Equates to used internal registers
+;--------------------------------------------------------
+STATUS equ     0xfd8
+WREG   equ     0xfe8
+FSR0L  equ     0xfe9
+FSR1L  equ     0xfe1
+FSR2L  equ     0xfd9
+POSTDEC1       equ     0xfe5
+PREINC1        equ     0xfe4
+PLUSW2 equ     0xfdb
+PLUSW1 equ     0xfe3
+PRODL  equ     0xff3
+PRODH  equ     0xff4
+
+
+; Internal registers
+.registers     udata_ovr       0x0000
+r0x00  res     1
+r0x01  res     1
+r0x02  res     1
+r0x03  res     1
+
+
+S_fps16x162slong____fps16x162slong     code
+___fps16x162slong:
+
+       movlw   0x04
+       movff   PLUSW1, PRODL
+
+       movlw   0x03
+       movf    PLUSW1, w
+
+       clrf    PRODH
+       clrf    FSR0L
+
+       btfss   PRODL, 7
+       bra     @1
+
+       bcf     PRODL, 7
+       comf    WREG, f
+       comf    PRODL, f
+       comf    PRODH, f
+       comf    FSR0L, f
+       
+       incfsz  WREG, f
+       bra     @1
+       incfsz  PRODL, f
+       bra     @1
+       incfsz  PRODH, f
+       bra     @1
+       incf    FSR0L, f
+
+@1:
+       return
+
+       end
diff --git a/device/lib/pic16/libsdcc/fixed16x16/fps16x162uchar.S b/device/lib/pic16/libsdcc/fixed16x16/fps16x162uchar.S
new file mode 100644 (file)
index 0000000..a0bade5
--- /dev/null
@@ -0,0 +1,53 @@
+
+;
+; fps16x162uchar.S - convert fixed16x16 to signed char
+;
+; written by Vangelis Rokas, 2004 <vrokas AT otenet.gr>
+;
+;
+; $Id$
+;
+
+       radix dec
+
+;--------------------------------------------------------
+; public variables in this module
+;--------------------------------------------------------
+       global ___fps16x162uchar
+
+;--------------------------------------------------------
+;      Equates to used internal registers
+;--------------------------------------------------------
+STATUS equ     0xfd8
+WREG   equ     0xfe8
+FSR0L  equ     0xfe9
+FSR1L  equ     0xfe1
+FSR2L  equ     0xfd9
+POSTDEC1       equ     0xfe5
+PREINC1        equ     0xfe4
+PLUSW2 equ     0xfdb
+PLUSW1 equ     0xfe3
+PRODL  equ     0xff3
+PRODH  equ     0xff4
+
+
+; Internal registers
+.registers     udata_ovr       0x0000
+r0x00  res     1
+r0x01  res     1
+r0x02  res     1
+r0x03  res     1
+
+
+S_fps16x162uchar____fps16x162uchar     code
+___fps16x162uchar:
+
+       ; normally would read from 0x04 but since we haven't setup
+       ; a stack frame, then read from 0x04 - 1 (VR)
+
+       movlw   0x03
+       movf    PLUSW1, w
+
+       return
+
+       end
diff --git a/device/lib/pic16/libsdcc/fixed16x16/fps16x162uint.S b/device/lib/pic16/libsdcc/fixed16x16/fps16x162uint.S
new file mode 100644 (file)
index 0000000..a5ddf85
--- /dev/null
@@ -0,0 +1,53 @@
+
+;
+; fps16x162uint.S - convert fixed16x16 to signed char
+;
+; written by Vangelis Rokas, 2004 <vrokas AT otenet.gr>
+;
+;
+; $Id$
+;
+
+       radix dec
+
+;--------------------------------------------------------
+; public variables in this module
+;--------------------------------------------------------
+       global ___fps16x162uint
+
+;--------------------------------------------------------
+;      Equates to used internal registers
+;--------------------------------------------------------
+STATUS equ     0xfd8
+WREG   equ     0xfe8
+FSR0L  equ     0xfe9
+FSR1L  equ     0xfe1
+FSR2L  equ     0xfd9
+POSTDEC1       equ     0xfe5
+PREINC1        equ     0xfe4
+PLUSW2 equ     0xfdb
+PLUSW1 equ     0xfe3
+PRODL  equ     0xff3
+PRODH  equ     0xff4
+
+
+; Internal registers
+.registers     udata_ovr       0x0000
+r0x00  res     1
+r0x01  res     1
+r0x02  res     1
+r0x03  res     1
+
+
+S_fps16x162uint____fps16x162uint       code
+___fps16x162uint:
+
+       movlw   0x04
+       movff   PLUSW1, PRODL
+
+       movlw   0x03
+       movf    PLUSW1, w
+
+       return
+
+       end
diff --git a/device/lib/pic16/libsdcc/fixed16x16/fps16x162ulong.S b/device/lib/pic16/libsdcc/fixed16x16/fps16x162ulong.S
new file mode 100644 (file)
index 0000000..6b5e03b
--- /dev/null
@@ -0,0 +1,61 @@
+
+;
+; fps16x162ulong.S - convert fixed16x16 to signed char
+;
+; written by Vangelis Rokas, 2004 <vrokas AT otenet.gr>
+;
+;
+; $Id$
+;
+
+       radix dec
+
+;--------------------------------------------------------
+; public variables in this module
+;--------------------------------------------------------
+       global ___fps16x162ulong
+
+;--------------------------------------------------------
+;      Equates to used internal registers
+;--------------------------------------------------------
+STATUS equ     0xfd8
+WREG   equ     0xfe8
+FSR0L  equ     0xfe9
+FSR1L  equ     0xfe1
+FSR2L  equ     0xfd9
+POSTDEC1       equ     0xfe5
+PREINC1        equ     0xfe4
+PLUSW2 equ     0xfdb
+PLUSW1 equ     0xfe3
+PRODL  equ     0xff3
+PRODH  equ     0xff4
+
+
+; Internal registers
+.registers     udata_ovr       0x0000
+r0x00  res     1
+r0x01  res     1
+r0x02  res     1
+r0x03  res     1
+
+
+S_fps16x162ulong____fps16x162ulong     code
+___fps16x162ulong:
+
+       movlw   0x04
+       movff   PLUSW1, PRODL
+
+       movlw   0x7f
+       andwf   PRODL, f
+
+       movlw   0x03
+       movf    PLUSW1, w
+
+       
+
+       clrf    PRODH
+       clrf    FSR0L
+
+       return
+
+       end
diff --git a/device/lib/pic16/libsdcc/fixed16x16/fps16x16_add.c b/device/lib/pic16/libsdcc/fixed16x16/fps16x16_add.c
new file mode 100644 (file)
index 0000000..5e9689c
--- /dev/null
@@ -0,0 +1,17 @@
+
+union u_t {
+  long value;
+  __fixed16x16 fix;
+};
+
+__fixed16x16 __fps16x16_add(__fixed16x16 a, __fixed16x16 b)
+{
+  volatile union u_t u1, u2;
+
+  u1.fix = a;
+  u2.fix = b;
+  
+  u1.value += u2.value;
+
+  return (u1.fix);
+}
diff --git a/device/lib/pic16/libsdcc/fixed16x16/fps16x16_div.c b/device/lib/pic16/libsdcc/fixed16x16/fps16x16_div.c
new file mode 100644 (file)
index 0000000..6656939
--- /dev/null
@@ -0,0 +1,17 @@
+
+union u_t {
+  long value;
+  __fixed16x16 fix;
+};
+
+__fixed16x16 __fps16x16_div(__fixed16x16 a, __fixed16x16 b)
+{
+  volatile union u_t u1, u2;
+
+  u1.fix = a;
+  u2.fix = b;
+  
+  u1.value = ((u1.value << 6) / u2.value) << 10;
+
+  return (u1.fix);
+}
diff --git a/device/lib/pic16/libsdcc/fixed16x16/fps16x16_eq.c b/device/lib/pic16/libsdcc/fixed16x16/fps16x16_eq.c
new file mode 100644 (file)
index 0000000..7bf4550
--- /dev/null
@@ -0,0 +1,42 @@
+/*-------------------------------------------------------------------------
+   fps16x16_eq.c - compare two __fixed16x16 values for equality
+
+             written by - Raphael Neider, rneider@web.de (2005)
+   
+   This library is free software; you can redistribute it and/or modify it
+   under the terms of the GNU Library General Public License as published by the
+   Free Software Foundation; either version 2, or (at your option) any
+   later version.
+
+   This library 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 Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+   In other words, you are welcome to use, share and improve this program.
+   You are forbidden to forbid anyone else to use, share and improve
+   what you give them.   Help stamp out software-hoarding!
+
+   $Id$
+-------------------------------------------------------------------------*/
+
+union u_t {
+  long value;
+  __fixed16x16 fix;
+};
+
+char
+__fps16x16_eq (__fixed16x16 a, __fixed16x16 b)
+{
+  union u_t u1, u2;
+
+  u1.fix = a;
+  u2.fix = b;
+  
+  return (u1.value == u2.value);
+}
+
diff --git a/device/lib/pic16/libsdcc/fixed16x16/fps16x16_gt.c b/device/lib/pic16/libsdcc/fixed16x16/fps16x16_gt.c
new file mode 100644 (file)
index 0000000..139d957
--- /dev/null
@@ -0,0 +1,42 @@
+/*-------------------------------------------------------------------------
+   fps16x16_gt.c - compare two __fixed16x16 values
+
+             written by - Raphael Neider, rneider@web.de (2005)
+   
+   This library is free software; you can redistribute it and/or modify it
+   under the terms of the GNU Library General Public License as published by the
+   Free Software Foundation; either version 2, or (at your option) any
+   later version.
+
+   This library 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 Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+   In other words, you are welcome to use, share and improve this program.
+   You are forbidden to forbid anyone else to use, share and improve
+   what you give them.   Help stamp out software-hoarding!
+
+   $Id$
+-------------------------------------------------------------------------*/
+
+union u_t {
+  long value;
+  __fixed16x16 fix;
+};
+
+char
+__fps16x16_gt (__fixed16x16 a, __fixed16x16 b)
+{
+  union u_t u1, u2;
+
+  u1.fix = a;
+  u2.fix = b;
+  
+  return (u1.value > u2.value);
+}
+
diff --git a/device/lib/pic16/libsdcc/fixed16x16/fps16x16_gteq.c b/device/lib/pic16/libsdcc/fixed16x16/fps16x16_gteq.c
new file mode 100644 (file)
index 0000000..33552bd
--- /dev/null
@@ -0,0 +1,42 @@
+/*-------------------------------------------------------------------------
+   fps16x16_gteq.c - compare two __fixed16x16 values
+
+             written by - Raphael Neider, rneider@web.de (2005)
+   
+   This library is free software; you can redistribute it and/or modify it
+   under the terms of the GNU Library General Public License as published by the
+   Free Software Foundation; either version 2, or (at your option) any
+   later version.
+
+   This library 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 Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+   In other words, you are welcome to use, share and improve this program.
+   You are forbidden to forbid anyone else to use, share and improve
+   what you give them.   Help stamp out software-hoarding!
+
+   $Id$
+-------------------------------------------------------------------------*/
+
+union u_t {
+  long value;
+  __fixed16x16 fix;
+};
+
+char
+__fps16x16_gteq (__fixed16x16 a, __fixed16x16 b)
+{
+  union u_t u1, u2;
+
+  u1.fix = a;
+  u2.fix = b;
+  
+  return (u1.value >= u2.value);
+}
+
diff --git a/device/lib/pic16/libsdcc/fixed16x16/fps16x16_lt.c b/device/lib/pic16/libsdcc/fixed16x16/fps16x16_lt.c
new file mode 100644 (file)
index 0000000..dac5659
--- /dev/null
@@ -0,0 +1,42 @@
+/*-------------------------------------------------------------------------
+   fps16x16_lt.c - compare two __fixed16x16 values
+
+             written by - Raphael Neider, rneider@web.de (2005)
+   
+   This library is free software; you can redistribute it and/or modify it
+   under the terms of the GNU Library General Public License as published by the
+   Free Software Foundation; either version 2, or (at your option) any
+   later version.
+
+   This library 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 Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+   In other words, you are welcome to use, share and improve this program.
+   You are forbidden to forbid anyone else to use, share and improve
+   what you give them.   Help stamp out software-hoarding!
+
+   $Id$
+-------------------------------------------------------------------------*/
+
+union u_t {
+  long value;
+  __fixed16x16 fix;
+};
+
+char
+__fps16x16_lt (__fixed16x16 a, __fixed16x16 b)
+{
+  union u_t u1, u2;
+
+  u1.fix = a;
+  u2.fix = b;
+  
+  return (u1.value < u2.value);
+}
+
diff --git a/device/lib/pic16/libsdcc/fixed16x16/fps16x16_lteq.c b/device/lib/pic16/libsdcc/fixed16x16/fps16x16_lteq.c
new file mode 100644 (file)
index 0000000..c615401
--- /dev/null
@@ -0,0 +1,42 @@
+/*-------------------------------------------------------------------------
+   fps16x16_lteq.c - compare two __fixed16x16 values
+
+             written by - Raphael Neider, rneider@web.de (2005)
+   
+   This library is free software; you can redistribute it and/or modify it
+   under the terms of the GNU Library General Public License as published by the
+   Free Software Foundation; either version 2, or (at your option) any
+   later version.
+
+   This library 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 Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+   In other words, you are welcome to use, share and improve this program.
+   You are forbidden to forbid anyone else to use, share and improve
+   what you give them.   Help stamp out software-hoarding!
+
+   $Id$
+-------------------------------------------------------------------------*/
+
+union u_t {
+  long value;
+  __fixed16x16 fix;
+};
+
+char
+__fps16x16_lteq (__fixed16x16 a, __fixed16x16 b)
+{
+  union u_t u1, u2;
+
+  u1.fix = a;
+  u2.fix = b;
+  
+  return (u1.value <= u2.value);
+}
+
diff --git a/device/lib/pic16/libsdcc/fixed16x16/fps16x16_mul.c b/device/lib/pic16/libsdcc/fixed16x16/fps16x16_mul.c
new file mode 100644 (file)
index 0000000..3e23f3f
--- /dev/null
@@ -0,0 +1,17 @@
+
+union u_t {
+  long value;
+  __fixed16x16 fix;
+};
+
+__fixed16x16 __fps16x16_mul(__fixed16x16 a, __fixed16x16 b)
+{
+  volatile union u_t u1, u2;
+
+  u1.fix = a;
+  u2.fix = b;
+  
+  u1.value = (u1.value >> 4) * (u2.value >> 4) >> 8;
+  
+  return (u1.fix);
+}
diff --git a/device/lib/pic16/libsdcc/fixed16x16/fps16x16_neq.c b/device/lib/pic16/libsdcc/fixed16x16/fps16x16_neq.c
new file mode 100644 (file)
index 0000000..5130a25
--- /dev/null
@@ -0,0 +1,42 @@
+/*-------------------------------------------------------------------------
+   fps16x16_neq.c - compare two __fixed16x16 values for inequality
+
+             written by - Raphael Neider, rneider@web.de (2005)
+   
+   This library is free software; you can redistribute it and/or modify it
+   under the terms of the GNU Library General Public License as published by the
+   Free Software Foundation; either version 2, or (at your option) any
+   later version.
+
+   This library 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 Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+   In other words, you are welcome to use, share and improve this program.
+   You are forbidden to forbid anyone else to use, share and improve
+   what you give them.   Help stamp out software-hoarding!
+
+   $Id$
+-------------------------------------------------------------------------*/
+
+union u_t {
+  long value;
+  __fixed16x16 fix;
+};
+
+char
+__fps16x16_neq (__fixed16x16 a, __fixed16x16 b)
+{
+  union u_t u1, u2;
+
+  u1.fix = a;
+  u2.fix = b;
+  
+  return (u1.value != u2.value);
+}
+
diff --git a/device/lib/pic16/libsdcc/fixed16x16/fps16x16_sub.c b/device/lib/pic16/libsdcc/fixed16x16/fps16x16_sub.c
new file mode 100644 (file)
index 0000000..a542d47
--- /dev/null
@@ -0,0 +1,17 @@
+
+union u_t {
+  long value;
+  __fixed16x16 fix;
+};
+
+__fixed16x16 __fps16x16_sub(__fixed16x16 a, __fixed16x16 b)
+{
+  volatile union u_t u1, u2;
+
+  u1.fix = a;
+  u2.fix = b;
+  
+  u1.value -= u2.value;
+
+  return (u1.fix);
+}
diff --git a/device/lib/pic16/libsdcc/fixed16x16/schar2fps16x16.S b/device/lib/pic16/libsdcc/fixed16x16/schar2fps16x16.S
new file mode 100644 (file)
index 0000000..97ed3a2
--- /dev/null
@@ -0,0 +1,57 @@
+
+;
+; schar2fps16x16.S - convert signed char to fixed16x16
+;
+; written by Vangelis Rokas, 2004 <vrokas AT otenet.gr>
+;
+;
+; $Id$
+;
+
+       radix dec
+
+;--------------------------------------------------------
+; public variables in this module
+;--------------------------------------------------------
+       global ___schar2fps16x16
+
+;--------------------------------------------------------
+;      Equates to used internal registers
+;--------------------------------------------------------
+STATUS equ     0xfd8
+WREG   equ     0xfe8
+FSR0L  equ     0xfe9
+FSR1L  equ     0xfe1
+FSR2L  equ     0xfd9
+POSTDEC1       equ     0xfe5
+PREINC1        equ     0xfe4
+PLUSW1 equ     0xfe3
+PRODL  equ     0xff3
+PRODH  equ     0xff4
+
+
+S_schar2fps16x16____schar2fps16x16     code
+___schar2fps16x16:
+
+       movlw   0x01
+       movff   PLUSW1, PRODH
+
+       clrf    WREG
+       clrf    PRODL
+       clrf    FSR0L
+
+       btfss   PRODH, 7
+       bra     @1
+
+       comf    PRODH, f
+       comf    FSR0L, f
+
+       infsnz  PRODH, f
+       incf    FSR0L, f
+
+       bsf     FSR0L, 7
+
+@1:
+       return
+
+       end
diff --git a/device/lib/pic16/libsdcc/fixed16x16/sint2fps16x16.S b/device/lib/pic16/libsdcc/fixed16x16/sint2fps16x16.S
new file mode 100644 (file)
index 0000000..3704182
--- /dev/null
@@ -0,0 +1,59 @@
+
+;
+; sint2fps16x16.S - convert signed char to fixed16x16
+;
+; written by Vangelis Rokas, 2004 <vrokas AT otenet.gr>
+;
+;
+; $Id$
+;
+
+       radix dec
+
+;--------------------------------------------------------
+; public variables in this module
+;--------------------------------------------------------
+       global ___sint2fps16x16
+
+;--------------------------------------------------------
+;      Equates to used internal registers
+;--------------------------------------------------------
+STATUS equ     0xfd8
+WREG   equ     0xfe8
+FSR0L  equ     0xfe9
+FSR1L  equ     0xfe1
+FSR2L  equ     0xfd9
+POSTDEC1       equ     0xfe5
+PREINC1        equ     0xfe4
+PLUSW1 equ     0xfe3
+PRODL  equ     0xff3
+PRODH  equ     0xff4
+
+
+S_sint2fps16x16____sint2fps16x16       code
+___sint2fps16x16:
+
+       movlw   0x02
+       movff   PLUSW1, FSR0L
+       movlw   0x01
+       movff   PLUSW1, PRODH
+
+       clrf    WREG
+       clrf    PRODL
+
+       btfss   FSR0L, 7
+       bra     @1
+
+       
+       comf    PRODH, f
+       comf    FSR0L, f
+
+       infsnz  PRODH, f
+       incf    FSR0L, f
+
+       bsf     FSR0L, 7
+
+@1:
+       return
+
+       end
diff --git a/device/lib/pic16/libsdcc/fixed16x16/slong2fps16x16.S b/device/lib/pic16/libsdcc/fixed16x16/slong2fps16x16.S
new file mode 100644 (file)
index 0000000..37acb92
--- /dev/null
@@ -0,0 +1,55 @@
+
+;
+; slong2fps16x16.S - convert signed long to fixed16x16
+;
+; written by Vangelis Rokas, 2004 <vrokas AT otenet.gr>
+;
+;
+; $Id$
+;
+
+       radix dec
+
+;--------------------------------------------------------
+; public variables in this module
+;--------------------------------------------------------
+       global ___slong2fps16x16
+
+;--------------------------------------------------------
+;      Equates to used internal registers
+;--------------------------------------------------------
+STATUS equ     0xfd8
+WREG   equ     0xfe8
+FSR0L  equ     0xfe9
+FSR1L  equ     0xfe1
+FSR2L  equ     0xfd9
+POSTDEC1       equ     0xfe5
+PREINC1        equ     0xfe4
+PLUSW1 equ     0xfe3
+PRODL  equ     0xff3
+PRODH  equ     0xff4
+
+
+S_slong2fps16x16____slong2fps16x16     code
+___slong2fps16x16:
+
+       movlw   0x02
+       movff   PLUSW1, FSR0L
+       movlw   0x01
+       movff   PLUSW1, PRODH
+
+       btfss   FSR0L, 7
+       bra     @1
+
+       comf    PRODH, f
+       comf    FSR0L, f
+
+       infsnz  PRODH, f
+       incf    FSR0L, f
+
+       bsf     FSR0L, 7
+
+@1:
+       return
+
+       end
diff --git a/device/lib/pic16/libsdcc/fixed16x16/uchar2fps16x16.S b/device/lib/pic16/libsdcc/fixed16x16/uchar2fps16x16.S
new file mode 100644 (file)
index 0000000..97fe866
--- /dev/null
@@ -0,0 +1,48 @@
+
+;
+; uchar2fps16x16.S - convert signed char to fixed16x16
+;
+; written by Vangelis Rokas, 2004 <vrokas AT otenet.gr>
+;
+;
+; $Id$
+;
+
+       radix dec
+
+;--------------------------------------------------------
+; public variables in this module
+;--------------------------------------------------------
+       global ___uchar2fps16x16
+
+;--------------------------------------------------------
+;      Equates to used internal registers
+;--------------------------------------------------------
+STATUS equ     0xfd8
+WREG   equ     0xfe8
+FSR0L  equ     0xfe9
+FSR1L  equ     0xfe1
+FSR2L  equ     0xfd9
+POSTDEC1       equ     0xfe5
+PREINC1        equ     0xfe4
+PLUSW1 equ     0xfe3
+PRODL  equ     0xff3
+PRODH  equ     0xff4
+
+
+S_uchar2fps16x16____uchar2fps16x16     code
+___uchar2fps16x16:
+
+       movlw   0x01
+       movff   PLUSW1, PRODH
+
+       clrf    WREG
+       clrf    PRODL
+       clrf    FSR0L
+
+       bcf     FSR0L, 7
+
+@1:
+       return
+
+       end
diff --git a/device/lib/pic16/libsdcc/fixed16x16/uint2fps16x16.S b/device/lib/pic16/libsdcc/fixed16x16/uint2fps16x16.S
new file mode 100644 (file)
index 0000000..177bc08
--- /dev/null
@@ -0,0 +1,49 @@
+
+;
+; uint2fps16x16.S - convert signed char to fixed16x16
+;
+; written by Vangelis Rokas, 2004 <vrokas AT otenet.gr>
+;
+;
+; $Id$
+;
+
+       radix dec
+
+;--------------------------------------------------------
+; public variables in this module
+;--------------------------------------------------------
+       global ___uint2fps16x16
+
+;--------------------------------------------------------
+;      Equates to used internal registers
+;--------------------------------------------------------
+STATUS equ     0xfd8
+WREG   equ     0xfe8
+FSR0L  equ     0xfe9
+FSR1L  equ     0xfe1
+FSR2L  equ     0xfd9
+POSTDEC1       equ     0xfe5
+PREINC1        equ     0xfe4
+PLUSW1 equ     0xfe3
+PRODL  equ     0xff3
+PRODH  equ     0xff4
+
+
+S_uint2fps16x16____uint2fps16x16       code
+___uint2fps16x16:
+
+       movlw   0x02
+       movff   PLUSW1, FSR0L
+       movlw   0x01
+       movff   PLUSW1, PRODH
+
+       clrf    WREG
+       clrf    PRODL
+
+       bcf     FSR0L, 7
+
+@1:
+       return
+
+       end
diff --git a/device/lib/pic16/libsdcc/fixed16x16/ulong2fps16x16.S b/device/lib/pic16/libsdcc/fixed16x16/ulong2fps16x16.S
new file mode 100644 (file)
index 0000000..f2a3831
--- /dev/null
@@ -0,0 +1,46 @@
+
+;
+; ulong2fps16x16.S - convert signed long to fixed16x16
+;
+; written by Vangelis Rokas, 2004 <vrokas AT otenet.gr>
+;
+;
+; $Id$
+;
+
+       radix dec
+
+;--------------------------------------------------------
+; public variables in this module
+;--------------------------------------------------------
+       global ___ulong2fps16x16
+
+;--------------------------------------------------------
+;      Equates to used internal registers
+;--------------------------------------------------------
+STATUS equ     0xfd8
+WREG   equ     0xfe8
+FSR0L  equ     0xfe9
+FSR1L  equ     0xfe1
+FSR2L  equ     0xfd9
+POSTDEC1       equ     0xfe5
+PREINC1        equ     0xfe4
+PLUSW1 equ     0xfe3
+PRODL  equ     0xff3
+PRODH  equ     0xff4
+
+
+S_ulong2fps16x16____ulong2fps16x16     code
+___ulong2fps16x16:
+
+       movlw   0x02
+       movff   PLUSW1, FSR0L
+       movlw   0x01
+       movff   PLUSW1, PRODH
+
+       bcf     FSR0L, 7
+
+@1:
+       return
+
+       end
index bbb233d9cb5a8b3036c0ff70a8bebcef9958a29e..87adf7fc6be7e77be8abf57e03a0807d2a1bc795 100644 (file)
@@ -1,57 +1,5 @@
-#
-# Makefile - Makefile to build pic16 float support library
-#
-# This file is part of the GNU PIC Library.
-#
-# January, 2004
-# The GNU PIC Library is maintained by,
-#      Vangelis Rokas <vrokas@otenet.gr>
-#
-# $Id$
-#
-#
+topsrcdir=../..
 
+SUBDIRS = 
 
-LIB    = sdccfloat.lib
-
-SRCS   =       fs2schar \
-               fs2sint \
-               fs2slong \
-               fs2uchar \
-               fs2uint \
-               fs2ulong \
-               fsadd \
-               fsdiv \
-               fseq \
-               fsgt \
-               fslt \
-               fsmul \
-               fsneq \
-               fssub \
-               schar2fs \
-               sint2fs \
-               slong2fs \
-               uchar2fs \
-               uint2fs \
-               ulong2fs
-
-LOCAL_FLAGS    =
-COMPILE_FLAGS  += $(LOCAL_FLAGS)
-
-include ../Makefile.rules
-
-all: build-library
-
-build-library: $(LIB)
-
-$(LIB): $(OFILES)
-       @echo Creating $(LIB) ...
-       @for object in $(OFILES) ; do \
-               if [ ! -e $(LIB) ]; then \
-                       $(AR) -c $(LIB) $$object ; \
-               else \
-                       $(AR) -r $(LIB) $$object ; \
-               fi; \
-               echo -n "$$object " ; \
-       done ;
-       @echo
+include $(topsrcdir)/Makefile.subdir
index 1659055d4b10d93e1980d96d541bfcbed887086f..87adf7fc6be7e77be8abf57e03a0807d2a1bc795 100644 (file)
@@ -1,36 +1,5 @@
-#
-# Makefile - Makefile to build pic16 generic pointer support library
-#
-# This file is part of the GNU PIC Library.
-#
-# January, 2004
-# The GNU PIC Library is maintained by,
-#      Vangelis Rokas <vrokas@otenet.gr>
-#
-# $Id$
-#
-#
+topsrcdir=../..
 
+SUBDIRS = 
 
-SRCS   =       gptrget1 \
-               gptrget2 \
-               gptrget3 \
-               gptrget4 \
-               gptrput1 \
-               gptrput2 \
-               gptrput3 \
-               gptrput4
-
-
-include ../Makefile.rules
-
-#OFILES        += gptrcommon.o
-
-
-all: build-library
-
-#gptrcommon.o: gptrcommon.S
-#      $(AS) -c $< -o $@
-
-build-library: $(OFILES)
-#      @$(CP) -v $(OFILES) ../../bin
+include $(topsrcdir)/Makefile.subdir
index f2ae3671065dba625aa468f7900191e15a7a687c..87adf7fc6be7e77be8abf57e03a0807d2a1bc795 100644 (file)
@@ -1,39 +1,5 @@
-#
-# Makefile - Makefile to build pic16 int upport library
-#
-# This file is part of the GNU PIC Library.
-#
-# January, 2004
-# The GNU PIC Library is maintained by,
-#      Vangelis Rokas <vrokas@otenet.gr>
-#
-# $Id$
-#
-#
+topsrcdir=../..
 
+SUBDIRS = 
 
-LIB    = sdccint.lib
-
-SRCS   =       divsint \
-               divuint \
-               modsint \
-               moduint \
-               mulint
-
-include ../Makefile.rules
-
-
-all: build-library
-
-build-library: $(LIB)
-
-$(LIB): $(OFILES)
-       @echo Creating $(LIB) ...
-       @for object in $(OFILES) ; do \
-               if [ ! -e $(LIB) ]; then \
-                       $(AR) -c $(LIB) $$object ; \
-               else \
-                       $(AR) -r $(LIB) $$object ; \
-               fi; \
-               echo adding $$object ; \
-       done ;
+include $(topsrcdir)/Makefile.subdir
index 57c4b7e493e57751576b0a8da0bc291faa428d6d..87adf7fc6be7e77be8abf57e03a0807d2a1bc795 100644 (file)
@@ -1,39 +1,5 @@
-#
-# Makefile - Makefile to build pic16 long support library
-#
-# This file is part of the GNU PIC Library.
-#
-# January, 2004
-# The GNU PIC Library is maintained by,
-#      Vangelis Rokas <vrokas@otenet.gr>
-#
-# $Id$
-#
-#
+topsrcdir=../..
 
+SUBDIRS = 
 
-LIB    = sdcclong.lib
-
-SRCS   =       divslong \
-               divulong \
-               modslong \
-               modulong \
-               mullong
-
-include ../Makefile.rules
-
-
-all: build-library
-
-build-library: $(LIB)
-
-$(LIB): $(OFILES)
-       @echo Creating $(LIB) ...
-       @for object in $(OFILES) ; do \
-               if [ ! -e $(LIB) ]; then \
-                       $(AR) -c $(LIB) $$object ; \
-               else \
-                       $(AR) -r $(LIB) $$object ; \
-               fi; \
-               echo adding $$object ; \
-       done ;
+include $(topsrcdir)/Makefile.subdir
index 0677a42ae458f78f66e9823d44bd5d6f2a6cd608..87adf7fc6be7e77be8abf57e03a0807d2a1bc795 100644 (file)
@@ -1,25 +1,5 @@
-#
-# Makefile - Makefile to build pic16 local register store/restore
-#           support library
-#
-# This file is part of the GNU PIC Library.
-#
-# January, 2004
-# The GNU PIC Library is maintained by,
-#      Vangelis Rokas <vrokas@otenet.gr>
-#
-# $Id$
-#
-#
+topsrcdir=../..
 
+SUBDIRS = 
 
-SRCS   =       lrst \
-               lrrest
-
-
-include ../Makefile.rules
-
-
-all: build-library
-
-build-library: $(OFILES)
+include $(topsrcdir)/Makefile.subdir
index f8a86a4580ff534202e31a37b7588aaf9561592f..882981fa837e9a8e783942bc8988ae152c511acd 100644 (file)
@@ -1,61 +1,6 @@
-#
-# Makefile - Makefile to build startup files
-#
-# This file is part of the GNU PIC Library.
-#
-# January, 2004
-# The GNU PIC Library is maintained by,
-#      Vangelis Rokas <vrokas@otenet.gr>
-#
-# $Id$
-#
-#
+topsrcdir=..
 
+SUBDIRS = 
+TARGETS = $(OBJS)
 
-PRJDIR = ../../../..
-include ../Makefile.common
-
-
-SRCS   =       crt0    \
-               crt0i   \
-               crt0iz
-
-
-# add nostdinc and nostdlib for this device libraries
-COMPILE_FLAGS  += $(MODELFLAGS) $(OPT_FLAGS)
-COMPILE_FLAGS  += --nostdinc --nostdlib --fommit-frame-pointer
-
-CFLAGS  += $(CSTD)
-
-CFILES = $(patsubst %,%.c,$(SRCS))
-OFILES = $(patsubst %.c,%.o,$(CFILES))
-
-
-%.o: %.c
-       $(CC) $(CFLAGS) $(COMPILE_FLAGS) -c $<
-
-
-all: build-library
-       @$(CP) -v $(OFILES) ../bin
-
-build-library: compile-sources
-
-compile-sources: $(OFILES)
-
-
-clean:
-       rm -f *.o *.lst *.asm
-
-
-clean-intermediate:
-       $(RM) -f *.lst *.asm *.dump*
-
-dep .depend:
-       rm -f .depend
-       for temp in $(CFILES); do               \
-               $(CPP) $(MM) $(CFLAGS) $$temp > .tmpdepend;     \
-               $(SED) s/.rel/.o/g .tmpdepend >> .depend;       \
-               $(RM) -f .tmpdepend;    \
-       done
-       
-include .depend
+include $(topsrcdir)/Makefile.subdir
index d1214ac0826cac4331a8e707b9c204e30396c6f1..a0b0297c4e7b5e5b8a9feb64a2b2e2b7b4018a1b 100644 (file)
@@ -122,6 +122,8 @@ _?"_asm"         {
 "eeprom"       { count(); TKEYWORDSDCC(EEPROM); }
 "__eeprom"     { count(); TKEYWORD(EEPROM); }
 "float"        { count(); return(FLOAT); }
+"fixed16x16"   { count(); TKEYWORDSDCC(FIXED16X16); }
+"__fixed16x16"   { count(); TKEYWORD(FIXED16X16); }
 "flash"        { count(); TKEYWORDSDCC(CODE); }
 "__flash"      { count(); TKEYWORD(CODE); }
 "for"          { count(); return(FOR); }
index 3e084fcdabb4fa38fc326e721c33bab532d8faf9..17dacb5dcf983d4f9dcac95417b504b1497d0c16 100644 (file)
@@ -90,7 +90,7 @@ bool uselessDecl = TRUE;
 %token TYPEDEF EXTERN STATIC AUTO REGISTER CODE EEPROM INTERRUPT SFR SFR16 SFR32
 %token AT SBIT REENTRANT USING  XDATA DATA IDATA PDATA VAR_ARGS CRITICAL
 %token NONBANKED BANKED SHADOWREGS WPARAM
-%token CHAR SHORT INT LONG SIGNED UNSIGNED FLOAT DOUBLE CONST VOLATILE VOID BIT
+%token CHAR SHORT INT LONG SIGNED UNSIGNED FLOAT DOUBLE FIXED16X16 CONST VOLATILE VOID BIT
 %token STRUCT UNION ENUM ELIPSIS RANGE FAR
 %token CASE DEFAULT IF ELSE SWITCH WHILE DO FOR GOTO CONTINUE BREAK RETURN
 %token NAKED JAVANATIVE OVERLAY
@@ -650,6 +650,11 @@ type_specifier2
               SPEC_NOUN($$) = V_FLOAT;
               ignoreTypedefType = 1;
             }
+   | FIXED16X16  {
+               $$=newLink(SPECIFIER);
+              SPEC_NOUN($$) = V_FIXED16X16;
+              ignoreTypedefType = 1;
+            }
    | XDATA     {
                   $$ = newLink (SPECIFIER);
                   SPEC_SCLS($$) = S_XDATA  ;
index 3cfdde6a9c2754ad7548ec87b4ead54003e04547..990f43fed6a379a1793adb92706b29f2ab02e5b9 100644 (file)
@@ -2098,7 +2098,8 @@ addCast (ast *tree, RESULT_TYPE resultType, bool upcast)
         break;
       case RESULT_TYPE_CHAR:
         if (IS_CHAR (tree->etype) ||
-            IS_FLOAT(tree->etype))
+            IS_FLOAT(tree->etype) ||
+            IS_FIXED(tree->etype))
           return tree;
         newLink = newCharLink();
         break;
@@ -3877,6 +3878,9 @@ decorateType (ast * tree, RESULT_TYPE resultType)
                 case V_FLOAT:
                     typeofv = TYPEOF_FLOAT;
                     break;
+                case V_FIXED16X16:
+                    typeofv = TYPEOF_FIXED16X16;
+                    break;
                 case V_CHAR:
                     typeofv = TYPEOF_CHAR;
                     break;
index 8e68739ec2487a728c631120b6c3dcb3bc686752..c64866f2891e6b71d1ebd0b295214d4b9ec02819 100644 (file)
@@ -818,7 +818,8 @@ algebraicOpts (iCode * ic, eBBlock * ebp)
     case '+':
       /* if adding the same thing change to left shift by 1 */
       if (IC_LEFT (ic)->key == IC_RIGHT (ic)->key &&
-          !IS_FLOAT (operandType (IC_RESULT (ic))))
+          !(IS_FLOAT (operandType (IC_RESULT (ic)))
+            || IS_FIXED(operandType (IC_RESULT (ic)))))
         {
           ic->op = LEFT_OP;
           IC_RIGHT (ic) = operandFromLit (1);
index 258c74486e9779afe96c730ffc03d759a5b6ad19..7a6772126d957a8b63c5bada49570776e1d5d2bd 100644 (file)
@@ -2384,6 +2384,16 @@ dwTagFromType (sym_link * type, dwtag * parent)
                                                    getSize (type)));
                  dwAddTagChild (dwRootTag, tp);
                  break;
+
+               case V_FIXED16X16:
+                 tp = dwNewTag (DW_TAG_base_type);
+                 dwAddTagAttr (tp, dwNewAttrConst (DW_AT_encoding,
+                                                   DW_ATE_float));
+                 dwAddTagAttr (tp, dwNewAttrString (DW_AT_name, "fixed16x16"));
+                 dwAddTagAttr (tp, dwNewAttrConst (DW_AT_byte_size,
+                                                   getSize (type)));
+                 dwAddTagChild (dwRootTag, tp);
+                 break;
                
                case V_CHAR:
                  tp = dwNewTag (DW_TAG_base_type);
index 2e0c1908705f3aa552582081c37b9b096c0413c7..1989aceb36511317d145c21136e453e111e71fc0 100644 (file)
@@ -171,6 +171,11 @@ void checkConstantRange(sym_link *ltype, value *val, char *msg,
     return;
   }
 
+  if (IS_FIXED(ltype)) {
+    // anything will do
+    return;
+  }
+
   if (!IS_UNSIGNED(val->type) && v<0) {
     negative=1;
     if (IS_UNSIGNED(ltype) && (pedantic>1)) {
@@ -225,6 +230,8 @@ printOperand (operand * op, FILE * file)
       opetype = getSpec (operandType (op));
       if (IS_FLOAT (opetype))
        fprintf (file, "%g {", SPEC_CVAL (opetype).v_float);
+      if (IS_FIXED16X16 (opetype))
+        fprintf (file, "%g {", doubleFromFixed16x16(SPEC_CVAL (opetype).v_fixed16x16));
       else
        fprintf (file, "0x%x {", (unsigned) floatFromVal (op->operand.valOperand));
       printTypeChain (operandType (op), file);
@@ -1295,6 +1302,13 @@ operandOperation (operand * left, operand * right,
          retval = operandFromLit (operandLitValue (left) ==
                                   operandLitValue (right));
        }
+      else
+      if (IS_FIXED16X16 (let) ||
+          IS_FIXED16X16 (ret))
+       {
+         retval = operandFromLit (operandLitValue (left) ==
+                                  operandLitValue (right));
+       }
       else
        {
          /* this op doesn't care about signedness */
@@ -2048,6 +2062,8 @@ geniCodeCast (sym_link * type, operand * op, bool implicit)
       !IS_BITFIELD (type) &&
       !IS_FLOAT (type) &&
       !IS_FLOAT (optype) &&
+      !IS_FIXED (type) &&
+      !IS_FIXED (optype) &&
       ((IS_SPEC (type) && IS_SPEC (optype)) ||
        (!IS_SPEC (type) && !IS_SPEC (optype))))
     {
@@ -2135,7 +2151,7 @@ geniCodeMultiply (operand * left, operand * right, RESULT_TYPE resultType)
   /* code generated for 1 byte * 1 byte literal = 2 bytes result is more
      efficient in most cases than 2 bytes result = 2 bytes << literal
      if port has 1 byte muldiv */
-  if (p2 && !IS_FLOAT (letype)
+  if (p2 && !IS_FLOAT (letype) && !IS_FIXED (letype)
       && !((resultType == RESULT_TYPE_INT) && (getSize (resType) != getSize (ltype))
            && (port->support.muldiv == 1))
       && strcmp (port->target, "pic16") != 0  /* don't shift for pic */
@@ -2184,6 +2200,7 @@ geniCodeDivision (operand * left, operand * right, RESULT_TYPE resultType)
      right shift */
   if (IS_LITERAL (retype) &&
       !IS_FLOAT (letype) &&
+      !IS_FIXED (letype) &&
       IS_UNSIGNED(letype) &&
       (p2 = powof2 ((TYPE_UDWORD)
                    floatFromVal (right->operand.valOperand)))) {
@@ -2308,7 +2325,8 @@ geniCodeSubtract (operand * left, operand * right, RESULT_TYPE resultType)
   IC_RESULT (ic)->isaddr = (isarray ? 1 : 0);
 
   /* if left or right is a float */
-  if (IS_FLOAT (ltype) || IS_FLOAT (rtype))
+  if (IS_FLOAT (ltype) || IS_FLOAT (rtype)
+      || IS_FIXED (ltype) || IS_FIXED (rtype))
     ic->supportRtn = 1;
 
   ADDTOCHAIN (ic);
@@ -2378,7 +2396,8 @@ geniCodeAdd (operand * left, operand * right, RESULT_TYPE resultType, int lvl)
 
   /* if left or right is a float then support
      routine */
-  if (IS_FLOAT (ltype) || IS_FLOAT (rtype))
+  if (IS_FLOAT (ltype) || IS_FLOAT (rtype)
+      || IS_FIXED (ltype) || IS_FIXED (rtype))
     ic->supportRtn = 1;
 
   ADDTOCHAIN (ic);
@@ -2580,6 +2599,9 @@ geniCodePostInc (operand * op)
     werror(W_SIZEOF_VOID);
   if (IS_FLOAT (rvtype))
     ic = newiCode ('+', rv, operandFromValue (constFloatVal ("1.0")));
+  else
+  if (IS_FIXED16X16 (rvtype))
+    ic = newiCode ('+', rv, operandFromValue (constFixed16x16Val ("1.0")));
   else
     ic = newiCode ('+', rv, operandFromLit (size));
 
@@ -2618,6 +2640,9 @@ geniCodePreInc (operand * op, bool lvalue)
     werror(W_SIZEOF_VOID);
   if (IS_FLOAT (roptype))
     ic = newiCode ('+', rop, operandFromValue (constFloatVal ("1.0")));
+  else
+  if (IS_FIXED16X16 (roptype))
+    ic = newiCode ('+', rop, operandFromValue (constFixed16x16Val ("1.0")));
   else
     ic = newiCode ('+', rop, operandFromLit (size));
   IC_RESULT (ic) = result = newiTempOperand (roptype, 0);
@@ -2666,6 +2691,9 @@ geniCodePostDec (operand * op)
     werror(W_SIZEOF_VOID);
   if (IS_FLOAT (rvtype))
     ic = newiCode ('-', rv, operandFromValue (constFloatVal ("1.0")));
+  else
+  if (IS_FIXED16X16 (rvtype))
+    ic = newiCode ('-', rv, operandFromValue (constFixed16x16Val ("1.0")));
   else
     ic = newiCode ('-', rv, operandFromLit (size));
 
@@ -2704,6 +2732,9 @@ geniCodePreDec (operand * op, bool lvalue)
     werror(W_SIZEOF_VOID);
   if (IS_FLOAT (roptype))
     ic = newiCode ('-', rop, operandFromValue (constFloatVal ("1.0")));
+  else
+  if (IS_FIXED16X16 (roptype))
+    ic = newiCode ('-', rop, operandFromValue (constFixed16x16Val ("1.0")));
   else
     ic = newiCode ('-', rop, operandFromLit (size));
   IC_RESULT (ic) = result = newiTempOperand (roptype, 0);
@@ -2867,7 +2898,8 @@ geniCodeDerefPtr (operand * op,int lvl)
                IS_STRUCT (rtype) ||
                IS_INT (rtype) ||
                IS_CHAR (rtype) ||
-               IS_FLOAT (rtype));
+               IS_FLOAT (rtype) ||
+               IS_FIXED (rtype));
 
   if (!isLvaluereq(lvl))
     op = geniCodeRValue (op, TRUE);
@@ -3003,6 +3035,10 @@ geniCodeLogic (operand * left, operand * right, int op)
       op != OR_OP)
    ic->supportRtn = 1;
 
+  /* if comparing a fixed type use support functions */
+  if (IS_FIXED(ctype))
+    ic->supportRtn = 1;
+
   ADDTOCHAIN (ic);
   return IC_RESULT (ic);
 }
index 285b356332565b40a8f6d34c7f823f69518d8170..24376b29c05ce49d3f32f0c378513870714bc7e1 100644 (file)
@@ -67,39 +67,77 @@ cnvToFcall (iCode * ic, eBBlock * ebp)
   left = IC_LEFT (ic);
   right = IC_RIGHT (ic);
 
-  switch (ic->op)
-    {
-    case '+':
-      func = __fsadd;
-      break;
-    case '-':
-      func = __fssub;
-      break;
-    case '/':
-      func = __fsdiv;
-      break;
-    case '*':
-      func = __fsmul;
-      break;
-    case EQ_OP:
-      func = __fseq;
-      break;
-    case NE_OP:
-      func = __fsneq;
-      break;
-    case '<':
-      func = __fslt;
-      break;
-    case '>':
-      func = __fsgt;
-      break;
-    case LE_OP:
-      func = __fslteq;
-      break;
-    case GE_OP:
-      func = __fsgteq;
-      break;
-    }
+  if(IS_FLOAT(operandType( IC_RIGHT( ic ) ))) {
+    switch (ic->op)
+      {
+      case '+':
+        func = __fsadd;
+        break;
+      case '-':
+        func = __fssub;
+        break;
+      case '/':
+        func = __fsdiv;
+        break;
+      case '*':
+        func = __fsmul;
+        break;
+      case EQ_OP:
+        func = __fseq;
+        break;
+      case NE_OP:
+        func = __fsneq;
+        break;
+      case '<':
+        func = __fslt;
+        break;
+      case '>':
+        func = __fsgt;
+        break;
+      case LE_OP:
+        func = __fslteq;
+        break;
+      case GE_OP:
+        func = __fsgteq;
+        break;
+      }
+  } else
+  if(IS_FIXED16X16 (operandType (IC_RIGHT(ic)))) {
+    switch (ic->op)
+      {
+      case '+':
+        func = __fps16x16_add;
+        break;
+      case '-':
+        func = __fps16x16_sub;
+        break;
+      case '/':
+        func = __fps16x16_div;
+        break;
+      case '*':
+        func = __fps16x16_mul;
+        break;
+      case EQ_OP:
+        func = __fps16x16_eq;
+        break;
+      case NE_OP:
+        func = __fps16x16_neq;
+        break;
+      case '<':
+        func = __fps16x16_lt;
+        break;
+      case '>':
+        func = __fps16x16_gt;
+        break;
+      case LE_OP:
+        func = __fps16x16_lteq;
+        break;
+      case GE_OP:
+        func = __fps16x16_gteq;
+        break;
+      }
+  }
+  
 
   /* if float support routines NOT compiled as reentrant */
   if (!options.float_rent)
@@ -224,6 +262,104 @@ cnvToFloatCast (iCode * ic, eBBlock * ebp)
            }
        }
     }
+
+  if(compareType (type, fixed16x16Type) == 1) {
+    func = __fp16x16conv[0][3][0];
+    goto found;
+  }
+
+  assert (0);
+found:
+
+  /* if float support routines NOT compiled as reentrant */
+  if (!options.float_rent)
+    {
+      /* first one */
+       if (IS_REGPARM (FUNC_ARGS(func->type)->etype)) 
+           {
+               newic = newiCode (SEND, IC_RIGHT (ic), NULL);
+               newic->argreg = SPEC_ARGREG(FUNC_ARGS(func->type)->etype);
+           }
+      else
+       {
+         newic = newiCode ('=', NULL, IC_RIGHT (ic));
+         IC_RESULT (newic) = operandFromValue (FUNC_ARGS(func->type));
+       }
+      addiCodeToeBBlock (ebp, newic, ip);
+      newic->lineno = linenno;
+
+    }
+  else
+    {
+      /* push the left */
+       if (IS_REGPARM (FUNC_ARGS(func->type)->etype)) {
+           newic = newiCode (SEND, IC_RIGHT (ic), NULL);
+           newic->argreg = SPEC_ARGREG(FUNC_ARGS(func->type)->etype);
+       }
+      else
+       {
+         newic = newiCode (IPUSH, IC_RIGHT (ic), NULL);
+         newic->parmPush = 1;
+         bytesPushed += getSize(operandType(IC_RIGHT(ic)));
+       }
+      addiCodeToeBBlock (ebp, newic, ip);
+      newic->lineno = linenno;
+
+    }
+
+  /* make the call */
+  newic = newiCode (CALL, operandFromSymbol (func), NULL);
+  IC_RESULT (newic) = IC_RESULT (ic);
+  newic->parmBytes+=bytesPushed;
+  ebp->hasFcall = 1;
+  if (currFunc)
+    FUNC_HASFCALL (currFunc->type) = 1;
+
+  if(TARGET_IS_PIC16) {
+       /* normally these functions aren't marked external, so we can use their
+        * _extern field to marked as already added to symbol table */
+
+       if(!SPEC_EXTR(func->etype)) {
+           memmap *seg = SPEC_OCLS(OP_SYMBOL(IC_LEFT(newic))->etype);
+               
+               SPEC_EXTR(func->etype) = 1;
+               seg = SPEC_OCLS( func->etype );
+               addSet(&seg->syms, func);
+       }
+  }
+
+  addiCodeToeBBlock (ebp, newic, ip);
+  newic->lineno = linenno;
+}
+
+/*----------------------------------------------------------------------*/
+/* cnvToFixed16x16Cast - converts casts to fixed16x16 to function calls */
+/*----------------------------------------------------------------------*/
+static void 
+cnvToFixed16x16Cast (iCode * ic, eBBlock * ebp)
+{
+  iCode *ip, *newic;
+  symbol *func = NULL;
+  sym_link *type = operandType (IC_RIGHT (ic));
+  int linenno = ic->lineno;
+  int bwd, su;
+  int bytesPushed=0;
+
+  ip = ic->next;
+  /* remove it from the iCode */
+  remiCodeFromeBBlock (ebp, ic);
+  /* depending on the type */
+  for (bwd = 0; bwd < 3; bwd++)
+    {
+      for (su = 0; su < 2; su++)
+       {
+         if (compareType (type, __multypes[bwd][su]) == 1)
+           {
+             func = __fp16x16conv[0][bwd][su];
+             goto found;
+           }
+       }
+    }
   assert (0);
 found:
 
@@ -381,6 +517,106 @@ found:
   newic->lineno = lineno;
 }
 
+/*--------------------------------------------------------------------------*/
+/* cnvFromFixed16x16Cast - converts casts from fixed16x16 to function calls */
+/*--------------------------------------------------------------------------*/
+static void 
+cnvFromFixed16x16Cast (iCode * ic, eBBlock * ebp)
+{
+  iCode *ip, *newic;
+  symbol *func = NULL;
+  sym_link *type = operandType (IC_LEFT (ic));
+  int lineno = ic->lineno;
+  int bwd, su;
+  int bytesPushed=0;
+
+  ip = ic->next;
+  /* remove it from the iCode */
+  remiCodeFromeBBlock (ebp, ic);
+
+  /* depending on the type */
+  for (bwd = 0; bwd < 3; bwd++)
+    {
+      for (su = 0; su < 2; su++)
+       {
+         if (compareType (type, __multypes[bwd][su]) == 1)
+           {
+             func = __fp16x16conv[1][bwd][su];
+             goto found;
+           }
+       }
+    }
+    
+  if (compareType (type, floatType) == 1)
+    {
+      func = __fp16x16conv[1][3][0];
+      goto found;
+    }
+    
+  assert (0);
+found:
+
+  /* if float support routines NOT compiled as reentrant */
+  if (!options.float_rent)
+    {
+      /* first one */
+       if (IS_REGPARM (FUNC_ARGS(func->type)->etype)) {
+           newic = newiCode (SEND, IC_RIGHT (ic), NULL);
+           newic->argreg = SPEC_ARGREG(FUNC_ARGS(func->type)->etype);
+       }
+      else
+       {
+         newic = newiCode ('=', NULL, IC_RIGHT (ic));
+         IC_RESULT (newic) = operandFromValue (FUNC_ARGS(func->type));
+       }
+      addiCodeToeBBlock (ebp, newic, ip);
+      newic->lineno = lineno;
+
+    }
+  else
+    {
+
+      /* push the left */
+       if (IS_REGPARM (FUNC_ARGS(func->type)->etype)) {
+           newic = newiCode (SEND, IC_RIGHT (ic), NULL);
+           newic->argreg = SPEC_ARGREG(FUNC_ARGS(func->type)->etype);
+       }
+      else
+       {
+         newic = newiCode (IPUSH, IC_RIGHT (ic), NULL);
+         newic->parmPush = 1;
+         bytesPushed += getSize(operandType(IC_RIGHT(ic)));
+       }
+      addiCodeToeBBlock (ebp, newic, ip);
+      newic->lineno = lineno;
+
+    }
+
+  /* make the call */
+  newic = newiCode (CALL, operandFromSymbol (func), NULL);
+  IC_RESULT (newic) = IC_RESULT (ic);
+  newic->parmBytes+=bytesPushed;
+  ebp->hasFcall = 1;
+  if (currFunc)
+    FUNC_HASFCALL (currFunc->type) = 1;
+
+  if(TARGET_IS_PIC16) {
+       /* normally these functions aren't marked external, so we can use their
+        * _extern field to marked as already added to symbol table */
+
+       if(!SPEC_EXTR(func->etype)) {
+           memmap *seg = SPEC_OCLS(OP_SYMBOL(IC_LEFT(newic))->etype);
+               
+               SPEC_EXTR(func->etype) = 1;
+               seg = SPEC_OCLS( func->etype );
+               addSet(&seg->syms, func);
+       }
+  }
+
+  addiCodeToeBBlock (ebp, newic, ip);
+  newic->lineno = lineno;
+}
+
 extern operand *geniCodeRValue (operand *, bool);
 
 /*-----------------------------------------------------------------*/
@@ -541,7 +777,8 @@ convertToFcall (eBBlock ** ebbs, int count)
             converted to function calls */
          if ((IS_CONDITIONAL (ic) ||
               IS_ARITHMETIC_OP (ic)) &&
-             (IS_FLOAT (operandType (IC_RIGHT (ic)))))
+             (IS_FLOAT (operandType (IC_RIGHT (ic)))
+               || IS_FIXED( operandType (IC_RIGHT (ic)))))
            {
 
              cnvToFcall (ic, ebbs[i]);
@@ -554,6 +791,10 @@ convertToFcall (eBBlock ** ebbs, int count)
                cnvFromFloatCast (ic, ebbs[i]);
              else if (IS_FLOAT (operandType (IC_LEFT (ic))))
                cnvToFloatCast (ic, ebbs[i]);
+             if (IS_FIXED16X16 (operandType (IC_RIGHT (ic))))
+               cnvFromFixed16x16Cast (ic, ebbs[i]);
+             else if (IS_FIXED16X16 (operandType (IC_LEFT (ic))))
+               cnvToFixed16x16Cast (ic, ebbs[i]);
            }
 
           // Easy special case which avoids function call: modulo by a literal power
index 91eb064fcfb71ccf79696f64a941cdfd8d4b68b2..3ea2843fcbb3b92dea7bf4033e65bd8f6a8b6e85 100644 (file)
@@ -47,6 +47,7 @@ char *nounName(sym_link *sl) {
       return "int";
     }
     case V_FLOAT: return "float";
+    case V_FIXED16X16: return "fixed16x16";
     case V_CHAR: return "char";
     case V_VOID: return "void";
     case V_STRUCT: return "struct";
@@ -541,6 +542,7 @@ void checkTypeSanity(sym_link *etype, char *name) {
 
   if ((SPEC_NOUN(etype)==V_CHAR || 
        SPEC_NOUN(etype)==V_FLOAT || 
+       SPEC_NOUN(etype)==V_FIXED16X16 ||
        SPEC_NOUN(etype)==V_DOUBLE || 
        SPEC_NOUN(etype)==V_VOID) &&
       (etype->select.s._short || SPEC_LONG(etype))) {
@@ -548,6 +550,7 @@ void checkTypeSanity(sym_link *etype, char *name) {
     werror (E_LONG_OR_SHORT_INVALID, noun, name);
   }
   if ((SPEC_NOUN(etype)==V_FLOAT || 
+       SPEC_NOUN(etype)==V_FIXED16X16 ||
        SPEC_NOUN(etype)==V_DOUBLE || 
        SPEC_NOUN(etype)==V_VOID) && 
       (etype->select.s._signed || SPEC_USIGN(etype))) {
@@ -735,6 +738,20 @@ newFloatLink ()
   return p;
 }
 
+/*------------------------------------------------------------------*/
+/* newFixed16x16Link - a new Float type                                  */
+/*------------------------------------------------------------------*/
+sym_link *
+newFixed16x16Link ()
+{
+  sym_link *p;
+
+  p = newLink (SPECIFIER);
+  SPEC_NOUN (p) = V_FIXED16X16;
+
+  return p;
+}
+
 /*------------------------------------------------------------------*/
 /* newLongLink() - new long type                                    */
 /*------------------------------------------------------------------*/
@@ -781,6 +798,8 @@ getSize (sym_link * p)
           return (IS_LONG (p) ? LONGSIZE : INTSIZE);
         case V_FLOAT:
           return FLOATSIZE;
+        case V_FIXED16X16:
+          return (4);
         case V_CHAR:
           return CHARSIZE;
         case V_VOID:
@@ -871,6 +890,8 @@ bitsForType (sym_link * p)
           return (IS_LONG (p) ? LONGSIZE * 8 : INTSIZE * 8);
         case V_FLOAT:
           return FLOATSIZE * 8;
+        case V_FIXED16X16:
+          return (32);
         case V_CHAR:
           return CHARSIZE * 8;
         case V_VOID:
@@ -1730,6 +1751,15 @@ computeType (sym_link * type1, sym_link * type2,
   /* which ever is greater in size */
   if (IS_FLOAT (etype1) || IS_FLOAT (etype2))
     rType = newFloatLink ();
+  else
+    /* if both are fixed16x16 then result is float */
+  if (IS_FIXED16X16(etype1) && IS_FIXED16X16(etype2))
+    rType = newFixed16x16Link();
+  else
+  if (IS_FIXED16X16(etype1) && IS_FLOAT (etype2))
+    rType = newFloatLink ();
+  if (IS_FLOAT (etype1) && IS_FIXED16X16 (etype2) )
+    rType = newFloatLink ();
   else
     /* if both are bitvars choose the larger one */
   if (IS_BITVAR (etype1) && IS_BITVAR (etype2))
@@ -2804,6 +2834,10 @@ printTypeChain (sym_link * start, FILE * of)
               fprintf (of, "float");
               break;
 
+            case V_FIXED16X16:
+              fprintf (of, "fixed16x16");
+              break;
+
             case V_STRUCT:
               fprintf (of, "struct %s", SPEC_STRUCT (type)->tag);
               break;
@@ -2975,6 +3009,10 @@ printTypeChainRaw (sym_link * start, FILE * of)
               fprintf (of, "float");
               break;
 
+            case V_FIXED16X16:
+              fprintf (of, "fixed16x16");
+              break;
+
             case V_STRUCT:
               fprintf (of, "struct %s", SPEC_STRUCT (type)->tag);
               break;
@@ -3044,16 +3082,30 @@ symbol *__fslteq;
 symbol *__fsgt;
 symbol *__fsgteq;
 
+symbol *__fps16x16_add;
+symbol *__fps16x16_sub;
+symbol *__fps16x16_mul;
+symbol *__fps16x16_div;
+symbol *__fps16x16_eq;
+symbol *__fps16x16_neq;
+symbol *__fps16x16_lt;
+symbol *__fps16x16_lteq;
+symbol *__fps16x16_gt;
+symbol *__fps16x16_gteq;
+
 /* Dims: mul/div/mod, BYTE/WORD/DWORD, SIGNED/UNSIGNED */
 symbol *__muldiv[3][3][2];
 /* Dims: BYTE/WORD/DWORD SIGNED/UNSIGNED */
 sym_link *__multypes[3][2];
 /* Dims: to/from float, BYTE/WORD/DWORD, SIGNED/USIGNED */
 symbol *__conv[2][3][2];
+/* Dims: to/from fixed16x16, BYTE/WORD/DWORD/FLOAT, SIGNED/USIGNED */
+symbol *__fp16x16conv[2][4][2];
 /* Dims: shift left/shift right, BYTE/WORD/DWORD, SIGNED/UNSIGNED */
 symbol *__rlrr[2][3][2];
 
 sym_link *floatType;
+sym_link *fixed16x16Type;
 
 static char *
 _mangleFunctionName(char *in)
@@ -3075,6 +3127,7 @@ _mangleFunctionName(char *in)
 /*                      'i' - int                                  */
 /*                      'l' - long                                 */
 /*                      'f' - float                                */
+/*                      'q' - fixed16x16                           */
 /*                      'v' - void                                 */
 /*                      '*' - pointer - default (GPOINTER)         */
 /* modifiers -          'u' - unsigned                             */
@@ -3118,6 +3171,10 @@ sym_link *typeFromStr (char *s)
             r->class = SPECIFIER;
             SPEC_NOUN(r) = V_FLOAT;
             break;
+        case 'q':
+            r->class = SPECIFIER;
+            SPEC_NOUN(r) = V_FIXED16X16;
+            break;
         case 'v':
             r->class = SPECIFIER;
             SPEC_NOUN(r) = V_VOID;
@@ -3183,7 +3240,11 @@ initCSupport ()
   };
   const char *sbwd[] =
   {
-    "char", "int", "long"
+    "char", "int", "long", "fixed16x16",
+  };
+  const char *fp16x16sbwd[] =
+  {
+    "char", "int", "long", "float",
   };
   const char *ssu[] =
   {
@@ -3202,6 +3263,7 @@ initCSupport ()
   }
 
   floatType = newFloatLink ();
+  fixed16x16Type = newFixed16x16Link ();
 
   for (bwd = 0; bwd < 3; bwd++)
     {
@@ -3236,6 +3298,18 @@ initCSupport ()
   __fsgt = funcOfType ("__fsgt", CHARTYPE, floatType, 2, options.float_rent);
   __fsgteq = funcOfType ("__fsgteq", CHARTYPE, floatType, 2, options.float_rent);
 
+  __fps16x16_add = funcOfType ("__fps16x16_add", fixed16x16Type, fixed16x16Type, 2, options.float_rent);
+  __fps16x16_sub = funcOfType ("__fps16x16_sub", fixed16x16Type, fixed16x16Type, 2, options.float_rent);
+  __fps16x16_mul = funcOfType ("__fps16x16_mul", fixed16x16Type, fixed16x16Type, 2, options.float_rent);
+  __fps16x16_div = funcOfType ("__fps16x16_div", fixed16x16Type, fixed16x16Type, 2, options.float_rent);
+  __fps16x16_eq = funcOfType ("__fps16x16_eq", CHARTYPE, fixed16x16Type, 2, options.float_rent);
+  __fps16x16_neq = funcOfType ("__fps16x16_neq", CHARTYPE, fixed16x16Type, 2, options.float_rent);
+  __fps16x16_lt = funcOfType ("__fps16x16_lt", CHARTYPE, fixed16x16Type, 2, options.float_rent);
+  __fps16x16_lteq = funcOfType ("__fps16x16_lteq", CHARTYPE, fixed16x16Type, 2, options.float_rent);
+  __fps16x16_gt = funcOfType ("__fps16x16_gt", CHARTYPE, fixed16x16Type, 2, options.float_rent);
+  __fps16x16_gteq = funcOfType ("__fps16x16_gteq", CHARTYPE, fixed16x16Type, 2, options.float_rent);
+
+
   for (tofrom = 0; tofrom < 2; tofrom++)
     {
       for (bwd = 0; bwd < 3; bwd++)
@@ -3256,6 +3330,32 @@ initCSupport ()
         }
     }
 
+  for (tofrom = 0; tofrom < 2; tofrom++)
+    {
+      for (bwd = 0; bwd < 4; bwd++)
+        {
+          for (su = 0; su < 2; su++)
+            {
+              if (tofrom)
+                {
+                  SNPRINTF (buffer, sizeof(buffer), "__fps16x162%s%s", ssu[su], fp16x16sbwd[bwd]);
+                  if(bwd == 3) {
+                    __fp16x16conv[tofrom][bwd][su] = funcOfType (buffer, floatType, fixed16x16Type, 1, options.float_rent);
+                  } else
+                    __fp16x16conv[tofrom][bwd][su] = funcOfType (buffer, __multypes[bwd][su], fixed16x16Type, 1, options.float_rent);
+                }
+              else
+                {
+                  SNPRINTF (buffer, sizeof(buffer), "__%s%s2fps16x16", ssu[su], fp16x16sbwd[bwd]);
+                  if(bwd == 3) {
+                    __fp16x16conv[tofrom][bwd][su] = funcOfType (buffer, fixed16x16Type, floatType, 1, options.float_rent);
+                  } else
+                    __fp16x16conv[tofrom][bwd][su] = funcOfType (buffer, fixed16x16Type, __multypes[bwd][su], 1, options.float_rent);
+                }
+            }
+        }
+    }
+
 /*
   for (muldivmod = 0; muldivmod < 3; muldivmod++)
     {
index 4e3340dbe81dd59b997d165ee0b02e0d6fd3ae30..df7e048432760691865f8796ef597990059fcc0f 100644 (file)
@@ -41,6 +41,7 @@ enum {
     TYPEOF_CHAR,
     TYPEOF_LONG,
     TYPEOF_FLOAT,
+    TYPEOF_FIXED16X16,
     TYPEOF_BIT,
     TYPEOF_BITFIELD,
     TYPEOF_SBIT,
@@ -93,6 +94,7 @@ typedef enum
   {
     V_INT = 1,
     V_FLOAT,
+    V_FIXED16X16,
     V_CHAR,
     V_VOID,
     V_STRUCT,
@@ -156,7 +158,8 @@ typedef struct specifier
        TYPE_DWORD  v_long;     /* 4 bytes: long constant value           */
         TYPE_UDWORD v_ulong;    /* 4 bytes: unsigned long constant value  */
        double      v_float;    /*          floating point constant value */
-        struct symbol *v_enum;  /* ptr to enum_list if enum==1            */
+       TYPE_UDWORD v_fixed16x16; /* 4 bytes: fixed floating point constant value */
+       struct symbol *v_enum;  /* ptr 2 enum_list if enum==1 */
       }
     const_val;
     struct structdef *v_struct;        /* structure pointer      */
@@ -467,7 +470,9 @@ extern sym_link *validateLink(sym_link      *l,
 #define IS_BIT(x) (IS_SPEC(x) && (x->select.s.noun  == V_BIT ||   \
                                   x->select.s.noun == V_SBIT ))
 #define IS_FLOAT(x)  (IS_SPEC(x) && x->select.s.noun == V_FLOAT)
-#define IS_ARITHMETIC(x) (IS_INTEGRAL(x) || IS_FLOAT(x))
+#define IS_FIXED16X16(x)  (IS_SPEC(x) && x->select.s.noun == V_FIXED16X16)
+#define IS_FIXED(x) (IS_FIXED16X16(x))
+#define IS_ARITHMETIC(x) (IS_INTEGRAL(x) || IS_FLOAT(x) || IS_FIXED(x))
 #define IS_AGGREGATE(x) (IS_ARRAY(x) || IS_STRUCT(x))
 #define IS_LITERAL(x)   (IS_SPEC(x)  && x->select.s.sclass == S_LITERAL)
 #define IS_CODE(x)      (IS_SPEC(x)  && SPEC_SCLS(x) == S_CODE)
@@ -493,12 +498,25 @@ extern symbol *__fslteq;
 extern symbol *__fsgt;
 extern symbol *__fsgteq;
 
+extern symbol *__fps16x16_add;
+extern symbol *__fps16x16_sub;
+extern symbol *__fps16x16_mul;
+extern symbol *__fps16x16_div;
+extern symbol *__fps16x16_eq;
+extern symbol *__fps16x16_neq;
+extern symbol *__fps16x16_lt;
+extern symbol *__fps16x16_lteq;
+extern symbol *__fps16x16_gt;
+extern symbol *__fps16x16_gteq;
+
 /* Dims: mul/div/mod, BYTE/WORD/DWORD, SIGNED/UNSIGNED */
 extern symbol *__muldiv[3][3][2];
 /* Dims: BYTE/WORD/DWORD SIGNED/UNSIGNED */
 extern sym_link *__multypes[3][2];
 /* Dims: to/from float, BYTE/WORD/DWORD, SIGNED/USIGNED */
 extern symbol *__conv[2][3][2];
+/* Dims: to/from fixed16x16, BYTE/WORD/DWORD/FLOAT, SIGNED/USIGNED */
+extern symbol *__fp16x16conv[2][4][2];
 /* Dims: shift left/shift right, BYTE/WORD/DWORD, SIGNED/UNSIGNED */
 extern symbol *__rlrr[2][3][2];
 
@@ -509,8 +527,8 @@ extern symbol *__rlrr[2][3][2];
 #define LONGTYPE       __multypes[2][0]
 #define ULONGTYPE      __multypes[2][1]
 
-
 extern sym_link *floatType;
+extern sym_link *fixed16x16Type;
 
 #include "SDCCval.h"
 
index 32c7bf74d4f2af67886c93850f24825ed1ab7257..134774f3c6ea2cdb84512db1f68e797be708c7a4 100644 (file)
@@ -22,6 +22,8 @@
    what you give them.   Help stamp out software-hoarding!
 -------------------------------------------------------------------------*/
 
+#include <math.h>
+
 #ifdef _WIN32
 #include <ctype.h>
 #include <windows.h>
@@ -296,6 +298,55 @@ const char *getBuildNumber(void)
   return (SDCC_BUILD_NUMBER);
 }
 
+/*-----------------------------------------------------------------*/
+/* doubleFromFixed16x16 - convert a fixed16x16 to double           */
+/*-----------------------------------------------------------------*/
+double doubleFromFixed16x16(TYPE_UDWORD value)
+{
+#if 0
+  /* This version is incorrect negative values. */
+  double tmp=0, exp=2;
+
+    tmp = (value & 0xffff0000) >> 16;
+    
+    while(value) {
+      value &= 0xffff;
+      if(value & 0x8000)tmp += 1/exp;
+      exp *= 2;
+      value <<= 1;
+    }
+  
+  return (tmp);
+#else
+  return ((double)(value * 1.0) / (double)(1UL << 16));
+#endif
+}
+
+TYPE_UDWORD fixed16x16FromDouble(double value)
+{
+#if 0
+  /* This version is incorrect negative values. */
+  unsigned int tmp=0, pos=16;
+  TYPE_UDWORD res;
+
+    tmp = floor( value );
+    res = tmp << 16;
+    value -= tmp;
+    
+    tmp = 0;
+    while(pos--) {
+      value *= 2;
+      if(value >= 1.0)tmp |= (1 << pos);
+      value -= floor( value );
+    }
+  
+    res |= tmp;
+
+  return (res);
+#else
+  return  (TYPE_UDWORD)(value * (double)(1UL << 16));
+#endif
+}
 
 
 #if defined(HAVE_VSNPRINTF) || defined(HAVE_VSPRINTF)
index d8956d49322aa078b6daed1a9f4f3b7eb00b0eaf..c939868a38534a09c5d277a12c5bb64ccc314d62 100644 (file)
@@ -88,6 +88,12 @@ char *strncatz(char *dest, const char *src, size_t n);
 /* return SDCC build number */
 const char *getBuildNumber(void);
 
+/* convert a fixed16x16 type to double */
+double doubleFromFixed16x16(TYPE_UDWORD value);
+
+/* convert a double type to fixed16x16 */
+TYPE_UDWORD fixed16x16FromDouble(double value);
+
 /* snprintf, by hook or by crook. */
 size_t SDCCsnprintf(char *, size_t, const char *, ...);
 
index f1ec65ce60bf2ff311e9bbc9d9db0ba2c4ea3242..6f7ffaf73db232a8c872db109129e4713f2292ee 100644 (file)
@@ -333,7 +333,7 @@ static value *cheapestVal (value *val) {
   TYPE_DWORD  sval=0;
   TYPE_UDWORD uval=0;
 
-  if (IS_FLOAT(val->type) || IS_CHAR(val->type))
+  if (IS_FLOAT(val->type) || IS_FIXED(val->type) || IS_CHAR(val->type))
     return val;
 
   if (SPEC_LONG(val->type)) {
@@ -384,7 +384,7 @@ static value *cheapestVal (value *val) {
 
 static value *cheapestVal (value *val)
 {
-  if (IS_FLOAT (val->type) || IS_CHAR (val->type))
+  if (IS_FLOAT (val->type) || IS_FIXED (val->type) || IS_CHAR (val->type))
     return val;
 
   /* - signed/unsigned must not be changed.
@@ -461,6 +461,29 @@ constFloatVal (char *s)
   return val;
 }
 
+/*-----------------------------------------------------------------*/
+/* constFixed16x16Val - converts a FIXED16X16 constant to value    */
+/*-----------------------------------------------------------------*/
+value *
+constFixed16x16Val (char *s)
+{
+  value *val = newValue ();
+  double sval;
+
+  if (sscanf (s, "%lf", &sval) != 1)
+    {
+      werror (E_INVALID_FLOAT_CONST, s);
+      return constVal ("0");
+    }
+
+  val->type = val->etype = newLink (SPECIFIER);
+  SPEC_NOUN (val->type) = V_FLOAT;
+  SPEC_SCLS (val->type) = S_LITERAL;
+  SPEC_CVAL (val->type).v_fixed16x16 = fixed16x16FromDouble ( sval );
+  return val;
+}
+
 /*-----------------------------------------------------------------*/
 /* constVal - converts an INTEGER constant into a cheapest value   */
 /*-----------------------------------------------------------------*/
@@ -951,6 +974,9 @@ floatFromVal (value * val)
   if (SPEC_NOUN (val->etype) == V_FLOAT)
     return (double) SPEC_CVAL (val->etype).v_float;
 
+  if (SPEC_NOUN (val->etype) == V_FIXED16X16)
+    return (double) doubleFromFixed16x16( SPEC_CVAL (val->etype).v_fixed16x16 );
+
   if (SPEC_LONG (val->etype))
     {
       if (SPEC_USIGN (val->etype))
@@ -996,6 +1022,8 @@ valUnaryPM (value * val)
   /* depending on type */
   if (SPEC_NOUN (val->etype) == V_FLOAT)
     SPEC_CVAL (val->etype).v_float = -1.0 * SPEC_CVAL (val->etype).v_float;
+  if (SPEC_NOUN (val->etype) == V_FIXED16X16)
+    SPEC_CVAL (val->etype).v_fixed16x16 = -SPEC_CVAL (val->etype).v_fixed16x16;
   else
     {
       if (SPEC_LONG (val->etype))
@@ -1096,6 +1124,9 @@ valMult (value * lval, value * rval)
 
   if (IS_FLOAT (val->type))
     SPEC_CVAL (val->type).v_float = floatFromVal (lval) * floatFromVal (rval);
+  else
+  if (IS_FIXED16X16 (val->type))
+    SPEC_CVAL (val->type).v_fixed16x16 = fixed16x16FromDouble(floatFromVal (lval) * floatFromVal (rval));
       /* signed and unsigned mul are the same, as long as the precision of the
          result isn't bigger than the precision of the operands. */
   else if (SPEC_LONG (val->type))
@@ -1146,6 +1177,9 @@ valDiv (value * lval, value * rval)
 
   if (IS_FLOAT (val->type))
     SPEC_CVAL (val->type).v_float = floatFromVal (lval) / floatFromVal (rval);
+  else
+  if (IS_FIXED16X16 (val->type))
+    SPEC_CVAL (val->type).v_fixed16x16 = fixed16x16FromDouble( floatFromVal (lval) / floatFromVal (rval) );
   else if (SPEC_LONG (val->type))
     {
       if (SPEC_USIGN (val->type))
@@ -1222,6 +1256,9 @@ valPlus (value * lval, value * rval)
   
   if (IS_FLOAT (val->type))
     SPEC_CVAL (val->type).v_float = floatFromVal (lval) + floatFromVal (rval);
+  else
+  if (IS_FIXED16X16 (val->type))
+    SPEC_CVAL (val->type).v_fixed16x16 = fixed16x16FromDouble( floatFromVal (lval) + floatFromVal (rval) );
   else  if (SPEC_LONG (val->type))
     {
       if (SPEC_USIGN (val->type))
@@ -1261,6 +1298,9 @@ valMinus (value * lval, value * rval)
   
   if (IS_FLOAT (val->type))
     SPEC_CVAL (val->type).v_float = floatFromVal (lval) - floatFromVal (rval);
+  else
+  if (IS_FIXED16X16 (val->type))
+    SPEC_CVAL (val->type).v_fixed16x16 = fixed16x16FromDouble( floatFromVal (lval) - floatFromVal (rval) );
   else  if (SPEC_LONG (val->type))
     {
       if (SPEC_USIGN (val->type))
@@ -1380,6 +1420,12 @@ valCompare (value * lval, value * rval, int ctype)
        {
          SPEC_CVAL (val->type).v_int = floatFromVal (lval) == floatFromVal (rval);
        }
+      else
+      if (SPEC_NOUN(lval->type) == V_FIXED16X16 ||
+         SPEC_NOUN(rval->type) == V_FIXED16X16)
+       {
+         SPEC_CVAL (val->type).v_int = floatFromVal (lval) == floatFromVal (rval);
+       }
       else
        {
          /* integrals: ignore signedness */
@@ -1407,6 +1453,12 @@ valCompare (value * lval, value * rval, int ctype)
        {
          SPEC_CVAL (val->type).v_int = floatFromVal (lval) != floatFromVal (rval);
        }
+      else
+      if (SPEC_NOUN(lval->type) == V_FIXED16X16 ||
+         SPEC_NOUN(rval->type) == V_FIXED16X16)
+       {
+         SPEC_CVAL (val->type).v_int = floatFromVal (lval) != floatFromVal (rval);
+       }
       else
        {
          /* integrals: ignore signedness */
@@ -1578,6 +1630,8 @@ valCastLiteral (sym_link * dtype, double fval)
 
   if (SPEC_NOUN (val->etype) == V_FLOAT)
       SPEC_CVAL (val->etype).v_float = fval;
+  else if (SPEC_NOUN (val->etype) == V_FIXED16X16)
+      SPEC_CVAL (val->etype).v_fixed16x16 = fixed16x16FromDouble( fval );
   else if (SPEC_NOUN (val->etype) == V_BIT ||
            SPEC_NOUN (val->etype) == V_SBIT)
     SPEC_CVAL (val->etype).v_uint = l ? 1 : 0;
index 363b5e459ea6e4c7fbe0169caf17320820439a2f..906bc7e5b603d198ff94c1d72b2b6cf5007c787e 100644 (file)
@@ -109,6 +109,7 @@ struct ast *list2expr (initList *);
 void resolveIvalSym (initList *, sym_link *);
 value *valFromType (sym_link *);
 value *constFloatVal (char *);
+value *constFixed16x16Val (char *);
 int getNelements (sym_link *, initList *);
 value *valForArray (struct ast *);
 value *valForStructElem (struct ast *, struct ast *);
index a7115d6f4262c0f687ac2ffbfae13c980029edd3..52532248fe88df3c0bf6aba7248a2e055c5a712a 100644 (file)
@@ -843,6 +843,7 @@ yylex (void)
       ENTRY (SIGNED);
       ENTRY (UNSIGNED);
       ENTRY (FLOAT);
+      ENTRY (FIXED16X16);
       ENTRY (DOUBLE);
       ENTRY (CONST);
       ENTRY (VOLATILE);
@@ -1042,6 +1043,7 @@ altlex_runtests (void)
   TEST (altlex_testparse ("enum") == ENUM);
   TEST (altlex_testparse ("extern") == EXTERN);
   TEST (altlex_testparse ("float") == FLOAT);
+  TEST (altlex_testparse ("fixed16x16") == FIXED16X16);
   TEST (altlex_testparse ("for") == FOR);
   TEST (altlex_testparse ("goto") == GOTO);
   TEST (altlex_testparse ("if") == IF);
index 1e8e277bde8380d4182156cf46acf5bd9a427cc6..3f7906a9a1c4555f63ec2ed6556adb670d440ed6 100644 (file)
@@ -439,6 +439,7 @@ void cdbTypeInfo (sym_link * type)
            case V_CHAR: fprintf (cdbFilePtr, "SC"); break;
            case V_VOID: fprintf (cdbFilePtr, "SV"); break;
            case V_FLOAT: fprintf (cdbFilePtr, "SF"); break;
+           case V_FIXED16X16: fprintf(cdbFilePtr, "SQ"); break;
            case V_STRUCT: 
              fprintf (cdbFilePtr, "ST%s", SPEC_STRUCT (type)->tag); 
              break;
index 570188af1303f578b0dbfa6be7505939c870f9d2..d1097d202bfe60df72ec25149d3738c523de99e6 100644 (file)
@@ -2830,10 +2830,14 @@ static void genUminus (iCode *ic)
     optype = operandType(IC_LEFT(ic));
     rtype = operandType(IC_RESULT(ic));
 
+
     /* if float then do float stuff */
-    if (IS_FLOAT(optype)) {
-      genUminusFloat(IC_LEFT(ic),IC_RESULT(ic));
-      goto release;
+    if (IS_FLOAT(optype) || IS_FIXED(optype)) {
+      if(IS_FIXED(optype))
+        debugf("implement fixed16x16 type\n", 0);
+       
+       genUminusFloat(IC_LEFT(ic),IC_RESULT(ic));
+       goto release;
     }
 
     /* otherwise subtract from zero by taking the 2's complement */
@@ -12351,17 +12355,22 @@ static void genAssign (iCode *ic)
   offset = 0 ;
 
   if(AOP_TYPE(right) == AOP_LIT) {
-       if(!IS_FLOAT(operandType( right )))
+       if(!(IS_FLOAT(operandType( right )) || IS_FIXED(operandType(right))))
                lit = (unsigned long)floatFromVal(AOP(right)->aopu.aop_lit);
-       else {
+       else{
           union {
              unsigned long lit_int;
              float lit_float;
            } info;
        
+
+             if(IS_FIXED16X16(operandType(right))) {
+               lit = (unsigned long)fixed16x16FromDouble( floatFromVal( AOP(right)->aopu.aop_lit));
+              } else {
                /* take care if literal is a float */
                info.lit_float = floatFromVal(AOP(right)->aopu.aop_lit);
                lit = info.lit_int;
+              }
        }
   }
 
index 7e1d1b762de80a2aaa61c0d7d5327a577230146d..5c78ee677ef11ff56e2b99e5db6c39d42df71e1f 100644 (file)
@@ -95,12 +95,18 @@ int pic16aopLiteral (value *val, int offset)
 
   /* if it is a float then it gets tricky */
   /* otherwise it is fairly simple */
-  if (!IS_FLOAT(val->type)) {
+  if (!(IS_FLOAT(val->type) || IS_FIXED(val->type))) {
     unsigned long v = (unsigned long) floatFromVal(val);
 
     return ( (v >> (offset * 8)) & 0xff);
   }
 
+  if(IS_FIXED16X16(val->type)) {
+    unsigned long v = (unsigned long)fixed16x16FromDouble( floatFromVal( val ) );
+    
+    return ( (v >> (offset * 8)) & 0xff);
+  }
+
   /* it is type float */
   fl.f = (float) floatFromVal(val);
 #ifdef WORDS_BIGENDIAN
index e57c29993f7c91070c553a93fe65524b77a1f83d..4eb914b6369877b60d7b3e94db321afa5fb24747 100644 (file)
@@ -62,6 +62,7 @@ static char *_pic16_keywords[] =
   "_naked",
   "shadowregs",
   "wparam",
+  "fixed16x16",
   
 //  "bit",
 //  "idata",