cas Posted December 31, 2005 Share Posted December 31, 2005 Hi, I just found this text from Henry G. Baker describing a 6502 Compiler for a extended 6502 Assembly Language called COMFY. The compiler is written in Lisp (GNU Emacs Lisp) and compilation can be started from the Editor. Description of the Comfy Language: http://home.pipeline.com/~hbaker1/sigplannotices/COMFY.TXT Lisp Code: http://home.pipeline.com/~hbaker1/sigplannotices/CFYCMP1.LSP Description of the 6502 Compiler (TeX Source): http://home.pipeline.com/~hbaker1/sigplann...column04.tex.gz Maybe something to investigate for a boring new years day Best regards and Happy 2006! Carsten Quote Link to comment Share on other sites More sharing options...
mos6507 Posted January 2, 2006 Share Posted January 2, 2006 In ALGOL-like notation: x:=1; while x<11 do begin print x; x:=x+1 end; In COMFY notation: x:=1; ~(x<11 -> print x; x:=x+1)^oo I think this about says it all. Algol looks a lot like what Basic evolved into and certainly reads easier than Comfy. I think history has proven that a keyword-driven language is easier to read than a punctuation-driven language. Quote Link to comment Share on other sites More sharing options...
danwinslow Posted January 2, 2006 Share Posted January 2, 2006 I agree. COMFY looks awful. Algol was the ancestor for all modern block structured languages; PASCAL,ADA,C,C++. etc. Basic I think actually started out as a different animal entirely, and only added certain block structure features later as they became widely accepted. Quote Link to comment Share on other sites More sharing options...
jaoswald Posted January 4, 2008 Share Posted January 4, 2008 (edited) In ALGOL-like notation: x:=1; while x<11 do begin print x; x:=x+1 end; In COMFY notation: x:=1; ~(x<11 -> print x; x:=x+1)^oo I think this about says it all. Algol looks a lot like what Basic evolved into and certainly reads easier than Comfy. I think history has proven that a keyword-driven language is easier to read than a punctuation-driven language. This is actually a bit unfair; that notation is from Baker's more mathematical description of the theory. ^oo is the text form of a "superscript infinity symbol", which is the mathematical expression of the COMFY concept "repeat forever", which you could notate however you want in your actual language. In a Lisp-based implementation, the syntax would be something like (seq (load x 1) (loop (< x 11) (print x) (inc x))) Or, in Algol-y terms seq { x = 1; loop { x < 11; print x; x += 1; } } The only tricky thing is that "seq" and "loop" have the special feature of immediately exiting the sequence or loop if any statement inside "fails", which in this example, only the < test can fail. It's this kind of "dumbing down" of things like loop tests that makes the language very simple to compile to machine code. The compiler for the 6502 example fits in a couple pages of code (although it is hard to read because Baker used i & j instead of x & y, and didn't use standard mnemonics for 6502 operations, etc. It took me several hours of reading to really understand it.) With Lispy macros, you can actually create all sorts of nifty "shortcuts." One that he introduces is basically (forx 0 12 <things to do>) which automatically compiles to LDX #0 LOOP CPX #12 BCS EXIT <things to do> INX JMP LOOP EXIT ... and the compiler is smart enough that it can emit LDX #0 LOOP CPX #12 BCC SKIP JMP EXIT SKIP <things to do> INX JMP LOOP EXIT .... in the case where <things to do> takes longer than 128 bytes. Two better articles are the ACM typeset versions of Baker: The COMFY 6502 compiler of the TeX paper and Baker: COMFY---A Comfortable Set of Control Primitives for Machine Language Programming of the COMFY.TXT if you can get through the ACM portal. Edited January 4, 2008 by jaoswald Quote Link to comment Share on other sites More sharing options...
aofl Posted April 11, 2008 Share Posted April 11, 2008 Here are links to the documents already formatted from the author's home page, so you don't need to pay ACM: http://home.pipeline.com/~hbaker1/sigplann...es/sigcol03.pdf http://home.pipeline.com/~hbaker1/sigplann...es/sigcol04.pdf A Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.