Live data from Hacker News

Creating a language using only assembly language

speakerdeck.com

61–67 of 67 posts

Re: Creating a language using only assembly language

#61
In the late 70s and early 80s the BASIC interpreters in personal computers were awesome exercises in assembly language.

There's a fantastic description of How Atari BASIC works. It's pretty sophisticated for something that doesn't really JIT, and the code fits in 8-10K. Link: http://users.telenet.be/kim1-6502/6502/p1.html

I was saddened by the lack of performance and sophistication of BASIC implementations on later computers. By comparison they were pedestrian, slow, buggy and harder to use.

(I haven't used BASIC since 1981, with the exception of a stint of Visual Basic in the mid 90s that was . . . eye-opening and really quite positive).

Re: Creating a language using only assembly language

#62

Earlier quoted context omitted.

I used to do some assembly on 68000, 6502 and some Z80. It's nice to have those simpler CPUs and the simpler hardware to learn an assembly language on.

I did 6502 in high school from a book and later did 6809 (EE class) and 8088 in college. The funny part was our compiler target for the CSci Compiler Course was an IBM 370 on which they taught the required assembler course. Of that group I liked the 6809 best. The 370 was ok and it sure had a lot more registers. We didn't write our compilers in assembly, but instead used the department's chosen language: Modula-2. It…

Argh! Modula-2, that brings back memories. They were still teaching it as an introductory language when I went to uni in 1997. The language seemed a tad irrelevant.

Re: Creating a language using only assembly language

#63
post #26

Earlier quoted context omitted.

Parsing LISP in assembly isn't even so hard. Without a lot of syntactic symbols, you're just finding whitespace and parens. Even syntactic sugar like ' for quote and , or @ in macros are pretty simple to parse compared to C or -- code gods forbid -- C++. What I'd dread is writing the garbage collector in assembly. Maybe you could rely on reference counting, but that could still be a mess.

> What I'd dread is writing the garbage collector in assembly. Then don't. If you're just building a lisp just so you can bootstrap your lisp compiler in lisp, the free-everything-and-quit should be a good enough GC strategy, and quite quick too.

Especially with 16 GiB of ram...

Re: Creating a language using only assembly language

#64
post #48

I wrote my own Lisp compiler in college using this as the foundation: http://schemeworkshop.org/2006/11-ghuloum.pdf

Thanks for this. Do you have a link to the extended version of the article mentioned at the end of the article. The provided link is dead now.

Unfortunately, I do not. I would try contacting the author, you never know.

Re: Creating a language using only assembly language

#65

Earlier quoted context omitted.

I did 6502 in high school from a book and later did 6809 (EE class) and 8088 in college. The funny part was our compiler target for the CSci Compiler Course was an IBM 370 on which they taught the required assembler course. Of that group I liked the 6809 best. The 370 was ok and it sure had a lot more registers. We didn't write our compilers in assembly, but instead used the department's chosen language: Modula-2. It…

Argh! Modula-2, that brings back memories. They were still teaching it as an introductory language when I went to uni in 1997. The language seemed a tad irrelevant.

It wasn't bad and did well to teach a lot of concepts, but it being on an IBM 370 made for some pain. I will say XEDIT did have some ok features but was a painful experience overall.

Re: Creating a language using only assembly language

#66
post #60

Earlier quoted context omitted.

Yeah, it's kind of a cheat. A real language built in assembler would be headaches and I bet a HLL prototype would be hidden somewhere. HLA might be doable, though, especially if macro's are used diligently for pre-optimization work. Competition has gone down from the 70's and 80's, though. I remember reading a Scheme paper that builds a software interpreter then implements the thing in hardware too. There were also p…

It's not that hard to write a "real language" compiler in assembler, lots of people have done so. Amiga-E is a good example for which source code is available. A simple, Wirth-type compiler is very straight-forward to write for most simple ALGOL-family languages. By Wirth-type compiler, I mean recursive descent parser with direct code generation (no AST). Single pass if the language allows it. You need a handful of u…

I'll be darned: your example [1] is indeed a real langauge written in M68K assembly. Also one I'd never heard of so thanks. Old guard's tenacity to get stuff done with constrained hardware and software continues to impress me.

Regarding compiler, yeah I was thinking of the complexity of one with AST and optimizations because who would use it without that? That would be an impressive compiler in assembler. Amiga-E is impressive enough, for now, while also proving the concept. Good points as well on how an assembler style could easily use templates and such during code gen phase. I think the analysis and transform phases might be the hardest in an optimizing compiler. Just a guess, though.

[1] https://en.wikipedia.org/wiki/Amiga_E

Post reply on HN