-
Notifications
You must be signed in to change notification settings - Fork 50
/
ccompilers.tex
47 lines (38 loc) · 2.16 KB
/
ccompilers.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
\chapter{C and C-Like Compilers}
Short answer: CC65 and KickC both work on the MEGA65.
Both CC65 and KickC are known to work on the MEGA65. However, both by
default have only a C64 memory model, and use only 6502 opcodes.
It would be super for someone to create a C65 memory configuration for
CC65, and should not be too hard to do.
CC65 supports overlays, which
could be powerfully used with the MEGA65's extra memory to allow
programs larger than 64KB. However, this would require writing a
suitable loader for such programs, which also does not yet exist.
Similarly, modifying the code
generator of CC65 to use 45GS02 features would not be particularly
difficult to do, and would help to overcome the otherwise horribly
slow and bloated code that CC65 produces. Also adding first-class
support for the 45GS02 CPU features in CA65 (or perhaps even better,
making CC65 produce ACME compatible assembly output) would be of
tremendous advantage, and not particularly hard to do. These would
all be great tasks to tackle while you wait for your MEGA65 DevKit to
arrive!
An example template for a C program that can be compiled using CC65
and executed on the MEGA65 can be found in the repository
\url{https://github.com/MEGA65/hello-world}. This repository will
even download and compile CC65, if you don't already have it installed
on your system. This repository should work on Linux and Mac, and
on Windows under the Windows Subsystem for Linux (WSL).
The LLVM-MOS project (\url{https://llvm-mos.org}) has
a MEGA65 target that has been tested with C99, C++11, and Rust.
The LLVM MOS compiler has support for 45GS02 instructions
(\texttt{-mcpu=mos45gs02}) and comes with an assembler and disassembler.
Pre-compiled binaries of the SDK are available for Linux, Windows, and macOS.
\section{MEGA65 libc}
A C library is being developed for the MEGA65, and which already
includes a number of useful features. This library is available from
\url{http://github.com/mega65/mega65-libc}. The procedures,
functions and definitions it provides are documented in a separate
chapter.
The MEGA65 libc is currently available only for LLVM and CC65, although we would
welcome someone maintaining a KickC port of it.