@DATABASE "ACEReference.doc"
@MASTER "ACEReference"

@NODE MAIN "Main Menu"

                         +---------------------------+
                         | ACE Enhancer Project V1.0 |
                         +---------------------------+

			
                        @{" Introduction                 " link 1introduction}
                        @{" Getting started              " link 2started}
                        @{" History                      " link 3history}
                        @{" Stop bits                    " link 4stop}


@ENDNODE
@NODE 1introduction "Introduction"
                               Introduction
                               ------------



                        @{" What is the ACE Enhancer Project?" link 1what}
                        @{" Who is it for?                   " link 1who}


@ENDNODE
@NODE 2started "Getting started"
                               Getting started
                               ---------------


                        @{" Installation                 " link 2installation}
                        @{" Using AEP                    " link 2using}
                        @{" Enhanced string routines     " link 1enhancedstringcalls}
                        @{" Enhanced math routines       " link 1enhancedmathcalls}
                        @{" Hints,tips and chips         " link 2hintstips}


@ENDNODE
@NODE 3history "History"
                                 History
                                 -------

           ! = bugfix.
           m = minor update.
           M = major update.

14/08/1997   Second public release.
             Mostly updated the guide.

12/11/1996   First public release.


@ENDNODE
@NODE 4stop "Stop bits"

                                 Stop bits
                                 ---------


                  @{" Future versions                      " link 4future}
                  @{" A note to PD libraries and reviewers " link 4pd}
                  @{" Disclaimer                           " link 4disclaim}
                  @{" Contacting the author                " link 4author}
                  @{" Final word                           " link 4final}

@ENDNODE
@NODE 1what "What is the ACE Enhancer Project?"
What is the ACE Enhancer Project?
---------------------------------

A set of speedy assembly routines ment to replace some of the original
ACE routines.

At this point most of the ACE @{"String" link 1enhancedstringcalls} calls are supported.

All of the ACE @{"Integer Math" link 1enhancedmathcalls} calls are supported.

The complete ACE Enhancer Project may be freely distributed.
 

@ENDNODE
@NODE 1who "Who is it for?"
Who is it for?
--------------

The ACE Enhancer Project is intended only for anyone who already knows ACE
and wants the following:

	- Even faster program execution.


@ENDNODE

@NODE 1enhancedstringcalls "Enhanced Stringcalls."
Enhanced Stringcalls.
---------------------

                            Rewritten routines.
                            ...................

     String assignment.    @{"_strcpy             " link 1strcpy}
     String length.        @{"_strlen             " link 1strlen}
     String slicing.       @{"_leftstr            " link 1stringslice}
                           @{"_rightstr           " link 1stringslice}
                           @{"_midstr             " link 1stringslice}
     String concatenation. @{"_strcat             " link 1strcat}
     String comparison.    @{"_streq              " link 1streq}
     String searching.     @{"_instr              " link 1instr}


@ENDNODE


@NODE 1enhancedmathcalls "Enhanced Mathcalls."
Enhanced Mathcalls.
-------------------

                            Rewritten routines.
                            ...................

     Multiplying           @{"lmul(u)             " link 1lmul}
     Division              @{"ace_ldiv            " link 1ldiv}
     Modulo                @{"ace_lrem            " link 1lrem}


@ENDNODE

@NODE 1strcpy "String assignment."
String assignment=String copying=_strcpy.
-----------------------------------------

This is one of the most heavely used string routines found in ACE.
So even a small gain, 15%-25% with short strings, could be very beneficial
in tight loops.
Speed increase can vary between 75% and 200+% when used with medium sized or
large strings.


Notes: _strcpy is also used to support other ACE functions/routines.
       When using the SuperOptimizer V2.01 with (I)nline option it will
       be inlined, saving one JSR and RTS instruction.


Ex.  : A$=""
       A$="ACE"
       B$=A$
       B$=A$+A$


@ENDNODE

@NODE 1strlen "String length"
String length=_strlen.
----------------------

Hmm, my version of getting a string length...
Code is rather strange but very efficient :)
Speed increase can vary between 10% and 30+% when used with medium sized or
large strings.


Notes: When using the SuperOptimizer V2.01 with (I)nline option it will
       be inlined, saving one JSR and RTS instruction.


Ex.  : _SIZE=LEN(A$)


