Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How-To: Use the cc65 compiler on Mac OS X for Apple II

250 views
Skip to first unread message

D Finnigan

unread,
Aug 6, 2012, 4:15:57 PM8/6/12
to
Learn how to compile and execute a C program on the Apple II using Mac OS X
and cc65.

Today we are going to learn how to compile a C program that will run under
ProDOS 8 on the Apple II using Mac OS X and cc65. Since we will be
programming on a Mac with a target of the Apple II, we are performing what
is known as cross-development.

I will assume that you already know how to program in C. By extension, if
you know C, then you probably are also familiar with the Terminal and the
Unix shell. Secondly, I assume that you are using either the Virtual ][ or
Sweet16 emulators to test your programs.

Setting Up The Development Environment

Before you can start, you will need to download and configure several free
software programs:

- XCode (Mac OS X Developer Tools)
- AppleCommander (A disk image tool in Java)
- cc65 (The 6502 C compiler)


Read the full, step-by-step article at Mac GUI:
http://macgui.com/kb/article/761

--
]DF$
Apple II Book: http://macgui.com/newa2guide/
Mac GUI Vault: http://macgui.com/vault/
Usenet Archive: http://macgui.com/usenet/

aiia...@gmail.com

unread,
Aug 6, 2012, 6:38:31 PM8/6/12
to
On Monday, August 6, 2012 1:15:57 PM UTC-7, D Finnigan wrote:
> Learn how to compile and execute a C program on the Apple II using Mac OS X
>
> and cc65.
>

Glenn Jones of A2retrosystems.com wrote a tutorial on using CC65 from CYGWIN on a windows machine..

Rich

Egan Ford

unread,
Aug 7, 2012, 9:56:50 AM8/7/12
to
On 8/6/12 2:15 PM, D Finnigan wrote:
> Learn how to compile and execute a C program on the Apple II using Mac OS X
> and cc65.
>
> Today we are going to learn how to compile a C program that will run under
> ProDOS 8 on the Apple II using Mac OS X and cc65. Since we will be
> programming on a Mac with a target of the Apple II, we are performing what
> is known as cross-development.
>
> I will assume that you already know how to program in C. By extension, if
> you know C, then you probably are also familiar with the Terminal and the
> Unix shell. Secondly, I assume that you are using either the Virtual ][ or
> Sweet16 emulators to test your programs.
>
> Setting Up The Development Environment
>
> Before you can start, you will need to download and configure several free
> software programs:
>
> - XCode (Mac OS X Developer Tools)
> - AppleCommander (A disk image tool in Java)
> - cc65 (The 6502 C compiler)
>
>
> Read the full, step-by-step article at Mac GUI:
> http://macgui.com/kb/article/761
>


A few suggestions from a frequent cc65/ca65 user:

1. XCode is huge. While not a problem for those of us that use it
frequently, for the rest, it is ~10G of disk space + ~2G if you forget
to remove the installer. I think a great addition to your article would
be a cc65 + gnu Make distribution. This would greatly simplify matters
for first-timers and may accelerate interest.


2. I use the following in my .profile (or .bash_common in my case) for
AppleCommander:

alias applecmd='java -jar
/Applications/AppleCommander.app/Contents/Resources/Java/AppleCommander.jar'

This changes "java -jar $AC -v" to just "applecmd -v" -- less to type,
less to remember.


3. One of the challenges with cc65/ca65 is rapid testing. Make, boot,
run, make, boot, run, etc... can be a bit time consuming. If you have
c2t installed (http://asciiexpress.net/files) this testing can be
accelerated with:

c2t -p progbinary | pbcopy

Then on the emulator you type:

CALL -151 (if not already at monitor) then CMD-V to paste in the monitor
code. Lastly for C code (varies with assembly) type 803G. Pasting in
OpenEmulator and Virtual ][ are much faster than Sweet16. With Virtual
][ if you have your speed set to 3, pasting in your compiled code
directly into the monitor takes a second.

c2t will read the 4 byte header from the cc65 binary to figure out the
length and start address automatically.


4. The cc65 distribution has some great example programs you may want
to point out.


5. cc65 cannot create 65816 binaries for the IIgs, however ca65 can.

Example header:

.P816 ; 65816
.A16 ; 16-bit accumulator
.I16 ; 16-bit index registers

rep #$FF ; set all status flags to 0
xce ; exchange emulation/carry flag
; to switch to 65816 mode

0 new messages