Jump to content
JesperGravgaard

KickC Optimizing C-Compiler now supports Atari 8bit XL/XE

Recommended Posts

Hi all,


KickC is a C-compiler that creates optimized 6502 assembler.


The newest release (version 0.8.3) adds direct support for developing for the Atari 8bit XL/XE platform. The compiler includes header-files and linker-files for the chipset of Atari 8bit XL/XE. It also includes a few example-programs that work in an emulator and on the real platform (tested using UNOcart A8 on 130XE and 800XL).


You can get it here: https://gitlab.com/camelot/kickc


PS. I am the author of KickC.
 

Screenshot 2020-09-26 at 23.50.00.png

Screenshot 2020-09-26 at 23.48.46.png

  • Like 9
  • Thanks 4

Share this post


Link to post
Share on other sites
7 hours ago, JesperGravgaard said:

Hi all,


KickC is a C-compiler that creates optimized 6502 assembler.


The newest release (version 0.8.3) adds direct support for developing for the Atari 8bit XL/XE platform. The compiler includes header-files and linker-files for the chipset of Atari 8bit XL/XE. It also includes a few example-programs that work in an emulator and on the real platform (tested using UNOcart A8 on 130XE and 800XL).


You can get it here: https://gitlab.com/camelot/kickc


PS. I am the author of KickC.
 

Screenshot 2020-09-26 at 23.50.00.png

Screenshot 2020-09-26 at 23.48.46.png



Hey Rex,

cool. Thanks for the A8 building options.

Cheers

 

Share this post


Link to post
Share on other sites
7 hours ago, zbyti said:

@JesperGravgaard

 

Unfortunately, I don't know C very well, but if you would like to add (or someone else) more examples for A8, I recommend review:

 

https://github.com/tebe6502/Mad-Pascal/tree/master/samples

https://github.com/zbyti/a8-mad-pascal-bench-suite

https://github.com/zbyti/a8-millfork-playground

well... just my 2 cents... as its about KickC Pascal etc doesn't make sense in this thread? as its not about programming languages in total? ;) 

  • Confused 1

Share this post


Link to post
Share on other sites
4 hours ago, Heaven/TQA said:

well... just my 2 cents... as its about KickC Pascal etc doesn't make sense in this thread? as its not about programming languages in total? ;) 

It is difficult to start programming on a given platform without enough simple examples.

 

I know it because I started programming on A8 in May this year with Action! (I have tried also: Quick and PL65) and only thanks to a large number of examples I slowly began to understand what was going on.

 

I know very well that those of you who have been programming for a long time do not need such examples, but let's do something for the new ones.

 

I did a similar job for A8 and Millfork, 90% of this examples is my work https://github.com/KarolS/millfork/tree/master/examples/a8

 

Why KickC can't have similar ones to make programming easier for beginners?

 

I just pointed out that more examples could be written and indicated where to get them from.

Edited by zbyti
Action!
  • Like 1

Share this post


Link to post
Share on other sites
3 hours ago, Cyprian_K said:

what about Lynx support?

Supporting the Lynx looks like it is very doable. The CPU is 65CS02 - almost identical to 65C02, which is already supported by the compiler.

So at a glance it seems we only need to add a linker configuration and header-files for the chipset of the Lynx.

I prefer to be able to test on real hardware myself - and I do not currently have an Atari Lynx. I will add builtin Lynx support it to my TODO-list and start looking for an affordable Lynx!

In the meantime it is possible for you (or anyone else interested) to implement the platform support. The target platform file format used by KickC is a JSON file specifying important properties (such as CPU, charset encoding, file extension and emulator) a linker file (in KickAss segment format) and header-files / library implementation. All these files are readable and user-modifyable in the binary release (in the /target/ and the /include/ and /lib/ folders respectively.)

  • Thanks 1

Share this post


Link to post
Share on other sites

Hi good afternoon.

 

your kickc makes a good impression.
the two demos have few bytes, which is wonderful.
89 bytes and 149 bytes.

 

greeting

Share this post


Link to post
Share on other sites
On 9/27/2020 at 3:58 AM, zbyti said:

It is difficult to start programming on a given platform without enough simple examples.

 

I know it because I started programming on A8 in May this year with Action! (I have tried also: Quick and PL65) and only thanks to a large number of examples I slowly began to understand what was going on.

 

