Prog8 language and compiler topic
Prog8 language and compiler topic
I had to look up what Kotlin was... looks a lot like Pascal (or Delphi). Did you have to re-implement a lexical analyzer in Kotlin or did you use an available library? Did you finish all the grammar for Prog8?
In the mid-90s I did a SPARC assembly compiler using the traditional C tools, lex and yacc. It'll be interesting to dig up that old source code and re-implement for 65c02 and X16. It might just be a waste of time since cc65 already exists... and time is a rare commodity.
Prog8 language and compiler topic
Talking about a BASIC Compiler ... here is one that is supposed to work. However I am not sure what happens to X16 special commands ...
https://www.c64-wiki.com/wiki/MOSpeed
- desertfish
- Posts: 1096
- Joined: Tue Aug 25, 2020 8:27 pm
- Location: Netherlands
Prog8 language and compiler topic
@geek504 I used the Antlr parser generator library as-is (Kotlin/JVM integrates seamlessly with Java). I did wrap the generated AST classes in easier to use Kotlin versions though.
@SerErris yes Prog8 is compiled into assembly code. The cx16 compiler target shares most of its code with the C64 target so no, most of the time the new 65c02 opcodes are not yet used. I have been using STZ and PHX/PLX a bit here and there in certain library routines but that's about it.
thanks for your questions!
Prog8 language and compiler topic
Those are five of the best instructions, the other three I really like are LDA (zp) : STA (zp) : SBC (zp) (SBC in particular because the three logic and ADC are commutative so you can typically LDA (zp1) : CLC : ADC a,X : STA (zp2) but subtraction is picky about which one comes first.
Prog8 language and compiler topic
On 8/30/2020 at 4:41 PM, desertfish said:
@Bones it's copied from the editor window from IntelliJ IDEA where I configured the major syntax highlighting rules for my language syntax. Which is incredibly easy to do in IDEA. To be honest, it was quite unexpected that pasting the source in here retained the coloring! (it's not a screenshot- it's the actual source code pasted as text)
@Johan Kårlin Thank you so much for the kind words it means a lot to me. Yeah it has been a long time coming and there's still much work left to do on the code generation part (projects are never "finished" are they? haha) but I'm really happy today already with where the language and its compiler are.
cool ..
I should revisit my prog8 ide project. Like so many things I start, it somehow just fell off my radar..
- desertfish
- Posts: 1096
- Joined: Tue Aug 25, 2020 8:27 pm
- Location: Netherlands
Prog8 language and compiler topic
wow I didn't know you actually started making an IDE for it (or did I forget???? ) ! Fantastic!
- desertfish
- Posts: 1096
- Joined: Tue Aug 25, 2020 8:27 pm
- Location: Netherlands
Prog8 language and compiler topic
I just released a new version (4.2) that contains a lot of bug fixes. Most if not all issues I've ran into while attempting to compile for the Cx16 have been solved in this version ? . I've updated the initial post. Download links can still be found there.
- desertfish
- Posts: 1096
- Joined: Tue Aug 25, 2020 8:27 pm
- Location: Netherlands
Prog8 language and compiler topic
The next version is going to introduce an exiting new feature: It can actually compile the exact same program for both the C64 and the CommanderX16. As long as you stick to using generic kernel subroutines and Prog8 library subroutines. And don't hardcode 40x25 screen size ?
Many of Prog8's example programs can now be compiled for both systems by just flipping a compiler command line option.
- desertfish
- Posts: 1096
- Joined: Tue Aug 25, 2020 8:27 pm
- Location: Netherlands
Prog8 language and compiler topic
I've just released the new 4.3 version with those improvements! Download links in initial post.
- desertfish
- Posts: 1096
- Joined: Tue Aug 25, 2020 8:27 pm
- Location: Netherlands
Prog8 language and compiler topic
The upcoming release has some pretty significant improvements in the generated code, sometimes it is now actually slightly faster than equivalent C code compiled by CC65. That's exciting, but it is only for a few silly benchmarks. Other prog8 code is still slower than equivalent compiled C but I'm quite happy with the steps I've been able to make over the past few releases.
There's already the Cobra MK3 space ship from Elite animating in 3d and my next goal is to port the "text elite" trading engine to Prog8. However this requires a few fundamental changes to the language such as the ability to have arrays that contain other things than just numbers, and perhaps also arrays that are larger than one page in memory.... ? Because there are 256 planets with their properties in a single galaxy. I have no idea how to solve this problem at this time because the "array is one memory page maximum" is quite fundamental in Prog8