SML compiler MOJAVU
ZXNet echo conference «zx.spectrum»
From Andrew Savichev → To All 20 February 1998
Hi, All!
Hello, Tim!
>
> May you have eighty-three bags of hryvnias, Andrew!
Well, why can I have that much on my own? ;)
> TY>> Nonsense. It is very difficult to overtake a modern optimizing compiler.
> AS> What are you arguing about here? About the ABSTRACT compiler? ;)
>About a specific Watcom C++ compiler, for example.
Can any of us reproduce it in relation to the z80? at least cross-,
I’m not even talking about resident.
>
> AS> Let’s take C as an example. So everyone knows that one of its main
> AS> advantages is good portability between platforms. It pays off at the high price that any processor costs 2 - 16 rubles. register
> AS> (main and auxiliary), memory and stack.
>
>As for any high-level language.
Not for any! There is a whole class of high-level machine-oriented languages
MLYAVU, which take into account the features of a specific architecture, in our case
Spectrum and z80!
But even among ordinary Javanese languages there are languages like FORT (don’t wince, it’s too complicated for me too
) and PL/Z (I couldn’t
find either a description of it or itself :( ). But even PL/M for The 8080 was able to work with registers (look
what “good code” it generates, version 4.3 under ISIS-II, so good
that sometimes there is nothing to improve, especially if the optimizerturned on to the maximum).
One problem - it uses only 8080 commands, and what’s more - it’s very simple!
For example: there is no support for working with files (in C there is), no work with strings
(in C there is), the syntax is dinosaur-like (of course, how much older is its ancestor
PL-I than C), no C operations. Only 4 operators!, no conditional
compilation.
But there is and advantages: strong typing - as in Pascal, work with
structures and with arrays of structures (and therefore with two-dimensional arrays),
partially defined and undefined references, AT attribute, work with bits
(in version PL/M-51). So a crazy idea was born - to make a hybrid
C, PL/M and Pascal and, moreover, machine-oriented (Spectrum+z80) and compact,
so that it could exist not only as a cross-compiler, but also resident
on the Spectrum-128 (well, or 256 :)).
> AS> If we are talking about the optimal compiler for a specific
> AS> z80 processor, and moreover for a Spectrum computer, then it must
> AS> take into account the architecture features! This will be the best optimization!
> AS> But the price for this is non-portability anywhere and the inability
> AS> to use software from other platforms.
>
>And the absence of such a compiler (optimizing for Spectrum).
I’ll have to write ;)
>
> AS> True, I came across a Pascal code to C code converter:)
>Sucks.
I'm not talking about that, but about the fact that you can write a C <-> SML converter :),
to take and take away :)
>
> AS> I'm going to make a one-pass simple compiler for a very simple
> AS> hybrid language (a cross between C, PL/M and Pascal :) ) high level, SML
> AS>, for "internal use". At the output, it should give code for
> AS> assembler V.Mednonogov.
>
>What's the point?
>C (not C++) on the Spectrum is not difficult to implement. There are not many operators in it. A
>libraries may not be implemented.
And I’m not saying that it’s impossible. Igor did it! Without an optimizer and far from C,
but still a subset of C, and what works through the stack, he admitted to me that
it takes a lot of effort (re-write) to work through
registers, and the optimizer still needs to be written.
For now, he compares it with BASIC, and not with assembler!
With this approach, I admit, he gave us all (especially dummies, one of them
your humble servant and lamers) is a very powerful tool.
I’m only afraid... system people won’t take it into their hands, but it will certainly provoke a boom in simple toys
and cool shells for the press.
Although I also thought, why not try to make a cross-compiler
of standard Spectrum BASIC. Or is there already?
After all, it’s enough for thisdig into 48.rom and think a little.
I also came across a converter from BASIC codes to an ASCII file, but not with the reverse
operation?, i.e. ASCII-> BASIC codes.
Such a problem is of course more difficult, because it already has elements of a translator:
semantic and syntactic analysis and code generation.
Such a thing + a standard BASIC compiler is also a good tool
for dummies and lamers, but the capabilities are still more familiar to the majority,
although Igor’s is of course faster and uses the Laser-Basic library (sprite-based)
he uses.
I also have I want to apologize to him: here I accidentally sent a letter
intended for ru.embedded echoes.
Igor, don’t take those two lines as a mockery of yourself, it’s just that
there are “hardened built-in coders” sitting there (I’m with them, as one of them,
you know embedded is my main piece of bread, I’ve been communicating since the summer of 96) and
name your compiler a C compiler would be...not entirely appropriate.
>
>With respect, Tim. [Team Aries - Rulez Forever]
Sincerely, Andrey Savichev /CGS
From George Shepelev → To All 21 February 1998
Hallo Andrew!
Friday February 20, 1998 08:59, Andrew Savichev wrote to All:
AS> Not for everyone! There is a whole class of machine-oriented languages of high
AS> level, which take into account the features of a specific architecture, in
AS> in our case Spectrum and z80! But even among ordinary Java languages there are languages like FORT
AS> (don’t wince, it’s also too complicated for me) and PL/Z (I couldn’t find either a description of
AS> or itself :( ).
It’s a pity that at the time when I had a Spectrum as my main computer, I didn’t
come across a description of Fort. Very simple (in terms of internal architecture) and rich in terms of capabilities of the language. I came across Doc when I had already bought IBM, so
I made my own version (Modest FORTH) for it. The kernel took about 3 kilobytes, in
the complete “research” kit the system takes up less than 10 kilobytes,
allowing you to address a linear 4-gigabyte
address space from 16-bit code...
The fort is the most. machine-independent of the programming languages, since it essentially emulates a virtual Forth machine. To rewrite the version of the system for
Spectrum it takes about a week ;)
I don’t know a more convenient tool for programming experiments...
So, rather than creating “monsters” with optimizing compilation, maybe it’s better to
study the capabilities of a compiling interpreter? ;)
AS>So a crazy idea was born - to make a hybrid of C, PL/M and Pascal and
AS>, moreover, machine-oriented (Spectrum + z80) and compact, so that
AS> it could exist not only as a cross-compiler, but also
AS> resident, on the Spectrum-128 (well, or 256 :)).
Will it be possible to debug it? ;) From experience, a Fort system can be debugged in a matter of days, everything in it is so strongly interconnected, any bug pops up instantly... And changes are very easy to make, as development progressed I made
three fundamentally different systems, without much strain...
If you make an optimizing compiler for the z80, it is better to write it
in Java as a cross-system. It's stupid to try to overtake the Pentium on the Spectrum...
AS> Although I also thought, why not try to make
AS> a cross-compiler of the standard Spectrum BASIC. Or is there already?
It was already. The biggest crap of all the "system" software that
came across on the Spectrum... ;)
AS> I also came across a converter from BASIC codes to an ASCII file,
Not mine by any chance? ;)
AS> but not with the reverse operation?, i.e. ASCII-> BASIC codes. Such a problem
AS> is of course more difficult, because it already contains elements of the translator:
AS> semantic and syntactic analysis and code generation.
What kind of semantic analysis? A conversion table is written in 15 minutes.The transcoding compiler (I was not mistaken) takes about 800 bytes. ;)
Really made for IBM :(
Sincerely George
From Marat Fayzullin → To All 22 February 1998
chto na C/Pascale/C++/etc. algoritm eshe bolee/menee napominaet svoi
sobstvennyi psevdokod, a na Forthe - vse sovsem inache.
: If you make an optimizing compiler for the z80, it’s better to write it
From George Shepelev → To All 23 February 1998
Hallo Marat!
Sunday February 22, 1998 17:37, Marat Fayzullin wrote to All:
MF> : I don’t know a more convenient tool for programming experiments...
MF> : So, rather than sculpting “monsters” with optimizing compilation, maybe it’s better
MF> : Study the capabilities of a compiling interpreter? ;)
MF> Mozhno, no vse zhe medlennei, i pisat' na nem slozhnee - v tom smysle
MF> chto na C/Pascale/C++/etc. algoritm eshe bolee/menee napominaet svoi
MF> sobstvennyi psevdokod, a na Forthe - vse sovsem inache.
How can I tell you. Having understood Forth a little, you will come up with
interesting algorithms that would never have occurred to you before.
And then use them in other programming languages...
I can and specifically - I myself use some ideas inspired by Forth when
programming in Assembler and Pascal of IBM's and in Assembler of PIC processors...
As for slower - very controversial issue. A competently written program in Forte runs 2...3 times slower than an assembly program and approximately at the speed of a program compiled in C without optimization. In comparison, Pascal produces
code that runs somewhat slower. It's simply ridiculous to compare with BASIC...
And finally, Forth is the easiest programming language to implement. Write a good version of Forth forSpectrum can be done in a week,
Pascal or C will require several months.
Sincerely, George
From Ivan Mak → To All 24 February 1998
Hello George.
Sat Feb 21 1998 16:54, George Shepelev wrote to Andrew Savichev:
GS> Hallo Andrew!
GS> It’s a pity that at the time when I had a Spectrum as my main computer, I
GS> didn’t come across a description of Fort. A very simple (in terms of internal architecture)
GS> and a language rich in capabilities. I came across this doc when I had already bought
GS> IBM, so I made my own version (Modest FORTH) for it. The kernel took up
GS> about 3 kilobytes, in the full "research" kit the system
GS> occupies less than 10 kilobytes, allowing 16-bit code
GS> to address a linear 4-gigabyte address space... Forth
GS> is the most machine-independent of the programming languages, since
GS> essentially emulates a virtual Fort car. To rewrite the
GS> version of the system for the Spectrum it takes about a week ;) I don’t know of a more convenient
GS> tool for programming experiments... So, rather than sculpting
GS> “monsters” with optimizing compilation, maybe it’s better to study
GS> the capabilities of the compiling interpreter? ;)
I support FORTH with all my hands and feet!
Ivan
From Marat Fayzullin → To All 25 February 1998
: MF> chto na C/Pascale/C++/etc. algoritm eshe bolee/menee napominaet svoi
: MF> sobstvennyi psevdokod, a na Forthe - vse sovsem inache.
: How can I tell you. Having understood Forth a little, you will come up with
: such interesting algorithms that would never have occurred to you before.
: And then use them in other programming languages...
From Dmitry Grigoryev → To All 26 February 1998
Hello, Ivan!
Tuesday February 24, 1998 05:18, Ivan Mak wrote to George Shepelev:
IM> I am all hands and feet behind FORTH!
I am surprised... And why are you constantly drawn to do not what is needed, but what is
the easiest to implement? A lot of programs have been written on Specky in ASMA and C, and
there are hardly a dozen (usable) programs on Forth. At the same time, fort compilers
existed almost from the birth of Spectrum.
IM> Ivan
Regards, Dmitry (OLDMAN).
ZXNet: 095/100.1
old...@i-connect.ru