home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format 91 / af091a.adf / af91a1.lzx / Docs / ace.doc < prev    next >
Text File  |  2016-03-27  |  114KB  |  3,201 lines

  1.  
  2.                 +----------+
  3.                 | ACE v2.4 |
  4.                 +----------+
  5.  
  6.  
  7.       CONTENTS                       LINE  PAGE
  8.       --------                        ----  ----
  9.  
  10.   (i)   Introduction
  11.  
  12.     Printing this document.......................100     2
  13.     What is ACE?.................................108     2
  14.     Who is it for?...............................198     4
  15.  
  16.     ------------------------------------------------
  17.  
  18.  (ii)    Getting started
  19.  
  20.     Installation.................................258     5
  21.     Using the compiler...........................302     5
  22.     Compiler options.............................349     6
  23.     Running ACE programs.........................437     7
  24.     About the example programs...................445     7
  25.  
  26.     ------------------------------------------------
  27.  
  28.  (iii)  A hitch-hiker's guide to ACE 
  29.  
  30.     General comments.............................477     8
  31.  
  32.     The preprocessor and #include files..........531     9
  33.  
  34.     Data types, expressions, constants...........585    10
  35.     Precedence of operators......................681    11
  36.     Indirection operators........................713    12
  37.     Identifiers..................................749    12
  38.  
  39.     Sequential Files.............................886    14
  40.     Random Files.................................983    16
  41.  
  42.     Command line and Workbench arguments........1098    18
  43.  
  44.     Subprograms.................................1149    18
  45.     Structures..................................1374    22
  46.     Shared library function calls...............1539    25
  47.     Machine code calls..........................1680    27
  48.  
  49.     External references.........................1752    28
  50.     Common and Global variables.................1814    29
  51.     Subprogram modules (SUBmods)................1847    29
  52.         
  53.     Windows.....................................2044    32
  54.     Screens.....................................2072    33
  55.  
  56.     Gadgets.....................................2124    34
  57.     Menus.......................................2237    35
  58.     Requesters..................................2271    36
  59.  
  60.     Turtle Graphics.............................2295    36
  61.     Loading & displaying IFF pictures...........2443    39
  62.  
  63.  
  64.                                   - page 1 -
  65.  
  66.     Sound.......................................2460    39
  67.  
  68.     Event trapping..............................2551    40
  69.  
  70.     Interprocess Communication..................2666    42
  71.  
  72.     Error handling..............................2692    43
  73.  
  74.     Notes for assembly programmers..............2725    43
  75.  
  76.     Limitations.................................2773    44
  77.     Known bugs..................................2826    45
  78.  
  79.     ------------------------------------------------
  80.  
  81. (iv)    Stop bits
  82.  
  83.     Future versions.............................2847    45
  84.  
  85.     A note to PD libraries and reviewers........2882    46
  86.  
  87.     Disclaimer..................................2900    46
  88.  
  89.     References..................................2907    46
  90.  
  91.     Contacting the author.......................2955    47
  92.  
  93.     CyberspACE: FTP, WWW, mailing list..........2975    47
  94.  
  95.     Final word..................................3038    48
  96.  
  97.         ================================================
  98.  
  99.  
  100. Printing this document
  101. ----------------------
  102. The simplest way to print this document is to use the pager utility which
  103. can be found in the utils/pager directory of the ACE distribution. Before
  104. printing, be sure to set your printer preferences such that the left and 
  105. right margin settings are 0 and 80 respectively.
  106.  
  107.  
  108. What is ACE?
  109. ------------
  110.  AmigaBASIC Compiler with Extras?
  111.  A Creative Environment? 
  112.  A Compiler for Everyone?
  113.  A Cool Enterprise?
  114.  Automatic Computing Engine (ala Alan Turing)?
  115.  Dr Who's last companion?  
  116.  
  117. Okay, seriously...
  118.  
  119. ACE is a freely distributable, recursive descent, peephole-optimising Amiga 
  120. BASIC compiler which produces A68K-compatible assembly source code. ACE runs 
  121. under Wb 1.3, 2.x and up, as do the executables it produces. ACE will run in 
  122. 512K, but more than this is required for programs beyond about 250 lines.
  123.  
  124. ACE supports a large subset of AmigaBASIC. It also provides a variety of 
  125. commands, functions and features not found in AmigaBASIC.
  126.  
  127.  
  128.                                   - page 2 -
  129.  
  130. In many cases, ACE programs produce results which are similar or identical 
  131. to programs written in AmigaBASIC.
  132.  
  133. Any differences between the two are discussed in this document and the command 
  134. and function reference (ref.doc).
  135.  
  136. The following files constitute a complete ACE package:
  137.  
  138.         executables
  139.         -----------      
  140.     bas        - A shell script which automates
  141.                 the production of ACE executables
  142.               (1.3 and 2.x/3.x versions).
  143.     app        - A simple preprocessor.
  144.     ace        - The BASIC compiler.
  145.     a68k        - Charlie Gibbs' 68000 assembler.
  146.     blink        - The Software Distillery's linker.
  147.     muchmore    - The file viewer by Fridtjof Siebert & 
  148.               Christian Stiens (1.3 and 2.x/3.x versions).
  149.  
  150.      documents
  151.     ---------        
  152.     ace.doc/guide    - The document you are reading, which describes ACE.
  153.     ref.doc/guide     - A command and function reference for ACE.
  154.     example.guide    - Examples of ACE command and function usage.
  155.     history        - A history of ACE's development.
  156.     a68k.doc    - Documentation for the assembler.
  157.     blink.doc    - Documentation for the linker.
  158.  
  159.     scanned libraries (NOT shared libraries)
  160.     -----------------
  161.     ami.lib        - A freely distributable version of amiga.lib.
  162.     startup.lib    - A library of routines needed at the start and
  163.               end of an ACE program run.
  164.     db.lib        - A library of assorted routines used by ACE
  165.               programs.
  166.  
  167.     other stuff
  168.     -----------
  169.     includes    - Some useful ACE include files. 
  170.     icons        - ACE tool and document icons.
  171.     utils        - Miscellaneous utilities.
  172.     examples    - Example programs which demonstrate many of 
  173.               ACE's capabilities.
  174.      AIDE        - A graphical front-end for ACE.
  175.  
  176. With one exception (see the discussion of file requesters under Wb 1.3 in 
  177. the "Requesters" section) ACE programs do not require any special run-time 
  178. shared libraries, so the executables which the compiler produces (via the 
  179. assembler and linker) are completely portable, requiring only the standard 
  180. Amiga shared libraries in your LIBS: directory. The three ".lib" files 
  181. mentioned above are scanned libraries and code from these is included at 
  182. link time.
  183.  
  184. ACE is written in C (Sozobon's ZC v1.01), while db.lib and startup.lib are 
  185. written in assembler (~50%) and C. I may eventually switch to SAS C.
  186.  
  187. A68K and Blink are used to assemble and link the code produced by ACE.
  188.  
  189. The MicroEmacs (v1.3 & v2.1) editor has been used throughout every stage 
  190. of ACE's development. It works for me.
  191.  
  192.                                   - page 3 -
  193.  
  194.  
  195. The complete ACE package may be freely distributed.
  196.  
  197.  
  198. Who is it for?
  199. --------------
  200. ACE is intended for anyone who already knows BASIC and wants one or more 
  201. of the following:
  202.  
  203.     - Faster program execution.
  204.  
  205.     - Independence from the BASIC interpreter, ie: standalone 
  206.       programs which are runnable from the CLI/Shell and Workbench.
  207.  
  208.     - Extra commands, functions and features: turtle graphics,
  209.       command-line (and Workbench) arguments, recursion, SUBs with 
  210.       return values, external references, named constants, structures, 
  211.       include files, better WAVE command, gadgets, requesters, ability
  212.       to create subprogram libraries, interprocess communication, etc.
  213.  
  214. Maybe you don't wish to learn another high-level language, or perhaps you 
  215. already use C or assembler but prefer to use BASIC for some tasks while 
  216. still having the power of a compiled language.
  217.  
  218. ACE is a general purpose language so in theory at least, it can be applied
  219. to any programming task you like. In practice however, I find ACE to be
  220. most useful for writing small to medium sized programs where speed is 
  221. important but so is ease of programming.
  222.  
  223. ACE is also a useful prototyping language. It allows you to get something 
  224. up and running quickly to test an idea. You may later decide to re-code in 
  225. C or assembler, or you may just add some polish to the existing ACE program.
  226.  
  227. The latter is becoming more feasible as ACE matures.
  228.  
  229. Here are some programs that have been written with ACE:
  230.  
  231.     - Shell utilities, eg: basic calculator (see ACE:prgs/ShellUtils).
  232.     - An 8SVX sound sample player.
  233.     - Fractal graphics programs.
  234.     - Neural networks.
  235.     - Astronomy programs, eg: galaxy collision simulator,
  236.       Jovian satellite position predictor, Messier object database.
  237.     - An Integrated Development Environment: AIDE.
  238.     - A GUI designer which generates ACE code: ReqEd.    
  239.     - A home security/wakeup system.
  240.     - A program which matches section headings to line and page 
  241.       numbers to create the document you are now reading from an
  242.       unformatted version of it.
  243.     - Workbench calculators (Me, John Stiwinter).
  244.     - A SpiroGraph simulator (Chuck Kenney).
  245.     - A serial Stratego game (Dan Oberlin).
  246.     - A control program for a 16" reflecting telescope (Neil Sproston).
  247.     - An assembly code optimiser for ACE programs (Manuel Andre).
  248.     - Interpreters for simple dialects of BASIC and Lisp.
  249.     - A variety of communications (simple terminal, X10) programs.
  250.     - A MED module player (Lauri Lehmus).
  251.     - A Protracker module player (John Mason).
  252.     - A preprocessor for ACE source code (Daniel Seifert).
  253.  
  254.  
  255.  
  256.                                   - page 4 -
  257.  
  258. Installation
  259. ------------
  260. Installing ACE consists of:
  261.  
  262.     - Unpacking the archive.
  263.  
  264.     - Adding a few commands to your s:user-startup (Wb 2.x/3.x) or 
  265.       s:startup-sequence (Wb 1.3) file.
  266.  
  267. First create a new drawer (eg. ACE) on your hard disk, open a shell window, 
  268. change to the new directory, and unpack the archive into it with:
  269.  
  270.     lha -a x <archive-name>
  271.  
  272. eg.    lha -a x ace24.lha
  273.     
  274. The "-a" switch preserves file attributes (eg. the "s" bit on shell scripts) 
  275. in the archive.
  276.  
  277. As you can see, it is *assumed* that you have a hard disk. If you don't, 
  278. unpack the ACE archive into the RAM disk and place the contents of the 
  279. distribution onto more than one floppy disk from there.
  280.  
  281. Next, add the following lines to your user-startup or startup-sequence 
  282. script:
  283.  
  284.     assign ACE: <volume or directory>
  285.     path ACE:bin add
  286.  
  287. where <volume or directory> is the name of the disk or directory where
  288. the main ACE files now reside (eg: assign ACE: sys:ACE).
  289.  
  290. In addition, you need to add three more statements to your startup-sequence
  291. or user-startup script:
  292.  
  293.     assign ACElib:       ACE:lib     ; bas finds scanned libraries here.
  294.     assign ACEbmaps:   ACE:bmaps     ; ace looks here for .bmap files.
  295.     assign ACEinclude: ACE:include     ; app uses this for include files.
  296.  
  297. Now reboot your Amiga to let the above path and assign commands take effect.
  298.  
  299. That's it!
  300.  
  301.  
  302. Using the compiler
  303. ------------------
  304. Starting with ACE v2.0 there are two ways to use the compiler:
  305.  
  306.     - From the shell/CLI.
  307.     - Via an Integrated Development Environment: AIDE.
  308.  
  309. Whichever environment you choose to work with ACE in, read on.
  310.  
  311. ACE expects all BASIC source files to have a ".b" or ".bas" extension.
  312.  
  313. If you have a program called foo.b[as], you would invoke the compiler thus:
  314.  
  315.     ace foo    (or ace foo.b[as])
  316.  
  317. This would produce foo.s, an A68K-compatible assembly source (text) file.
  318.  
  319.  
  320.                                   - page 5 -
  321.  
  322. If you wanted to preprocess, compile, assemble and link foo.b[as], you'd 
  323. type:
  324.  
  325.     bas foo
  326.  
  327. which would yield foo (the executable).
  328.  
  329. The bas script sets the stack to 40000 bytes. Before running ACE by itself,
  330. you will need to set this. A minimum stack size seems to be around 5000
  331. for many ACE compilations, but I recommend 40000 to be safe.
  332.  
  333. If your Amiga GURUs or hangs during a compile or produces garbage in the 
  334. shell, you can be confident that the stack is too small.
  335.  
  336. You can either create a BASIC source file using an editor or in the AmigaBASIC 
  337. environment. If you want to compile a program developed with the interpreter,
  338. just save the program in ASCII format thus:
  339.  
  340.     save "foo.b[as]",a
  341.  
  342. ACE will only compile ASCII source files, not AmigaBASIC's compressed format.
  343.  
  344. For those who don't have access to the AmigaBASIC interpreter but who wish
  345. to convert old AmigaBASIC programs not saved in ASCII format, see the 
  346. ACE:utils directory for a utility called ab2ascii written by Stefan Reisner.
  347.  
  348.  
  349. Compiler options
  350. ----------------
  351. The full command line syntax for ACE is:
  352.  
  353.     ace [words | -bcEilmOw] <sourcefile>[.b[as]]
  354.  
  355. which indicates that there are currently eight optional compiler switches. 
  356.  
  357. Before giving a description of these switches however, let me say something
  358. about the optional "words" parameter. If the command:
  359.  
  360.     ace words
  361.  
  362. is given, all the reserved words which are known to the compiler will be
  363. dumped to standard output (ie. to the shell/CLI). Using redirection thus:
  364.  
  365.     ace words > rwords
  366.  
  367. will result in a file containing this information. This feature will be
  368. useful for anyone wanting to know which words are reserved by the compiler. 
  369. AmigaBASIC and ACE keywords are differentiated.
  370.  
  371. The switches can appear in any combination (eg: -bO, -clb, -O, -ObE) but 
  372. they *are* case sensitive (so -b does not equal -B).
  373.  
  374. The "b" switch tells the compiler to include code to check for ctrl-c breaks 
  375. by the user. The inclusion of this code can result in noticeably larger
  376. assembly source files, but execution speed doesn't seem to suffer appreciably.
  377. When a ctrl-c is detected, the program will clean up and exit but user-defined
  378. windows and screens will remain open. The use of ON BREAK can get around this 
  379. by allowing for user-controlled clean up (see the "Event Trapping" section
  380. below). See also the "w" switch.
  381.  
  382. The "c" switch includes each line of ACE source code as a comment in the
  383.  
  384.                                   - page 6 -
  385.  
  386. final assembly source file. This was requested as a debugging aid. Warning:
  387. the presence of such comments interferes with peephole optimisation. Also be
  388. aware that ACE sometimes includes extra code apart from that which you might
  389. expect purely on the basis of the source code.
  390.  
  391. The "E" switch creates a file in the current directory called ace.err which
  392. contains all error messages generated during a compliation. Error messages
  393. are still displayed to the screen during compilation however.
  394.  
  395. The "i" switch tells ACE to make an icon for the executable resulting from 
  396. the compilation. The file "ACE:icons/exe.info" must exist as it is used as
  397. the source file for the icon. This allows you to use an icon of your own if
  398. you so wish.
  399.  
  400. The "l" switch causes the compiler to display each line of ACE source code 
  401. as it is being compiled.
  402.  
  403. The "m" switch creates a linkable module containing no startup code (See
  404. "Creating & using ACE subprogram modules" section below).
  405.  
  406. The "O" switch causes the assembly source code produced by ACE to be optimised.
  407. A range of peephole optimisations is currently carried out. Assembly code size
  408. reductions of around 5% to 10% are usual. Speed improvements vary, depending
  409. upon the program, however I recommend the use of the -O switch for all programs
  410. where speed is the least bit important. ACE's optimiser has been improved since 
  411. v2.0 and it will continue to be improved.
  412.  
  413. The "w" switch tells ACE to include checks for window close-gadget clicks.
  414. ACE checks all open windows and upon detecting a close-gadget click, the
  415. clicked window is closed and the program exits. However, any other open
  416. windows or screens will not be closed. The use of ON WINDOW can get around 
  417. this by allowing for a user-defined clean-up subroutine (see the "Event 
  418. Trapping" section below).
  419.  
  420. See also the OPTION command in ref.doc.
  421.  
  422. The syntax for the bas script is:
  423.  
  424.     bas [-bcEilmOw] <sourcefile> [<objectfile>]
  425.  
  426. where <sourcefile> is the program to be compiled (without the .b[as] 
  427. extension) and <objectfile> is a C, assembly or ACE module which has been 
  428. (compiled and) assembled to produce an object file.
  429.  
  430. The <objectfile> is linked with the output of ACE+A68K along with db.lib, 
  431. startup.lib and ami.lib. This is necessary when an external function or 
  432. variable in <objectfile> is referenced by an ACE program. For more about 
  433. external functions, see the sections "External references" and "Creating & 
  434. using ACE subprogram modules" below.
  435.  
  436.  
  437. Running ACE programs
  438. --------------------
  439. ACE programs can be run from either a shell/CLI or Workbench. In the latter
  440. case a tool icon must be created for the executable. One has been provided
  441. with the archive in the icons directory (exe.info). Refer to the "i" switch 
  442. in "Compiler options" above re: automatic icon creation by the compiler.
  443.  
  444.  
  445. About the example programs
  446. --------------------------
  447.  
  448.                                   - page 7 -
  449.  
  450. I have written a number of programs which illustrate most of the features
  451. of ACE up to this point and you should find these with the distribution.
  452.  
  453. Several programs are related to chaos theory and fractals. The remainder 
  454. are an assorted bunch which demonstrate ACE's capabilities.
  455.  
  456. The information for the chaos/fractal programs came from a wide variety of 
  457. sources. The algorithms for henon.b and lorenz.b came from "Dynamical systems 
  458. and fractals: computer graphics experiments in Pascal" by Becker & Dorfler, 
  459. 1990.
  460.  
  461. Some programs are optimised at the source level and some are not. You'll 
  462. find that using integer variables can often result in quite dramatic 
  463. improvements in program execution speed (eg: try replacing op% with op! and 
  464. k% with k! in ifs.b and you'll see what I mean).
  465.  
  466. There are several examples which demonstrate the use of recursive 
  467. subprograms in ACE (eg: misc/fact.b).
  468.  
  469. Another area of interest for me is neural networks and you'll find a 
  470. program called gfx/hopnet.b, which shows graphically how a simple Hopfield 
  471. network changes under various conditions.
  472.  
  473. Other programs include a talking clock (tclock.b), a sound sample player 
  474. (sound/play.b) and a command-line calculator (ShellUtils/bc.b).
  475.  
  476.  
  477. General comments
  478. ----------------
  479. I made a decision very early on in the project to allow standard I/O (for 
  480. shell/CLI). All other windows are (as of ACE v2.0) Intuition windows.
  481.  
  482. The execution speed of most programs (especially with graphics, eg: ifs.b)
  483. is, as you might expect, *fast* compared to interpreted AmigaBASIC.
  484.   
  485. No error messages are given at run-time (but some errors are reported via ERR
  486. and ON ERROR), nor is there any stack overflow or array bounds checking. 
  487.  
  488. Labels are supported and can be used with GOSUB and GOTO. Line numbers are 
  489. supported, but are only necessary for old BASIC programs. Also, ACE's rich 
  490. assortment of control constructs makes the use of GOTO largely redundant.
  491.  
  492. Available control constructs are: WHILE..WEND, REPEAT..UNTIL, IF..THEN..ELSE,
  493. IF..THEN..ELSE..END IF, CASE..END CASE, ON..GOTO, ON..GOSUB, SUB..END SUB and 
  494. GOSUB..RETURN.
  495.  
  496. Apart from single line comments with REM and ' ACE allows block comments with
  497. { and }. For example:
  498.  
  499.  { comments can span more than 
  500.    one line like this }
  501.  
  502. Multi-statements are also supported by ACE - as they are in AmigaBASIC, eg:
  503.  
  504.  x$="hello":y$="there":say translate$(x$+" "+y$)
  505.  
  506. In ACE (as in AmigaBASIC) end-of-line characters (ASCII 10) are significant,
  507. so a line continuation character (~) must be used to extend expressions and
  508. parameter lists (etc) over more than one line, eg.
  509.  
  510.  DECLARE FUNCTION MyAmazingExternalFunction(theFirst, theSecond, theThird, ~
  511.  
  512.                                   - page 8 -
  513.  
  514.                         theFourth) EXTERNAL
  515.  
  516. Note that this feature is ACE-specific. Multi-statements may be split across
  517. lines in similar fashion, eg.
  518.  
  519.     CASE
  520.       n = 1 : print "This is the one!" :~
  521.           ++n :~
  522.           print "That will do."
  523.       .
  524.       .
  525.       .
  526.     END CASE
  527.  
  528. On a related note, statement blocks are also supported via BLOCK..END BLOCK.
  529.  
  530.  
  531. The preprocessor and #include files
  532. ------------------------------------
  533. The ACE preprocessor: APP, is modest when compared to the C preprocessor,
  534. but is not the only choice available to the ACE programmer (see the note 
  535. at the end of this section).
  536.  
  537. Its main function thus far is for the inclusion of files with the #include 
  538. directive. As in C, #include "filename" looks for the file as specified, 
  539. while #include <filename> looks for the file in a local include directory 
  540. (see "Installation"). A file will only ever be included once.
  541.  
  542. The #include directive can also be used in included files, but since file 
  543. inclusion is recursive, watch your stack size (40000 bytes is plenty).
  544.  
  545. APP also handles single-line comments (text following a "'") and block
  546. comments (starting with "{" and ending with "}"). This is partly to allow
  547. #include commands to be commented out and also to make less work for the 
  548. compiler. However, the compiler does still handle comments in case the pre-
  549. processor isn't invoked. APP does not handle REM since this is a BASIC 
  550. statement.
  551.  
  552. The syntax for APP is: 
  553.  
  554.     app <source> <dest> 
  555.  
  556. The bas script uses APP by first preprocessing an ACE source file to the
  557. RAM:T directory.
  558.  
  559. Use of #include has the effect of adding lines to the preprocessed ACE 
  560. source, which has an impact upon the physical location of lines from the
  561. main ACE file when transfered to the destination file.
  562.  
  563. ACE include files have two purposes. As in C they can be used to include
  564. constants and structure definitions. Second, as with files like WBarg.h,
  565. ACE include files may contain subprogram definitions and although this is 
  566. quite possible in C, it seems to be less often done under the guise of .h 
  567. files. I have arbitrarily chosen to append all include files with .h but 
  568. there is no reason why this need be so. Purists will probably be aghast.
  569.  
  570. APP will be improved as time goes by.
  571.  
  572. Note that if you wish to use the new ACE include files (created by Nils
  573. Sjoholm), you will need to use an actual C preprocessor instead of APP,
  574. and one has been provided (acpp), along with alternate bas scripts (see
  575.  
  576.                                   - page 9 -
  577.  
  578. bas2 and bas3) for exactly this purpose.
  579.  
  580. NOTE: For compiling programs which use the new include files in 
  581.       ACEinclude: you should use a better preprocessor, eg. ACPP or NAP.
  582.       Be aware however that ACPP assumes that ACEinclude: = ACE:include.
  583.   
  584.  
  585. Data types, expressions and constants
  586. ------------------------------------- 
  587. The following fundamental data types are currently supported:
  588.  
  589.     - signed short integers (2 bytes = 16 bits)
  590.     - signed long integers  (4 bytes = 32 bits)
  591.     - single-precision: Motorola fast floating point (4 bytes = 32 bits)
  592.     - strings (default length of 1024 bytes including ASCII 0 at end of string) 
  593.  
  594. Exponential and fixed-point formats are recognised by ACE for single-precision 
  595. numbers.
  596.  
  597. Expression parsing is the same as for AmigaBASIC, as is the precedence of 
  598. operators. Evaluation of _all_ expressions proceeds from left to right.
  599. This includes exponentiation, so 2^3^2 will be evaluated as (2^3)^2.
  600.  
  601. In addition, due to the higher precedence of exponentiation over unary 
  602. negation and the way ACE's recursive descent parser works, 4^(-2) is okay, 
  603. but 4^-2 isn't.
  604.  
  605. ACE supports full 32-bit and single-precision floating point math:
  606.  
  607.     addition, subtraction, multiplication:
  608.         
  609.         - 16-bit integer
  610.         - 32-bit integer
  611.         - single-precision 
  612.  
  613.     division & modulo arithmetic:
  614.  
  615.         - 32-bit integer
  616.         - single-precision
  617.  
  618. Increment and decrement operators are provided in ACE in the following form:
  619.  
  620.     ++<variable> OR --<variable>
  621.  
  622. The value of the simple, external, global, or common variable is incremented 
  623. or decremented by 1.
  624.  
  625. Notice that ++ and -- are pre-increment & pre-decrement operators ONLY (ie.
  626. not also post-increment/decrement). Those familiar with C will recognise 
  627. these operators and their utility. In terms of efficiency: ++x is better 
  628. than x=x+1.  
  629.                     
  630. Unlike interpreted AmigaBASIC, hexadecimal and octal constants can be either 
  631. short or long values. This makes for nicer addressing with PEEK & POKE. Also,
  632. the prefixes &H and &O may precede an integer anywhere that it makes sense,
  633. including in strings submitted to the VAL function. The effect of &H and &O
  634. is to indicate that a hexadecimal or octal value follows. The use of these 
  635. prefixes is consistent with AmigaBASIC.
  636.  
  637. Trailing characters (%&!#) after constants cause coercion from one numeric
  638. data type to another, as in AmigaBASIC, eg:
  639.  
  640.                                   - page 10 -
  641.  
  642.     
  643.     Delay(50&)   '..50 is coerced from short to long integer
  644.     x=12.5*65!   '..65 is coerced from short integer to single-precision
  645.  
  646. Using these type-qualifier characters means that ACE doesn't have to generate
  647. numeric conversion code. This leads to smaller assembly code source files.
  648.  
  649. As in AmigaBASIC expression evaluation, all operands in an expression are 
  650. converted to the data type of the most precise operand. Logical operators 
  651. (AND,EQV,IMP,NOT,OR,XOR) convert their operands to integer values as does 
  652. the integer division operator "\". Relational operators (= <> > < >= <=) 
  653. yield long integer results.  
  654.   
  655. ACE's boolean values are as follows: 0=false, N=true where N is any 
  656. non-zero long integer. Note that relational operations give -1 for true 
  657. (since: NOT -1 = 0).
  658.  
  659. Please note that in addition to their use in relational expressions, the 
  660. logical operators (AND, NOT...) actually work in bitwise fashion. This means 
  661. that you can create bitwise AND masks and perform other operations on groups 
  662. of bits, as desired. The SHL and SHR functions may also prove useful in this 
  663. respect (see ref.doc).
  664.  
  665. ACE allows you to define named global signed numeric constants with the 
  666. CONST directive (see command and function reference).
  667.  
  668. Strings have a default length of 1K instead of the usual 32K, since ACE 
  669. programs reserve memory for each string immediately at run-time which could
  670. result in quite memory hungry executables if strings were too large. It is 
  671. possible however, to define strings which are longer or shorter than 1K (see 
  672. the STRING command).
  673.  
  674. ACE strings are NULL terminated, ie: the last character is an ASCII 0, as in
  675. strings manipulated by C's standard library functions.
  676.  
  677. A string literal without a final '"' will be truncated at the end of the 
  678. line.
  679.  
  680.  
  681. Precedence of operators
  682. -----------------------
  683. ACE follows AmigaBASIC in operator precedence, with the addition of structure 
  684. dereferencing and indirection operators.
  685.  
  686.     Level    Operation/Operator                Symbol
  687.     -----    ------------------                ------
  688.  
  689.     1.      Structure Member Dereferencing,            ->
  690.             Parentheses and Address Operator        () @
  691.     2.      Indirection Operators                *% *& *!    
  692.     3.      Exponentiation                    ^
  693.     4.      Unary Negation                    -
  694.     5.      Multiplication and Floating-Point Division    * /
  695.     6.      Integer Division                \
  696.     7.      Modulo Arithmetic                MOD
  697.     8.      Addition and Subtraction            + -
  698.     9.      Relational Operators                = < > <= >= <>
  699.     10.     NOT
  700.     11.     AND
  701.     12.     OR and XOR
  702.     13.     EQV
  703.  
  704.                                   - page 11 -
  705.  
  706.     14.     IMP
  707.  
  708. The use of parentheses in an expression forces the enclosed term to be 
  709. evaluated before adjacent terms. Expression evaluation always proceeds 
  710. from left to right in ACE and AmigaBASIC.
  711.  
  712.   
  713. Indirection operators
  714. ---------------------
  715. ACE has four indirection operators: @,*%,*&, and *!. These are _similar_
  716. to pointers in C.
  717.  
  718.     @<object>   - returns the absolute address of a data object or SUB.
  719.             - note that this is identical to VARPTR(<object>).
  720.     *%<address> - peeks or pokes a short value at the specified address.
  721.     *&<address> - peeks or pokes a long value at the specified address.
  722.     *!<address> - peeks or pokes a single value at the specified address.
  723.  
  724. The indirection operators can therefore be used in a statement (poke) and/or 
  725. as part of an expression (peek), for example:
  726.  
  727.     address x
  728.     y=23.25
  729.     x=@y
  730.     *!x := *!x + 2
  731.     print y
  732.  
  733. will print a value of 25.25.
  734.  
  735. There are two things to notice here. First, the pointers are to addresses, 
  736. not necessarily connected to variables. It would be quite legal to allocate
  737. an area of memory and then dereference it with these operators.
  738.  
  739. Second, when assigning a value to a dereferenced memory location as in the 
  740. above example, the ":=" symbol must be used, simply because of the way the 
  741. parser processes statements. Pascal programmers will recognise this as 
  742. the assignment operator. 
  743.  
  744. See also the section below for information about how to use these operators
  745. to implement variable parameters (call-by-reference) for simple variables in 
  746. ACE subprograms.
  747.  
  748.  
  749. Identifiers
  750. -----------
  751. As in AmigaBASIC an identifier can consist of a combination of letters, 
  752. numbers and periods (".") up to a maximum length of 40 characters. 
  753.  
  754. In ACE the underscore ("_") character is also legal. An ACE identifier must 
  755. start with either a letter or an underscore character.
  756.  
  757. An identifier can be used to represent the following:
  758.  
  759.         - labels
  760.         - arrays
  761.         - variables
  762.         - parameters
  763.         - structures
  764.         - subprograms
  765.         - defined functions
  766.         - named constants
  767.  
  768.                                   - page 12 -
  769.  
  770.         - shared library functions
  771.         - external functions and variables
  772.  
  773. Note that in ACE, a simple variable and an array with the same name
  774. cannot coexist. For example, a single-precision variable V cannot
  775. coexist with a single-precision array, eg: DIM V(100). However 'V!' *can*
  776. live with V(100) since V and V! are different variables in ACE. See the 
  777. discussion of qualifier characters below.
  778.  
  779. Labels are global in ACE, so a main program label and a SUB label cannot 
  780. have the same name. The format for a label definition is:
  781.  
  782.     <name>:
  783.  
  784. Labels are used by GOTO and GOSUB. For example:
  785.  
  786.     GOSUB HaveSomeFun
  787.     STOP
  788.  
  789.     HaveSomeFun:
  790.         PRINT "Are we having fun yet?"
  791.     RETURN
  792.         
  793. Identifiers can have a qualifier character (%&$!#) appended in order to 
  794. indicate data type, where:
  795.  
  796.         % = short integer
  797.         & = long integer
  798.         ! = single-precision
  799.         # = double-precision -> not supported yet
  800.         $ = string    
  801.  
  802. Examples of valid identifiers are:
  803.  
  804.         x3
  805.         num&
  806.         _putchar
  807.         play.sound
  808.  
  809. An identifer with no qualifier has a default type of single-precision. The 
  810. DEFxxx compiler directives (see command and function reference) have the
  811. same effect as the qualifier characters except they affect all identifiers
  812. starting with a certain letter. Qualifier characters have higher priority
  813. than DEFxxx directives. 
  814.  
  815. For shared library functions and external references, a qualifier is used 
  816. merely to declare data type. So for example, an external function might be 
  817. declared thus:
  818.  
  819.         external function RangeRand%
  820.  
  821. but can later be referred to as RangeRand.
  822.  
  823. The declaration of external functions/variables and shared library functions
  824. is global no matter where the declaration occurs.
  825.  
  826. Defined constants are unaffected by qualifier characters. The _value_ of a 
  827. defined constant determines its type. Thus CONST x&=1.2 is a single-precision
  828. - NOT a long integer - constant. Needless to say therefore, it is unwise to
  829. use qualifier characters for named constants.
  830.  
  831.  
  832.                                   - page 13 -
  833.  
  834. The declaration of constants (with CONST) is always global whether the
  835. declaration takes place in the main program or a subprogram.
  836.  
  837. Structure variables hold a long integer value (address), so trailing 
  838. characters have no effect.
  839.  
  840. Structure type definitions are global, but structure variable declarations
  841. are local.
  842.  
  843. ACE allows for *optional* variable declarations with the SHORTINT, LONGINT,
  844. ADDRESS, SINGLE and STRING directives. Such declarations are useful in that:
  845.     
  846.         (i)    They ensure that a variable has a NULL or zero 
  847.             value.
  848.  
  849.         (ii)    They prevent dangerous errors which result from 
  850.             the misspelling of variable names.
  851.  
  852.         (iii)    Most languages have them and they serve to 
  853.             document variable usage explicitly.
  854.  
  855.         (iv)    They provide a "cleaner" way of establishing a 
  856.             variable which is to be shared by a subprogram
  857.             in ACE.
  858.  
  859. My feeling on the matter of variable declarations is that in a small program 
  860. they probably aren't necessary so long as you are careful, but in a large 
  861. program all major variables should be declared for safety. I plan to add a
  862. compiler switch which could be used to enforce mandatory variable declarations.
  863.   
  864. Variable declarations override the DEFxxx compiler directives and qualifier
  865. characters and are local to the current level (main program or subprogram).
  866.  
  867. Summary of identifier properties:
  868.  
  869. +---------------+---------------+------------------+
  870. | Identifier    | Local/Global  | Affected by %&!$ |
  871. +---------------+---------------+------------------+
  872. | ARRAY        | LOCAL        | YES            |
  873. | SIMPLE VAR    | LOCAL        | YES           |
  874. | STRUCTURE VAR | LOCAL        | NO           |            
  875. | PARAMETER    | LOCAL        | YES           |
  876. | STRUCTURE DEF | GLOBAL    | NO           |        
  877. | LABEL        | GLOBAL    | NO           |
  878. | NAMED CONST   | GLOBAL    | NO           |
  879. | SUBPROGRAM     | GLOBAL    | YES           |
  880. | DEF FN     | GLOBAL    | YES           |
  881. | LIBRARY FUNC  | GLOBAL    | YES (declaration)|
  882. | EXT VAR/FUNC    | GLOBAL    | YES (declaration)|
  883. +---------------+---------------+------------------+
  884.  
  885.    
  886. Sequential Files
  887. ----------------
  888. AmigaBASIC sequential files are supported and random files are on the list 
  889. of things to do.
  890.  
  891. The commands and functions for manipulating sequential files in ACE are:
  892.  
  893. commands:
  894.     - OPEN
  895.  
  896.                                   - page 14 -
  897.  
  898.     - CLOSE
  899.     - PRINT#
  900.     - WRITE#
  901.     - INPUT#
  902.     - LINE INPUT#
  903.  
  904. functions:
  905.     - INPUT$ 
  906.     - EOF
  907.     - LOF
  908.     - HANDLE *
  909.  
  910.     * not found in AmigaBASIC
  911.  
  912. Note that for any command which is immediately followed by a # there should 
  913. be at least one space between the keyword and the #, even though I may refer 
  914. to such commands as <name># in the text of this document and in ref.doc.
  915.  
  916. See the command and function reference for details of each of these.
  917.  
  918. When WRITE# is used, the result is identical to AmigaBASIC. For example:
  919.  
  920.     X=12 : Y=-3.2 : Z$="fun eh?"
  921.     OPEN "O",#1,"stuff"
  922.       WRITE #1,X,Y,Z$
  923.     CLOSE #1
  924.  
  925. results in a one-line file of the following format:
  926.  
  927.     12,-3.2,"fun eh?"
  928.  
  929. On the other hand, if the following is used instead: 
  930.  
  931.     PRINT #1,X,Y,Z$ 
  932.  
  933. the file format will be:
  934.  
  935.      12         -3.2        fun eh?
  936.  
  937. while if semicolons are used:
  938.  
  939.     PRINT #1,X;Y;Z$
  940.  
  941. the file format becomes:
  942.  
  943.      12 -3.2 fun eh?
  944.  
  945. INPUT# (eg: INPUT #1,X,Y,Z$) can be used to read values from a file in any 
  946. of the above formats, but bear in mind that strings that are not delimited
  947. by quotes, but contain spaces or tabs will be seen as more than one string 
  948. by INPUT#. So, in the example formats above, while 
  949.  
  950.     "fun eh?" 
  951.  
  952. is one string,
  953.  
  954.     fun eh?
  955.  
  956. is two strings as far as INPUT# is concerned.
  957.  
  958. The formats of sequential files in ACE and AmigaBASIC are now very nearly
  959.  
  960.                                   - page 15 -
  961.  
  962. identical, the only differences being in ACE tabs (produced by comma 
  963. delimiters in PRINT -- see PRINT in ref.doc) and the number of decimal 
  964. places written for single-precision values (usually more in ACE).
  965.   
  966. If you find ACE file I/O too slow, you may want to use the dos.library 
  967. functions (eg: xRead, xWrite). For this reason, I have included the HANDLE 
  968. function which returns the AmigaDOS handle of a file opened with ACE's OPEN 
  969. command. You may also wish to use the ami.lib buffered file I/O functions 
  970. which also require this handle. If HANDLE returns 0, the file can't be opened.
  971.  
  972. See prgs/IO/print.b for an example of opening a sequential file to a printer. 
  973.  
  974. Although SER: may be opened as a sequential file, it is not possible to 
  975. specify parameters for the serial port (baud rate etc) by this method as 
  976. is possible in AmigaBASIC.
  977.  
  978. Instead, ACE provides a set of special serial I/O commands. See ref.doc for 
  979. details of SERIAL OPEN/CLOSE etc, and prgs/IO/aterm.b for a simple terminal 
  980. program.
  981.  
  982.  
  983. Random Files
  984. ------------
  985. ACE's random files depart from AmigaBASIC's in a number of ways. I believe
  986. that the result is cleaner, and more programmer-friendly than AmigaBASIC's 
  987. random files.
  988.  
  989. The major design goals for random files in ACE were: run-time efficiency,
  990. simplicity, and flexibility, all of which have been achieved.
  991.  
  992. Quite some time was spent in deciding what would be the best approach 
  993. would be. For comparison, here are the commands and functions necessary
  994. to do random files in AmigaBASIC:
  995.  
  996.     CVD    MKD$
  997.     CVI    MKI$    
  998.     CVL    MKL$
  999.     CVS    MKS$
  1000.     FIELD    OPEN
  1001.     GET    PUT
  1002.     LOC    RSET
  1003.     LSET
  1004.  
  1005. In ACE, the following are all that's required:
  1006.  
  1007.     GET
  1008.     LOC
  1009.     OPEN
  1010.     PUT
  1011.  
  1012. In common with both sequential and random files are commands/functions 
  1013. like CLOSE, and LOF which may be used in the same way with either file
  1014. type.
  1015.  
  1016. How is this possible, you ask? ACE structures (see the section below on 
  1017. "Structures") are used as the basic unit of storage for the records of 
  1018. random files. Indeed, the effect of the AmigaBASIC FIELD, MKx$, CVx, 
  1019. LSET, and RSET commands is to build and modify an internal data structure
  1020. for a random file, which in essence, _is_ a structure. ACE simply makes
  1021. this explicit and removes from the programmer, the burden of having to
  1022. worry about the conversion of data to a form suitable for writing to or
  1023.  
  1024.                                   - page 16 -
  1025.  
  1026. reading from a random file.
  1027.  
  1028. So, for example, take the following structure definition and variable
  1029. declaration:
  1030.  
  1031.     Struct person
  1032.         String theName Size 20
  1033.         String phoneNum Size 16
  1034.         Shortint age
  1035.     End Struct
  1036.  
  1037.     Declare Struct person X,Y
  1038.  
  1039. A random file could be opened and a record written thus:
  1040.  
  1041.     Open "R",#1,"ram:people.db"
  1042.     If Err = 0 Then 
  1043.         X->theName = "David Benn
  1044.         X->phoneNum = "261 461"
  1045.         X->age = 32
  1046.         Put #1,X    '..the record number is optional.
  1047.       Close #1
  1048.     End If  
  1049.  
  1050. The first (and only) record could then be read like this:
  1051.  
  1052.     Open "R",#1,"ram:people.db"
  1053.     If Err = 0 Then
  1054.           Get #1,Y    '..the record number is optional.
  1055.           bytesRead = Loc(1)
  1056.           Print "<<Record";Str$(bytesRead\Sizeof(Y));">>"
  1057.           Print " Name: ",Y->theName
  1058.           Print "Phone: ",Y->phoneNum
  1059.           Print "  Age: ",Y->age
  1060.           Print
  1061.       Close #1
  1062.     End If  
  1063.  
  1064. Also, reading and writing can take place on the same open file.
  1065.  
  1066. So, what's the downside?
  1067.  
  1068. ACE random files are not binary-compatible with AmigaBASIC random files. 
  1069. AmigaBASIC random file records are similar to ACE's, but not identical. 
  1070. The main differences are:
  1071.  
  1072.     - In AmigaBASIC, strings are not ASCII-zero terminated as in ACE, 
  1073.       and are padded with spaces to the right or left in each random 
  1074.       file record using RSET or LSET. 
  1075.  
  1076.     - AmigaBASIC and ACE floating-point values have a different format
  1077.       since the latter uses standard Amiga libraries for floating-point
  1078.       math, while the former uses a proprietary Microsoft format.
  1079.        
  1080. If necessary, a program could be written to convert AmigaBASIC random files 
  1081. to ACE's format and vice-versa.
  1082.        
  1083. ACE random files are flexible because it is possible to have multiple
  1084. structure types in a single random file. They are efficient because there
  1085. is a 1:1 correspondence between a given structure and random file record.
  1086. They are also simple for this reason and because few commands and functions
  1087.  
  1088.                                   - page 17 -
  1089.  
  1090. are needed.
  1091.  
  1092. See ACE:prgs/IO/rfile.b for an example program, and carefully read the
  1093. section on "Structures" below. See ref.doc for the details of CLOSE, GET,
  1094. LOC, LOF, OPEN, and PUT. See also ERR for error codes relating to random
  1095. files.
  1096.  
  1097.     
  1098. Command line and Workbench arguments
  1099. ------------------------------------
  1100. When invoked from a Shell or CLI, an ACE program may have arguments, eg:
  1101.  
  1102.     tree 30
  1103.  
  1104. Arguments can be accessed by two ACE functions:
  1105.  
  1106.     ARGCOUNT and ARG$(n)
  1107.  
  1108. The former returns a short integer value indicating the number of arguments
  1109. for the current program, while the latter returns the nth argument as a string
  1110. where n ranges from 0 to argcount. The zeroth argument (ie. ARG$(0)) is the 
  1111. name of the program.
  1112.  
  1113. Workbench arguments are currently supported by ACE in the form of four 
  1114. functions in the WBarg SUBmod: WBargcount, WBarg$(n), WBargPath$(n) and
  1115. WBargLock&(n).
  1116.  
  1117. The first three are the most useful. The fourth is mainly for use by 
  1118. WBargPath$. 
  1119.  
  1120. WBargcount returns the number of arguments passed to a program. This includes
  1121. the program name.
  1122.  
  1123. As with ARG$(0), the zeroth Workbench argument is the name of the program.
  1124.  
  1125. To pass arguments to a program via Workbench one of the shift keys is held 
  1126. down while the icons which represent the arguments to be passed are activated.
  1127. While still depressing the shift key, the application icon is double clicked. 
  1128.  
  1129. An alternative method of passing arguments is to change the default tool of a 
  1130. project icon (eg: document) with the Info option from Workbench.
  1131.  
  1132. When this project icon is double clicked, the default tool will be loaded.
  1133. In this case, if the source code of the default tool (the program) had a line 
  1134. such as:
  1135.  
  1136.     x$ = WBarg$(1)
  1137.  
  1138. x$ would contain the name of the project file.
  1139.  
  1140. WBargPath$(n) is used to find the full path of the file name and includes 
  1141. trailing ":" and "/" characters.
  1142.  
  1143. This SUBmod also has functions for handling ToolTypes: ToolTypeVal$,
  1144. ToolTypeMatched, and DefaultTool$.
  1145.  
  1146. See the source code and example programs in SUBmods/WBarg for more.
  1147.  
  1148.       
  1149. Subprograms
  1150. -----------
  1151.  
  1152.                                   - page 18 -
  1153.  
  1154. Subprograms are supported by ACE, but differ from AmigaBASIC subprograms in
  1155. a number of ways. Namely, ACE subprograms:
  1156.  
  1157.     - Don't use the STATIC keyword,
  1158.     - Allow recursion,
  1159.        - Can return values.
  1160.  
  1161. ACE subprograms don't make use of the STATIC keyword because they are non
  1162. static. This means that between calls to a specific subprogram, variables
  1163. local to the subprogram cease to retain any meaningful value since the 
  1164. memory used to store them may be reused for other purposes.
  1165.  
  1166. Recursive subprograms are an important feature of modern general programming 
  1167. languages. For several examples of the use of recursion, see the included 
  1168. programs (eg: fact.b, hanoi.b, tree.b). See also the WBarg SUBmod.
  1169.  
  1170. A word of warning about recursion: it can be stack hungry, so it's a good 
  1171. idea to set your stack to 20000 or so, just to be safe, although in most 
  1172. cases, this will be a lot more than you need. From Workbench, simply change 
  1173. the tool's stack size with Info, or with the STACK command in a shell.
  1174.  
  1175. As with AmigaBASIC, ACE subprogram declarations cannot be nested.
  1176.  
  1177. The syntax of a subprogram call is the same as in AmigaBASIC:
  1178.  
  1179.     [CALL] sub-name[(parameter-list)]
  1180.  
  1181. The only difference is that the parentheses around the parameter list are
  1182. not optional when CALL is omitted -- unless there are NO parameters. 
  1183.  
  1184. CALL *must* be used after THEN in a single-line IF..THEN statement.
  1185.  
  1186. By default, every subprogram has a return type of single-precision (just like 
  1187. variables). The DEFxxx directives can be used to change the default data type 
  1188. of subprograms, as can the trailing characters !#$&%. A subprogram name can
  1189. also be preceded by SHORTINT,LONGINT,ADDRESS,SINGLE or STRING as yet another
  1190. alternative to setting the subprogram's return type.
  1191.  
  1192. The fact that ACE subprograms can be easily used as functions pretty much 
  1193. obviates the need for DEF FN. However for reasons of compatibility with 
  1194. AmigaBASIC and other BASICs, as well as its utility for simple functions, 
  1195. ACE supports DEF FN (as of ACE v2.0). 
  1196.  
  1197. A subprogram is given a value either inside the body of the relevant 
  1198. subprogram or in the main program (eg: to zero it) - ala Pascal - thus:
  1199.  
  1200.     sub-name = <expression>
  1201.  
  1202. However, subprograms cannot be assigned a value in any other way (eg: with
  1203. INPUT or READ).
  1204.  
  1205. A subprogram can be used in an expression, whereupon the subprogram is called
  1206. and its value pushed onto the stack for inclusion in the final result of the
  1207. expression, eg:
  1208.  
  1209.     x = n*pow(n)
  1210.  
  1211. where "pow" is a subprogram with one parameter.
  1212.  
  1213. While subprogram declarations can appear anywhere within the program text,
  1214. ACE requires that declarations precede calls. So:
  1215.  
  1216.                                   - page 19 -
  1217.  
  1218.  
  1219.     sub test
  1220.       print "hello"
  1221.      end sub
  1222.  
  1223.     test
  1224.  
  1225. is legal, but:
  1226.  
  1227.     test
  1228.  
  1229.     sub test
  1230.       print "hello"
  1231.      end sub
  1232.  
  1233. is not, and will yield an "undeclared subprogram" error. To get around this, 
  1234. a forward declaration can be used:
  1235.  
  1236.     declare sub test
  1237.     
  1238.     test
  1239.  
  1240.     sub test
  1241.       print "hello"
  1242.     end sub
  1243.  
  1244. Forward declarations can include a parameter list. If you later declare
  1245. the actual SUB with a different parameter list and you've already called 
  1246. the subprogram after a forward declaration, the results will be unpredictable.
  1247. I may place tighter controls on this at some stage.
  1248.  
  1249. Actual parameters are checked for number and type against formals, and 
  1250. parameter count mismatches result in a compilation error. Actual parameters
  1251. are coerced to the corresponding formal parameter's type.
  1252.  
  1253. ACE's parameter passing mechanism for subprograms is NOT the same as that
  1254. used for assembly code routines or C functions. In other words, the standard 
  1255. C parameter passing mechanism is not used for SUBs. This may be changed in 
  1256. the future as it makes object modules written in ACE incompatible with C or 
  1257. assembler object modules in this respect.
  1258.   
  1259. Changes made to a formal parameter have no effect upon the actual parameter 
  1260. in a simple call to an ACE subprogram, but see "Limitations" re: overwriting 
  1261. of strings/arrays during recursive calls; see also "Structures" below. 
  1262.  
  1263. The formal parameter list consists of identifiers separated by commas. Each 
  1264. identifier may also be preceded by: SHORTINT,LONGINT,ADDRESS,SINGLE or STRING 
  1265. to avoid the use of a qualifier (%&!$).
  1266.  
  1267. Actual parameters can basically be any type of expression. A whole array 
  1268. cannot be passed as a value parameter in ACE however.
  1269.  
  1270. There is an arbitrary upper limit of 40 parameters per subprogram at the
  1271. moment, which may be removed at some stage.
  1272.  
  1273. Main program variables and arrays can be accessed and modified within 
  1274. subprograms via the SHARED directive. All shared variables are passed by 
  1275. reference to a subprogram.
  1276.  
  1277. Multiple SHARED statements are allowed within a single subprogram.
  1278.  
  1279.  
  1280.                                   - page 20 -
  1281.  
  1282. DIM SHARED is not allowed. An array is declared to be shared in exactly the 
  1283. same way as simple variables, for example:
  1284.  
  1285.     DIM x(10)
  1286.  
  1287.     sub thing
  1288.         shared x
  1289.         .
  1290.         .
  1291.         end sub
  1292.  
  1293. Note that parentheses are not required after an array in the shared statement, 
  1294. nor are they legal in ACE.
  1295.  
  1296. Keep the following in mind with regard to shared variables in ACE:
  1297.  
  1298.     - Shared variables only allow access to main program
  1299.       variables from a subprogram, and do not provide a
  1300.       mechanism for changing the value of variables in 
  1301.           one subprogram from another.  
  1302.  
  1303.         - The name of a variable to be shared must correspond
  1304.       to the name of an existing (ie: already referenced/declared) 
  1305.           main program variable.
  1306.  
  1307. Although variable parameters are not explictly provided by ACE there are 
  1308. two ways to implement them: using indirection operators for simple variables 
  1309. and the ADDRESS option of DIM and STRING (see also "Structures" section).
  1310.  
  1311. Here's an example of call-by-reference parameters for simple variables:
  1312.  
  1313.     sub doub(address x)
  1314.        *!x := *!x * 2    '..n! = n!*2 [note the ":=" symbol!]
  1315.     end sub
  1316.  
  1317.     n!=22.5
  1318.     print n!
  1319.     doub(@n!)  '..pass the address of n!
  1320.     print n!
  1321.  
  1322. which passes the single-precision variable n by reference to the subprogram 
  1323. doub, where n is doubled. This will first print 22.5 and then 45.
  1324.  
  1325. For an array, the following can be done:
  1326.  
  1327.     sub test(address x)
  1328.     dim a(10) address x  
  1329.       a(3)=a(3)+12
  1330.     end sub
  1331.  
  1332.     dim n(10)
  1333.     n(3)=2
  1334.     print n(3)
  1335.     test(@n)    '..pass address of array n.
  1336.     print n(3)
  1337.  
  1338. which would print first 2 and then 14.
  1339.  
  1340. The same mechanism can be used to pass a string variable by reference (see
  1341. the STRING command's ADDRESS option).
  1342.  
  1343.  
  1344.                                   - page 21 -
  1345.  
  1346. These variable parameter mechanisms are most useful when used to pass data 
  1347. *between* subprograms, otherwise it is simpler to use SHARED variables.
  1348.    
  1349. The following table shows the possibilities regarding parameters and shared 
  1350. variables in ACE:
  1351.  
  1352. +---------------------+---------+-------------+------------------------------+
  1353. | Data Type / Object  |    Shared     | Value param | Call by Reference parameter  |
  1354. +---------------------+---------+-------------+------------------------------+
  1355. | SHORTINT VARIABLE   |    YES        | YES          |    YES - *%addr                 |
  1356. |              |             |          |                     |
  1357. | LONGINT/ADDRESS VAR |    YES     | YES          |    YES - *&addr                 |
  1358. |              |            |          |                         |
  1359. | SINGLE VARIABLE     |    YES     | YES          |    YES - *!addr                 |
  1360. |              |            |          |                         |
  1361. | STRING VARIABLE     |    YES    | YES          |    YES - STRING x ADDRESS addr  |
  1362. |              |        |          |                         |
  1363. | EXTERNAL VARIABLE   |    NO    | YES          |    YES - *%, *&, *!, STRING ..  |
  1364. |              |        |          |                     |
  1365. | ARRAY              |    YES    | NO          |    YES - DIM x ADDRESS addr     |
  1366. |              |        |          |                         |
  1367. | STRUCTURE          |    YES    | NO          |    YES - See "Structures" below |
  1368. +---------------------+---------+-------------+------------------------------+
  1369.  
  1370. Note: In the above table, "addr" is a long integer address. VARPTR or @ 
  1371. can be used to obtain this.
  1372.  
  1373.     
  1374. Structures
  1375. ----------
  1376. Structures have been included in ACE mainly because of their utility in 
  1377. gaining access to operating system functions. 
  1378.  
  1379. Structure members may be of the following type: BYTE (in structures only),
  1380. SHORTINT, LONGINT, ADDRESS, SINGLE, STRING. The latter can have an optional 
  1381. size specification. A structure may also have as a member another structure. 
  1382.  
  1383. If you want to have a pointer to a structure (or a pointer to anything else) 
  1384. as a member, simply declare it to be of type ADDRESS.
  1385.  
  1386. Allowing structures to have other structures as members makes converting 
  1387. system structures from C to ACE much easier than it otherwise would be, eg:
  1388.  
  1389.     STRUCT DateStamp
  1390.        LONGINT days
  1391.       LONGINT secs
  1392.       LONGINT ticks
  1393.       END STRUCT
  1394.  
  1395.     STRUCT myFirstStruct
  1396.       DateStamp ds
  1397.       STRING name SIZE 30
  1398.     END STRUCT
  1399.  
  1400.     DECLARE STRUCT myFirstStruct mine
  1401.     DECLARE STRUCT DateStamp *myDate
  1402.     
  1403.     .
  1404.     .
  1405.  
  1406.     myDate = @mine->ds    '..assign address of mine->ds to myDate.
  1407.  
  1408.                                   - page 22 -
  1409.  
  1410.     myDate->days = 23
  1411.  
  1412.     .
  1413.     .
  1414.  
  1415. If an array is required as a structure member, it is currently necessary 
  1416. to use STRING <ident> SIZE <bytes>. Most system structures use character
  1417. arrays (strings) anyway. As an example, if you wanted a SHORTINT array 
  1418. member with 50 elements (0..49) you could say:
  1419.  
  1420.     STRUCT mySecondStruct
  1421.       STRING myArray SIZE 100    '..reserve space for the array
  1422.       .
  1423.       .
  1424.     END STRUCT
  1425.     
  1426.     DECLARE STRUCT mySecondStruct aStruct
  1427.  
  1428.     DIM N%(100) ADDRESS @aStruct->myArray
  1429.  
  1430. You can of course use SIZEOF to determine the number of bytes ACE would
  1431. set aside for a particular array. A two line program would accomplish
  1432. this:
  1433.  
  1434.     DIM a_short_array%(49)
  1435.     PRINT SIZEOF(a_short_array%)
  1436.  
  1437. The value thus derived can then be used when declaring a structure such
  1438. as the one shown above.
  1439.  
  1440. Note that in the case of the array and structure members above, it is 
  1441. necessary to take the address of the member and assign it to a normal
  1442. array or structure (pointer to structure - see below) variable. 
  1443.  
  1444. When declaring a structure, the only difference between the following two
  1445. forms:
  1446.  
  1447.         DECLARE STRUCT mystructtype mystruct
  1448.     and
  1449.         DECLARE STRUCT mystructtype *mystruct
  1450.  
  1451. is that for the former, an appropriate data object is created (on a long
  1452. word boundary), but not for the latter.
  1453.  
  1454. In both cases, mystruct contains the start address of a structure of type 
  1455. mystructtype. In the second case, the address is NULL until assigned a value 
  1456. (eg: with ALLOC). In both cases, the address can be reassigned at will, 
  1457. although this should only really be done for structure pointers (the second
  1458. form).
  1459.  
  1460. Since both forms of structure declaration result in an address being stored
  1461. (in mystruct in the example), the dereferencing operator is always "->".
  1462.  
  1463.     examples:
  1464.     --------
  1465.  
  1466.     PRINT mystruct          -  prints the start address of the structure.
  1467.  
  1468.     PRINT mystruct->mins -     prints the value of a member called mins.
  1469.   
  1470. The SIZEOF function can be used to determine the size of a structure type
  1471.  
  1472.                                   - page 23 -
  1473.  
  1474. if allocating memory for a structure (see prgs/misc/linkedlist.b).
  1475.  
  1476. ACE structures are stand-alone data objects, and cannot be elements in an 
  1477. array, although structure *addresses* _can_ be. For an example of the 
  1478. latter, see prgs/misc/array_of_structs.b.
  1479.  
  1480. An ACE structure can be SHARED to allow its member's values to be modified, 
  1481. or a structure's address can be passed to a subprogram, eg:
  1482.  
  1483.     struct my
  1484.        longint one
  1485.        longint two
  1486.     end struct
  1487.     
  1488.     sub test(addr&)
  1489.     declare struct my *second
  1490.        second=addr&
  1491.        second->one = second->one * 2
  1492.     end sub
  1493.  
  1494.     '..main
  1495.     declare struct my first
  1496.     first->one=12
  1497.     print first->one
  1498.     test(first)
  1499.     print first->one
  1500.  
  1501. which will print 12 followed by 24.
  1502.  
  1503. The following code allocates enough memory to hold a structure of type "my", 
  1504. gives values to the structure's 2 members, and changes the address held by 
  1505. the structure variable "third" to the start of the newly allocated memory 
  1506. area:
  1507.  
  1508.     declare struct my *third
  1509.  
  1510.     sub create(ADDRESS a_struct)
  1511.     declare struct my *temp
  1512.       temp = ALLOC(sizeof(my))
  1513.       temp->one = 16
  1514.       temp->two = 10
  1515.       *&a_struct := temp    '..change structure variable's value
  1516.     end sub
  1517.  
  1518.     '..main
  1519.     create(@third)
  1520.     .
  1521.     .
  1522.  
  1523. One word of caution. ACE makes no attempt to align data on word boundaries 
  1524. within a structure, so make sure that Shortint, Longint or Address members
  1525. start at an offset from the start of the structure which is a multiple of
  1526. the size of the data member in question (check with Print Sizeof(Shortint)
  1527. or Print Sizeof(Longint) etc if in doubt). If alignment is out, the assembler
  1528. will complain. ACE _does_ long-word align a static structure's start address 
  1529. however, and assigning to structure pointer variables results in long-word
  1530. aligned structures when using ACE's ALLOC or Exec's AllocMem() etc. 
  1531.  
  1532. Finally, it is not currently possible to use INPUT, (LINE) INPUT# or READ 
  1533. in conjunction with structures.
  1534.  
  1535.  
  1536.                                   - page 24 -
  1537.  
  1538.     
  1539. Shared library function calls
  1540. -----------------------------
  1541. ACE provides access to shared libraries in the same way as AmigaBASIC does
  1542. with the exception that you MUST declare a function in order to use it. 
  1543.  
  1544. Also, the library in question must either be in LIBS: or in ROM.
  1545.  
  1546. As of version 2.0, ACE and AmigaBASIC are otherwise pretty much the same. 
  1547. The ACE commands also retain their earlier syntax for backward compatibility 
  1548. and convenience.
  1549.  
  1550. The commands are as follows:
  1551.  
  1552. LIBRARY <libname>    
  1553.  
  1554.     - Where <libname> is the name of a shared library with or 
  1555.       without quotes (eg: "graphics", "graphics.library", graphics).
  1556.  
  1557.     - A ".library" or ".bmap" suffix is allowed but optional.
  1558.  
  1559.            - The LIBRARY command opens the shared library and provides
  1560.       a copy of its base address for use internally by function 
  1561.       calls.
  1562.  
  1563.     - If a library can't be opened at run-time, the program 
  1564.       will abort.
  1565.  
  1566.  
  1567. LIBRARY CLOSE [<libname>]
  1568.  
  1569.     - Closes the specified shared library or all open libraries
  1570.       if no library name is given.
  1571.  
  1572.     - Closing a library more than once will cause no harm.
  1573.  
  1574.  
  1575. Notes about standard libraries used by ACE:
  1576.  
  1577.     - There are currently six standard libraries which are often opened 
  1578.       by ACE routines during a program run. These are: dos, intuition,
  1579.       graphics, mathffp, mathtrans and translator libraries.
  1580.  
  1581.     - If one of these six is opened by the LIBRARY command it will 
  1582.       be opened at the start of the program *and* closed at the end. 
  1583.       Any other library will be opened and closed at the points in 
  1584.       the program specified by you.
  1585.  
  1586.     - You don't actually have to close any of the six libraries 
  1587.       mentioned above, but it won't hurt.
  1588.  
  1589.     - Moreover, you never have to open or close the dos.library
  1590.       since ACE opens it for EVERY program.
  1591.  
  1592.  
  1593. DECLARE FUNCTION <funcname>[%&!#$][(param-list)] LIBRARY [<libname>]
  1594.         
  1595.     - Where <funcname> is the case sensitive name of a function in a
  1596.       shared library.
  1597.  
  1598.     - <funcname> may have a trailing character (&%#!$) to indicate type,
  1599.  
  1600.                                   - page 25 -
  1601.  
  1602.       otherwise default data type rules apply for the function's return 
  1603.       value. This character is optional when CALLing the function.
  1604.  
  1605.     - The optional parameter-list is for documentation purposes only
  1606.       and is otherwise ignored.
  1607.  
  1608.     - If <libname> (same as for LIBRARY and LIBRARY CLOSE) is specified, 
  1609.       ACE only looks in the bmap file for that library, otherwise ACE
  1610.       looks for the function in the bmap files for all open libraries 
  1611.       and all the standard libraries known to the compiler. Needless 
  1612.       to say that specifying <libname> results in faster bmap file
  1613.       entry lookups. This option is not given by AmigaBASIC however.
  1614.  
  1615.     - Example: DECLARE FUNCTION SetSoftStyle LIBRARY
  1616.  
  1617.  
  1618. [CALL] <funcname>[(parameter-list)]
  1619.  
  1620.     - Transfers control to the function <funcname>, loading the
  1621.       appropriate registers before doing so, according to the
  1622.       information about that function in the library's bmap file. 
  1623.  
  1624.      - The return value of a function can be accessed by calling
  1625.       a function as part of an expression, eg: addr& = AllocMem(100,2).
  1626.  
  1627. Function declarations are GLOBAL. They are are NOT optional in ACE.
  1628.  
  1629. ** PLEASE NOTE ***
  1630. No type checking of parameters is performed, so expect weirdness if you pass
  1631. values of the wrong type to a shared library function. ACE _does_ however now 
  1632. automatically promote all short integers to long integers by sign-extension.
  1633.  
  1634. When passing strings as parameters it is not necessary to add a CHR$(0)
  1635. to the end of a string since ACE strings are already NULL terminated. 
  1636.  
  1637. Either VARPTR or SADD can safely be used to find the address of a string 
  1638. variable or constant. Actually, the use of SADD or VARPTR for strings
  1639. passed to library functions is optional, but it's probably a good idea to 
  1640. use one or the other all the time, for consistency's sake. These comments 
  1641. also apply to calling machine code routines and external functions.
  1642.   
  1643. It is up to YOU to open and close libraries correctly. ACE doesn't keep
  1644. track of this, and will try to jump to a library function so long as 
  1645. it finds a reference to it in a bmap file even if the library hasn't 
  1646. been opened! As mentioned above, it is not necessary to open and close 
  1647. dos.library because _every_ ACE program does this.
  1648.  
  1649. ACE expects the bmap file for a library to be in the directory ACEbmaps:
  1650. (see "Installation"). As of version 2.37 these are supplied with the ACE
  1651. distribution for the standard Amiga shared libraries. In addition to these 
  1652. are a complete set of header files translated from the original C headers. 
  1653. In no way are these necessary to use shared library function in ACE but for 
  1654. serious system-level work they are highly recommended. 
  1655.  
  1656. Be aware that while the bmap files in ACEbmaps: cater for all operating
  1657. system versions from 1.3 through to 3.0, some library functions may not be 
  1658. supported on the machine you're compiling programs for. The same is true of
  1659. the header files in ACEinclude:.
  1660.  
  1661. As of version 2.0, I have provided a program (FD2BMAP) which is functionally 
  1662. equivalent to ConvertFD (since this may NOT be freely redistributed) so that 
  1663.  
  1664.                                   - page 26 -
  1665.  
  1666. bmap files for new libraries can be created. The program FD2BMAP can be found 
  1667. in the ACE:utils/fd2bmap directory and was written in ACE by Harald Schneider, 
  1668. with some modifications from me.
  1669.  
  1670. The 1.3 FD files can be found in the BasicDemos drawer on the Extras disk. 
  1671.  
  1672. AmigaBASIC cannot handle functions which use address register a5. This is 
  1673. not true for ACE. Neither ACE nor AmigaBASIC allow the use of functions which
  1674. use register a6 however.
  1675.  
  1676. See the programs in prgs/Library for examples of how to use shared library 
  1677. functions in ACE.
  1678.  
  1679.   
  1680. Machine code calls
  1681. ------------------
  1682. ACE supports AmigaBASIC's mechanism for calling machine code routines and
  1683. the passing of parameters to such routines. AmigaBASIC's stack conventions 
  1684. are also followed (ie: C style parameter passing).
  1685.  
  1686. The syntax for calling such a routine is:
  1687.  
  1688.     CALL long-integer-variable-name[(parameter-list)]
  1689.  
  1690. Note that CALL is NOT optional. Also, the variable containing the address 
  1691. of the routine *must* be a long integer (LONGINT or ADDRESS) in ACE.
  1692.  
  1693. For example, 
  1694.  
  1695.     CALL caps&(length&,addr&)
  1696.  
  1697. will set up the stack like this:
  1698.     
  1699.     8(sp) = addr&
  1700.     4(sp) = length&
  1701.     0(sp) = return address
  1702.  
  1703. on entry to the machine code subroutine caps&.
  1704.  
  1705. On exit from a routine, ACE cleans up the stack by POPping all parameters.
  1706.  
  1707. You can use a short integer array, a string or an allocated area of memory
  1708. (eg. with ACE's ALLOC function) to poke the bytes of a machine code routine 
  1709. into. I prefer the latter method.
  1710.  
  1711. Note that because ACE treats ASCII 0 as the end-of-string character, don't 
  1712. use the string-building method, eg:
  1713.  
  1714.     z$=""
  1715.     for i=1 to N
  1716.          read b
  1717.       z$=z$+chr$(b)
  1718.         next
  1719.  
  1720. since if b=0, chr$(b) will be the NULL string. If you want to use a string,
  1721. do the following:
  1722.  
  1723.     z$=""    '..or STRING z$ SIZE 100 (if there are 100 bytes of MC).
  1724.     addr&=sadd(z$)
  1725.     for i&=0 to N-1
  1726.       read b%
  1727.  
  1728.                                   - page 27 -
  1729.  
  1730.       poke addr&+i&,b%
  1731.     next
  1732.     call addr&
  1733.  
  1734. The latter is okay, so long as you don't allocate other strings with odd 
  1735. sizes. But if you want to be sure that you have an area of memory which 
  1736. is long-word aligned, use ALLOC (or AllocMem), eg:
  1737.  
  1738.     addr&=Alloc(100)    '..100 bytes of ANY memory
  1739.     for i&=0 to N-1
  1740.       read b%
  1741.       poke addr&+i&,b%
  1742.     next
  1743.     CALL addr&
  1744.  
  1745. The above examples assume the presence of appropriate DATA statements. See 
  1746. the prgs/MC directory for examples.
  1747.  
  1748. ACE also supports primitive inline assembly code inclusion. See ref.doc
  1749. under ASSEM..END ASSEM for details.
  1750.  
  1751.  
  1752. External references
  1753. -------------------
  1754. Reference can be made to a variable or function in another file which is
  1755. resolved at link time. You may for instance, have written a function in C
  1756. or assembler. It is possible to pass parameters to, call and obtain return
  1757. values (as with ACE SUBs) from such a function in ACE after declaring an 
  1758. external reference to the function with the EXTERNAL FUNCTION or DECLARE
  1759. FUNCTION ... EXTERNAL directive (see command and function reference for 
  1760. syntax).
  1761.  
  1762. When passing parameters, standard C parameter passing conventions
  1763. are used. Although some C compilers seem to pass all parameters as
  1764. 4 bytes per parameter on the stack, ACE allows 2 (short words) or 4 
  1765. byte parameters. Be aware of this! See prgs/ExternFunc for examples.
  1766.  
  1767. External variables can be assigned values like normal variables, eg:
  1768.  
  1769.         external RangeSeed&
  1770.         RangeSeed=5276&
  1771.  
  1772. Instead of the "&" qualifier, the following is also legal:
  1773.  
  1774.         external longint RangeSeed
  1775.  
  1776. External function return values may be of any type as may external variables.
  1777.  
  1778. Note however that externally referenced string variables are assumed to be 
  1779. arrays of characters ala C, eg.
  1780.  
  1781.         char my_buffer[80];
  1782. or
  1783.         char my_string[] = "Hello World!";
  1784.  
  1785. but _not_ a character pointer, eg:
  1786.  
  1787.         char *a_char_pointer = "Hello World!";
  1788.             
  1789. Use a C function to return a character pointer, and externally reference it
  1790. from your ACE program.
  1791.  
  1792.                                   - page 28 -
  1793.  
  1794.  
  1795. All external reference identifiers have an underscore prefixed by ACE but
  1796. this is optional when declaring or using an external reference. C compilers 
  1797. always seem to prefix referenceable symbols with an underscore, so ACE does 
  1798. too.
  1799.  
  1800. Note that the names of external references (all except external SUBs -
  1801. see below) *are* case sensitive.
  1802.  
  1803. Also, the bas script can take as a third argument the name of the object 
  1804. file produced from the original C or assembly source (ie: .o or .lib file) 
  1805. which contains the external function or variable to be linked with your
  1806. ACE program. AIDE has facilities which allow for the linking of multiple
  1807. object modules.
  1808.  
  1809. You can't easily call ACE SUBs from C or assembler because ACE SUBs don't 
  1810. use C parameter passing conventions and ACE code relies heavily upon linking
  1811. code from run-time libraries (db.lib and startup.lib).
  1812.  
  1813.  
  1814. Common and Global variables
  1815. ---------------------------
  1816. It is sometimes desirable for variables to be static (in the BSS segment) rather
  1817. than stack-allocated. For example, since in a SUBmod (see next section), there is
  1818. no main-program level, only the environment of individual subprograms, there can 
  1819. be no stack-allocated main-program variables. An ACE Global variable solves
  1820. this problem by permitting the creation of simple, static variables at level 0
  1821. (main-program level).
  1822.  
  1823. A Global variable's scope is the _whole_ source module from the point of 
  1824. declaration. A Common variable is the same except that it is exported to any
  1825. other module that wishes to use it. So, for example, one ACE module may contain:
  1826.  
  1827.     Common Single x
  1828.  
  1829. while another has the declaration:
  1830.  
  1831.     External Single x
  1832.  
  1833. which is a reference to the former. The scope of a Common is the same as that
  1834. for a global, except that its fame can spread far and wide to other modules.
  1835. Due to this scoping, there is no need to explicitly share Commons or Globals
  1836. in SUBs.
  1837.  
  1838. In short, Common and Global variables have similar semantics to Externals
  1839. with the exception that a Common or Global string variable may not be of
  1840. the form:
  1841.  
  1842.     Common | Global String <id> Address <addr>
  1843.  
  1844. but the Size option may still be used.
  1845.  
  1846.  
  1847. Subprogram modules (SUBmods)
  1848. ----------------------------
  1849. It is possible to create libraries of ACE subprograms and so to have
  1850. multi-file ACE projects. For example in one file you can have:
  1851.  
  1852.     SUB lines(n) EXTERNAL
  1853.       FOR i=1 to n
  1854.         LINE (RND*640,RND*200)-(RND*640,RND*200)
  1855.  
  1856.                                   - page 29 -
  1857.  
  1858.       NEXT
  1859.     END SUB
  1860.  
  1861. and in another file:
  1862.  
  1863.     '..main
  1864.     DECLARE SUB lines(n) EXTERNAL
  1865.     LIBRARY "graphics.library"
  1866.     WINDOW 1,,(0,0)-(640,200)
  1867.     lines(500)
  1868.     WINDOW CLOSE 1
  1869.     END
  1870.  
  1871. If the latter file is called say, main.b and the former is called lines.b
  1872. then the following sequence of shell commands will give you an executable
  1873. called main:
  1874.  
  1875.     ace -Om lines        { The -m switch is the key here }
  1876.     a68k lines.s
  1877.     bas -O main lines.o
  1878.  
  1879. The first two commands can be replaced by:
  1880.  
  1881.     module lines
  1882.  
  1883. which is a shell script in the bin directory. The effect of the last of 
  1884. the 3 commands shown above can also be achieved via the Linker menu in 
  1885. AIDE, while the Compiler menu "Create Linkable Module" option is the 
  1886. equivalent of the first two.
  1887.  
  1888. There are a few things to be kept in mind when using ACE modules:
  1889.     
  1890.     1. Only subprograms - not subroutines (ie. via GOTO/GOSUB) - in 
  1891.     such modules can be called from other modules.
  1892.  
  1893.     2. The main module *MUST* open all standard libraries required
  1894.     by the other ACE modules linked to it. If in doubt add the 
  1895.     following lines of code at the top of your main program:
  1896.  
  1897.             LIBRARY mathffp
  1898.             LIBRARY mathtrans
  1899.             LIBRARY graphics
  1900.             LIBRARY intuition
  1901.             LIBRARY translator    '..only if TRANSLATE$ used
  1902.  
  1903.     If your code works as a single-module program but you invoke 
  1904.     the GURU or your program just doesn't work anymore when part 
  1905.     of it is placed into a linkable module, the above should fix it.
  1906.  
  1907.     3. The "m" switch creates an assembly source module containing 
  1908.     bare code with no calls to the startup functions normally invoked
  1909.     by an ACE program. Because of this, you need to keep the following
  1910.     in mind:
  1911.  
  1912.     - Command-line arguments must either be handled in the main
  1913.       program module or ARGCOUNT or ARG$ must be used one or more 
  1914.       times in the main module if they are going to be used in a 
  1915.       module produced with ACE's "m" switch. A line of code in 
  1916.       the main module such as:
  1917.  
  1918.         n = ARGCOUNT
  1919.  
  1920.                                   - page 30 -
  1921.  
  1922.  
  1923.       will suffice.
  1924.  
  1925.     - Likewise, if ALLOC is used in a module, it must also be used 
  1926.       at least once in the main program (eg. x=ALLOC(0) - no bytes
  1927.       will be allocated).     
  1928.  
  1929. In both cases, it is a matter of letting the compiler know that these
  1930. features are required by the final executable program which the above
  1931. actions will do.
  1932.  
  1933.     - In order to use DATA/READ within a module, make sure you issue
  1934.       a RESTORE command (in a subprogram) before the _first_ READ is 
  1935.       executed. This RESTORE command *must* be in a subprogram.
  1936.  
  1937.       For example, in the calling module:
  1938.  
  1939.         library mathffp
  1940.         declare sub data_test external
  1941.         data_test
  1942.  
  1943.       and in the library module:
  1944.  
  1945.         sub data_test external
  1946.             restore
  1947.             read x
  1948.             print x
  1949.             data 1.345    '..DATA lines _can_ be outside of SUBs
  1950.         end sub
  1951.  
  1952.     - ON TIMER normally has special startup code associated with it.
  1953.       Since there _is_ no startup code in modules, you will have to
  1954.       include the following lines of code such that they will be 
  1955.       executed before the ON TIMER code:
  1956.  
  1957.         external function ontimerstart
  1958.         ontimerstart
  1959.  
  1960.       For example, in the calling module:
  1961.  
  1962.           library mathffp
  1963.           declare sub timer_test external
  1964.           timer_test
  1965.  
  1966.       and in the library module:
  1967.  
  1968.           sub timer_test external
  1969.         SHORTINT count
  1970.           external function ontimerstart    '..can be outside SUB
  1971.           ontimerstart
  1972.             on timer(1) gosub do_beep
  1973.             timer on
  1974.             while -1
  1975.                 if count=5 then exit sub
  1976.             wend  
  1977.           do_beep:
  1978.               ++count
  1979.               beep
  1980.               return
  1981.         end sub
  1982.  
  1983.  
  1984.                                   - page 31 -
  1985.  
  1986. In addition, while subprograms can be treated as functions when in modules,
  1987. because there is no startup code, SUBs in a module are allocated no space
  1988. for return value storage. This means that function return values must be
  1989. passed by some method other than via the stack frame. In this case, ACE
  1990. uses the 680x0 register d0. Since d0 can be overwritten at any time, the
  1991. final thing a subprogram (in a module) should do is to assign the return 
  1992. value for the subprogram. C forces you to do this anyway, it's just 
  1993. that ACE normally gives you more flexibility than C. For example, the 
  1994. following:
  1995.  
  1996.     SUB even(n) EXTERNAL
  1997.       m = n MOD 2
  1998.       IF m=0 THEN
  1999.         even = -1
  2000.       ELSE
  2001.         even = 0
  2002.       END IF 
  2003.     END SUB
  2004.  
  2005. is acceptable since the final action of the subprogram is to assign itself
  2006. a return value. On the other hand, the following will cause d0 to be 
  2007. overwritten before the subprogram can return its value to the caller:
  2008.  
  2009.     SUB even(n) EXTERNAL
  2010.       m = n MOD 2
  2011.       IF m=0 THEN
  2012.         even = -1
  2013.       ELSE
  2014.         even = 0
  2015.       END IF 
  2016.         PRINT n;"mod 2 is";m    ' trashes d0!!
  2017.     END SUB
  2018.  
  2019. If need be of course, you can simply use a temporary local variable to
  2020. hold the final return value to be assigned later.
  2021.  
  2022. Note that the d0 convention ONLY applies when the "m" compiler switch is
  2023. used and that it applies to all subprograms in a module. However, even if
  2024. a SUB is declared to be external, the d0 parameter passing convention will
  2025. not be used unless either: (i) the "m" switch is used for the module in 
  2026. which the SUB is defined, or (ii) a SUB is used after being externally
  2027. referenced via DECLARE SUB ... EXTERNAL.
  2028.  
  2029. Instead of an external SUB, it is legal to have an external DEF FN. The
  2030. forward declaration is still the same as for a SUB. The definition for
  2031. the "even" function (in a module) looks like this:
  2032.  
  2033.     DEF even(n) EXTERNAL = -(n MOD 2)
  2034.  
  2035. Remember also that only variables which are local to SUBs and subprogram 
  2036. parameters may be used in a module. Global variables are not provided for 
  2037. correctly when declared in a module produced with the "m" switch, again 
  2038. because of the lack of startup code.
  2039.  
  2040. Finally, be careful to match up the return and parameter types for an 
  2041. externally defined subprogram and its forward (external) declaration.
  2042.  
  2043.  
  2044. Windows
  2045. -------
  2046. You can open up to 16 user-defined windows per program. See the command 
  2047.  
  2048.                                   - page 32 -
  2049.  
  2050. and function reference for the syntax of the WINDOW statement.
  2051.  
  2052. All user-defined windows are now (as of ACE v2.0) Intuition windows with 
  2053. each characteristic being configurable via the "type" parameter as per 
  2054. AmigaBASIC (see ref.doc).
  2055.  
  2056. Windows can be opened on the Workbench screen or on a user-defined screen.
  2057.  
  2058. The zeroth window (the shell/CLI, if the program was CLI launched) is now
  2059. the only instance of a DOS console window in ACE.
  2060.  
  2061. The WINDOW function takes a single parameter and returns information about
  2062. the current output window. See ref.doc for details.
  2063.  
  2064. Note that for user-defined windows, close-gadget clicks must be handled by 
  2065. the use of ON WINDOW event trapping or via the "w" compiler switch (or the
  2066. OPTION w+ command).
  2067.  
  2068. Please read the next section for more information about how windows relate
  2069. to screens in ACE.
  2070.  
  2071.   
  2072. Screens
  2073. -------
  2074. A single program can have open nine screens at once (memory permitting).
  2075.  
  2076. By default, when a screen is opened, a (BORDERLESS+BACKDROP) window
  2077. the same size as the screen is also opened. Subsequent output is directed 
  2078. to and input received from this window until the screen is closed (unless 
  2079. other windows are defined for the screen). Note that this feature is not 
  2080. found in AmigaBASIC. Note also that this default window is *not* counted
  2081. as having a window-id of 0. That privilege is reserved for the shell window
  2082. if the program was shell-launched. Read on...
  2083.  
  2084. The main use for such a default window is to provide a simple graphics
  2085. output "slate" for quick-and-dirty programs. The borderless+backdrop
  2086. characteristic prevents user-defined windows which may later be opened 
  2087. onto the screen from accidentally being depth arranged behind an invisible
  2088. window where they would stay for the remainder of that screen's life. With
  2089. a backdrop window this cannot happen since it will _always_ be the rear-most
  2090. window for a screen.
  2091.  
  2092. Text and graphics positions will be different on a screen's default window 
  2093. than for user-defined windows. For example, text in the first row will be 
  2094. partially off the top of the screen, so LOCATE may need to be used to adjust 
  2095. this. In short, I recommend that default windows now ONLY be used for rough 
  2096. output. If you still want a borderless window, use the  WINDOW command and 
  2097. ensure that the window-type has 32 as a component.
  2098.  
  2099. Avoid mixing the use of default and user-defined windows. Except for the
  2100. simple case in which you use nothing but screens and their default windows
  2101. you should consider your own windows to be the primary output destination 
  2102. for graphics and text.
  2103.  
  2104. Windows with depth gadgets cannot be sent behind the default window, but 
  2105. one screen can be sent to the back of other screens. It can also be moved 
  2106. vertically (and possibly horizontally). SCREEN BACK|FORWARD can be used to 
  2107. shuffle screens under program control.
  2108.  
  2109. When a screen is closed, ACE makes the screen with the next highest id 
  2110. the current one, so it is advisable to open and close screens in ascending 
  2111.  
  2112.                                   - page 33 -
  2113.  
  2114. and descending order.
  2115.  
  2116. A special SCREEN function exists in ACE which returns pointers to various
  2117. Intuition structures (window,screen,rastport,viewport,bitmap) and x,y font
  2118. sizes. This is detailed in the command and function reference (ref.doc) as 
  2119. are the following commands: SCREEN, SCREEN CLOSE, PALETTE and PRINTS. The 
  2120. latter is now redundant since all commands and functions can - as of ACE v2.0 
  2121. - be used transparently for screens, user-defined windows and the shell/CLI.
  2122.  
  2123.  
  2124. Gadgets
  2125. -------
  2126. ACE supports the Amiga's three standard gadget types: boolean, proportional 
  2127. (vertical and horizontal), and string (including long integer). 
  2128.  
  2129. Since one of my aims is to support all Amigas running everything from Wb 1.3 
  2130. to Wb 3.0, I have chosen to stick with simple Intuition gadgets for now.
  2131.  
  2132. Even so, ACE now supports the 3D bevel-box look of GadTools gadgets found
  2133. under Wb 2.x/3.0. Moreover, a BEVELBOX command allows the programmer to
  2134. create such boxes at will.
  2135.  
  2136. A future revision may support other gadget types, such as radio buttons, 
  2137. check boxes, list boxes etc.
  2138.  
  2139. Memory permitting, up to 255 gadgets can be created during a single program 
  2140. run.
  2141.  
  2142. The GADGET command creates a gadget with specific features while GADGET CLOSE 
  2143. removes the gadget from the window. Once created, a gadget can be enabled or
  2144. disabled, indeed it can be disabled upon creation if so desired. The GADGET
  2145. MOD command modifies the state of a slider (knob size and position).
  2146.  
  2147. Having created a gadget or gadgets, you must then decide how to receive and
  2148. handle information from them. ACE provides four methods: standard event
  2149. trapping (ON GADGET), polling (via the GADGET function), WAITing for a
  2150. specific gadget or WAITing for any gadget.
  2151.  
  2152. Where it is possible to make your programs modal (ie. focussed upon a single
  2153. event or event type) you can use the GADGET WAIT command.
  2154.  
  2155. The following commands set up a window with two boolean gadgets and a close 
  2156. gadget. The latter is set up by Intuition with the WINDOW command.
  2157.  
  2158. The program traps WINDOW and GADGET events. The comments should help you to
  2159. understand the code.
  2160.  
  2161. CONST having_fun = -1&
  2162.  
  2163. WINDOW 1,"Gadgets",(0,0)-(640,200),8
  2164.  
  2165. GADGET 1,ON,"Hit Me",(3,3)-(75,20),BUTTON,1
  2166. GADGET 2,OFF,"Quit",(100,150)-(200,175),BUTTON,2
  2167.  
  2168. ON GADGET GOSUB gadget_handler
  2169. GADGET ON
  2170.  
  2171. ON WINDOW GOTO quit
  2172. WINDOW ON
  2173.  
  2174. '..main loop (actually does nothing, but is necessary for event trapping)
  2175.  
  2176.                                   - page 34 -
  2177.  
  2178. WHILE having_fun
  2179.   '..have a nap while nothing's happening 
  2180.   '..(don't hog the machine by busy waiting) 
  2181.   SLEEP        
  2182. WEND
  2183.  
  2184. gadget_handler:
  2185.   '..find out which gadget was selected
  2186.   gad = GADGET(1)
  2187.   LOCATE 12,40:PRINT "<<";gad;">>" 
  2188.   if gad = 2 then quit    
  2189. RETURN
  2190.  
  2191. quit:
  2192.   GADGET CLOSE 2
  2193.   GADGET CLOSE 1
  2194.  
  2195.   WINDOW CLOSE 1
  2196. END
  2197.  
  2198. Alternatively, you could poll for a gadget to the exclusion of other events:
  2199.  
  2200. .
  2201. .
  2202. '..await a gadget selection
  2203. REPEAT
  2204.   WHILE NOT GADGET(0)
  2205.     SLEEP  '..be a little nice to other tasks
  2206.   WEND
  2207.   
  2208.   '..which one?
  2209.   gad = GADGET(1)
  2210.   LOCATE 12,40
  2211.   PRINT "<<";gad;">>" 
  2212. UNTIL gad=2
  2213. .
  2214. .
  2215.  
  2216. Finally, you can wait for a gadget:
  2217.  
  2218. .
  2219. .
  2220. GADGET WAIT 2      '.."GADGET WAIT 0" waits for ANY gadget! -> BEST method!
  2221. .
  2222. .
  2223.  
  2224. See the program prgs/GUI/ACEgadgets.b for an example of gadget programming
  2225. in ACE.
  2226.  
  2227. For boolean gadgets you can - if you need to - get information about the 
  2228. width and height of the gadget's text font by calling SCREEN(5) and 
  2229. SCREEN(6). If you need more precise width information, use the graphics 
  2230. library TextLength or TextExtent (v36) function.
  2231.  
  2232. String and LongInt gadgets now have associated with them a 1K buffer.
  2233.  
  2234. For more details about the GADGET commands and function, see ref.doc.
  2235.  
  2236.  
  2237. Menus
  2238. -----
  2239.  
  2240.                                   - page 35 -
  2241.  
  2242. ACE supports menus ala AmigaBASIC, with two additions: menu item keyboard
  2243. equivalents and a MENU WAIT command. The latter puts the program to sleep 
  2244. until a menu event occurs. The former is specified by an optional parameter 
  2245. to the MENU command, for example:
  2246.  
  2247.     MENU 1,5,1,"Quit","Q"
  2248.  
  2249. defines menu item number 5 in menu number 1 to be the 'Quit' option and 
  2250. sets up a command-key sequence (Amiga-Q) for that item. The third parameter
  2251. enables the menu item as per AmigaBASIC.
  2252.  
  2253. Note that although ACE adjusts menu text for font size and type as set
  2254. via preferences, some fonts may require you to pad your menu title/item 
  2255. names with blanks when using command keys to avoid overlaps, so it is a
  2256. good idea to add a couple of spaces to the end of a menu item string.
  2257.  
  2258. For an example of menu programming with ACE see prgs/ifs.b. For a better
  2259. example, see the source code for AIDE. Over time I will modify some of 
  2260. the other example programs in the archive so that they are menu-driven.
  2261.  
  2262. Note that in ACE, MENU CLEAR replaces MENU RESET.
  2263.  
  2264. See ref.doc for more details about the MENU commands and function. See
  2265. also the SUBmod/Menu directory for a SUBmod which permits the creation
  2266. of GadTools (OS Release 2.x/3.x) menus including submenus while still
  2267. allowing the MENU(n) function to be used. In fact, MENU(2) returns the
  2268. submenu item selected.
  2269.  
  2270.  
  2271. Requesters
  2272. ----------
  2273. As of version 2.0, ACE supports 3 standard requesters:
  2274.  
  2275.     - System requester
  2276.     - File requester
  2277.     - Input requesters (STRING and LONGINT)
  2278.  
  2279. Visual Basic for Windows has had an influence upon me and led me to add these
  2280. to ACE since I have now come to expect them. You can get the most commonly 
  2281. needed requesters with a single line of ACE code!
  2282.  
  2283. If you are running Wb 2.x and above, ACE generates an ASL file requester.
  2284.  
  2285. For Wb 1.3 an ARP file requester is invoked for two simple reasons:
  2286.  
  2287.     - It is quite acceptable.
  2288.     - The arp.library is common on Wb 1.3 systems.
  2289.  
  2290. See MSGBOX, FILEBOX, INPUTBOX and INPUTBOX$ in ref.doc for more. The
  2291. SUBmods directory contains other requesters to enhance your programs,
  2292. eg. FontReq, EasyRequest.
  2293.  
  2294.     
  2295. Turtle Graphics
  2296. ---------------
  2297. You may be wondering one or more of the following:
  2298.  
  2299.     - what the heck is Turtle Graphics?
  2300.     - isn't that for kids?
  2301.     - why did he include THAT?
  2302.  
  2303.  
  2304.                                   - page 36 -
  2305.  
  2306. To answer the first question: Turtle Graphics (TG) originated as a subset of 
  2307. the language LOGO invented by Seymour Papert et al at MIT. LOGO was originally 
  2308. intended as a language for learning. Children are able to write simple programs
  2309. to draw shapes on the computer's screen or move a Turtle - a dome-shaped robot 
  2310. - on a sheet of paper on the floor, learning about geometry "by doing" and
  2311. having fun to boot. 
  2312.  
  2313. LOGO also has many Lisp-like qualities and so can be used as a language for 
  2314. AI work, although to my knowledge, it's not.
  2315.  
  2316. But I digress. Apart from the fun kids can have with TG, it's actually 
  2317. possible to construct quite complex shapes with it. Combined with recursion,
  2318. TG is a powerful tool. It is particularly useful in plotting many fractal
  2319. shapes (see snowflake.b, dragon.b).
  2320.  
  2321. Since the first LOGO, there have been many manifestations of TG. Turbo Pascal 
  2322. for the PC and the Mac have both had TG.
  2323.  
  2324. A few years ago, I  wrote a pure TG subset of LOGO which used the same syntax 
  2325. as the original language and allowed recursive procedures. I've also written 
  2326. TG functions in C. Both of these have been useful to me and I've often wished 
  2327. that BASIC came with TG built-in. Well, now one dialect does!
  2328.  
  2329. For some examples of the use of Turtle Graphics in ACE, see the following
  2330. programs:
  2331.  
  2332.     - tree.b
  2333.     - flower.b
  2334.     - boxit.b
  2335.     - torus.b
  2336.     - dragon.b
  2337.     - snowflake.b
  2338.     - bst.b
  2339.  
  2340. The above discussion should have answered the second question. As for 
  2341. the third, the answer is: because I wanted to!! :^)
  2342.  
  2343. Okay, enough philosophy. Here's the ACE stuff:
  2344.  
  2345. BACK n        - move turtle back by n.
  2346. FORWARD n    - move turtle forward by n.
  2347. HEADING     - return turtle's current heading in degrees (0..359).
  2348. HOME        - move turtle back to its home position.
  2349. PENDOWN        - put turtle's pen down. 
  2350. PENUP        - lift turtle's pen up.
  2351. SETHEADING degs - change turtle's heading to degs.
  2352. SETXY x,y    - change turtle's current x,y location.
  2353. TURN degs    - rotate turtle by degs.
  2354. TURNLEFT degs    - turn turtle left by degs.
  2355. TURNRIGHT degs  - turn turtle right by degs.
  2356. XCOR        - return turtle's current x-coordinate.
  2357. YCOR        - return turtle's current y-coordinate.
  2358.  
  2359. where:
  2360.     - n is pixels
  2361.     - degs is a signed short integer representing degrees with
  2362.       the turtle starting at a 270 degree orientation -- pointing up.
  2363.     - home is the turtle's x,y start location (0,0).
  2364.  
  2365. Note that the X:Y ratio can be modified thus:
  2366.  
  2367.  
  2368.                                   - page 37 -
  2369.  
  2370.     EXTERNAL SINGLE tg_xy_ratio
  2371.     tg_xy_ratio = 1.125    
  2372.  
  2373. but this should not be necessary (from v2.19) since ACE determines the
  2374. correct aspect ratio for each user-defined screen when it is opened. A 
  2375. hi-res, non-interlaced Workbench screen is assumed at startup however. 
  2376. The correct values for tg_xy_ratio are shown below:
  2377.  
  2378.     Screen mode            Aspect ratio    
  2379.     -----------            ------------
  2380.     Lo-res, non-interlaced        0.9375
  2381.     Hi-res, non-interlaced        1.875
  2382.     Lo-res, interlaced        0.46875
  2383.     Hi-res, interlaced        0.9375
  2384.     Hold and Modify (HAM)        0.9375
  2385.     Extra-Halfbrite            0.9375
  2386.  
  2387. Most LOGO environments use a coordinate system where 0,0 is at the center of
  2388. the screen and positions to the left and down of this origin are negative 
  2389. while those up and to the right are positive. ACE's TG system however, uses 
  2390. the Amiga's normal graphics coordinate system with 0,0 at the top left of 
  2391. the screen/window so as to maintain consistency with ACE's normal graphics 
  2392. commands and functions (eg: POINT, PSET, LINE, PAINT, CIRCLE, AREAFILL).
  2393.   
  2394. If a negative value is specified for the turnleft or turnright commands,
  2395. the turtle will be rotated in the opposite direction to that indicated by
  2396. the the command name. Note that there is also a TURN command.
  2397.  
  2398. When using ACE's TG system, it's best to think of an imaginary turtle (in LOGO
  2399. it's usually a small triangle on the screen) which rotates and moves according
  2400. to your whim. The turtle can either have its pen lowered or raised - and will
  2401. therefore draw or not - which is useful when you need to move in a relative 
  2402. fashion from one location to another without drawing anything.      
  2403.  
  2404. SetXY is like the graphics library Move() command and may need to be preceded 
  2405. by PENUP unless you want to draw a line as the turtle finds its new position.
  2406.  
  2407. To change the colour of the drawing pen, use the COLOR command.
  2408.  
  2409. That's probably enough about ACE's Turtle Graphics. Oh by the way, if you want
  2410. to know more about the origins and uses of Logo, read Papert's "Mindstorms"
  2411. and his recent book entitled "The Children's Machine: Rethinking School in the 
  2412. Age of the Computer". They make for interesting reading.
  2413.  
  2414. The archetypal book on TG however, is "Turtle Geometry" by Abelson and diSessa.
  2415.  
  2416. On a related note, I wrote a paper called "Turtle Graphics and J" which
  2417. appeared in the British APL Association's journal, Vector, Vol.12 No.3,
  2418. January 1996. J is a cool language of the functional variety and a modern
  2419. dialect of APL. These two are often unkindly referred to as read-only 
  2420. languages, although not entirely without justification. Here's an example
  2421. of J code:
  2422.  
  2423.     +/ % >: i.100
  2424.  
  2425. which says: "sum the reciprocals of the integers 1..100". Neat eh? The 
  2426. equivalent ACE code would be:
  2427.  
  2428.     Single i,sum
  2429.     For i=1 To 100
  2430.       sum = sum + 1/i
  2431.  
  2432.                                   - page 38 -
  2433.  
  2434.     Next i
  2435.  
  2436. Not nearly as pretty. :)
  2437.  
  2438. While I think of it, Sherry Turkle wrote a book called "The Second Self: 
  2439. Computers and the human spirit", which I recommend if you're at all 
  2440. interested in the psychological/social effects of computing.
  2441.  
  2442.  
  2443. Loading & displaying IFF pictures
  2444. ---------------------------------
  2445. IFF graphics files can now be loaded and displayed with ACE by using 
  2446. a few simple commands and functions.
  2447.  
  2448. The short example program prgs/gfx/iff.b demonstrates typical usage.
  2449.  
  2450. IFF READ uses the freeware ILBM.library but you don't need to have this
  2451. since it will be created by ACE automatically at run-time if need be. If
  2452. LIBS:ilbm.library is not found at run-time ACE will use the library's binary 
  2453. image - which is stored in db.lib - to create ram:ILBMtmp/ilbm.library. This
  2454. file and the directory ILBMtmp will be removed when the program exits. The
  2455. idea of using a binary image like this was Roland Acton's.
  2456.  
  2457. See ref.doc for details of the IFF commands and function.
  2458.  
  2459.  
  2460. Sound
  2461. -----
  2462. ACE provides you with similar functionality as AmigaBASIC for sound
  2463. generation. It also allows you to do some things that AmigaBASIC doesn't.
  2464.  
  2465. See prgs/sound/sound.b for an example of how to use ACE's sound facilities 
  2466. in general.
  2467.  
  2468. How many times have you wished that AmigaBASIC would let you produce
  2469. white noise easily like the good ol' C64 and Vic-20 did?
  2470.  
  2471. Well, you'll be pleased to know that ACE allows you to do this. All you 
  2472. have to do is allocate about 4000 or more bytes of Chip RAM (upwards of 
  2473. 4000 bytes yields better quality white noise), poke it with random values 
  2474. (between -128 and 127), call WAVE and you're set (see sound.b)!
  2475.  
  2476. Moreover, you can actually play sound samples (IFF or otherwise) in the
  2477. same way, using just the two commands WAVE and SOUND (see prgs/sound/play.b). 
  2478.  
  2479. As with AmigaBASIC, a sine waveform is the default, but through the WAVE
  2480. statement you can create any waveform you wish including sawtooth, triangle, 
  2481. square and random (white noise).
  2482.  
  2483. WAVE has the following syntaxes:
  2484.  
  2485.     WAVE voice,SIN
  2486. and    
  2487.     WAVE voice,waveform-address,byte-count
  2488.  
  2489. where waveform-address is the start of a block of memory where the waveform
  2490. resides (an area of ALLOC'd CHIP memory) and byte-count is the number of bytes 
  2491. in the waveform table.
  2492.  
  2493. The SOUND statement syntax is as follows:
  2494.  
  2495.  
  2496.                                   - page 39 -
  2497.  
  2498.     SOUND period,duration[,volume][,voice]
  2499.  
  2500. This is different to AmigaBASIC in a number of ways. First, in ACE you
  2501. specify the sampling period NOT the frequency. This was easier to implement
  2502. and still provides the same functionality, but if you want specific notes, 
  2503. you'll have to do the calculations yourself (see equations below).
  2504.  
  2505. Sampling period is inversely proportional to frequency, so a high sampling
  2506. rate corresponds to a low frequency and vice-versa. ACE allows you to
  2507. specify a sampling period in the range 124..32767.
  2508.  
  2509. The duration is a single-precision value as in AmigaBASIC but can range from 
  2510. 0..999 (instead of 0..77). This range is somewhat arbitrary, but gives plenty
  2511. of scope for large sound samples. This specifies the length of time that a 
  2512. tone should be played for. A duration of 18.2 corresponds to about 1 second. 
  2513.  
  2514. Volume defaults to 64 if not specified and can range from 0..64.
  2515.  
  2516. The voice can be in the range 0..3 - since there are 4 audio channels - 
  2517. with 0 & 3 corresponding to the left speaker and 1 & 2 to the right.
  2518. The default voice is 0.
  2519.  
  2520. At the moment, ACE's SOUND statement isn't very good when used to produce a 
  2521. series of short pulses, although this is somewhat dependent upon the waveform 
  2522. in use. In any case, more work needs to be done in this area to prevent 
  2523. "popping" between SOUND statements when the audio hardware is turned on and 
  2524. off in rapid sequence.
  2525.  
  2526. ACE sound is produced by programming the hardware directly. A future version
  2527. will utilise the audio device instead. Indeed, the SOUND statement in ACE 
  2528. may change in the future to be more in line with AmigaBASIC (see also "Future 
  2529. Versions").
  2530.  
  2531. Finally, here's some useful equations for use in conjunction with ACE's SOUND 
  2532. statement:
  2533.  
  2534.     samples/second to period:
  2535.     ------------------------
  2536.     period = 3579546 / samples-per-second
  2537.     
  2538.     musical note to period:
  2539.     ----------------------
  2540.     period = 3579546 / (length * frequency)
  2541.  
  2542.     where length is the size of the waveform table in bytes 
  2543.     (32 bytes for ACE's sine waveform) and frequency is the
  2544.     note itself (eg: middle C is 523.25 Hz).
  2545.  
  2546.     duration value for one waveform cycle:
  2547.     -------------------------------------
  2548.     duration = .279365 * period * length / 1E6 * 18.2
  2549.  
  2550.         
  2551. Event trapping
  2552. --------------
  2553. ACE provides for AmigaBASIC-style event trapping, with additions. The following 
  2554. event types are supported:
  2555.  
  2556.     BREAK     -  user break: ctrl-c.
  2557.     MOUSE     -  left mouse button press.
  2558.     TIMER(n)  -  cause a trap every n seconds.
  2559.  
  2560.                                   - page 40 -
  2561.  
  2562.     ERROR      -  I/O and other errors.
  2563.     MENU      -  menu selection.
  2564.     WINDOW      -  window event: close-gadget click. * 
  2565.     GADGET      -  user-defined gadget selection. *
  2566.  
  2567.     * Not supported by AmigaBASIC.
  2568.  
  2569. Event trapping in ACE works by checking for a given event at strategic points
  2570. in a program (before NEXT, WEND, GOTO, CALL, PRINT etc) and if an event is
  2571. detected, control is passed to a trap handling routine. Note that trapping here
  2572. does not refer to CPU traps (exceptions).
  2573.  
  2574. Even if your program expects to do nothing but trap events, you'll need a
  2575. loop like this:
  2576.  
  2577.     WHILE -1
  2578.       SLEEP      '..don't hog the CPU  [optional but nice] 
  2579.     WEND
  2580.  
  2581. if you wish to have any events handled by your program.
  2582.  
  2583. The specification for the trapping of an event can be via:
  2584.  
  2585.     ON <event> GOSUB | GOTO <label>|<line-number> (eg. ON BREAK GOTO quit)
  2586.     or
  2587.     ON <event> CALL <SUBname> (eg. ON BREAK CALL quit)
  2588.  
  2589. which indicates the routine/SUB to which control is to be passed when an event
  2590. is trapped. This is followed at some stage by:
  2591.  
  2592.     <event> ON  (eg. BREAK ON)  
  2593.  
  2594. which causes the compiled program from that point _until_ the trap handling 
  2595. routine, to contain hidden event trapping code.
  2596.  
  2597. Other commands are:
  2598.  
  2599.     <event> STOP
  2600.  
  2601. which disables trapping for the event until another <event> ON is issued, 
  2602. and:
  2603.  
  2604.     <event> OFF
  2605.  
  2606. which disables trapping for the event permanently.
  2607.  
  2608. Just so there is no misunderstanding, the latter two commands prevent the 
  2609. inclusion of event trapping code for a specific event in your program at the 
  2610. assembly source level. They do this from the point in an ACE program at 
  2611. which they are issued.
  2612.  
  2613. Here's a typical example:
  2614.  
  2615.     ON BREAK GOTO quit
  2616.     BREAK ON
  2617.  
  2618.     for i=1 to 1000000
  2619.      print i
  2620.     next
  2621.  
  2622.     quit:
  2623.  
  2624.                                   - page 41 -
  2625.  
  2626.       PRINT "**break!"
  2627.       STOP
  2628.  
  2629. In the case of subroutines, it is a good idea to put trap handlers at the end 
  2630. of a program, since once the handler for an event is found by the compiler, no 
  2631. more event trapping code is generated for that event even if there is code below 
  2632. the handing routine. In other words, the equivalent of an <event> OFF command is 
  2633. issued once the trap handling subroutine is found by the compiler.
  2634.  
  2635. If using a subprogram as an event handler, the SUB must either be defined or 
  2636. declared (using DECLARE SUB) before the appropriate ON <event> CALL <SUBname> 
  2637. statement. To avoid hidden recursive subprogram calls, a silent <event> OFF is 
  2638. issued when a SUB is found after an <event> ON directive, eg.
  2639.  
  2640.     DECLARE SUB foo
  2641.     .
  2642.     .
  2643.     ON BREAK CALL foo
  2644.     BREAK ON
  2645.     .
  2646.     .
  2647.     SUB foo
  2648.     .        <- ACE issues a silent BREAK OFF here
  2649.     .           since we don't want foo called recursively!
  2650.     END SUB
  2651.  
  2652. For a SUB to be an event handler, it must not have a parameter list. If it
  2653. does, ACE will generate a compile-time error. Also, if a return value is 
  2654. given to a SUB, it will be ignored.
  2655.  
  2656. Simultaneous trapping of several different events is possible and in general
  2657. works very well. The use of INKEY$ and ON BREAK together when a user-defined 
  2658. window is the current output window leads to some competition. You may simply 
  2659. need to hit ctrl-c a few times in this circumstance for a user break to be 
  2660. accepted.
  2661.  
  2662. If you wish to trap only one kind of event you should consider the use of 
  2663. WAITing (only for menus and gadgets currently - see MENU/GADGET WAIT).
  2664.  
  2665.  
  2666. Interprocess Communication
  2667. --------------------------
  2668. ACE provides a simple IPC mechanism centered around a set of MESSAGE
  2669. commands (see ref.doc for full details).
  2670.  
  2671. ACEports represent a blocking/non-blocking, named IPC mechanism.
  2672.  
  2673. Put another way, ACEports provide an synchronous/asynchronous, indirectly 
  2674. named message-passing mechanism (Bal & Grune, p 202-206).
  2675.  
  2676. The mechanism is based upon Exec message ports and provides a simple way
  2677. for concurrently running ACE programs to communicate across unique, safe
  2678. channels. Strings can be sent as messages to a particular message port,
  2679. the name of which must be known in advance.
  2680.  
  2681. Messages may be of any length (memory permitting) and are queued.
  2682.  
  2683. Probably the best way to find out how the MESSAGE commands are used
  2684. in ACE is to compile, run and study the programs in prgs/ACEports.
  2685.   
  2686. ARexx capabilities are also planned for ACE at some stage.
  2687.  
  2688.                                   - page 42 -
  2689.  
  2690.  
  2691.  
  2692. Error Handling
  2693. --------------
  2694. The compiler messages generated by ACE are often different to the ones in the
  2695. AmigaBASIC interpreter (and ACE doesn't beep at you with each error) but they
  2696. are usually fairly clear.
  2697.  
  2698. Syntactically incorrect programs can lead ACE to produce a bunch of spurious 
  2699. error messages. In such cases, it's best to ignore all but the first one or 
  2700. two, unless there are "clusters" of messages which are separated by periods 
  2701. of error-free compilation. In short, ACE makes no attempt to do error recovery
  2702. at compile-time.
  2703.  
  2704. If you leave out END IF, WEND, UNTIL, NEXT, END SUB, END STRUCT or END CASE, 
  2705. there will be a corresponding number of error messages at the end of the 
  2706. compile. If you leave off two WENDs, you'll get 2 "WHILE without WEND" error
  2707. messages.
  2708.  
  2709. ACE generally reports the first error in a line of code and ignores the rest 
  2710. of the "bad" line. A typical message consists of the line containing the error,
  2711. a carat ("^") marker, and the error message itself. More work still needs to 
  2712. be done on ACE's compile-time error handling, but it's bearable.
  2713.  
  2714. No error messages are issued by ACE programs at run-time. Generally, when a 
  2715. program runs into something it can't do, or an erroneous request - like
  2716. trying to open two files to the same file number or trying to open a library 
  2717. that doesn't exist - the program will either quit or just not have the desired 
  2718. effect. 
  2719.  
  2720. Note that while the ERR function and ON ERROR event trapping are supported,
  2721. only file I/O, serial I/O, IFF, IPC (MESSAGE) and window/screen open errors 
  2722. are currently reported via these mechanisms. See ref.doc for details.
  2723.  
  2724.  
  2725. Notes for assembly programmers
  2726. ------------------------------
  2727. I've tried to make the assembly source files that ACE produces as 
  2728. readable as possible by using meaningful data object names. See also
  2729. "Compiler options" re: the compiler's "-c" switch.
  2730.  
  2731. Linked library routines use data registers d0-d6 and address registers 
  2732. a0-a3, while d7 is used for array index calculations. Also, a4 and a5 are 
  2733. used as stack frame pointers for variables and parameters.
  2734.  
  2735. Most db.lib routines don't save and restore registers via the stack, but 
  2736. the use of registers is internally consistent (ie: all registers are up for 
  2737. grabs but interdependent routines are written in such a way so as not to 
  2738. conflict). External function calls in ACE programs now _do_ save and restore 
  2739. registers.
  2740.  
  2741. The use of linked libraries means that the size of all executables is
  2742. fairly large. But given that disk space and memory are cheap, I'd rather
  2743. this than the alternative of having every executable be dependent upon one
  2744. or more special shared libraries at run-time. However, I will try to reduce
  2745. the size of executables. Some improvement has been made with the current
  2746. revision. Kendall Sears has suggested the creation of smaller versions of 
  2747. db.lib and startup.lib for use with shell-based programs. I like this idea
  2748. and will hopefully implement it when I have time.
  2749.  
  2750. Due to BASIC's tendency to coerce data types so much for the programmer,
  2751.  
  2752.                                   - page 43 -
  2753.  
  2754. the resulting code can look a little nasty, and big increases in efficiency 
  2755. can be gained by careful combinations of data types in expressions.
  2756.  
  2757. Writing ACE has so far been a learning experience for me and if when I started
  2758. I knew what I know now, I would have done many things differently.
  2759.  
  2760. My original rationale for passing parameters via registers to ACE (and shared) 
  2761. library functions was to improve execution speed. However, since I call lots 
  2762. of other functions (eg: in ami.lib) which require their parameters to be on 
  2763. the stack, I would probably call ALL functions in this way if I did it again. 
  2764.  
  2765. Moreover, my desire for internal consistency led me to a rather odd method of 
  2766. passing parameters to SUBs. This allowed me to treat parameters in the same way
  2767. as variables which is all very nice, but it led to other problems, chief among
  2768. them being the need to use a Forbid()/Permit() pair when sending parameters to 
  2769. a SUB. This works fine however, so I'm taking the view that if it 'aint broke,
  2770. I probably shouldn't fix it. 
  2771.  
  2772.  
  2773. Limitations
  2774. -----------
  2775. 1. Undeclared variables do NOT get a default zero or NULL value, so don't
  2776. assume ANYTHING about the contents of an uninitialised variable, eg.
  2777.  
  2778.     PRINT X 
  2779.  
  2780. will yield garbage if X has not been given a value. The optional variable 
  2781. declarations provided in ACE are therefore worth using since they DO give
  2782. variables an initial zero or NULL value.
  2783.  
  2784. 2. The precision of exponentiation begins to falter with large numbers (where 
  2785. the exponent is around 23 or higher) because all exponentiation is currently 
  2786. done in single-precision. Use either long integer multiplication or ACE's SHL 
  2787. function for greater accuracy, where integers are applicable. For example, 
  2788. compare SHL(2,22) with INT(2^23).
  2789.  
  2790. 3. See the LONGINT(n) function for getting around the problem of extracting a
  2791. large integer value from a string.
  2792.  
  2793. 4. While strings can be defined to be longer (or shorter) than 1K, there
  2794. are some ACE commands and functions which still assume a 1K limit, namely: 
  2795. STRING$, SPACE$, LINE INPUT#, INPUT and SWAP.
  2796.  
  2797. 5. Strings and arrays which are local to a subprogram will be overwritten if
  2798. the SUB has recursive calls to itself. The same applies to string parameters. 
  2799. In all these cases a single static data item is being referenced.
  2800.    
  2801. 6. If you issue RETURN from within a FOR loop, the return address will *not* 
  2802. be the top item on the stack. Instead, FOR..NEXT loop data will be. A GURU will 
  2803. almost certainly result. It is probably better to use a while or repeat loop 
  2804. if you must RETURN from within a loop. See also EXIT FOR in ref.doc which
  2805. allows for the safe, early termination of FOR loops, although it's not perfect.
  2806.  
  2807. 7. A shared variable cannot be used as a FOR loop index in ACE. Any attempt to
  2808. do so will result in a compile-time error.
  2809.  
  2810. 8. IF..THEN NEXT will not have the desired effect (it's bad coding anyway).
  2811. NEXT must always appear on a line by itself or as part of a multi-statement. 
  2812.  
  2813. 9. ACE does not consider "=>" to be the same symbol as ">=". In fact, ACE 
  2814. doesn't recognise the former at all. The same is true of "=<".
  2815.  
  2816.                                   - page 44 -
  2817.  
  2818.  
  2819. 10. The compiler only responds to ctrl-c during the main compilation phase, 
  2820. and not during optimisation or when target code is being written.
  2821.  
  2822. 11. Don't mix the compiler's "b"/"w" option with BREAK/WINDOW event trapping, 
  2823. as they will conflict.
  2824.  
  2825.  
  2826. Known Bugs
  2827. ---------- 
  2828. If mathieeesingtrans.library is not present at runtime, the FFP SPPow()
  2829. function will be used for exponentiation. This will produce incorrect
  2830. results for a combination of a negative base and odd exponent. Only pre-2.0
  2831. systems should be affected by this however. SPPow() is otherwise less
  2832. accurate and apparently slower than its IEEE counterpart, which is used if
  2833. the IEEE library is present.
  2834.  
  2835. The SAY(n) *function* works under release 2.x but not under 1.3. Since the 
  2836. function uses no 2.x-specific code, this is puzzling. The SAY command works 
  2837. under both 1.3 and 2.x however.
  2838.  
  2839. Some fonts cause the INPUTBOX[$] display (string gadget) to be corrupted. 
  2840. Stick to topaz for this where possible. A future revision may use a 
  2841. GadTools or BOOPSI requester (for 2.x/3.x machines).
  2842.  
  2843. A68K sometimes complains about string literal definitions produced by ACE 
  2844. if they are much longer than a single line.
  2845.   
  2846.  
  2847. Future versions
  2848. ---------------
  2849. Double-precision floating-point math is high on the agenda, as is some
  2850. kind of LIST datatype based upon Exec lists.
  2851.  
  2852. More graphics (eg: GET,PUT) commands and functions are planned and I also 
  2853. intend to fix any remaining differences between ACE and AmigaBASIC in this 
  2854. area. 
  2855.  
  2856. AGA screen modes will happen sometime.
  2857.  
  2858. I may provide support for sprites at some stage. 
  2859.  
  2860. Thus far, I've taken the approach of implementing what I most often use 
  2861. and what I have often wished for in a language.
  2862.  
  2863. In recent times I have been impressed by three things in the programming 
  2864. world: the rise of Object-Oriented Programming (OOP), Resources (as found
  2865. on the Macintosh and MS-Windows), Visual BASIC for Windows, and functional
  2866. languages such as J and Scheme.
  2867.  
  2868. The idea of resources (pioneered by the Macintosh resource fork and ResEdit) 
  2869. is a powerful one and Microsoft have picked up on this in Windows 3.x/95. 
  2870. I wish that Amiga executables had resources as standard, but alas, no.
  2871.  
  2872. I am trying to add more "visual" stuff to ACE, hence: gadgets, menus,
  2873. requesters, AIDE. You can expect to see more "visualising" of ACE as time
  2874. goes by. ReqEd, a GUI designer written in ACE, for ACE, is one example of 
  2875. this. To make ACE like Visual BASIC would take a major redesign, but I can 
  2876. at least try to take advantage of some of its features.
  2877.  
  2878.  
  2879.  
  2880.                                   - page 45 -
  2881.  
  2882. A note to PD libraries and reviewers
  2883. ------------------------------------
  2884. First, to those magazines who have reviewed ACE so far, let me say a big 
  2885. THANK YOU. Good publicity is always appreciated as is acknowledgement of 
  2886. the time I've spent on ACE.
  2887.    
  2888. I'd appreciate it if you would check with me (if possible) to ensure you
  2889. have the latest version of ACE before including it in your library or
  2890. reviewing it for a magazine. If you don't have e-mail access, I don't
  2891. expect you to do this (snail-mail is a pain isn't it!?).
  2892.  
  2893. Lastly, the wider ACE travels the happier I am, so I'm pleased to see
  2894. ACE turning up in the odd PD library. Please note however that I don't
  2895. wish people to profit financially from the distribution of ACE. You may
  2896. charge a fee which covers the cost of the disk and the copying thereof,
  2897. but no more.
  2898.  
  2899.  
  2900. Disclaimer
  2901. ----------
  2902. Although every care has been taken in the development and testing of the 
  2903. compiler and its libraries, the author will not be held liable for damages 
  2904. caused either directly or indirectly as a result of the use of ACE.
  2905.  
  2906.  
  2907. References
  2908. ----------
  2909. The following references have been used in developing ACE:
  2910.  
  2911. +----------------------------------------------------------------------------+
  2912. | "Amiga BASIC" (manual), 1985, Commodore-Amiga Inc. and Microsoft Inc.      |
  2913. |                                         |
  2914. | "Amiga ROM Kernel Reference Manual: Libraries", 1992, Commodore-Amiga         |
  2915. |                                         |
  2916. | "Amiga ROM Kernel Reference Manual: Devices", 1991, Commodore-Amiga         |
  2917. |                                         |
  2918. | Anderson & Thompson, 1990, "Mapping the Amiga", COMPUTE! Publications Inc. |
  2919. |                                         |
  2920. | Bal & Grune, 1994, "Programming Language Essentials", Addison-Wesley         |
  2921. |                                         |
  2922. | Bleek, Jenrich & Schulz, 1989, "Amiga C for Advanced Programmers", Abacus  |
  2923. |                                         |
  2924. | Choi, 1990, "Advanced Programming Techniques", University of Tasmania      |
  2925. |                                         |
  2926. | Dittrich, 1989, "Amiga Machine Language", Abacus                 |
  2927. +----------------------------------------------------------------------------+
  2928.  
  2929. This is by no means an exhaustive list, but it is representative.
  2930.  
  2931. Despite its not infrequent errors, "Mapping the Amiga" remains an excellent 
  2932. resource. I have also often referenced "Advanced Amiga C programming". 
  2933.  
  2934. Naturally, the two RKM volumes listed above and the "Amiga BASIC" manual are 
  2935. used regularly as well.
  2936.   
  2937. Although not listed, Commodore's Autodocs for the Amiga (supplied with the
  2938. Native Developer Kit) are also constantly used.
  2939.  
  2940. Young Choi's Advanced Programming notes in many ways provided the impetus
  2941. for the development of ACE. They were used in a compiler construction course
  2942. I took as an undergraduate. I thank Young for introducing me to the joys
  2943.  
  2944.                                   - page 46 -
  2945.  
  2946. of compiler writing, although I know he didn't intend me to spend *all* my
  2947. time writing programming language translators of one kind or another. :-)
  2948.  
  2949. Including the Pascal Minus compiler I wrote for that course, and the PC BASIC 
  2950. interpreter I wrote during the same period, I've since written a version of
  2951. Logo (turtle graphics subset), a Forth interpreter, and ACE, and other 
  2952. assorted compilers/interpreters.
  2953.  
  2954.  
  2955. Contacting the author
  2956. ---------------------
  2957.  
  2958. I am contactable via e-mail on: the Internet, Compuserve and Discovery 40/80.
  2959. Of course, there is also the telephone and snail-mail.
  2960.  
  2961. +-----------------------------------------------+
  2962. |     Internet:    ace@vision.net.au            |
  2963. |        D.Benn@appcomp.utas.edu.au     |
  2964. |                        |
  2965. |   Compuserve: 100033,605                  |
  2966. |                        |
  2967. |      Phone: (03) 6326 1461 [home]              |
  2968. |          (03) 6344 4432 [work]              |
  2969. |                              |
  2970. |    Address: 9 Mayne Street, Invermay,     |               
  2971. |          Tasmania, Australia, 7248              |
  2972. +-----------------------------------------------+
  2973.  
  2974.  
  2975. CyberspACE: FTP, mailing list, WWW
  2976. ----------------------------------
  2977. In February 1994 I was allowed to establish a listserver-based discussion 
  2978. list for ACE on one of the Unix boxes at my previous place of work, the 
  2979. University of Tasmania at Launceston's Department of Applied Computing 
  2980. and Mathematics.
  2981.  
  2982. The purpose of the list is to allow for the dissemination of information 
  2983. about ACE, the discussion of bugs, problems, solutions and ACE programming 
  2984. in general.
  2985.  
  2986. In September 1996, the ACE list moved to one of the BSDi Unix boxes at my
  2987. place of work, Vision Internet Services.
  2988.  
  2989. To subscribe to the list send (Internet) e-mail to:
  2990.  
  2991.     majordom@vision.net.au
  2992.  
  2993. The subject-line of the message is unimportant, but the first line of the 
  2994. message must be of the following format:
  2995.  
  2996.     subscribe acebasic
  2997.  
  2998. The listserver will send you a welcome message and information about how 
  2999. to use the list.
  3000.  
  3001. At about the same time as the ACE list was established, an anonymous FTP
  3002. server was set up at:
  3003.  
  3004.     ftp.appcomp.utas.edu.au
  3005.  
  3006. ACE-related files are stored in the directory:
  3007.  
  3008.                                   - page 47 -
  3009.  
  3010.  
  3011.     /pub/ACE
  3012.  
  3013. The ACE FTP site is also maintained at:
  3014.  
  3015.     ftp.vision.net.au
  3016. in:
  3017.     /pub/ACE
  3018.  
  3019. and should be considered to be the primary site now. There are lots of
  3020. extra goodies to be found on the FTP sites, including extra example
  3021. programs and more utilities.
  3022.  
  3023. There is also an ACE home page on the World Wide Web, the URL of which
  3024. is:
  3025.     http://www.vision.net.au/~ace/
  3026.  
  3027. A vote of thanks goes to my boss, Roy Austen for allowing me to use 
  3028. Vision Internet Services facilities for ACE activities.
  3029.  
  3030. I'd like to thank Tony Gray (Technical Services Manager) for maintaining 
  3031. the first listserver and Young Choi (Head of Department) for allowing me 
  3032. to use the department's facilities.
  3033.  
  3034. You should also check out dev/basic on Aminet sites, and the AmigaTech
  3035. forum on CompuServe for ACE related material.
  3036.   
  3037.  
  3038. Final word
  3039. ----------
  3040. Let me offer my thanks to Charlie Gibbs for his reliable assembler and to 
  3041. the Software Distillery for Blink. Without these excellent programs, far 
  3042. fewer Amiga compilers would have seen the light of day, including ACE. 
  3043.  
  3044. More recently, ACE users have also been able to make use of PhxAss and PhxLnk,
  3045. so Frank Willie and Volker Barthelmann deserve a round of applause too.
  3046.  
  3047. Sozobon C (ZC) has always been a reliable workhorse for me, so a vote of
  3048. thanks goes to Sozobon as well. Isn't freeware great?
  3049.  
  3050. I'd like to thank those people who have tested ACE so far. They are too 
  3051. numerous to mention here, but special thanks goes to Addison Laurent, 
  3052. Alan-Peyton Smith, Peter Zielinski, John Stiwinter and the members of
  3053. the ACE mailing list (see above).
  3054.  
  3055. These guys have given ACE a good workout on a variety of platforms ranging 
  3056. from an A1000 running Wb 1.3 to 68030 machines running Wb 3.0.
  3057.  
  3058. I'd especially like to thank Michael Zielinski for discovering a particularly 
  3059. serious bug which prevented branches of greater than 32K in length prior
  3060. to v1.02. Also, Enforcer hits reported by him started me on a trail which
  3061. led to a nasty string-related bug (see entry for 13/4/93 in docs/history).
  3062.  
  3063. Jarto 'Robin' Tarp pointed out how inefficient my first implementation
  3064. of INSTR was. It's considerably faster now (since v1.02).
  3065.  
  3066. Let me stress that any remaining bugs in ACE are entirely my fault.
  3067.  
  3068. Others have given me a great deal of encouragement and made useful comments 
  3069. The sense of community on the virtual world of the Net is a refreshing change 
  3070. from the general weirdness of the "real" world.
  3071.  
  3072.                                   - page 48 -
  3073.  
  3074.  
  3075. I'd like to thank John Stiwinter for all his excellent work in putting
  3076. together the AmigaGuide documents for ACE. Having ACE's reference material
  3077. in this format has enhanced its utility enormously. He has also done 
  3078. other stuff in the background for which I am grateful.
  3079.  
  3080. Of late, Nils Sjoholm has been doing a great deal of work for the ACE
  3081. project. He single-handledly converted all the C header files into a 
  3082. form which could be used by ACE not to mention writing numerous example
  3083. programs for shared libraries such as ReqTools and Triton.
  3084.  
  3085. This, in conjunction with Escom giving me permission to distribute the
  3086. bmaps has given a big boost to the project and makes ACE a serious 
  3087. system-level programming tool. I'd like to thank Dr Peter Kittel for 
  3088. giving me permission to make the bmaps available.
  3089.  
  3090. More recently still, Herbert Breuer has taken over work on AIDE, Daniel
  3091. Seifert has contributed NAP (New ACE Preprocessor), and Manuel Andre has
  3092. written a SuperOptimiser which makes ACE's -O switch pale by comparison.
  3093.  
  3094. Many of the subscribers to the ACE mailing list (see above section)
  3095. have given me plenty to think about, plenty of bug reports and plenty of 
  3096. support. In particular, thanks goes to Kendall Sears for keeping me on my 
  3097. toes and for providing expert technical knowledge of the Amiga's operating
  3098. system.
  3099.  
  3100. Jeff Harris, Chuck Kenney, Dan Oberlin, Sean Miller and Kenneth Brill,  
  3101. Bill Maddock, and John Mason have all contributed to ACE in their own ways. 
  3102. Thanks guys! Also, to all those who have e-mailed or written to me, thanks. 
  3103. You know who you are!
  3104.  
  3105. I'd also like to thank my wife Karen, for her encouragement and support, 
  3106. for putting up with the number of hours I spend at the computer, and
  3107. just for tolerating me generally. :-)  IFS is her favourite program so 
  3108. it's dedicated to her (try the "Green Fern").
  3109.  
  3110. Despite ACE's problems (see "Limitations" and "Known Bugs") it is proving
  3111. to be a useful tool for me, and if others can derive benefit from it, well, 
  3112. that's great. ACE is gradually coming to support the features I and others 
  3113. want it to, but there's still plenty of work to do.
  3114.  
  3115. The provision of support for shared library functions, external functions, 
  3116. machine code routines, inline assembly code, include files and SUBmods 
  3117. should go a long way towards making up for ACE's intrinsic shortcomings.
  3118.   
  3119. I hope you enjoy ACE and find it useful. I'm learning a great deal by 
  3120. developing it and having a lot of fun in the process. If you'd like to see
  3121. ACE developed further, feel free to send me a donation, but I certainly don't
  3122. expect you to do so. ACE development will continue, with or without such 
  3123. incentives. :)
  3124.  
  3125. What I DO want is feedback. If you have any problems, requests, queries or 
  3126. suggestions, I want to hear from you and I'd like to hear about interesting 
  3127. programs you've written with ACE. Send me the source code if you like. I'm
  3128. always on the lookout for good example programs to include in the ACE archive.
  3129.  
  3130. Remember that ACE is FreeWare, so redirect flames to NIL:  :^).
  3131.  
  3132. Happy programming!
  3133.  
  3134. Regards, David Benn
  3135.  
  3136.                                   - page 49 -
  3137.  
  3138. 12th September 1996
  3139.  
  3140.  
  3141.  
  3142.  
  3143.  
  3144.  
  3145.  
  3146.  
  3147.  
  3148.  
  3149.  
  3150.  
  3151.  
  3152.  
  3153.  
  3154.  
  3155.  
  3156.  
  3157.  
  3158.  
  3159.  
  3160.  
  3161.  
  3162.  
  3163.  
  3164.  
  3165.  
  3166.  
  3167.  
  3168.  
  3169.  
  3170.  
  3171.  
  3172.  
  3173.  
  3174.  
  3175.  
  3176.  
  3177.  
  3178.  
  3179.  
  3180.  
  3181.  
  3182.  
  3183.  
  3184.  
  3185.  
  3186.  
  3187.  
  3188.  
  3189.  
  3190.  
  3191.  
  3192.  
  3193.  
  3194.  
  3195.  
  3196.  
  3197.  
  3198.  
  3199.  
  3200.                                   - page 50 -
  3201.