Cappuccino - Interpreter/Assembler

Developed or developing a new product in PureBasic? Tell the world about it.
Killswitch
Enthusiast
Enthusiast
Posts: 731
Joined: Wed Apr 21, 2004 7:12 pm

Cappuccino - Interpreter/Assembler

Post by Killswitch »

Cappuccino is an interpreter I've written in PB, it's nowhere near complete yet but I'm hoping this release will generate some interest with some people who'd be able to help introduce some more advanced features (specifically GUI/graphics commands).

The download has three files in it. First, Code.txt. Write your test code (I've written some as an example) in here. Second, Assembler.exe. This translates Code.txt into ByteCode and outputs into a new file (Script). Finally, run VM.exe to run the script.

The Code has the following syntax (it's based on ASM):

Code: Select all

 'This is a comment
 
  Title "Not nessacary, and uneeded in this early version"

  StackSize 1024 'Again, not nessacary

  Entry Start 'Not nessacary, but usefull

  .data 'This section is where you declare variables
    One.l
    Two.f
    Three.s
  .code 'This is where you write your code
    Start: 'This is a label
      Add One,1
  .end 'Nothing after this line
Cappuccino ASM supports the following commands:

Interger maths: ADD, SUB, MUL, DIV
Float maths: FADD, FSUB, FMUL, FDIV

General: JMP, Mov

There are also 15 registers to play with (although 3 have a specific usage):

Long registers: L0, L1, L2, L3, L4
Float registers: F0, F1, F2, F3, F4
String registers: S0, S1, S2, S3, S4

The '0' registers will hold the result of a command excecuted via a call:

Code: Select all

    Push 97
    Call [Chr] 'Supported calls are MessageBox, Len, Chr and Asc
    'S0 now holds "a"
  
I'm going to continue to develop this and (eventually) make a high-level language and compiler which'll output Cappuccino ASM code and make use of the VM.

Enjoy!

DOWNLOAD
Last edited by Killswitch on Wed Sep 06, 2006 9:05 pm, edited 1 time in total.
~I see one problem with your reasoning: the fact is thats not a chicken~
User avatar
GeoTrail
Addict
Addict
Posts: 2794
Joined: Fri Feb 13, 2004 12:45 am
Location: Bergen, Norway
Contact:

Post by GeoTrail »

Looks abit complicated :shock: ;)
Anyways, why the name Cappuccino ?
I Stepped On A Cornflake!!! Now I'm A Cereal Killer!
dracflamloc
Addict
Addict
Posts: 1648
Joined: Mon Sep 20, 2004 3:52 pm
Contact:

Post by dracflamloc »

He was probably sipping some while looking at a picture of Hasselhoff. :twisted:
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

I cant make it compile :/
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

GeoTrail wrote:Anyways, why the name Cappuccino ?
A VM, just like Java? (And his previous thing was called Mocha.)
Killswitch
Enthusiast
Enthusiast
Posts: 731
Joined: Wed Apr 21, 2004 7:12 pm

Post by Killswitch »

I've updated the assembler so it displays a message once the compilations finished. Just as a quick and dirty solution remember that all the code must be written in Code.txt, and the assembler will always output to the 'Script' file.

It'll admit it looks a bit complicated, I'm writing an ASM based language first so I can translate a higher language into it later on. The Cappuccino step will be like the FASM step with PB.

Cappuccino is a very lame and indirect reference to Java (since, it's a VM as well), as well as keeping in touch with some of my previous work (last two projects were called Mocha and Latte). I was wondering if someone would notice that - thanks Trond :)

Hopefully that should clear things up a little, if you're still having trouble compiling then please post any error messages your getting/the source I'll try and help as much as possible.

DOWNLOAD
~I see one problem with your reasoning: the fact is thats not a chicken~
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Have you given up with Mocha then, as this seems a change in direction?
I may look like a mule, but I'm not a complete ass.
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

works now :)
Killswitch
Enthusiast
Enthusiast
Posts: 731
Joined: Wed Apr 21, 2004 7:12 pm

Post by Killswitch »

I'd stopped working on Mocha quite a while ago, I shifted to a new codebase which I called 'Latte'. I'm still interested in writing a 'true' compiler, rather than an interpreter, but I lack the ASM knowledge to do it properly.

This project is designed to let me create a new language but also supply a code base which can easily be switched over to compile to FASM, hence the ASM syntax here.

If there's any demand for it I'll realse the source for Mocha and Latte.

How's everyone enjoying this project? :)
~I see one problem with your reasoning: the fact is thats not a chicken~
newcoder
User
User
Posts: 13
Joined: Tue Nov 25, 2003 11:34 pm

Post by newcoder »

I like this project alot. I am doing this exact same thing. But just like you I want to be able to make a true compiler but my assembler knowledge is not that great.

I'm writing my vm in C though.
User avatar
GeoTrail
Addict
Addict
Posts: 2794
Joined: Fri Feb 13, 2004 12:45 am
Location: Bergen, Norway
Contact:

Post by GeoTrail »

Trond wrote:
GeoTrail wrote:Anyways, why the name Cappuccino ?
A VM, just like Java? (And his previous thing was called Mocha.)
Aaa didn't see the similarity hehehehe. too obvious ;)
Personally, I prefer Espresso :D
I Stepped On A Cornflake!!! Now I'm A Cereal Killer!
Killswitch
Enthusiast
Enthusiast
Posts: 731
Joined: Wed Apr 21, 2004 7:12 pm

Post by Killswitch »

That's funny actually, I considered calling this Expresso but rejected the name on the basis that I hate it!
~I see one problem with your reasoning: the fact is thats not a chicken~
Inf0Byt3
PureBasic Fanatic
PureBasic Fanatic
Posts: 2236
Joined: Fri Dec 09, 2005 12:15 pm
Location: Elbonia

Post by Inf0Byt3 »

YOU WILL GIVE ME ALL YOUR CAPPUCINO!

Image

This project looks really good! 8)
None are more hopelessly enslaved than those who falsely believe they are free. (Goethe)
Post Reply