Page 1 of 1

MochaBASIC (Switch Compiler)

Posted: Mon Apr 10, 2006 12:49 am
by Killswitch
[Edit] Nuts, this was supposed to be in the annoucments forum - can someone move it please? Thanks!

After many more hours hammering out code I've added some new functionality to my compiler and given it a new name!

Just as a recap Mocha is a Basic > FASM compiler which I've writeen from scratch, it supports:

Operators

Code: Select all

  + - * / ( ) / ^


Variables

Code: Select all

  Long.l
  Float.f
  String.s
Constants *New*

Code: Select all

  #Number=1
  #String="constant"
Structures *New*

Code: Select all

  Structure Test
  {
    Long.l
    Float.f
    String.s
  }

  MyVariable.Test
  MyVariable\Long=1
Enumerations *New*

Code: Select all

  Enumeration
  {
    #Constant1
    #Constant2
    #Constant3
   }
Inline ASM *New*

Code: Select all

  ASM
  {
     Mov eax,1
     ;Essentially this code block is ignored by the compiler - so no error checking is performed
   }
As before write your code in Code.txt and run Compiler.exe - don't worry about Optimizier.exe as it is run automatically. Code written between the ASM braces is subject to the optimizer as well.

A small note on brace syntax. The following are all ok (using Enumeration as an example, but applicable to all):

Code: Select all

  Enumeration {
    #Constant
  }

  Enumeration 
  {
     #Constant2
   }

   Enumeration{
     #Constant3
   }
   
   Enumeration
   {
     #Constant4 }
You can do a bit of mixing and matching - open and close braces on the same line result in a syntax error.

Enjoy!

DOWNLOAD

Posted: Mon Apr 10, 2006 3:27 am
by Shannara
You know, your compiler gets better and better with each release. .. I love {}

Posted: Mon Apr 10, 2006 7:49 am
by Killswitch
Let's hope I continue the trend :D. I'm considering what I should put into the next release, either conditional statements and loops OR some actual commands. Who'd like to see which?

Posted: Mon Apr 10, 2006 10:19 am
by Inf0Byt3
Great job! When it will be ready, I'll use it next after PureBasic :).

[Edit]
Both conditional and some commands :D. Just joking. I guess it's better to add some loops and conditionals. It's better to finish the structure first, than add a command set ;).

Posted: Mon Apr 10, 2006 11:06 am
by dagcrack
Inf0Byt3 wrote:Great job! When it will be ready, I'll use it next after PureBasic :).

[Edit]
Both conditional and some commands :D. Just joking. I guess it's better to add some loops and conditionals. It's better to finish the structure first, than add a command set ;).
I agree

ps: great stuff. But I'd call it MOCCA instead of MOCHA ..

Posted: Mon Apr 10, 2006 4:05 pm
by Killswitch
Edit: Hang on are you sure MOCCHA is the correct spelling?

Damnit. My bad spelling is the root cause of like 60% of all the bugs in my code, I should really do something about it.

Note: I've edited the name of the file, thread etc dagcrack isn't mad :P

Posted: Mon Apr 10, 2006 4:29 pm
by blueznl
and i was thinking you were calling it MACHObasic :-)

Posted: Mon Apr 10, 2006 4:38 pm
by Killswitch
You don't want to make the Pineappliser angry.....<<<

:P

Posted: Tue Oct 10, 2006 2:02 pm
by Trond
I know you've stopped working on this, but...

I was just messing around with it to see how you did the strings and to see the quality of the generated code, and I can't get the strings to work.

I do it like this:

Code: Select all

MyString.s
MyString = "Whatever"
By the way, don't stop working on this because you don't know enough ASM. All the ASM I know I've learned by working on my compiler.

Posted: Tue Oct 10, 2006 4:15 pm
by Killswitch
I've had to update the code so it works in PB 4.0, so I've included what I've used here (Main - Compiler.pb is the one to run).

I can't seem to recreate the problem you had though, can you explain what problem you had a little bit more?

P.S I've decided to move from FASM to HLA (which can compile into FASM), and that's making progress a lot easier.

Posted: Tue Oct 10, 2006 5:02 pm
by fsw
Killswitch wrote:P.S I've decided to move from FASM to HLA (which can compile into FASM), and that's making progress a lot easier.
Which hla version? 1.x or 2.x

IIRC version 1.x is no longer in development, and 2.x doesn't compile to other assemblers anymore but creates native exes.

Posted: Tue Oct 10, 2006 6:55 pm
by Trond
Killswitch wrote:I've had to update the code so it works in PB 4.0, so I've included what I've used here (Main - Compiler.pb is the one to run).

I can't seem to recreate the problem you had though, can you explain what problem you had a little bit more?

P.S I've decided to move from FASM to HLA (which can compile into FASM), and that's making progress a lot easier.
When I used the code I posted above with the version of Mocha from the first post I get the following error: Line: 3. Can't write a float into a variable of this type.

I don't have the problem with the other version you uploaded, though.

I get so confused every time I read HLA code because it puts the last operand first. So mov eax, b in fasm becomes mov b, eax in HLA.

Posted: Tue Oct 10, 2006 7:32 pm
by Killswitch
I was using 1.x, I didn't realise there was a 2.x version out - I'll have a look for it now, but (just in case) do you happen to have a link?

Posted: Tue Oct 10, 2006 8:06 pm
by fsw
Killswitch wrote:I was using 1.x, I didn't realise there was a 2.x version out - I'll have a look for it now, but (just in case) do you happen to have a link?
Well the official release didn't happen yet, but source code, binaries and documentation are already available.
Here the homepage:
http://webster.cs.ucr.edu/AsmTools/HLA/hla2/0_hla2.html

Version 1.x is AFAIK no longer in development.

Posted: Tue Oct 10, 2006 11:23 pm
by Killswitch
Thanks for that mate :)