Selaa lähdekoodia

Import pstarter.

git-svn-id: file:///var/svn/tigccpp/trunk@484 9552661e-59e3-4036-b4f2-dbe53926924f
kevinkofler 18 vuotta sitten
vanhempi
commit
3642799dba

+ 504 - 0
tigcc/pstarter/LGPL.txt

@@ -0,0 +1,504 @@
+      GNU LESSER GENERAL PUBLIC LICENSE
+           Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 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.
+
+[This is the first released version of the Lesser GPL.  It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+          Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+  This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it.  You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+  When we speak of free software, we are referring to freedom of use,
+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 and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+  To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights.  These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+  For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you.  You must make sure that they, too, receive or can get the source
+code.  If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it.  And you must show them these terms so they know their rights.
+
+  We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+  To protect each distributor, we want to make it very clear that
+there is no warranty for the free library.  Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+  Finally, software patents pose a constant threat to the existence of
+any free program.  We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder.  Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+  Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License.  This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License.  We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+  When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library.  The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom.  The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+  We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License.  It also provides other free software developers Less
+of an advantage over competing non-free programs.  These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries.  However, the Lesser license provides advantages in certain
+special circumstances.
+
+  For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard.  To achieve this, non-free programs must be
+allowed to use the library.  A more frequent case is that a free
+library does the same job as widely used non-free libraries.  In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+  In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software.  For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+  Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.  Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library".  The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+      GNU LESSER GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+  A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+  The "Library", below, refers to any such software library or work
+which has been distributed under these terms.  A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language.  (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+  "Source code" for a work means the preferred form of the work for
+making modifications to it.  For a library, 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 library.
+
+  Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it).  Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+  
+  1. You may copy and distribute verbatim copies of the Library's
+complete 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 distribute a copy of this License along with the
+Library.
+
+  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 Library or any portion
+of it, thus forming a work based on the Library, 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) The modified work must itself be a software library.
+
+    b) You must cause the files modified to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    c) You must cause the whole of the work to be licensed at no
+    charge to all third parties under the terms of this License.
+
+    d) If a facility in the modified Library refers to a function or a
+    table of data to be supplied by an application program that uses
+    the facility, other than as an argument passed when the facility
+    is invoked, then you must make a good faith effort to ensure that,
+    in the event an application does not supply such function or
+    table, the facility still operates, and performs whatever part of
+    its purpose remains meaningful.
+
+    (For example, a function in a library to compute square roots has
+    a purpose that is entirely well-defined independent of the
+    application.  Therefore, Subsection 2d requires that any
+    application-supplied function or table used by this function must
+    be optional: if the application does not supply it, the square
+    root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Library,
+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 Library, 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 Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library.  To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License.  (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.)  Do not make any other change in
+these notices.
+
+  Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+  This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+  4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you 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.
+
+  If distribution of 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 satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library".  Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+  However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library".  The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+  When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library.  The
+threshold for this to be true is not precisely defined by law.
+
+  If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work.  (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+  Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+  6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+  You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License.  You must supply a copy of this License.  If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License.  Also, you must do one
+of these things:
+
+    a) Accompany the work with the complete corresponding
+    machine-readable source code for the Library including whatever
+    changes were used in the work (which must be distributed under
+    Sections 1 and 2 above); and, if the work is an executable linked
+    with the Library, with the complete machine-readable "work that
+    uses the Library", as object code and/or source code, so that the
+    user can modify the Library and then relink to produce a modified
+    executable containing the modified Library.  (It is understood
+    that the user who changes the contents of definitions files in the
+    Library will not necessarily be able to recompile the application
+    to use the modified definitions.)
+
+    b) Use a suitable shared library mechanism for linking with the
+    Library.  A suitable mechanism is one that (1) uses at run time a
+    copy of the library already present on the user's computer system,
+    rather than copying library functions into the executable, and (2)
+    will operate properly with a modified version of the library, if
+    the user installs one, as long as the modified version is
+    interface-compatible with the version that the work was made with.
+
+    c) Accompany the work with a written offer, valid for at
+    least three years, to give the same user the materials
+    specified in Subsection 6a, above, for a charge no more
+    than the cost of performing this distribution.
+
+    d) If distribution of the work is made by offering access to copy
+    from a designated place, offer equivalent access to copy the above
+    specified materials from the same place.
+
+    e) Verify that the user has already received a copy of these
+    materials or that you have already sent this user a copy.
+
+  For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it.  However, as a special exception,
+the materials to be 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.
+
+  It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system.  Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+  7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+    a) Accompany the combined library with a copy of the same work
+    based on the Library, uncombined with any other library
+    facilities.  This must be distributed under the terms of the
+    Sections above.
+
+    b) Give prominent notice with the combined library of the fact
+    that part of it is a work based on the Library, and explaining
+    where to find the accompanying uncombined form of the same work.
+
+  8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License.  Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library 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.
+
+  9. 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 Library or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+  10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+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 with
+this License.
+
+  11. 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 Library at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Library 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 Library.
+
+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.
+
+  12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library 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.
+
+  13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser 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 Library
+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 Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+  14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+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
+
+  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "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
+LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. 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 LIBRARY 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
+LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+         END OF TERMS AND CONDITIONS
+
+           How to Apply These Terms to Your New Libraries
+
+  If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change.  You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+  To apply these terms, attach the following notices to the library.  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 library's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 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
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; 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.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the
+  library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+  <signature of Ty Coon>, 1 April 1990
+  Ty Coon, President of Vice
+
+That's all there is to it!
+
+

+ 224 - 0
tigcc/pstarter/lzma/CPL.html

@@ -0,0 +1,224 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<HTML><HEAD><TITLE>Common Public License - v 1.0</TITLE>
+<META http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
+<BODY vLink=#800000 bgColor=#ffffff>
+<P align=center><B>Common Public License - v 1.0</B> 
+<P><B></B><FONT size=3></FONT>
+<P><FONT size=3></FONT><FONT size=2>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER 
+THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR 
+DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS 
+AGREEMENT.</FONT> 
+<P><FONT size=2></FONT>
+<P><FONT size=2><B>1. DEFINITIONS</B></FONT> 
+<P><FONT size=2>"Contribution" means:</FONT> 
+<UL><FONT size=2>a) in the case of the initial Contributor, the initial code 
+  and documentation distributed under this Agreement, and<BR clear=left>b) in 
+  the case of each subsequent Contributor:</FONT></UL>
+<UL><FONT size=2>i) changes to the Program, and</FONT></UL>
+<UL><FONT size=2>ii) additions to the Program;</FONT></UL>
+<UL><FONT size=2>where such changes and/or additions to the Program originate 
+  from and are distributed by that particular Contributor. </FONT><FONT size=2>A 
+  Contribution 'originates' from a Contributor if it was added to the Program by 
+  such Contributor itself or anyone acting on such Contributor's behalf. 
+  </FONT><FONT size=2>Contributions do not include additions to the Program 
+  which: (i) are separate modules of software distributed in conjunction with 
+  the Program under their own license agreement, and (ii) are not derivative 
+  works of the Program. </FONT></UL>
+<P><FONT size=2></FONT>
+<P><FONT size=2>"Contributor" means any person or entity that distributes the 
+Program.</FONT> 
+<P><FONT size=2></FONT><FONT size=2></FONT>
+<P><FONT size=2>"Licensed Patents " mean patent claims licensable by a 
+Contributor which are necessarily infringed by the use or sale of its 
+Contribution alone or when combined with the Program. </FONT>
+<P><FONT size=2></FONT><FONT size=2></FONT>
+<P><FONT size=2></FONT><FONT size=2>"Program" means the Contributions 
+distributed in accordance with this Agreement.</FONT> 
+<P><FONT size=2></FONT>
+<P><FONT size=2>"Recipient" means anyone who receives the Program under this 
+Agreement, including all Contributors.</FONT> 
+<P><FONT size=2><B></B></FONT>
+<P><FONT size=2><B>2. GRANT OF RIGHTS</B></FONT> 
+<UL><FONT size=2></FONT><FONT size=2>a) </FONT><FONT size=2>Subject to the 
+  terms of this Agreement, each Contributor hereby grants</FONT><FONT size=2> 
+  Recipient a non-exclusive, worldwide, royalty-free copyright license 
+  to</FONT><FONT color=#ff0000 size=2> </FONT><FONT size=2>reproduce, prepare 
+  derivative works of, publicly display, publicly perform, distribute and 
+  sublicense the Contribution of such Contributor, if any, and such derivative 
+  works, in source code and object code form.</FONT></UL>
+<UL><FONT size=2></FONT></UL>
+<UL><FONT size=2></FONT><FONT size=2>b) Subject to the terms of this 
+  Agreement, each Contributor hereby grants </FONT><FONT size=2>Recipient a 
+  non-exclusive, worldwide,</FONT><FONT color=#008000 size=2> </FONT><FONT 
+  size=2>royalty-free patent license under Licensed Patents to make, use, sell, 
+  offer to sell, import and otherwise transfer the Contribution of such 
+  Contributor, if any, in source code and object code form. This patent license 
+  shall apply to the combination of the Contribution and the Program if, at the 
+  time the Contribution is added by the Contributor, such addition of the 
+  Contribution causes such combination to be covered by the Licensed Patents. 
+  The patent license shall not apply to any other combinations which include the 
+  Contribution. No hardware per se is licensed hereunder. </FONT></UL>
+<UL><FONT size=2></FONT></UL>
+<UL><FONT size=2>c) Recipient understands that although each Contributor 
+  grants the licenses to its Contributions set forth herein, no assurances are 
+  provided by any Contributor that the Program does not infringe the patent or 
+  other intellectual property rights of any other entity. Each Contributor 
+  disclaims any liability to Recipient for claims brought by any other entity 
+  based on infringement of intellectual property rights or otherwise. As a 
+  condition to exercising the rights and licenses granted hereunder, each 
+  Recipient hereby assumes sole responsibility to secure any other intellectual 
+  property rights needed, if any. For example, if a third party patent license 
+  is required to allow Recipient to distribute the Program, it is Recipient's 
+  responsibility to acquire that license before distributing the 
+Program.</FONT></UL>
+<UL><FONT size=2></FONT></UL>
+<UL><FONT size=2>d) Each Contributor represents that to its knowledge it has 
+  sufficient copyright rights in its Contribution, if any, to grant the 
+  copyright license set forth in this Agreement. </FONT></UL>
+<UL><FONT size=2></FONT></UL>
+<P><FONT size=2><B>3. REQUIREMENTS</B></FONT> 
+<P><FONT size=2><B></B>A Contributor may choose to distribute the Program in 
+object code form under its own license agreement, provided that:</FONT> 
+<UL><FONT size=2>a) it complies with the terms and conditions of this 
+  Agreement; and</FONT></UL>
+<UL><FONT size=2>b) its license agreement:</FONT></UL>
+<UL><FONT size=2>i) effectively disclaims</FONT><FONT size=2> on behalf of all 
+  Contributors all warranties and conditions, express and implied, including 
+  warranties or conditions of title and non-infringement, and implied warranties 
+  or conditions of merchantability and fitness for a particular purpose; 
+</FONT></UL>
+<UL><FONT size=2>ii) effectively excludes on behalf of all Contributors all 
+  liability for damages, including direct, indirect, special, incidental and 
+  consequential damages, such as lost profits; </FONT></UL>
+<UL><FONT size=2>iii)</FONT><FONT size=2> states that any provisions which 
+  differ from this Agreement are offered by that Contributor alone and not by 
+  any other party; and</FONT></UL>
+<UL><FONT size=2>iv) states that source code for the Program is available from 
+  such Contributor, and informs licensees how to obtain it in a reasonable 
+  manner on or through a medium customarily used for software 
+  exchange.</FONT><FONT color=#0000ff size=2> </FONT><FONT color=#ff0000 
+  size=2></FONT></UL>
+<UL><FONT color=#ff0000 size=2></FONT><FONT size=2></FONT></UL>
+<P><FONT size=2>When the Program is made available in source code form:</FONT> 
+<UL><FONT size=2>a) it must be made available under this Agreement; and 
+</FONT></UL>
+<UL><FONT size=2>b) a copy of this Agreement must be included with each copy 
+  of the Program. </FONT></UL>
+<P><FONT size=2></FONT><FONT color=#0000ff size=2><STRIKE></STRIKE></FONT>
+<P><FONT color=#0000ff size=2><STRIKE></STRIKE></FONT><FONT size=2>Contributors 
+may not remove or alter any copyright notices contained within the Program. 
+</FONT>
+<P><FONT size=2></FONT>
+<P><FONT size=2>Each Contributor must identify itself as the originator of its 
+Contribution, if any, in a manner that reasonably allows subsequent Recipients 
+to identify the originator of the Contribution. </FONT>
+<P><FONT size=2></FONT>
+<P><FONT size=2><B>4. COMMERCIAL DISTRIBUTION</B></FONT> 
+<P><FONT size=2>Commercial distributors of software may accept certain 
+responsibilities with respect to end users, business partners and the like. 
+While this license is intended to facilitate the commercial use of the Program, 
+the Contributor who includes the Program in a commercial product offering should 
+do so in a manner which does not create potential liability for other 
+Contributors. Therefore, if a Contributor includes the Program in a commercial 
+product offering, such Contributor ("Commercial Contributor") hereby agrees to 
+defend and indemnify every other Contributor ("Indemnified Contributor") against 
+any losses, damages and costs (collectively "Losses") arising from claims, 
+lawsuits and other legal actions brought by a third party against the 
+Indemnified Contributor to the extent caused by the acts or omissions of such 
+Commercial Contributor in connection with its distribution of the Program in a 
+commercial product offering. The obligations in this section do not apply to any 
+claims or Losses relating to any actual or alleged intellectual property 
+infringement. In order to qualify, an Indemnified Contributor must: a) promptly 
+notify the Commercial Contributor in writing of such claim, and b) allow the 
+Commercial Contributor to control, and cooperate with the Commercial Contributor 
+in, the defense and any related settlement negotiations. The Indemnified 
+Contributor may participate in any such claim at its own expense.</FONT> 
+<P><FONT size=2></FONT>
+<P><FONT size=2>For example, a Contributor might include the Program in a 
+commercial product offering, Product X. That Contributor is then a Commercial 
+Contributor. If that Commercial Contributor then makes performance claims, or 
+offers warranties related to Product X, those performance claims and warranties 
+are such Commercial Contributor's responsibility alone. Under this section, the 
+Commercial Contributor would have to defend claims against the other 
+Contributors related to those performance claims and warranties, and if a court 
+requires any other Contributor to pay any damages as a result, the Commercial 
+Contributor must pay those damages.</FONT> 
+<P><FONT size=2></FONT><FONT color=#0000ff size=2></FONT>
+<P><FONT color=#0000ff size=2></FONT><FONT size=2><B>5. NO WARRANTY</B></FONT> 
+<P><FONT size=2>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS 
+PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
+EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR 
+CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A 
+PARTICULAR PURPOSE. Each Recipient is</FONT><FONT size=2> solely responsible for 
+determining the appropriateness of using and distributing </FONT><FONT 
+size=2>the Program</FONT><FONT size=2> and assumes all risks associated with its 
+exercise of rights under this Agreement</FONT><FONT size=2>, including but not 
+limited to the risks and costs of program errors, compliance with applicable 
+laws, damage to or loss of data, </FONT><FONT size=2>programs or equipment, and 
+unavailability or interruption of operations</FONT><FONT size=2>. </FONT><FONT 
+size=2></FONT>
+<P><FONT size=2></FONT>
+<P><FONT size=2></FONT><FONT size=2><B>6. DISCLAIMER OF LIABILITY</B></FONT> 
+<P><FONT size=2></FONT><FONT size=2>EXCEPT AS EXPRESSLY SET FORTH IN THIS 
+AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR 
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
+</FONT><FONT size=2>(INCLUDING WITHOUT LIMITATION LOST PROFITS),</FONT><FONT 
+size=2> HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS 
+GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.</FONT> 
+<P><FONT size=2></FONT><FONT size=2></FONT>
+<P><FONT size=2><B>7. GENERAL</B></FONT> 
+<P><FONT size=2></FONT><FONT size=2>If any provision of this Agreement is 
+invalid or unenforceable under applicable law, it shall not affect the validity 
+or enforceability of the remainder of the terms of this Agreement, and without 
+further action by the parties hereto, such provision shall be reformed to the 
+minimum extent necessary to make such provision valid and enforceable.</FONT> 
+<P><FONT size=2></FONT>
+<P><FONT size=2>If Recipient institutes patent litigation against a Contributor 
+with respect to a patent applicable to software (including a cross-claim or 
+counterclaim in a lawsuit), then any patent licenses granted by that Contributor 
+to such Recipient under this Agreement shall terminate as of the date such 
+litigation is filed. In addition, if Recipient institutes patent litigation 
+against any entity (including a cross-claim or counterclaim in a lawsuit) 
+alleging that the Program itself (excluding combinations of the Program with 
+other software or hardware) infringes such Recipient's patent(s), then such 
+Recipient's rights granted under Section 2(b) shall terminate as of the date 
+such litigation is filed. </FONT><FONT size=2></FONT>
+<P><FONT size=2></FONT>
+<P><FONT size=2>All Recipient's rights under this Agreement shall terminate if 
+it fails to comply with any of the material terms or conditions of this 
+Agreement and does not cure such failure in a reasonable period of time after 
+becoming aware of such noncompliance. If all Recipient's rights under this 
+Agreement terminate, Recipient agrees to cease use and distribution of the 
+Program as soon as reasonably practicable. However, Recipient's obligations 
+under this Agreement and any licenses granted by Recipient relating to the 
+Program shall continue and survive. </FONT><FONT size=2></FONT>
+<P><FONT size=2></FONT>
+<P><FONT size=2></FONT><FONT size=2>Everyone is permitted to copy and distribute 
+copies of this Agreement, but in order to avoid inconsistency the Agreement is 
+copyrighted and may only be modified in the following manner. The Agreement 
+Steward reserves the right to </FONT><FONT size=2>publish new versions 
+(including revisions) of this Agreement from time to </FONT><FONT size=2>time. 
+No one other than the Agreement Steward has the right to modify this Agreement. 
+IBM is the initial Agreement Steward. IBM may assign the responsibility to serve 
+as the Agreement Steward to a suitable separate entity. </FONT><FONT size=2>Each 
+new version of the Agreement will be given a distinguishing version number. The 
+Program (including Contributions) may always be distributed subject to the 
+version of the Agreement under which it was received. In addition, after a new 
+version of the Agreement is published, Contributor may elect to distribute the 
+Program (including its Contributions) under the new </FONT><FONT size=2>version. 
+</FONT><FONT size=2>Except as expressly stated in Sections 2(a) and 2(b) above, 
+Recipient receives no rights or licenses to the intellectual property of any 
+Contributor under this Agreement, whether expressly, </FONT><FONT size=2>by 
+implication, estoppel or otherwise</FONT><FONT size=2>.</FONT><FONT size=2> All 
+rights in the Program not expressly granted under this Agreement are 
+reserved.</FONT> 
+<P><FONT size=2></FONT>
+<P><FONT size=2>This Agreement is governed by the laws of the State of New York 
+and the intellectual property laws of the United States of America. No party to 
+this Agreement will bring a legal action under this Agreement more than one year 
+after the cause of action arose. Each party waives its rights to a jury trial in 
+any resulting litigation.</FONT> 
+<P><FONT size=2></FONT><FONT size=2></FONT>
+<P><FONT size=2></FONT></P></BODY></HTML>

+ 504 - 0
tigcc/pstarter/lzma/LGPL.txt

@@ -0,0 +1,504 @@
+      GNU LESSER GENERAL PUBLIC LICENSE
+           Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 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.
+
+[This is the first released version of the Lesser GPL.  It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+          Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+  This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it.  You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+  When we speak of free software, we are referring to freedom of use,
+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 and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+  To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights.  These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+  For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you.  You must make sure that they, too, receive or can get the source
+code.  If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it.  And you must show them these terms so they know their rights.
+
+  We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+  To protect each distributor, we want to make it very clear that
+there is no warranty for the free library.  Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+  Finally, software patents pose a constant threat to the existence of
+any free program.  We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder.  Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+  Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License.  This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License.  We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+  When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library.  The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom.  The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+  We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License.  It also provides other free software developers Less
+of an advantage over competing non-free programs.  These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries.  However, the Lesser license provides advantages in certain
+special circumstances.
+
+  For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard.  To achieve this, non-free programs must be
+allowed to use the library.  A more frequent case is that a free
+library does the same job as widely used non-free libraries.  In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+  In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software.  For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+  Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.  Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library".  The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+      GNU LESSER GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+  A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+  The "Library", below, refers to any such software library or work
+which has been distributed under these terms.  A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language.  (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+  "Source code" for a work means the preferred form of the work for
+making modifications to it.  For a library, 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 library.
+
+  Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it).  Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+  
+  1. You may copy and distribute verbatim copies of the Library's
+complete 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 distribute a copy of this License along with the
+Library.
+
+  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 Library or any portion
+of it, thus forming a work based on the Library, 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) The modified work must itself be a software library.
+
+    b) You must cause the files modified to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    c) You must cause the whole of the work to be licensed at no
+    charge to all third parties under the terms of this License.
+
+    d) If a facility in the modified Library refers to a function or a
+    table of data to be supplied by an application program that uses
+    the facility, other than as an argument passed when the facility
+    is invoked, then you must make a good faith effort to ensure that,
+    in the event an application does not supply such function or
+    table, the facility still operates, and performs whatever part of
+    its purpose remains meaningful.
+
+    (For example, a function in a library to compute square roots has
+    a purpose that is entirely well-defined independent of the
+    application.  Therefore, Subsection 2d requires that any
+    application-supplied function or table used by this function must
+    be optional: if the application does not supply it, the square
+    root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Library,
+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 Library, 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 Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library.  To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License.  (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.)  Do not make any other change in
+these notices.
+
+  Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+  This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+  4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you 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.
+
+  If distribution of 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 satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library".  Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+  However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library".  The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+  When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library.  The
+threshold for this to be true is not precisely defined by law.
+
+  If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work.  (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+  Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+  6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+  You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License.  You must supply a copy of this License.  If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License.  Also, you must do one
+of these things:
+
+    a) Accompany the work with the complete corresponding
+    machine-readable source code for the Library including whatever
+    changes were used in the work (which must be distributed under
+    Sections 1 and 2 above); and, if the work is an executable linked
+    with the Library, with the complete machine-readable "work that
+    uses the Library", as object code and/or source code, so that the
+    user can modify the Library and then relink to produce a modified
+    executable containing the modified Library.  (It is understood
+    that the user who changes the contents of definitions files in the
+    Library will not necessarily be able to recompile the application
+    to use the modified definitions.)
+
+    b) Use a suitable shared library mechanism for linking with the
+    Library.  A suitable mechanism is one that (1) uses at run time a
+    copy of the library already present on the user's computer system,
+    rather than copying library functions into the executable, and (2)
+    will operate properly with a modified version of the library, if
+    the user installs one, as long as the modified version is
+    interface-compatible with the version that the work was made with.
+
+    c) Accompany the work with a written offer, valid for at
+    least three years, to give the same user the materials
+    specified in Subsection 6a, above, for a charge no more
+    than the cost of performing this distribution.
+
+    d) If distribution of the work is made by offering access to copy
+    from a designated place, offer equivalent access to copy the above
+    specified materials from the same place.
+
+    e) Verify that the user has already received a copy of these
+    materials or that you have already sent this user a copy.
+
+  For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it.  However, as a special exception,
+the materials to be 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.
+
+  It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system.  Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+  7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+    a) Accompany the combined library with a copy of the same work
+    based on the Library, uncombined with any other library
+    facilities.  This must be distributed under the terms of the
+    Sections above.
+
+    b) Give prominent notice with the combined library of the fact
+    that part of it is a work based on the Library, and explaining
+    where to find the accompanying uncombined form of the same work.
+
+  8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License.  Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library 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.
+
+  9. 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 Library or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+  10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+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 with
+this License.
+
+  11. 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 Library at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Library 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 Library.
+
+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.
+
+  12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library 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.
+
+  13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser 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 Library
+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 Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+  14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+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
+
+  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "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
+LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. 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 LIBRARY 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
+LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+         END OF TERMS AND CONDITIONS
+
+           How to Apply These Terms to Your New Libraries
+
+  If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change.  You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+  To apply these terms, attach the following notices to the library.  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 library's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 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
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; 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.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the
+  library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+  <signature of Ty Coon>, 1 April 1990
+  Ty Coon, President of Vice
+
+That's all there is to it!
+
+

+ 361 - 0
tigcc/pstarter/lzma/LzmaDecode.c