@ENDNODE
@NODE 1stringslice "String Slicing"
String slicing.
--------------

All three string slicing routines, _leftstr,_rightstr and _midstr have
been rewritten for maximum speed.
Again, speed increase will vary depending on the string length, but it
should be at least 15%.
In general, higher figures (30+%) will be encountered.


Notes: When using the SuperOptimizer V2.01 with (I)nline option, the _leftstr
       routine will be inlined, saving one JSR and RTS instruction.

       The original ACE MID$ function seems to be bugged.
       Try to give a negative start position and you'll see what I mean.
       Ex.  : Dest$=(SRC$,-2,7)


Ex.  : Dest$=LEFT$(SRC$,5)
       Dest$=RIGHT$(SRC$,2)
       Dest$=MID$(SRC$,4,8)
       Dest$=MID$(SRC$,9)


@ENDNODE

@NODE 1strcat "String concatenation"
String concatenation=_strcat.
-----------------------------

Nothing much to say about this one, except that it is about 50-200% faster
than the original ACE routine.
This is, because the surrounding _strcpy routine is also replaced with
the new version.


Notes: When using the SuperOptimizer V2.01 with (I)nline option it will
       be inlined, saving one JSR and RTS instruction.


Ex.  : Dest$=SRC$+SRC$


@ENDNODE

@NODE 1instr "String searching"
String searching=_instr.
------------------------

After getting Daniel Seifert's New Ace Preprocessor, thank you David and Daniel, I
was interested in his INSTR replacement routine (Search2).
Soon I found out that it had certain flaws : 

 1) It has to be externally linked, so register D1-D7/A0-A6 are saved before
    and restored after the routine call.
    This results in a fairly high overhead, specially with small strings.

 2) It tends to be very slow, if the string to be searched (snippet) is actually
    larger in length than the string it has to be found in.

 3) It keeps on searching, even if snippet is larger than the remaining
    string length to compare. (Same as the original ACE routine I think...)

 4) It does not test if the start position is valid.


It took me several hours of testing and fine-tuning before a fully ACE
compatible version was created.

And..., surprise, surprise... It is at least 3 to 4 times faster than the ACE
original version and sometimes even 8 times faster!!!


Ex.  : _POS=INSTR(SRC$,"ACE is for ACES!!!")
       _POS=INSTR(_STARTPOS,SRC$,"Not for whimps!!!")


@ENDNODE

@NODE 1streq "String comparison."
String comparison.
------------------

At this point only 1 routine has been implemented; _streq.

The code seems rather strange but very effective, in fact I've never
encountered an implementation such as mine :)


Notes: When using the SuperOptimizer V2.01 with (I)nline option it will
       be inlined, saving one JSR and RTS instruction.


Ex.  : _EQUAL=SRC$=Dest$


@ENDNODE

@NODE 1lmul "Multiplying"
Multiplying=lmul(u).
--------------------

The new routines make use of the extended arithmetic capabilities that
are implemented in the MC68020/30 and 40 series of processors.

Due to restrictions of the MC68000 CPU, 32*32 bit multiplications have
to be performed in several steps.
These steps include three 16*16 bit multiplications, costing a lot 
of CPU-time.

These steps have now become just one instruction!

  - unsigned multiplication : MULU.L <ea>,Dn
  - signed multilpication   : MULS.L <ea>,Dn


Notes: I could be wrong, but I think that the MC68060 does not support
       these new capabilities.
       However, it seems that they are emulated through software.


@ENDNODE

@NODE 1ldiv "Division"
Division=ace_ldiv.
------------------

The new routine makes use of the extended arithmetic capabilities that
are implemented in the MC68020/30 and 40 series of processors.

Due to restrictions of the MC68000 CPU, 32/32 bit divisions have
to be performed in several steps costing a lot of CPU-time.

These steps have now become just one instruction!

  - signed division : DIVS.L <ea>,Dn


Notes: I could be wrong, but I think that the MC68060 does not support
       these new capabilities.
       However, it seems that they are emulated through software.

       Strange, ACE only supports only signed divisions?


@ENDNODE

@NODE 1lrem "Modulo"
Modulo=ace_lrem.
----------------

The new routine makes use of the extended arithmetic capabilities that
are implemented in the MC68020/30 and 40 series of processors.

