Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.sys.apple2.programmer > #342 > unrolled thread

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

Started byD Finnigan <dog_cow@macgui.com>
First post2012-08-06 20:15 +0000
Last post2012-08-07 07:56 -0600
Articles 3 — 3 participants

Back to article view | Back to comp.sys.apple2.programmer


Contents

  How-To: Use the cc65 compiler on Mac OS X for Apple II D Finnigan <dog_cow@macgui.com> - 2012-08-06 20:15 +0000
    Re: How-To: Use the cc65 compiler on Mac OS X for Apple II aiiadict@gmail.com - 2012-08-06 15:38 -0700
    Re: How-To: Use the cc65 compiler on Mac OS X for Apple II Egan Ford <datajerk@gmail.com> - 2012-08-07 07:56 -0600

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

FromD Finnigan <dog_cow@macgui.com>
Date2012-08-06 20:15 +0000
SubjectHow-To: Use the cc65 compiler on Mac OS X for Apple II
Message-ID<dog_cow-1344284156@macgui.com>
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/

[toc] | [next] | [standalone]


#343

Fromaiiadict@gmail.com
Date2012-08-06 15:38 -0700
Message-ID<1244a797-d106-4095-92fa-abbd9f448c6b@googlegroups.com>
In reply to#342
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

[toc] | [prev] | [next] | [standalone]


#345

FromEgan Ford <datajerk@gmail.com>
Date2012-08-07 07:56 -0600
Message-ID<jvr6r2$lhb$1@news.xmission.com>
In reply to#342
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

[toc] | [prev] | [standalone]


Back to top | Article view | comp.sys.apple2.programmer


csiph-web