From: cuz Date: Tue, 26 Nov 2002 18:46:40 +0000 (+0000) Subject: Added blurb about register variables X-Git-Tag: V2.12.0~1993 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=6598be68b23725bdf34ef5c2f547278c5d0fd963;p=cc65 Added blurb about register variables git-svn-id: svn://svn.cc65.org/cc65/trunk@1654 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/doc/cc65.sgml b/doc/cc65.sgml index ba44c43af..c565fd59c 100644 --- a/doc/cc65.sgml +++ b/doc/cc65.sgml @@ -70,6 +70,7 @@ Short options: -h Help (this text) -j Default characters are signed -o name Name the output file + -r Enable register variables -t sys Set the target system -v Increase verbosity @@ -87,6 +88,8 @@ Long options: --debug-info Add debug info to object file --help Help (this text) --include-dir dir Set an include directory search path + --register-space b Set space available for register variables + --register-vars Enable register variables --rodata-name seg Set the name of the RODATA segment --signed-chars Default characters are signed --static-locals Make local variables static @@ -177,6 +180,38 @@ Here is a description of all the command line options: Print the short option summary shown above. + -o name + + Specify the name of the output file. If you don't specify a name, the + name of the C input file is used, with the extension replaced by ".s". + + + -r, --register-vars + + . + + + --register-space + + This option takes a numeric parameter and is used to specify, how much + zero page register space is available. Please note that just giving this + option will not increase or decrease by itself, it will just tell the + compiler about the available space. You will have to allocate that space + yourself using an assembler module with the necessary allocations, and a + linker configuration that matches the assembler module. The default value + for this option is 6 (bytes). + + If you don't know what all this means, please don't use this option. + + --rodata-name seg Set the name of the rodata segment (the segment used for readonly data). @@ -262,12 +297,6 @@ Here is a description of all the command line options: search list. - -o name - - Specify the name of the output file. If you don't specify a name, the - name of the C input file is used, with the extension replaced by ".s". - - -O, -Oi, -Or, -Os Enable an optimizer run over the produced code. @@ -372,12 +401,8 @@ and the one defined by the ISO standard:

The compiler does not support bit fields.

- Because of the "wrong" order of the parameters on the stack, there is - an additional macro needed to access parameters in a variable - parameter list in a C function. -

- Functions may not return structs (or unions), and structs may not be - passed as parameters by value. However, struct assignment *is* + C Functions may not return structs (or unions), and structs may not + be passed as parameters by value. However, struct assignment *is* possible.

Part of the C library is available only with fastcall calling @@ -485,9 +510,9 @@ This cc65 version has some extensions to the ISO C standard. _GCmd: - .byte 3 - .word $2000 - .word $3000 + .byte 3 + .word $2000 + .word $3000 Since the variable is of type __APPLE2__ + + This macro is defined if the target is the Apple ][ (-t apple2). + + __ATARI__ + + This macro is defined if the target is one of the Atari computers + (400/800/130XL/800XL). + + __ATMOS__ + + This macro is defined if the target is the Oric Atmos (-t atmos). + __CBM__ This macro is defined if the target system is one of the CBM targets. @@ -547,15 +585,6 @@ The compiler defines several macros at startup: This macro is defined if the target is the PET family of computers (-t pet). - __ATARI__ - - This macro is defined if the target is one of the Atari computers - (400/800/130XL/800XL). - - __APPLE2__ - - This macro is defined if the target is the Apple ][ (-t apple2). - __GEOS__ This macro is defined if you are compiling for the GEOS system (-t geos). @@ -768,6 +797,48 @@ id="pragma-staticlocals"

+Register variables

+ +The runtime for all supported platforms has 6 bytes of zero page space +available for register variables (this could be increased, but I think it's a +good value). So you can declare register variables up to a total size of 6 per +function. The compiler will allocate register space on a "first come, first +served" base and convert any Inline assembler

The compiler allows to insert assembler statements into the output file. The diff --git a/doc/cl65.sgml b/doc/cl65.sgml index c521b2d37..e98b10bd7 100644 --- a/doc/cl65.sgml +++ b/doc/cl65.sgml @@ -41,6 +41,7 @@ Short options: -l Create an assembler listing -m name Create a map file -o name Name the output file + -r Enable register variables -t sys Set the target system -v Verbose mode -vm Verbose map file @@ -77,6 +78,8 @@ Long options: --include-dir dir Set a compiler include directory path --listing Create an assembler listing --mapfile name Create a map file + --register-space b Set space available for register variables + --register-vars Enable register variables --rodata-name seg Set the name of the RODATA segment --signed-chars Default characters are signed --start-addr addr Set the default start address diff --git a/doc/coding.sgml b/doc/coding.sgml index 23f04ee7e..19c7074f0 100644 --- a/doc/coding.sgml +++ b/doc/coding.sgml @@ -312,6 +312,10 @@ As a general rule: Use register variables only for pointers that are dereferenced several times in your function, or for heavily used induction variables in a loop (with several 100 accesses). +When declaring register variables, try to keep them together, because this +will allow the compiler to save and restore the old values in one chunk, and +not in several. + And remember: Register variables must be enabled with