CC65 programming environment

discussion of games, software, hardware & emulators relating to the Acorn Atom and Acorn System machines.
Post Reply
User avatar
oss003
Posts: 2782
Joined: Tue Jul 14, 2009 11:57 am
Location: Netherlands
Contact:

CC65 programming environment

Post by oss003 » Sat Apr 30, 2016 6:33 pm

Hi guys,

I'm home again ...... :)
Here is my CC65 environment, it is working in Windows32 in a CMD window.

Changes:
========
- Downloaded MAKE.EXE v3.78.1 for Windows32
- Change makefiles to work with DOS

Create Atom library file:
=========================

- Enter directory : CD LIBSRC
- Clean sources : MAKE CLEAN
- Create library : MAKE ATOMLIB

Build examples:
===============

- Enter directory : CD TESTCODE\LIB
- Clean sources : MAKE CLEAN
- Create examples : MAKE ALL

Add header to examples:
=======================
- 22 byte header has to be added
00-15, Filename terminated with $00
16-17, Loadaddress lb/hb ($2902)
18-19, Execaddress lb/hb ($2902)
20-21, Length lb/hb
- Run example in Atomulator
- Some programs need DOS enabled for Posix IO

Points of attention:
====================
- Upper-/lower case, all uppercase and inverted lowercase?
- Invert characters, is lowercase in Atom mode?
- Execution of \n CR or CRLF?
- Time -> IRQ routine running at 50 Hz?
- Use AtoMMC instead of DOS for POSIX IO
- ATOM.CFG, what is the best memory usage.

https://drive.google.com/file/d/0B7dXeO ... sp=sharing

Greetings
Kees

janrinze
Posts: 57
Joined: Sat Mar 19, 2016 6:38 am
Contact:

Re: CC65 programming environment

Post by janrinze » Sat Apr 30, 2016 10:42 pm

Thanks for putting the whole environment online.

I found the cc65 source repository on github and made a fork at https://github.com/janrinze/cc65
This fork now contains the first step to having the Acorn Atom integrated in cc65.

I have only tested under Linux so I am not sure how it will compile on Windows.

On Linux I now can do:

------
/* hello.c */
#include <stdio.h>

int main(int argc,char** argv)
{
printf("HELLO WORLD.\n");
return 0;
}

cc65 -Oi --target atom ./hello.c
ca65 --target atom hello.s
ld65 --target atom -o HELLO hello.o --lib atom.lib

The file HELLO is not yet adapted for MMC usage but should be loaded at #2902 and exec #2902
--target atom will set __ATOM__ in C and assembler.

User avatar
jgharston
Posts: 3248
Joined: Thu Sep 24, 2009 11:22 am
Location: Whitby/Sheffield
Contact:

Re: CC65 programming environment

Post by jgharston » Sat Apr 30, 2016 11:36 pm

janrinze wrote:I found the cc65 source repository on github and made a fork at https://github.com/janrinze/cc65
This fork now contains the first step to having the Acorn Atom integrated in cc65.
I started building the files to target the BBC (checks code... eek!) almost ten years ago. :( Really should get around to finishing them.

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.25
(C) Copyright J.G.Harston 1989,2005-2015
>_

User avatar
oss003
Posts: 2782
Joined: Tue Jul 14, 2009 11:57 am
Location: Netherlands
Contact:

Re: CC65 programming environment

Post by oss003 » Sun May 01, 2016 8:20 am

IIRC Dominic Beesley also has a BBC port of CC65.

Greetings
Kees

janrinze
Posts: 57
Joined: Sat Mar 19, 2016 6:38 am
Contact:

Re: CC65 programming environment

Post by janrinze » Sat May 28, 2016 10:22 am

I have been improving on the cc65 compiler setup for the atom and learned a few things along the way.

1: The C compiler isn't very efficient but builds working code.
2: ZP memory needs to be defined in the atom.lib using exports with prepended underscores
3: Using a start address of #0800 works and allows me to test a rudimentary basic editor that works on basic programs at #2900
4: Roland's Atom is great for testing with software on an SDcard. (I still need to learn about the serial port)
5: Don't use the keyboard routine but write your own, it's faster and escape can be more easily trapped.
6: Write routines in inline assembler when speed matters.
7: Use 'static' keyword in C as often as possible, it helps the compiler to optimize.
8: The Atom is still a great platform! :-)

I am working on a full ZP reference for the C compiler that can be included to facilitate easy ZP usage.
Calls to the C,D and F roms should get a nice include file too. They need to be exported in the atom.lib and a full set of references in a include file for C.

It's probably going to take a lot more time but I am already happy with the results so far.
Hopefully in the near future I can upload a demo of the BASIC editor and get some feedback :-)

User avatar
oss003
Posts: 2782
Joined: Tue Jul 14, 2009 11:57 am
Location: Netherlands
Contact:

Re: CC65 programming environment

Post by oss003 » Sat May 28, 2016 10:32 am

janrinze wrote:Hopefully in the near future I can upload a demo of the BASIC editor and get some feedback :-)
That would be great...
You can find the sources for serial communication in hoglet's FPGA ROM in the serial.inc file:

https://github.com/hoglet67/AtomFpga/tr ... /fpgautils

Serial communication works great but serial in lacks a handshake signal so all incoming serial data has to be processed real time within the baudrate timing.