@@ -0,0 +1,361 @@
+/*
+  LzmaDecode.c
+  LZMA Decoder
+  
+  LZMA SDK 4.05 Copyright (c) 1999-2004 Igor Pavlov (2004-08-25)
+  Modifications for TIGCC Copyright (C) 2004 Kevin Kofler
+  http://www.7-zip.org/
+
+  LZMA SDK is licensed under two licenses:
+  1) GNU Lesser General Public License (GNU LGPL)
+  2) Common Public License (CPL)
+  It means that you can select one of these two licenses and 
+  follow rules of that license.
+
+  SPECIAL EXCEPTION:
+  Igor Pavlov, as the author of this code, expressly permits you to 
+  statically or dynamically link your code (or bind by name) to the 
+  interfaces of this file without subjecting your linked code to the 
+  terms of the CPL or GNU LGPL. Any modifications or additions 
+  to this file, however, are subject to the LGPL or CPL terms.
+*/
+
+#include "LzmaDecode.h"
+
+#define Byte unsigned char
+
+#define kNumTopBits 24
+#define kTopValue ((UInt32)1 << kNumTopBits)
+
+#define kNumBitModelTotalBits 11
+#define kBitModelTotal (1 << kNumBitModelTotalBits)
+#define kNumMoveBits 5
+
+typedef struct _CRangeDecoder
+{
+  Byte *Buffer;
+  UInt32 Range;
+  UInt32 Code;
+} CRangeDecoder;
+
+#define ReadByte (*rd->Buffer++)
+
+static inline void RangeDecoderInit(CRangeDecoder *rd,
+    Byte *stream)
+{
+  int i;
+  rd->Buffer = stream;
+  rd->Code = 0;
+  rd->Range = (0xFFFFFFFF);
+  for(i = 0; i < 5; i++)
+    rd->Code = (rd->Code << 8) | ReadByte;
+}
+
+#define RC_INIT_VAR UInt32 range = rd->Range; UInt32 code = rd->Code;        
+#define RC_FLUSH_VAR rd->Range = range; rd->Code = code;
+#define RC_NORMALIZE if (range < kTopValue) { range <<= 8; code = (code << 8) | ReadByte; }
+
+static inline UInt32 RangeDecoderDecodeDirectBits(CRangeDecoder *rd, int numTotalBits)
+{
+  RC_INIT_VAR
+  UInt32 result = 0;
+  int i;
+  for (i = numTotalBits; i > 0; i--)
+  {
+    /* UInt32 t; */
+    range >>= 1;
+
+    result <<= 1;
+    if (code >= range)
+    {
+      code -= range;
+      result |= 1;
+    }
+    /*
+    t = (code - range) >> 31;
+    t &= 1;
+    code -= range & (t - 1);
+    result = (result + result) | (1 - t);
+    */
+    RC_NORMALIZE
+  }
+  RC_FLUSH_VAR
+  return result;
+}
+
+static __attribute__((regparm)) int RangeDecoderBitDecode(CProb *prob, CRangeDecoder *rd)
+{
+  UInt32 bound = (rd->Range >> kNumBitModelTotalBits) * *prob;
+  if (rd->Code < bound)
+  {
+    rd->Range = bound;
+    *prob += (kBitModelTotal - *prob) >> kNumMoveBits;
+    if (rd->Range < kTopValue)
+    {
+      rd->Code = (rd->Code << 8) | ReadByte;
+      rd->Range <<= 8;
+    }
+    return 0;
+  }
+  else
+  {
+    rd->Range -= bound;
+    rd->Code -= bound;
+    *prob -= (*prob) >> kNumMoveBits;
+    if (rd->Range < kTopValue)
+    {
+      rd->Code = (rd->Code << 8) | ReadByte;
+      rd->Range <<= 8;
+    }
+    return 1;
+  }
+}
+
+static __attribute__((regparm)) int RangeDecoderBitTreeDecode(CProb *probs, int numLevels, CRangeDecoder *rd)
+{
+  int mi = 1;
+  int i;
+  for(i = numLevels; i > 0; i--)
+  {
+    mi = (mi + mi) + RangeDecoderBitDecode(probs + mi, rd);
+  }
+  return mi - (1 << numLevels);
+}
+
+static inline int RangeDecoderReverseBitTreeDecode(CProb *probs, int numLevels, CRangeDecoder *rd)
+{
+  int mi = 1;
+  int i;
+  int symbol = 0;
+  for(i = 0; i < numLevels; i++)
+  {
+    int bit = RangeDecoderBitDecode(probs + mi, rd);
+    mi = mi + mi + bit;
+    symbol |= (bit << i);
+  }
+  return symbol;
+}
+
+static inline Byte LzmaLiteralDecode(CProb *probs, CRangeDecoder *rd)
+{ 
+  int symbol = 1;
+  do
+  {
+    symbol = (symbol + symbol) | RangeDecoderBitDecode(probs + symbol, rd);
+  }
+  while (symbol < 0x100);
+  return symbol;
+}
+
+static inline Byte LzmaLiteralDecodeMatch(CProb *probs, CRangeDecoder *rd, Byte matchByte)
+{ 
+  int symbol = 1;
+  do
+  {
+    int bit;
+    int matchBit = (matchByte >> 7) & 1;
+    matchByte <<= 1;
+    bit = RangeDecoderBitDecode(probs + ((1 + matchBit) << 8) + symbol, rd);
+    symbol = (symbol << 1) | bit;
+    if (matchBit != bit)
+    {
+      while (symbol < 0x100)
+      {
+        symbol = (symbol + symbol) | RangeDecoderBitDecode(probs + symbol, rd);
+      }
+      break;
+    }
+  }
+  while (symbol < 0x100);
+  return symbol;
+}
+
+#define kNumPosBitsMax 1
+#define kNumPosStatesMax (1 << kNumPosBitsMax)
+
+#define kLenNumLowBits 3
+#define kLenNumLowSymbols (1 << kLenNumLowBits)
+#define kLenNumMidBits 3
+#define kLenNumMidSymbols (1 << kLenNumMidBits)
+#define kLenNumHighBits 8
+#define kLenNumHighSymbols (1 << kLenNumHighBits)
+
+#define LenChoice 0
+#define LenChoice2 (LenChoice + 1)
+#define LenLow (LenChoice2 + 1)
+#define LenMid (LenLow + (kNumPosStatesMax << kLenNumLowBits))
+#define LenHigh (LenMid + (kNumPosStatesMax << kLenNumMidBits))
+#define kNumLenProbs (LenHigh + kLenNumHighSymbols) 
+
+static __attribute__((regparm)) int LzmaLenDecode(CProb *p, CRangeDecoder *rd, int posState)
+{
+  if(RangeDecoderBitDecode(p + LenChoice, rd) == 0)
+    return RangeDecoderBitTreeDecode(p + LenLow +
+        (posState << kLenNumLowBits), kLenNumLowBits, rd);
+  if(RangeDecoderBitDecode(p + LenChoice2, rd) == 0)
+    return kLenNumLowSymbols + RangeDecoderBitTreeDecode(p + LenMid +
+        (posState << kLenNumMidBits), kLenNumMidBits, rd);
+  return kLenNumLowSymbols + kLenNumMidSymbols + 
+      RangeDecoderBitTreeDecode(p + LenHigh, kLenNumHighBits, rd);
+}
+
+#define kNumStates 12
+
+#define kStartPosModelIndex 4
+#define kEndPosModelIndex 14
+#define kNumFullDistances (1 << (kEndPosModelIndex >> 1))
+
+#define kNumPosSlotBits 6
+#define kNumLenToPosStates 4
+
+#define kNumAlignBits 4
+#define kAlignTableSize (1 << kNumAlignBits)
+
+#define kMatchMinLen 2
+
+#define IsMatch 0
+#define IsRep (IsMatch + (kNumStates << kNumPosBitsMax))
+#define IsRepG0 (IsRep + kNumStates)
+#define IsRepG1 (IsRepG0 + kNumStates)
+#define IsRepG2 (IsRepG1 + kNumStates)
+#define IsRep0Long (IsRepG2 + kNumStates)
+#define PosSlot (IsRep0Long + (kNumStates << kNumPosBitsMax))
+#define SpecPos (PosSlot + (kNumLenToPosStates << kNumPosSlotBits))
+#define Align (SpecPos + kNumFullDistances - kEndPosModelIndex)
+#define LenCoder (Align + kAlignTableSize)
+#define RepLenCoder (LenCoder + kNumLenProbs)
+#define Literal (RepLenCoder + kNumLenProbs)
+
+int LzmaDecode(
+    unsigned char *inStream,
+    unsigned char *outStream, UInt32 outSize)
+{
+  UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE);
+  CProb p[LZMA_BASE_SIZE+LZMA_LIT_SIZE];
+  CRangeDecoder rd;
+  UInt32 i;
+  int state = 0;
+  int previousIsMatch = 0;
+  Byte previousByte = 0;
+  UInt32 rep0 = 1, rep1 = 1, rep2 = 1, rep3 = 1;
+  UInt32 nowPos = 0;
+  UInt32 posStateMask = 1;
+  int len = 0;
+  for (i = 0; i < numProbs; i++)
+    p[i] = kBitModelTotal >> 1; 
+  RangeDecoderInit(&rd, inStream);
+
+  while(nowPos < outSize)
+  {
+    int posState = (int)(nowPos & posStateMask);
+    if (RangeDecoderBitDecode(p + IsMatch + (state << kNumPosBitsMax) + posState, &rd) == 0)
+    {
+      CProb *probs = p + Literal;
+
+      if (state < 4) state = 0;
+      else if (state < 10) state -= 3;
+      else state -= 6;
+      if (previousIsMatch)
+      {
+        Byte matchByte;
+        matchByte = outStream[nowPos - rep0];
+        previousByte = LzmaLiteralDecodeMatch(probs, &rd, matchByte);
+        previousIsMatch = 0;
+      }
+      else
+        previousByte = LzmaLiteralDecode(probs, &rd);
+      outStream[nowPos++] = previousByte;
+    }
+    else             
+    {
+      previousIsMatch = 1;
+      if (RangeDecoderBitDecode(p + IsRep + state, &rd))
+      {
+        if (RangeDecoderBitDecode(p + IsRepG0 + state, &rd) == 0)
+        {
+          if (RangeDecoderBitDecode(p + IsRep0Long + (state << kNumPosBitsMax) + posState, &rd) == 0)
+          {
+            if (nowPos == 0)
+              return LZMA_RESULT_DATA_ERROR;
+            state = state < 7 ? 9 : 11;
+            previousByte = outStream[nowPos - rep0];
+            outStream[nowPos++] = previousByte;
+            continue;
+          }
+        }
+        else
+        {
+          UInt32 distance;
+          if(RangeDecoderBitDecode(p + IsRepG1 + state, &rd) == 0)
+            distance = rep1;
+          else 
+          {
+            if(RangeDecoderBitDecode(p + IsRepG2 + state, &rd) == 0)
+              distance = rep2;
+            else
+            {
+              distance = rep3;
+              rep3 = rep2;
+            }
+            rep2 = rep1;
+          }
+          rep1 = rep0;
+          rep0 = distance;
+        }
+        len = LzmaLenDecode(p + RepLenCoder, &rd, posState);
+        state = state < 7 ? 8 : 11;
+      }
+      else
+      {
+        int posSlot;
+        rep3 = rep2;
+        rep2 = rep1;
+        rep1 = rep0;
+        state = state < 7 ? 7 : 10;
+        len = LzmaLenDecode(p + LenCoder, &rd, posState);
+        posSlot = RangeDecoderBitTreeDecode(p + PosSlot +
+            ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << 
+            kNumPosSlotBits), kNumPosSlotBits, &rd);
+        if (posSlot >= kStartPosModelIndex)
+        {
+          int numDirectBits = ((posSlot >> 1) - 1);
+          rep0 = ((2 | ((UInt32)posSlot & 1)) << numDirectBits);
+          if (posSlot < kEndPosModelIndex)
+          {
+            rep0 += RangeDecoderReverseBitTreeDecode(
+                p + SpecPos + rep0 - posSlot - 1, numDirectBits, &rd);
+          }
+          else
+          {
+            rep0 += RangeDecoderDecodeDirectBits(&rd, 
+                numDirectBits - kNumAlignBits) << kNumAlignBits;
+            rep0 += RangeDecoderReverseBitTreeDecode(p + Align, kNumAlignBits, &rd);
+          }
+        }
+        else
+          rep0 = posSlot;
+        rep0++;
+      }
+      if (rep0 == (UInt32)(0))
+      {
+        /* it's for stream version */
+        /* len = -1; */
+        break;
+      }
+      if (rep0 > nowPos)
+      {
+        return LZMA_RESULT_DATA_ERROR;
+      }
+      len += kMatchMinLen;
+      do
+      {
+        previousByte = outStream[nowPos - rep0];
+        outStream[nowPos++] = previousByte;
+        len--;
+      }
+      while(len > 0 && nowPos < outSize);
+    }
+  }
+
+  return LZMA_RESULT_OK;
+}

+ 47 - 0
tigcc/pstarter/lzma/LzmaDecode.h

@@ -0,0 +1,47 @@
+/* 
+  LzmaDecode.h
+  LZMA Decoder interface
+
+  LZMA SDK 4.05 Copyright (c) 1999-2004 Igor Pavlov (2004-08-25)
+  Modifications for TIGCC Copyright (C) 2004 Kevin Kofler
+  http://www.7-zip.org/
+
+  LZMA SDK is licensed under two licenses:
+  1) GNU Lesser General Public License (GNU LGPL)
+  2) Common Public License (CPL)
+  It means that you can select one of these two licenses and 
+  follow rules of that license.
+
+  SPECIAL EXCEPTION:
+  Igor Pavlov, as the author of this code, expressly permits you to 
+  statically or dynamically link your code (or bind by name) to the 
+  interfaces of this file without subjecting your linked code to the 
+  terms of the CPL or GNU LGPL. Any modifications or additions 
+  to this file, however, are subject to the LGPL or CPL terms.
+*/
+
+#ifndef __LZMADECODE_H
+#define __LZMADECODE_H
+
+#define UInt32 unsigned long
+#define CProb unsigned short
+
+#define LZMA_RESULT_OK 0
+#define LZMA_RESULT_DATA_ERROR 1
+#define LZMA_RESULT_NOT_ENOUGH_MEM 2
+
+#define LZMA_BASE_SIZE 1062
+#define LZMA_LIT_SIZE 768
+
+/* 
+bufferSize = (LZMA_BASE_SIZE + (LZMA_LIT_SIZE << (lc + lp)))* sizeof(CProb)
+bufferSize += 100 in case of _LZMA_OUT_READ
+by default CProb is unsigned short, 
+but if specify _LZMA_PROB_32, CProb will be UInt32(unsigned int)
+*/
+
+int LzmaDecode(
+    unsigned char *inStream,
+    unsigned char *outStream, UInt32 outSize);
+
+#endif

+ 525 - 0
tigcc/pstarter/lzma/LzmaDecode.s

@@ -0,0 +1,525 @@
+	.file	"LzmaDecode.c"
+#NO_APP
+	.text
+tigcc_compiled.:
+	.text
+	.even
+RangeDecoderBitDecode:
+	movm.l #0x1c30,-(%sp)
+	move.l %a0,%a3
+	move.l %a1,%a2
+	move.l 4(%a1),%d5
+	move.l %d5,%d0
+	moveq.l #11,%d1
+	lsr.l %d1,%d0
+	move.w (%a0),%d3
+	move.w %d3,-(%sp)
+	clr.w -(%sp)
+	move.l %d0,-(%sp)
+	jbsr __mulsi3
+	addq.l #8,%sp
+	move.l %d0,%d1
+	move.l 8(%a2),%d4
+	cmp.l %d4,%d0
+	jbls .L2
+	move.l %d0,4(%a2)
+	move.w #2048,%d0
+	sub.w %d3,%d0
+	lsr.w #5,%d0
+	add.w %d0,%d3
+	move.w %d3,(%a3)
+	cmp.l #16777215,%d1
+	jbhi .L3
+	lsl.l #8,%d4
+	move.l (%a2),%a0
+	or.b (%a0),%d4
+	move.l %d4,8(%a2)
+	addq.l #1,(%a2)
+	move.l %d1,%d0
+	lsl.l #8,%d0
+	move.l %d0,4(%a2)
+.L3:
+	clr.w %d0
+	jbra .L1
+	.even
+.L2:
+	move.l %d5,%d2
+	sub.l %d0,%d2
+	move.l %d2,4(%a2)
+	sub.l %d0,%d4
+	move.l %d4,%d1
+	move.l %d4,8(%a2)
+	move.w %d3,%d0
+	lsr.w #5,%d0
+	sub.w %d0,%d3
+	move.w %d3,(%a3)
+	cmp.l #16777215,%d2
+	jbhi .L5
+	lsl.l #8,%d1
+	move.l (%a2),%a0
+	or.b (%a0),%d1
+	move.l %d1,8(%a2)
+	addq.l #1,(%a2)
+	lsl.l #8,%d2
+	move.l %d2,4(%a2)
+.L5:
+	moveq.l #1,%d0
+.L1:
+	movm.l (%sp)+,#0xc38
+	rts
+	.even
+RangeDecoderBitTreeDecode:
+	movm.l #0x1f00,-(%sp)
+	move.l %a0,%d7
+	move.w %d0,%d5
+	move.l %a1,%d6
+	moveq.l #1,%d1
+	move.w %d0,%d4
+	jbra .L7
+	.even
+.L11:
+	move.w %d1,%d3
+	add.w %d1,%d3
+	move.w %d1,%a0
+	add.l %a0,%a0
+	move.l %d6,%a1
+	lea (%a0,%d7.l),%a0
+	jbsr RangeDecoderBitDecode
+	move.w %d3,%d1
+	add.w %d0,%d1
+	subq.w #1,%d4
+.L7:
+	tst.w %d4
+	jbgt .L11
+	moveq.l #1,%d0
+	lsl.w %d5,%d0
+	sub.w %d0,%d1
+	move.w %d1,%d0
+	movm.l (%sp)+,#0xf8
+	rts
+	.even
+LzmaLenDecode:
+	movm.l #0x1820,-(%sp)
+	move.l %a0,%a2
+	move.l %a1,%d3
+	move.w %d0,%d4
+	jbsr RangeDecoderBitDecode
+	tst.w %d0
+	jbne .L13
+	move.w %d4,%d1
+	ext.l %d1
+	lsl.l #4,%d1
+	move.l %d3,%a1
+	moveq.l #3,%d0
+	lea 4(%a2,%d1.l),%a0
+	jbsr RangeDecoderBitTreeDecode
+	jbra .L12
+	.even
+.L13:
+	move.l %d3,%a1
+	lea (2,%a2),%a0
+	jbsr RangeDecoderBitDecode
+	tst.w %d0
+	jbne .L14
+	move.w %d4,%d1
+	ext.l %d1
+	lsl.l #4,%d1
+	move.l %d3,%a1
+	moveq.l #3,%d0
+	lea 36(%a2,%d1.l),%a0
+	jbsr RangeDecoderBitTreeDecode
+	addq.w #8,%d0
+	jbra .L12
+	.even
+.L14:
+	move.l %d3,%a1
+	moveq.l #8,%d0
+	lea (68,%a2),%a0
+	jbsr RangeDecoderBitTreeDecode
+	add.w #16,%d0
+.L12:
+	movm.l (%sp)+,#0x418
+	rts
+	.even
+	.globl	LzmaDecode
+LzmaDecode:
+	lea (-3692,%sp),%sp
+	movm.l #0x1f3a,-(%sp)
+	clr.w 50(%sp)
+	clr.w 48(%sp)
+	moveq.l #1,%d7
+	move.l %d7,44(%sp)
+	move.l %d7,40(%sp)
+	move.l %d7,36(%sp)
+	sub.l %a6,%a6
+	moveq.l #0,%d0
+	lea (64,%sp),%a0
+	jbra .L16
+	.even
+.L20:
+	move.w #1024,(%a0)+
+	addq.l #1,%d0
+.L16:
+	cmp.l #1830,%d0
+	jbcs .L20
+	lea (52,%sp),%a1
+	move.l 3732(%sp),(%a1)
+	clr.l 8(%a1)
+	moveq.l #-1,%d0
+	move.l %d0,4(%a1)
+	moveq.l #4,%d1
+	jbra .L21
+	.even
+.L25:
+	move.l 8(%a1),%d0
+	lsl.l #8,%d0
+	move.l (%a1),%a0
+	or.b (%a0),%d0
+	move.l %d0,8(%a1)
+	addq.l #1,(%a1)
+	subq.w #1,%d1
+.L21:
+	tst.w %d1
+	jbge .L25
+	jbra .L102
+	.even
+.L101:
+	move.w %a6,%d5
+	and.w #1,%d5
+	lea (52,%sp),%a4
+	move.w 50(%sp),%d3
+	ext.l %d3
+	move.l %d3,%d4
+	add.l %d3,%d4
+	move.w %d5,%a3
+	lea (%a3,%d4.l),%a0
+	add.l %a0,%a0
+	moveq.l #64,%d6
+	add.l %sp,%d6
+	move.l %a4,%a1
+	add.l %d6,%a0
+	jbsr RangeDecoderBitDecode
+	tst.w %d0
+	jbne .L30
+	move.l %sp,%d6
+	add.l #2188,%d6
+	cmp.w #3,50(%sp)
+	jbgt .L31
+	clr.w 50(%sp)
+	jbra .L32
+	.even
+.L31:
+	cmp.w #9,50(%sp)
+	jbgt .L33
+	subq.w #3,50(%sp)
+	jbra .L32
+	.even
+.L33:
+	subq.w #6,50(%sp)
+.L32:
+	moveq.l #1,%d0
+	tst.w 48(%sp)
+	jbeq .L47
+	move.l %a6,%d0
+	sub.l %d7,%d0
+	move.l 3736(%sp),%a0
+	move.b (%a0,%d0.l),%d5
+	moveq.l #1,%d4
+.L36:
+	move.b %d5,%d3
+	lsr.b #7,%d3
+	and.w #1,%d3
+	lsl.b #1,%d5
+	addq.w #1,%d3
+	move.w %d3,%d0
+	ext.l %d0
+	subq.w #1,%d3
+	lsl.l #8,%d0
+	move.l %d0,%a1
+	lea (%a1,%d4.w),%a0
+	add.l %a0,%a0
+	move.l %a4,%a1
+	add.l %d6,%a0
+	jbsr RangeDecoderBitDecode
+	lsl.w #1,%d4
+	or.w %d0,%d4
+	cmp.w %d3,%d0
+	jbeq .L38
+	jbra .L40
+	.even
+.L43:
+	move.w %d4,%d3
+	add.w %d4,%d3
+	move.w %d4,%a0
+	add.l %a0,%a0
+	move.l %a4,%a1
+	lea (%a0,%d6.l),%a0
+	jbsr RangeDecoderBitDecode
+	move.w %d3,%d4
+	or.w %d0,%d4
+.L40:
+	cmp.w #255,%d4
+	jble .L43
+	jbra .L37
+	.even
+.L38:
+	cmp.w #255,%d4
+	jble .L36
+.L37:
+	move.b %d4,%d3
+	clr.w 48(%sp)
+	jbra .L46
+	.even
+.L47:
+	move.w %d0,%d3
+	add.w %d0,%d3
+	move.w %d0,%a0
+	add.l %a0,%a0
+	move.l %a4,%a1
+	lea (%a0,%d6.l),%a0
+	jbsr RangeDecoderBitDecode
+	or.w %d3,%d0
+	cmp.w #255,%d0
+	jble .L47
+	move.b %d0,%d3
+.L46:
+	move.l 3736(%sp),%d0
+	move.b %d3,(%a6,%d0.l)
+	jbra .L104
+	.even
+.L30:
+	move.w #1,48(%sp)
+	move.l %d6,%a2
+	add.l %d4,%a2
+	move.l %a4,%a1
+	lea (48,%a2),%a0
+	jbsr RangeDecoderBitDecode
+	tst.w %d0
+	jbeq .L53
+	move.l %a4,%a1
+	lea (72,%a2),%a0
+	jbsr RangeDecoderBitDecode
+	tst.w %d0
+	jbne .L54
+	lsl.l #2,%d3
+	move.l %d6,%d0
+	add.l %d3,%d0
+	lea (%a3,%a3.l),%a0
+	lea (%a0,%d0.l),%a0
+	move.l %a4,%a1
+	lea (144,%a0),%a0
+	jbsr RangeDecoderBitDecode
+	tst.w %d0
+	jbne .L59
+	moveq.l #1,%d0
+	cmp.w #0,%a6
+	jbeq .L15
+	moveq.l #9,%d0
+	cmp.w #6,50(%sp)
+	jble .L58
+	moveq.l #11,%d0
+.L58:
+	move.w %d0,50(%sp)
+	move.l %a6,%d0
+	sub.l %d7,%d0
+	move.l 3736(%sp),%a0
+	move.b (%a0,%d0.l),(%a6,%a0.l)
+.L104:
+	addq.l #1,%a6
+	jbra .L102
+	.even
+.L54:
+	move.l %a4,%a1
+	lea (96,%a2),%a0
+	jbsr RangeDecoderBitDecode
+	move.l 44(%sp),%d1
+	tst.w %d0
+	jbeq .L61
+	move.l %a4,%a1
+	lea (120,%a2),%a0
+	jbsr RangeDecoderBitDecode
+	move.l 40(%sp),%d1
+	tst.w %d0
+	jbeq .L63
+	move.l 36(%sp),%d1
+	move.l 40(%sp),36(%sp)
+.L63:
+	move.l 44(%sp),40(%sp)
+.L61:
+	move.l %d7,44(%sp)
+	move.l %d1,%d7
+.L59:
+	move.w %d5,%d0
+	move.l %a4,%a1
+	lea (1608,%sp),%a0
+	jbsr LzmaLenDecode
+	move.w %d0,%d5
+	moveq.l #8,%d0
+	cmp.w #6,50(%sp)
+	jble .L65
+	moveq.l #11,%d0
+.L65:
+	move.w %d0,50(%sp)
+	jbra .L66
+	.even
+.L53:
+	move.l 40(%sp),36(%sp)
+	move.l 44(%sp),40(%sp)
+	move.l %d7,44(%sp)
+	moveq.l #7,%d0
+	cmp.w #6,50(%sp)
+	jble .L68
+	moveq.l #10,%d0
+.L68:
+	move.w %d0,50(%sp)
+	move.w %d5,%d0
+	move.l %a4,%a1
+	lea (1028,%sp),%a0
+	jbsr LzmaLenDecode
+	move.w %d0,%d5
+	cmp.w #3,%d0
+	jble .L69
+	moveq.l #3,%d0
+.L69:
+	ext.l %d0
+	lsl.l #7,%d0
+	move.l %d6,%a0
+	add.l %d0,%a0
+	move.l %a4,%a1
+	moveq.l #6,%d0
+	lea (192,%a0),%a0
+	jbsr RangeDecoderBitTreeDecode
+	move.w %d0,%d2
+	move.w %d0,%d1
+	ext.l %d1
+	move.l %d1,%d7
+	cmp.w #3,%d0
+	jble .L93
+	move.w %d0,%d4
+	asr.w #1,%d4
+	move.w %d4,%a3
+	subq.w #1,%a3
+	moveq.l #1,%d7
+	and.l %d1,%d7
+	moveq.l #2,%d0
+	or.l %d0,%d7
+	clr.l %d0
+	move.w %a3,%d0
+	lsl.l %d0,%d7
+	cmp.w #13,%d2
+	jbgt .L71
+	move.l %d7,%d0
+	add.l %d7,%d0
+	add.l %d6,%d0
+	add.l %d1,%d1
+	sub.l %d1,%d0
+	move.l %d0,%a2
+	lea (702,%a2),%a2
+	moveq.l #1,%d3
+	clr.w %d6
+	clr.w %d4
+	jbra .L72
+	.even
+.L76:
+	move.w %d3,%a0
+	add.l %a0,%a0
+	move.l %a4,%a1
+	lea (%a2,%a0.l),%a0
+	jbsr RangeDecoderBitDecode
+	add.w %d3,%d3
+	add.w %d0,%d3
+	lsl.w %d4,%d0
+	or.w %d0,%d6
+	addq.w #1,%d4
+.L72:
+	cmp.w %a3,%d4
+	jblt .L76
+	jbra .L103
+	.even
+.L71:
+	move.l 4(%a4),%d0
+	move.l 8(%a4),%d1
+	moveq.l #0,%d3
+	move.w %d4,%d2
+	subq.w #5,%d2
+	jbra .L79
+	.even
+.L85:
+	lsr.l #1,%d0
+	add.l %d3,%d3
+	cmp.l %d1,%d0
+	jbhi .L83
+	sub.l %d0,%d1
+	moveq.l #1,%d4
+	or.l %d4,%d3
+.L83:
+	cmp.l #16777215,%d0
+	jbhi .L81
+	lsl.l #8,%d0
+	lsl.l #8,%d1
+	move.l (%a4),%a0
+	or.b (%a0),%d1
+	addq.l #1,(%a4)
+.L81:
+	subq.w #1,%d2
+.L79:
+	tst.w %d2
+	jbgt .L85
+	move.l %d0,4(%a4)
+	move.l %d1,8(%a4)
+	lsl.l #4,%d3
+	add.l %d3,%d7
+	lea (996,%sp),%a2
+	moveq.l #1,%d3
+	clr.w %d6
+	clr.w %d4
+	jbra .L87
+	.even
+.L91:
+	move.w %d3,%a0
+	add.l %a0,%a0
+	move.l %a4,%a1
+	lea (%a2,%a0.l),%a0
+	jbsr RangeDecoderBitDecode
+	add.w %d3,%d3
+	add.w %d0,%d3
+	lsl.w %d4,%d0
+	or.w %d0,%d6
+	addq.w #1,%d4
+.L87:
+	cmp.w #4,%d4
+	jblt .L91
+.L103:
+	move.l %d7,%a0
+	lea (%a0,%d6.w),%a0
+	move.l %a0,%d7
+.L93:
+	addq.l #1,%d7
+.L66:
+	tst.l %d7
+	jbeq .L28
+	moveq.l #1,%d0
+	cmp.l %d7,%a6
+	jbcs .L15
+	addq.w #2,%d5
+	move.l 3736(%sp),%a0
+	sub.l %d7,%a0
+	lea (%a6,%a0.l),%a0
+.L96:
+	move.l 3736(%sp),%a1
+	move.b (%a0)+,(%a6,%a1.l)
+	addq.l #1,%a6
+	subq.w #1,%d5
+	tst.w %d5
+	jble .L102
+	cmp.l 3740(%sp),%a6
+	jbcs .L96
+.L102:
+	cmp.l 3740(%sp),%a6
+	jbcs .L101
+.L28:
+	clr.w %d0
+.L15:
+	movm.l (%sp)+,#0x5cf8
+	lea (3692,%sp),%sp
+	rts

+ 1 - 0
tigcc/pstarter/lzma/compile.bat

@@ -0,0 +1 @@
+tigcc -Os -fomit-frame-pointer -mpcrel -D_LZMA_UINT32_IS_ULONG -S LzmaDecode.c

+ 92 - 0
tigcc/pstarter/lzma/history.txt

@@ -0,0 +1,92 @@
+HISTORY of the LZMA SDK
+-----------------------
+
+  Version 4.06-tigcc-4        2004-12-22
+  --------------------------------------
+    - lzmaInternalData is now stack-allocated within LzmaDecode.
+
+  Version 4.06-tigcc-3        2004-12-22
+  --------------------------------------
+    - Decreased kNumPosBitsMax from 4 to 1. Decreased LZMA_BASE_SIZE
+      accordingly from 1846 to 1062.
+    - Dropped == 1 from a test of a decoded bit.
+
+  Version 4.06-tigcc-2        2004-12-21
+  --------------------------------------
+    - Removed check for extra bytes.
+
+  Version 4.06-tigcc-1        2004-12-21
+  --------------------------------------
+    - Removed #ifdefs, selected only the needed code.
+    - Hard-coded lc=lp=0, pb=1.
+    - Removed buffer size check.
+    - Removed OutSizeProcessed.
+    - Made functions called exactly once (RangeDecoderInit,
+      RangeDecoderDecodeDirectBits, RangeDecoderReverseBitTreeDecode,
+      LzmaLiteralDecode, LzmaLiteralDecodeMatch) static inline.
+    - Made the other internal functions (RangeDecoderReadByte,
+      RangeDecoderBitDecode, RangeDecoderBitTreeDecode, LzmaLenDecode)
+      static __attribute__((regparm)).
+    - Disabled a len = -1; used only for the stream version.
+
+  Version 4.06                2004-09-05
+  --------------------------------------
+    - Bug in v4.05 was fixed:
+        LZMA-Encoder didn't release output stream in some cases.
+
+
+  Version 4.05                2004-08-25
+  --------------------------------------
+    - Source code of filters for x86, IA-64, ARM, ARM-Thumb 
+      and PowerPC code was included to SDK
+    - Some internal minor changes
+
+
+  Version 4.04                2004-07-28
+  --------------------------------------
+    - More compatibility with some C++ compilers
+
+
+  Version 4.03                2004-06-18
+  --------------------------------------
+    - "Benchmark" command was added. It measures compressing 
+      and decompressing speed and shows rating values. 
+      Also it checks hardware errors.
+
+
+  Version 4.02                2004-06-10
+  --------------------------------------
+    - C++ LZMA Encoder/Decoder code now is more portable
+      and it can be compiled by GCC on Linux.
+
+
+  Version 4.01                2004-02-15
+  --------------------------------------
+    - Some detection of data corruption was enabled.
+        LzmaDecode.c / RangeDecoderReadByte
+        .....
+        {
+          rd->ExtraBytes = 1;
+          return 0xFF;
+        }
+
+
+  Version 4.00                2004-02-13
+  --------------------------------------
+    - Original version of LZMA SDK
+
+
+
+HISTORY of the LZMA
+-------------------
+  2001-2004:  Improvements to LZMA compressing/decompressing code, 
+              keeping compatibility with original LZMA format
+  1996-2001:  Development of LZMA compression format
+
+  Some milestones:
+
+  2001-08-30: LZMA compression was added to 7-Zip
+  1999-01-02: First version of 7-Zip was released
+  
+
+End of document

