Prog8 language and compiler topic

All aspects of programming on the Commander X16.
geek504
Posts: 95
Joined: Wed Aug 26, 2020 4:52 pm

Prog8 language and compiler topic

Post by geek504 »


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.

SerErris
Posts: 172
Joined: Sat Aug 08, 2020 9:18 am

Prog8 language and compiler topic

Post by SerErris »


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

User avatar
desertfish
Posts: 1092
Joined: Tue Aug 25, 2020 8:27 pm
Location: Netherlands

Prog8 language and compiler topic

Post by desertfish »


@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!

BruceMcF
Posts: 1336
Joined: Fri Jul 03, 2020 4:27 am

Prog8 language and compiler topic

Post by BruceMcF »


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.

Bones
Posts: 3
Joined: Wed Jul 01, 2020 7:12 am

Prog8 language and compiler topic

Post by Bones »



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..

image.thumb.png.375be4723cb06d5fe66d7e7deddfe80d.png

image.thumb.png.d327dac87868697af5181ab532fc4aa1.png

image.thumb.png.4341292d6533c3209d690b49f19d488c.png

 

User avatar
desertfish
Posts: 1092
Joined: Tue Aug 25, 2020 8:27 pm
Location: Netherlands

Prog8 language and compiler topic

Post by desertfish »


wow I didn't know you actually started making an IDE for it  (or did I forget???? )  !  Fantastic!

User avatar
desertfish
Posts: 1092
Joined: Tue Aug 25, 2020 8:27 pm
Location: Netherlands

Prog8 language and compiler topic

Post by desertfish »


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.

User avatar
desertfish
Posts: 1092
Joined: Tue Aug 25, 2020 8:27 pm
Location: Netherlands

Prog8 language and compiler topic

Post by desertfish »


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.

 

User avatar
desertfish
Posts: 1092
Joined: Tue Aug 25, 2020 8:27 pm
Location: Netherlands

Prog8 language and compiler topic

Post by desertfish »


I've just released the new 4.3 version with those improvements!      Download links in initial post.

User avatar
desertfish
Posts: 1092
Joined: Tue Aug 25, 2020 8:27 pm
Location: Netherlands

Prog8 language and compiler topic

Post by desertfish »


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

Post Reply