6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri Apr 26, 2024 2:50 am

All times are UTC




Post new topic Reply to topic  [ 11 posts ] 
Author Message
PostPosted: Sat Jun 07, 2014 8:40 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10793
Location: England
Elsewhere, Mike took note of David Schmenck's latest adventure, called PLASMA, which is some kind of virtual machine or programming environment for 6502 - presently for Apple 8-bit machines - which aims to learn from previous VMs such as Java (ported to 6502 by David himself), Pascal, and Forth.

PLASMA - Proto Language AsSeMbler for Apple

Code:
import stdlib
    predef puts
end

byte hello[] = "Hello, world.\n"

puts(@hello)
done


Looks interesting!

Cheers
Ed

barrym95838 wrote:
I just ran across THIS today, from a certainly gifted Mr. Schmenk. At first glance, it seems a bit like an alternative to Forth, with similar performance and footprint, but with a syntax that looks a bit more "C-like". Is this something that you or anyone else here might find to be interesting?

Here's a modestly technical description of what PLASMA is about:

https://github.com/dschmenk/PLASMA

Mike


Last edited by BigEd on Tue Feb 21, 2017 7:56 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: Sun Jun 08, 2014 10:49 pm 
Offline

Joined: Sat Aug 21, 2010 7:52 am
Posts: 231
Location: Arlington VA
This looks pretty cool!


Top
 Profile  
Reply with quote  
PostPosted: Fri Jan 08, 2016 10:22 pm 
Offline

Joined: Sat Dec 12, 2015 7:48 pm
Posts: 122
Location: Lake Tahoe
I've been spending a bit of effort to organize and clean up the documentation, as well as including a link the the PLASMA KansasFest video. Hopefully this makes PLASMA a little more accessible to anyone who wants to try it out. It has become quite stable and is being used to write the game logic for Lawless Legends: http://www.lawlesslegends.com

There are also some new modules that support the Uthernet cards, a handle based swappable memory manager, and a fiber (non pre-emptive threads) library.

I believe PLASMA has some unique characteristics that make it the perfect mid-level 6502 language. I hope you agree.

https://github.com/dschmenk/PLASMA

Dave...


Top
 Profile  
Reply with quote  
PostPosted: Fri Jan 08, 2016 10:44 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10793
Location: England
That's great - thanks Dave, and welcome!


Top
 Profile  
Reply with quote  
PostPosted: Sat Jan 09, 2016 2:30 pm 
Offline
User avatar

Joined: Fri Dec 11, 2009 3:50 pm
Posts: 3346
Location: Ontario, Canada
resman wrote:
I've been spending a bit of effort to organize and clean up the documentation [...]

https://github.com/dschmenk/PLASMA

"A bit of effort," he says?! This document is thorough and highly readable -- which, for a subject of any complexity, is saying a great deal -- it's far from a trivial achievement, as any would-be writer soon learns. Congratulations (and welcome!).

-- Jeff

_________________
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html


Top
 Profile  
Reply with quote  
PostPosted: Sat Jan 09, 2016 3:37 pm 
Offline

Joined: Sat Dec 12, 2015 7:48 pm
Posts: 122
Location: Lake Tahoe
Thanks Ed. I've only been lurking here for 10 years - I finally got off my rear and made an account.

Jeff, I admit it was more than a little effort for me. I would rather go to the dentist than write documentation. It is still work in progress, but I sent an email to Brian Kernighan, who's writing style I admire and was trying to replicate, and got a nice note back.

Dave...


Top
 Profile  
Reply with quote  
PostPosted: Sun Jan 10, 2016 1:35 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10793
Location: England
Just finished reading the docs - great work. I notice there's no SWAP opcode - presumably this means that the stack frame and eval stack approach has avoided the need to do a lot of fiddling with stack contents?

I'm just about to watch your PLASMA-hosted presentation at https://youtu.be/RrR79WVHwJo?t=11m1s


Top
 Profile  
Reply with quote  
PostPosted: Sun Jan 10, 2016 7:38 pm 
Offline