Due to restrictions of the MC68000 CPU, 32/32 bit modulo's have
to be performed in several steps costing a lot of CPU-time.

These steps have now become just one instruction!

  - signed modulo : DIVS.L <ea>,Dn:Dn


Notes: I could be wrong, but I think that the MC68060 does not support
       these new capabilities.
       However, it seems that they are emulated through software.

       Strange, ACE only supports only signed modulo's?


@ENDNODE


@NODE 2installation "Installation"
Installation
------------

You will need to open a shell to install the ACE Enhancer Project
Installation consists of:

	- Extracting the archive found in the single supplied ACE Enhancer
     Project archive.
	  Copying the Stringlib.o and Math020.o to the ACE:lib drawer.
	  Copying the guide and it's icon to the ACE:docs drawer.  

	  ACE, ofcourse, has to be installed to be of any use. ;-)
 
That's it!


@ENDNODE
@NODE 2using "Using the ACE Enhancer Project"
Using the ACE Enhancer Project.
-------------------------------

There are two ways to use the ACE Enhancer Project:

	- From the shell/CLI.
	- Via an Integrated Development Environment: AIDE.


With Aide:

   - Select the linker menu and add both the modules.
   - Build or Make the executable.

From the shell:

   - Compile but do not link the program.
   - Link the resulting object code with the new and standard
     ACE link libraries.
     Ex.: Phxlnk T:your_prog.o ACElib:Stringlib.o Math020.o ACElib:startup.lib
          ACElib:db.lib ACElib:ami.lib

   - Beware! The new modules MUST be linked before the standard ACE link
     libraries.

@ENDNODE

@NODE 2hintstips "Hints, tips and chips."
How to get the most out of ACE in combination with SuperOptimizer and AEP.
--------------------------------------------------------------------------

1. The fastest program execution.
.................................

   Compile your program, Superoptimize it with the FULL option.
   Assemble and Link it with the AEP modules and standard ACE link libraries.

   This will indeed give you the fastest program execution, but because
   most of the String functions are inlined the resulting executable tends
   to become a bit large.


2. Fast and small.
..................

   Compile you program, Superoptimize it with all options set, except
   (I)nlining.
   Assemble and Link it with the AEP modules and standard ACE link libraries.

   Program execution will be a bit slower, but the executable size will
   become significantly smaller with large programs.

@ENDNODE

@NODE 4future "Future versions"
Future versions
---------------

Don't know...depends on the respone I'll get.


@ENDNODE


@NODE 4pd "A note to PD libraries and reviewers"
A note to PD libraries and reviewers
------------------------------------

I hope that you will find this program good enough to include it in your
library or to give it a small review.
   
I'd appreciate it if you would check with me (if possible) to ensure you
have the latest version of the ACE Enhancer Project, before including it in
your library or reviewing it for a magazine.

Lastly, the wider the ACE Enhancer Project travels the happier I am, so I'm
pleased to see it turning up in the odd PD library. 
Please note however that I don't wish people to profit financially from the
distribution of it. You may charge a fee which covers the cost of the disk
and the copying thereof, but no more.


@ENDNODE
@NODE 4disclaim "Disclaimer"
Disclaimer
----------

Allthough every care has been taken in the development and testing of the 
ACE Enhancer Project, the author will not be held liable for damages caused
either directly or indirectly as a result it's use.


@ENDNODE
@NODE 4author "Contacting the author"
Contacting the author
---------------------

I am contactable via snail-mail and telephone only:
 
   Manuel ANDRE
   Arbeidersstraat Nr. 9
   2600   BERCHEM
   Belgium

   Tel.: 32-3-230-66-10
         \/
         |
         -->Belgium.

   Direct modem to modem access possible, but only on special request.
	
@ENDNODE
@NODE 4final "Final word"
Final word
----------

Let me offer my thanks to David Benn, he deserves an ACE!

It's a shame that ACE is not more often reviewed in magazines and
newsletters.

ACE is the ultimate 'AmigaBasic Compiler Experience' and should be
treated as such!

Get rid of AMOS and Blitz!!!
  
I hope you enjoy the ACE Enhancer Project and find it useful.
But what I REALLY want is feedback. If you have any problems, requests
or suggestions, I want to hear from you.

Happy Coding.

Regards, Manuel ANDRE
14 August 1997

@ENDNODE
