Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.compilers > #203 > unrolled thread
| Started by | Billy Mays <81282ed9a88799d21e77957df2d84bd6514d9af6@myhashismyemail.com> |
|---|---|
| First post | 2011-07-18 16:16 -0400 |
| Last post | 2011-08-08 22:54 +0100 |
| Articles | 14 — 13 participants |
Back to article view | Back to comp.compilers
Language Design Billy Mays <81282ed9a88799d21e77957df2d84bd6514d9af6@myhashismyemail.com> - 2011-07-18 16:16 -0400
Re: Language Design Roberto Waltman <usenet@rwaltman.com> - 2011-07-18 18:10 -0400
Re: Language Design Srinivas Nayak <sinu.nayak2001@gmail.com> - 2011-07-18 22:54 -0700
Re: Language Design anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2011-07-19 13:12 +0000
Re: Language Design Andreas Zwinkau <zwinkau@kit.edu> - 2011-07-20 13:26 +0200
Re: Language Design mac <acolvin@efunct.com> - 2011-07-23 01:11 +0000
Re: Language Design Christophe de Dinechin <christophe.de.dinechin@gmail.com> - 2011-07-23 08:17 -0700
Re: Language Design Oleg Sesov <osesov@gmail.com> - 2011-07-23 14:58 -0700
Re: Language Design Gene <gene.ressler@gmail.com> - 2011-07-26 10:28 -0700
Re: Language Design Roberto Waltman <usenet@rwaltman.com> - 2011-07-28 13:22 -0400
Re: Language Design torbenm@diku.dk (Torben Ægidius Mogensen) - 2011-08-08 16:11 +0200
Re: Language Design tm <thomas.mertes@gmx.at> - 2011-07-27 08:11 -0700
Re: Language Design "s_dubrovich@yahoo.com" <s_dubrovich@yahoo.com> - 2011-08-04 18:43 -0700
Re: Language Design for a tiny processor "BartC" <bc@freeuk.com> - 2011-08-08 22:54 +0100
| From | Billy Mays <81282ed9a88799d21e77957df2d84bd6514d9af6@myhashismyemail.com> |
|---|---|
| Date | 2011-07-18 16:16 -0400 |
| Subject | Language Design |
| Message-ID | <11-07-027@comp.compilers> |
I am trying to design a programming language for a simple processor (16 bit, ~10 instructions, 16 registers). I am not sure what a language actually needs in order to be more useful than pure assembly, but is also reasonable to implement. I had originally tried to make a RPN style language where the language is purely stack based, but I realized it wouldn't be Turing complete. I'd rather not just re implement C or other commonly used languages, but I'm having a hard time coming up with something I'd actually want to use. Any advice for a newbie? -- Bill [Rather than trying to invent yet another language, I'd retarget some existing 16 bit C compiler. -John]
[toc] | [next] | [standalone]
| From | Roberto Waltman <usenet@rwaltman.com> |
|---|---|
| Date | 2011-07-18 18:10 -0400 |
| Message-ID | <11-07-029@comp.compilers> |
| In reply to | #203 |
Billy Mays wrote: >I am trying to design a programming language for a simple processor >(16 bit, ~10 instructions, 16 registers). I am not sure what a >language actually needs in order to be more useful than pure assembly, >but is also reasonable to implement. > >I had originally tried to make a RPN style language where the language >is purely stack based, but I realized it wouldn't be Turing complete. >I'd rather not just re implement C or other commonly used languages, >but I'm having a hard time coming up with something I'd actually want >to use. > >Any advice for a newbie? Start were newbies like you (and me) should. These books describe simple compilers that could be ported to a new processor in a reasonably short time. [ Sorry, they are "C or other commonly used languages" ] "Brinch Hansen on Pascal Compilers" - P.B.Hansen "Compiler Construction" - N. Wirth The 2nd is available on-line, as well as the "Small-C" compiler. -- Roberto Waltman
[toc] | [prev] | [next] | [standalone]
| From | Srinivas Nayak <sinu.nayak2001@gmail.com> |
|---|---|
| Date | 2011-07-18 22:54 -0700 |
| Message-ID | <11-07-030@comp.compilers> |
| In reply to | #203 |
Hi Bill, Why do you think a stack based language shall not be turing complete? You can get some ideas from http://en.wikipedia.org/wiki/Esoteric_programming_language http://en.wikipedia.org/wiki/Brainfuck http://en.wikipedia.org/wiki/FALSE "A Turing tarpit is a Turing-complete programming language whose number of commands, operators, or equivalent objects is very small. These include brainfuck (8 commands, all with 0 operands), OISC (1 command, 3 operands), and Thue (1 command, 2 operands)." - Wiki Many stack based languages are turing complete. Sincerely, Srinivas Nayak
[toc] | [prev] | [next] | [standalone]
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Date | 2011-07-19 13:12 +0000 |
| Message-ID | <11-07-031@comp.compilers> |
| In reply to | #203 |
Billy Mays <81282ed9a88799d21e77957df2d84bd6514d9af6@myhashismyemail.com> writes: >I am trying to design a programming language for a simple processor >(16 bit, ~10 instructions, 16 registers). I am not sure what a >language actually needs in order to be more useful than pure assembly, >but is also reasonable to implement. > >I had originally tried to make a RPN style language where the language >is purely stack based, but I realized it wouldn't be Turing complete. Why not. Anyway, you can implement Forth or something similar, which is Turing-complete and relatively easy to implement. - anton -- M. Anton Ertl anton@mips.complang.tuwien.ac.at http://www.complang.tuwien.ac.at/anton/
[toc] | [prev] | [next] | [standalone]
| From | Andreas Zwinkau <zwinkau@kit.edu> |
|---|---|
| Date | 2011-07-20 13:26 +0200 |
| Message-ID | <11-07-034@comp.compilers> |
| In reply to | #203 |
My first thought would be to implement yourself a Forth. Philosophy and Goals: http://www.forth.com/resources/evolution/evolve_1.html For the implementation read JonesForth: http://rwmj.wordpress.com/2010/08/07/jonesforth-git-repository/ c2 Wiki for lots of Links and Discussion: http://c2.com/cgi/wiki?ForthLanguage -- Andreas Zwinkau Karlsruhe Institute of Technology (KIT) Institut fC<r Programmstrukturen und Datenorganisation (IPD) Lehrstuhl Prof. Snelting Adenauerring 20a 76131 Karlsruhe Phone: +49 721 608 48351 Fax: +49 721 608 48457 Email: zwinkau@kit.edu Web: http://pp.info.uni-karlsruhe.de/person.php?id=107
[toc] | [prev] | [next] | [standalone]
| From | mac <acolvin@efunct.com> |
|---|---|
| Date | 2011-07-23 01:11 +0000 |
| Message-ID | <11-07-035@comp.compilers> |
| In reply to | #203 |
> I'd rather not just re implement C or other commonly used languages, but > I'm having a hard time coming up with something I'd actually want to use. XPL? It was populsr in the 16-bit days
[toc] | [prev] | [next] | [standalone]
| From | Christophe de Dinechin <christophe.de.dinechin@gmail.com> |
|---|---|
| Date | 2011-07-23 08:17 -0700 |
| Message-ID | <11-07-036@comp.compilers> |
| In reply to | #203 |
On Jul 18, 10:16 pm, Billy Mays
<81282ed9a88799d21e77957df2d84bd6514d9...@myhashismyemail.com> wrote:
> I am trying to design a programming language for a simple processor
> (16 bit, ~10 instructions, 16 registers). I am not sure what a
> language actually needs in order to be more useful than pure assembly,
> but is also reasonable to implement.
Bill,
Is your objective to invent a language, or have a language that works
on that simple processor? You may be interested in XL (http://
xlr.sf.net). The XL2 portion of it is very easy to retarget, and it is
a high level language which you can then tweak to explore various
language or CPU design ideas.
Basically, say you want to add a 16-bit unsigned type and the
associated multiply-add, where the assembly syntax is "fma16 target =
src1, src2, src3", all you need to do is:
- Modify xl2/native/library/runtime/C/xl_builtins.xs with the required
language declarations:
type uint16 is XL.BYTECODE.uint16
function FusedMultiplyAdd(X, Y, Z: uint16) return uint16 written
X*Y+Z is XL.BYTECODE.fma_uint16
- Add the corresponding target syntax in the bytecode file
fma_uint16 "fma16 $1 = $2, $3"
If that approach works for you, you can create your own "runtime" by
replicating the "C" directory (which targets standard C compilers) and
creating a directory for your target, say "myproc". Then, you run the
compiler with "nxl -r myproc foo.xl" and it will compile using this
runtime.
Hope this helps
Christophe
[toc] | [prev] | [next] | [standalone]
| From | Oleg Sesov <osesov@gmail.com> |
|---|---|
| Date | 2011-07-23 14:58 -0700 |
| Message-ID | <11-07-037@comp.compilers> |
| In reply to | #203 |
On 19 P8QP;, 03:16, Billy Mays <81282ed9a88799d21e77957df2d84bd6514d9...@myhashismyemail.com> wrote: > I am trying to design a programming language for a simple processor > (16 bit, ~10 instructions, 16 registers). B I am not sure what a > language actually needs in order to be more useful than pure assembly, > but is also reasonable to implement. > > I had originally tried to make a RPN style language where the language > is purely stack based, but I realized it wouldn't be Turing complete. > I'd rather not just re implement C or other commonly used languages, > but I'm having a hard time coming up with something I'd actually want > to use. 10 instructions CPU is not very capable, however many compiler construction books contain examples of tiny language compilers targeting similar environment, so they might be used to start with. To name a few: http://ssw.jku.at/Coco/ Coco/R parser generator and book (older editions available on the web) contains pretty simple Taste compiler. http://www.cs.sjsu.edu/~louden/cmptext/ Compiler Construction by Kenneth C. Louden. Rather old, but still might be interesting. http://foja.dcs.fmph.uniba.sk/kompilatory/docs/compiler.pdf Compiler Construction using Flex and Bison by Anthony A. Aaby. and others.
[toc] | [prev] | [next] | [standalone]
| From | Gene <gene.ressler@gmail.com> |
|---|---|
| Date | 2011-07-26 10:28 -0700 |
| Message-ID | <11-07-038@comp.compilers> |
| In reply to | #203 |
On Jul 18, 4:16 pm, Billy Mays <81282ed9a88799d21e77957df2d84bd6514d9...@myhashismyemail.com> wrote: > I am trying to design a programming language for a simple processor > (16 bit, ~10 instructions, 16 registers). I am not sure what a > language actually needs in order to be more useful than pure assembly, > but is also reasonable to implement. ... > -- > Bill > [Rather than trying to invent yet another language, I'd retarget some >existing 16 bit C compiler. -John] The old Turbo Pascal 2.0 dialect was pretty remarkable. There was a version for Z80 (CP/M) and 8086 (MSDOS). I think the whole compiler was only 50K or so. The runtime was tiny (as it had to be), yet included floating point (6-byte proprietary), variable-length strings (up to 255 chars, not ANSI standard), sets over domains up to 255 in cardinality, primitive extensions to write memory and I/O ports, graphics (x86 only), an overlay system that was good enough to handle a 200K SLOC program for on the Z80, and probably some other stuff I'm foregetting. All this is to say that you could a lot worse than to re- implement this dialect of Pascal as well as it was in this case. Pascal is also straightforward to compile, especially if you don't allow nested functions/procedures (although Turbo did).
[toc] | [prev] | [next] | [standalone]
| From | Roberto Waltman <usenet@rwaltman.com> |
|---|---|
| Date | 2011-07-28 13:22 -0400 |
| Message-ID | <11-07-040@comp.compilers> |
| In reply to | #214 |
Gene wrote: >The old Turbo Pascal 2.0 dialect was pretty remarkable. There was a >version for Z80 (CP/M) and 8086 (MSDOS). I think the whole compiler >was only 50K or so. The CPM 3.0 version was 31K - As you said, remarkable. (Available here: http://www.retroarchive.org/cpm/lang/lang.htm ) -- Roberto Waltman
[toc] | [prev] | [next] | [standalone]
| From | torbenm@diku.dk (Torben Ægidius Mogensen) |
|---|---|
| Date | 2011-08-08 16:11 +0200 |
| Message-ID | <11-08-009@comp.compilers> |
| In reply to | #214 |
Gene <gene.ressler@gmail.com> writes: > The old Turbo Pascal 2.0 dialect was pretty remarkable. There was a > version for Z80 (CP/M) and 8086 (MSDOS). I think the whole compiler > was only 50K or so. [...] > Pascal is also straightforward to compile, especially if you don't > allow nested functions/procedures (although Turbo did). Turbo Pascal used shallow binding, which makes nested procedures relatively simple to implement, though it made reference parameters behave in a non-standard way. With shallow binding, each variable name has its own global memory address. When you during execution pass a variable declaration, you stack the current value of the variable and set the new value according to the declaration. When you exit the scope of the declaration, you restore the old value from the stack. IIRC, later versions of Turbo Pascal changed this to be more standard compliant (i.e., by using deep binding). Torben
[toc] | [prev] | [next] | [standalone]
| From | tm <thomas.mertes@gmx.at> |
|---|---|
| Date | 2011-07-27 08:11 -0700 |
| Message-ID | <11-07-039@comp.compilers> |
| In reply to | #203 |
On 18 Jul., 22:16, Billy Mays <81282ed9a88799d21e77957df2d84bd6514d9...@myhashismyemail.com> wrote: > I am trying to design a programming language for a simple processor > (16 bit, ~10 instructions, 16 registers). You are trying to do two things simultaneously: Designing a language and implementing it for a processor. I suggest you concentrate on one part. Either implement an existing language, like C, for this processor, or design a language and forget about the processor. When you implement an existing language you can build on the work of others. Perhaps you can modify an existing compiler and use existing libraries and documentation. Writing a runtime library is usually much more work than writing a compiler. For an existing language you can also expect to find helping hands and useful information in the internet. When you design a language your implementation can use an interpreter or you compile to some well known base, like C or JVM. This way you can also build on the work of others. Your language needs features, that are not present or not well supported in other languages. Otherwise people will not be interested. Getting other people interested might not be your goal, but it can lead to helping hands (this was the reason, why I released Seed7). > Any advice for a newbie? If you a relly a newbie, I suggest you start with a simpler project. Greetings Thomas Mertes -- Seed7 Homepage: http://seed7.sourceforge.net Seed7 - The extensible programming language: User defined statements and operators, abstract data types, templates without special syntax, OO with interfaces and multiple dispatch, statically typed, interpreted or compiled, portable, runs under linux/unix/windows.
[toc] | [prev] | [next] | [standalone]
| From | "s_dubrovich@yahoo.com" <s_dubrovich@yahoo.com> |
|---|---|
| Date | 2011-08-04 18:43 -0700 |
| Message-ID | <11-08-005@comp.compilers> |
| In reply to | #203 |
On Jul 18, 3:16 pm, Billy Mays <81282ed9a88799d21e77957df2d84bd6514d9...@myhashismyemail.com> wrote: > I am trying to design a programming language for a simple processor > (16 bit, ~10 instructions, 16 registers). I am not sure what a > language actually needs in order to be more useful than pure assembly, > but is also reasonable to implement. I'd list the top three as: consistant, readable, provide high level flow control constructs. You can get that with assembly language and a separate macro pre- processor. > I had originally tried to make a RPN style language where the language > is purely stack based, but I realized it wouldn't be Turing complete. > I'd rather not just re implement C or other commonly used languages, > but I'm having a hard time coming up with something I'd actually want > to use. > > Any advice for a newbie? No one has mentioned Grimley Evans's bcompiler. It is actually several step-wise compilers to bootstrap his BCC compiler, from nothing. He borrows the stream i/o convenience of linux; stdin, stdout, redirection to/from a file and the elf file format. here: http://homepage.ntlworld.com/edmund.grimley-evans/ Anyway, food for thought.. Steve
[toc] | [prev] | [next] | [standalone]
| From | "BartC" <bc@freeuk.com> |
|---|---|
| Date | 2011-08-08 22:54 +0100 |
| Subject | Re: Language Design for a tiny processor |
| Message-ID | <11-08-011@comp.compilers> |
| In reply to | #203 |
"Billy Mays" <81282ed9a88799d21e77957df2d84bd6514d9af6@myhashismyemail.com> > I am trying to design a programming language for a simple processor > (16 bit, ~10 instructions, 16 registers). I am not sure what a > language actually needs in order to be more useful than pure assembly, > but is also reasonable to implement. > > I had originally tried to make a RPN style language where the language > is purely stack based, but I realized it wouldn't be Turing complete. > I'd rather not just re implement C or other commonly used languages, > but I'm having a hard time coming up with something I'd actually want > to use. Is this a commercially available processor with a part-number, or something you are also creating (or perhaps exists only in an emulator)? Having a look at the instruction set (with only ten instructions, you could just list them...) it might make it easier to offer advice on what sort of language might be viable and whether it would make programming much easier. -- Bartc
[toc] | [prev] | [standalone]
Back to top | Article view | comp.compilers
csiph-web