1
0
mirror of https://github.com/RevCurtisP/C02.git synced 2024-11-15 17:08:51 +00:00
C syntax compiler optimized for the 6502 microprocessor
Go to file
2018-01-28 14:44:10 -05:00
apple1/oldclude Updates to compiler header files 2018-01-28 13:38:17 -05:00
doc Removed ptrsav() and ptrrst() from pointer library 2018-01-28 14:29:22 -05:00
include Removed ptrsav() and ptrrst() from pointer library 2018-01-28 14:29:22 -05:00
test Updates to compiler header files 2018-01-28 13:38:17 -05:00
vcs Added Atari 2600 C02 test programs vcs/*.c02 2018-01-28 14:44:10 -05:00
vic20 Added VIC-20 specific C02 compile scripts vic20/c02.bat and vic20/c02.sh 2018-01-28 14:38:11 -05:00
.gitignore Added .gitignore to cache 2018-01-28 14:39:31 -05:00
asm6502.c Numerous modifications 2017-06-26 20:16:23 -04:00
asm.c Numerous modifications 2017-06-26 20:16:23 -04:00
asm.h Save entire project before changing condition parser to use JMP 2017-04-22 14:39:52 -04:00
c02.bat Added DOS batch, Bash script, and Notepad++ language files 2018-01-28 13:43:17 -05:00
c02.c Fixed bug with constant parsing and array indexes. 2018-01-28 13:27:33 -05:00
c02.exe Added DOS batch, Bash script, and Notepad++ language files 2018-01-28 13:43:17 -05:00
c02.lang Added DOS batch, Bash script, and Notepad++ language files 2018-01-28 13:43:17 -05:00
c02.ppj Added Pelles C IDE project files 2018-01-28 13:32:49 -05:00
c02.ppx Added Pelles C IDE project files 2018-01-28 13:32:49 -05:00
c02.sh Added DOS batch, Bash script, and Notepad++ language files 2018-01-28 13:43:17 -05:00
c02.tag Added DOS batch, Bash script, and Notepad++ language files 2018-01-28 13:43:17 -05:00
common.c Save entire project before changing condition parser to use JMP 2017-04-22 14:39:52 -04:00
common.h Updates to compiler header files 2018-01-28 13:38:17 -05:00
cond.c Numerous modifications 2017-06-26 20:16:23 -04:00
cond.h Implemented do, while, and for 2017-04-30 21:17:50 -04:00
expr.c Fixed bug with constant parsing and array indexes. 2018-01-28 13:27:33 -05:00
expr.h Numerous modifications 2017-06-26 20:16:23 -04:00
files.c Save entire project before changing condition parser to use JMP 2017-04-22 14:39:52 -04:00
files.h Save entire project before changing condition parser to use JMP 2017-04-22 14:39:52 -04:00
include.c Fixed bug with constant parsing and array indexes. 2018-01-28 13:27:33 -05:00
include.h Numerous modifications 2017-06-26 20:16:23 -04:00
label.c Numerous modifications 2017-06-26 20:16:23 -04:00
label.h Numerous modifications 2017-06-26 20:16:23 -04:00
parse.c Fixed bug with constant parsing and array indexes. 2018-01-28 13:27:33 -05:00
parse.h Updates to compiler header files 2018-01-28 13:38:17 -05:00
README.md Created README.md 2018-01-28 14:06:08 -05:00
stmnt.c Fixed bug with constant parsing and array indexes. 2018-01-28 13:27:33 -05:00
stmnt.h Numerous modifications 2017-06-26 20:16:23 -04:00
test.asm
vars.c Fixed bug with constant parsing and array indexes. 2018-01-28 13:27:33 -05:00
vars.h Updates to compiler header files 2018-01-28 13:38:17 -05:00

C02

C02 is a simple C-syntax language designed to generate highly optimized code for the 6502 microprocessor. The C02 specification is a highly specific subset of the C standard with some modifications and extensions

Purpose

Why create a whole new language, particularly one with severe restrictions, when there are already full-featured C compilers available? It can be argued that standard C is a poor fit for processors like the 6502. The C was language designed to translate directly to machine language instructions whenever possible. This works well on 32-bit processors, but requires either a byte-code interpreter or the generation of complex code on a typical 8-bit processor. C02, on the other hand, has been designed to translate directly to 6502 machine language instructions.

The C02 language and compiler were designed with two goals in mind.

The first goal is the ability to target machines with low memory: a few kilobytes of RAM (assuming the generated object code is to be loaded into and ran from RAM), or as little as 128 bytes of RAM and 2 kilobytes of ROM (assuming the object code is to be run from a ROM or PROM).

The compiler is agnostic with regard to system calls and library functions. Calculations and comparisons are done with 8 bit precision. Intermediate results, array indexing, and function calls use the 6502 internal registers. While this results in compiled code with virtually no overhead, it severely restricts the syntax of the language.

The second goal is to port the compiler to C02 code so that it may be compiled by itself and run on any 6502 based machine with sufficient memory and appropriate peripherals. This slightly restricts the implementation of code structures.