Joined: Sat Dec 12, 2015 7:48 pm
Posts: 122
Location: Lake Tahoe
BigEd wrote:
Just finished reading the docs - great work. I notice there's no SWAP opcode - presumably this means that the stack frame and eval stack approach has avoided the need to do a lot of fiddling with stack contents?

I'm just about to watch your PLASMA-hosted presentation at https://youtu.be/RrR79WVHwJo?t=11m1s


Good eye. Indeed, having a compiler generate the code, and judicious use of local variables, removed the need for a SWAP op. It was originally in there, but as I got better with code generation (mostly with the indirect call), I was able to remove it. Now, if the evaluation stack was to be manipulated directly from the program, ala Forth, it would make a lot more sense to have SWAP and other direct stack ops available.

The operation that I did end up introducing that you may not find in many stack oriented architectures is the 'duplicate TOS to memory' operation. - the equivalent to a store/load of the same variable. I optimized the FOR/NEXT loop to keep the iteration variable on the TOS. The value can be incremented/decremented and compared to the end condition without having to reload it constantly. However, because the iteration variable can be read at any time, I just duplicate the TOS to the variable in memory at the beginning of the loop. You might notice that writing to the iteration variable inside the loop won't actually affect it's value (which is on the TOS). A small price to pay for a faster implementation.

Dave...


Top
 Profile  
Reply with quote  
PostPosted: Wed Jan 13, 2016 5:55 pm 
Offline

Joined: Thu Jun 04, 2015 3:43 pm
Posts: 42
I just watched the Kansasfest presentation a little while ago. Super cool stuff!

One thing that wasn't immediately clear to me reading the documentation was whether the function frames were something that paired with a function definition or a function invocation. Given the comments about recursion, I'm assuming that they are allocated at function invocation, is that correct? (I suppose it wouldn't make sense any other way, but you never know with memory-constrained systems.)

Also interesting, I think, is how object-oriented the architecture seems. Functions look a whole lot like objects, or at least like PostScript procedures, dictionary stack and all.

One of my long-term goals is some day implementing a PostScript-like programming environment, so maybe that's just my bias showing. :-)


Top
 Profile  
Reply with quote  
PostPosted: Wed Jan 13, 2016 8:23 pm 
Offline

Joined: Sat Dec 12, 2015 7:48 pm
Posts: 122
Location: Lake Tahoe
magetoo wrote:
I just watched the Kansasfest presentation a little while ago. Super cool stuff!

One thing that wasn't immediately clear to me reading the documentation was whether the function frames were something that paired with a function definition or a function invocation. Given the comments about recursion, I'm assuming that they are allocated at function invocation, is that correct? (I suppose it wouldn't make sense any other way, but you never know with memory-constrained systems.)

Also interesting, I think, is how object-oriented the architecture seems. Functions look a whole lot like objects, or at least like PostScript procedures, dictionary stack and all.

One of my long-term goals is some day implementing a PostScript-like programming environment, so maybe that's just my bias showing. :-)


Glad the video was beneficial. KFest is a blast and has some very hard-core technical membership and content. You've guessed correctly regarding the call frames - they are allocated per invocation. I've tried updating the documentation to make it more clear.

As for the object oriented nature of PLASMA, that is probably more of a function (no pun intended) of it being modular and some of the syntax I chose (on purpose) to make it more familiar. There isn't any kind of OO enforcement, but you can fake it pretty well. I tried it with the TCP/IP modules. Hiding the different hardware implementations and state behind a common interface made it clean and easy to write the higher level code.

When implementing a language for the 6502, I've decided that "less is more".

Dave...


Top
 Profile  
Reply with quote  
PostPosted: Wed Jan 13, 2016 10:36 pm 
Offline

Joined: Thu Jun 04, 2015 3:43 pm
Posts: 42
Right, "object oriented" is maybe not the best term. It's not OO in the sense that the language has explicit syntax for creating objects and inheritance, but the runtime sort of smells like it would work for an OO language. (Or maybe that's just me having a stroke.)

What tickled my interest was that the call frames together with the functions can be seen as forming a kind of object, with code and data bundled together. And if frames also have backlinks to their callers, that looks very familiar too; like the instance of a function "inheriting" some context from the caller. Maybe that's more of a functional thing though.

Either way, it's given me some ideas I'll have to think about.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: