4 ms·
For a language with a C-like syntax that compiles into minimal x86 executables check out W [1]. It was designed for use in a small, single-executable self-hosti
by networked 14y ago
For a language with a C-like syntax that compiles into minimal x86 executables check out W [1]. It was designed for use in a small, single-executable self-hosting compiler targeting the HP 95LX family of early MS-DOS "calculators"/PDAs [2] and hence has no equivalent of libc; instead it expects you to code your own basic routines in assembly. I once wrote a bootable toy application in it that ran on regular x86 desktops (a command-line interpreter and calculator) and found the experience quite pleasant.
Here's a "Hello, World" in W:
write := 0x8B55, 0x8BEC, 0x085E, 0x4E8B, 0x8B04, 0x0656, 0x00B8,
0xCD40, 0x7321, 0x3102, 0x8BC0, 0x5DE5, 0x90C3
_() :=
{
write(1, "Hello, World!\r\n", 15)
}
[1] http://www.vttoth.com/CMS/index.php/projects/49 http://www.vttoth.com/CMS/index.php/projects/49
[2] https://en.wikipedia.org/wiki/HP_200LX https://en.wikipedia.org/wiki/HP_200LX
- scott_s 14y agoYou're not actually implementing your subroutines in assembly, but machine code.
- networked 14y agoWell, yes. I should have been more clear that it's a "bring your own assembler" kind of deal. You have put the machine code in hexadecimal in the final .W file before it's compiled. Back then I used a free early version of Hiew [1] to assemble the subroutine code for my project but if I did it now I'd either make some kind of a preprocessor to convert in-line assembly to machine code before the source is fed to W.COM (the compiler's executable) or modify the compiler itself to call an external assembler. You can do the latter since the compiler's source code [2] is licensed under the GNU GPL. [1] http://www.hiew.ru/ http://www.hiew.ru/ [2] ftp://gateway.vttoth.com/pub/w.zip