+ 61 - 0
tigcc/pstarter/lzma/lzma.tpr

@@ -0,0 +1,61 @@
+[Settings]
+Archive=0
+Flash OS=0
+Fargo=0
+Use Data Variable=0
+Data Variable=
+Copy Data Variable=1
+Copy Data Variable if Archived=1
+Pack=0
+Packed Variable=
+Project Name=lzma
+GCC Switches=-Os -Wall -W -Wwrite-strings -fomit-frame-pointer -mpcrel -D_LZMA_UINT32_IS_ULONG
+GNU Assembler Switches=
+Assembler Switches=-g -t
+Debug Info=0
+Standard Library=1
+Initialize BSS=1
+Optimize NOPs=1
+Optimize Returns=1
+Optimize Branches=1
+Optimize Moves=1
+Optimize Tests=1
+Optimize Calculations=1
+Remove Unused Sections=1
+Cut Unused Ranges=1
+Reorder Sections=1
+Merge Constants=1
+Binary Output=0
+Command Line=
+Post-Build Process=
+
+[Library Options]
+Use TI-89=1
+Use TI-92 Plus=1
+Use V200=1
+Optimize Calc Consts=0
+Use Kernel=0
+Use PreOS=0
+Minimum AMS Version Defined=1
+Minimum AMS Version=1.00
+Unofficial OS Support=1
+Reloc Format=AMS
+ROM Call Format=Direct
+BSS Ref Format=Kernel
+Data Ref Format=Kernel
+Use F-Line Jumps=0
+Use 4-Byte F-Line Jumps=0
+Optimize ROM Calls=0
+Use Internal F-Line Emulator=0
+Use Return Value=0
+Enable Error Return=0
+Save Screen=1
+
+[File Editing]
+Open File=E:\TI-89\pstarter\lzma\LzmaDecode.c
+
+[Included Files]
+C File 1=LzmaDecode.c
+Text File 1=history.txt
+Header File 1=LzmaDecode.h
+

+ 507 - 0
tigcc/pstarter/lzma/lzma.txt

@@ -0,0 +1,507 @@
+LZMA SDK 4.06
+-------------
+
+LZMA SDK 4.06  Copyright (C) 1999-2004 Igor Pavlov
+
+LZMA SDK provides developers with documentation, source code,
+and sample code necessary to write software that uses LZMA compression. 
+
+LZMA is default and general compression method of 7z format
+in 7-Zip compression program (www.7-zip.org). LZMA provides high 
+compression ratio and very fast decompression.
+
+LZMA is an improved version of famous LZ77 compression algorithm. 
+It was improved in way of maximum increasing of compression ratio,
+keeping high decompression speed and low memory requirements for 
+decompressing.
+
+
+
+LICENSE
+-------
+
+LZMA SDK is licensed under two licenses:
+
+1) GNU Lesser General Public License (GNU LGPL)
+2) Common Public License (CPL)
+
+It means that you can select one of these two licenses and 
+follow rules of that license.
+
+SPECIAL EXCEPTION
+Igor Pavlov, as the author of this code, expressly permits you 
+to statically or dynamically link your code (or bind by name) 
+to the files from LZMA SDK without subjecting your linked 
+code to the terms of the CPL or GNU LGPL. 
+Any modifications or additions to files from LZMA SDK, however, 
+are subject to the GNU LGPL or CPL terms.
+
+
+GNU LGPL and CPL licenses are pretty similar and both these
+licenses are classified as 
+
+1) "Free software licenses" at http://www.gnu.org/ 
+2) "OSI-approved" at http://www.opensource.org/
+
+
+LZMA SDK also can be available under a proprietary license for 
+those who cannot use the GNU LGPL or CPL in their code. To request
+such proprietary license or any additional consultations,
+send email message from that page:
+http://www.7-zip.org/support.html
+
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+You should have received a copy of the Common Public License
+along with this library.
+
+
+LZMA SDK Contents
+-----------------
+
+LZMA SDK includes:
+
+  - C++ source code of LZMA Encoder and Decoder
+  - C++ source code for file->file LZMA compressing and decompressing
+  - ANSI-C compatible source code for LZMA decompressing
+  - Compiled file->file LZMA compressing/decompressing program for Windows system
+
+ANSI-C LZMA decompression code was ported from original C++ sources to C.
+Also it was simplified and optimized for code size. 
+But it is fully compatible with LZMA from 7-Zip.
+
+
+UNIX/Linux version 
+------------------
+To compile C++ version of file->file LZMA, go to directory
+SRC/7zip/Compress/LZMA_Alone 
+and type "make" or "make clean all" to recompile all.
+
+In some UNIX/Linux versions you must compile LZMA with static libraries.
+To compile with static libraries, change string in makefile
+LIB = -lm
+to string  
+LIB = -lm -static
+
+
+Files
+---------------------
+SRC      - directory with source code
+lzma.txt - LZMA SDK description (this file)
+LGPL.txt - GNU Lesser General Public License
+CPL.html - Common Public License
+lzma.exe - Compiled file->file LZMA encoder/decoder for Windows
+history.txt - history of the LZMA SDK
+
+
+Source code structure
+---------------------
+
+SRC
+  Common  - common files for C++ projects
+  Windows - common files for Windows related code
+  7zip    - files related to 7-Zip Project
+    Common   - common files for 7-Zip
+    Compress - files related to compression/decompression
+      LZ     - files related to LZ (Lempel-Ziv) compression algorithm
+        BinTree    - Binary Tree Match Finder for LZ algorithm
+        HashChain  - Hash Chain Match Finder for LZ algorithm
+        Patricia   - Patricia Match Finder for LZ algorithm
+      RangeCoder   - Range Coder (special code of compression/decompression)
+      LZMA         - LZMA compression/decompression on C++
+      LZMA_Alone   - file->file LZMA compression/decompression
+      LZMA_C       - ANSI-C compatible LZMA decompressor
+        LzmaDecode.h  - interface for LZMA decoding on ANSI-C
+        LzmaDecode.c  - LZMA decoding on ANSI-C
+        LzmaTest.c    - test application that decodes LZMA encoded file
+      Branch       - Filters for x86, IA-64, ARM, ARM-Thumb and PowerPC code
+
+Source code of LZMA SDK is only part of big 7-Zip project. That is 
+why LZMA SDK uses such complex source code structure. 
+
+You can find ANSI-C LZMA decompressing code at folder 
+  SRC/7zip/Compress/LZMA_C
+7-Zip doesn't use that ANSI-C LZMA code and that code was developed 
+specially for this SDK. And files from LZMA_C do not need files from 
+other directories of SDK for compiling.
+
+7-Zip source code can be downloaded from 7-Zip's SourceForge page:
+
+  http://sourceforge.net/projects/sevenzip/
+
+
+LZMA Decompression features
+---------------------------
+  - Variable dictionary size (up to 256 MB)
+  - Estimated compressing speed: about 500 KB/s on 1 GHz CPU
+  - Estimated decompressing speed: 
+      - 8-12 MB/s on 1 GHz Intel Pentium 3 or AMD Athlon
+      - 500-1000 KB/s on 100 MHz ARM, MIPS, PowerPC or other simple RISC
+  - Small memory requirements for decompressing (8-32 KB + DictionarySize)
+  - Small code size for decompressing: 2-8 KB (depending from 
+    speed optimizations) 
+
+LZMA decoder uses only integer operations and can be 
+implemented in any modern 32-bit CPU (or on 16-bit CPU with some conditions).
+
+Some critical operations that affect to speed of LZMA decompression:
+  1) 32*16 bit integer multiply
+  2) Misspredicted branches (penalty mostly depends from pipeline length)
+  3) 32-bit shift and arithmetic operations
+
+Speed of LZMA decompression mostly depends from CPU speed.
+Memory speed has no big meaning. But if your CPU has small data cache, 
+overall weight of memory speed will slightly increase.
+
+
+How To Use
+----------
+
+Using LZMA encoder/decoder executable
+--------------------------------------
+
+Usage:  LZMA <e|d> inputFile outputFile [<switches>...]
+
+  e: encode file
+
+  d: decode file
+
+  b: Benchmark. There are two tests: compressing and decompressing 
+     with LZMA method. Benchmark shows rating in MIPS (million 
+     instructions per second). Rating value is calculated from 
+     measured speed and it is normalized with AMD Athlon XP CPU
+     results. Also Benchmark checks possible hardware errors (RAM 
+     errors in most cases). Benchmark uses these settings:
+     (-a1, -d21, -fb32, -mfbt4). You can change only -d. Also you 
+     can change number of iterations. Example for 30 iterations:
+	LZMA b 30
+     Default number of iterations is 10.
+
+<Switches>
+  
+
+  -a{N}:  set compression mode 0 = fast, 1 = normal, 2 = max
+          default: 2 (max)
+
+  d{N}:   Sets Dictionary size - [0, 28], default: 23 (8MB)
+          The maximum value for dictionary size is 256 MB = 2^28 bytes.
+          Dictionary size is calculated as DictionarySize = 2^N bytes. 
+          For decompressing file compressed by LZMA method with dictionary 
+          size D = 2^N you need about D bytes of memory (RAM).
+
+  -fb{N}: set number of fast bytes - [5, 255], default: 128
+          Usually big number gives a little bit better compression ratio 
+          and slower compression process.
+
+  -lc{N}: set number of literal context bits - [0, 8], default: 3
+          Sometimes lc=4 gives gain for big files.
+
+  -lp{N}: set number of literal pos bits - [0, 4], default: 0
+          lp switch is intended for periodical data when period is 
+          equal 2^N. For example, for 32-bit (4 bytes) 
+          periodical data you can use lp=2. Often it's better to set lc0, 
+          if you change lp switch.
+
+  -pb{N}: set number of pos bits - [0, 4], default: 2
+          pb switch is intended for periodical data 
+          when period is equal 2^N.
+
+  -mf{MF_ID}: set Match Finder. Default: bt4. 
+              Compression ratio for all bt* and pat* almost the same.
+              Algorithms from hc* group doesn't provide good compression 
+              ratio, but they often works pretty fast in combination with 
+              fast mode (-a0). Methods from bt* group require less memory 
+              than methods from pat* group. Usually bt4 works faster than 
+              any pat*, but for some types of files pat* can work faster. 
+
+              Memory requirements depend from dictionary size 
+              (parameter "d" in table below). 
+
+               MF_ID     Memory                   Description
+
+                bt2    d*9.5 +  1MB  Binary Tree with 2 bytes hashing.
+                bt3    d*9.5 + 65MB  Binary Tree with 2-3(full) bytes hashing.
+                bt4    d*9.5 +  6MB  Binary Tree with 2-3-4 bytes hashing.
+                bt4b   d*9.5 + 34MB  Binary Tree with 2-3-4(big) bytes hashing.
+                pat2r  d*26  +  1MB  Patricia Tree with 2-bits nodes, removing.
+                pat2   d*38  +  1MB  Patricia Tree with 2-bits nodes.
+                pat2h  d*38  + 77MB  Patricia Tree with 2-bits nodes, 2-3 bytes hashing.
+                pat3h  d*62  + 85MB  Patricia Tree with 3-bits nodes, 2-3 bytes hashing.
+                pat4h  d*110 +101MB  Patricia Tree with 4-bits nodes, 2-3 bytes hashing.
+                hc3    d*5.5 +  1MB  Hash Chain with 2-3 bytes hashing.
+                hc4    d*5.5 +  6MB  Hash Chain with 2-3-4 bytes hashing.
+
+  -eos:   write End Of Stream marker. By default LZMA doesn't write 
+          eos marker, since LZMA decoder knows uncompressed size 
+          stored in .lzma file header.
+
+  -si:    Read data from stdin (it will write End Of Stream marker).
+  -so:    Write data to stdout
+
+
+Examples:
+
+1) LZMA e file.bin file.lzma -d16 -lc0 
+
+compresses file.bin to file.lzma with 64 KB dictionary (2^16=64K)  
+and 0 literal context bits. -lc0 allows to reduce memory requirements 
+for decompression.
+
+
+2) LZMA e file.bin file.lzma -lc0 -lp2
+
+compresses file.bin to file.lzma with settings suitable 
+for 32-bit periodical data (for example, ARM or MIPS code).
+
+3) LZMA d file.lzma file.bin
+
+decompresses file.lzma to file.bin.
+
+
+Compression ratio hints
+-----------------------
+
+Recommendations
+---------------
+
+To increase compression ratio for LZMA compressing it's desirable 
+to have aligned data (if it's possible) and also it's desirable to locate
+data in such order, where code is grouped in one place and data is 
+grouped in other place (it's better than such mixing: code, data, code,
+data, ...).
+
+
+Using Filters
+-------------
+You can increase compression ratio for some data types, using
+special filters before compressing. For example, it's possible to 
+increase compression ratio on 5-10% for code for those CPU ISAs: 
+x86, IA-64, ARM, ARM-Thumb, PowerPC.
+
+You can find C/C++ source code of such filters in folder "7zip/Compress/Branch"
+
+You can check compression ratio gain of these filters with such 
+7-Zip commands (example for ARM code):
+No filter:
+  7z a a1.7z a.bin -m0=lzma
+
+With filter for little-endian ARM code:
+  7z a a2.7z a.bin -m0=bc_arm -m1=lzma        
+
+With filter for big-endian ARM code (using additional Swap4 filter):
+  7z a a3.7z a.bin -m0=swap4 -m1=bc_arm -m2=lzma
+
+It works in such manner:
+Compressing    = Filter_encodeing + LZMA_encoding
+Decompressing  = LZMA_decoding + Filter_decodeing
+
+Compressing and decompressing speed of such filters is very high,
+so it will not increase decompressing time too much.
+Moreover, it reduces decompression time for LZMA_decoding, 
+since compression ratio with filtering is higher.
+
+These filters convert CALL (calling procedure) instructions 
+from relative offsets to absolute addresses, so such data becomes more 
+compressible. Source code of these CALL filters is pretty simple
+(about 20 lines of C++), so you can convert it from C++ version yourself.
+
+For some ISAs (for example, for MIPS) it's impossible to get gain from such filter.
+
+
+LZMA compressed file format
+---------------------------
+Offset Size Description
+  0     1   Special LZMA properties for compressed data
+  1     4   Dictionary size (little endian)
+  5     8   Uncompressed size (little endian). -1 means unknown size
+ 13         Compressed data
+
+
+ANSI-C LZMA Decoder
+~~~~~~~~~~~~~~~~~~~
+
+Memory requirements for LZMA decoding
+-------------------------------------
+
+LZMA decoder doesn't allocate memory itself, so you must 
+calculate required memory, allocate it and send it to LZMA.
+
+Stack usage of LZMA function for local variables is not 
+larger than 200 bytes.
+
+Memory requirements for decompression depend 
+from interface that you want to use:
+
+  a) Memory to memory decompression:
+    
+    M1 = (inputSize + outputSize + lzmaInternalSize).
+
+  b) Decompression with buffering:
+
+    M2 = (inputBufferSize + outputBufferSize + dictionarySize + lzmaInternalSize)
+
+
+How To decompress data
+----------------------
+
+1) Read first byte of properties for LZMA compressed stream, 
+   check that it has correct value and calculate three 
+   LZMA property variables:
+
+  int lc, lp, pb;
+  unsigned char prop0 = properties[0];
+  if (prop0 >= (9*5*5))
+  {
+    sprintf(rs + strlen(rs), "\n properties error");
+    return 1;
+  }
+  for (pb = 0; prop0 >= (9 * 5); 
+    pb++, prop0 -= (9 * 5));
+  for (lp = 0; prop0 >= 9; 
+    lp++, prop0 -= 9);
+  lc = prop0;
+
+2) Calculate required amount for LZMA lzmaInternalSize:
+
+  lzmaInternalSize = (LZMA_BASE_SIZE + (LZMA_LIT_SIZE << (lc + lp))) * 
+     sizeof(CProb)
+
+  LZMA_BASE_SIZE = 1846
+  LZMA_LIT_SIZE = 768
+
+  LZMA decoder uses array of CProb variables as internal structure.
+  By default, CProb is (unsigned short)
+  But you can define _LZMA_PROB32 to make it (unsigned int)
+  It can increase speed on some 32-bit CPUs, but memory usage will 
+  be doubled in that case.
+
+
+  2b) If you use Decompression with buffering, add 100 bytes to 
+      lzmaInternalSize:
+     
+      #ifdef _LZMA_OUT_READ
+      lzmaInternalSize += 100;
+      #endif
+
+3) Allocate that memory with malloc or some other function:
+
+  lzmaInternalData = malloc(lzmaInternalSize);
+
+
+4) Decompress data:
+
+  4a) If you use simple memory to memory decompression:
+
+    int result = LzmaDecode(lzmaInternalData, lzmaInternalSize,
+        lc, lp, pb,
+        unsigned char *inStream, unsigned int inSize,
+        unsigned char *outStream, unsigned int outSize, 
+        &outSizeProcessed);
+
+  4b) If you use Decompression with buffering
+
+    4.1) Read dictionary size from properties
+
+      unsigned int dictionarySize = 0;
+      int i;
+      for (i = 0; i < 4; i++)
+        dictionarySize += (unsigned int)(b) << (i * 8);
+
+    4.2) Allocate memory for dictionary
+
+      unsigned char *dictionary = malloc(dictionarySize);
+
+    4.3) Initialize LZMA decoder:
+
+    LzmaDecoderInit((unsigned char *)lzmaInternalData, lzmaInternalSize,
+        lc, lp, pb,
+        dictionary, dictionarySize,
+        &bo.ReadCallback);
+
+    4.4) In loop call LzmaDecoderCode function:
+
+    for (nowPos = 0; nowPos < outSize;)
+    {
+      unsigned int blockSize = outSize - nowPos;
+      unsigned int kBlockSize = 0x10000;
+      if (blockSize > kBlockSize)
+        blockSize = kBlockSize;
+      res = LzmaDecode((unsigned char *)lzmaInternalData, 
+      ((unsigned char *)outStream) + nowPos, blockSize, &outSizeProcessed);
+      if (res != 0)
+      {
+        printf("\nerror = %d\n", res);
+        break;
+      }
+      nowPos += outSizeProcessed;
+      if (outSizeProcessed == 0)
+      {
+        outSize = nowPos;
+        break;
+      }
+    }
+
+
+EXIT codes
+-----------
+
+LZMA decoder can return on of the following codes:
+
+#define LZMA_RESULT_OK 0
+#define LZMA_RESULT_DATA_ERROR 1
+#define LZMA_RESULT_NOT_ENOUGH_MEM 2
+
+If you use callback function for input data and you return some 
+error code, LZMA Decoder also returns that code.
+
+
+
+LZMA Defines
+------------
+
+_LZMA_IN_CB    - Use callback for input data
+
+_LZMA_OUT_READ - Use read function for output data
+
+_LZMA_LOC_OPT  - Enable local speed optimizations inside code
+
+_LZMA_PROB32   - It can increase speed on some 32-bit CPUs, 
+                 but memory usage will be doubled in that case
+
+_LZMA_UINT32_IS_ULONG  - Define it if int is 16-bit on your compiler
+                         and long is 32-bit.
+
+
+NOTES
+-----
+1) please note that LzmaTest.c doesn't free allocated memory in some cases. 
+But in your real applicaions you must free memory after decompression.
+
+2) All numbers above were calculated for case when int is not more than 
+  32-bit in your compiler. If in your compiler int is 64-bit or larger 
+  probably LZMA can require more memory for some structures.
+
+
+
+C++ LZMA Encoder/Decoder 
+~~~~~~~~~~~~~~~~~~~~~~~~
+C++ LZMA code use COM-like interfaces. So if you want to use it, 
+you can study basics of COM/OLE.
+
+By default, LZMA Encoder contains all Match Finders.
+But for compressing it's enough to have just one of them.
+So for reducing size of compressing code you can define:
+  #define COMPRESS_MF_BT
+  #define COMPRESS_MF_BT4
+and it will use only bt4 match finder.
+
+
+---
+
+http://www.7-zip.org
+http://www.7-zip.org/support.html
+
+

+ 614 - 0
tigcc/pstarter/pst-lzma.h

