Go to file
Stephen Heumann 83537fd3c7 Disable a peephole optimization that can produce bad code.
The optimization applies to code sequences like:
	dec abs
	lda abs
	beq ...
where the dec and lda were supposed to refer to the same location.

There were two problems with this optimization as written:
-It considered the dec and lda to refer to the same location even if they were actually references to different elements of the same array.
-It did not work in the case where the A register value was needed in subsequent code.

The first of these was already an issue in previous ORCA/C releases, as in the following example:

#pragma optimize -1
int x[2] = {0,0};
int main(void) {
        --x[0];
        if (x[1] != 0)
                return 123;
        return 0; /* should return 0 */
}

I do not believe the second problem was triggered by any code sequences generated in previous releases of ORCA/C, but it can be triggered after commit 4c402fc88, e.g. by the following example:

#pragma optimize -1
int x = 1;
int main(void) {
        int y = 123;
        --x;
        return x == 0; /* should return 1 */
}

Since the circumstances where this peephole optimization was triggered validly are pretty obscure, just disabling it should have a minimal impact on the generated code.
2024-03-17 21:31:18 -05:00
C.Samples Address issues in samples detected by new lint checks. 2023-04-23 19:35:16 -05:00
ORCACDefs Correct a misspelled error code in <gsos.h>. 2024-01-18 17:55:41 -06:00
Tests Change division-by-zero tests to cases requiring a constant expression. 2024-02-27 13:06:45 -06:00
obj ORCA/C 2.1.0 source from the Opus ][ CD 2017-10-01 17:47:47 -06:00
Asm.pas Count variables referenced in assembly code as used. 2022-12-13 19:04:18 -06:00
C.Read.Me Update readme files for version 2.2.1. 2024-02-28 20:11:13 -06:00
C.Update.ReadMe Update readme files for version 2.2.1. 2024-02-28 20:11:13 -06:00
CC.pas Add lint option to check for unused variables. 2022-12-12 21:47:32 -06:00
CC.rez Update version number for ORCA/C 2.2.1 development. 2024-01-15 21:47:00 -06:00
CC.rez2 Change all text/source files to LF line endings. 2017-10-21 18:40:19 -05:00
CCommon.asm Use an improved hash function for symbol tables. 2023-03-06 21:54:14 -06:00
CCommon.macros Change all text/source files to LF line endings. 2017-10-21 18:40:19 -05:00
CCommon.pas Update version number for ORCA/C 2.2.1 development. 2024-01-15 21:47:00 -06:00
CGC.asm Simplify code for writing out extended constants. 2023-04-04 18:11:04 -05:00
CGC.macros Do not use FX2X to copy floating-point values. 2023-04-02 16:34:53 -05:00
CGC.pas Simplify code for writing out extended constants. 2023-04-04 18:11:04 -05:00
CGI.Comments Add debugging option to detect illegal use of null pointers. 2023-02-12 18:56:02 -06:00
CGI.Debug Fix issues with type names in the third expression of a for loop. 2024-03-13 22:09:25 -05:00
CGI.pas Fix issues with type names in the third expression of a for loop. 2024-03-13 22:09:25 -05:00
Charset.pas Support UTF-8/16/32 string literals and character constants (C11). 2021-10-11 20:54:37 -05:00
DAG.pas Optimize double stores to just use integer operations. 2023-06-17 19:24:50 -05:00
DAG2.pas Change all text/source files to LF line endings. 2017-10-21 18:40:19 -05:00
Debugger.md Update the debugging format for long long values. 2021-01-31 20:26:51 -06:00
Exp.macros Evaluate arithmetic and shifts in long long constant expressions. 2021-02-14 20:39:35 -06:00
Expression.asm Evaluate 64-bit comparisons in constant expressions. 2021-02-16 23:11:41 -06:00
Expression.pas Avoid possible errors when using postfix ++/-- on pointer expressions. 2024-02-09 20:45:14 -06:00
Gen.pas Generate better code for most unsigned 32-bit comparisons. 2024-03-10 21:24:33 -05:00
Header.pas Update version number for ORCA/C 2.2.1 development. 2024-01-15 21:47:00 -06:00
Header2.pas Change all text/source files to LF line endings. 2017-10-21 18:40:19 -05:00
LICENSE ORCA/C 2.1.0 source from the Opus ][ CD 2017-10-01 17:47:47 -06:00
MM.asm Move some more code out of the blank segment to make space for static data. 2017-10-21 20:36:21 -05:00
MM.macros Change all text/source files to LF line endings. 2017-10-21 18:40:19 -05:00
MM.pas Move memory allocation code to a new function in MM. 2022-12-03 18:50:26 -06:00
Manual.docx Add const qualifiers in some non-standard function declarations. 2023-07-30 10:33:47 -05:00
Native.asm Avoid out-of-range branches around asm code using dcl directives. 2022-10-13 18:00:16 -05:00
Native.macros Change all text/source files to LF line endings. 2017-10-21 18:40:19 -05:00
Native.pas Disable a peephole optimization that can produce bad code. 2024-03-17 21:31:18 -05:00
Native2.pas Change all text/source files to LF line endings. 2017-10-21 18:40:19 -05:00
ObjOut.asm Make the object buffer dynamically resizable. 2022-12-06 21:49:20 -06:00
ObjOut.macros Expand the size of the object buffer from 64K to 128K, and use 32-bit values to track related sizes. 2017-10-21 20:36:21 -05:00
ObjOut.pas Never make the segment in the root file dynamic. 2022-12-11 14:46:38 -06:00
ObjOut2.asm Expand all tabs in assembly files to spaces. 2018-02-10 21:55:24 -06:00
ObjOut2.pas Change all text/source files to LF line endings. 2017-10-21 18:40:19 -05:00
Parser.pas Fix issues with type names in the third expression of a for loop. 2024-03-13 22:09:25 -05:00
Printf.pas Update format checker to reflect that L length modifier now works in scanf. 2023-06-10 21:27:00 -05:00
README.md Update script for setting filetypes. 2023-08-06 17:50:26 -05:00
Scanner.asm Do not give an error for files that end with an #endif with no newline. 2023-03-15 20:11:39 -05:00
Scanner.debug Change all text/source files to LF line endings. 2017-10-21 18:40:19 -05:00
Scanner.macros Allow line continuations within // comments. 2022-12-04 23:16:06 -06:00
Scanner.pas Use more correct logic for expanding macros in macro parameters. 2024-02-26 22:31:46 -06:00
Symbol.Print Record volatile and restrict qualifiers in types. 2021-08-30 18:19:58 -05:00
Symbol.asm Maintain a pool of empty symbol tables that can be reused. 2022-12-13 21:14:23 -06:00
Symbol.macros Change all text/source files to LF line endings. 2017-10-21 18:40:19 -05:00
Symbol.pas Avoid spurious undefined variable errors for functions returning structs/unions. 2023-04-06 18:52:45 -05:00
Table.asm Treat unary + as an actual operator, not a no-op. 2022-12-09 19:03:38 -06:00
Table.macros Recognize the new keywords from C99 and C11 as such. 2020-01-03 22:48:53 -06:00
Table.pas Add a command-line option to select the C standard to use. 2022-12-07 21:35:15 -06:00
Tech.Support Update documentation for ORCA/C 2.2.0 release. 2023-07-20 14:14:07 -05:00
backup Change all text/source files to LF line endings. 2017-10-21 18:40:19 -05:00
cc.notes Disable a peephole optimization that can produce bad code. 2024-03-17 21:31:18 -05:00
count Change all text/source files to LF line endings. 2017-10-21 18:40:19 -05:00
linkit Add initial support for universal character names. 2020-01-19 23:59:54 -06:00
linkit2 Change all text/source files to LF line endings. 2017-10-21 18:40:19 -05:00
make Add initial support for universal character names. 2020-01-19 23:59:54 -06:00
make2 Change all text/source files to LF line endings. 2017-10-21 18:40:19 -05:00
settypes Update script for setting filetypes. 2023-08-06 17:50:26 -05:00
smake Change all text/source files to LF line endings. 2017-10-21 18:40:19 -05:00

README.md

ORCA-C

Apple IIGS ORCA/C Compiler, an ANSI C compiler for the 65816 with libraries for the Apple IIGS

Binary downloads for the latest ORCA/C release are on the releases page.

If you would like to make changes to this compiler and distribute them to others, feel free to submit them here. If the changes apply to compilation on and for an Apple IIGS, they will generally be approved for distribution on the master branch unless the changes deviate significantly from the ANSI C standard. For changes that deviate form ANSI C or changes that retarget the compiler to run on a different platform or generate code for a different platform, the project will either be forked or a new repository will be created, as appropriate.

The general conditions that must be met before a change is released on master are:

  1. The modified compiler must compile under the currently released version of ORCA/M and ORCA/Pascal.

  2. All samples from the original ORCA/C distribution must compile and execute under the modified compiler, or the sample must be updated, too.

  3. The compiler must pass the ORCA/C tset suite, or the test suite must be suitably modified, too.

  4. The compiler must work with the current ORCA/C libraries, or the libraries must be modified, too.

Contact support@byteworks.us if you need contributor access.

A complete distribution of the ORCA languages, including installers and documentation, is available from the Juiced GS store at https://juiced.gs/store/category/software/. It is distributed as part of the Opus ][ package.

Line Endings and File Types

The text and source files in this repository originally used CR line endings, as usual for Apple II text files, but they have been converted to use LF line endings because that is the format expected by Git. If you wish to move them to a real or emulated Apple II and build them there, you will need to convert them back to CR line endings.

If you wish, you can configure Git to perform line ending conversions as files are checked in and out of the Git repository. With this configuration, the files in your local working copy will contain CR line endings suitable for use on an Apple II. To set this up, perform the following steps in your local copy of the Git repository (these should be done when your working copy has no uncommitted changes):

  1. Add the following lines at the end of the .git/config file:
[filter "crtext"]
	clean = LC_CTYPE=C tr \\\\r \\\\n
	smudge = LC_CTYPE=C tr \\\\n \\\\r
  1. Add the following line to the .git/info/attributes file, creating it if necessary:
* filter=crtext
  1. Run the following commands to convert the existing files in your working copy:
rm .git/index
git checkout HEAD -- .

Alternatively, you can keep the LF line endings in your working copy of the Git repository, but convert them when you copy the files to an Apple II. There are various tools to do this. One option is udl, which is available both as a IIGS shell utility and as C code that can be built and used on modern systems.

In addition to converting the line endings, you will also have to set the files to the appropriate file types before building ORCA/C on a IIGS. The included settypes script (for use under the ORCA shell) can be used to do this.