changeset 554:afff0087c27f

findstr and signal finished.
author roug
date Tue, 22 Oct 2002 19:09:04 +0000
parents b93501797906
children d14042385d24
files docs/ccguide/basic09.appendix docs/ccguide/errors.appendix
diffstat 2 files changed, 192 insertions(+), 75 deletions(-) [+]
line wrap: on
line diff
--- a/docs/ccguide/basic09.appendix	Sun Oct 20 05:16:37 2002 +0000
+++ b/docs/ccguide/basic09.appendix	Tue Oct 22 19:09:04 2002 +0000
@@ -9,4 +9,105 @@
 calling protocol.
 </para>
 
+<section>
+<title>Example 1 - Simple Integer Aritmetic Case</title>
+<para>
+This first example illustrates a simple case. Write a C function to
+add an integer value to three integer variables.
+<screen>
+build bt1.c
+? addints(cnt,value,s1,arg1,s2,arg2,s2,arg3,s4)
+? int *value,*arg1,*arg2,*arg3;
+? {
+?     *arg1 += *value;
+?     *arg2 += *value;
+?     *arg3 += *value;
+? }
+?
+</screen>
+</para>
+<para>
+That's the C function. The name of the function is "addints". The
+name is information for C and c.link; BASIC09 will not know anything
+about the name. Page 9-13 of the BASIC09 Reference manual describes
+how BASIC09 passes parameters to machine language modules. Since
+BASIC09 and C pass parameters in a similar fashion, it is easy to
+access BASIC09 values. The first parameter on the BASIC09 stack is
+a two-byte count of the number of following parameter pairs. Each
+pair consists of an address and size of value. For most C
+functions, the parameter count and pair size is not used. The
+address, however, is the useful piece of information. The address
+is declared in the C function to always be a "pointer to..." type.
+BASIC09 always passes addresses to procedures, even for constant
+values. The arguments cnt, s1, s2, s3 and s4 are just place holders
+to indicate the presence of the parameter count and argument sizes
+on the stack. These can be used to check validity of the passed
+arguments if desired.
+</para>
+<para>
+The line "int *value,*arg1,*arg2,*arg3" declares the parameters (in
+this case all "pointers to int"), so the compiler will generate the
+correct code to access the BASIC09 values. The remaining lines
+increment each arg by the passed value. Notice that a simple
+arithmetic operation is performed here (addition), so C will not
+have to call a library function to do the operation.
+</para>
+<para>
+To compile this function, the following C compiler command line is
+used:
+<informalexample>
+<para>
+cc2 bt1.c -rs
+</para>
+</informalexample>
+CC2 uses the Level-Two compiler. Replace cc2 with cc1 if you are
+using the Level-One compiler. The -r option causes the compiler to
+leave bt1.r as output, ready to be linked. The -s option suppresses
+the call to the stack-checking function. Since we will be making a
+module for BASIC09, cstart.r will not be used. Therefore, no
+initialized data, static data, or stack checking is allowed. More
+on this later.
+</para>
+<para>
+The bt1.r file must now be converted to a loadable module that
+BASIC09 can link to by using a special linking technique as follows:
+<informalexample>
+<para>
+c.link bt1.r -b=addints -o=addints
+</para>
+</informalexample>
+This command tells the linker to read bt1.r as input. The option
+"-b=addints" tells the linker to make the output file a module that
+BASIC09 can link to and that the function "addints" is to be the
+entrypoint in the module. You may give many input files to c.link
+in this mode. It resolves references in the normal fashion. The
+name given to the "-b=" option indicates which of the functions is
+to be entered directly by the BASIC09 RUN command. The option
+"-o=addints" says what the name of the output file is to be, in this
+case "addints". This name should be the name used in the BASIC09
+RUN command to call the C procedure. The name given in "-o="
+option is the name of the procedure to RUN. The "-b=" option is
+merely information to the linker so it can fill in the correct
+module entrypoint offset.
+</para>
+
+<para>
+Enter the following BASIC09 program:
+<programlisting>
+PROCEDURE btest
+DIM i,j,k:INTEGER
+i=1
+j=132
+k=-1033
+RUN addints(4,i,j,k)
+PRINT i,j,k
+END
+</programlisting>
+When this procedure is RUN, it should print:
+<screen>
+5       136     -1029
+</screen>
+indicating that our C function worked!
+</para>
+
 </appendix>
--- a/docs/ccguide/errors.appendix	Sun Oct 20 05:16:37 2002 +0000
+++ b/docs/ccguide/errors.appendix	Tue Oct 22 19:09:04 2002 +0000
@@ -33,434 +33,450 @@
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>argument storage</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>bad character</term>
+<listitem>
+<para>
+</para>
+</listitem>
+</varlistentry>
+
+<varlistentry><term>both must be integral</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>break error</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>can't take address</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>cannot cast</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>cannot evaluate data</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>cannot initialize</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>compiler trouble</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>condition needed</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>constant expression required</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>constant overflow</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>constant required</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>continue error</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>declaration mismatch</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>divide by zero</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>? expected</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>expression missing</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>function header missing</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>function type error</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>function unfinished</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>identifier missing</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>illegal declaration</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>label required</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>label undefined</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>lvalue required</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>multiple defaults</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>multiple definition</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>must be integral</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>name clash</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>name in cast</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>named twice</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
-<listitem>
-<para>
-</para>
-</listitem>
-</varlistentry>
-
-<varlistentry><term></term>
+<varlistentry><term>no 'if' for 'else'</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>no switch statement</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>not a function</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>not an argument</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>operand expected</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>out of memory</term>
 <listitem>
 <para>
+Compiler dynamic memory overflow. The compiler requires
+dynamic memory for symbol table entries, block level
+declarations and code generation. Three major factors affect
+this memory usage. Permanent declarations (those appearing on
+the outer block level (used in include files)) must be
+reserved from the dynamic memory for the duration of the
+compilation of the file. Each { causes the compiler to perform
+a block-level recursion which may involve "pushing down"
+previous declarations which consume memory. Auto class
+initializers require saving expression trees until past the
+declarations which may be very memory-expensive if may exist.
+Avoiding excessive declarations, both permanent and inside
+compound statement blocks conserve memory. If this error
+occurs on an auto initializer, try initializing the value in
+the code body.
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
-<listitem>
-<para>
-</para>
-</listitem>
-</varlistentry>
-
-<varlistentry><term></term>
+<varlistentry><term>pointer mismatch</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>pointer or integer required</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>pointer required</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>primary expected</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>should be NULL</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>**** STACK OVERFLOW ****</term>
+<listitem>
+<para>
+</para>
+</listitem>
+</varlistentry>
+
+<varlistentry><term>storage error</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>struct member mismatch</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>struct member required</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>struct syntax</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>struct or union inappropiate</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>syntax error</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>third expression missing</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>too long</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>too many brackets</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>too many elements</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>type error</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>type mismatch</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>typedef - not a variable</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>undeclared variable</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>undefined structure</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>unions not allowed</term>
 <listitem>
 <para>
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>unterminated character constant</term>
 <listitem>
 <para>
+Unmatched ' character delimiters. (2.4.3)
 </para>
 </listitem>
 </varlistentry>
 
-<varlistentry><term></term>
+<varlistentry><term>unterminated string</term>
 <listitem>
 <para>
 Unmatched " string delimiters. (2.5)
@@ -471,7 +487,7 @@
 <varlistentry><term>while expected</term>
 <listitem>
 <para>
-No while found for do statements (9.5)
+No while found for do statement. (9.5)
 </para>
 </listitem>
 </varlistentry>