@@ -0,0 +1,614 @@
+| TIGCC Program Starter - LZMA decompression support
+| Copyright (C) 1999-2004 Igor Pavlov
+| Copyright (C) 2004-2005 Kevin Kofler
+|
+| LICENSE
+| -------
+|
+| LZMA SDK is licensed under two licenses:
+|
+| 1) GNU Lesser General Public License (GNU LGPL)
+| 2) Common Public License (CPL)
+|
+| It means that you can select one of these two licenses and 
+| follow rules of that license.
+|
+| SPECIAL EXCEPTION
+| Igor Pavlov, as the author of this code, expressly permits you 
+| to statically or dynamically link your code (or bind by name) 
+| to the files from LZMA SDK without subjecting your linked 
+| code to the terms of the CPL or GNU LGPL. 
+| Any modifications or additions to files from LZMA SDK, however, 
+| are subject to the GNU LGPL or CPL terms.
+
+| Expected LZMA compression options: -lc0 -pb1 -mfbt2
+
+| GET_UNCOMPRESSED_SIZE inline function
+| INPUT: %a3.l: pointer to compressed data
+| OUTPUT: %d6.l: uncompressed size
+| SIDE EFFECTS: throws a Data Type error if not a valid compressed program
+|               may throw a Memory error
+|               may advance %a3 for later decompression
+| DESTROYS: %d0-%d2/%a0-%a1
+.macro GET_UNCOMPRESSED_SIZE
+| Get the length of the variable.
+moveq.l #0,%d6
+move.w (%a3)+,%d6
+| Get a pointer to the data type of the variable.
+lea.l -1(%a3,%d6.l),%a0
+| Check if it has type "LZMA".
+cmp.b #0xf8,(%a0)
+jbne invalid_archive
+tst.b -(%a0)
+jbne invalid_archive
+cmp.b #'A',-(%a0)
+jbne invalid_archive
+cmp.b #'M',-(%a0)
+jbne invalid_archive
+cmp.b #'Z',-(%a0)
+jbne invalid_archive
+cmp.b #'L',-(%a0)
+jbne invalid_archive
+tst.b -(%a0)
+jbne invalid_archive
+cmp.l #0x2d000080,(%a3)+
+jbne invalid_archive
+tst.b (%a3)+
+jbeq valid_archive
+invalid_archive:
+.word 0xA000+210 | ER_DATATYPE
+valid_archive:
+| Get the uncompressed size.
+move.b (%a3)+,%d1
+move.w (%a3)+,%d6
+tst.b %d6
+jbne invalid_archive
+move.b %d1,%d6
+tst.l (%a3)+
+jbne invalid_archive
+tst.b (%a3)+
+jbne invalid_archive
+.endm
+
+| MEM_TO_MEM_DECOMPRESS inline function
+| INPUT: %a3.l: pointer to compressed data
+|        %a0.l: pointer to buffer for uncompressed data
+|        %d6.l: uncompressed size
+| OUTPUT: %a4.l: pointer to uncompressed data
+| SIDE EFFECTS: may throw a Memory or Data Type error
+| DESTROYS: %d0-%d2/%a0-%a2
+.macro MEM_TO_MEM_DECOMPRESS
+| LzmaDecode(src,dest,OutSize)
+move.l %d6,-(%a7) | OutSize
+pea.l (%a0) | dest
+pea.l (%a3) | src
+| Satisfy output constraint
+movea.l %a0,%a4
+jbsr LzmaDecode
+lea.l 12(%a7),%a7
+| Check return value
+tst.w %d0
+jbne invalid_archive
+.endm
+
+	.text
+	.even
+RangeDecoderBitDecode:
+	movm.l #0x1c30,-(%sp)
+	move.l %a0,%a3
+	move.l %a1,%a2
+	move.l 4(%a1),%d5
+	move.l %d5,%d0
+	moveq.l #11,%d1
+	lsr.l %d1,%d0
+	move.w (%a0),%d3
+	move.w %d3,-(%sp)
+	clr.w -(%sp)
+	move.l %d0,-(%sp)
+	jbsr __mulsi3
+	addq.l #8,%sp
+	move.l %d0,%d1
+	move.l 8(%a2),%d4
+	cmp.l %d4,%d0
+	jbls .L2
+	move.l %d0,4(%a2)
+	move.w #2048,%d0
+	sub.w %d3,%d0
+	lsr.w #5,%d0
+	add.w %d0,%d3
+	move.w %d3,(%a3)
+	cmp.l #16777215,%d1
+	jbhi .L3
+	lsl.l #8,%d4
+	move.l (%a2),%a0
+	or.b (%a0),%d4
+	move.l %d4,8(%a2)
+	addq.l #1,(%a2)
+	move.l %d1,%d0
+	lsl.l #8,%d0
+	move.l %d0,4(%a2)
+.L3:
+	clr.w %d0
+	jbra .L1
+	.even
+.L2:
+	move.l %d5,%d2
+	sub.l %d0,%d2
+	move.l %d2,4(%a2)
+	sub.l %d0,%d4
+	move.l %d4,%d1
+	move.l %d4,8(%a2)
+	move.w %d3,%d0
+	lsr.w #5,%d0
+	sub.w %d0,%d3
+	move.w %d3,(%a3)
+	cmp.l #16777215,%d2
+	jbhi .L5
+	lsl.l #8,%d1
+	move.l (%a2),%a0
+	or.b (%a0),%d1
+	move.l %d1,8(%a2)
+	addq.l #1,(%a2)
+	lsl.l #8,%d2
+	move.l %d2,4(%a2)
+.L5:
+	moveq.l #1,%d0
+.L1:
+	movm.l (%sp)+,#0xc38
+	rts
+	.even
+RangeDecoderBitTreeDecode:
+	movm.l #0x1f00,-(%sp)
+	move.l %a0,%d7
+	move.w %d0,%d5
+	move.l %a1,%d6
+	moveq.l #1,%d1
+	move.w %d0,%d4
+	jbra .L7
+	.even
+.L11:
+	move.w %d1,%d3
+	add.w %d1,%d3
+	move.w %d1,%a0
+	add.l %a0,%a0
+	move.l %d6,%a1
+	lea (%a0,%d7.l),%a0
+	jbsr RangeDecoderBitDecode
+	move.w %d3,%d1
+	add.w %d0,%d1
+	subq.w #1,%d4
+.L7:
+	tst.w %d4
+	jbgt .L11
+	moveq.l #1,%d0
+	lsl.w %d5,%d0
+	sub.w %d0,%d1
+	move.w %d1,%d0
+	movm.l (%sp)+,#0xf8
+	rts
+	.even
+LzmaLenDecode:
+	movm.l #0x1820,-(%sp)
+	move.l %a0,%a2
+	move.l %a1,%d3
+	move.w %d0,%d4
+	jbsr RangeDecoderBitDecode
+	tst.w %d0
+	jbne .L13
+	move.w %d4,%d1
+	ext.l %d1
+	lsl.l #4,%d1
+	move.l %d3,%a1
+	moveq.l #3,%d0
+	lea 4(%a2,%d1.l),%a0
+	jbsr RangeDecoderBitTreeDecode
+	jbra .L12
+	.even
+.L13:
+	move.l %d3,%a1
+	lea (2,%a2),%a0
+	jbsr RangeDecoderBitDecode
+	tst.w %d0
+	jbne .L14
+	move.w %d4,%d1
+	ext.l %d1
+	lsl.l #4,%d1
+	move.l %d3,%a1
+	moveq.l #3,%d0
+	lea 36(%a2,%d1.l),%a0
+	jbsr RangeDecoderBitTreeDecode
+	addq.w #8,%d0
+	jbra .L12
+	.even
+.L14:
+	move.l %d3,%a1
+	moveq.l #8,%d0
+	lea (68,%a2),%a0
+	jbsr RangeDecoderBitTreeDecode
+	add.w #16,%d0
+.L12:
+	movm.l (%sp)+,#0x418
+	rts
+	.even
+	.globl	LzmaDecode
+LzmaDecode:
+	lea (-3692,%sp),%sp
+	movm.l #0x1f3a,-(%sp)
+	clr.w 50(%sp)
+	clr.w 48(%sp)
+	moveq.l #1,%d7
+	move.l %d7,44(%sp)
+	move.l %d7,40(%sp)
+	move.l %d7,36(%sp)
+	sub.l %a6,%a6
+	moveq.l #0,%d0
+	lea (64,%sp),%a0
+	jbra .L16
+	.even
+.L20:
+	move.w #1024,(%a0)+
+	addq.l #1,%d0
+.L16:
+	cmp.l #1830,%d0
+	jbcs .L20
+	lea (52,%sp),%a1
+	move.l 3732(%sp),(%a1)
+	clr.l 8(%a1)
+	moveq.l #-1,%d0
+	move.l %d0,4(%a1)
+	moveq.l #4,%d1
+	jbra .L21
+	.even
+.L25:
+	move.l 8(%a1),%d0
+	lsl.l #8,%d0
+	move.l (%a1),%a0
+	or.b (%a0),%d0
+	move.l %d0,8(%a1)
+	addq.l #1,(%a1)
+	subq.w #1,%d1
+.L21:
+	tst.w %d1
+	jbge .L25
+	jbra .L102
+	.even
+.L101:
+	move.w %a6,%d5
+	and.w #1,%d5
+	lea (52,%sp),%a4
+	move.w 50(%sp),%d3
+	ext.l %d3
+	move.l %d3,%d4
+	add.l %d3,%d4
+	move.w %d5,%a3
+	lea (%a3,%d4.l),%a0
+	add.l %a0,%a0
+	moveq.l #64,%d6
+	add.l %sp,%d6
+	move.l %a4,%a1
+	add.l %d6,%a0
+	jbsr RangeDecoderBitDecode
+	tst.w %d0
+	jbne .L30
+	move.l %sp,%d6
+	add.l #2188,%d6
+	cmp.w #3,50(%sp)
+	jbgt .L31
+	clr.w 50(%sp)
+	jbra .L32
+	.even
+.L31:
+	cmp.w #9,50(%sp)
+	jbgt .L33
+	subq.w #3,50(%sp)
+	jbra .L32
+	.even
+.L33:
+	subq.w #6,50(%sp)
+.L32:
+	moveq.l #1,%d0
+	tst.w 48(%sp)
+	jbeq .L47
+	move.l %a6,%d0
+	sub.l %d7,%d0
+	move.l 3736(%sp),%a0
+	move.b (%a0,%d0.l),%d5
+	moveq.l #1,%d4
+.L36:
+	move.b %d5,%d3
+	lsr.b #7,%d3
+	and.w #1,%d3
+	lsl.b #1,%d5
+	addq.w #1,%d3
+	move.w %d3,%d0
+	ext.l %d0
+	subq.w #1,%d3
+	lsl.l #8,%d0
+	move.l %d0,%a1
+	lea (%a1,%d4.w),%a0
+	add.l %a0,%a0
+	move.l %a4,%a1
+	add.l %d6,%a0
+	jbsr RangeDecoderBitDecode
+	lsl.w #1,%d4
+	or.w %d0,%d4
+	cmp.w %d3,%d0
+	jbeq .L38
+	jbra .L40
+	.even
+.L43:
+	move.w %d4,%d3
+	add.w %d4,%d3
+	move.w %d4,%a0
+	add.l %a0,%a0
+	move.l %a4,%a1
+	lea (%a0,%d6.l),%a0
+	jbsr RangeDecoderBitDecode
+	move.w %d3,%d4
+	or.w %d0,%d4
+.L40:
+	cmp.w #255,%d4
+	jble .L43
+	jbra .L37
+	.even
+.L38:
+	cmp.w #255,%d4
+	jble .L36
+.L37:
+	move.b %d4,%d3
+	clr.w 48(%sp)
+	jbra .L46
+	.even
+.L47:
+	move.w %d0,%d3
+	add.w %d0,%d3
+	move.w %d0,%a0
+	add.l %a0,%a0
+	move.l %a4,%a1
+	lea (%a0,%d6.l),%a0
+	jbsr RangeDecoderBitDecode
+	or.w %d3,%d0
+	cmp.w #255,%d0
+	jble .L47
+	move.b %d0,%d3
+.L46:
+	move.l 3736(%sp),%d0
+	move.b %d3,(%a6,%d0.l)
+	jbra .L104
+	.even
+.L30:
+	move.w #1,48(%sp)
+	move.l %d6,%a2
+	add.l %d4,%a2
+	move.l %a4,%a1
+	lea (48,%a2),%a0
+	jbsr RangeDecoderBitDecode
+	tst.w %d0
+	jbeq .L53
+	move.l %a4,%a1
+	lea (72,%a2),%a0
+	jbsr RangeDecoderBitDecode
+	tst.w %d0
+	jbne .L54
+	lsl.l #2,%d3
+	move.l %d6,%d0
+	add.l %d3,%d0
+	lea (%a3,%a3.l),%a0
+	lea (%a0,%d0.l),%a0
+	move.l %a4,%a1
+	lea (144,%a0),%a0
+	jbsr RangeDecoderBitDecode
+	tst.w %d0
+	jbne .L59
+	moveq.l #1,%d0
+	cmp.w #0,%a6
+	jbeq .L15
+	moveq.l #9,%d0
+	cmp.w #6,50(%sp)
+	jble .L58
+	moveq.l #11,%d0
+.L58:
+	move.w %d0,50(%sp)
+	move.l %a6,%d0
+	sub.l %d7,%d0
+	move.l 3736(%sp),%a0
+	move.b (%a0,%d0.l),(%a6,%a0.l)
+.L104:
+	addq.l #1,%a6
+	jbra .L102
+	.even
+.L54:
+	move.l %a4,%a1
+	lea (96,%a2),%a0
+	jbsr RangeDecoderBitDecode
+	move.l 44(%sp),%d1
+	tst.w %d0
+	jbeq .L61
+	move.l %a4,%a1
+	lea (120,%a2),%a0
+	jbsr RangeDecoderBitDecode
+	move.l 40(%sp),%d1
+	tst.w %d0
+	jbeq .L63
+	move.l 36(%sp),%d1
+	move.l 40(%sp),36(%sp)
+.L63:
+	move.l 44(%sp),40(%sp)
+.L61:
+	move.l %d7,44(%sp)
+	move.l %d1,%d7
+.L59:
+	move.w %d5,%d0
+	move.l %a4,%a1
+	lea (1608,%sp),%a0
+	jbsr LzmaLenDecode
+	move.w %d0,%d5
+	moveq.l #8,%d0
+	cmp.w #6,50(%sp)
+	jble .L65
+	moveq.l #11,%d0
+.L65:
+	move.w %d0,50(%sp)
+	jbra .L66
+	.even
+.L53:
+	move.l 40(%sp),36(%sp)
+	move.l 44(%sp),40(%sp)
+	move.l %d7,44(%sp)
+	moveq.l #7,%d0
+	cmp.w #6,50(%sp)
+	jble .L68
+	moveq.l #10,%d0
+.L68:
+	move.w %d0,50(%sp)
+	move.w %d5,%d0
+	move.l %a4,%a1
+	lea (1028,%sp),%a0
+	jbsr LzmaLenDecode
+	move.w %d0,%d5
+	cmp.w #3,%d0
+	jble .L69
+	moveq.l #3,%d0
+.L69:
+	ext.l %d0
+	lsl.l #7,%d0
+	move.l %d6,%a0
+	add.l %d0,%a0
+	move.l %a4,%a1
+	moveq.l #6,%d0
+	lea (192,%a0),%a0
+	jbsr RangeDecoderBitTreeDecode
+	move.w %d0,%d2
+	move.w %d0,%d1
+	ext.l %d1
+	move.l %d1,%d7
+	cmp.w #3,%d0
+	jble .L93
+	move.w %d0,%d4
+	asr.w #1,%d4
+	move.w %d4,%a3
+	subq.w #1,%a3
+	moveq.l #1,%d7
+	and.l %d1,%d7
+	moveq.l #2,%d0
+	or.l %d0,%d7
+	clr.l %d0
+	move.w %a3,%d0
+	lsl.l %d0,%d7
+	cmp.w #13,%d2
+	jbgt .L71
+	move.l %d7,%d0
+	add.l %d7,%d0
+	add.l %d6,%d0
+	add.l %d1,%d1
+	sub.l %d1,%d0
+	move.l %d0,%a2
+	lea (702,%a2),%a2
+	moveq.l #1,%d3
+	clr.w %d6
+	clr.w %d4
+	jbra .L72
+	.even
+.L76:
+	move.w %d3,%a0
+	add.l %a0,%a0
+	move.l %a4,%a1
+	lea (%a2,%a0.l),%a0
+	jbsr RangeDecoderBitDecode
+	add.w %d3,%d3
+	add.w %d0,%d3
+	lsl.w %d4,%d0
+	or.w %d0,%d6
+	addq.w #1,%d4
+.L72:
+	cmp.w %a3,%d4
+	jblt .L76
+	jbra .L103
+	.even
+.L71:
+	move.l 4(%a4),%d0
+	move.l 8(%a4),%d1
+	moveq.l #0,%d3
+	move.w %d4,%d2
+	subq.w #5,%d2
+	jbra .L79
+	.even
+.L85:
+	lsr.l #1,%d0
+	add.l %d3,%d3
+	cmp.l %d1,%d0
+	jbhi .L83
+	sub.l %d0,%d1
+	moveq.l #1,%d4
+	or.l %d4,%d3
+.L83:
+	cmp.l #16777215,%d0
+	jbhi .L81
+	lsl.l #8,%d0
+	lsl.l #8,%d1
+	move.l (%a4),%a0
+	or.b (%a0),%d1
+	addq.l #1,(%a4)
+.L81:
+	subq.w #1,%d2
+.L79:
+	tst.w %d2
+	jbgt .L85
+	move.l %d0,4(%a4)
+	move.l %d1,8(%a4)
+	lsl.l #4,%d3
+	add.l %d3,%d7
+	lea (996,%sp),%a2
+	moveq.l #1,%d3
+	clr.w %d6
+	clr.w %d4
+	jbra .L87
+	.even
+.L91:
+	move.w %d3,%a0
+	add.l %a0,%a0
+	move.l %a4,%a1
+	lea (%a2,%a0.l),%a0
+	jbsr RangeDecoderBitDecode
+	add.w %d3,%d3
+	add.w %d0,%d3
+	lsl.w %d4,%d0
+	or.w %d0,%d6
+	addq.w #1,%d4
+.L87:
+	cmp.w #4,%d4
+	jblt .L91
+.L103:
+	move.l %d7,%a0
+	lea (%a0,%d6.w),%a0
+	move.l %a0,%d7
+.L93:
+	addq.l #1,%d7
+.L66:
+	tst.l %d7
+	jbeq .L28
+	moveq.l #1,%d0
+	cmp.l %d7,%a6
+	jbcs .L15
+	addq.w #2,%d5
+	move.l 3736(%sp),%a0
+	sub.l %d7,%a0
+	lea (%a6,%a0.l),%a0
+.L96:
+	move.l 3736(%sp),%a1
+	move.b (%a0)+,(%a6,%a1.l)
+	addq.l #1,%a6
+	subq.w #1,%d5
+	tst.w %d5
+	jble .L102
+	cmp.l 3740(%sp),%a6
+	jbcs .L96
+.L102:
+	cmp.l 3740(%sp),%a6
+	jbcs .L101
+.L28:
+	clr.w %d0
+.L15:
+	movm.l (%sp)+,#0x5cf8
+	lea (3692,%sp),%sp
+	rts

+ 360 - 0
tigcc/pstarter/pst-shrn.h

@@ -0,0 +1,360 @@
+| TIGCC Program Starter - Shrink92 decompression support
+| SHRINK92 - Copyright 1998, 1999 David Kuehling
+| Adaptation for TI-89/92+ - Copyright 2002, 2003, 2004, 2005 Patrick Pelissier
+| Adaptation for pstarter - Copyright 2005 Kevin Kofler
+| Additional Optimizations - By Samuel Stearley
+|
+| This file is based on the SHRINK92 Library.
+|
+| The SHRINK92 Library is free software; you can redistribute it and/or modify
+| it under the terms of the GNU Lesser General Public License as published by
+| the Free Software Foundation; either version 2.1 of the License, or (at your
+| option) any later version.
+|
+| The SHRINK92 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 Lesser General Public
+| License for more details.
+|
+| You should have received a copy of the GNU Lesser General Public License
+| along with the SHRINK92 Library; see the file COPYING.LIB.  If not, write to
+| the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+| MA 02111-1307, USA.
+
+| Version : 1.00.P4-tigcc-2 by Kevin Kofler Apr 23 2005
+| * adjust calling convention for pstarter changes
+
+| Version : 1.00.P4-tigcc-1 by Kevin Kofler Mar 18 2005
+| * change tios.h to doorsos.h
+| * delete TI-92 support
+| * delete archive pack support
+| * allocate Table of Unresolved Elements on the stack
+| * use HeapAllocPtr to allocate archive descriptor
+| * throw an error if allocating the archive descriptor fails
+| * don't allocate memory in Extract
+| * free archive descriptor at end of Extract, delete CloseArchive
+| * always extract first section
+| * read uncompressed size in OpenArchive
+| * adjust calling conventions for pstarter
+| * use nostub ROM_CALL convention
+| * convert to GNU as
+
+| Version : 1.00.P4 by Patrick Pelissier Feb 10 2005
+| Version : 1.00.P3 by Patrick Pelissier Nov 10 2004
+| Version : 1.00.P2 by Patrick Pelissier Nov 24 2003
+
+.equ RLE_ESC,256
+.equ RLE_BITS,5
+.equ REP_ESC,257
+.equ START_REP_BITS,4
+.equ START_REP_CODES,16
+.equ REP_CODES,64
+.equ MIN_REP,3
+.equ CODES,256+REP_CODES+1
+
+| GET_UNCOMPRESSED_SIZE inline function
+| INPUT: %a3.l: pointer to compressed data
+| OUTPUT: %d6.l: uncompressed size
+| SIDE EFFECTS: throws a Data Type error if not a valid compressed program
+|               may throw a Memory error
+|               may advance %a3 for later decompression
+| DESTROYS: %d0-%d2/%a0-%a1
+.macro GET_UNCOMPRESSED_SIZE
+| Get the length of the variable.
+moveq.l #0,%d6
+move.w (%a3)+,%d6
+| Get a pointer to the data type of the variable.
+lea.l -1(%a3,%d6.l),%a0
+| Check if it has type "SHRN".
+cmp.b #0xf8,(%a0)
+jbne invalid_archive
+tst.b -(%a0)
+jbne invalid_archive
+cmp.b #'N',-(%a0)
+jbne invalid_archive
+cmp.b #'R',-(%a0)
+jbne invalid_archive
+cmp.b #'H',-(%a0)
+jbne invalid_archive
+cmp.b #'S',-(%a0)
+jbne invalid_archive
+tst.b -(%a0)
+jbeq valid_archive
+invalid_archive:
+.word 0xA000+210 | ER_DATATYPE
+valid_archive:
+bsr OpenArchive
+.endm
+
+| MEM_TO_MEM_DECOMPRESS inline function
+| INPUT: %a3.l: pointer to compressed data
+|        %a0.l: pointer to buffer for uncompressed data
+|        %d6.l: uncompressed size
+| OUTPUT: %a4.l: pointer to uncompressed data
+| SIDE EFFECTS: may throw a Memory or Data Type error
+| DESTROYS: %d0-%d2/%a0-%a2
+.macro MEM_TO_MEM_DECOMPRESS
+bsr Extract
+.endm
+
+|| **************************************************************************
+|  OpenArchive
+| --------------------------------------------------------------------------
+|  Input:  %a3.l = pointer to archive
+|  Output: %a3.l = pointer to archive descriptor
+|          %d6.l = length of section
+|  Destroys: %d1-%d2/%a0-%a1
+|  Throws ER_MEMORY if not enough memory.
+| /
+OpenArchive:	movem.l	%d0/%d3-%d5/%d7/%a2/%a4/%a6,-(%a7)	
+		movea.l	%a7,%a6			|  %a6 = saved SP for removing stack arguments later
+		movea.l	%a3,%a2			|  %a2 = pointer to archive (%a2 isn't modified by ROM functions)
+
+	|| ***** Initialize The Table Of The Unresolved Leaves/Junctions| /
+		|  Table's format: <weight (word)> <address (word)> ...
+                |   <address>: pointer,relative to the huffman tree's begin
+                |              if the MSB is set: it represents a compression CODE (character)
+		| /
+	     ||  allocate memory for the table| /
+		lea	-(CODES*4)(%a7),%a7
+		movea.l	%a7,%a3
+		
+	     ||  uncompress frequency table from archive's begin into that table| /
+		|  %a2 = pointer to archive begin (RLE compressed freqency table| each byte is a frequency) -- input
+		|  %a3 = pointer to Unresolved Table -- output
+		move.w	#0x8000,%d7		|  %d7 = <address>-counter (code | 0x8000)
+		movea.l	%a3,%a1			|  %a1 = output-pointer (is increased whereas %a3 points to the table's begin)
+		clr.w	%d1			|  %d1.w = one byte (high byte has to be cleared)
+		moveq	#-1,%d3			|  %d3.w = number of entries in table - 1
+OAExtrFreqLoop:	clr.w	%d0			   |  %d0 = RLE repetition length - 1 (0 = ONE character -- no RLE)
+		move.b	(%a2)+,%d1		   |  %d1 = current byte / RLE ESC byte
+		cmpi.w	#0xE0,%d1 		   |  is it an RLE ESC character ?
+		blt.s	OA__RLEloop		      |  (if it isn't: cylcle one time through RLE loop)
+		andi.w	#0x001F,%d1		      |  extract RLE length from RLE ESC byte
+		move.w	%d1,%d0			 
+		move.b	(%a2)+,%d1		      |  read RLE byte
+OA__RLEloop:	tst.w	%d1			         |  don't add entries with a frequency of zero
+		beq.s	OA____Skip
+		move.w	%d1,(%a1)+                        |  copy frequency and <address> (%d7) to output table (%a1)
+		move.w	%d7,(%a1)+
+		addq.w	#1,%d3			         |  (%d3 = number of table entries)
+OA____Skip:	addq.w	#1,%d7
+		dbra	%d0,OA__RLEloop
+		cmpi.w	#CODES+0x8000,%d7
+		blt.s	OAExtrFreqLoop
+
+	     ||  align input address on even address| /
+		move.l	%a2,%d1
+		addq.l	#1,%d1
+		bclr.b	#0,%d1
+		movea.l	%d1,%a2
+
+	|| ***** Create Archive Descriptor,Containing the Huffman Tree| /
+		|  %d3 = number of entries in Table of Unresolved Elements - 1
+		|  %a2 = aligned pointer directly after the RLE compressed frequency table in the input archive
+		|  %a3 = pointer to first entry in Table of Unresolved Elements
+	     ||  allocate memory for archive descriptor| /
+		move.w	(%a2)+,-(%a7)		|  at the current position in the archive the size of the descriptor is stored
+		clr.w	-(%a7)			|  it is a long value
+		move.l	0xa2*4(%a5),%a0		|  HeapAllocPtr
+		jsr	(%a0)
+		move.l	%a0,%d5			|  %a0 = %d5 = pointer to archive descriptor
+		beq.s	OAError
+
+		move.l	%a2,(%a0)+		|  store archive address into descriptor
+		movea.l	%a0,%a1			|  %a1 = working pointer| %a0 = pointer to huffman tree
+		clr.w	(%a1)+			|  leave space for root pointer
+		moveq	#0,%d6			|  extend 2(%a2) to longword in %d6
+		move.w	2(%a2),%d6		|  %d6 = length of section
+
+	     ||  create the huffman tree| /
+OAHuffTreeLoop:	||  find the two elements with the lowest weight| /
+		bsr.s	OAGetMinWeight		   |  %a2 = pointer to min element| %d0 = its weight
+		move.w	%d0,%d2			   |  %d2 = lowest weight 1
+		move.w	2(%a2),%d4		   |  %d4 = relative pointer to lowest elm 1
+		move.l	(%a3)+,(%a2) 	           |  "delete" element from unresolved list (replace it by first elm)
+		subq.w	#1,%d3			   |  decrease number of entries
+		bmi.s	OAHuffTreeEnd		   |  if number of entries was #1: end of Huffman Tree creation
+		bsr.s	OAGetMinWeight		   |  %a2 = pointer to min element| %d0 = it's weight
+	
+		||  replace that element by a newly created junction of the two min elements| /
+		|  %d2 = lowest weight1
+		|  %d4 = relative pointer to lowest elm 1
+		|  %a2 = pointer to entry of loweset elm1 in unresolved table: (%a2) = weight| 2(%a2) = pointer
+		add.w	%d2,(%a2)+		   |  weight of min2 += weight of min1
+		move.l	%a1,%d1		   	   |  %d1 = relative address of new junction
+		sub.l	%a0,%d1
+		move.w	%d4,(%a1)+		   |  new Huffman Tree element: set left branch of junction
+		move.w	(%a2),(%a1)+		   |                            set right branch of junction
+		move.w	%d1,(%a2)		   |  entry in Unresolved Table: set the pointer to the Huffman Tree element
+		bra.s	OAHuffTreeLoop		   |  continue...
+	
+OAHuffTreeEnd:	move.w	%d4,(%a0)  		|  store root pointer to archive descriptor
+
+		movea.l	%d5,%a3			|  %a3 = pointer to archive descriptor
+		movea.l	%a6,%a7			|  restore stored %a7 -- remove all stack elements
+		movem.l	(%a7)+,%d0/%d3-%d5/%d7/%a2/%a4/%a6	|  restore registers
+		rts
+OAError:
+	.word 0xa000+670 |ER_MEMORY
+
+	| 
+ 	|  Get the element witht the minimum weight in the table of unresolved tree elements.
+ 	|  Input:  %a3 = pointer to first table entry
+	|          %d3 = number of entries - 1
+  	|  Output: %a2 = pointer to element with the minimum weight < 32767 or NULL if no such elements are left
+	|          %d0 = minimum weight 
+	|  %a4/%d1 destroyed!
+	| /
+OAGetMinWeight:	moveq	#-1,%d0			|  %d0 = minimum weight = 32768 (unsigned)
+		move.w	%d3,%d1			|  %d1 = counter
+		movea.l	%a3,%a4			|  %a4 = scanning pointer
+OACmpLoop:	cmp.w	(%a4),%d0		   |  current element's weight less than minimum weight ?
+		bls.s	OA__NotLess
+		movea.l	%a4,%a2			   |  minimum element found: update %a2 and %d0
+		move.w	(%a4),%d0
+OA__NotLess:	addq.l	#4,%a4			   |  go to next element
+		dbra	%d1,OACmpLoop
+		rts
+
+
+|| *************************************************************************************************
+|  Bitwise Input
+| /
+|| *************************************************************************************************
+|  ReadBit
+| --------------------------------------------------------------------------------------------------
+|  Input:  %a2.l = pointer to next byte
+| 	   %d0.b = contents of current byte
+| 	   %d1.b = last bit number
+|  Output: zeroflag set or cleared,depending on value of bit,
+|          %a2,%d0,%d1 adjusted to current bit
+| /
+ReadBit:
+		subq.b	#1,%d1			|  increase bit number  --  go to current bit
+		bne.s	RBSameByte
+			move.b	(%a2)+,%d0	|  read new byte,begin again with bit #0
+			moveq	#8,%d1
+RBSameByte:	lsr.b	#1,%d0			|  test bit -- set carry/extend flag accordingly
+		rts
+
+|| *************************************************************************************************
+|  ReadNBits
+| --------------------------------------------------------------------------------------------------
+|  Input:  %a2.l = pointer to next byte
+| 	   %d0.b = contents of current byte
+| 	   %d1.b = last bit number
+|          %d7.w = number of bits to read
+|  Output: %a2,%d0,%d1 adjusted to last bit of bits read
+|          %d7 = -1 
+|          %d3 = read bits (first read bit is high bit)
+| /
+ReadNBits:	subq.w	#1,%d7		|  %d7 = counter
+		moveq	#0,%d3		|  %d3 = bits
+
+RNBReadLoop:	bsr.s	ReadBit		|  read a bit
+		addx.l  %d3,%d3		|  move in the bit
+RNB__ZeroBit:	dbra	%d7,RNBReadLoop
+		rts
+		
+
+|| *************************************************************************************************
+|  Extract
+| --------------------------------------------------------------------------------------------------
+|  Input:  %a3.l = pointer to archive descriptor
+|          %a0.l = address of extraction destination
+|          %d6.l = length of section
+|  Output: %a4.l = address of extraction destination
+|  Throws ER_DATATYPE for an invalid archive.
+|  Destroys: %d0-%d2/%a0-%a2
+| /
+Extract: 	movem.l	%d3-%d7/%a3/%a6,-(%a7)
+
+		||  Prepare Extraction...| /
+		move.l	(%a3),%a2			|  %a2 = pointer to archive data (after frequency table)
+		adda.w	(%a2),%a2			|  %a2 = address of first section (expect offset <32768)
+|SNS changed it to a 1
+		moveq	#1,%d1			|  %d1 = bit number (1 forces 'ReadBit' to read new byte into %d0)
+		moveq	#0,%d4			|  %d4 = input offset
+		movea.l	%a0,%a1			|  %a1 = working destination pointer
+
+	    |  %a0 = address of destination memory block
+	    |  %a1 = address of destination memory block (working pointer that is increased during extraction)
+	    |  %a2 = address of archive section begin (is increased during extraction)
+	    |  %a3 = pointer to huffman tree begin (within descriptor)
+	    |  %d0 = current byte
+	    |  %d1 = bit number within current byte '%d0'
+	    |  %d2 = handle of allocated destination block or original value 
+	    |  %d6 = length of section
+	    |  %d4 = current input offset
+	|| ***** Extraction Loop| /
+EXExtractLoop:
+	     ||  check whether end of file| /
+		cmp.l	%d6,%d4
+		beq.s	EXExtractEnd
+		bgt.s	EXError
+		
+	     ||  read a Huffman code| /
+		moveq   #0,%d7
+
+EX__HuffLoop: 		move.w	4(%a3, %d7.w),%d7|  %d7 = relative pointer to root element
+						 |  if bit #15 in "address" is set -> it is a leaf| %d7 contains the code
+			bmi.s	EX__HuffDone	 |  %d7 points to current element| (%d7) = left branch 2(%d7) = right branch
+			bsr.s	ReadBit
+			bcc.s	EX__HuffLoop
+			addq.w	#2,%d7	|  continue with right branch
+			bra.s	EX__HuffLoop
+|SNS: unlike the previous version it has not yet cleared the high bit of d7
+EX__HuffDone:	|  %d7.w = current code
+		cmp.w	#256+32768,%d7		|  check code
+		beq.s	EX__RLE			   |  code = 256: RLE
+		bgt.s	EX__Rep			   |  code > 256: Rep
+
+		||  'code' (%d7) is a character| /
+		move.b	%d7,(%a1)+		   |  copy code to destination
+		addq.l	#1,%d4
+		bra.s	EXExtractLoop
+
+		||  RLE| /
+EX__RLE:	move.b	-1(%a1),%d5		   |  %d5 = RLE repeating character
+		moveq	#RLE_BITS,%d7		   |  read length of RLE sequence
+		bsr	ReadNBits		   
+		addq.w	#1,%d3			   |  %d3 = RLE repetition length - 1
+		add.l	%d3,%d4
+		addq.l  #1,%d4
+
+EX____RLEloop:		move.b	%d5,(%a1)+		      |  output characters...
+			dbra	%d3,EX____RLEloop
+		bra.s	EXExtractLoop
+
+		||  Repetition encoding| /
+EX__Rep:		sub.w	#32768+REP_ESC-MIN_REP+1,%d7   |  %d7 = length of repetition - 1
+		move.w	%d7,-(%a7)		   	|  store it on the stack
+		moveq	#START_REP_BITS-1,%d7	  	|  get the number of bits that is required for coding an offset
+		moveq	#START_REP_CODES/2,%d3
+EX____IncrBitN:		addq.l	#1,%d7
+			add.l	%d3,%d3
+			move.l	%d3,%d5
+			addq.l	#MIN_REP,%d5
+			cmp.l	%d4,%d5		|  codable range is too small ? --> increase bit number and try again
+			bls.s	EX____IncrBitN
+						|  %d7 = number of bits
+		bsr	ReadNBits		|  %d3 = repetition offset
+		move.w	(%a7)+,%d7		|  %d7 = length of repetition - 1
+		lea	0(%a0,%d3.l),%a4		|  %a4 = pointer to repetition
+		add.l	%d7,%d4
+		addq.l  #1,%d4
+EX____RepCopyLp:	move.b	(%a4)+,(%a1)+	|  copy repetition to current output position...
+			dbra	%d7,EX____RepCopyLp
+		bra.s	EXExtractLoop
+
+EXError:		suba.l	%a0,%a0			|  %a0 = zero (indicates error)
+EXExtractEnd:	movea.l	%a0,%a4
+		pea.l	(%a3)			|  Free Archive Descriptor
+		move.l	0xa3*4(%a5),%a0		|  HeapFreePtr
+		jsr	(%a0)
+		addq.l	#4,%a7
+		move.l	%a4,%d0
+		beq	invalid_archive
+		movem.l	(%a7)+,%d3-%d7/%a3/%a6
+		rts

+ 404 - 0
tigcc/pstarter/pst-ttuf.h

@@ -0,0 +1,404 @@
+| TIGCC Program Starter - ttunpack decompression support (fast & large version)
+| Copyright (C) 2004-2005 Samuel Stearley, Kevin Kofler
+|
+| THE LICENSE:
+|
+|               wxWindows Library Licence, Version 3.1
+|               ======================================
+|
+| Copyright (C) 1998-2005 Julian Smart, Robert Roebling et al
+|
+| Everyone is permitted to copy and distribute verbatim copies
+| of this licence document, but changing it is not allowed.
+|
+|                      WXWINDOWS LIBRARY LICENCE
+|    TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+|
+| This library is free software; you can redistribute it and/or modify it
+| under the terms of the GNU Library General Public Licence as published by
+| the Free Software Foundation; either version 2 of the Licence, 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 Licence for more details.
+|
+| You should have received a copy of the GNU Library General Public Licence
+| along with this software, usually in a file named COPYING.LIB.  If not,
+| write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+| Boston, MA 02111-1307 USA.
+|
+| EXCEPTION NOTICE
+|
+| 1. As a special exception, the copyright holders of this library give
+| permission for additional uses of the text contained in this release of
+| the library as licenced under the wxWindows Library Licence, applying
+| either version 3.1 of the Licence, or (at your option) any later version of
+| the Licence as published by the copyright holders of version
+| 3.1 of the Licence document.
+|
+| 2. The exception is that you may use, copy, link, modify and distribute
+| under your own terms, binary object code versions of works based
+| on the Library.
+|
+| 3. If you copy code from files distributed under the terms of the GNU
+| General Public Licence or the GNU Library General Public Licence into a
+| copy of this library, as this licence permits, the exception does not
+| apply to the code that you add in this way.  To avoid misleading anyone as
+| to the status of such modified files, you must delete this exception
+| notice from such code and/or adjust the licensing conditions notice
+| accordingly.
+|
+| 4. If you write modifications of your own for this library, it is your
+| choice whether to permit this exception to apply to your modifications. 
+| If you do not wish that, you must delete the exception notice from such
+| code and/or adjust the licensing conditions notice accordingly.
+
+| GET_UNCOMPRESSED_SIZE inline function
+| INPUT: %a3.l: pointer to compressed data
+| OUTPUT: %d6.l: uncompressed size
+| SIDE EFFECTS: throws a Data Type error if not a valid compressed program
+|               may throw a Memory error
+|               may advance %a3 for later decompression
+| DESTROYS: %d0-%d2/%a0-%a1
+.macro GET_UNCOMPRESSED_SIZE
+| Get the length of the variable.
+moveq.l #0,%d6
+move.w (%a3)+,%d6
+| Get a pointer to the data type of the variable.
+lea.l -1(%a3,%d6.l),%a0
+| Check if it has type "ppg".
+cmp.b #0xf8,(%a0)
+jbne invalid_archive
+tst.b -(%a0)
+jbne invalid_archive
+cmp.b #'g',-(%a0)
+jbne invalid_archive
+moveq.l #'p',%d0
+cmp.b -(%a0),%d0
+jbne invalid_archive
+cmp.b -(%a0),%d0
+jbne invalid_archive
+tst.b -(%a0)
+jbeq valid_archive
+| We don't need to check the magic number in the ttunpack header,
+| the decompression routine does that already.
+invalid_archive:
+.word 0xA000+210 | ER_DATATYPE
+valid_archive:
+| Get the uncompressed size.
+move.w (%a3),%d6
+rol.w #8,%d6
+.endm
+
+| MEM_TO_MEM_DECOMPRESS inline function
+| INPUT: %a3.l: pointer to compressed data
+|        %a0.l: pointer to buffer for uncompressed data
+|        %d6.l: uncompressed size
+| OUTPUT: %a4.l: pointer to uncompressed data
+| SIDE EFFECTS: may throw a Memory or Data Type error
+| DESTROYS: %d0-%d2/%a0-%a2
+.macro MEM_TO_MEM_DECOMPRESS
+pea.l (%a0) | destination
+pea.l (%a3) | source
+move.l %a0,%a4 | satisfy output constraint
+jbsr ttunpack_decompress
+addq.l #8,%a7
+tst.w %d0
+jbne invalid_archive
+.endm
+
+.text
+ttunpack_decompress:
+	.word	18663
+	.word	7998
+	.word	11375
+	.word	44
+	.word	10863
+	.word	48
+	.word	18414
+	.word	15
+	.word	31232
+	.word	6702
+	.word	6
+	.word	32264
+	.word	28676
+	.word	3118
+	.word	84
+	.word	2
+	.word	26236
+	.word	3118
+	.word	80
+	.word	3
+	.word	26228
+	.word	28678
+	.word	3118
+	.word	8
+	.word	10
+	.word	26218
+	.word	3118
+	.word	128
+	.word	11
+	.word	26210
+	.word	28679
+	.word	29184
+	.word	4654
+	.word	9
+	.word	10241
+	.word	20801
+	.word	25172
+	.word	28677
+	.word	29184
+	.word	4654
+	.word	12
+	.word	8769
+	.word	23361
+	.word	28230
+	.word	29696
+	.word	2498
+	.word	21314
+	.word	-6086
+	.word	-6083
+	.word	28672
+	.word	4115
+	.word	19958
+	.word	16
+	.word	18938
+	.word	60
+	.word	18948
+	.word	26116
+	.word	18938
+	.word	82
+	.word	20463
+	.word	-260
+	.word	9295
+	.word	16922
+	.word	28672
+	.word	29191
+	.word	30208
+	.word	451
+	.word	5312
+	.word	21315
+	.word	26362
+	.word	21056
+	.word	20937
+	.word	-14
+	.word	9295
+	.word	7198
+	.word	20180
+	.word	28672
+	.word	20463
+	.word	260
+	.word	17408
+	.word	19679
+	.word	31992
+	.word	20085
+	.word	6848
+	.word	7942
+	.word	12319
+	.word	7198
+	.word	4102
+	.word	-4504
+	.word	4610
+	.word	-15872
+	.word	-19963
+	.word	26348
+	.word	21902
+	.word	7198
+	.word	-25020
+	.word	25092
+	.word	7198
+	.word	20551
+	.word	24832
+	.word	272
+	.word	13824
+	.word	21312
+	.word	26488
+	.word	24832
+	.word	262
+	.word	20992
+	.word	26156
+	.word	22851
+	.word	26044
+	.word	22595
+	.word	4614
+	.word	18497
+	.word	7966
+	.word	12831
+	.word	4638
+	.word	7169
+	.word	-4439
+	.word	28927
+	.word	4097
+	.word	16129
+	.word	4639
+	.word	16885
+	.word	0
+	.word	4120
+	.word	-12287
+	.word	6848
+	.word	20939
+	.word	-8
+	.word	20180
+	.word	21760
+	.word	12809
+	.word	26396
+	.word	-7320
+	.word	29184
+	.word	4033
+	.word	21313
+	.word	-15866
+	.word	-25015
+	.word	25098
+	.word	7198
+	.word	7937
+	.word	12831
+	.word	4614
+	.word	20551
+	.word	-4503
+	.word	-32703
+	.word	29184
+	.word	7936
+	.word	12831
+	.word	7942
+	.word	12319
+	.word	7198
+	.word	4102
+	.word	-4504
+	.word	4608
+	.word	17921
+	.word	18049
+	.word	16885
+	.word	6144
+	.word	6872
+	.word	20939
+	.word	-4
+	.word	20180
+	.word	21255
+	.word	3846
+	.word	26474
+	.word	18951
+	.word	26116
+	.word	32264
+	.word	7198
+	.word	21255
+	.word	3846
+	.word	26368
+	.word	198
+	.word	18951
+	.word	26116
+	.word	32264
+	.word	7198
+	.word	24944
+	.word	5632
+	.word	27164
+	.word	-10749
+	.word	21255
+	.word	3846
+	.word	22208
+	.word	-27136
+	.word	18951
+	.word	26116
+	.word	32264
+	.word	7198
+	.word	24920
+	.word	21248
+	.word	16131
+	.word	7808
+	.word	13855
+	.word	24910
+	.word	3072
+	.word	32
+	.word	25606
+	.word	4147
+	.word	0
+	.word	24602
+	.word	-6392
+	.word	4614
+	.word	22343
+	.word	25098
+	.word	7198
+	.word	7937
+	.word	12831
+	.word	4614
+	.word	20551
+	.word	-4503
+	.word	513
+	.word	7
+	.word	-32767
+	.word	6848
+	.word	20939
+	.word	-4
+	.word	20180
+	.word	18951
+	.word	26116
+	.word	32264
+	.word	7198
+	.word	7942
+	.word	12831
+	.word	7198
+	.word	4614
+	.word	-4503
+	.word	30463
+	.word	5633
+	.word	16885
+	.word	14336
+	.word	6872
+	.word	6872
+	.word	20180
+	.word	28672
+	.word	12807
+	.word	4032
+	.word	21312
+	.word	-13312
+	.word	-17152
+	.word	26118
+	.word	4118
+	.word	17920
+	.word	20545
+	.word	-28110
+	.word	0
+	.word	3073
+	.word	8
+	.word	25860
+	.word	29192
+	.word	21063
+	.word	-25023
+	.word	25092
+	.word	20551
+	.word	7198
+	.word	28672
+	.word	21249
+	.word	26390
+	.word	4032
+	.word	21312
+	.word	-16378
+	.word	-25023
+	.word	25098
+	.word	7198
+	.word	7936
+	.word	12319
+	.word	4102
+	.word	20551
+	.word	-4504
+	.word	960
+	.word	20085
+	.word	18951
+	.word	26116
+	.word	32264
+	.word	7198
+	.word	7942
+	.word	12319
+	.word	4126
+	.word	7168
+	.word	-4504
+	.word	4613
+	.word	6658
+	.word	-13824
+	.word	17922
+	.word	-16382
+	.word	17922
+	.word	-32767
+	.word	6848
+	.word	20180

+ 209 - 0
tigcc/pstarter/pst-ttup.h

@@ -0,0 +1,209 @@
+| TIGCC Program Starter - ttunpack decompression support
+| Copyright (C) 2004-2005 Samuel Stearley, Kevin Kofler
+|
+| THE LICENSE:
+|
+|               wxWindows Library Licence, Version 3.1
+|               ======================================
+|
+| Copyright (C) 1998-2005 Julian Smart, Robert Roebling et al
+|
+| Everyone is permitted to copy and distribute verbatim copies
+| of this licence document, but changing it is not allowed.
+|
+|                      WXWINDOWS LIBRARY LICENCE
+|    TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+|
+| This library is free software; you can redistribute it and/or modify it
+| under the terms of the GNU Library General Public Licence as published by
+| the Free Software Foundation; either version 2 of the Licence, 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 Licence for more details.
+|
+| You should have received a copy of the GNU Library General Public Licence
+| along with this software, usually in a file named COPYING.LIB.  If not,
+| write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+| Boston, MA 02111-1307 USA.
+|
+| EXCEPTION NOTICE
+|
+| 1. As a special exception, the copyright holders of this library give
+| permission for additional uses of the text contained in this release of
+| the library as licenced under the wxWindows Library Licence, applying
+| either version 3.1 of the Licence, or (at your option) any later version of
+| the Licence as published by the copyright holders of version
+| 3.1 of the Licence document.
+|
+| 2. The exception is that you may use, copy, link, modify and distribute
+| under your own terms, binary object code versions of works based
+| on the Library.
+|
+| 3. If you copy code from files distributed under the terms of the GNU
+| General Public Licence or the GNU Library General Public Licence into a
+| copy of this library, as this licence permits, the exception does not
+| apply to the code that you add in this way.  To avoid misleading anyone as
+| to the status of such modified files, you must delete this exception
+| notice from such code and/or adjust the licensing conditions notice
+| accordingly.
+|
+| 4. If you write modifications of your own for this library, it is your
+| choice whether to permit this exception to apply to your modifications. 
+| If you do not wish that, you must delete the exception notice from such
+| code and/or adjust the licensing conditions notice accordingly.
+
+| GET_UNCOMPRESSED_SIZE inline function
+| INPUT: %a3.l: pointer to compressed data
+| OUTPUT: %d6.l: uncompressed size
+| SIDE EFFECTS: throws a Data Type error if not a valid compressed program
+|               may throw a Memory error
+|               may advance %a3 for later decompression
+| DESTROYS: %d0-%d2/%a0-%a1
+.macro GET_UNCOMPRESSED_SIZE
+| Get the length of the variable.
+moveq.l #0,%d6
+move.w (%a3)+,%d6
+| Get a pointer to the data type of the variable.
+lea.l -1(%a3,%d6.l),%a0
+| Check if it has type "ppg".
+cmp.b #0xf8,(%a0)
+jbne invalid_archive
+tst.b -(%a0)
+jbne invalid_archive
+cmp.b #'g',-(%a0)
+jbne invalid_archive
+moveq.l #'p',%d0
+cmp.b -(%a0),%d0
+jbne invalid_archive
+cmp.b -(%a0),%d0
+jbne invalid_archive
+tst.b -(%a0)
+jbeq valid_archive
+| We don't need to check the magic number in the ttunpack header,
+| the decompression routine does that already.
+invalid_archive:
+.word 0xA000+210 | ER_DATATYPE
+valid_archive:
+| Get the uncompressed size.
+move.w (%a3),%d6
+rol.w #8,%d6
+.endm
+
+| MEM_TO_MEM_DECOMPRESS inline function
+| INPUT: %a3.l: pointer to compressed data
+|        %a0.l: pointer to buffer for uncompressed data
+|        %d6.l: uncompressed size
+| OUTPUT: %a4.l: pointer to uncompressed data
+| SIDE EFFECTS: may throw a Memory or Data Type error
+| DESTROYS: %d0-%d2/%a0-%a2
+.macro MEM_TO_MEM_DECOMPRESS
+move.l %a0,%a4 | satisfy output constraint
+jbsr ttunpack_decompress
+tst.w %d0
+jbne invalid_archive
+.endm
+
+.text
+ttunpack_decompress:
+	.word	18663
+	.word	7998
+	.word	6699
+	.word	6
+	.word	32384
+	.word	28680
+	.word	21643
+	.word	3163
+	.word	21584
+	.word	26140
+	.word	23179
+	.word	6171
+	.word	-18432
+	.word	25108
+	.word	3163
+	.word	2176
+	.word	26126
+	.word	-12245
+	.word	3
+	.word	17395
+	.word	2300
+	.word	3091
+	.word	5
+	.word	25874
+	.word	19679
+	.word	31992
+	.word	20085
+	.word	24886
+	.word	-16059
+	.word	29192
+	.word	-28156
+	.word	24894
+	.word	4288
+	.word	24874
+	.word	-20475
+	.word	26354
+	.word	24892
+	.word	13824
+	.word	21312
+	.word	26438
+	.word	24884
+	.word	20992
+	.word	26586
+	.word	21760
+	.word	4627
+	.word	24866
+	.word	29191
+	.word	24852
+	.word	17920
+	.word	17536
+	.word	4336
+	.word	2303
+	.word	20939
+	.word	-6
+	.word	24788
+	.word	4612
+	.word	28672
+	.word	24586
+	.word	-7393
+	.word	25602
+	.word	7193
+	.word	-9210
+	.word	-11968
+	.word	21249
+	.word	27378
+	.word	17600
+	.word	20085
+	.word	29702
+	.word	25066
+	.word	21706
+	.word	-4
+	.word	29190
+	.word	-28094
+	.word	28673
+	.word	24808
+	.word	25052
+	.word	25794
+	.word	25048
+	.word	25752
+	.word	25062
+	.word	5632
+	.word	27148
+	.word	25038
+	.word	16128
+	.word	25052
+	.word	21248
+	.word	7808
+	.word	13855
+	.word	25044
+	.word	21762
+	.word	27398
+	.word	4147
+	.word	3
+	.word	24580
+	.word	29186
+	.word	25012
+	.word	4288
+	.word	28672
+	.word	24738

+ 520 - 0
tigcc/pstarter/pstarter.s

@@ -0,0 +1,520 @@
+| TIGCC Program Starter
+| Copyright (C) 2004-2005 Kevin Kofler, Lionel Debroux.
+|
+| This launcher is free software; you can redistribute it and/or
+| modify it under the terms of the GNU Lesser General Public
+| License as published by the Free Software Foundation; either
+| version 2.1 of the License, or (at your option) any later version.
+|
+| As a special exception, UNMODIFIED copies of this launcher may also be
+| redistributed or sold without source code, for any purpose, as long as
+| such redistribution or selling is allowed by the license of the chosen
+| decompression routine. (The Lesser General Public License restrictions
+| do apply in other respects; for example, they cover modification of
+| the launcher. Licensing restrictions of the chosen decompression routine
+| also apply.) Merely replacing "tempprog" with the name of your program
+| shall not be considered a modification for the purposes of this
+| paragraph. This exception notice must be removed on modified copies of
+| this launcher.
+|
+| Please make sure you also read the licensing terms of the decompression
+| routine of your choice. They are written in the corresponding header
+| files.
+|
+| This launcher 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
+| Lesser General Public License for more details.
+|
+| You should have received a copy of the GNU Lesser General Public
+| License along with this library; if not, write to the Free Software
+| Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+.ifdef lzma
+.include "pst-lzma.h"
+.endif
+.ifdef ttunpack
+.include "pst-ttup.h"
+.endif
+.ifdef ttunpack_fast
+.include "pst-ttuf.h"
+.endif
+.ifdef shrink92
+.include "pst-shrn.h"
+.endif
+
+.xdef _ti89
+.xdef _ti92plus
+.xdef _v200
+.xdef _ti89ti
+.xdef _tigcc_native
+
+.section _st1
+
+| INITIALIZATION
+
+movem.l %d3-%d7/%a2-%a5,-(%sp)
+move.l 0xC8.w,%a5
+| Check if this is a TI-89 Titanium.
+move.l %a5,%d0
+| Size optimization: the highest bit (#31) determines the sign (N bit in ccr).
+| 23+8 = 31 => we can use rol #8 (2 bytes) instead of btst # (4 bytes).
+rol.l #8,%d0 | btst.l #23,%d0
+smi.b %d7 | sne.b %d7
+| First, look for the current address.
+lea.l (%pc),%a1
+move.l %a1,%d4
+| This is to prevent problems with Kevin's HW2 TSR support.
+and.l #0x3FFFF,%d4
+| Set the bit instead of clearing it.
+moveq.l #1,%d3
+| Call function.
+jbsr __set_clear_in_use_bit__
+| On failure, try using the return address of the program, to do the same for
+| a possible launcher.
+tst.w %d0
+jbne __in_use_done__
+| Get the return address.
+move.l 32(%sp),%d4
+| Check if it is in RAM range.
+cmp.l #0x1FFFFF,%d4
+| If not, it's not the launcher. Now we don't know who started us.
+jbhi __in_use_done__
+| This is to prevent problems with Kevin's HW2 TSR support.
+and.l #0x3FFFF,%d4
+| Call function.
+jbsr __set_clear_in_use_bit__
+__in_use_done__:
+| Save variables for reentrancy
+move.l ercatcherpc(%pc),-(%a7)
+lea.l DecompressedHandle(%pc),%a0
+move.l (%a0),-(%a7)
+| Initialize the handles to 0
+clr.l (%a0)
+__error_return_support:
+| Get 60 bytes on the stack (size of an error frame).
+lea (%sp,-60),%sp
+| Push a pointer to these 60 bytes.
+pea.l (%sp)
+| Call ER_catch
+move.l (%a5,0x154*4),%a0 /* ER_catch */
+jsr (%a0)
+| Now, this is a little complicated:
+| If an error is thrown later, a second return from ER_catch with an error
+| in %d0 is simulated.
+| So, if %d0 contains 0, then we resume normally, otherwise we go to the
+| cleanup block, but remember the error.
+| Store the error in a variable.
+lea.l __error_num__(%pc),%a0
+move.w %d0,(%a0)
+jbne __error_returned__
+
+
+| FIND FILE TO DECOMPRESS
+
+| Convert program name to SYM_STR
+lea.l ProgramName(%pc),%a0
+symstr_loop:
+tst.b (%a0)+
+jbne symstr_loop
+| SymFindPtr(SYMSTR(ProgramName),0)
+clr.w -(%a7)
+pea.l -1(%a0)
+move.l (%a5,0x283*4),%a0 /* SymFindPtr */
+jsr (%a0)
+| File found?
+move.l %a0,%d0
+jbne file_found
+file_not_found:
+.word 0xA000+850 /* ER_PRGM_NOT_FOUND */
+file_found:
+| Get handle
+lea.l CompressedHandle(%pc),%a2
+move.w 12(%a0),%d6
+jbeq file_not_found
+| Check if locked
+move.w %d6,(%a7)
+move.l (%a5,0x9B*4),%a0 /* HeapGetLock */
+jsr (%a0)
+tst.w %d0
+jbne already_locked
+| Save handle for unlocking if not already locked
+move.w %d6,(%a2)
+already_locked:
+| Lock handle and get pointer to compressed data
+move.w %d6,(%a7)
+move.l (%a5,0x99*4),%a0 /* HLock */
+jsr (%a0)
+move.l %a0,%a3
+addq.l #6,%a7
+
+
+| DECOMPRESS FILE
+
+| Check if the archive is valid and compute the uncompressed size
+GET_UNCOMPRESSED_SIZE
+| Allocate the memory needed to decompress the program
+| NOTE: We can't use HeapAllocPtr here because of kernel-based programs.
+move.l %d6,-(%a7)
+| Add the stub bytes for the Titanium
+tst.b %d7
+jbeq no_add_bytes
+add.l #102,(%a7)
+no_add_bytes:
+move.l (%a5,0x93*4),%a0 /* HeapAllocThrow */
+jsr (%a0)
+move.w %d0,(%a7)
+move.w %d0,-(%a2) | save handle for freeing
+move.l (%a5,0x99*4),%a0 /* HLock */
+jsr (%a0)
+addq.l #4,%a7
+| Decompress the archive
+MEM_TO_MEM_DECOMPRESS
+
+
+| LAUNCH DECOMPRESSED PROGRAM
+| NOTE: Some of this code is the same as in ttstart. This is
+|       because this is code _I_ contributed to ttstart. So
+|       it is being relicensed by the original author.
+
+| If we're not on a Titanium, switch the execution pointer to
+| the ghost space.
+tst.b %d7
+jbne dont_use_ghost_space
+moveq.l #4,%d1
+swap %d1
+adda.l %d1,%a4
+| Now enter the ghost space.
+jbsr own_enter_ghost_space
+| Set the ERROR_FRAME PC to the ghost space.
+ori.w #4,56(%a7)
+dont_use_ghost_space:
+| Skip the size bytes and read the actual size (upper word of d6 is 0).
+move.w (%a4)+,%d6
+| Relocate the program.
+pea.l -1(%a4,%d6.l) | tag_ptr
+pea.l (%a4) | base_addr
+move.l (%a5,0x15a*4),%a0 /* EX_patch */
+jsr (%a0)
+addq.l #8,%a7
+| The following code was compiled and hand-edited from:
+| /* If we are on AMS 2, we have to set the "last executed program" to somewhere
+|    in the last 4 KB of RAM, or else APD may crash under certain circumstances.
+|    The code below looks for the "last executed program" variable. That variable
+|    is cleared during initialization, immediately after the stack fence is set up.
+|    So we look for the value of the stack fence (0xDEADDEAD) in the initialization
+|    code and add 8 to get the wanted short pointer, which must then be
+|    sign-extended to an actual pointer. (The sign extension is implicit in the
+|    generated code, as it should be.) */
+| if (!(AMS_1xx||*(short*)0x32==('R'<<8)+'O')) {
+|   /* rb and q are factored out in order to get more efficient code. */
+|   char *rb=ROM_base;
+|   char *p=rb+0x12000;
+|   char *q=rb+0x18000;
+|
+|   while (p<q && *(unsigned long*)p!=0xDEADDEAD) p+=2;
+|   p+=2[(short *)p]?8:12;
+|   *(void **)(long)*(short *)p=isTitanium?(dest+2):(void*)0x3f000;
+| }
+| Then, it was optimized by Lionel Debroux. A consequence is that the assembly
+| code does not look like the C code above at all.
+cmp.l #1000,-4(%a5)
+jbcs .Llastexec1
+cmp.w #0x524F,0x32.w
+jbeq .Llastexec1
+move.l %a5,%d0
+andi.l #0xE00000,%d0
+add.l #0x12000,%d0
+move.l %d0,%a0
+move.w #((0x18000-0x12000)/2)-1,%d0 | Set up iteration counter
+0:
+cmpi.l #0xDEADDEAD,(%a0) | Look for the stack fence
+addq.l #2,%a0 | Increment pointer, condition codes unchanged
+dbeq %d0,0b
+tst.w 2(%a0)
+bne.s 3f
+addq.l #4,%a0
+3:
+move.w 6(%a0),%a0
+tst.b %d7
+jbne use_dest_pointer
+move.l #0x3F000,(%a0)
+jbra .Llastexec1
+use_dest_pointer:
+move.l %a4,(%a0)
+.Llastexec1:
+| Now actually run the program.
+movem.l %d1-%d7/%a0-%a6,-(%sp)
+tst.b %d7
+jbeq not_titanium
+| Round the length up to an even size
+| NOTE: The handle size is rounded up automatically.
+addq.l #1,%d6
+moveq.l #0xfffffffe,%d0
+and.l %d0,%d6
+| Save error catcher PC
+lea.l ercatcherpc(%pc),%a0
+move.l 112(%sp),(%a0)
+| Set new error catcher PC
+lea.l 0(%a4,%d6.l),%a0
+lea.l (ercatcher-middle)(%a0),%a1
+move.l %a1,112(%sp)
+| Append the stub to the program
+lea.l middle(%pc),%a1
+moveq.l #50,%d0
+stub_copy_loop:
+move.w (%a1)+,(%a0)+
+dbra %d0,stub_copy_loop
+| Unprotect and run the program
+pea target(%PC)
+movea.l %a4,%a3
+pea (%a3,%d6.l)
+jbra unprotect_a3_jumpto_a4
+target:
+| Clean up
+lea (%sp,36),%sp
+move.l (%sp)+,%d0
+bra.s 0f
+not_titanium:
+| Run the program in the ghost space
+jsr (%a4)
+| Handle RETURN_VALUE
+st.b %d0
+bra.s 0f
+clr.b %d0
+0: movem.l (%sp)+,%d1-%d7/%a0-%a6
+| If %d0==0, we have to fix the return address.
+tst.b %d0
+jbne no_return_value
+lea.l 108(%sp),%a1
+move.l (%a1),%a0
+cmpi.w #0x21EE,(%a0)
+jbne .L__no_add_2
+addq.l #2,(%a1)
+.L__no_add_2:
+addq.l #4,(%a1)
+no_return_value:
+
+
+| ERROR HANDLING
+
+__error_return_support_cleanup:
+| We have terminated successfully, so remove the error frame.
+move.l (%a5,0x155*4),%a0 /* ER_success */
+jsr (%a0)
+| This is the place where we should go if an error happened.
+| %d0 is not 0 in this case.
+__error_returned__:
+| Remove the error frame and the parameter from the stack.
+lea (%sp,64),%sp
+jbsr __set_clear_in_use_bit__
+
+
+| PSTARTER CLEANUPS
+
+| Free decompressed program handle, if any.
+pea.l DecompressedHandle(%pc)
+move.l (%a5,0x98*4),%a0 /* HeapFreeIndir */
+jsr (%a0)
+| Unlock compressed program handle, if it wasn't already locked
+move.w CompressedHandle(%pc),(%a7)
+jbeq no_unlock
+move.l (%a5,0x9f*4),%a0 /* HeapUnlock */
+jsr (%a0)
+no_unlock:
+addq.l #4,%a7
+| Restore variables for reentrancy
+lea.l ercatcherpc(%pc),%a0
+move.l (%a7)+,DecompressedHandle-ercatcherpc(%a0)
+move.l (%a7)+,(%a0)
+
+
+| GENERIC CLEANUPS
+
+| If we had any cleaning up to do, it absolutely MUST be finished at this
+| point. That is, we have to be able to return from here under any given
+| circumstances.
+| Go to __no_error__ if no error happened.
+lea.l __error_num__(%pc),%a0
+tst.w (%a0)
+beq.s __no_error__
+| Construct an A-Line value.
+or.w #0xA000,(%a0)
+__error_return_support_ams_1:
+| In AMS 1.xx, we need to unlock our own handle.
+| Otherwise, the program cannot be started again.
+cmp.l #1000,(%a5,-4) /* TIOS_entries */
+jbcc __ams_1_err_handling_not_needed__
+| Get the starting address of the program and push it on the stack.
+pea.l __ld_entry_point-2(%pc)
+| Convert it to a handle.
+move.l (%a5,0x23A*4),%a0 /* HeapPtrToHandle */
+jsr (%a0)
+| The handle is now in %d0. It is 0 on failure.
+move.w %d0,(%sp)
+jbeq __ams_1_err_handling_not_needed__
+| Unlock it.
+move.l (%a5,0x9F*4),%a0 /* HeapUnlock */
+jsr (%a0)
+| No need to clean up the stack, since we are going to throw an error anyway.
+__ams_1_err_handling_not_needed__:
+| This is where the A-Line error throwing is constructed.
+__error_num__:
+.word 0
+__no_error__:
+clr.w (%a0)
+movem.l (%sp)+,%d3-%d7/%a2-%a5
+rts
+
+
+| IN-USE BIT SUPPORT
+
+| This function relies on the address of the jump table being in %a5.
+| %d4 is an arbitrary address somewhere in our program (or the launcher,
+| respectively).
+| If %d3.w is 0, clear the bit, otherwise set it. If action is to set the bit,
+| the previous value is stored in %d3.
+| Register %d5 is destroyed.
+__set_clear_in_use_bit__:
+| Call SymFindFirst with appropriate parameters to look for the handle.
+move.w #0x06,-(%sp) /* FO_RECURSE | FO_SKIP_TEMPS */
+clr.l -(%sp)
+move.l (%a5,0x6C*4),%a0 /* SymFindFirst */
+jbsr (%a0)
+addq.l #6,%sp
+__symbol_search_loop__:
+| Store failure value in %d0
+clr.w %d0
+| If the SYM_ENTRY pointer is 0, quit.
+move.l %a0,%d5
+jbeq __symbol_search_done__
+| Dereference the handle from the SYM_ENTRY structure.
+move.w (%a0,12),-(%sp)
+move.l (%a5,0x96*4),%a0 /* HeapDeref */
+jbsr (%a0)
+addq.l #2,%sp
+| If the address returned is higher than the address we are looking for, the
+| symbol can't be the one.
+| Actually, if it is equal, then something is seriously broken, but we don't
+| check for that here.
+cmp.l %d4,%a0
+jbhi __skip_symbol__
+| Add the size of the variable to %a0.
+| Note that we would actually need to add 2 more bytes to skip the size
+| field, but we make up for that by using a <= comparison.
+moveq #0,%d0
+move.w (%a0),%d0
+add.l %d0,%a0
+| If the end address is lower than the address we are looking for, the
+| symbol can't be the one.
+cmp.l %d4,%a0
+jbls __skip_symbol__
+| Store success result in %d0.
+moveq #1,%d0
+| If %d3.w is 0, clear the in-use bit.
+move.l %d5,%a0
+lea 11(%a0),%a0
+tst.w %d3
+jbeq __clear_bit__
+| Otherwise, store the previous value in %d3, set the bit, and quit.
+moveq #0x10,%d1
+move.b (%a0),%d3
+and.w %d1,%d3
+or.b %d1,(%a0)
+rts
+__skip_symbol__:
+| Call SymFindNext.
+move.l (%a5,0x6D*4),%a0 /* SymFindNext */
+jbsr (%a0)
+| Go to beginning of loop.
+jra __symbol_search_loop__
+__clear_bit__:
+and.b #0xEF,(%a0)
+__symbol_search_done__:
+rts
+
+
+| GHOST SPACE ENTERING ROUTINE
+| WARNING: This routine wants #0x40000 in %d1.l.
+
+own_enter_ghost_space:
+move.l (%sp),%d0
+cmp.l %d1,%d0
+jbcc 2f
+cmpi.l #1000,(%a5,-4)
+jbcs 2f
+movem.l %a2-%a6/%d3-%d7,-(%sp)
+lea.l 0x3E000,%a3
+lea.l 1f(%pc,%d1.l),%a4
+jbra unprotect_a3_jumpto_a4
+1:
+lea (%sp,20),%sp
+movem.l (%sp)+,%a2-%a6/%d3-%d7
+2:
+move.l (%sp)+,%d0
+bset.l #18,%d0
+movea.l %d0,%a0
+jmp (%a0)
+
+
+| CODE EXECUTED AT END OF PROGRAM
+| NOTE: This is the same code as in ttstart, because the code in ttstart
+|       is actually MY code.
+
+middle:
+| Handle RETURN_VALUE
+st.b %d0
+bra.s 0f
+clr.b %d0
+0:
+| Unprotect and jump to the launcher
+movea.l (%sp)+,%a4
+lea __ld_entry_point-target(%a4),%a3
+move.l %d0,16(%sp)
+| Unprotection routine
+unprotect_a3_jumpto_a4:
+lea (%sp,-20),%sp
+move.l %a5,%d0
+andi.l #0xE00000,%d0
+addi.l #0x20000,%d0
+move.l %d0,(%sp,12)
+move.l %d0,(%sp,16)
+move.l 20(%sp),(%sp)
+move.l 24(%sp),4(%sp)
+trap #0xC
+move.w #0x2700,%sr
+moveq #0xF,%d3
+pea (%a4)
+clr.w  -(%sp)
+move.l 0xAC.w,%a0
+jmp (%a0)
+ercatcherentrypoint: .long __ld_entry_point
+ercatcherpc: .long 0
+.even
+ercatcher:
+movem.l %d0-%d7/%a0-%a6,-(%sp)
+move.l ercatcherentrypoint(%PC),%a3
+lea.l ercatchercleanup-__ld_entry_point(%a3),%a4
+jbra unprotect_a3_jumpto_a4
+
+
+| LAUNCHING CLEANUP CODE EXECUTED IN THE LAUNCHER'S EXECUTION SPACE
+
+ercatchercleanup:
+lea (%sp,20),%sp
+movem.l (%sp)+,%d0-%d7/%a0-%a6
+move.l ercatcherpc(%PC),-(%a7)
+rts
+
+
+| DATA
+
+.data
+
+.byte 0
+ProgramName:      | program name
+.asciz "tempprog" | to be patched in by TIGCC
+
+DecompressedHandle: .word 0 | handle to free, 0 if no freeing needed
+CompressedHandle: .word 0 | handle to unlock, 0 if no unlocking needed
+

+ 64 - 0
tigcc/pstarter/pstarter.tpr

@@ -0,0 +1,64 @@
+[Settings]
+Archive=0
+Flash OS=0
+Fargo=0
+Use Data Variable=0
+Data Variable=
+Copy Data Variable=1
+Copy Data Variable if Archived=1
+Pack=0
+Packed Variable=
+Project Name=pstarter
+GCC Switches=-Os -Wall -W -Wwrite-strings -ffunction-sections -fdata-sections
+GNU Assembler Switches=--defsym ttunpack=1 -l
+Assembler Switches=-g -t
+Debug Info=0
+Standard Library=1
+Initialize BSS=1
+Optimize NOPs=1
+Optimize Returns=1
+Optimize Branches=1
+Optimize Moves=1
+Optimize Tests=1
+Optimize Calculations=1
+Remove Unused Sections=1
+Cut Unused Ranges=1
+Reorder Sections=0
+Merge Constants=1
+Binary Output=0
+Command Line=
+Post-Build Process=
+
+[Library Options]
+Use TI-89=1
+Use TI-92 Plus=1
+Use V200=1
+Optimize Calc Consts=0
+Use Kernel=0
+Use PreOS=0
+Minimum AMS Version Defined=1
+Minimum AMS Version=1.00
+Unofficial OS Support=0
+Reloc Format=AMS
+ROM Call Format=Direct
+BSS Ref Format=Kernel
+Data Ref Format=Kernel
+Use F-Line Jumps=0
+Use 4-Byte F-Line Jumps=0
+Optimize ROM Calls=0
+Use Internal F-Line Emulator=0
+Use Return Value=0
+Enable Error Return=0
+Save Screen=1
+
+[File Editing]
+Open File=E:\TI-89\pstarter\pstarter.s
+
+[Included Files]
+GNU Assembler File 1=pstarter.s
+Text File 1=pstarter.txt
+Header File 1=pst-ttup.h
+Header File 2=pst-ttuf.h
+Header File 3=pst-lzma.h
+Header File 4=pst-shrn.h
+

+ 36 - 0
tigcc/pstarter/pstarter.txt

@@ -0,0 +1,36 @@
+This is the next-generation TIGCC pstarter. I wanted to get rid of all the #ifdef
+mess in ttstart, instead concentrating on a launcher explicitly optimized for use
+as an automatic TIGCC decompressor. There are 4 supported decompresssion
+routines:
+* ttunpack-small
+* ttunpack-fast
+* LZMA
+* Shrink92
+
+    TIGCC Program Starter
+    Copyright (C) 2004-2005 Kevin Kofler, Lionel Debroux
+
+    This launcher is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    As a special exception, UNMODIFIED copies of this launcher may also be
+    redistributed or sold without source code, for any purpose, as long as
+    such redistribution or selling is allowed by the license of the chosen
+    decompression routine. (The Lesser General Public License restrictions
+    do apply in other respects; for example, they cover modification of
+    the launcher. Licensing restrictions of the chosen decompression routine
+    also apply.) Merely replacing "tempprog" with the name of your program
+    shall not be considered a modification for the purposes of this
+    paragraph. This exception notice must be removed on modified copies of
+    this launcher.
+
+    This launcher 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
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

+ 12 - 0
tigcc/pstarter/ttunpack/hexarray.c

@@ -0,0 +1,12 @@
+unsigned short ttunpack_decompress[]=
+{\
+0x48e7,0x1f3e,0x1a2b,0x0006,0x7e80,0x7008,0x548b,0x0c5b,0x5450,0x661c,\
+0x5a8b,0x181b,0xb800,0x6214,0x0c5b,0x0880,0x660e,0xd02b,0x0003,0x43f3,\
+0x08fc,0x0c13,0x0005,0x6512,0x4cdf,0x7cf8,0x4e75,0x6136,0xc145,0x7208,\
+0x9204,0x613e,0x10c0,0x612a,0xb005,0x66f2,0x613c,0x3600,0x5340,0x6746,\
+0x6134,0x5200,0x67da,0x5500,0x1213,0x6122,0x7207,0x6114,0x4600,0x4480,\
+0x10f0,0x08ff,0x51cb,0xfffa,0x60d4,0x1204,0x7000,0x600a,0xe31f,0x6402,\
+0x1c19,0xdc06,0xd140,0x5301,0x6af2,0x44c0,0x4e75,0x7406,0x61ea,0x54ca,\
+0xfffc,0x7206,0x9242,0x7001,0x60e8,0x61dc,0x64c2,0x61d8,0x6498,0x61e6,\
+0x1600,0x6a0c,0x61ce,0x3f00,0x61dc,0x5300,0x1e80,0x361f,0x61d4,0x5502,\
+0x6b06,0x1033,0x0003,0x6004,0x7202,0x61b4,0x10c0,0x7000,0x60a2};

+ 107 - 0
tigcc/pstarter/ttunpack/hexarray.s

@@ -0,0 +1,107 @@
+	.file	"hexarray.c"
+#NO_APP
+	.text
+tigcc_compiled.:
+	.globl	ttunpack_decompress
+	.text
+	.even
+ttunpack_decompress:
+	.word	18663
+	.word	7998
+	.word	6699
+	.word	6
+	.word	32384
+	.word	28680
+	.word	21643
+	.word	3163
+	.word	21584
+	.word	26140
+	.word	23179
+	.word	6171
+	.word	-18432
+	.word	25108
+	.word	3163
+	.word	2176
+	.word	26126
+	.word	-12245
+	.word	3
+	.word	17395
+	.word	2300
+	.word	3091
+	.word	5
+	.word	25874
+	.word	19679
+	.word	31992
+	.word	20085
+	.word	24886
+	.word	-16059
+	.word	29192
+	.word	-28156
+	.word	24894
+	.word	4288
+	.word	24874
+	.word	-20475
+	.word	26354
+	.word	24892
+	.word	13824
+	.word	21312
+	.word	26438
+	.word	24884
+	.word	20992
+	.word	26586
+	.word	21760
+	.word	4627
+	.word	24866
+	.word	29191
+	.word	24852
+	.word	17920
+	.word	17536
+	.word	4336
+	.word	2303
+	.word	20939
+	.word	-6
+	.word	24788
+	.word	4612
+	.word	28672
+	.word	24586
+	.word	-7393
+	.word	25602
+	.word	7193
+	.word	-9210
+	.word	-11968
+	.word	21249
+	.word	27378
+	.word	17600
+	.word	20085
+	.word	29702
+	.word	25066
+	.word	21706
+	.word	-4
+	.word	29190
+	.word	-28094
+	.word	28673
+	.word	24808
+	.word	25052
+	.word	25794
+	.word	25048
+	.word	25752
+	.word	25062
+	.word	5632
+	.word	27148
+	.word	25038
+	.word	16128
+	.word	25052
+	.word	21248
+	.word	7808
+	.word	13855
+	.word	25044
+	.word	21762
+	.word	27398
+	.word	4147
+	.word	3
+	.word	24580
+	.word	29186
+	.word	25012
+	.word	4288
+	.word	28672
+	.word	24738

+ 53 - 0
tigcc/pstarter/ttunpack/license.txt

@@ -0,0 +1,53 @@
+                wxWindows Library Licence, Version 3.1
+                ======================================
+
+  Copyright (C) 1998-2005 Julian Smart, Robert Roebling et al
+
+  Everyone is permitted to copy and distribute verbatim copies
+  of this licence document, but changing it is not allowed.
+
+                       WXWINDOWS LIBRARY LICENCE
+     TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+  
+  This library is free software; you can redistribute it and/or modify it
+  under the terms of the GNU Library General Public Licence as published by
+  the Free Software Foundation; either version 2 of the Licence, 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 Licence for more details.
+
+  You should have received a copy of the GNU Library General Public Licence
+  along with this software, usually in a file named COPYING.LIB.  If not,
+  write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+  Boston, MA 02111-1307 USA.
+
+  EXCEPTION NOTICE
+
+  1. As a special exception, the copyright holders of this library give
+  permission for additional uses of the text contained in this release of
+  the library as licenced under the wxWindows Library Licence, applying
+  either version 3.1 of the Licence, or (at your option) any later version of
+  the Licence as published by the copyright holders of version
+  3.1 of the Licence document.
+
+  2. The exception is that you may use, copy, link, modify and distribute
+  under your own terms, binary object code versions of works based
+  on the Library.
+
+  3. If you copy code from files distributed under the terms of the GNU
+  General Public Licence or the GNU Library General Public Licence into a
+  copy of this library, as this licence permits, the exception does not
+  apply to the code that you add in this way.  To avoid misleading anyone as
+  to the status of such modified files, you must delete this exception
+  notice from such code and/or adjust the licensing conditions notice
+  accordingly.
+
+  4. If you write modifications of your own for this library, it is your
+  choice whether to permit this exception to apply to your modifications. 
+  If you do not wish that, you must delete the exception notice from such
+  code and/or adjust the licensing conditions notice accordingly.
+
+

+ 118 - 0
tigcc/pstarter/ttunpack/ttunpack.h

@@ -0,0 +1,118 @@
+/******************************************************************************
+*
+* project name:    TIGCC Tools Suite
+* file name:       ttunpack.h
+* initial date:    01/02/2001
+* authors:         thomas.nussbaumer@gmx.net
+*                  samuel@nyall.net
+*
+* description:     defines for exepack functionalities including unpack routine
+*                  (complete rewrite of TIGCC Tools Suite header file)
+*
+*   This is a 100% assembly version of the ttunpack routine, which is
+*   based on code by Pasi 'Albert' Ojala, albert@cs.tut.fi, then
+*   reduced by Thomas Nussbaumer to fit his needs.  For a full details
+*   on the algorithm see:
+*
+*	  http://www.cs.tut.fi/~albert/Dev/pucrunch/index.html
+*
+*
+* Liscense:
+*
+*   The liscense is quite similar to that of the origional version in c.
+*
+*   The code may be freely used in any non commercial application.  If
+*   you do use it please give credit to tict (http://tict.ticalc.org) and
+*   myself (Samuel Stearley).  I state this as a request but it is actually
+*   not.
+*
+*   The author(s) (Samuel/Tict/Any other contributor) make no
+*   representations or warranties about the suitability of the software,
+*   either express or implied. The author(s) shall not be liable for
+*   any damages suffered as a result of using or distributing this
+*   software.
+*
+*   If you distribute this file on a website or as part of
+*   the source of a project do not remove the liscense from this file.
+*
+*
+* $Id: ttunpack.h,v 1.1 2006-02-28 23:36:58 kevinkofler Exp $
+*
+******************************************************************************/
+#ifndef __TTUNPACK_H__
+#define __TTUNPACK_H__
+
+typedef struct {
+    unsigned char  osize_lo;   // original size lowbyte
+    unsigned char  osize_hi;   // original size highbyte
+    unsigned char  magic1;     // must be equal to TTUNPACK_MAGIC1
+    unsigned char  magic2;     // must be equal to TTUNPACK_MAGIC2
+    unsigned char  csize_lo;   // compressed size lowbyte
+    unsigned char  csize_hi;   // compressed size lowbyte
+    unsigned char  esc1;       // escape >> (8-escBits)
+    unsigned char  notused3;
+    unsigned char  notused4;
+    unsigned char  esc2;       // escBits
+    unsigned char  gamma1;     // maxGamma + 1
+    unsigned char  gamma2;     // (1<<maxGamma)
+    unsigned char  extralz;    // extraLZPosBits
+    unsigned char  notused1;
+    unsigned char  notused2;
+    unsigned char  rleentries; // rleUsed
+} TTUNPACK_HEADER;
+
+#define TTUNPACK_MAGIC1 0x54
+#define TTUNPACK_MAGIC2 0x50
+
+#define ttunpack_size(_p_)  ((unsigned short)(((TTUNPACK_HEADER*)(_p_))->osize_lo | (((TTUNPACK_HEADER*)(_p_))->osize_hi << 8)))
+#define ttunpack_valid(_p_) (((TTUNPACK_HEADER*)(_p_))->magic1 == TTUNPACK_MAGIC1 && ((TTUNPACK_HEADER*)(_p_))->magic2 == TTUNPACK_MAGIC2)
+
+#define TTUNPACK_OKAY             0
+#define TTUNPACK_NOESCFOUND     248
+#define TTUNPACK_ESCBITS        249
+#define TTUNPACK_MAXGAMMA       250
+#define TTUNPACK_EXTRALZP       251
+#define TTUNPACK_NOMAGIC        252
+#define TTUNPACK_OUTBUFOVERRUN  253
+#define TTUNPACK_LZPOSUNDERRUN  254
+
+#define ttunpack_decompress ((unsigned short(*)(unsigned char*,unsigned char*))(unsigned short[])\
+{\
+0x48e7,0x1f3e,0x1a2b,0x0006,0x7e80,0x7008,0x548b,0x0c5b,0x5450,0x661c,\
+0x5a8b,0x181b,0xb800,0x6214,0x0c5b,0x0880,0x660e,0xd02b,0x0003,0x43f3,\
+0x08fc,0x0c13,0x0005,0x6512,0x4cdf,0x7cf8,0x4e75,0x6136,0xc145,0x7208,\
+0x9204,0x613e,0x10c0,0x612a,0xb005,0x66f2,0x613c,0x3600,0x5340,0x6746,\
+0x6134,0x5200,0x67da,0x5500,0x1213,0x6122,0x7207,0x6114,0x4600,0x4480,\
+0x10f0,0x08ff,0x51cb,0xfffa,0x60d4,0x1204,0x7000,0x600a,0xe31f,0x6402,\
+0x1c19,0xdc06,0xd140,0x5301,0x6af2,0x44c0,0x4e75,0x7406,0x61ea,0x54ca,\
+0xfffc,0x7206,0x9242,0x7001,0x60e8,0x61dc,0x64c2,0x61d8,0x6498,0x61e6,\
+0x1600,0x6a0c,0x61ce,0x3f00,0x61dc,0x5300,0x1e80,0x361f,0x61d4,0x5502,\
+0x6b06,0x1033,0x0003,0x6004,0x7202,0x61b4,0x10c0,0x7000,0x60a2})
+
+#endif
+
+//=============================================================================
+// Revision History
+//=============================================================================
+//
+// $Log: not supported by cvs2svn $
+//
+// Revision 2.0  2004/08/30 12:00:00  Samuel Stearley
+// New extraction routine in 100% asm.
+//
+// Revision 1.4  2002/03/28 21:17:28  tnussb
+// project name in header changed to TIGCC Tools Suite
+//
+// Revision 1.3  2002/03/13 15:09:58  tnussb
+// new exepack decompression function generated from old/unpack.c added
+// (its a little bit smaller now). The new function should work as the old one,
+// but if there are problems I will leave the old hexcode array here, too
+//
+// Revision 1.2  2001/02/05 20:33:01  Thomas Nussbaumer
+// (1) magic of ttunpack header splitted again into 2 bytes to prevent address errors
+// (2) new (stable?) pc-relative version of unpacking routine
+//
+//
+
+
+ 

+ 415 - 0
tigcc/pstarter/ttunpack/unpack.asm

@@ -0,0 +1,415 @@
+;-----------------------------------------------------------------------
+;INTRODUCTION:
+;
+;   This is a 100% assembly version of the ttunpack routine, which is
+;   based on code by Pasi 'Albert' Ojala, albert@cs.tut.fi, then
+;   reduced by Thomas Nussbaumer to fit his needs.  For a full details
+;   on the algorithm see:
+;
+;	  http://www.cs.tut.fi/~albert/Dev/pucrunch/index.html
+;
+;   Version: 2.33 Super Small, Improper Return Value
+;			Requires even alignment
+;			Register Parameters, a0 -> dest, a3 -> source
+;			Removed optional delta_lz code
+;			Fixed a bug in header error checks
+;
+;THE LICENSE:
+;
+; Copyright (C) 2004-2005 Samuel Stearley
+;
+;               wxWindows Library Licence, Version 3.1
+;               ======================================
+;
+; Copyright (C) 1998-2005 Julian Smart, Robert Roebling et al
+;
+; Everyone is permitted to copy and distribute verbatim copies
+; of this licence document, but changing it is not allowed.
+;
+;                      WXWINDOWS LIBRARY LICENCE
+;    TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU Library General Public Licence as published by
+; the Free Software Foundation; either version 2 of the Licence, 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 Licence for more details.
+;
+; You should have received a copy of the GNU Library General Public Licence
+; along with this software, usually in a file named COPYING.LIB.  If not,
+; write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+; Boston, MA 02111-1307 USA.
+;
+; EXCEPTION NOTICE
+;
+; 1. As a special exception, the copyright holders of this library give
+; permission for additional uses of the text contained in this release of
+; the library as licenced under the wxWindows Library Licence, applying
+; either version 3.1 of the Licence, or (at your option) any later version of
+; the Licence as published by the copyright holders of version
+; 3.1 of the Licence document.
+;
+; 2. The exception is that you may use, copy, link, modify and distribute
+; under your own terms, binary object code versions of works based
+; on the Library.
+;
+; 3. If you copy code from files distributed under the terms of the GNU
+; General Public Licence or the GNU Library General Public Licence into a
+; copy of this library, as this licence permits, the exception does not
+; apply to the code that you add in this way.  To avoid misleading anyone as
+; to the status of such modified files, you must delete this exception
+; notice from such code and/or adjust the licensing conditions notice
+; accordingly.
+;
+; 4. If you write modifications of your own for this library, it is your
+; choice whether to permit this exception to apply to your modifications. 
+; If you do not wish that, you must delete the exception notice from such
+; code and/or adjust the licensing conditions notice accordingly.
+;
+;
+;NOTES:
+;
+;1) There were several other names associated with this, but not
+;   anymore ;)
+;
+;
+;2) The code was written with wordpad.  It might look better if
+;   opened with that program.
+;
+;
+;3) A version of this is included as a hex array for use with programs
+;   written with tigcc.  OR you can use this file directly with a
+;   tigcc project: add it to the project and remove the ';' from
+;   before the 'CALL_DIRECTLY' below.  Be sure to have the latest
+;   version of tigcc when doing this.
+;----------------------------------------------------------------------
+
+;CALL_DIRECTLY			;if this label is defined then this code can be used
+					;  directly as part of a tigcc project.
+
+
+
+
+ ifd CALL_DIRECTLY
+	public ttunpack_decompress
+ endc
+
+ ifnd CALL_DIRECTLY
+	include "os.h"
+	xdef _ti89
+	xdef _nostub
+ endc
+
+
+;------------------------------------------------------------------
+;The data structure defines and error return values
+;------------------------------------------------------------------
+
+osize_lo		equ	0	;original size lowbyte
+osize_hi		equ	1	;original size highbyte
+magic1		equ	2	;must be equal to UNPACK_MAGIC1
+magic2		equ	3	;must be equal to UNPACK_MAGIC2
+csize_lo		equ	4	;compressed size lowbyte
+csize_hi		equ	5	;compressed size lowbyte
+esc1			equ	6	;escape >> (8-escBits)
+notused3		equ	7	;
+notused4		equ	8	;
+esc2			equ	9	;escBits
+gamma1		equ	10	;maxGamma + 1
+gamma2		equ	11	;(1<<maxGamma)
+extralz		equ	12	;extraLZPosBits
+notused1		equ	13	;
+notused2		equ	14	;
+rleentries		equ	15	;rleUsed
+
+HEADER_SIZE		equ	16
+
+__MAGIC_CHAR1	equ	$54
+__MAGIC_CHAR2	equ	$50
+
+__ERRPCK_OKAY		equ	0
+__ERRPCK_NOESCFOUND	equ	8		;248
+__ERRPCK_ESCBITS		equ	7		;249
+__ERRPCK_MAXGAMMA		equ	6		;250
+__ERRPCK_EXTRALZP		equ	5		;251
+__ERRPCK_NOMAGIC		equ	4		;252
+__ERRPCK_OUTBUFOVERRUN	equ	3		;253
+__ERRPCK_LZPOSUNDERRUN	equ	2		;254
+
+;-----------------------------------------------------------------------
+;Notes on register useage, might be good Idea to print this.
+;
+;	a0 => Input: The destination buffer
+;	a1 => Points to the next byte of the compressed data.
+;		udated when d7 overflows.
+;	a2 => NOT USED
+;	a3 => Input: The source data
+;		Used during error checking, will point to extralz bits
+;		Used to access 'bytecodevec' table
+;	a4 => NOT USED
+;	a5 => NOT USED
+;	a6 => NOT USED
+;
+;	d0 => Trashing, output of __GetBits and __GetValue
+;	d1 => Trashing, input to __GetBits
+;	d2 => Trashing by __GetValue
+;	d3 => Trashing but only by the main routine, not the subroutines
+;	d4 => # of escape bits
+;	d5 => Start escape
+;	d6 => Current byte of data.
+;	d7 => Which bit we are at in the compressed data.
+;
+;-----------------------------------------------------------------------
+ttunpack_decompress:
+
+ ifnd CALL_DIRECTLY
+	dc.b		"UNPACK_0"
+ endc
+
+	movem.l	d3-d7/a2-a6,-(a7)
+;	move.l	4+10*4(a7),a3
+;	move.l	8+10*4(a7),a0
+;--------------------------------------------------------
+;  startesc = cth->esc1;     //d5
+;  bytecodevec = &src[15];   //a3
+;  __imask__   = 0x80;	     //d7
+;
+;These are initialized here to insure that certain
+;branches can use the short form.
+;--------------------------------------------------------
+	move.b	esc1(a3),d5		;'StartEsc'
+	moveq		#-128,d7		;which bit i am at.
+;-------------------------------------------------------------------------------------------------
+;  if (cth->magic1 != __MAGIC_CHAR1 || cth->magic2 != __MAGIC_CHAR2) return __ERRPCK_NOMAGIC;
+;  if (cth->gamma1 != 8 || cth->gamma2 != 128)                       return __ERRPCK_MAXGAMMA;
+;  if ((escbits = cth->esc2) > 8)                                    return __ERRPCK_ESCBITS;
+;  if ((extralzposbits = cth->extralz) > 4)                          return __ERRPCK_EXTRALZP;
+;-------------------------------------------------------------------------------------------------
+	moveq		#8,d0			;code for error is non-zero
+	addq.l	#2,a3
+	cmp.w		#__MAGIC_CHAR1*256+__MAGIC_CHAR2,(a3)+
+	bne.s		__ReturnError
+
+	addq.l	#5,a3			;point to esc2
+	move.b	(a3)+,d4		;get esc2 and point to gamma1
+	cmp.b		d0,d4
+	bhi.s		__ReturnError
+
+	cmp.w		#8*256+128,(a3)+	;gamma1 = 8 and gamma2 = 128?
+	bne.s		__ReturnError
+;--------------------------------------------------------
+;  __ibuffer__ = src + sizeof(__PACKHEADER) + cth->rleentries;  //a1
+;--------------------------------------------------------
+	add.b		3(a3),d0		;upper bytes of d0.l = 0, add (not load) in case a3 points to a zero
+	lea		4-8(a3,d0.l),a1	;  because d0 is the error code must not be zero.
+	cmp.b		#5,(a3)
+	bcs.s		__DecompressLoop	;jump into the loop if 4..0
+;---------------------------------------------------------
+;And when all is done branch here
+;  If success d0 will be zero
+;---------------------------------------------------------
+__ReturnError:
+__WeAreDone:
+	movem.l	(a7)+,d3-d7/a2-a6
+	rts
+;-----------------------------------------------------------------
+;  newesc = __GetBits(escbits);
+;  *outbuffer++ = (startesc<<escbits8) | __GetBits(escbits8);
+;  startesc = newesc;
+;  continue;
+;-----------------------------------------------------------------
+__NextBitIsClear_EscapeFromEscape:
+	bsr.s		__GetBits_D4Input	;d0 is 'newesc'
+	exg		d0,d5			;'startesc' = 'newesc'; and d0 = OLD_startesc
+;---------------------------------------------------------
+;  *outbuffer++ = (sel<<escbits8) | __GetBits(escbits8);
+;  continue;
+;---------------------------------------------------------
+__SelIsNOTStartEscape:
+	moveq		#8,d1
+	sub.b		d4,d1			;'escbits8'
+	bsr.s		__GetBits_D0_IS_Loaded_For_Shifting
+	move.b	d0,(a0)+
+;---------------------------------------------------------
+;The while(1) loop, just a label ;)
+;---------------------------------------------------------
+__DecompressLoop:
+
+;---------------------------------------------------------
+;  sel = (escbits) ? __GetBits(escbits) : startesc;
+;  if (sel == startesc) {
+;---------------------------------------------------------
+	bsr.s		__GetBits_D4Input	;get the bits, input is in d4
+	cmp.b		d5,d0			;did __getBits return 'startesc' into 'sel'?
+	bne.s		__SelIsNOTStartEscape
+;---------------------------------------------------------
+;The following code is entered if sel = start escape
+;but it does not actually use the sel variable
+;
+;  lzlen = __GetValue();
+;  if (lzlen != 1) {
+;---------------------------------------------------------
+__SelIsStartEscape:
+	bsr.s		__GetValue		;get a value for 'lzlen', d1 will be negative from above __GetBits
+						;  as a side effect d1 will be negative
+	move.w	d0,d3			;save 'lzlen'
+	subq.w	#1,d0			;does 'lzlen' == 1 ?
+	beq.s		__RleDecoding	;this destination requires d0 = 0
+;---------------------------------------------------------
+;Zip decoding
+;
+;  lzposhi = __GetValue() - 1;
+;  if (lzposhi == 254) {
+;---------------------------------------------------------
+	bsr.s		__GetValue		;if it equals 254, then lzlen must be > 3 because
+	addq.b	#1,d0			;  there is no other possiblity because Delta decompression
+	beq.s		__WeAreDone		;  is not being used.  It the branch is not taken it
+						;  drops through to the __LzPosHi_IsNot254
+						;  This __GetValue relies on d1 = negative from above __GetValue
+;----------------------------------------------------------------------------------------
+;  if (extralzposbits) lzposhi = (lzposhi<<extralzposbits) | __GetBits(extralzposbits);
+;  lzposlo = __Get8Bit() ^ 0xff;
+;  lzpos   = COMBINE_LOWHIGH(lzposlo,lzposhi);
+;
+; d0= lzPosHi, d3.w = lzlen, d2.l =lzpos
+;----------------------------------------------------------------------------------------
+__LzPosHi_IsNot254:
+	subq.b	#2,d0				;undo the addq.b #1 and do the subtract that wasn't done
+	move.b	(a3),d1			;get 'extralzposbits'
+	bsr.s		__GetBits_D0_IS_Loaded_For_Shifting
+__NextBitClear_DoZipAfterAll:			;to jump here be sure that d0.l = 0
+	moveq		#7,d1
+	bsr.s		__GetBits_D0_IS_Loaded_For_Shifting_D1_is_not_Variable
+;-----------------------------------------------------------------------------------
+;  for (i=0; i<=lzlen; i++) {
+;    *outbuffer = *(outbuffer - lzpos - 1); //no 'add' variable
+;    outbuffer++;
+;  }
+;
+; d0.l must be lzpos
+; d3.w must be lzlen
+;------------------------------------------------------------------------------------
+	not.b		d0
+	neg.l		d0
+__WriteDataLoop:
+	move.b	-1(a0,d0.l),(a0)+		;18 cycles
+__UseZipCopyLoop:					;entrance for the rle code
+	dbra		d3,__WriteDataLoop
+	bra.s		__DecompressLoop		;continue
+;-------------------------------------------------------------
+;  __GetValue returns an 8 bit value in d0.l  It can be used
+;  as an:
+;	unsigned character
+;	unsigned short
+;	unsigned long
+;
+;  __GetBits takes as its input d1.b, returns a value in d0.w
+;  There is a limit on it being 16 bit output.  With the
+;  upper bits being 0 so it can be used as an:
+;	unsigned character, if 8 bits or less are requested.
+;	unsigned short
+;	unsigned long
+;
+;  __GetBits has two other entrances, that assume a value in d0
+;  is ready to be shifted up as bits are shifted in.  This is
+;  limited to 16 bit values, with no guarantee about the upper
+;  bits.
+;
+;  '__GetBits_D0_IS_Loaded_For_Shifting_D1_is_not_Variable' is
+;  used when there is no possiblity that the input is 0.  For
+;  example: __getBits(3)
+;
+;--------------------------------------------------------------
+__GetBits_D4Input:
+	move.b	d4,d1
+__GetBits:
+	moveq		#0,d0
+	bra.s		__IntoLoop
+__GetBits_D0_IS_Loaded_For_Shifting_D1_is_not_Variable:
+__inl_loop0:
+__CheckBitProceed:			;to call this like the old 'CheckBitProceed' make sure d1 = negative
+	rol.b		#1,d7
+	bcc.s		__NotInNext
+	move.b	(a1)+,d6
+__NotInNext:
+	add.b		d6,d6
+	addx.w	d0,d0
+__GetBits_D0_IS_Loaded_For_Shifting:
+__IntoLoop:
+	subq.b	#1,d1			;must be byte valued, if d1.b = negative then drop through
+	bpl.s		__inl_loop0
+	move		d0,ccr		;put the last bit into the carry flag.
+	rts
+
+__GetValue:
+	moveq		#6,d2
+__inl_loop1:
+	bsr.s		__CheckBitProceed
+	dbcc		d2,__inl_loop1
+	moveq		#6,d1
+	sub.w		d2,d1
+	moveq		#1,d0
+	bra.s		__GetBits_D0_IS_Loaded_For_Shifting
+;---------------------------------------------------------
+;RLE decoding
+;---------------------------------------------------------
+__RleDecoding:						;important! at this point d0=0 and d1 = -1
+	bsr.s		__CheckBitProceed			;will modify d0 if the bit is set
+	bcc.s		__NextBitClear_DoZipAfterAll	;if it branches d0 is still 0, the destination requires this!
+	bsr.s		__CheckBitProceed
+	bcc.s		__NextBitIsClear_EscapeFromEscape
+;-----------------------------------------------------------------
+;  rlelen = __GetValue();
+;  if (rlelen >= 128) {
+;     rlelen = ((rlelen-128)<<1) | __GetBits(1);
+;     rlelen |= (((__GetValue())-1)<<8);
+;  }
+;------------------------------------------------------------------
+__NextBitIsSet_RunLengthEncoding:
+	bsr.s		__GetValue		;get 'rlelen' into d0, limited to 8 bit values. d1 = is still negative!
+						;  it gets the value and d1 is negative again
+	move.b	d0,d3			;copy it and check sign bit to see if >= 128
+	bpl.s		__LessThan128
+	bsr.s		__CheckBitProceed	;__getBits(1), important d1 is negative
+	move.w	d0,-(a7)
+	bsr.s		__GetValue		;relies on d1 being negative !  Satisfied by above __GetValue
+	subq.b	#1,d0
+	move.b	d0,(a7)		;overwrites the high bit that is should be cleared by
+	move.w	(a7)+,d3		;  by the rlelen-128
+;-------------------------------------------------------------------
+;Need the byte to copy
+;
+;  bytecode = __GetValue();
+;  if (bytecode < 32) byte = bytecodevec[bytecode];
+;  else               byte = ((bytecode-32)<<3) | __GetBits(3);
+;-------------------------------------------------------------------
+__LessThan128:
+	bsr.s		__GetValue			;get 'bytecode'
+	subq.b	#2,d2				;d2= (6- # of bits retireved) jump if 5 ,6, or 7
+	bmi.s		__GreaterThanOrEqual32	;   bits retrieved means that it is >= 32
+	move.b	3(a3,d0.w),d0		;byte = bytecodevec[bytecode];
+	bra.s		__RleCopy
+__GreaterThanOrEqual32:
+	moveq		#2,d1
+	bsr.s		__GetBits_D0_IS_Loaded_For_Shifting_D1_is_not_Variable
+;--------------------------------------------------------
+;  for (i=0; i<=rlelen; i++) *outbuffer++ = byte;
+;  continue;   // continue the main loop ...
+;
+;Rle loop expects
+; d0 = byte
+; d3 = number of em to copy, no need to subtract 1 for
+;	 dbra
+;--------------------------------------------------------
+__RleCopy:
+	move.b	d0,(a0)+
+	moveq		#0,d0
+	bra.s		__UseZipCopyLoop
+
+ ifnd CALL_DIRECTLY
+	dc.b		"UNPACK_1"
+ endc

+ 42 - 0
tigcc/pstarter/ttupfast/hexarray.c

@@ -0,0 +1,42 @@
+#include <default.h>
+
+asm("
+.xdef _ti89
+.xdef _ti92plus
+.xdef _v200
+.xdef _ti89ti
+.xdef _tigcc_native
+");
+
+unsigned short ttunpack_decompress[]=
+{\
+0x48e7,0x1f3e,0x2c6f,0x002c,0x2a6f,0x0030,0x47ee,0x000f,0x7a00,0x1a2e,\
+0x0006,0x7e08,0x7004,0x0c2e,0x0054,0x0002,0x667c,0x0c2e,0x0050,0x0003,\
+0x6674,0x7006,0x0c2e,0x0008,0x000a,0x666a,0x0c2e,0x0080,0x000b,0x6662,\
+0x7007,0x7200,0x122e,0x0009,0x2801,0x5141,0x6254,0x7005,0x7200,0x122e,\
+0x000c,0x2241,0x5b41,0x6e46,0x7400,0x09c2,0x5342,0xe83a,0xe83d,0x7000,\
+0x1013,0x4df6,0x0010,0x49fa,0x003c,0x4a04,0x6604,0x49fa,0x0052,0x4fef,\
+0xfefc,0x244f,0x421a,0x7000,0x7207,0x7600,0x01c3,0x14c0,0x5343,0x66fa,\
+0x5240,0x51c9,0xfff2,0x244f,0x1c1e,0x4ed4,0x7000,0x4fef,0x0104,0x4400,\
+0x4cdf,0x7cf8,0x4e75,0x1ac0,0x1f06,0x301f,0x1c1e,0x1006,0xee68,0x1202,\
+0xc200,0xb205,0x66ec,0x558e,0x1c1e,0x9e44,0x6204,0x1c1e,0x5047,0x6100,\
+0x0110,0x3600,0x5340,0x6778,0x6100,0x0106,0x5200,0x662c,0x5943,0x65bc,\
+0x5843,0x1206,0x4841,0x1f1e,0x321f,0x121e,0x1c01,0xeea9,0x70ff,0x1001,\
+0x3f01,0x121f,0x41f5,0x0000,0x1018,0xd001,0x1ac0,0x51cb,0xfff8,0x4ed4,\
+0x5500,0x3209,0x671c,0xe368,0x7200,0x0fc1,0x5341,0xc206,0x9e49,0x620a,\
+0x1c1e,0x1f01,0x321f,0x1206,0x5047,0xee69,0x8041,0x7200,0x1f00,0x321f,\
+0x1f06,0x301f,0x1c1e,0x1006,0xee68,0x1200,0x4601,0x4681,0x41f5,0x1800,\
+0x1ad8,0x51cb,0xfffc,0x4ed4,0x5307,0x0f06,0x676a,0x4a07,0x6604,0x7e08,\
+0x1c1e,0x5307,0x0f06,0x6700,0x00c6,0x4a07,0x6604,0x7e08,0x1c1e,0x6170,\
+0x1600,0x6a1c,0xd603,0x5307,0x0f06,0x56c0,0x9600,0x4a07,0x6604,0x7e08,\
+0x1c1e,0x6158,0x5300,0x3f03,0x1e80,0x361f,0x614e,0x0c00,0x0020,0x6406,\
+0x1033,0x0000,0x601a,0xe708,0x1206,0x5747,0x620a,0x1c1e,0x1f01,0x321f,\
+0x1206,0x5047,0xee69,0x0201,0x0007,0x8001,0x1ac0,0x51cb,0xfffc,0x4ed4,\
+0x4a07,0x6604,0x7e08,0x1c1e,0x1f06,0x321f,0x1c1e,0x1206,0xee69,0x76ff,\
+0x1601,0x41f5,0x3800,0x1ad8,0x1ad8,0x4ed4,0x7000,0x3207,0x0fc0,0x5340,\
+0xcc00,0xbd00,0x6606,0x1016,0x4600,0x5041,0x9232,0x0000,0x0c01,0x0008,\
+0x6504,0x7208,0x5247,0x9e41,0x6204,0x5047,0x1c1e,0x7000,0x5301,0x6716,\
+0x0fc0,0x5340,0xc006,0x9e41,0x620a,0x1c1e,0x1f00,0x301f,0x1006,0x5047,\
+0xee68,0x03c0,0x4e75,0x4a07,0x6604,0x7e08,0x1c1e,0x1f06,0x301f,0x101e,\
+0x1c00,0xee68,0x1205,0x1a02,0xca00,0x4602,0xc002,0x4602,0x8001,0x1ac0,\
+0x4ed4};

+ 317 - 0
tigcc/pstarter/ttupfast/hexarray.s

@@ -0,0 +1,317 @@
+	.file	"hexarray_fast.c"
+#NO_APP
+	.text
+tigcc_compiled.:
+#APP
+	.xdef __ref_all___startup_code
+	.xdef __ref_all___MIN_AMS_required
+	.xdef __ref_all___MIN_AMS_1_01
+	.set _A_LINE,0xA000
+	.xdef __ref_all___kernel_format_data_var
+	.xdef _tigcc_native
+	.xdef __ref_all___nostub
+	.xdef __ref_all___kernel_format_bss
+	.xdef __ref_all___kernel_format_rom_calls
+	
+.xdef _ti89
+.xdef _ti92plus
+.xdef _v200
+.xdef _ti89ti
+.xdef _tigcc_native
+
+#NO_APP
+	.globl	ttunpack_decompress
+	.text
+	.even
+ttunpack_decompress:
+	.word	18663
+	.word	7998
+	.word	11375
+	.word	44
+	.word	10863
+	.word	48
+	.word	18414
+	.word	15
+	.word	31232
+	.word	6702
+	.word	6
+	.word	32264
+	.word	28676
+	.word	3118
+	.word	84
+	.word	2
+	.word	26236
+	.word	3118
+	.word	80
+	.word	3
+	.word	26228
+	.word	28678
+	.word	3118
+	.word	8
+	.word	10
+	.word	26218
+	.word	3118
+	.word	128
+	.word	11
+	.word	26210
+	.word	28679
+	.word	29184
+	.word	4654
+	.word	9
+	.word	10241
+	.word	20801
+	.word	25172
+	.word	28677
+	.word	29184
+	.word	4654
+	.word	12
+	.word	8769
+	.word	23361
+	.word	28230
+	.word	29696
+	.word	2498
+	.word	21314
+	.word	-6086
+	.word	-6083
+	.word	28672
+	.word	4115
+	.word	19958
+	.word	16
+	.word	18938
+	.word	60
+	.word	18948
+	.word	26116
+	.word	18938
+	.word	82
+	.word	20463
+	.word	-260
+	.word	9295
+	.word	16922
+	.word	28672
+	.word	29191
+	.word	30208
+	.word	451
+	.word	5312
+	.word	21315
+	.word	26362
+	.word	21056
+	.word	20937
+	.word	-14
+	.word	9295
+	.word	7198
+	.word	20180
+	.word	28672
+	.word	20463
+	.word	260
+	.word	17408
+	.word	19679
+	.word	31992
+	.word	20085
+	.word	6848
+	.word	7942
+	.word	12319
+	.word	7198
+	.word	4102
+	.word	-4504
+	.word	4610
+	.word	-15872
+	.word	-19963
+	.word	26348
+	.word	21902
+	.word	7198
+	.word	-25020
+	.word	25092
+	.word	7198
+	.word	20551
+	.word	24832
+	.word	272
+	.word	13824
+	.word	21312
+	.word	26488
+	.word	24832
+	.word	262
+	.word	20992
+	.word	26156
+	.word	22851
+	.word	26044
+	.word	22595
+	.word	4614
+	.word	18497
+	.word	7966
+	.word	12831
+	.word	4638
+	.word	7169
+	.word	-4439
+	.word	28927
+	.word	4097
+	.word	16129
+	.word	4639
+	.word	16885
+	.word	0
+	.word	4120
+	.word	-12287
+	.word	6848
+	.word	20939
+	.word	-8
+	.word	20180
+	.word	21760
+	.word	12809
+	.word	26396
+	.word	-7320
+	.word	29184
+	.word	4033
+	.word	21313
+	.word	-15866
+	.word	-25015
+	.word	25098
+	.word	7198
+	.word	7937
+	.word	12831
+	.word	4614
+	.word	20551
+	.word	-4503
+	.word	-32703
+	.word	29184
+	.word	7936
+	.word	12831
+	.word	7942
+	.word	12319
+	.word	7198
+	.word	4102
+	.word	-4504
+	.word	4608
+	.word	17921
+	.word	18049
+	.word	16885
+	.word	6144
+	.word	6872
+	.word	20939
+	.word	-4
+	.word	20180
+	.word	21255
+	.word	3846
+	.word	26474
+	.word	18951
+	.word	26116
+	.word	32264
+	.word	7198
+	.word	21255
+	.word	3846
+	.word	26368
+	.word	198
+	.word	18951
+	.word	26116
+	.word	32264
+	.word	7198
+	.word	24944
+	.word	5632
+	.word	27164
+	.word	-10749
+	.word	21255
+	.word	3846
+	.word	22208
+	.word	-27136
+	.word	18951
+	.word	26116
+	.word	32264
+	.word	7198
+	.word	24920
+	.word	21248
+	.word	16131
+	.word	7808
+	.word	13855
+	.word	24910
+	.word	3072
+	.word	32
+	.word	25606
+	.word	4147
+	.word	0
+	.word	24602
+	.word	-6392
+	.word	4614
+	.word	22343
+	.word	25098
+	.word	7198
+	.word	7937
+	.word	12831
+	.word	4614
+	.word	20551
+	.word	-4503
+	.word	513
+	.word	7
+	.word	-32767
+	.word	6848
+	.word	20939
+	.word	-4
+	.word	20180
+	.word	18951
+	.word	26116
+	.word	32264
+	.word	7198
+	.word	7942
+	.word	12831
+	.word	7198
+	.word	4614
+	.word	-4503
+	.word	30463
+	.word	5633
+	.word	16885
+	.word	14336
+	.word	6872
+	.word	6872
+	.word	20180
+	.word	28672
+	.word	12807
+	.word	4032
+	.word	21312
+	.word	-13312
+	.word	-17152
+	.word	26118
+	.word	4118
+	.word	17920
+	.word	20545
+	.word	-28110
+	.word	0
+	.word	3073
+	.word	8
+	.word	25860
+	.word	29192
+	.word	21063
+	.word	-25023
+	.word	25092
+	.word	20551
+	.word	7198
+	.word	28672
+	.word	21249
+	.word	26390
+	.word	4032
+	.word	21312
+	.word	-16378
+	.word	-25023
+	.word	25098
+	.word	7198
+	.word	7936
+	.word	12319
+	.word	4102
+	.word	20551
+	.word	-4504
+	.word	960
+	.word	20085
+	.word	18951
+	.word	26116
+	.word	32264
+	.word	7198
+	.word	7942
+	.word	12319
+	.word	4126
+	.word	7168
+	.word	-4504
+	.word	4613
+	.word	6658
+	.word	-13824
+	.word	17922
+	.word	-16382
+	.word	17922
+	.word	-32767
+	.word	6848
+	.word	20180

+ 53 - 0
tigcc/pstarter/ttupfast/license.txt

@@ -0,0 +1,53 @@
+                wxWindows Library Licence, Version 3.1
+                ======================================
+
+  Copyright (C) 1998-2005 Julian Smart, Robert Roebling et al
+
+  Everyone is permitted to copy and distribute verbatim copies
+  of this licence document, but changing it is not allowed.
+
+                       WXWINDOWS LIBRARY LICENCE
+     TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+  
+  This library is free software; you can redistribute it and/or modify it
+  under the terms of the GNU Library General Public Licence as published by
+  the Free Software Foundation; either version 2 of the Licence, 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 Licence for more details.
+
+  You should have received a copy of the GNU Library General Public Licence
+  along with this software, usually in a file named COPYING.LIB.  If not,
+  write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+  Boston, MA 02111-1307 USA.
+
+  EXCEPTION NOTICE
+
+  1. As a special exception, the copyright holders of this library give
+  permission for additional uses of the text contained in this release of
+  the library as licenced under the wxWindows Library Licence, applying
+  either version 3.1 of the Licence, or (at your option) any later version of
+  the Licence as published by the copyright holders of version
+  3.1 of the Licence document.
+
+  2. The exception is that you may use, copy, link, modify and distribute
+  under your own terms, binary object code versions of works based
+  on the Library.
+
+  3. If you copy code from files distributed under the terms of the GNU
+  General Public Licence or the GNU Library General Public Licence into a
+  copy of this library, as this licence permits, the exception does not
+  apply to the code that you add in this way.  To avoid misleading anyone as
+  to the status of such modified files, you must delete this exception
+  notice from such code and/or adjust the licensing conditions notice
+  accordingly.
+
+  4. If you write modifications of your own for this library, it is your
+  choice whether to permit this exception to apply to your modifications. 
+  If you do not wish that, you must delete the exception notice from such
+  code and/or adjust the licensing conditions notice accordingly.
+
+

+ 140 - 0
tigcc/pstarter/ttupfast/ttunpack.h

@@ -0,0 +1,140 @@
+/******************************************************************************
+*
+* project name:    TIGCC Tools Suite
+* file name:       ttunpack.h
+* initial date:    01/02/2001
+* authors:         thomas.nussbaumer@gmx.net
+*                  samuel@nyall.net
+*
+* description:     defines for exepack functionalities including unpack routine
+*                  (complete rewrite of TIGCC Tools Suite header file)
+*
+*   This is a 100% assembly version of the ttunpack routine, which is
+*   based on code by Pasi 'Albert' Ojala, albert@cs.tut.fi, then
+*   reduced by Thomas Nussbaumer to fit his needs.  For a full details
+*   on the algorithm see:
+*
+*	  http://www.cs.tut.fi/~albert/Dev/pucrunch/index.html
+*
+*
+* Liscense:
+*
+*   The liscense is quite similar to that of the origional version in c.
+*
+*   The code may be freely used in any non commercial application.  If
+*   you do use it please give credit to tict (http://tict.ticalc.org) and
+*   myself (Samuel Stearley).  I state this as a request but it is actually
+*   not.
+*
+*   The author(s) (Samuel/Tict/Any other contributor) make no
+*   representations or warranties about the suitability of the software,
+*   either express or implied. The author(s) shall not be liable for
+*   any damages suffered as a result of using or distributing this
+*   software.
+*
+*   If you distribute this file on a website or as part of
+*   the source of a project do not remove the liscense from this file.
+*
+*
+* $Id: ttunpack.h,v 1.1 2006-02-28 23:36:58 kevinkofler Exp $
+*
+******************************************************************************/
+#ifndef __TTUNPACK_H__
+#define __TTUNPACK_H__
+
+typedef struct {
+    unsigned char  osize_lo;   // original size lowbyte
+    unsigned char  osize_hi;   // original size highbyte
+    unsigned char  magic1;     // must be equal to TTUNPACK_MAGIC1
+    unsigned char  magic2;     // must be equal to TTUNPACK_MAGIC2
+    unsigned char  csize_lo;   // compressed size lowbyte
+    unsigned char  csize_hi;   // compressed size lowbyte
+    unsigned char  esc1;       // escape >> (8-escBits)
+    unsigned char  notused3;
+    unsigned char  notused4;
+    unsigned char  esc2;       // escBits
+    unsigned char  gamma1;     // maxGamma + 1
+    unsigned char  gamma2;     // (1<<maxGamma)
+    unsigned char  extralz;    // extraLZPosBits
+    unsigned char  notused1;
+    unsigned char  notused2;
+    unsigned char  rleentries; // rleUsed
+} TTUNPACK_HEADER;
+
+#define TTUNPACK_MAGIC1 0x54
+#define TTUNPACK_MAGIC2 0x50
+
+#define ttunpack_size(_p_)  ((unsigned short)(((TTUNPACK_HEADER*)(_p_))->osize_lo | (((TTUNPACK_HEADER*)(_p_))->osize_hi << 8)))
+#define ttunpack_valid(_p_) (((TTUNPACK_HEADER*)(_p_))->magic1 == TTUNPACK_MAGIC1 && ((TTUNPACK_HEADER*)(_p_))->magic2 == TTUNPACK_MAGIC2)
+
+#define TTUNPACK_OKAY             0
+#define TTUNPACK_NOESCFOUND     248
+#define TTUNPACK_ESCBITS        249
+#define TTUNPACK_MAXGAMMA       250
+#define TTUNPACK_EXTRALZP       251
+#define TTUNPACK_NOMAGIC        252
+#define TTUNPACK_OUTBUFOVERRUN  253
+#define TTUNPACK_LZPOSUNDERRUN  254
+
+#define GREG_UNPACK_HEXARRAY
+
+#define ttunpack_decompress ((unsigned short(*)(unsigned char*,unsigned char*))(unsigned short[])\
+{\
+0x48e7,0x1f3e,0x2c6f,0x002c,0x2a6f,0x0030,0x47ee,0x000f,0x7a00,0x1a2e,\
+0x0006,0x7e08,0x7004,0x0c2e,0x0054,0x0002,0x667c,0x0c2e,0x0050,0x0003,\
+0x6674,0x7006,0x0c2e,0x0008,0x000a,0x666a,0x0c2e,0x0080,0x000b,0x6662,\
+0x7007,0x7200,0x122e,0x0009,0x2801,0x5141,0x6254,0x7005,0x7200,0x122e,\
+0x000c,0x2241,0x5b41,0x6e46,0x7400,0x09c2,0x5342,0xe83a,0xe83d,0x7000,\
+0x1013,0x4df6,0x0010,0x49fa,0x003c,0x4a04,0x6604,0x49fa,0x0052,0x4fef,\
+0xfefc,0x244f,0x421a,0x7000,0x7207,0x7600,0x01c3,0x14c0,0x5343,0x66fa,\
+0x5240,0x51c9,0xfff2,0x244f,0x1c1e,0x4ed4,0x7000,0x4fef,0x0104,0x4400,\
+0x4cdf,0x7cf8,0x4e75,0x1ac0,0x1f06,0x301f,0x1c1e,0x1006,0xee68,0x1202,\
+0xc200,0xb205,0x66ec,0x558e,0x1c1e,0x9e44,0x6204,0x1c1e,0x5047,0x6100,\
+0x0110,0x3600,0x5340,0x6778,0x6100,0x0106,0x5200,0x662c,0x5943,0x65bc,\
+0x5843,0x1206,0x4841,0x1f1e,0x321f,0x121e,0x1c01,0xeea9,0x70ff,0x1001,\
+0x3f01,0x121f,0x41f5,0x0000,0x1018,0xd001,0x1ac0,0x51cb,0xfff8,0x4ed4,\
+0x5500,0x3209,0x671c,0xe368,0x7200,0x0fc1,0x5341,0xc206,0x9e49,0x620a,\
+0x1c1e,0x1f01,0x321f,0x1206,0x5047,0xee69,0x8041,0x7200,0x1f00,0x321f,\
+0x1f06,0x301f,0x1c1e,0x1006,0xee68,0x1200,0x4601,0x4681,0x41f5,0x1800,\
+0x1ad8,0x51cb,0xfffc,0x4ed4,0x5307,0x0f06,0x676a,0x4a07,0x6604,0x7e08,\
+0x1c1e,0x5307,0x0f06,0x6700,0x00c6,0x4a07,0x6604,0x7e08,0x1c1e,0x6170,\
+0x1600,0x6a1c,0xd603,0x5307,0x0f06,0x56c0,0x9600,0x4a07,0x6604,0x7e08,\
+0x1c1e,0x6158,0x5300,0x3f03,0x1e80,0x361f,0x614e,0x0c00,0x0020,0x6406,\
+0x1033,0x0000,0x601a,0xe708,0x1206,0x5747,0x620a,0x1c1e,0x1f01,0x321f,\
+0x1206,0x5047,0xee69,0x0201,0x0007,0x8001,0x1ac0,0x51cb,0xfffc,0x4ed4,\
+0x4a07,0x6604,0x7e08,0x1c1e,0x1f06,0x321f,0x1c1e,0x1206,0xee69,0x76ff,\
+0x1601,0x41f5,0x3800,0x1ad8,0x1ad8,0x4ed4,0x7000,0x3207,0x0fc0,0x5340,\
+0xcc00,0xbd00,0x6606,0x1016,0x4600,0x5041,0x9232,0x0000,0x0c01,0x0008,\
+0x6504,0x7208,0x5247,0x9e41,0x6204,0x5047,0x1c1e,0x7000,0x5301,0x6716,\
+0x0fc0,0x5340,0xc006,0x9e41,0x620a,0x1c1e,0x1f00,0x301f,0x1006,0x5047,\
+0xee68,0x03c0,0x4e75,0x4a07,0x6604,0x7e08,0x1c1e,0x1f06,0x301f,0x101e,\
+0x1c00,0xee68,0x1205,0x1a02,0xca00,0x4602,0xc002,0x4602,0x8001,0x1ac0,\
+0x4ed4})
+
+#endif
+
+//=============================================================================
+// Revision History
+//=============================================================================
+//
+// $Log: not supported by cvs2svn $
+//
+// Revision 2.0  2004/08/30 12:00:00  Samuel Stearley
+// New extraction routine in 100% asm.
+//
+// Revision 1.4  2002/03/28 21:17:28  tnussb
+// project name in header changed to TIGCC Tools Suite
+//
+// Revision 1.3  2002/03/13 15:09:58  tnussb
+// new exepack decompression function generated from old/unpack.c added
+// (its a little bit smaller now). The new function should work as the old one,
+// but if there are problems I will leave the old hexcode array here, too
+//
+// Revision 1.2  2001/02/05 20:33:01  Thomas Nussbaumer
+// (1) magic of ttunpack header splitted again into 2 bytes to prevent address errors
+// (2) new (stable?) pc-relative version of unpacking routine
+//
+//
+
+
+ 

+ 663 - 0
tigcc/pstarter/ttupfast/unpack.asm

@@ -0,0 +1,663 @@
+;-----------------------------------------------------------------------
+;INTRODUCTION:
+;
+;   This is a 100% assembly version of the ttunpack routine, which is
+;   based on code by Pasi 'Albert' Ojala, albert@cs.tut.fi, then
+;   reduced by Thomas Nussbaumer to fit his needs.  For a full details
+;   on the algorithm see:
+;
+;	  http://www.cs.tut.fi/~albert/Dev/pucrunch/index.html
+;
+;   Version 2.28 Fast
+;
+;
+;THE LICENSE:
+;
+; Copyright (C) 2004-2005 Samuel Stearley
+;
+;               wxWindows Library Licence, Version 3.1
+;               ======================================
+;
+; Copyright (C) 1998-2005 Julian Smart, Robert Roebling et al
+;
+; Everyone is permitted to copy and distribute verbatim copies
+; of this licence document, but changing it is not allowed.
+;
+;                      WXWINDOWS LIBRARY LICENCE
+;    TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU Library General Public Licence as published by
+; the Free Software Foundation; either version 2 of the Licence, 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 Licence for more details.
+;
+; You should have received a copy of the GNU Library General Public Licence
+; along with this software, usually in a file named COPYING.LIB.  If not,
+; write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+; Boston, MA 02111-1307 USA.
+;
+; EXCEPTION NOTICE
+;
+; 1. As a special exception, the copyright holders of this library give
+; permission for additional uses of the text contained in this release of
+; the library as licenced under the wxWindows Library Licence, applying
+; either version 3.1 of the Licence, or (at your option) any later version of
+; the Licence as published by the copyright holders of version
+; 3.1 of the Licence document.
+;
+; 2. The exception is that you may use, copy, link, modify and distribute
+; under your own terms, binary object code versions of works based
+; on the Library.
+;
+; 3. If you copy code from files distributed under the terms of the GNU
+; General Public Licence or the GNU Library General Public Licence into a
+; copy of this library, as this licence permits, the exception does not
+; apply to the code that you add in this way.  To avoid misleading anyone as
+; to the status of such modified files, you must delete this exception
+; notice from such code and/or adjust the licensing conditions notice
+; accordingly.
+;
+; 4. If you write modifications of your own for this library, it is your
+; choice whether to permit this exception to apply to your modifications. 
+; If you do not wish that, you must delete the exception notice from such
+; code and/or adjust the licensing conditions notice accordingly.
+;
+;
+;NOTES:
+;
+;1) There were several other names associated with this, but not
+;   anymore ;)
+;
+;
+;2) There should be an unpack.c distributed with this that has
+;   additional comments that will help clarify what this is doing.
+;   But maybe not.  It depends on where you got this.  you should
+;   always be able to find this on my site:  http://www.nyall.net
+;
+;
+;3) If caller wants, they can alter the default int priority to
+;   speed up execution before calling this routine.
+;
+;
+;4) The code was written with wordpad.  It might look better if
+;   opened with that program.
+;
+;
+;5) A version of this is included as a hex array for use with programs
+;   written with tigcc.  OR you can use this file directly with a
+;   tigcc project: add it to the project and remove the ';' from
+;   before the 'CALL_DIRECTLY' below.  Be sure to have the latest
+;   version of tigcc when doing this.
+;----------------------------------------------------------------------
+
+;CALL_DIRECTLY		;if this label is defined then this code can be used
+				;  directly as part of a tigcc project.
+
+DELTA_LZ			;If defined it will include code to do DELTA lz decompression
+				;  ebooks and ppg compressed programs currently do not take advantage of
+				;  the -fdelta option of the compressor.
+
+;UNROLL_RLE
+
+;UNROLL_LZ
+
+
+
+ ifd CALL_DIRECTLY
+	public ttunpack_decompress
+ endc
+
+
+ ifnd CALL_DIRECTLY
+	include "os.h"
+	xdef _ti89
+	xdef _nostub
+ endc
+
+
+
+osize_lo		equ	0	;original size lowbyte
+osize_hi		equ	1	;original size highbyte
+magic1		equ	2	;must be equal to UNPACK_MAGIC1
+magic2		equ	3	;must be equal to UNPACK_MAGIC2
+csize_lo		equ	4	;compressed size lowbyte
+csize_hi		equ	5	;compressed size lowbyte
+esc1			equ	6	;escape >> (8-escBits)
+notused3		equ	7	;
+notused4		equ	8	;
+esc2			equ	9	;escBits
+gamma1		equ	10	;maxGamma + 1
+gamma2		equ	11	;(1<<maxGamma)
+extralz		equ	12	;extraLZPosBits
+notused1		equ	13	;
+notused2		equ	14	;
+rleentries		equ	15	;rleUsed
+
+HEADER_SIZE		equ	16
+
+__MAGIC_CHAR1	equ	$54
+__MAGIC_CHAR2	equ	$50
+
+__ERRPCK_OKAY		equ	0
+__ERRPCK_NOESCFOUND	equ	8		;248
+__ERRPCK_ESCBITS		equ	7		;249
+__ERRPCK_MAXGAMMA		equ	6		;250
+__ERRPCK_EXTRALZP		equ	5		;251
+__ERRPCK_NOMAGIC		equ	4		;252
+__ERRPCK_OUTBUFOVERRUN	equ	3		;253
+__ERRPCK_LZPOSUNDERRUN	equ	2		;254
+
+;-----------------------------------------------------------------------
+;Notes on register useage, might be good Idea to print this.
+;
+;	a0 => trashing, but may not be used by the subroutines
+;	a1 => extra z position bits
+;	a2 => a table that maps a byte to the highest bit set in it.
+;	a3 => the bytecodevec table
+;	a4 => The point to jump to when doing a continue
+;	a5 => the destination buffer
+;	a6 => points to the next byte of the compressed data.
+;		updated when d7 overflows.
+;
+;	d0 => trashing, output of __GetBits and __GetValue
+;	d1 => trashing, input to __GetBits
+;	d2 => prepared mask for isolating # of escape bits
+;	d3 => trashing but only by the main routine, not the subroutines
+;		It is usually the prepared count.
+;	d4 => # of escape bits
+;	d5 => start escape
+;	d6 => the current compressed byte, updated when d7 overflows.
+;	d7 => which bit we are at in the compressed data.
+;-----------------------------------------------------------------------
+
+CORRECT_IN_MASK	MACRO
+	tst.b		d7
+	bne.s		\@fun
+	moveq		#8,d7
+	move.b	(a6)+,d6
+\@fun
+	ENDM
+
+
+
+ttunpack_decompress:
+
+ ifnd CALL_DIRECTLY
+	dc.b		"UNPACK_0"
+ endc
+
+	movem.l	d3-d7/a2-a6,-(a7)
+	move.l	4+10*4(a7),a6
+	move.l	8+10*4(a7),a5
+;--------------------------------------------------------
+;  startesc = cth->esc1;     //d5
+;  bytecodevec = &src[15];   //a3
+;  __imask__   = 0x80;	     //d7
+;
+;These are initialized here to insure that certain
+;branches can use the short form.
+;--------------------------------------------------------
+	lea		15(a6),a3			;'bytecodevec'
+	moveq		#0,d5
+	move.b	esc1(a6),d5			;'StartEsc'
+	moveq		#8,d7				;which bit i am at
+;-------------------------------------------------------------------------------------------------
+;  if (cth->magic1 != __MAGIC_CHAR1 || cth->magic2 != __MAGIC_CHAR2) return __ERRPCK_NOMAGIC;
+;  if (cth->gamma1 != 8 || cth->gamma2 != 128)                       return __ERRPCK_MAXGAMMA;
+;  if ((escbits = cth->esc2) > 8)                                    return __ERRPCK_ESCBITS;
+;  if ((extralzposbits = cth->extralz) > 4)                          return __ERRPCK_EXTRALZP;
+;-------------------------------------------------------------------------------------------------
+	moveq		#__ERRPCK_NOMAGIC,d0
+	cmp.b		#__MAGIC_CHAR1,magic1(a6)	;these could be optimized into 1 word compare
+	bne.s		__ReturnError			;  if evenly aligned.
+	cmp.b		#__MAGIC_CHAR2,magic2(a6)
+	bne.s		__ReturnError
+
+	moveq		#__ERRPCK_MAXGAMMA,d0
+	cmp.b		#8,gamma1(a6)
+	bne.s		__ReturnError
+	cmp.b		#128,gamma2(a6)
+	bne.s		__ReturnError
+
+	moveq		#__ERRPCK_ESCBITS,d0
+	moveq		#0,d1
+	move.b	esc2(a6),d1
+	move.l	d1,d4
+	subq.w	#8,d1
+	bhi.s		__ReturnError
+
+	moveq		#__ERRPCK_EXTRALZP,d0
+	moveq		#0,d1
+	move.b	extralz(a6),d1
+	move.l	d1,a1			;extralz pos bits
+	subq.w	#5,d1
+	bgt.s		__ReturnError
+;--------------------------------------------------------
+;  escbits8 = 8 - escbits;   //not used
+;  __ibuffer__ = src + sizeof(__PACKHEADER) + cth->rleentries;  //a6
+;--------------------------------------------------------
+	moveq		#0,d2
+	bset		d4,d2
+	subq.w	#1,d2			;the mask for the number of escape bits
+	ror.b		d4,d2			;set the upper bits
+	ror.b		d4,d5			;shift up start escape
+	moveq		#0,d0
+	move.b	(a3),d0		
+	lea		HEADER_SIZE(a6,d0),a6
+;--------------------------------------------------------
+;To remove checking if escbits == 0 in the literal byte
+;  loop, there are two points used for continuing.
+;--------------------------------------------------------
+	lea		__ReturnPointForNonZeroEscapeBits(pc),a4
+	tst.b		d4
+	bne.s		__Skipper
+	lea		__SelIsStartEscape(pc),a4
+__Skipper:
+;--------------------------------------------------------
+;a2 will point to a table that maps a byte to the
+;  highest bit set in it.  0 will be mapped to zero,
+;  this is important.
+;--------------------------------------------------------
+	lea		-260(a7),a7
+	move.l	a7,a2
+	clr.b		(a2)+
+	moveq		#0,d0
+	moveq		#7,d1
+AllBytes:
+	moveq		#0,d3
+	bset		d0,d3
+ThisByte:
+	move.b	d0,(a2)+
+	subq.w	#1,d3
+	bne.s		ThisByte
+	addq.w	#1,d0
+	dbra    	d1,AllBytes
+	move.l	a7,a2
+	move.b	(a6)+,d6		;very first byte of compressed data
+	jmp		(a4)			;jump into the loop
+;---------------------------------------------------------
+;And when all is done branch here
+;---------------------------------------------------------
+__WeAreDone:
+	moveq		#0,d0			;return value
+	lea		260(a7),a7
+__ReturnError:
+	neg.b		d0			;turn loaded error code into actual value
+	movem.l	(a7)+,d3-d7/a2-a6
+	rts
+
+;---------------------------------------------------------
+;  *outbuffer++ = (sel<<escbits8) | __GetBits(escbits8);
+;  continue;
+;---------------------------------------------------------
+__SelIsNOTStartEscape:
+	move.b	d0,(a5)+			;put litteral byte to the output
+;---------------------------------------------------------
+;The while(1) loop:
+;
+;  sel = (escbits) ? __GetBits(escbits) : startesc;
+;  if (sel == startesc) {
+;---------------------------------------------------------
+__ReturnPointForNonZeroEscapeBits
+	move.b	d6,-(a7)
+	move.w	(a7)+,d0
+	move.b	(a6)+,d6
+	move.b	d6,d0
+	lsr.w		d7,d0				;__get8bits() done
+	move.b	d2,d1
+	and.b		d0,d1				;isolate the upper escape bits
+	cmp.b		d5,d1				;are they 'startesc'
+	bne.s		__SelIsNOTStartEscape
+	subq.l	#2,a6
+	move.b	(a6)+,d6
+	sub.w		d4,d7
+	bhi.s		__StillInSameByte2
+	move.b	(a6)+,d6
+	addq.w	#8,d7
+__StillInSameByte2:
+;---------------------------------------------------------
+;The following code is entered if sel == startesc
+;but it does not actually use the sel variable
+;
+;  lzlen = __GetValue();
+;  if (lzlen != 1) {
+;---------------------------------------------------------
+__SelIsStartEscape:
+	bsr		__GetValue		;get a value for 'lzlen'
+	move.w	d0,d3			;save 'lzlen'
+	subq.w	#1,d0			;does 'lzlen' == 1 ?
+	beq.s		__RleDecoding
+;---------------------------------------------------------
+;Zip decoding
+;
+;  lzposhi = __GetValue() - 1;
+;  if (lzposhi == 254) {
+;---------------------------------------------------------
+
+ ifnd DELTA_LZ
+	bsr		__GetValue		;if it equals 254, then lzlen must be > 3 because
+	addq.b	#1,d0			;  there is no other possiblity because Delta decompression
+	beq.s		__WeAreDone		;  is not being used.  It the branch is not taken it
+ endc						;  drops through to the __LzPosHi_IsNot254
+
+
+ ifd DELTA_LZ
+		bsr		__GetValue		;get 'lzposhi', dont subtract 1 yet
+		addq.b	#1,d0			;does 'lzposhi' == 254, remember it has not yet subtracted 1
+		bne.s		__LzPosHi_IsNot254
+		subq.w	#4,d3			;is 'lzlen' greater than 3?
+		bcs.s		__WeAreDone		;destination is above
+	;---------------------------------------------------------
+	;  add   = __Get8Bit();			//put into d1
+	;  lzpos = __Get8Bit() ^ 0xff;	//put into d0
+	;
+	;take advantage of the fact that two __Get8Bit's are used
+	;sequentially by inlining them.
+	;
+	;the bit inverstion and the pointer subtraction will be
+	;  combined
+	;---------------------------------------------------------
+		addq.w	#4,d3			;undo above subq.w
+		move.b	d6,d1			;put current byte into d1
+		swap		d1			;put it in the upper word
+		move.b	(a6)+,-(a7)		;get the second byte
+		move.w	(a7)+,d1		;put it in d1
+		move.b	(a6)+,d1		;the third byte
+		move.b	d1,d6
+		lsr.l		d7,d1
+		moveq		#-1,d0
+		move.b	d1,d0			;d0 is -'lzpos' +1
+		move.w	d1,-(a7)
+		move.b	(a7)+,d1		;shift it 8 bits to the right
+	;---------------------------------------------------------
+	;  for (i=0; i<=lzlen; i++) {
+	;    *outbuffer = *(outbuffer - lzpos - 1) + add;
+	;    outbuffer++;
+	;  }
+	;---------------------------------------------------------
+		lea		0(a5,d0.w),a0
+	__WriteDataLoop2:
+		move.b	(a0)+,d0
+		add.b		d1,d0
+		move.b	d0,(a5)+
+		dbra		d3,__WriteDataLoop2
+		jmp		(a4)				;continue
+ endc
+;----------------------------------------------------------------------------------------
+;  if (extralzposbits) lzposhi = (lzposhi<<extralzposbits) | __GetBits(extralzposbits);
+;  lzposlo = __Get8Bit() ^ 0xff;
+;  lzpos   = COMBINE_LOWHIGH(lzposlo,lzposhi);
+;
+; d0= lzPosHi, d3.w = lzlen, d1.l =lzpos
+;----------------------------------------------------------------------------------------
+__LzPosHi_IsNot254:
+	subq.b	#2,d0				;undo the addq.b #1
+	move.w	a1,d1				;is 'extralzposbits' == 0?
+	beq.s		__extralZposBitsIsZero
+	lsl.w		d1,d0				;shift it by 'extralzposbits'
+	moveq		#0,d1
+	bset.w	d7,d1
+	subq.w	#1,d1
+	and.b		d6,d1
+	sub.w		a1,d7
+	bhi.s		__StillInSameByte61
+	move.b	(a6)+,d6
+	move.b	d1,-(a7)
+	move.w	(a7)+,d1
+	move.b	d6,d1
+	addq.w	#8,d7
+__StillInSameByte61:
+	lsr.w		d7,d1
+	or.w		d1,d0				;or them back together
+__extralZposBitsIsZero:				;at this point d0.b == 'lzposhi'
+	moveq		#0,d1
+	move.b	d0,-(a7)			;a faster way to do lsl.w #8
+	move.w	(a7)+,d1			;shift it into the high byte of 'lzpos', first step of COMBINE_LOWHIGH
+	move.b	d6,-(a7)			;start the __Get8Bit
+	move.w	(a7)+,d0
+	move.b	(a6)+,d6
+	move.b	d6,d0
+	lsr.w		d7,d0				;get 8 bit done
+	move.b	d0,d1				;COMBINE_LOWHIGH
+	not.b		d1
+	not.l		d1
+;-----------------------------------------------------------------------------------
+;  for (i=0; i<=lzlen; i++) {
+;    *outbuffer = *(outbuffer - lzpos - 1); //no 'add' variable
+;    outbuffer++;
+;  }
+;
+; d2.l must be -lzpos+1
+; d3.w must be lzlen
+;------------------------------------------------------------------------------------
+	lea		0(a5,d1.l),a0
+
+ ifd UNROLL_LZ
+	lsr.w		#1,d3
+	bcc.s		__FirstByte
+__WriteDataLoop:
+	move.b	(a0)+,(a5)+
+__FirstByte:
+	move.b	(a0)+,(a5)+
+	dbra		d3,__WriteDataLoop
+ endc
+
+ ifnd UNROLL_LZ
+__WriteDataLoop:
+	move.b	(a0)+,(a5)+
+	dbra		d3,__WriteDataLoop
+ endc
+
+	jmp		(a4)				;continue
+;----------------------------------------------------------------------
+;'lzlen' = 1
+;    RLE decoding, OR 2 byte zip, OR escape from the escape
+;----------------------------------------------------------------------
+__RleDecoding:
+	subq.b	#1,d7
+	btst.b	d7,d6
+	beq.s		__NextBitClear_DoZipAfterAll
+
+ CORRECT_IN_MASK
+
+;The second NEXT_BIT_SET()
+
+	subq.b	#1,d7
+	btst.b	d7,d6
+	beq		__NextBitIsClear_EscapeFromEscape
+;-----------------------------------------------------------------
+;  rlelen = __GetValue();
+;  if (rlelen >= 128) {
+;     rlelen = ((rlelen-128)<<1) | __GetBits(1);
+;     rlelen |= (((__GetValue())-1)<<8);
+;  }
+;------------------------------------------------------------------
+__NextBitIsSet_RunLengthEncoding:
+ CORRECT_IN_MASK
+
+	bsr.s		__GetValue		;get 'rlelen' into d0, limited to 8 bit values.
+	move.b	d0,d3			;copy it and check sign bit to see if >= 128
+	bpl.s		__LessThan128
+;	sub.w		#128,d3		;not needed
+	add.b		d3,d3			;double it, this clears the high bit so there is no need to subtract 128
+
+;-----An Inlined version of __GetBits optimized for an input of 1 --------
+
+	subq.b	#1,d7
+	btst.b	d7,d6
+	sne		d0
+	sub.b		d0,d3			;subtract -1 if the bit was set = add 1
+ CORRECT_IN_MASK
+
+	bsr.s		__GetValue
+	subq.b	#1,d0
+	move.w	d3,-(a7)
+	move.b	d0,(a7)
+	move.w	(a7)+,d3
+;-------------------------------------------------------------------
+;Need the byte to copy
+;
+;  bytecode = __GetValue();
+;  if (bytecode < 32) byte = bytecodevec[bytecode];
+;  else               byte = ((bytecode-32)<<3) | __GetBits(3); //subracting 32 not needed
+;-------------------------------------------------------------------
+__LessThan128:
+	bsr.s		__GetValue			;get bytecode
+	cmp.b		#32,d0
+	bcc.s		__GreaterThanOrEqual32
+	move.b	0(a3,d0.w),d0		;byte = bytecodevec[bytecode];
+	bra.s		__RleCopy
+__GreaterThanOrEqual32:
+
+;-----An Inlined version of GetBits that is optimized for an input of 3-------
+
+	lsl.b		#3,d0
+	move.b	d6,d1
+	subq.w	#3,d7
+	bhi.s		__StillInSameByte2345
+	move.b	(a6)+,d6
+	move.b	d1,-(a7)
+	move.w	(a7)+,d1
+	move.b	d6,d1
+	addq.w	#8,d7
+__StillInSameByte2345:
+	lsr.w		d7,d1
+	and.b		#$7,d1
+	or.b		d1,d0
+;--------------------------------------------------------
+;  for (i=0; i<=rlelen; i++) *outbuffer++ = byte;
+;  continue;   // continue the main loop ...
+;
+;Rle loop expects
+; d0 = byte
+; d3 = number of em to copy, no need to subtract 1 for
+;	 dbra
+;--------------------------------------------------------
+__RleCopy:
+
+ ifd UNROLL_RLE
+	lsr.w		#1,d3
+	bcc.s		__FirstRleByte
+__RleLoop:
+	move.b	d0,(a5)+
+__FirstRleByte:
+	move.b	d0,(a5)+
+	dbra		d3,__RleLoop
+ endc
+
+ ifnd UNROLL_RLE
+__RleLoop:
+	move.b	d0,(a5)+
+	dbra		d3,__RleLoop
+ endc
+
+	jmp		(a4)
+;---------------------------------------------------------
+;  lzpos = __Get8Bit() ^ 0xff;
+;---------------------------------------------------------
+__NextBitClear_DoZipAfterAll:
+ CORRECT_IN_MASK
+	move.b	d6,-(a7)		;current byte
+	move.w	(a7)+,d1
+	move.b	(a6)+,d6		;next byte
+	move.b	d6,d1
+	lsr.w		d7,d1
+	moveq		#-1,d3
+	move.b	d1,d3
+	lea		0(a5,d3.l),a0
+	move.b	(a0)+,(a5)+
+	move.b	(a0)+,(a5)+		;'lzlen' is 1, means 2 byte copy.
+	jmp		(a4)			;continue
+;-------------------------------------------------------------
+;  __GetValue returns a value in d0.l
+;  __GetBits takes as its input d1.b, returns a value in d0.l
+;
+; The outputs can be manipulated as:
+;	unsigned character,
+;	unsigned shorts,
+;	unsigned longs
+;
+; They may update
+;	d6, d7, a6
+;
+; They may not destroy 
+;	d3-d5/a0-a5
+;
+; They expect a2 to be a table that tells the number of the
+;	highest bit that is set
+;
+;--------------------------------------------------------------
+__GetValue:					;This function has a goal of counting till it finds
+	moveq		#0,d0
+	move.w	d7,d1
+	bset.w	d7,d0
+	subq.w	#1,d0			;made the mask
+	and.b		d0,d6			;mask out bits of interest, clear bits that we have already
+						;  passed by
+	eor.b		d6,d0			;invert the bits of interest
+	bne.s		__BitsSetInThisByte
+	move.b	(a6),d0
+	not.b		d0
+	addq.w	#8,d1
+__BitsSetInThisByte:
+	sub.b		0(a2,d0.w),d1
+	cmp.b		#8,d1
+	bcs.s		__LessThan7
+	moveq		#8,d1
+	addq.w	#1,d7
+__LessThan7:
+	sub.w		d1,d7
+	bhi.s		__SameByte
+	addq.w	#8,d7
+	move.b	(a6)+,d6
+__SameByte:
+	moveq		#0,d0
+	subq.b	#1,d1
+	beq.s       __inl_exit4
+	bset.w	d7,d0
+	subq.w	#1,d0
+	and.b		d6,d0
+	sub.w		d1,d7
+	bhi.s		__StillInSameByte4
+	move.b	(a6)+,d6
+	move.b	d0,-(a7)
+	move.w	(a7)+,d0
+	move.b	d6,d0
+	addq.w	#8,d7
+__StillInSameByte4:
+	lsr.w		d7,d0
+__inl_exit4:
+	bset.b	d1,d0
+	rts
+;-----------------------------------------------------------------
+;  newesc = __GetBits(escbits);
+;  *outbuffer++ = (startesc<<escbits8) | __GetBits(escbits8);
+;  startesc = newesc;
+;  continue;
+;-----------------------------------------------------------------
+__NextBitIsClear_EscapeFromEscape:
+ CORRECT_IN_MASK
+	move.b	d6,-(a7)
+	move.w	(a7)+,d0
+	move.b	(a6)+,d0
+	move.b	d0,d6
+	lsr.w		d7,d0			;get8bits done
+	move.b	d5,d1			;save old 'startesc'
+	move.b	d2,d5
+	and.b		d0,d5			;set the new start esc
+	not.b		d2
+	and.b		d2,d0			;isolate the lower bits
+	not.b		d2
+	or.b		d1,d0			;recombine
+	move.b	d0,(a5)+
+	jmp		(a4)
+
+
+ ifnd CALL_DIRECTLY
+	dc.b		"UNPACK_1"
+ endc

+ 1 - 7
tigcc/setup/CreateSourceZip.bat

@@ -3,15 +3,10 @@
 SET INFOZIPDIR=E:\zip\zip
 SET ZIPDIR=E:\TI-89\tigcc-096
 SET A68KSRCDIR=E:\TI-89\A68k\source
-SET PSTARTERSRCDIR=E:\TI-89\pstarter
 SET TTPACKSRCDIR=E:\TI-89\Compilers\tigcc\tt\src\pctools
 
 MD a68k
 COPY "%A68KSRCDIR%\*.*" a68k
-MD pstarter
-FOR %%i IN ("%PSTARTERSRCDIR%\LGPL.txt" "%PSTARTERSRCDIR%\pstarter.s" "%PSTARTERSRCDIR%\pstarter.tpr" "%PSTARTERSRCDIR%\pstarter.txt" "%PSTARTERSRCDIR%\pst-ttup.h") DO COPY "%%i" pstarter
-MD pstarter\ttunpack
-COPY "%PSTARTERSRCDIR%\ttunpack\*.*" pstarter\ttunpack
 MD ttpack
 FOR %%i IN ("%TTPACKSRCDIR%\..\..\readme.txt" "%TTPACKSRCDIR%\packhead.h" "%TTPACKSRCDIR%\revtools.h" "%TTPACKSRCDIR%\tt.h" "%TTPACKSRCDIR%\ttpack.c" "%TTPACKSRCDIR%\ttversion.h") DO COPY "%%i" ttpack
 
@@ -19,11 +14,10 @@ DEL "%ZIPDIR%\tigccsrc.zip"
 CD ..\doc
 "%INFOZIPDIR%\zip.exe" -9 -r "doc.zip" Programs System -x CVS
 CD ..\setup
-"%INFOZIPDIR%\zip.exe" -9 -r "%ZIPDIR%\tigccsrc.zip" ..\Readme.txt ..\License.txt a68k ..\archive ..\components ..\doc\doc.zip ..\gcc ..\general ..\hsf2rc ..\ide ..\ld-tigcc pstarter ..\setup\*.nsi ..\setup\*.ini ..\setup\*.bat ..\setup\makeall.pif ..\tigcc ..\tprbuilder ttpack -x CVS
+"%INFOZIPDIR%\zip.exe" -9 -r "%ZIPDIR%\tigccsrc.zip" ..\Readme.txt ..\License.txt a68k ..\archive ..\components ..\doc\doc.zip ..\gcc ..\general ..\hsf2rc ..\ide ..\ld-tigcc ..\pstarter ..\setup\*.nsi ..\setup\*.ini ..\setup\*.bat ..\setup\makeall.pif ..\tigcc ..\tprbuilder ttpack -x CVS
 DEL ..\doc\doc.zip
 
 DELTREE /Y a68k
-DELTREE /Y pstarter
 DELTREE /Y ttpack
 
 ECHO Finished.