EightBall - New Programming Language

Basic and Machine Language

Moderator: Moderators

Post Reply
Bobbi
Vic 20 Afficionado
Posts: 355
Joined: Thu Oct 13, 2016 11:35 am
Location: Toronto
Occupation: Programmer

EightBall - New Programming Language

Post by Bobbi »

I have been doing a bit more work on my little programming language interpreter project and thought that maybe it was time to let some other people play with it. This started out as a VIC-20 project (VICScript) but now supports C64 and Apple IIe/c as well. Accordingly I renamed it to EightBall "The Eight Bit Algorithmic Language".

It is still a work in progress.

Source code, executables, disk images and documentation at https://github.com/bobbimanners/EightBa ... /Eightball

Here is a sample program, to give you a flavour:

Code: Select all

' Sieve of Eratosthenes                                                         
                                                                                
' Globals                                                                       
byte nr = 10                                                                    
word n = nr * nr                                                                
byte A[n] = 1                                                                   
                                                                                
pr.msg "Sieve of Eratosthenes ..."; pr.nl                                       
call doall()                                                                    
end                                                                             
                                                                                
sub doall()                                                                     
  call sieve()                                                                  
  call printresults()                                                           
return 0                                                                        
                                                                                
sub sieve()                                                                     
  word i = 0; word j = 0                                                        
  for i = 2 : (nr - 1)                                                          
    if A[i]                                                                     
      j = i * i                                                                 
      while (j < n)                                                             
        A[j] = 0                                                                
        j = j + i                                                               
      endwhile                                                                  
    endif                                                                       
  endfor                                                                        
return 0                                                                        
                                                                                
sub printresults()                                                              
  word i = 0                                                                    
  for i = 2 : (n - 1)                                                           
    if A[i]                                                                     
      if i > 2                                                                  
        pr.msg ", "                                                             
      endif                                                                     
      pr.dec i                                                                  
    endif                                                                       
  endfor                                                                        
  pr.msg "."                                                                    
return 0 
User avatar
Kweepa
Vic 20 Scientist
Posts: 1314
Joined: Fri Jan 04, 2008 5:11 pm
Location: Austin, Texas
Occupation: Game maker

Re: EightBall - New Programming Language

Post by Kweepa »

Pretty cool...
Can the interpreted language be compiled?
It looks like it might make fast code since you can declare bytes :)
Bobbi
Vic 20 Afficionado
Posts: 355
Joined: Thu Oct 13, 2016 11:35 am
Location: Toronto
Occupation: Programmer

Re: EightBall - New Programming Language

Post by Bobbi »

Right now I am interpreting the text directly, which is slow. However it is quite convenient to be able to load and save ASCII files and exchange them between systems this way (with some help from petcat!)

I am planning on moving to a tokenized representation, which should speed things up. I am also thinking to implement a virtual machine and a simple compiler targeting it. I am open to suggestions as to the best approach ... obviously, memory is tight. This should be a fun project over the winter months, and I guess I will learn a lot about compiler development :)

First though, I want to stabilize this release, add multidimensional arrays and squash some bugs.
Bobbi
Vic 20 Afficionado
Posts: 355
Joined: Thu Oct 13, 2016 11:35 am
Location: Toronto
Occupation: Programmer

Re: EightBall - New Programming Language

Post by Bobbi »

Took longer than I thought, but there is a new release of EightBall on my GitHub page:
https://github.com/bobbimanners/EightBall

There is now a

Code: Select all

comp
command which compiles the language to bytecode for the EightBall VM (also new with this release.) The compiled code runs much faster than interpreted code (even with the totally unoptimized VM I have at present.)

Documentation is included in the wiki on the GitHub page.

Enjoy!
Bobbi
Vic 20 Afficionado
Posts: 355
Joined: Thu Oct 13, 2016 11:35 am
Location: Toronto
Occupation: Programmer

Re: EightBall - New Programming Language

Post by Bobbi »

Fixed a couple of bugs. Latest version is v0.52.
Bobbi
Vic 20 Afficionado
Posts: 355
Joined: Thu Oct 13, 2016 11:35 am
Location: Toronto
Occupation: Programmer

Re: EightBall - New Programming Language

Post by Bobbi »

v0.76 is now available from https://github.com/bobbimanners/EightBall

There are numerous small improvements. The virtual machine has been optimized somewhat and compiled bytecode now runs a good deal faster than before.
dr.geek
Vic 20 Drifter
Posts: 22
Joined: Tue Aug 28, 2018 5:05 am

Re: EightBall - New Programming Language

Post by dr.geek »

Looks very interesting - i have been looking at the quetzalcoatl compiler which can produce prg's for an actual VIC. Do you see Eightball getting to this point?
Post Reply