开发者

Programming languages implemented in assembly language

Recently 开发者_开发知识库I've stumbled upon JONESFORTH, which is an interpreter for the Forth programming language implemented in plain assembly language.

I find this implementation interesting, because it shows how a language can be implemented in assembly language, although I understand that implementing a language can be a serious portability tradeoff.

So I wondered if there are any other programming languages implemented in assembly language, whose source are still available (and maybe are even still under active development)?


While it is possible to write a language implementation in assembly, for most languages it is not really advisable to do so for a variety of reasons: assembly code is notoriously difficult to develop and maintain, and it is by definition not portable.

That said, some languages are significantly easier to produce implementations for:

  • It is very easy to produce an assembly implementation for Brainfuck

  • Forth has a number of implementations in assembly, which is why it is used in the firmware of several non-PC workstations. You can find some assembly implementations for various platforms here.

  • Many BASIC interpretters have been written in assembly - in fact that was probably true for most BASIC implementations in the various home computers of the late '70s and early '80s. Some can be found here.


Several versions of Turbo Pascal since 1.0 were written in assembly language. It was the only way to fit an editor, compiler, a debugger, and the compiled program into the 64 KB RAM of the time, and it provided for blazing edit-compile-debug speeds never witnessed before.


Pico Lisp recently (in the past few years) switched from C to x86-64 assembler. That's the only example I can think of that was undertaken in the "modern" era. There are some older Lisps bootstrapped from assembler still in use. Actually wait, someone recently wrote a Scheme in ARM assembler (http://armpit.sourceforge.net/index.html). I don't know why they would have done such a crazy-sounding thing and I haven't looked at it closely. Of course it's very common to write in C and add some asm functions to implement call/cc or the like.

The BDS C compiler from the 1980's was written in 8080 assembler and the source code was released a few years ago, but it's mostly of historical interest.


Ultimately every language is implemented in assembler, a c-compiler must map + to an assembler instruction, somehow, somewhere. There is only a great variability in how large a part of a language is in the assembler kernel, and how large part of the language is defined in the language itself. If you look at jonesforth you will see that a part of the kernel, even in the assembler file, is in fact Forth code, not assembler code.

So the criterion may be whether the language of the main program is assembler or the language itself. More important may be whether a languages needs another language to be build, e.g. a lisp implementation in Pascal, Gforth implemented using C. It may be a liability to be dependant from a compiler that you don't control, and language standards that may make some practices obsolescent. Keeping up with new features of a processor in a compiler, requires in depth assembly knowledge, whether your compiler is written in itself or in assembly.

As long as you have the source the language is not dead. So you can look at FIG-Forth's (1980). jonesforth has part of its inspiration from my ciforth, an i86 assembler Forth for 16/32/64 bits.

I can recomment especially `` yourforth '' a Forth in assembler that I made specifically for educational purposes. It has exercises, but those are not completed yet: https://bitbucket.org/avanderhorst/yourforth


Although not purely in assembly, the vm and some other sections of luajit is written in macro'd assembly, for multiple platforms (mainly x86), purely for the speed it provides (mike paul may have other reasons, but I beleive this is the main one). The macro processor is also custom built as well, using lua however.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