Trying to compile a ProDOS program with cc65

6 posts / 0 new
Last post
Offline
Last seen: 5 years 6 months ago
Joined: Aug 9 2018 - 07:31
Posts: 4
Trying to compile a ProDOS program with cc65

I'm so close, but something is amiss when I'm trying to create a "Hello World" program for Prodos, that tuns

I'm using Applewin as an emulator and the latest Windows snapshot of cc65.

My simple hello world program is as follows:
---------------------
#include
void main()
{
printf("Hello World!\n");
}
-----------------------

I have created a new .po disk image and it has Prodos v 2.4.2 (The one made by John Brooks). I also added the loader.system file (Which was renamed to hello.system to load my program) In ciderPress I set it as a file type of SYS with an AUX of $2000

I compiled my hello world program with the following:
-----------------
cl65 -t apple2enh -C apple2enh.cfg hello.c
-----------------

I used Ciderpress to add the resultant "hello" file to the disk. I set it as filetype "BIN" and an aux of "$0803" (According to CC65, this is the default memory address for programs linked against apple2enh)

The loader announces it is "Loading "HELLO" and then bombs to the monitor.

I'm either not using the right compile switches, or my transfer of the program the disk via Ciderpress is incorrect. Can anyone give me some assistance on compiling this right? I figure this is an everyday exorcise for Apple II developers.

Offline
Last seen: 5 years 4 months ago
Joined: Jul 25 2018 - 23:41
Posts: 5
How does the loader work, how

How does the loader work? What is it supposed to do, and how does it know to load your hello.bin?

Also, does the hello.bin work from a regular brun command?

Offline
Last seen: 5 years 6 months ago
Joined: Aug 9 2018 - 07:31
Posts: 4
It doesn't "BRUN HELLO" gives

It doesn't "BRUN HELLO" gives me a syntax error. I decided to look at the compiled binary and it appears there is some header thing going on (The first byte is a 0, along with some address locations). All the tutorials are telling me use AppleCommander, which I could never get to run on my system (Clicking on the java icon did nothing)

Looking further, the hello program is almost 3K in size.

Looking on Applecommander's page, it appears to read this header, so I'm going to have to battle to get it running. It kind of irks me that that all the tutorials I'm finding assume I just have a linux box on hand to do all this. :/

Offline
Last seen: 5 years 6 months ago
Joined: Aug 9 2018 - 07:31
Posts: 4
As an update - I goit

As an update - I goit applecommander to run and I decided to follow a few tutorials. They all failed. I have an example one here (I modified it so that I could use the Windows command line)

First Applecommander makes invalid ProDOS disks. Using the -pro140 switch crates a disk that will dump to the monitor if you boot it (as opposed to getting a "PRODOS NOT FOUND"
Creating a blank prodos disk image in CiderPress works fine

Adding the file in AppleCommander using the --cc65 argument crates the BIN, but with an AUX of $0500

doing a BRUN from Applesoft results in a "NO BUFFERS AVAILABLE" error

I can't imagine it's this painful to get a cross compiler going on an apple...

Offline
Last seen: 5 years 4 months ago
Joined: Jul 25 2018 - 23:41
Posts: 5
Syntax error sounds like you

Syntax error sounds like you’re not using a basic version that has BRUN command, also,some older version won’t recognize the command if you type it lowercase. Make sure it’s uppercase. Are you using basic that came with Prodos ?

Offline
Last seen: 5 years 6 months ago
Joined: Aug 29 2018 - 19:19
Posts: 1
halkun wrote:I decided to

I decided to look at the compiled binary and it appears there is some header thing going on (The first byte is a 0, along with some address locations).

Yes, the binaries produced by cc65 are AppleSingle files. This basically means it has a header that contains the ProDOS metadata, such as type and aux type. (AppleSingle files can also do fancier things like represent Macintosh forked files, but that's not relevant here.)

The relevant command to use in AppleCommander is "-as" for AppleSingle files. For example,

ac -as mydisk.po hello < hello

For you, "ac" would probably need to be "ac.bat", the two-line MS-DOS batch file given on the AppleCommander install page.

According to the CiderPress features page, CiderPress supports AppleSingle files, so it should be possible to use CiderPress, too. However, I use AppleCommander, because I am on Mac OS X, and CiderPress is a Windows-only program.

I've used the AppleCommander "-pro140" option to make ProDOS disks, and I haven't had any trouble with them, although I haven't tried booting them. It sounds like AppleCommander doesn't put the bootloader in block 0. If you want to create a bootable disk, just start from an existing bootable ProDOS disk image.

Log in or register to post comments