I know very well that those of you who have been programming for a long time do not need such examples, but let's do something for the new ones.

 

I did a similar job for A8 and Millfork, 90% of this examples is my work https://github.com/KarolS/millfork/tree/master/examples/a8

 

Why KickC can't have similar ones to make programming easier for beginners?

 

I just pointed out that more examples could be written and indicated where to get them from.

C is a tough language to learn by only reading example code.   It's syntax is rather terse, and very flexible in how you can write it.

 

I would recommend reading C lessons online to learn how put together simple programs, structures, pointers, etc.

 

Since I've been using C so long now, the sample code posted here makes sense, but when I was starting out, I found it to be a rather frustrating language to get into.   Of course it didn't help back then that all the good compilers cost money, and the free ones weren't so complete...

 

Share this post


Link to post
Share on other sites

This is great. Here I am just rediscovering atari, learning mad pascal, and along comes a c compiler!

 

For anyone interested, I downloaded the standard c/c++ eclipse IDE and use the following "External Run" to assemble / run the code under Altirra64:

Name: kickc selected
Location: <your/path/to>/kickc.bat
Working Dir: ${workspace_loc:/your-project-name}
Arguments: -emu=altirra64 -target=atarixl -odir=build src/${resource_name}

Create 2 dirs under your project: "src", "build".

Keep your c files under "src/" subdir of your project.

Select the c file you wish to compile/run, and run the External Tool with the config above.

 

Share this post


Link to post
Share on other sites
26 minutes ago, zzip said:

C is a tough language to learn by only reading example code.   It's syntax is rather terse, and very flexible in how you can write it.

 

I would recommend reading C lessons online to learn how put together simple programs, structures, pointers, etc.

 

Since I've been using C so long now, the sample code posted here makes sense, but when I was starting out, I found it to be a rather frustrating language to get into.   Of course it didn't help back then that all the good compilers cost money, and the free ones weren't so complete...

 

It's not all about C per se. I wrote:

Quote

It is difficult to start programming on a given platform without enough simple examples.

It's not about me either, I can start programming in Atari subset C in a week :]

Edited by zbyti
Atari subset C

Share this post


Link to post
Share on other sites

Hi @JesperGravgaard thank you so much for this.

 

Where can I post questions to about writing some atari specific things? Can i raise them in issues as questions in gitlab, or would you prefer here?

 

For a starter, I'm trying to print a string to the screen, but I need to convert from a char* string into atascii.

 

My code is currently:

char *message = "hello, world!";

which is getting translated to:

  .segment Data
  .encoding "ascii"
    message: .text @"hello\$0c\$00world\$01"
    .byte 0

I wasn't quite expecting the comma and space (", ") to be translated into $0c$00.

 

Ideally, I'd also like to create a string that ends in the character "$9b" which is atascii for Carriage Return. Is that possible with a simple char* definition in this way?

e.g. "char *message = "hello, world!\$9b";" or something similar. (This fails with illegal escape)

 

I'm interfacing to Atari's CIOV and IOCBs to do the printing, so hopefully I'll have something to contribute back to your project to implement stdio.h as there's currently no conio.h for atari.

 

Cheers

Mark

Edited by fenrock

Share this post


Link to post
Share on other sites

In C, the normal way to put in a newline is:

char *message = "hello, world!\n";

and let the compiler translate \n into whatever is required for your system ($9B for Atari 8 bit system).

 

If the compiler doesn't do this then the next thing to try is:

char *message = "hello, world!\x9b";

Share this post


Link to post
Share on other sites

I don't know why I didn't think of trying \n. That does translate to $9b.

However spaces are translating to $00 (instead of $20) and commas to $0c (instead of $2c).

 

In fact, every character between $20 and $5f is losing bit 6, becoming $00 to $3f:

 

char *message = " !\"#$%&'()*+,-./0123456789:;<=>[email protected][\\]^_ abcdefghijklmnopqrstuvwxyz";

is translated to:

  .encoding "ascii"
    message: .text @"\$00\$01\$02\$03\$04\$05\$06\$07\$08\$09\$0a\$0b\$0c\$0d\$0e\$0f\$10\$11\$12\$13\$14\$15\$16\$17\$18\$19\$1a\$1b\$1c\$1d\$1e\$1f\$20\$21\$22\$23\$24\$25\$26\$27\$28\$29\$2a\$2b\$2c\$2d\$2e\$2f\$30\$31\$32\$33\$34\$35\$36\$37\$38\$39\$3a\$3b\$3c\$3d\$3e\$3f\$00abcdefghijklmnopqrstuvwxyz"
    .byte 0

 

