CH++

Developed or developing a new product in PureBasic? Tell the world about it.
remi_meier
Enthusiast
Enthusiast
Posts: 468
Joined: Sat Dec 20, 2003 6:19 pm
Location: Switzerland

CH++

Post by remi_meier »

The name is debatable :wink:

Long time ago (about half a year) I made an announcement (I think only
in the German forums) that I would rewrite my old compiler (German
forums again). Before 3 weeks I started (had to, because I have a dead-
line for this 'product', spring 06 incl. documentation (following)).
The compiler is now a lot more exemplary (not really every part of the
source) including a new parser which generates a nice ASM code. Now the
stack isn't necessary anymore for calculations viz an error message like
in PB appears (Out of Registers) if there aren't enough registers anymore.

The code is ideally written in WordPad (couldn't find another editor which
encodes correctly). The syntax is a mix out of Pascal, C and Basic (in this
order). You can find a website for the project under
http://mypage.bluewin.ch/remimeier/recu ... ojekte.htm
the site mostly isn't up to date (i. c. the example isn't working at the mo-
ment ^^) and in German.

A direct link to the download (incl. sources, examples and poor docu (GE)):
http://mypage.bluewin.ch/remimeier/zip/compiler2.zip


To see the quality for people with ASM knowledge here a little example:

Code: Select all

a := a + (6 * 7); 
a := MessageRequester("hallo", "welt"); 
a := (a + 3) * (b + (2 - c)); 
a := (a + 3);
compiles to:

Code: Select all

MOV Ebx, dword 6 
IMUL Ebx, dword 7 
MOV Esi, dword [Ebp + 0] 
ADD Esi, Ebx 
MOV dword [Ebp + 0], Esi 
PUSH dword s_S2 
PUSH dword s_S1 
CALL _MessageRequester 
MOV dword [Ebp + 0], Eax 
MOV Ebx, dword [Ebp + 0] 
ADD Ebx, dword 3 
MOV Esi, dword 2 
SUB Esi, dword [v_c] 
MOV Edi, dword [v_b] 
ADD Edi, Esi 
IMUL Ebx, Edi 
MOV dword [Ebp + 0], Ebx 
MOV Ebx, dword [Ebp + 0] 
ADD Ebx, dword 3 
MOV dword [Ebp + 0], Ebx
As you can see, there isn't any constants folding (I think it wont follow)
and other missing optimizations which PB already has. It would be just
a matter of time to implement them, but I don't have it. The work is com-
plete for me (just some Bug-fixings) because this was the aim of the
project.
This version is early Alpha and probably there are a lot of bugs :P

I hope somebody is interested in this compiler and I wish you all a happy
New Year!

greetz
Remi
Athlon64 3700+, 1024MB Ram, Radeon X1600
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

That looks really cool.

I will have a good play with this tonight.

How far do you intend this to go? I mean, will it compile full gui's etc? The .obj files you link to, are they MS COFF format or the (proper! :D ) COFF format (hang on, didn't MS design COFF?) and can you link to any such object file?

Once again, it looks very impressive; congrats.
I may look like a mule, but I'm not a complete ass.
remi_meier
Enthusiast
Enthusiast
Posts: 468
Joined: Sat Dec 20, 2003 6:19 pm
Location: Switzerland

Post by remi_meier »

Thx!

I won't go any further because I don't have enough time. The only variable
types are int and string. So this will limit to just some test programs.
The .obj files are format MS COFF (example in \libraries\MessageReq.ASM
or for C in Documents\Sprachbeschreibung.doc -> 1.4.4) and you can
link to any such object file but at the moment you are limited to use
crt.lib, kernel32.lib and user32.lib. I don't know, but perhaps you can also
link to other .obj formats as it just uses polink.exe

As you can see, the source is included. Feel free to use any part as long as
you give me credits :wink:

greetz
Remi
Athlon64 3700+, 1024MB Ram, Radeon X1600
remi_meier
Enthusiast
Enthusiast
Posts: 468
Joined: Sat Dec 20, 2003 6:19 pm
Location: Switzerland

Post by remi_meier »

Fixed an awkward bug :oops: (if you just tried while (a < 10) it crashed...)
(I think there are more of those)
Athlon64 3700+, 1024MB Ram, Radeon X1600
Fred
Administrator
Administrator
Posts: 18237
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

looks interesting, nice work !
Post Reply