JesperGravgaard Posted September 26, 2020 Share Posted September 26, 2020 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. 11 5 Quote Link to comment Share on other sites More sharing options...
zbyti Posted September 26, 2020 Share Posted September 26, 2020 (edited) @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 Edited September 26, 2020 by zbyti github 1 Quote Link to comment Share on other sites More sharing options...
Heaven/TQA Posted September 27, 2020 Share Posted September 27, 2020 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. Hey Rex, cool. Thanks for the A8 building options. Cheers Quote Link to comment Share on other sites More sharing options...
Heaven/TQA Posted September 27, 2020 Share Posted September 27, 2020 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? 1 Quote Link to comment Share on other sites More sharing options...
zbyti Posted September 27, 2020 Share Posted September 27, 2020 (edited) 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 September 27, 2020 by zbyti Action! 1 Quote Link to comment Share on other sites More sharing options...
Cyprian Posted September 27, 2020 Share Posted September 27, 2020 well done @JesperGravgaard what about Lynx support? Quote Link to comment Share on other sites More sharing options...
JesperGravgaard Posted September 27, 2020 Author Share Posted September 27, 2020 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.) 1 Quote Link to comment Share on other sites More sharing options...
funkheld Posted September 27, 2020 Share Posted September 27, 2020 Hi good afternoon. your kickc makes a good impression. the two demos have few bytes, which is wonderful. 89 bytes and 149 bytes. greeting Quote Link to comment Share on other sites More sharing options...
Cyprian Posted September 28, 2020 Share Posted September 28, 2020 great @JesperGravgaard thanks Quote Link to comment Share on other sites More sharing options...
Yaron Nir Posted September 28, 2020 Share Posted September 28, 2020 Hi, good work. I'd like to learn more in terms of performance compared with CC65? 1 Quote Link to comment Share on other sites More sharing options...
zzip Posted September 28, 2020 Share Posted September 28, 2020 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... Quote Link to comment Share on other sites More sharing options...
fenrock Posted September 28, 2020 Share Posted September 28, 2020 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. Quote Link to comment Share on other sites More sharing options...
zbyti Posted September 28, 2020 Share Posted September 28, 2020 (edited) 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 September 28, 2020 by zbyti Atari subset C Quote Link to comment Share on other sites More sharing options...
fenrock Posted September 28, 2020 Share Posted September 28, 2020 (edited) 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 September 29, 2020 by fenrock Quote Link to comment Share on other sites More sharing options...
stepho Posted September 29, 2020 Share Posted September 29, 2020 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"; Quote Link to comment Share on other sites More sharing options...
fenrock Posted September 29, 2020 Share Posted September 29, 2020 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:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_ 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 Quote Link to comment Share on other sites More sharing options...
fenrock Posted September 29, 2020 Share Posted September 29, 2020 (edited) 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. Edited September 29, 2020 by fenrock Quote Link to comment Share on other sites More sharing options...
Wrathchild Posted September 29, 2020 Share Posted September 29, 2020 @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? Quote Link to comment Share on other sites More sharing options...
zbyti Posted September 29, 2020 Share Posted September 29, 2020 (edited) 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 September 29, 2020 by zbyti I'm curious too Quote Link to comment Share on other sites More sharing options...
JesperGravgaard Posted September 29, 2020 Author Share Posted September 29, 2020 (edited) 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 September 29, 2020 by JesperGravgaard 1 Quote Link to comment Share on other sites More sharing options...
JesperGravgaard Posted September 29, 2020 Author Share Posted September 29, 2020 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. 1 Quote Link to comment Share on other sites More sharing options...
fenrock Posted September 29, 2020 Share Posted September 29, 2020 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. Quote Link to comment Share on other sites More sharing options...
stepho Posted September 30, 2020 Share Posted September 30, 2020 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 1 Quote Link to comment Share on other sites More sharing options...
Wrathchild Posted October 1, 2020 Share Posted October 1, 2020 @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). Quote Link to comment Share on other sites More sharing options...
JesperGravgaard Posted October 1, 2020 Author Share Posted October 1, 2020 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! 1 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.