Share this post


Link to post
Share on other sites

@JesperGravgaard

#define BoardStartDrawX         0
...
#define SquareSizeX             4
...
#define LevelsStartX            ((BoardStartDrawX+7)*SquareSizeX)+3

Giving me:

Error! #define declared parameter not a NAME.
File C:\kickc\examples\ataxx\.\ataxx.c
Line 28
(

This should be ok?

 

Share this post


Link to post
Share on other sites
15 hours ago, Yaron Nir said:

Hi, good work.

I'd like to learn more in terms of performance compared with CC65?

I think You are capable to do some benchmarks ;) I'm curious too.

Edited by zbyti
I'm curious too

Share this post


Link to post
Share on other sites
2 hours ago, fenrock said:

wow, that was quick @JesperGravgaard - just found https://gitlab.com/camelot/kickc/-/issues/526

I'd wondered if there was a pragma for atascii, and now I've added "#pragma encoding(atascii)" to my code the $20 bit isn't an issue.

The \n will wait until I get the latest release.

 

 

@fenrock 

 

The default encoding on the ATARI XL platform is screencode_atari. I can see you already found the way to select the ATASCII encoding!
 

#pragma encoding(atascii)

 

As you saw in the linked issue there is a problem with the encoding of the newline right now, but it is already fixed and the fix will be in the next release.

 

If you want a pre-release version please let me know. Then I will help you get one.

 

Edited by JesperGravgaard
  • Like 1

Share this post


Link to post
Share on other sites
2 hours ago, Wrathchild said:

@JesperGravgaard

#define BoardStartDrawX         0
...
#define SquareSizeX             4
...
#define LevelsStartX            ((BoardStartDrawX+7)*SquareSizeX)+3

Giving me:

Error! #define declared parameter not a NAME.
File C:\kickc\examples\ataxx\.\ataxx.c
Line 28
(

This should be ok?

 

 

@Wrathchild You are right!

 

There is a problem with macros where the body starts with a parenthesis in the current version - the compiler erronously believes you are trying to declare a macro with parameters. It has already been fixed and the fix will be in the next version.

 

https://gitlab.com/camelot/kickc/-/issues/518

 

If you want a pre-release version please let me know. Then I will help you get one.

 

  • Like 1

Share this post


Link to post
Share on other sites

Obviously in this case, you can change the define to:

#define LevelsStartX            3+SquareSizeX*(BoardStartDrawX+7)

but good the brackets ordering is fixed in next release.

Share this post


Link to post
Share on other sites

It is good practice to enclose any macro formulae in brackets.
Eg:

 

#define TOTAL_LEN   3+4

#define TOTAL_AREA  TOTAL_LEN * TOTAL_LEN

Gives an area of 3+(4*3)+4 = 19 .

 

#define TOTAL_LEN   (3+4)

#define TOTAL_AREA  ((TOTAL_LEN) * (TOTAL_LEN))

Gives an area of (3+4)*(3+4) = 49 .


Some of those brackets are redundant but defensive programming puts multiple layers of defence so that certain classes of bugs just don't happen, regardless of how the earlier macros are defined or how the final macro is used.
Every numeric macro is defined with enclosing brackets.
Every numeric macro encloses each child macro with brackets.

 

Apologies if I'm ranting :)

  • Like 1

Share this post


Link to post
Share on other sites

@JesperGravgaard are there some command line options I can use to identify what the cause of "Calculation not implemented false != false" is?

I've run with -v and the last line of the output was "Successful SSA optimization Pass2ConstantIdentification" (of three). 

Share this post


Link to post
Share on other sites
5 hours ago, Wrathchild said:

@JesperGravgaard are there some command line options I can use to identify what the cause of "Calculation not implemented false != false" is?

I've run with -v and the last line of the output was "Successful SSA optimization Pass2ConstantIdentification" (of three). 

It seems I have missed handling the case when comparing two boolean constants! That is an oversight on my part.

 

I have fixed them problem, and the fix will include it in the next release. https://gitlab.com/camelot/kickc/-/issues/527

 

In the meantime, if you want a pre-release version please let me know. Then I will help you get one. 

 

Thank you for reporting the problems you encounter!

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...