Prog8 language and compiler topic

All aspects of programming on the Commander X16.
ZeroByte
Posts: 714
Joined: Wed Feb 10, 2021 2:40 pm

Prog8 language and compiler topic

Post by ZeroByte »



On 12/27/2021 at 11:53 AM, desertfish said:




I have not yet worked with the mouse on the x16, but perhaps there is something similar going on?   If not, all I can say is compare the resulting assembly code from prog8 to your own code and try to discover where the difference occurs.   The easiest way to do this is by making a minimal reproduction program



The mouse in X16 is janky. It only returns screen X Y positions and buttons. (i.e. no dX dY options) and it coopts sprite 0 even if you don't want to have a pointer on the screen. You can specify a blank sprite as sprite0 as the graphic for the pointer, but sprite 0 will be positioned at the X,Y the Kernal wants it to be. Whenever I get zsound to the point where I push it out the door, I might get back on my widget library I was working on, where I planned to counter this by making the engine hide the kernal pointer and move it back to the middle of the screen on each frame so you won't ever run into the edge of the screen and not be able to continue moving the mouse in that direction.

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.7 has been released!   https://github.com/irmen/prog8/releases/tag/v7.7

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



  • added pipe operator |>


  • added new syntax for string encodings, and added iso: encoding


  • on cx16: added txt.iso() to switch to iso charset


  • added @requirezp flag on variables to force them in Zeropage


  • added pokemon() function


  • fix assembly <-> prog8 label referencing issue (labels in asm no longer start with underscore)


  • less aggressive dead code (variables) removal


  • fixed some type casting issues


  • several small code gen optimizations


  • fix broken code generated for certain equality comparison expressions


  • several other bugfixes.



Ed Minchau
Posts: 503
Joined: Sat Jul 11, 2020 3:30 pm

Prog8 language and compiler topic

Post by Ed Minchau »



On 1/19/2022 at 2:09 PM, desertfish said:




added pokemon() function



Gotta catch them all.

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

Prog8 language and compiler topic

Post by borgar »


It's so nice to see so much regular progress for Prog8.

BTW, I first encountered a language with "piping" syntax during my university days. That was in the BETA programming language (https://en.wikipedia.org/wiki/BETA_(programming_language)). There is looked like this

(* x = 1 *)

1 -> x ;


(* x = f(1)  *)

1 -> f -> x ;


(* res = fibonacci(1,5)  *)

(1,5) -> fibonacci -> res;


Multiple parameters was supported and "safe" so that



(x, y) -> (y, x)



did a "swap".

This syntax is a lot easier read for long functions chains but I have to admit that I never got 100% comfortable with this syntax style. I guess the traditional Algol syntax was already firmly embedded in my skull by the time I encountered BETA.

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

Prog8 language and compiler topic

Post by desertfish »



pokemon(address, value)



Attempts to write a byte to a ROM at a location in machine language monitor bank. Doesn’t have anything to do with a certain video game.



 



because writing to rom is not possible the function effectively does nothing and is implemented as such



 



 



 



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

Prog8 language and compiler topic

Post by desertfish »


@borgarthe pipe was or is a bit experimental. It’s inspired by the pipe operator in f#. The implementation can perhaps be used later to serialize nested expressions, thereby avoiding the slow stack based approach. But it lacks some features to do this now

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.7.1 has been released that fixes a bunch of compiler crashes.  https://github.com/irmen/prog8/releases/tag/v7.7.1

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.8 has been released   https://github.com/irmen/prog8/releases/tag/v7.8


  • removed old @"screencodes" string encoding syntax (use sc:"hello" instead)


  • library API change: moved cx16.vload() to cx16diskio module


  • API change: added alignment parameter to memory() function


  • library API change: string.find now returns index of character + carry bit status (instead of substring address)


  • completely rewritten variable allocation, resulting in large program size savings


  • diskio.list_files() now has a larger buffer to be able to list larger directories


  • restructured code generator and added -expericodegen command line flag to select alternate experimental code generator (only a stub at the moment)


  • tweak compiler output to be less noisy


  • various bugfixes and optimizations


 

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.9 has been released  https://github.com/irmen/prog8/releases/tag/v7.9



  • added atari compilation target, to create programs for the Atari 800XL. It's very rudimentary still.


  • breaking syntax change of the pipe operator |> : the functions in a pipe now have to be actual function calls (without the first argument specified), rather than just the function names


  • breaking change of the pipe operator |>: you can no longer use a variable at the end to store the value into. Just use an assignment instead.


  • sys.memcopy and sys.memset on the cx16 target no longer depend on kernal routine so now work even when the kernal is not banked in.


  • fix program crash bug caused by non-inlined asmsub not having a proper RTS instruction.


  • fixed compile time calculated constant results of sin() and cos() functions to now be identical to their runtime counterpart


  • better searching for used variable names inside assembly code so unused variable elimination is smarter


  • properly report duplicate label names


  • properly report invalid text encoding selection


  • properly report in check against non-constant range


  • many internal refactorings in the code generator as ongoing attempts to make it easier to change/replace



 

KennethWilke
Posts: 8
Joined: Fri Feb 25, 2022 5:52 am

Prog8 language and compiler topic

Post by KennethWilke »


Wow, this is very impressive work! I need to put this in my queue of things to tinker with ?

I wrote a 6502 assembler a long while back but never did anything more with it.

Post Reply