Page 1 of 1

CH++

Posted: Tue Jan 03, 2006 4:25 pm
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

Posted: Tue Jan 03, 2006 4:32 pm
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.

Posted: Tue Jan 03, 2006 4:49 pm
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

Posted: Wed Jan 04, 2006 3:24 pm
by remi_meier
Fixed an awkward bug :oops: (if you just tried while (a < 10) it crashed...)
(I think there are more of those)

Posted: Wed Jan 04, 2006 4:33 pm
by Fred
looks interesting, nice work !