MERCAT V0.3 ============ Beta release (C) 1997-8 David Given 18/11/1998 INTRODUCTION ============ This is a beta release of my Mercat virtual machine and compiler. The Mercat system comprises a compiler, assembler and a run-time system. The run-time system is written in C; the rest of it is, of course, written in Mercat. All languages that are worth their weight in HD floppies are self-hosting. QUICK START GUIDE ================= You will need a run-time system. You can download the source (the posix*.zip package) or a binary (linux*.zip, dos32*.zip, dos16*.zip). The end result is a program called `mi' (or `mi.exe'). Now, do this: mi snake.mo And you will get one of my demonstration programs. (Hint: cursor keys.) Files ending in .mo are Mercat object files. Mercat HLL source files use the .mi extension. Mercat-P files, that is, assembly files, use .mp. To compile a source file do this: mi mic.mo foobar.mi foobar.mp mi masm.mo foobar.mp foobar.mo If you're using DOS or Linux there are some scripts that will help: com foobar.mi foobar.mp masm foobar.mp foobar.mo Currently, the only documentation is the source. MANIFEST ======== Or, what the **** am I looking at anyway? com.awk The original cross-compiler I wrote. In awk. No, I'm not masochistic, I had reasons for the language choice. It is now completely obsolete (the Mercat compiler supports rather more features than the awk one) and is included for interest value. com.bat com Shorthand scripts to run the compiler. editor.mi editor.mo Source and binary for ME, the Mercat Editor. This is a full-screen editor I wrote as a demonstration and test for the bitmap text library. It supports pull-down menus, decent keyboard support, and so on. It doesn't have many features but it's a start. Eventually, the menu library this uses will be exported as a stand-alone library. snake.mi snake.mo Source and binary for Sea Snake, an incredibly tacky snake game I hacked up. Demonstrates the time functions and how to write action(!) games in Mercat. mic.mi mic.mo Source and binary for the compiler itself. This is the biggie. This is where all my time got spent. If you want to modify this, go ahead, but be very, very careful. Always remember to back up the old binary. Syntax: mi mic.mo masm.mi masm.mo Source and binary for the assembler. This converts .mp files emitted by the compiler into .mo files that are ready to run. This originally dated from the days before I implemented structures; the implementation is very slow (lots of dictionary updates) and produces awful code (all instructions are emitted using the long-form opcode, rather than picking the most appropriate one --- so, `addi 2' takes five bytes). Take a look at a .mo in a hex editor and you'll see. I need to rewrite this completely some time. Syntax: mi masm.mo paranoia.mi paranoia.mo Yes, this is the original Mercat test program! As featured in the alpha versions! It's a quick-n-dirty port of the classic BSD game. standard.ml The Mercat standard library. The equivalent of stdio.h. You can't do anything without this. scr.ml The bitmap text library, as used by Snake and ME. Provides the ability to write text in any colour to any point on the screen, and to read single characters from the keyboard (and handle extended keys). scrx.ml SCR extensions. Useful stuff, written in Mercat; currently one function that reads a line of text from the user --- in a text box, which scrolls, supports editing with the cursor keys, etc. ME uses it to get filenames. internet.ml Very basic networking functions. Currently allows a Mercat program to send an email message, on Linux systems only. I need this for an internal project of my own (watch this space). DANGER, WILL ROBINSON! ====================== This is an beta release. It's not complete, it's not bug-free. The compiler has no optimisation. The assembler is antioptimised; it always uses the longest form of the instructions because there's a bug in it (and it needs a rewrite anyway). That said, this is v0.3 rather than v0.2.1. It should be a lot more stable. I've added lots of new features, and filled in a lot of the holes; we now have "delete" and "insert" pseudofunctions that insert and delete entries from arrays (you can't delete from dictionaries, though). We also have a big new feature: structures. Take a look at the editor source, which relies on them inherently. There's one other strange thing: rather embarassingly, my original awk cross-compiler (supplied; com.awk) is a bit faster than the Mercat version. Eeek! I've got a feeling this is because I have a very inefficient parser (lots of string concatenation). If anyone feels the sudden urge to improve things, I would only too happy. DOCUMENTATION ============= You're reading it. FEEDBACK ======== Comments should go to dg@tao.co.uk. Food, money, mailbombs etc go to 31 Sturbridge Close, Lower Earley, Reading RG6 4EE. (Actually, don't send me that last. This is a rented house.) LICENSE ======= The little grey men with briefcases made me put this bit in. Anyway. It's mine, all mine[*], you can use it for non-commercial purposes but can't redistribute it without my permission. If you wish to make changes send them back to me and I'll integrate them into the rest of the system. [*] Except for the Paranoia game. This is my port of Tim Lister's implementation. He, in turn, took the text from an article by Sam Shirley. See the top of paranoia.mi for more information.