Greetings
Kees

janrinze
Posts: 57
Joined: Sat Mar 19, 2016 6:38 am
Contact:

Re: CC65 programming environment

Post by janrinze » Wed Jun 29, 2016 6:05 pm

updates for CC65 at:
https://github.com/janrinze/cc65

Current changes are simple, the atomlib gets built out of the box.
Headers for ATOMMC still need to be added and the current start address of code is #800 to ensure that even large projects will have a decent amount of RAM available.
Next to that small applications can be loaded without overwriting the BASIC space at #2900
Heap is at #7FFF downwards.

There is plenty of opportunities to tweak things and the zpdefs are far from filled up yet. (Needed to interface to C programs.)

User avatar
oss003
Posts: 2782
Joined: Tue Jul 14, 2009 11:57 am
Location: Netherlands
Contact:

Re: CC65 programming environment

Post by oss003 » Wed Jun 29, 2016 7:35 pm

Here is a nice test project for CC65 ...... 8)

https://github.com/StewBC/manicminer

Greetings
Kees

janrinze
Posts: 57
Joined: Sat Mar 19, 2016 6:38 am
Contact:

Re: CC65 programming environment

Post by janrinze » Wed Jun 29, 2016 9:45 pm

oss003 wrote:Here is a nice test project for CC65 ...... 8)

https://github.com/StewBC/manicminer

Greetings
Kees
Unfortunately that code is a bit hard to compile due to some strange way of coding.
Also the code is using memory mapped video in a C64 way so it will require porting. (can try this sometime soon)

janrinze
Posts: 57
Joined: Sat Mar 19, 2016 6:38 am
Contact:

Re: CC65 programming environment

Post by janrinze » Wed Jun 29, 2016 9:52 pm

Another update for CC65:

The generation of the ATOMMC header works now but will have a default name CC65GEN.
I still need to figure out how the linker exposes the output filename to the assembler.
load address, start address and size are correctly setup in the header and compilation is now very easy.

Code: Select all

/* hello.c */
#include <stdio.h>

int main(int argc,char**argv)
{
    printf("helloworld");
    return 0;
}

Code: Select all

cl65 -t atom hello.c -o HELLO
On the Atom:

Code: Select all

>*HELLO
helloworld>
Looks quite simple and effective to me :-)

User avatar
roland
Posts: 2941
Joined: Thu Aug 29, 2013 8:29 pm
Location: Born (NL)
Contact:

Re: CC65 programming environment

Post by roland » Thu Jun 30, 2016 7:02 pm

That looks fantastic =D>

What about floating point calculations and graphics?
256K + 6502 Inside
MAN WOMAN :shock:

User avatar
oss003
Posts: 2782
Joined: Tue Jul 14, 2009 11:57 am
Location: Netherlands
Contact:

Re: CC65 programming environment

Post by oss003 » Fri Jul 01, 2016 11:05 am

Floating point is supported but I'm not sure it's working for the Atom and there is a graphics TGI library available but has to be adapted for the Atom.

Greetings
Kees

janrinze
Posts: 57
Joined: Sat Mar 19, 2016 6:38 am
Contact:

Re: CC65 programming environment

Post by janrinze » Fri Jul 01, 2016 3:45 pm

Graphics can be added, it's just a matter of adding a library.
I don't think that cc65 supports floating point but with a library it's possible to add it.
Since both are supported by BASIC a wrapper could be devised that uses calls to the BASIC equivalents.

User avatar
oss003
Posts: 2782
Joined: Tue Jul 14, 2009 11:57 am
Location: Netherlands
Contact:

Re: CC65 programming environment

Post by oss003 » Sat Jul 02, 2016 6:12 pm

The TGI library is included but you have to write a graphics driver for the Atom.
TGI functions in tgi-kernal.s are:

Code: Select all

; Jump table for the driver functions.

jumpvectors:
tgi_install:        jmp     $0000
tgi_uninstall:      jmp     $0000
tgi_init:           jmp     $0000
tgi_done:           jmp     $0000
tgi_geterror:       jmp     $0000
tgi_control:        jmp     $0000
tgi_clear:          jmp     $0000
tgi_setviewpage:    jmp     $0000
tgi_setdrawpage:    jmp     $0000
tgi_setcolor:       jmp     $0000
tgi_setpalette:     jmp     $0000
tgi_getpalette:     jmp     $0000
tgi_getdefpalette:  jmp     $0000
tgi_setpixel:       jmp     $0000
tgi_getpixel:       jmp     $0000
tgi_line:           jmp     $0000
tgi_bar:            jmp     $0000
tgi_textstyle:      jmp     $0000
tgi_outtext:        jmp     $0000
tgi_irq:            .byte $60, $00, $00       ; RTS plus two dummy bytes
Gregg King added Floating Point functions to CC65: https://github.com/cc65/cc65/blob/maste ... ommon/fp.h

Greetings
Kees

Fabrizio
Posts: 10
Joined: Fri Apr 27, 2018 4:33 pm
Contact:

Re: CC65 programming environment

Post by Fabrizio » Wed Nov 07, 2018 2:14 pm

Hi guys,

Any progress on this?
Any hope to see this merged in main CC65?

It would be really cool!

Fabrizio

Post Reply