Prog8 language and compiler topic

All aspects of programming on the Commander X16.
User avatar
desertfish
Posts: 1097
Joined: Tue Aug 25, 2020 8:27 pm
Location: Netherlands

Prog8 language and compiler topic

Post by desertfish »


Version 7.2 of the Prog8 compiler has just been released https://github.com/irmen/prog8/releases/tag/v7.2

Documentation is here https://prog8.readthedocs.io

 


This is mainly a version with performance optimizations.

Various parts of the code generator now create faster code, and sometimes also smaller code.

Depending on your source code, you can observe pretty significant gains in resulting program size (tens to hundreds of bytes smaller).



Other fixes:




  • PETSCII block drawing character mapping was updated to now correctly separate certain box line characters


  • Fixed type casting errors related to certain const propagation


  • str is now allowed as a parameter type in subroutines (it is passed by reference/address)


  • compiler no longer crashes when an input file doesn't exist


  • gradle builds now automatically run installDist task after build


  • updated to Kotlin 1.5.31




 


borgar
Posts: 52
Joined: Wed Mar 31, 2021 9:30 am
Location: Oslo

Prog8 language and compiler topic

Post by borgar »


Very nice. My only currently working project (https://www.commanderx16.com/forum/index.php?/files/file/182-petaxian/) still compiles and run fine though there is no reason to rebuild and upload yet.

I have made the Git project public (https://github.com/cyborgar/Petaxian) in case anyone want to look at a bit larger Prog8 code example compared to the mostly smaller examples coming with the compiler. I have organized code in multiple files/modules. Though there is no code protection this does require explicit references when crossing modules and that helps a lot with visibility.

I have (slowly) started on another clone game (this one is going to copy liberally from Llamasoft's Gridrunner) but I've just gotten started. I'm going to focus on getting it to work on C64 before I'll probably port it to CX16.

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

Prog8 language and compiler topic

Post by desertfish »


For comparison

Petaxian compiled with prog8 7.0: 19639 bytes

Petaxian compiled with prog8 7.2: 19405 bytes

234 bytes of overhead removed

update: Petaxian compiled with prog8 7.3: 19258 bytes

               another 147 bytes of overhead removed by producing more efficient code

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

Prog8 language and compiler topic

Post by desertfish »


Version 7.3 has just been released https://github.com/irmen/prog8/releases/tag/v7.3

Docs are here as always https://prog8.readthedocs.io/


More improvements in generated code efficiency, resulting in smaller code that runs faster. (see the post above this one for an indication of savings you might see)

Also added a few small new quality of life features.




  • fixed operator not priority: it is now higher prio than and/or/xor !


  • fixed division of signed bytes by 2


  • added new cos and sin builtin functions cosr8 sinr8 cosr16 sinr16, and also their unsigned valued siblings. These make it easier to deal with arcs of degrees 0-359 rather than 0-255 of the existing trig functions.


  • added signed versions of the cx16 virtual registers: r0s - r15s including the L and H byte variants of them.


  • less temporary variables generated and used


  • more optimizations to expression evaluations


  • compiler no longer uses cx16 R15 virtual register as tempvar


  • unit tests now use KoTest as test framework.



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

Prog8 language and compiler topic

Post by desertfish »


While I was boasting about the reduced code size of the compiled Petaxian game, I now discovered that a bug has crept in in 7.3 that now makes the sound glitch out on the C64 build of Petaxian. I will investigate and fix this soon, hopefully.

Weirdly enough the game still works fine with sound on the X16 build.

 

update: found the bug and fixed it for 7.4, there was a new optimizer added that was too aggressive in removing double-stores

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

Prog8 language and compiler topic

Post by desertfish »


Version 7.4.1 has been released  https://github.com/irmen/prog8/releases/tag/v7.4.1

Documentation as always here  https://prog8.readthedocs.io

 


Even more improvements in generated code efficiency, resulting in smaller code that runs faster.




  • improved code generation.


  • optimizer is now smarter about accesses to memory mapped IO that shouldn't be optimized away


  • performance improvements in the compiler itself, updated to Kotlin 1.6


  • fixed some illegal instructions in the conv module on c64 target


  • other bugfixes


  • documentation improvements



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

Prog8 language and compiler topic

Post by desertfish »


Version 7.5 has been released  https://github.com/irmen/prog8/releases/tag/v7.5

Documentation as always here:   https://prog8.readthedocs.io/


Some new features and more optimizations have been added.




  • added diskio.load_raw() to load headerless files


  • added cx16diskio with load() and load_raw() that are HIRAM bank-aware


  • added cx16.getrambank() / getrombank()


  • fix grammar problem: \x and \u escape sequences now work properly in character literals


  • fix grammar problem: scoped variables such as cx16.r0-r15 are now allowed as loop variable in for loops


  • cx16.r0-r15 are now properly considered to be already in zeropage on X16 if you use them as pointers


  • allow using ubyte[] as subroutine parameter type


  • some other bugfixes and optimizations



yock1960
Posts: 136
Joined: Tue Nov 16, 2021 8:42 pm

Prog8 language and compiler topic

Post by yock1960 »


Is anyone using this on a Windows machine? I've tried two different systems now, Win10 & Win7, started with Java 11, moved to the open source Java and all I get are can't access jar file errors.  The entire reason that I like working with 'old' 8bit systems is simplicity! 

borgar
Posts: 52
Joined: Wed Mar 31, 2021 9:30 am
Location: Oslo

Prog8 language and compiler topic

Post by borgar »


Sure. I use this on WIndows 7 (old stationary pc) and Windows 10 (laptop). Never had any problems getting this to work.

BTW, I have just set up a few small bat scripts to compile and/or run stuff. This on I use just to build the Petaxian code, I have variants that can take program name as argument, build for C64 instead for XC16 etc.

SET PATH=%PATH%;..

SET jar=..\prog8compiler-7.5-all.jar


IF %computername%==BIFROST (

  SET javap="C:\Program Files\OpenJDK\jdk-11.0.9.1-hotspot\bin\java.exe"

) ELSE (

  SET javap="C:\Program Files\OpenJDK\jdk-11.0.8.10-hotspot\bin\java.exe"

)


%javap% -jar %jar% -srcdirs cx16 -target cx16 petaxian.p8

..\cmdrx16v38\x16emu.exe -joy1 SNES -run -prg petaxian.prg

 

yock1960
Posts: 136
Joined: Tue Nov 16, 2021 8:42 pm

Prog8 language and compiler topic

Post by yock1960 »



On 12/12/2021 at 4:58 AM, borgar said:




Sure. I use this on WIndows 7 (old stationary pc) and Windows 10 (laptop). Never had any problems getting this to work.



BTW, I have just set up a few small bat scripts to compile and/or run stuff. This on I use just to build the Petaxian code, I have variants that can take program name as argument, build for C64 instead for XC16 etc.



SET PATH=%PATH%;..

SET jar=..\prog8compiler-7.5-all.jar




IF %computername%==BIFROST (

  SET javap="C:\Program Files\OpenJDK\jdk-11.0.9.1-hotspot\bin\java.exe"

) ELSE (

  SET javap="C:\Program Files\OpenJDK\jdk-11.0.8.10-hotspot\bin\java.exe"

)




%javap% -jar %jar% -srcdirs cx16 -target cx16 petaxian.p8



..\cmdrx16v38\x16emu.exe -joy1 SNES -run -prg petaxian.prg

 



Thanks Borgar! I thought about this, but I thought that after 60+ years of computing, we shouldn't have to do this type of thing anymore! But I guess that's just grumpy old me! ?

Post Reply