home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 2 / FFMCD02.bin / useful / dist / dev / lang / ace / docs / ace.doc < prev    next >
Encoding:
Text File  |  1993-07-10  |  71.5 KB  |  1,888 lines

  1.  
  2.                 ---------
  3.                 ACE v1.1a        
  4.                 ---------
  5.  
  6.       CONTENTS                       LINE
  7.       --------                        ----
  8.  
  9.   (i)   Getting started
  10.  
  11.     What is ACE?..................................53
  12.     Who should use it?...........................124
  13.     Installation.................................164
  14.     Using the compiler...........................199
  15.     Compiler options.............................233
  16.     The pre-processor and #include files.........289
  17.     Running ACE programs.........................327
  18.     About the example programs...................337
  19.  
  20.  (ii)   A hitch-hiker's guide to ACE 
  21.  
  22.     General comments.............................364
  23.     Data types, expressions, constants...........399
  24.     Precedence of operators......................472
  25.     Identifiers..................................501
  26.     Indirection operators........................599
  27.     Structures...................................634
  28.     Subprograms..................................726
  29.     Shared library function calls................940
  30.     Machine code calls..........................1034
  31.     External references.........................1103
  32.     Program arguments...........................1143
  33.     Windows.....................................1183
  34.     Screens.....................................1224
  35.     Files.......................................1263
  36.     Sound.......................................1354
  37.     Turtle Graphics.............................1443
  38.     Event trapping..............................1542
  39.     Error handling..............................1609
  40.  
  41. (iii)   Stop bits
  42.  
  43.     Notes for assembly programmers..............1637
  44.     Limitations.................................1677
  45.     Known bugs..................................1726
  46.     Future versions.............................1750
  47.     Disclaimer..................................1767
  48.     References..................................1774
  49.     Final word..................................1816
  50.  
  51.         ================================================
  52.  
  53. What is ACE?
  54. ------------
  55.  AmigaBASIC Compiler with Extras?
  56.  A Creative Environment? 
  57.  A Compiler for Everyone?
  58.  Automatic Computing Engine (ala Alan Turing)?
  59.  Dr Who's companion?  
  60.  
  61. Seriously...
  62.  
  63. ACE is a freely distributable, recursive descent, peephole-optimising Amiga 
  64. BASIC compiler which produces A68K-compatible assembly source code. ACE runs 
  65. under Wb 1.3, 2.04 and up, as do the executables it produces. ACE will run
  66. on 512K machines, but at least 1M is required for medium to large programs.
  67.  
  68. ACE is both a subset and a superset of AmigaBASIC which, in most cases 
  69. produces very similar results to the latter. Any differences between the 
  70. two are discussed in this document and the command and function reference.
  71.  
  72. The following files constitute a complete ACE archive:
  73.  
  74.         executables
  75.         -----------      
  76.     app        - A simple pre-processor.
  77.     ace        - The BASIC compiler.
  78.     a68k        - Charlie Gibbs' 68000 assembler.
  79.     blink        - The Software Distillery's linker.
  80.     bas        - A shell script which automates
  81.                 the compile-assemble-link process.
  82.      documents
  83.     ---------        
  84.     ace.doc        - This document.
  85.     ref.doc     - A command and function reference for ACE.
  86.     history        - A history of ACE's development.
  87.     a68k.doc    - Documentation for the assembler.
  88.     blink.doc    - Documentation for the linker.
  89.  
  90.     scanned libraries
  91.     -----------------
  92.     ami.lib        - A freely distributable version of amiga.lib.
  93.     startup.lib    - A library of routines needed at start/end of 
  94.               an ACE program run (eg: opening libraries).
  95.     db.lib        - A library of assorted routines used by ACE
  96.               programs.
  97.  
  98.     other stuff
  99.     -----------
  100.     includes    - Some useful ACE include files. 
  101.     icons        - ACE tool and document icons.
  102.     examples    - A selection of example programs used during 
  103.               testing which demonstrate ACE's capabilities.
  104.      
  105. ACE programs do NOT require any special run-time shared libraries, so the 
  106. executables which the compiler produces (via the assembler and linker)
  107. are completely portable, requiring only the standard Amiga shared libraries 
  108. in your libs directory. The three ".lib" files mentioned above are scanned 
  109. libraries, so code from these is incorporated at link time.
  110.  
  111. ACE is written in Sozobon C (ZC v1.01), while db.lib and startup.lib are 
  112. written in assembler (~75%) and C.
  113.  
  114. A68K and Blink are used to assemble and link the code produced by ACE.
  115. The MicroEmacs (v1.3 & v2.1) editor has been used throughout every stage
  116. of ACE's development. It works for me.
  117.  
  118. The complete ACE package may be freely distributed but I retain the copyright 
  119. to the C and assembly source code (not yet included in the archive). No profit
  120. may be made from such distribution but a minimal fee of no more than $5.00 
  121. (Australian) may be charged to cover the cost of a disk based distribution. 
  122.  
  123.  
  124. Who should use it?
  125. ------------------
  126. ACE is intended for anyone who already knows BASIC and wants one or more of
  127. the following:
  128.  
  129.     - Faster program execution.
  130.     - Independence from the BASIC interpreter, ie: standalone programs 
  131.       which are runnable from the CLI/Shell and Workbench.
  132.     - Extra commands, functions and features: turtle graphics,
  133.       command-line and Workbench arguments, recursion, SUBs with 
  134.       return values, external references, defined constants, structures, 
  135.       include files, better WAVE and SAY features, among other things.
  136.  
  137. Maybe you don't wish to learn another high-level language, or perhaps you 
  138. already know C or assembler but prefer to use BASIC for some tasks while 
  139. still having the power of a compiled language.
  140.  
  141. ACE is a general purpose language so in theory at least, it can be applied
  142. to any programming task you like. In practice however, I find ACE to be most
  143. useful for writing small to medium sized programs where speed is important 
  144. but so is ease of programming.
  145.  
  146. ACE is also a useful prototyping language. It allows you to get something 
  147. up and running quickly to test an idea. You may later decide to re-code in 
  148. C or assembler, or you may just add some polish to the exisiting ACE program.
  149.  
  150. Once again, in practice, ACE is not intended for writing AMOS-like demos/games, 
  151. nor - at this stage - is it really suitable for producing slick commercial 
  152. applications. As ACE improves, the latter will no longer be true I hope.
  153.  
  154. I have written the following kinds of programs with ACE:
  155.  
  156.     - Shell utilities.
  157.     - Fractal graphics programs.
  158.     - Simple neural networks.
  159.     - A sound sample player.
  160.     - Astronomy programs, eg: galaxy collision simulator,
  161.       planetary ephemeride calculator, Yale Bright Star Catalog plotter.
  162.         
  163.  
  164. Installation
  165. ------------
  166. Starting with the supplied archive, you just need to "unarc" it thus:
  167.  
  168.     lha -a x ace
  169.  
  170. after cd'ing to a blank ACE disk or hard disk directory you've created. 
  171.  
  172. The appropriate directories (bin,lib,include,docs,prgs,run,icons) and files 
  173. will be extracted from the archive.
  174.  
  175. Then add the following lines to your user-startup or startup-sequence script:
  176.  
  177.     assign ACE: <volume or directory name>
  178.     path ACE:bin add
  179.  
  180. where <volume or directory name> is the name of the disk or directory where
  181. the ACE files now reside.
  182.  
  183. In addition, you need to add three more statements to your startup-sequence
  184. or user-startup script:
  185.  
  186.     assign ACElib:        - bas uses this for linked libraries.
  187.     assign ACEbmaps:    - ace uses this for .bmap files.
  188.     assign ACEinclude:     - app uses this for include files.
  189.  
  190. Typically, they will be something like this:
  191.  
  192.     assign ACElib:        ACE:lib
  193.     assign ACEbmaps:   ACE:bmaps/2.0
  194.     assign ACEinclude: ACE:include
  195.  
  196. That's it! Now reboot your Amiga and you're away.
  197.  
  198.  
  199. Using the compiler
  200. ------------------
  201. ACE currently expects all BASIC source files to have a ".b" extension.
  202.  
  203. If you wrote a program called foo.b, you would invoke the compiler thus:
  204.  
  205.     ace foo
  206.  
  207. which would produce foo.s, an A68K-compatible assembly source (text) file which 
  208. can be inspected and/or hand-optimised if so desired.
  209.  
  210. If you wanted to pre-process, compile, assemble and link foo.b, you would type:
  211.  
  212.     bas foo
  213.  
  214. which would yield foo (the executable).
  215.  
  216. The bas script sets the stack to 40000 bytes. Before running ACE by itself,
  217. you will need to set this. A minimum stack size seems to be around 5000
  218. for many ACE compilations, but I recommend 20000 to 40000 bytes to be safe.
  219.  
  220. If your Amiga GURUs or hangs during a compile or produces garbage in the shell,
  221. you can be pretty sure that the stack is too small. However with a stack of 
  222. 40000 I've had no problems.
  223.  
  224. You can either create a BASIC source file using an editor or in the AmigaBASIC 
  225. environment. If you want to compile a program developed with the interpreter,
  226. just save the program in ASCII format thus:
  227.  
  228.     save "foo.b",a
  229.  
  230. ACE will ONLY compile ASCII source files, not AmigaBASIC's compressed format.
  231.  
  232.  
  233. Compiler options
  234. ----------------
  235. The full command line syntax for ACE is:
  236.  
  237.     ace [-bcEilO] <sourcefile>
  238.  
  239. which indicates that there are currently three optional compiler switches. 
  240.  
  241. The switches can appear in any combination (ie: -bi, -clb, -O, -ObE) but are 
  242. case sensitive (eg: -b is NOT the same as -B).
  243.  
  244. The -b switch tells the compiler to include code to check for ctrl-c breaks 
  245. by the user. The inclusion of this code can result in noticeably larger
  246. assembly source files, but execution speed doesn't seem to suffer appreciably.
  247. When a ctrl-c is detected, the program will clean up and exit, but user-created
  248. windows will remain open. The use of ON BREAK can get around this though (see
  249. the "Event Trapping" section).
  250.  
  251. The -c switch includes each line of ACE source code as a comment in the
  252. final assembly source file. This was requested as a debugging aid. Warning:
  253. the presence of such comments interferes with peephole optimisation. Also be
  254. aware that ACE sometimes includes extra code apart from that which you would 
  255. expect purely on the basis of the source code, so the comments can appear to 
  256. be in strange places.
  257.  
  258. The -E switch creates a file in the current directory called ace.err which
  259. contains all compiler error messages at the end of an ACE run. Error messages
  260. will still be displayed during compilation.
  261.  
  262. The -i switch tells ACE to make an icon for the executable resulting from 
  263. the compilation. The file "ACE:icons/exe.info" must exist as it is used as
  264. the source file for the icon. This allows you to use an icon of your own if
  265. you so wish.
  266.  
  267. The -l switch causes the compiler to display each line of ACE source code 
  268. before it is compiled.
  269.  
  270. The -O switch causes the assembly source code produced by ACE to be optimised.
  271. At present, simple peephole optimisation is carried out. Assembly code size
  272. reductions of around 5% to 10% are usual. Speed improvements vary, depending
  273. upon the program, however I recommend the use of the -O switch for all programs
  274. where speed is the least bit important. As time goes by, ACE's optimiser will 
  275. be improved.
  276.  
  277. The syntax for the bas script is:
  278.  
  279.     bas [-bcEilO] <sourcefile> [<objectfile>]
  280.  
  281. where <sourcefile> is the program to be compiled (without the .b extension)
  282. as with the ACE syntax, and <objectfile> is a C or assembly module which has
  283. been (compiled and) assembled to produce an object file. This is used when
  284. you are calling an external function. The <objectfile> is linked with the
  285. output of ACE and A68K along with db.lib, startup.lib and ami.lib. For more
  286. about external functions, see the section "External references".
  287.  
  288.  
  289. The pre-processor and #include files
  290. ------------------------------------
  291. The ACE pre-processor: APP, is modest when compared with the C pre-processor.
  292.  
  293. Its main function thus far is for the C-style inclusion of files with the
  294. #include directive. As in C, #include "filename" looks for the file as
  295. specified, while #include <filename> looks for the file in a local include 
  296. directory (see "Installing ACE"). A file will only ever be included once.
  297.  
  298. The #include directive can be used in included files, but since file inclusion 
  299. is recursive, watch your stack size (20000 to 40000 bytes should be plenty).
  300.  
  301. APP also handles single-line comments (lines starting with "'") and block
  302. comments (starting with "{" and ending with "}"). This is partly to allow
  303. #include commands to be commented out and also to make less work for the 
  304. compiler. However, the compiler does still handle comments in case the pre-
  305. processor isn't invoked. APP does not handle REM since this is a BASIC 
  306. statement.
  307.  
  308. The syntax for APP is: app <source> <dest> and APP commands are case 
  309. insensitive.
  310.  
  311. The bas script uses APP by first pre-processing an ACE source file to RAM:t.
  312.  
  313. Use of #include can have the effect of adding lines to the pre-processed ACE 
  314. source file in the ram:t directory. Line numbers referred to in compilation
  315. errors pertain to this file. Comments don't change the line numbering.
  316.  
  317. APP will be improved and added to as time goes by. 
  318.  
  319. ACE include files have two purposes. First, like C they can be used to include
  320. constants and structure definitions etc. Second, as with files like WBarg.h and
  321. req.h, ACE include files may contain subprogram definitions and although this
  322. is quite possible in C, it seems to be less often done under the guise of .h
  323. files. I have arbitrarily chosen to append all include files with .h but there
  324. is no reason why this need be so. Purists will probably be aghast at this.
  325.  
  326.   
  327. Running ACE programs
  328. --------------------
  329. ACE programs can be run from either a shell/CLI or Workbench. In the latter
  330. case a tool icon must be created for the executable. One has been provided
  331. with the archive in the icons directory (exe.info). 
  332.  
  333. As far as I can tell, ACE programs are pure and so can be made resident once 
  334. the pure bit is set with the protect command. I've had no problems so far.
  335.  
  336.  
  337. About the example programs
  338. --------------------------
  339. I have written a number of programs which illustrate most of the capabilities
  340. of ACE up to this point and you should find these with the ACE archive.
  341.  
  342. Several programs are related to chaos theory and fractals, which is a pet 
  343. interest of mine (and thousands of other programmers :). The other programs 
  344. are an assorted bunch, designed to demonstrate the features supported by ACE. 
  345.  
  346. Some are optimised (at the source level) and some are not. You'll find that 
  347. using integer variables can often result in quite dramatic improvements
  348. in program execution speed (eg: try replacing op% with op and k% with k in 
  349. ifs.b and you'll see what I mean). However, this depends a bit on the data
  350. types *expected* by various routines, so you'll have to experiment a bit.  
  351.  
  352. There are several examples which demonstrate the use of recursive 
  353. subprograms in ACE (eg: fact.b). See the section on subprograms below.
  354.  
  355. Another area of interest for me is neural networks and you'll find a 
  356. program called hopnet.b, which shows graphically how a simple Hopfield 
  357. network changes under various conditions. This program uses many of ACE's
  358. features and so is a good test of the compiler.
  359.  
  360. Other programs include tic-tac-toe (ttt.b), a talking clock (tclock.b), 
  361. a sound sample player (play.b) and a Tiny BASIC interpreter.
  362.  
  363.  
  364. General comments
  365. ----------------
  366. I made a decision very early on in the project to allow standard I/O (to shell
  367. or CLI) because this feature was lacking in other BASIC compilers I'd seen
  368. (except HiSoft's). ACE's standard output routines expect the default topaz 8 
  369. font and the use of other fonts may have weird effects upon your display. 
  370.  
  371. The execution speed of most programs (especially with graphics, eg: ifs.b) is 
  372. _fast_ compared to interpreted AmigaBASIC.
  373.   
  374. No error messages are given at run-time yet, nor is there any stack overflow 
  375. or array bounds checking. This means that executables are fast on the whole, 
  376. but a rogue program will very likely stomp all over memory and invoke 
  377. the GURU (or its Wb 2.04 equivalent). Still, the nature of BASIC doesn't 
  378. encourage rogue programs.
  379.  
  380. Labels are supported and can be used with GOSUB and GOTO. Line numbers are 
  381. now supported, but are only necessary for old BASIC programs. Also, ACE's 
  382. rich assortment of control constructs makes the use of GOTO rarely necessary.
  383.  
  384. Available control constructs are: WHILE..WEND, REPEAT..UNTIL, IF..THEN..ELSE,
  385. IF..THEN..ELSE..END IF, CASE..END CASE, ON..GOTO, ON..GOSUB, SUB..END SUB and 
  386. GOSUB..RETURN.
  387.  
  388. Apart from single line comments with REM and ' ACE allows block comments with
  389. "{" and "}" ala Pascal. For example:
  390.  
  391.  { comments can span more than 
  392.    one line like this }
  393.  
  394. Multi-statements are also supported by ACE, eg:
  395.  
  396.  x$="hello":y$="there":say translate$(x$+" "+y$)
  397.    
  398.  
  399. Data types, expressions and constants
  400. ------------------------------------- 
  401. The following data types are currently supported:
  402.  
  403.     - signed short integers (2 bytes)
  404.     - signed long integers  (4 bytes)
  405.     - single precision: Motorola fast floating point (4 bytes)
  406.     - strings (1024 bytes including ASCII 0 end-of-string marker)
  407.  
  408. Exponential and fixed-point formats are now recognised by all ACE functions
  409. and in program text for single-precision numbers.
  410.  
  411. Expression parsing is the same as for AmigaBASIC, as is the precedence of 
  412. operators. Evaluation of _all_ expressions proceeds from left to right.
  413. This includes exponentiation, so 2^3^2 will be evaluated as (2^3)^2.
  414.  
  415. In addition, due to the higher precedence of exponentiation over unary 
  416. negation and the way ACE's recursive descent parser works, 4^(-2) is okay, 
  417. but 4^-2 isn't. This is actually better than AmigaBASIC which doesn't even 
  418. allow the former syntax.
  419.  
  420. ACE supports full 32-bit and single-precision floating point math:
  421.  
  422.     addition, subtraction, multiplication:
  423.         
  424.         - 16 bit integer
  425.         - 32 bit integer
  426.         - single precision 
  427.  
  428.     division & modulo arithmetic:
  429.  
  430.         - 32 bit integer
  431.         - single precision
  432.  
  433. Increment and decrement operators are provided in ACE in the following form:
  434.  
  435.     ++<variable> OR --<variable>
  436.  
  437. The value of the simple or external variable is incremented or decremented by 1.
  438.  
  439. Notice that ++ and -- are pre-increment & pre-decrement operators ONLY. Those 
  440. familiar with C will recognise these operators and their utility. In terms of 
  441. efficiency: ++x is better than x=x+1.  
  442.                     
  443. Unlike interpreted AmigaBASIC, hexadecimal and octal constants can be either 
  444. short or long values. This makes for nicer addressing with PEEK & POKE.
  445.  
  446. Trailing characters (%&!#) after constants cause coercion from one numeric
  447. data type to another, as in AmigaBASIC, eg:
  448.     
  449.     Delay(50&)   '..50 is coerced from short to long integer
  450.     x=12.5*65!   '..65 is coerced from short integer to single-precision
  451.  
  452. As in AmigaBASIC expression evaluation, all operands are converted to the
  453. data type of the most precise operand. Logical operators convert their 
  454. operands to integer values. Relational operations result in long integers.  
  455.   
  456. ACE's boolean values are as follows: 0=false, N=true where N is any non-zero 
  457. long integer. Note that relational operations yield -1 for true (NOT -1 = 0).
  458.  
  459. ACE allows you to define global signed numeric constants with the CONST 
  460. directive (see command and function reference).
  461.  
  462. Strings have a default length of 1K instead of the usual 32K, since ACE 
  463. programs reserve memory for each string immediately at run-time which could
  464. result in quite memory hungry executables if strings were too large. It is 
  465. possible however, to define strings which are longer or shorter than 1K (see 
  466. STRING command).
  467.  
  468. ACE strings are NULL terminated as in C (ie: the last character is an ASCII 0).
  469. A string literal without a final '"' will be truncated at the end of the line.
  470.  
  471.  
  472. Precedence of operators
  473. -----------------------
  474. This is the same as AmigaBASIC with the addition of structure dereferencing
  475. and indirection operators.
  476.  
  477.                             operators
  478.                             ---------
  479.  
  480.     1.  Structure Member Dereferencing        ->
  481.         Parentheses and Address Operator        () @
  482.     2.  Indirection Operators            *% *& *!    
  483.     3.  Exponentiation                ^
  484.     4.  Unary Negation                -
  485.     5.  Multiplication and Floating-Point Division    * /
  486.     6.  Integer Division                \
  487.     7.  Modulo Arithmetic                MOD
  488.     8.  Addition and Subtraction            + -
  489.     9.  Relational Operators            = < > <= >= <>
  490.     10. NOT
  491.     11. AND
  492.     12. OR and XOR
  493.     13. EQV
  494.     14. IMP
  495.  
  496. The use of parentheses in an expression forces the enclosed term to be 
  497. evaluated before adjacent terms. Expression evaluation always proceeds from 
  498. left to right in ACE and AmigaBASIC.
  499.  
  500.   
  501. Identifiers
  502. -----------
  503. In ACE, as in AmigaBASIC an identifier can consist of a combination of 
  504. letters, numbers and  periods (".") up to a maximum length of 40 characters. 
  505. In addition, in ACE the underline ("_") character is also legal. An ACE 
  506. identifier must start with either a letter or underline character.
  507.  
  508. An identifier can be used to represent the following:
  509.  
  510.         - labels
  511.         - variables
  512.         - arrays
  513.         - structures
  514.         - subprograms
  515.         - parameters
  516.         - defined constants
  517.         - shared library functions
  518.         - external functions or variables
  519.  
  520. Labels are global in ACE, so a main program label and a SUB label cannot have
  521. the same name.
  522.  
  523. Identifiers can have a qualifier character (%&$!#) appended in order to 
  524. indicate data type, where:
  525.  
  526.         % = short integer    (2 bytes)
  527.         & = long integer    (4 bytes)
  528.         ! = single precision    (4 bytes)
  529.         # = double precision    (8 bytes) -> not supported yet
  530.         $ = string        (1024 bytes including end-of-string)
  531.  
  532. Examples of valid identifiers are:
  533.  
  534.         x3
  535.         num&
  536.         _putchar
  537.         play.sound
  538.  
  539. An identifer with no qualifier has a default type of single-precision. The 
  540. DEFxxx compiler directives (see command and function reference) have the
  541. same effect as the qualifier characters except they affect all identifiers
  542. starting with a certain letter or letters. Qualifier characters have higher 
  543. precedence than DEFxxx directives. 
  544.  
  545. For shared library functions and external references, a qualifier is used 
  546. merely to declare data type. So, for example, an external function _RangeRand 
  547. might be defined thus:
  548.  
  549.         external function _RangeRand%
  550.  
  551. but can later be referred as _RangeRand or RangeRand%.
  552.  
  553. The declaration of external functions/variables and shared library functions
  554. is global no matter where the declaration occurs.
  555.  
  556. Defined constants are unaffected by qualifier characters. The _value_ of a 
  557. defined constant determines its type. Thus CONST x&=1.2 is a single-precision
  558. - NOT a long integer - constant.
  559.  
  560. The declaration of constants (with CONST) is always global whether the
  561. declaration takes place in the main program or a subprogram.
  562.  
  563. Structure variables always hold a long integer value (address), so trailing 
  564. characters have no effect.
  565.  
  566. Structure type declarations are global, but structure variable declarations
  567. are local.
  568.  
  569. ACE allows for *optional* variable declarations with the SHORTINT, LONGINT,
  570. ADDRESS, SINGLE and STRING directives. Such declarations are useful in that:
  571.     
  572.         - they ensure that a variable has a NULL or zero value.
  573.         - they provide a "cleaner" way of establishing a variable
  574.           which is to be shared by a subprogram.
  575.         - most languages have them and they serve to document
  576.           variable usage explicitly.
  577.  
  578. Variable declarations override the DEFxxx compiler directives and qualifier
  579. characters and are local to the main program or a subprogram.
  580.  
  581. Summary of identifier properties:
  582.  
  583. +---------------+---------------+------------------+
  584. | Identifier    | Local/Global  | Affected by %&!$ |
  585. +---------------+---------------+------------------+
  586. | ARRAY        | LOCAL        | YES            |
  587. | SIMPLE VAR    | LOCAL        | YES           |
  588. | STRUCTURE VAR | LOCAL        | NO           |            
  589. | PARAMETER    | LOCAL        | YES           |
  590. | STRUCTURE DEF | GLOBAL    | NO           |        
  591. | LABEL        | GLOBAL    | NO           |
  592. | DEF'D CONST   | GLOBAL    | NO           |
  593. | SUBPROGRAM     | GLOBAL    | YES           |
  594. | SH'D LIB FUNC | GLOBAL    | YES (declaration)|
  595. | EXT VAR/FUNC    | GLOBAL    | YES (declaration)|
  596. +---------------+---------------+------------------+
  597.  
  598.    
  599. Indirection operators
  600. ---------------------
  601. ACE has four indirection operators: @,*%,*&, and *!. These are _similar_
  602. to C pointers.
  603.  
  604.     @<object>   - returns the absolute address of a data object.
  605.             - note that this is identical to VARPTR(<object>).
  606.     *%<address> - peeks or pokes a short value at the specified address.
  607.     *&<address> - peeks or pokes a long value at the specified address.
  608.     *!<address> - peeks or pokes a single value at the specified address.
  609.  
  610. The indirection operators can therefore be used in a statement (poke) and/or 
  611. as part of an expression (peek), for example:
  612.  
  613.     deflng x
  614.     y=23.25
  615.     x=@y
  616.     *!x := *!x + 2
  617.     print y
  618.  
  619. will print a value of 25.25.
  620.  
  621. There are two things to notice here. First, the pointers are to addresses, 
  622. not necessarily connected to variables. It would be quite legal to allocate
  623. an area of memory and then dereference it with these operators.
  624.  
  625. Second, when assigning a value to a dereferenced memory location as in the 
  626. above example, the ":=" symbol must be used, simply because of the way the 
  627. parser processes statements. Pascal programmers will recognise this as 
  628. the assignment operator. 
  629.  
  630. See also the section below for information about how to use these operators
  631. to implement variable parameters (call-by-reference) in ACE subprograms.
  632.  
  633.  
  634. Structures
  635. ----------
  636. Structures have been included in ACE mainly because of their utility in 
  637. gaining access to operating system functions. 
  638.  
  639. Legal structure members are of the following type: BYTE (in structures only),
  640. SHORTINT, LONGINT, ADDRESS, SINGLE, STRING. The latter can have an optional 
  641. size specification. BYTE members are coerced to and from SHORTINTs.
  642.  
  643. If an array or structure is required as a structure member, it is necessary
  644. to use STRING <ident> SIZE <bytes>. The address of the member can then be
  645. found with @ or VARPTR and assigned to an array or structure variable.
  646.  
  647. If you want to have an address (ie: pointer to an object) as a structure
  648. member simply declare it as an item of type ADDRESS (or LONGINT).
  649.  
  650. When declaring a structure, the only difference between the following two
  651. forms:
  652.  
  653.         DECLARE STRUCT mystructtype mystruct
  654.     and
  655.         DECLARE STRUCT mystructtype *mystruct
  656.  
  657. is that for the former, an appropriate data object is created, but not for 
  658. the latter. In both cases, mystruct contains the start address of a structure 
  659. of type mystructtype. In the second case, the address is NULL until assigned 
  660. a value (eg: with ALLOC). In both cases, the address can be reassigned at 
  661. will, although this should only really be done for structure pointers (the 
  662. second form).
  663.  
  664. Since both forms of structure declaration result in an address being stored
  665. (in mystruct in the example), the dereferencing operator is always "->".
  666.  
  667.     examples:
  668.     --------
  669.  
  670.     PRINT mystruct          -  prints the start address of the structure.
  671.  
  672.     PRINT mystruct->mins -     prints the value of a member called mins.
  673.   
  674. The SIZEOF function can be used to determine the size of a structure type
  675. if allocating memory for a structure (see linkedlist.b).
  676.  
  677. ACE structures are stand-alone data objects, and cannot be elements in an 
  678. array (although structure addresses can be). ACE structures can be SHARED, 
  679. or a structure's address can be passed to a subprogram, eg:
  680.  
  681.     struct my
  682.        longint one
  683.        longint two
  684.     end struct
  685.  
  686.     declare struct my first
  687.     
  688.     sub test(addr&)
  689.     declare struct my *second
  690.        second=addr&
  691.        print second->one
  692.     end sub
  693.  
  694.     '..main
  695.     first->one=12
  696.     print first->one
  697.     test(first)
  698.  
  699. which will print 12 twice.
  700.  
  701. The following code allocates enough memory to hold a structure of type "my", 
  702. zeros the structure's two LONGINT members, and changes the address held by 
  703. the structure variable "third" to the newly allocated memory:
  704.  
  705.     const PUBLIC=2
  706.  
  707.     declare struct my *third
  708.  
  709.     sub create(ADDRESS a_struct)
  710.     declare struct my *temp
  711.       temp = Alloc(sizeof(my),PUBLIC)
  712.       temp->one = 0
  713.       temp->two = 0
  714.       *&a_struct := temp    '..change structure variable's value
  715.     end sub
  716.  
  717.     '..main
  718.     create(@third)
  719.     .
  720.     .
  721.  
  722. Finally, it is not currently possible to use INPUT, (LINE) INPUT# or READ in 
  723. conjunction with structures.
  724.  
  725.     
  726. Subprograms
  727. -----------
  728. Subprograms are supported by ACE, but differ from AmigaBASIC subprograms in
  729. a number of ways. Namely, ACE subprograms:
  730.  
  731.     - are non-static
  732.     - allow recursion
  733.        - can be assigned return values 
  734.  
  735. By way of explanation, being non-static means that once a subprogram has 
  736. finished execution, its local variables and parameters (effectively or
  737. actually) cease to exist.
  738.  
  739. Recursion is (in my opinion) an important feature of modern general 
  740. programming languages. For several examples of the use of recursion, see 
  741. the included programs (eg: fact.b, hanoi.b and tree.b).
  742.  
  743. A word of warning about recursion: it can be stack hungry, so it's a good 
  744. idea to set your stack to 20000 or so, just to be safe, although in most 
  745. cases, this will be a lot more than you need. From Workbench, simply change 
  746. the tool's stack size with Info, or with the stack command in a shell.
  747.  
  748. As with AmigaBASIC, ACE subprogram declarations cannot be nested.
  749.  
  750. The syntax of a subprogram call is the same as in AmigaBASIC:
  751.  
  752.     [CALL] sub-name[(parameter-list)]
  753.  
  754. The only difference is that the parentheses around the parameter list are
  755. not optional when CALL is omitted -- unless there are NO parameters. 
  756.  
  757. CALL must be used after THEN in a single-line IF..THEN statement.
  758.  
  759. By default, every subprogram has a return type of single-precision (just like 
  760. variables). DEFINT,DEFLNG etc can be used to change the default data type of 
  761. subprograms, as can the trailing characters !#$&%.
  762.  
  763. This pretty much obviates the need for DEF FN which is not supported in ACE.
  764. If you really need to you can create a subprogram with a name starting with 
  765. FN for an old BASIC program in which DEF FN was used.
  766.  
  767. A subprogram is given a value either inside the body of the relevant 
  768. subprogram or in the main program (eg: to zero it) - ala Pascal - thus:
  769.  
  770.     sub-name = <expression>
  771.  
  772. However, subprograms cannot be assigned a value in any other way (eg: with
  773. INPUT or READ).
  774.  
  775. A subprogram can be used in an expression, whereupon the subprogram is called
  776. and its value pushed onto the stack for inclusion in the final result of the
  777. expression. An example of this might be:
  778.  
  779.     x=n*pow(n)
  780.  
  781. where "pow" is a subprogram with one parameter.
  782.  
  783. While subprogram declarations can appear anywhere within the program text,
  784. ACE requires that declarations precede calls. So:
  785.  
  786.     sub test
  787.       print "hello"
  788.      end sub
  789.  
  790.     test
  791.  
  792. is legal, but:
  793.  
  794.     test
  795.  
  796.     sub test
  797.       print "hello"
  798.      end sub
  799.  
  800. is not, and will yield an "undeclared subprogram" error. To get around this, 
  801. a forward declaration is used:
  802.  
  803.     declare sub test
  804.     
  805.     test
  806.  
  807.     sub test
  808.       print "hello"
  809.     end sub
  810.  
  811. Forward declarations can include a parameter list. If you later declare
  812. the actual SUB with a different parameter list and you've already called 
  813. the subprogram after a forward declaration, the results will be unpredictable.
  814. I may place tighter controls on this at some stage.
  815.  
  816. Actual parameters are checked for number and type against formals, and 
  817. parameter count mismatches result in a compilation error. An actual parameter
  818. is coerced to the formal parameter's type.
  819.  
  820. ACE's parameter passing mechanism for subprograms is NOT the same as that
  821. used for machine code routines or external functions. In other words, the 
  822. standard C parameter passing mechanism is not used for SUBs. This may be 
  823. changed in the future as it makes object modules written in ACE incompatible 
  824. with C or assembler object modules in this respect.
  825.   
  826. Changes made to a formal parameter have no effect upon the actual parameter 
  827. in a simple call to an ACE subprogram (see "Limitations" re: overwriting of 
  828. string parameters during recursive calls). The formal parameter list consists
  829. of identifiers separated by commas. Each identifier may also be preceded by:
  830. SHORTINT,LONGINT,ADDRESS,SINGLE or STRING to avoid use of a qualifier (%&!$).
  831.  
  832. Currently, actual parameters can be expressions, simple variables, 
  833. parameters (when calling one subprogram from another) and subprograms 
  834. (the equivalent of passing a C or Pascal function), but not arrays. Array 
  835. _elements_ can be passed as actual parameters however. 
  836.  
  837. There is an arbitrary upper limit of 40 parameters per subprogram at the
  838. moment, which may be removed at some stage. This limit also applies to
  839. SHARED variables (see below).
  840.  
  841. Main program variables and arrays can be accessed and modified within 
  842. subprograms via the SHARED directive. All shared variables are passed by 
  843. reference to a subprogram.
  844.  
  845. Multiple SHARED statements are allowed within a single subprogram.
  846.  
  847. DIM SHARED is not allowed. An array is declared to be shared in exactly the 
  848. same way as simple variables, for example:
  849.  
  850.     DIM x(10)
  851.  
  852.     sub thing
  853.         shared x
  854.         .
  855.         .
  856.         end sub
  857.  
  858. Note that parentheses are not required after an array in the shared statement, 
  859. nor are they legal.
  860.  
  861. The differences between variable parameters and shared variables in ACE 
  862. are that:
  863.  
  864.     - shared variables only allow access to main program
  865.       variables from a subprogram, and do not provide a
  866.       mechanism for changing the value of variables in 
  867.           one subprogram from another.  
  868.         - the name of a variable to be shared must correspond
  869.       to the name of an existing (ie: already referenced/declared) 
  870.           main program variable.
  871.  
  872. Although variable parameters are not explictly provided by ACE there are 
  873. two ways to implement them: using indirection operators for simple variables 
  874. and the ADDRESS option of DIM and STRING (see also "Structures" section above).
  875.  
  876. Here's an example of call-by-reference parameters for simple variables
  877. (note: DEFxxx directives are used here for clarity only):
  878.  
  879.     deflng x  '..x is address holder
  880.     defsng n  '..n is a single-precision variable
  881.  
  882.     sub doub(x)
  883.        *!x := *!x * 2  '...n=n*2 [note the ":=" symbol!]
  884.     end sub
  885.  
  886.     n=22.5
  887.     print n
  888.     doub(@n)  '..pass the address of n
  889.     print n
  890.  
  891. which passes the single-precision variable n by reference to the subprogram 
  892. doub, where n is doubled. This will first print 22.5 and then 45.
  893.  
  894. For an array, the following could be done:
  895.  
  896.     deflng    x  '..x is address holder
  897.  
  898.     sub test(x)
  899.     dim a(10) address x  '..points to n
  900.       a(3)=a(3)+12
  901.     end sub
  902.  
  903.     dim n(10)
  904.     n(3)=2
  905.     print n(3)
  906.     test(@n)
  907.     print n(3)
  908.  
  909. which would print first 2 and then 14.
  910.  
  911. These variable parameter mechanisms are most useful when used to pass data 
  912. *between* subprograms, otherwise it is simpler to use SHARED variables.
  913.    
  914. The following table shows the possibilities regarding parameters and shared 
  915. variables in ACE:
  916.  
  917. +---------------------+---------+-------------+-----------------------------+
  918. | Data Type / Object  |    Shared     | Value param |    Variable param                 |
  919. +---------------------+---------+-------------+-----------------------------+
  920. | SHORTINT VARIABLE   |    YES        | YES          |    YES - *%addr                |
  921. |              |             |          |                    |
  922. | LONGINT/ADDRESS VAR |    YES     | YES          |    YES - *&addr                |
  923. |              |            |          |                        |
  924. | SINGLE VARIABLE     |    YES     | YES          |    YES - *!addr                |
  925. |              |            |          |                        |
  926. | STRING VARIABLE     |    YES    | YES          |    YES - STRING x ADDRESS addr |
  927. |              |        |          |                        |
  928. | EXTERNAL VARIABLE   |    NO    | YES          |    YES - *%, *&, *!, STRING .. |
  929. |              |        |          |                    |
  930. | ARRAY              |    YES    | NO          |    YES - DIM x ADDRESS addr    |
  931. |              |        |          |                        |
  932. | STRUCTURE          |    YES    | NO          |    YES - *&addr (see above)    |
  933. +---------------------+---------+-------------+-----------------------------+
  934.  
  935. Note: In the above table, "addr" is a long integer address. VARPTR or @ 
  936. can be used to obtain this. The address is passed to the SUB by value. 
  937. Strings and arrays use the same method, an example of which was given above.  
  938.     
  939.     
  940. Shared library function calls
  941. -----------------------------
  942. ACE provides access to shared libraries in much the same way as
  943. AmigaBASIC does except that you are required to be a bit more specific
  944. when declaring functions in ACE.
  945.  
  946. The commands are as follows:
  947.  
  948. LIBRARY libname    
  949.  
  950.     - where libname is NOT a quote-enclosed string, but the name 
  951.       of a shared library in ROM or in your libs directory
  952.       (eg: LIBRARY graphics). Don't add the ".library" suffix.
  953.            - the LIBRARY command opens the shared library and provides
  954.       its base address for use by functions.
  955.     - if a library can't be opened at run-time, the ACE program 
  956.       will quit.
  957.  
  958. LIBRARY CLOSE libname
  959.  
  960.     - closes the shared library libname.
  961.  
  962. DECLARE FUNCTION funcname LIBRARY libname
  963.         
  964.     - where funcname is the case sensitive name of a function in
  965.       the library libname (eg: DECLARE FUNCTION Move LIBRARY graphics).
  966.     - funcname may have a trailing character (&%#!$) to indicate type
  967.       otherwise default data type rules apply for the function's 
  968.       return type. This character is optional when CALLing the function.
  969.              
  970. [CALL] funcname[(parameter-list)]
  971.  
  972.     - transfers control to the function funcname, loading the
  973.       appropriate registers before doing so, according to the
  974.       information about that function in the library's bmap file 
  975.       (in the ACE:bmaps directory - see "Installing ACE" section).
  976.      - the return value of a function can be accessed by calling
  977.       a function as part of an expression (r-value) 
  978.           (eg: addr&=Alloc(100,2).
  979.  
  980. Function declarations are GLOBAL. They are are NOT optional.
  981.  
  982. ** PLEASE NOTE ***
  983. No type checking of parameters is performed, so expect weirdness if you pass
  984. values of the wrong type. If the RKM or whatever reference you are using for
  985. library functions says to use a long integer, then do so. Don't assume that
  986. a short integer will be coerced to a long integer. It won't.
  987.  
  988. When passing strings as parameters it is not necessary to add a CHR$(0)
  989. to the end of a string since ACE strings are already NULL terminated. 
  990.  
  991. Either VARPTR or SADD can safely be used to find the address of a string 
  992. variable or constant. Actually, the use of SADD or VARPTR for strings
  993. passed to library functions is optional, but it's probably a good idea to 
  994. use one or the other all the time, for consistency's sake. These comments 
  995. also apply to calling machine code routines and external functions.
  996.   
  997. The library itself MUST be in sys:libs (unless it's in ROM).
  998.  
  999. It is up to YOU to open and close libraries correctly. ACE doesn't keep
  1000. track of this, and will try to jump to a library function so long as 
  1001. it finds a reference to it in a .bmap file even if the library hasn't 
  1002. been opened! It is not necessary to open and close the dos.library because
  1003. every ACE program does this.
  1004.  
  1005. ACE expects the .bmap file for a library to be in the directory ACEbmaps:
  1006. (see "Installing ACE"). I have been advised by Commodore Australia that 
  1007. these files may be distributed with ACE but I will wait until I have this 
  1008. in writing before providing them with the archive.
  1009.  
  1010. In a future release I intend to provide a program which is functionally 
  1011. equivalent to ConvertFD (since this may NOT be freely redistributed) so that 
  1012. .bmap files for new libraries can be created. If you have the 1.3 Extras disk, 
  1013. you can use ConvertFD anyway, along with the .FD files Both are to be found in 
  1014. the BasicDemos drawer.
  1015.  
  1016. AmigaBASIC cannot handle functions which use address register a5. This is 
  1017. not true for ACE. Neither ACE nor AmigaBASIC allow the use of functions which
  1018. use register a6. The use of this register for parameters seems to be restricted
  1019. to the cia.device anyway.
  1020.  
  1021. See library.b for an example of how to use shared library functions in ACE.
  1022.  
  1023. In all ACE programs, there are typically a couple of shared libraries opened 
  1024. at the start of execution (at least one anyway: dos.library) and closed at the
  1025. end of execution. If you issue a LIBRARY command to open/close a standard 
  1026. library which ACE had to open at start-up, the library won't be opened/closed 
  1027. at the time you think it should be (eg: mid-execution). Rather, such a library 
  1028. will be opened at the start of execution and closed at the end of the program 
  1029. run.
  1030.  
  1031. An ACE program will abort if a library doesn't exist or can't be opened.
  1032.   
  1033.  
  1034. Machine code calls
  1035. ------------------
  1036. ACE supports AmigaBASIC's mechanism for calling machine code routines and
  1037. the passing of parameters to such routines. AmigaBASIC's stack conventions 
  1038. are also followed (ie: C style parameter passing).
  1039.  
  1040. The syntax for calling such a routine is:
  1041.  
  1042.     CALL long-integer-variable-name[(parameter-list)]
  1043.  
  1044. Note that CALL is NOT optional and the variable containing the address of
  1045. the routine *must* be a long integer.
  1046.  
  1047. For example, 
  1048.  
  1049.     CALL caps&(length&,addr&)
  1050.  
  1051. will set up the stack like this:
  1052.     
  1053.     8(sp) = addr&
  1054.     4(sp) = length&
  1055.     0(sp) = return address
  1056.  
  1057. on entry to the machine code subroutine caps&.
  1058.  
  1059. On exit from a routine, ACE cleans up the stack by POPping all parameters.
  1060.  
  1061. You can use a short integer array, a string or an allocated area of memory
  1062. (with ACE's ALLOC function) to poke the bytes of a machine code routine into. 
  1063. I prefer the latter method.
  1064.  
  1065. Note that because ACE treats ASCII 0 as the end-of-string character, don't 
  1066. use the string-building method, eg:
  1067.  
  1068.     z$=""
  1069.     for i=1 to N
  1070.          read b
  1071.       z$=z$+chr$(b)
  1072.         next
  1073.  
  1074. since if b=0, chr$(b) will be the NULL string. If you want to use a string,
  1075. do the following:
  1076.  
  1077.     z$=""    '..or STRING z$ SIZE 100 (if there are 100 bytes of MC).
  1078.     addr&=sadd(z$)
  1079.     for i&=0 to N-1
  1080.       read b%
  1081.       poke addr&+i&,b%
  1082.     next
  1083.     call addr&
  1084.  
  1085. The latter should be okay, so long as you don't allocate other strings with 
  1086. odd sizes. But if you want to be sure that you have an area of memory which 
  1087. is long-word aligned, use ALLOC, eg:
  1088.  
  1089.     addr&=Alloc(100,2)    '..100 bytes of PUBLIC memory
  1090.     for i&=0 to N-1
  1091.       read b%
  1092.       poke addr&+i&,b%
  1093.     next
  1094.     CALL addr&
  1095.  
  1096. The above examples assume the presence of appropriate DATA statements. See 
  1097. ledflash.b and caps.b for examples. 
  1098.  
  1099. ACE also supports inline assembly code inclusion. See ASSEM..END ASSEM in 
  1100. ref.doc for details.
  1101.  
  1102.  
  1103. External references
  1104. -------------------
  1105. Reference can be made to a variable or function in another file which is
  1106. resolved at link time. You may for instance, have written a function in C
  1107. or assembler. It is possible to pass parameters to, call and obtain return
  1108. values (as with ACE SUBs) from such a function in ACE after declaring an 
  1109. external reference to the function with the EXTERNAL FUNCTION directive 
  1110. (see command and function reference for syntax).
  1111.  
  1112. When passing parameters, standard C parameter passing conventions are
  1113. observed. Although some C compilers seem to pass all parameters as
  1114. 4 bytes per parameter on the stack, ACE allows 2 (short words) or 4 
  1115. byte parameters. Be aware of this! See func.b and func2.b for examples.
  1116.  
  1117. External variables can be assigned values like normal variables, for example:
  1118.  
  1119.         external RangeSeed&
  1120.         RangeSeed=5276&
  1121.     
  1122. All external reference identifiers have an underscore prefixed by ACE but
  1123. this is optional when declaring or using an external reference. C compilers 
  1124. prepend an underscore to external symbols, so ACE does too.
  1125.  
  1126. Note that the names of external references ARE case sensitive.
  1127.  
  1128. Also, the bas script can take as a third argument, the name of the object 
  1129. file produced from the original C or assembly source (ie: .o or .lib file) 
  1130. which contains the external function or variable to be linked with your
  1131. ACE program. 
  1132.  
  1133. It's not easy to call ACE SUBs from C or assembler for two reasons:
  1134.  
  1135.     1. ACE SUBs don't currently use C parameter passing conventions.
  1136.     2. ACE produces whole  assembly source programs, not just functions
  1137.        like a C compiler does.
  1138.  
  1139. For now, you'll have to get your hands dirty with the assembly source code 
  1140. produced by ACE. ACE's -c switch may be of some help here.
  1141.  
  1142.         
  1143. Program arguments
  1144. -----------------
  1145. When called from a Shell or CLI, an ACE program may have arguments, eg:
  1146.  
  1147.     tree 30
  1148.  
  1149. Arguments can be accessed by two ACE functions:
  1150.  
  1151.     ARGCOUNT and ARG$(n)
  1152.  
  1153. The former returns a short integer value indicating the number of arguments
  1154. for the current program, while the latter returns the nth argument as a string,
  1155. where n ranges from 0 to argcount. The zeroth argument (ie: ARG$(0)) is the 
  1156. name of the program.
  1157.  
  1158. Workbench arguments are supported by ACE in the form of four functions in the
  1159. include file WBarg.h: WBargcount, WBarg$(n), WBargPath$(n) and WBargLock&(n).
  1160.  
  1161. The first three are most useful. The fourth is mainly for use by WBargPath$(n). 
  1162. WBargcount returns the number of arguments passed to a program as single
  1163. clicked icons. The zeroth argument is the name of the program and thereafter 
  1164. are the names of those icons which have been activated (single clicked). 
  1165.  
  1166. To pass arguments to a program via Workbench a shift key is held while the 
  1167. icons which represent the arguments to be passed are activated. While still
  1168. depressing the shift key, the application icon is double clicked. 
  1169.  
  1170. An alternative method of passing arguments is to change the default tool of a 
  1171. project icon (document etc) with the Info option from Workbench.
  1172.  
  1173. When this project icon is double clicked, the default tool will be loaded.
  1174. In this case, if the default tool (the program) had a line such as x$=WBarg$(1)
  1175. x$ would contain the name of the project icon.
  1176.  
  1177. WBargPath$(n) is used to find the full path of the file name and includes 
  1178. trailing ":" and "/" characters.
  1179.  
  1180. See the include file WBarg.h for further descriptions of each function.
  1181.  
  1182.  
  1183. Windows
  1184. -------
  1185. You can open up to nine user-defined windows on the Workbench screen. 
  1186. See the command and function reference for the syntax of the WINDOW 
  1187. statement.
  1188.  
  1189. All user-defined windows in ACE are currently RAW: windows and any such
  1190. window will have the standard RAW: gadgets, so the "type" parameter in 
  1191. the AmigaBASIC syntax has no relevance in ACE. As mentioned earlier, I 
  1192. have relied heavily on standard I/O in ACE, and the use of such windows 
  1193. is consistent with this.
  1194.  
  1195. In ACE, the current output window and the selected output window are 
  1196. identical (see WINDOW(0) & WINDOW(1)).
  1197.  
  1198. The WINDOW function takes a single parameter and returns information about
  1199. the current output window:
  1200.  
  1201.     WINDOW(0)  - same as window(1)
  1202.     WINDOW(1)  - window-id of current output window.
  1203.     WINDOW(2)  - present width of current output window.
  1204.     WINDOW(3)  - present height of current output window.
  1205.     WINDOW(4)  - x-coordinate in current output window where next 
  1206.              pixel will be plotted (always.
  1207.     WINDOW(5)  - y-coordinate in current output window where next 
  1208.              pixel will be plotted.
  1209.       WINDOW(6)  - maximum legal colour-id for current output window.
  1210.     WINDOW(7)  - pointer to Intuition Window for current output window.
  1211.     WINDOW(8)  - pointer to Rastport of current output window.
  1212.     WINDOW(9)  - pointer to AmigaDOS file handle for current output window.
  1213.     WINDOW(10) - foreground pen in current output window.
  1214.     WINDOW(11) - background pen in current output window.
  1215.  
  1216. Note that the WINDOW function can also be used for a SCREEN (see below), but
  1217. only the arguments 2,3,4,5,6,7,8,10 and 11 are meaningful.
  1218.  
  1219. When called from a console window (opened with the WINDOW command), WINDOW(4)
  1220. and WINDOW(5) return zero, presumably because of the AmigaDOS manipulation
  1221. of the Intuition environment.
  1222.  
  1223.  
  1224. Screens
  1225. -------
  1226. Screens are implemented, but currently have some limitations. You can open 
  1227. 9 screens at once (memory permitting!).
  1228.  
  1229. Currently, when a screen is opened, a BORDERLESS window the same size as
  1230. the screen is also opened. All subsequent graphics commands send their
  1231. output to the newly created screen's window (until the latter is closed).
  1232. In order to print to such a window, a special command is needed: PRINTS
  1233. (see ref.doc for details about PRINTS). 
  1234.  
  1235. The existence of an Intuition window allows an ACE program to read keyboard
  1236. events. At the moment, the only way of getting input from a screen's window
  1237. is with ACE's INKEY$ function, but I have written an include file (inputs.h) 
  1238. which consists of screen INPUT functions. 
  1239.  
  1240. When a screen is first opened, it is set to black. This can be changed with 
  1241. a combination of COLOR and CLS or by changing the values in PALETTE 0.
  1242.  
  1243. When a screen and its window are closed, ACE makes the screen with the next 
  1244. highest screen-id the current output screen, so it is advisable to open and 
  1245. close screens in ascending and descending order.  
  1246.  
  1247. While in screen mode, don't use WINDOW OUTPUT as there will be no way of
  1248. directing output back to the screen. A future revision of ACE will probably
  1249. allow user-defined windows on screens.
  1250.   
  1251. A special SCREEN(n) function exists in ACE which returns pointers to various
  1252. Intuition structures (window,screen,rastport,viewport). This is detailed in 
  1253. the command and function reference (ref.doc) as are the following commands: 
  1254. SCREEN, SCREEN CLOSE, PALETTE and PRINTS. 
  1255.  
  1256. Finally, the following ACE commands and functions can be used in either window 
  1257. or screen mode transparently: INKEY$,LOCATE,CLS,PSET,LINE,CIRCLE,PAINT,PALETTE,
  1258. COLOR,MOUSE,POINT,PRINTS,AREA,AREAFILL,PATTERN and the turtle graphics commands.
  1259.  
  1260. See also WINDOW(n) in the above section on windows.
  1261.     
  1262.  
  1263. Files
  1264. -----
  1265. AmigaBASIC sequential files are implemented and random files are on the list 
  1266. of things to do.
  1267.  
  1268. The commands and functions for manipulating sequential files in ACE are:
  1269.  
  1270. commands:
  1271.     - OPEN
  1272.     - CLOSE
  1273.     - PRINT#
  1274.     - WRITE#
  1275.     - INPUT#
  1276.     - LINE INPUT#
  1277.  
  1278. functions:
  1279.     - INPUT$ 
  1280.     - EOF
  1281.     - LOF
  1282.     - HANDLE *
  1283.  
  1284.     * not found in AmigaBASIC
  1285.  
  1286. Note that for any command which is immediately followed by a # there should be
  1287. at least one space between the keyword and the #, even though I refer to such
  1288. commands as <command># in the text of this document and ref.doc.
  1289.  
  1290. See the command and function reference for details of each of these.
  1291.  
  1292. When WRITE# is used, the result is identical to AmigaBASIC. For example:
  1293.  
  1294.     X=12 : Y=-3.2 : Z$="fun eh?"
  1295.     OPEN "O",#1,"stuff"
  1296.       WRITE #1,X,Y,Z$
  1297.     CLOSE #1
  1298.  
  1299. results in a one-line file of the following format:
  1300.  
  1301.     12,-3.2,"fun eh?"
  1302.  
  1303. On the other hand, if the following is used instead: 
  1304.  
  1305.     PRINT #1,X,Y,Z$ 
  1306.  
  1307. the file format will be:
  1308.  
  1309.      12         -3.2        fun eh?
  1310.  
  1311. while if semicolons are used:
  1312.  
  1313.     PRINT #1,X;Y;Z$
  1314.  
  1315. the file format becomes:
  1316.  
  1317.      12 -3.2 fun eh?
  1318.  
  1319. INPUT# (eg: INPUT #1,X,Y,Z$) can be used to read values from a file in any of
  1320. the above formats, but bear in mind that strings that are not delimited by
  1321. quotes, but contain spaces or tabs will be seen as more than one string by
  1322. INPUT#. So, in the example formats above, while 
  1323.  
  1324.     "fun eh?" 
  1325.  
  1326. is one string,
  1327.  
  1328.     fun eh?
  1329.  
  1330. is two strings as far as INPUT# is concerned.
  1331.  
  1332. The formats of sequential files in ACE and AmigaBASIC are now very nearly
  1333. identical, the only differences being in ACE tabs (produced by comma 
  1334. delimiters in PRINT -- see PRINT in ref.doc) and the number of decimal 
  1335. places written for single-precision values (usually more in ACE).
  1336.  
  1337. Notice that strings are delimited with double quotation marks by WRITE
  1338. but not by PRINT. For better or worse, this is what AmigaBASIC and ACE do.
  1339.  
  1340. If you find ACE file I/O too slow, you may want to use the dos.library 
  1341. functions (eg: xRead, xWrite). For this reason, I have included the HANDLE(n) 
  1342. function which returns the AmigaDOS handle of a file opened with ACE's OPEN 
  1343. command. You may also wish to use the ami.lib buffered file I/O functions which
  1344. also require this AmigaDOS handle. If HANDLE returns 0, the file doesn't exist.
  1345.  
  1346. See print.b for an example of opening a sequential file to a printer (PRT:). 
  1347.  
  1348. Although SER: may be opened as a sequential file, it is not yet possible to 
  1349. specify parameters for the serial port (baud rate etc) by this method as is 
  1350. possible in AmigaBASIC. I am still thinking about the best way to implement
  1351. this.
  1352.  
  1353.  
  1354. Sound
  1355. -----
  1356. ACE provides you with similar functionality as AmigaBASIC for sound
  1357. generation. It also allows you to do some things that AmigaBASIC doesn't.
  1358.  
  1359. How many times have you wished that AmigaBASIC would let you produce
  1360. white noise easily like the good ol' C64 and Vic-20 did?
  1361.  
  1362. Well, you'll be pleased to know that ACE allows you to do this. All you 
  1363. have to do is allocate about 4000 or more bytes of Chip RAM (upwards of 
  1364. 4000 bytes yields better quality white noise), poke it with random values, 
  1365. (between -128 and 127) call WAVE and you're set (see sound.b)!
  1366.  
  1367. Moreover, you can actually play sound samples (IFF or otherwise) in the
  1368. same way, using just the two commands WAVE and SOUND. In fact, I've written 
  1369. a program in ACE that plays sound samples and recognises IFF 8SVX samples
  1370. (see play.b). 
  1371.  
  1372. See sound.b for an example of how to use ACE's sound facilities in general.
  1373.  
  1374. As with AmigaBASIC, a sine waveform is the default, but through the WAVE
  1375. statement you can create any waveform you wish including sawtooth, triangle 
  1376. and square.
  1377.  
  1378. WAVE has the following syntaxes:
  1379.  
  1380.     WAVE voice,SIN
  1381.  
  1382. and
  1383.     
  1384.     WAVE voice,waveform-address,byte-count
  1385.  
  1386. where waveform-address is the beginning of a block of memory where the waveform
  1387. resides (an area of Alloc'd CHIP memory) and byte-count is the number of bytes 
  1388. in the waveform table.
  1389.  
  1390. The SOUND statement syntax is as follows:
  1391.  
  1392.     SOUND period,duration[,volume][,voice]
  1393.  
  1394. This is different to AmigaBASIC in a number of ways. First, in ACE you
  1395. specify the sampling period NOT the frequency. This was easier to implement
  1396. and still provides the same functionality, but if you want specific notes, 
  1397. you'll have to do the calculations yourself (see equations below).
  1398.  
  1399. Sampling period is inversely proportional to frequency, so a high sampling
  1400. rate corresponds to a low frequency and vice-versa. ACE allows you to
  1401. specify a sampling period in the range 124..32767.
  1402.  
  1403. The duration is a single-precision value as in AmigaBASIC but can range from 
  1404. 0..999 (instead of 0..77). This range is somewhat arbitrary, but gives plenty
  1405. of scope for large sound samples. This specifies the length of time that a 
  1406. tone should be played for. A duration of 18.2 corresponds to about 1 second. 
  1407.  
  1408. Volume defaults to 64 if not specified and can range from 0..64.
  1409.  
  1410. The voice can be in the range 0..3 - since there are 4 audio channels - 
  1411. with 0 & 3 corresponding to the left speaker and 1 & 2 to the right.
  1412. The default voice is 0.
  1413.  
  1414. At the moment, ACE's SOUND statement isn't very good when used to produce a 
  1415. series of short pulses, although this is somewhat dependent upon the waveform 
  1416. in use. In any case, more work needs to be done in this area to prevent 
  1417. "popping" between SOUND statements when the audio hardware is turned on and 
  1418. off in rapid sequence.
  1419.  
  1420. ACE sound is produced by programming the hardware directly. A future version
  1421. will probably utilise the audio device instead.
  1422.  
  1423. Finally, here's some useful equations for use in conjunction with ACE's SOUND 
  1424. statement:
  1425.  
  1426.     samples/second to period:
  1427.     ------------------------
  1428.     period = 3579546 / samples-per-second
  1429.     
  1430.     musical note to period:
  1431.     ----------------------
  1432.     period = 3579546 / (length * frequency)
  1433.  
  1434.     where length is the size of the waveform table in bytes 
  1435.     (32 bytes for ACE's sine waveform) and frequency is the
  1436.     note itself (eg: middle C is 523.25 Hz).
  1437.  
  1438.     duration value for one waveform cycle:
  1439.     -------------------------------------
  1440.     duration = .279365 * period * length / 1E6 * 18.2
  1441.  
  1442.         
  1443. Turtle Graphics
  1444. ---------------
  1445. You may be wondering some of these things:
  1446.  
  1447.     - what the heck is Turtle Graphics?
  1448.     - isn't that for kids?
  1449.     - why did he include THAT?
  1450.  
  1451. To answer the first question: Turtle Graphics (TG) originated as a subset of 
  1452. the language LOGO invented by Seymour Papert at MIT. LOGO was originally 
  1453. intended as a language for learning. Children are able to write simple programs
  1454. to draw shapes on the computer's screen or move a Turtle - a dome-shaped robot 
  1455. - on a sheet of paper on the floor, thereby learning about geometry by doing. 
  1456.  
  1457. LOGO also has many Lisp-like qualities and so can be used as a serious
  1458. language for AI work, although it isn't to my knowledge.
  1459.  
  1460. But I digress. Apart from the fun kids can have with TG, it's actually 
  1461. possible to construct quite complex shapes with it. Combined with recursion,
  1462. TG is a powerful tool. It is particularly useful in plotting many fractal
  1463. shapes (see snowflake.b, dragon.b).
  1464.  
  1465. Since the first LOGO, there have been many manifestations of TG. Turbo Pascal 
  1466. for the PC and the Mac have both had TG.
  1467.  
  1468. A couple of years ago, I  wrote a pure TG subset of LOGO which used the same 
  1469. syntax as the original language and allowed recursive procedures. I've also
  1470. written TG functions in C. Both of these have been useful to me and I've often
  1471. wished that BASIC came with TG built-in. Well, now one dialect does!
  1472.  
  1473. For some examples of the use of Turtle Graphics in ACE, see the following
  1474. programs:
  1475.  
  1476.     - tree.b
  1477.     - flower.b
  1478.     - boxit.b
  1479.     - torus.b
  1480.     - dragon.b
  1481.     - snowflake.b
  1482.  
  1483. The above discussion should have answered the second question. As for 
  1484. the third, the answer is: because I wanted to!! :^)
  1485.  
  1486. Okay, enough philosophy. Here's the ACE stuff:
  1487.  
  1488. BACK n        - move turtle back by n.
  1489. FORWARD n    - move turtle forward by n.
  1490. HEADING     - return turtle's current heading in degrees (0..359).
  1491. HOME        - move turtle back to its home position.
  1492. PENDOWN        - put turtle's pen down. 
  1493. PENUP        - lift turtle's pen up.
  1494. SETHEADING degs - change turtle's heading to degs.
  1495. SETXY x,y    - change turtle's current x,y location.
  1496. TURN degs    - rotate turtle by degs.
  1497. TURNLEFT degs    - turn turtle left by degs.
  1498. TURNRIGHT degs  - turn turtle right by degs.
  1499. XCOR        - return turtle's current x-coordinate.
  1500. YCOR        - return turtle's current y-coordinate.
  1501.  
  1502. where:
  1503.     - n is pixels (x:y ratio is 2.25:1 -- assumes hi-res screen).
  1504.     - degs is a signed short integer representing degrees with
  1505.       the turtle starting at a 270 degree orientation -- pointing up).
  1506.     - home is the turtle's x,y start location (0,0).
  1507.  
  1508. Note that the X:Y ratio can be modified thus:
  1509.  
  1510.     EXTERNAL _tg_xy_ratio!
  1511.     _tg_xy_ratio = 1.125    '..1.125 is about right for a lo-res screen
  1512.  
  1513. Most LOGO environments use a coordinate system where 0,0 is at the center of
  1514. the screen and positions to the left and down of this origin are negative while
  1515. those up and to the right are positive. ACE's TG system however, uses the
  1516. Amiga's normal graphics coordinate system with 0,0 at the top left of the
  1517. screen/window, so as to maintain consistency with other graphics commands
  1518. such as PSET, LINE and CIRCLE.
  1519.   
  1520. If a negative value is specified for the turnleft or turnright commands,
  1521. the turtle will be rotated in the opposite direction to that indicated by
  1522. the the command name. Note that there is also a turn command.
  1523.  
  1524. When using these commands, it's best to think of an imaginary turtle (in LOGO
  1525. it's usually a small triangle on the screen) which rotates and moves according
  1526. to your whim. The turtle can either have its pen lowered or raised - and will
  1527. therefore draw or not - which is useful when you need to move in a relative 
  1528. fashion from one location to another without drawing anything.      
  1529.  
  1530. SetXY is like the graphics library Move() command and may need to be preceded 
  1531. by PENUP unless you want to draw a line.
  1532.  
  1533. To change the colour of the pen, use the COLOR command.
  1534.  
  1535. That's probably enough about Turtle Graphics. Oh, by the way, if you ever
  1536. get the chance to read Papert's "Mindstorms", do so. It's good value.
  1537. While I think of it, Sherry Turkle - that's Papert's wife - wrote a book
  1538. called "The Second Self: Computers and the human spirit", which I recommend 
  1539. if you're at all interested in the psychological/social effects of computing.
  1540.  
  1541.  
  1542. Event trapping
  1543. --------------
  1544. ACE provides for AmigaBASIC-style event trapping. The following event 
  1545. types are supported:
  1546.  
  1547.     BREAK     -  ctrl-c (user break).
  1548.     MOUSE     -  left mouse button.
  1549.     TIMER(n)  -  cause a trap every n seconds.
  1550.     MENU      -  right mouse (menu) button -- not implemented yet.
  1551.  
  1552. Since ACE has no sprite support, ON COLLISION is not included as yet.
  1553.  
  1554. Event trapping in ACE works by checking for a given event at strategic points
  1555. in a program (before NEXT, WEND, GOTO, CALL, PRINT etc) and if an event is
  1556. detected, control is passed to a trap handling routine. Hence, trapping here
  1557. does not refer to software traps (exceptions).
  1558.  
  1559. The specification for the trapping of an event is: 
  1560.  
  1561.     ON <event> GOSUB | GOTO <label>|<line-number> (eg: ON BREAK GOTO quit)
  1562.  
  1563. which indicates the routine to which control is to be passed when a trap
  1564. occurs. This is followed at some stage by:
  1565.  
  1566.     <event> ON  (eg: BREAK ON)  
  1567.  
  1568. which causes all code from that point in a program - UNTIL the trap handling 
  1569. routine - to contain (at the object code level) event trapping code.
  1570.  
  1571. It is a good idea to put trap handlers at the end of a program, since once the
  1572. handler for an event is found by the compiler, no more event trapping code is
  1573. generated for that event even if there is code below the handing routine. In
  1574. other words, the equivalent of an <event> OFF (see below) command is issued 
  1575. once the trap handing code is entered. 
  1576.  
  1577. Other commands are:
  1578.  
  1579.     <event> STOP
  1580.  
  1581. which disables trapping for the event until another <event> ON is issued, 
  1582. and:
  1583.  
  1584.     <event> OFF
  1585.  
  1586. which disables trapping for the event permanently.
  1587.  
  1588. Just so there is no misunderstanding, the latter two commands prevent the 
  1589. inclusion of event trapping code for a specific event in your program at the 
  1590. assembly source level. They do this from the point in an ACE program at 
  1591. which they are issued.
  1592.  
  1593. Here's a typical example:
  1594.  
  1595.     ON BREAK GOTO quit
  1596.     BREAK ON
  1597.  
  1598.     for i=1 to 1000000
  1599.      print i
  1600.     next
  1601.  
  1602.     quit:
  1603.       PRINT "**break!"
  1604.       STOP
  1605.  
  1606. ACE event trapping will be improved as time goes by (eg: ON MENU).
  1607.             
  1608.  
  1609. Error Handling
  1610. --------------
  1611. The error messages generated by ACE are mostly different to the ones in the
  1612. AmigaBASIC interpreter (and ACE doesn't beep at you :) but are usually fairly
  1613. clear.
  1614.  
  1615. Syntactically incorrect programs can lead ACE to produce a bunch of spurious 
  1616. error messages. In such cases, it's best to ignore all but the first one or 
  1617. two, unless there are "clusters" of messages which are separated by periods 
  1618. of error-free compilation.
  1619.  
  1620. If you leave out END IF, WEND, UNTIL, NEXT, END SUB, END STRUCT or END CASE, 
  1621. there will be a corresponding number of error messages at the end of the 
  1622. compile. If you leave off two WENDs, you'll get 2 "WHILE without WEND" error
  1623. messages.
  1624.  
  1625. ACE only reports the first error in a line of code and ignores the remainder 
  1626. of the "bad" line. A typical message consists of the line containing the error,
  1627. a carat ("^") marker, and the error message itself. More work still needs to 
  1628. be done on ACE's compile-time error handling, but it's not too bad.
  1629.  
  1630. No error messages are issued by ACE programs at run-time yet. Generally,
  1631. when a program runs into something it can't do, or an erroneous request - like
  1632. trying to open two files to the same file number or trying to open a library 
  1633. that doesn't exist - the program will either quit or just not have the desired 
  1634. effect. I intend to have run-time errors generate an autorequester in future.
  1635.  
  1636.  
  1637. Notes for assembly programmers
  1638. ------------------------------
  1639. I've tried to make the assembly source files that ACE produces as 
  1640. readable as possible by using meaningful data object names. See also
  1641. "Compiler options" re: the compiler's -c switch.
  1642.  
  1643. Linked library routines use data registers d0-d6 and address registers 
  1644. a0-a3, while d7 is used for array index calculations. Also, a4 and a5 are 
  1645. used as stack frame pointers for variables and parameters.
  1646.  
  1647. db.lib routines don't save and restore registers via the stack, but the 
  1648. use of registers is internally consistent.
  1649.  
  1650. The use of linked libraries means that the size of all executables is
  1651. fairly large. But given that disk space and memory are cheap, I'd rather
  1652. this than the alternative of having every executable be dependent upon one
  1653. or more special shared libraries at run-time. However, I will try to reduce
  1654. the size of executables.
  1655.  
  1656. Due to BASIC's tendancy to coerce data types so much for the programmer,
  1657. the resulting code can look a little nasty, and big increases in efficiency 
  1658. can be gained by careful combinations of data types in expressions.
  1659.  
  1660. Writing ACE has so far been a learning experience for me and if when I started,
  1661. I knew what I know now, I would have done many things differently.
  1662.  
  1663. My original rationale for passing parameters via registers to ACE (and shared) 
  1664. library functions was to improve execution speed. However, since I call lots 
  1665. of other functions (eg: in ami.lib) which require their parameters to be on 
  1666. the stack, I would probably call ALL functions in this way if I did it again. 
  1667. Oh well.
  1668.  
  1669. Moreover, my desire for internal consistency led me to a rather odd method of 
  1670. passing parameters to SUBs. This allowed me to treat parameters in the same way
  1671. as variables which is all very nice, but it led to other problems, chief among
  1672. them being the need to use a Forbid()/Permit() pair when sending parameters to 
  1673. a SUB. This works fine however, so I'm taking the view that if it 'aint broke,
  1674. I probably shouldn't fix it. 
  1675.  
  1676.  
  1677. Limitations
  1678. -----------
  1679. Although ACE can theoretically handle arrays with up to 255 dimensions, I
  1680. have set an arbitrary limit of 10 dimensions (hands up how many of you ever
  1681. use more than 3?), mainly in the interest of minimising symbol table size.
  1682. However, I will probably remove this limit at some stage.
  1683.  
  1684. Variables do NOT get a default zero or NULL value, so don't assume ANYTHING
  1685. about the contents of an uninitialised variable. For example: PRINT X will
  1686. yield garbage if X has not been given a value. The optional variable 
  1687. declarations provided in ACE are therefore worth using since they DO give
  1688. variables an initial zero or NULL value.
  1689.  
  1690. The precision of exponentiation begins to falter with large numbers because
  1691. all exponentiation is currently done with the single-precision math library 
  1692. function SPPow().
  1693.  
  1694. While strings can be defined to be longer (or shorter) than 1K, there
  1695. are some ACE commands and functions which still assume a 1K limit, namely: 
  1696. STRING$, SPACE$, LINE INPUT#, INPUT and SWAP.
  1697.  
  1698. Recursive activations of a subprogram will allow local strings and arrays
  1699. to be overwritten. The same applies to string parameters. In all these cases 
  1700. a single static data item is being referenced.
  1701.    
  1702. If you issue RETURN from within a FOR loop, the return address will *not* be 
  1703. the top item on the stack. Instead, FOR..NEXT loop data will be. A GURU will 
  1704. almost certainly result. Use a while or repeat loop if you must RETURN. In 
  1705. general, don't branch out of a FOR loop, never to return. GOSUB & CALL are 
  1706. okay since they both return control back to the next statement in the loop.
  1707.  
  1708. A shared variable cannot be used as a FOR loop index in ACE. Any attempt to
  1709. do so will result in a compilation error. There is no need to do this anyway.
  1710.  
  1711. IF..THEN NEXT will not have the desired effect (it's bad coding anyway).
  1712. NEXT must always appear on a line by itself or as part of a multi-statement. 
  1713.  
  1714. Expressions and parameter lists cannot currently be split over more than 
  1715. one line. I intend to change this.
  1716.  
  1717. The compiler currently only responds to ctrl-c during the main compilation 
  1718. phase, and not during optimisation or when target code is being written.
  1719.  
  1720. ON BREAK and ctrl-c trapping currently only works from windows, not screens.
  1721.  
  1722. Don't mix the compiler's -b option with BREAK event trapping, as they will
  1723. conflict.
  1724.  
  1725.  
  1726. Known Bugs
  1727. ---------- 
  1728. When ACE aborts due to internal list allocation errors (on 512K machines 
  1729. typically, or with big programs), there is sometimes a small memory leak.
  1730. Although this doesn't cause me problems, it might do so on a 512K machine 
  1731. after several compilations, and is obviously undesirable in any case.
  1732.  
  1733. There seems to be a ctrl-c trapping mechanism produced by ZC which sometimes 
  1734. competes with my own ctrl-c trapping code in ACE and APP. I've fixed this to
  1735. some extent and the bug surfaces far less often now. If you get the "ace/app
  1736. terminating" message, all is well, otherwise memory won't be properly cleaned
  1737. up. Please note that this is a problem with the compiler, not the executables 
  1738. generated by ACE/A68K/Blink.
  1739.  
  1740. The SAY(n) _function_ works under Workbench 2.04 but not under 1.3. Since the 
  1741. function uses no 2.04-specific code, this is puzzling. The SAY command works 
  1742. under both 1.3 and 2.04 however.
  1743.  
  1744. I'm working on these problems, so please be patient.
  1745.  
  1746. A68K sometimes complains about string literal definitions produced by ACE 
  1747. which are much longer than a single line.
  1748.  
  1749.  
  1750. Future versions
  1751. ---------------
  1752. Double-precision floating-point and menus are high on the agenda.
  1753.  
  1754. Other plans include more graphics commands, random files plus miscellaneous 
  1755. other commands and functions.
  1756.  
  1757. Use of PRINT and INPUT will eventually be screen/window transparent. 
  1758.  
  1759. ACE's WINDOW command may allow for user-defined windows on screens.
  1760.  
  1761. I may provide support for gadgets and sprites at some stage. 
  1762.   
  1763. Thus far, I've taken the approach of implementing what I most often use 
  1764. and what I have often wished for in BASIC.
  1765.  
  1766.    
  1767. Disclaimer
  1768. ----------
  1769. Although every care has been taken in the development and testing of the 
  1770. compiler and its libraries, the author will not be held liable for damages 
  1771. caused either directly or indirectly as a result of the use of ACE.
  1772.  
  1773.  
  1774. References
  1775. ----------
  1776. The following references have been used throughout the development of ACE:
  1777.  
  1778. =============
  1779. "Amiga BASIC", 1985, Commodore-Amiga Inc. and Microsoft Inc.
  1780.  
  1781. "Amiga ROM Kernel Reference Manual: Libraries and Devices", Commodore-Amiga
  1782.  
  1783. Anderson, Thompson, 1990, "Mapping the Amiga", COMPUTE! Publications Inc.
  1784.  
  1785. Berry, 1986, "Inside the Amiga with C", SAMS
  1786.  
  1787. Bleek, Jenrich, Schulz, 1989, "Amiga C for Advanced Programmers", Abacus
  1788.  
  1789. Bleek, Jenrich, Schulz, 1989, "Advanced System Programmers Guide", Abacus
  1790.  
  1791. Choi, 1990, "Advanced Programming Techniques", University of Tasmania
  1792.  
  1793. Commander, 1987, "Amiga Assembly Language Programming", TAB Books Inc.
  1794.  
  1795. Dittrich, 1989, "Amiga Machine Language", Abacus
  1796.  
  1797. Schaun, 1990, "Amiga C for Beginners", Abacus
  1798. =============
  1799.  
  1800. The most frequently used of these has been "Mapping the Amiga". Despite 
  1801. it's not infrequent errors, it remains an excellent resource. I have
  1802. also referred quite often to the two machine language books as well as to
  1803. the Advanced C programming book by Bleek et al.
  1804.   
  1805. Although not listed, Commodore's Autodocs for the Amiga (supplied with the
  1806. Native Developer Kit) are constantly used.
  1807.  
  1808. Young Choi's Advanced Programming notes were in many ways the impetus for
  1809. the development of ACE. They were used in a compiler construction course
  1810. I took as an undergraduate. I thank Young for introducing me to the joys
  1811. of compiler writing. Including the Pascal Minus compiler I wrote for that
  1812. course, and the BASIC interpreter I wrote in the same period, I've since
  1813. written a Logo interpreter, a Forth interpreter and ACE.
  1814.  
  1815.  
  1816. Final word
  1817. ----------
  1818. Let me offer my thanks to Charlie Gibbs for his reliable assembler and to 
  1819. the Software Distillery for Blink. Without these excellent programs, far 
  1820. fewer compilers would have seen the light of day, including ACE.
  1821.  
  1822. Sozobon C (ZC) has always been a reliable workhorse for me, so a vote of
  1823. thanks goes to Sozobon as well. Isn't PD great?
  1824.  
  1825. I'd like to thank those people who have tested ACE so far: Addison Laurent, 
  1826. Byron Montgomerie, Juergen Weinelt, Alan Peyton-Smith, Michael Zielinski,
  1827. Ken Thompson and others.
  1828.  
  1829. These guys have given ACE a good workout on a variety of platforms ranging 
  1830. from an A1000 running Wb 1.3 to 68030 machines running Wb 3.0. They have 
  1831. all pointed out a number of bugs/problems to me which have either been fixed 
  1832. or put on the list of things to fix.
  1833.  
  1834. I'd especially like to thank Michael Zielinski for discovering a particularly 
  1835. serious bug which prevented branches of greater than 32K in length prior
  1836. to v1.02. Also, Enforcer hits reported by him started me on a trail which led 
  1837. to a nasty string-related bug (see entry for 13/4/93 in docs/history).
  1838.  
  1839. Jarto 'Robin' Tarp pointed out how inefficient my first implementation
  1840. of INSTR was. It's considerably faster now.
  1841.  
  1842. Let me stress that any remaining bugs in ACE are entirely my fault.
  1843.  
  1844. Many others have given me a great deal of encouragement and made useful 
  1845. comments in recent times. I hope this continues.
  1846.  
  1847. I'd also like to thank my fiancee, Karen Lacey, for her encouragement and 
  1848. support and for putting up with the number of hours I spend at the computer.
  1849.  
  1850. Despite ACE's problems (see "Limitations" and "Known Bugs") it is already 
  1851. proving to be a useful tool for me, and if others can derive benefit from it, 
  1852. well, that's great. Although ACE has a long way to go before it can be called 
  1853. complete (if ever!), I'm not terribly concerned about that. As long as it does 
  1854. most of what you want and is extensible, I guess that's the main thing.
  1855.  
  1856. The provision of calls to shared library functions, external functions, 
  1857. machine code routines, inline assembly code, and #include files should 
  1858. go a long way towards making up for ACE's intrinsic shortcomings.
  1859.   
  1860. I hope you enjoy ACE and find it useful. I'm learning a great deal by 
  1861. developing it and having a lot of fun in the process, so I'm not after 
  1862. monetary rewards. Of course, please feel free to donate if you wish!
  1863.  
  1864. What I DO want is feedback. If you have any problems, requests, queries or 
  1865. suggestions, I want to hear from you and I'd like to hear about interesting 
  1866. programs you've written with ACE (e-mail the source to me if you like!).
  1867.  
  1868. Obviously I want to know about bugs too. 
  1869.  
  1870. Remember that ACE is FreeWare, so redirect flames to /dev/null (ie: be nice).
  1871.  
  1872. Happy ACEing!
  1873.  
  1874. Regards, David Benn
  1875. 10th July 1993
  1876.  
  1877. +-----------------------------------------------+
  1878. |     Internet: dbenn@leven.appcomp.utas.edu.au |
  1879. |   Compuserve: 100033,605                  |
  1880. | Discovery 40: 032432850            |
  1881. |                              |
  1882. |      Phone: (003) 317 680 [home]              |
  1883. |          (003) 243 285 [work]              |
  1884. |                              |
  1885. |    Address: 181 St John Street, Launceston,     |               
  1886. |          Tasmania, Australia, 7250              |
  1887. +-----------------------------------------------+
  1888.