Exotic programming languages for DOS: MoonRock.
MoonRock is a BASIC-like language with several extensions. It produces small and tight executables (MS-DOS). 8086, 80186+ or 80386+ code, with support for DOS real mode and DPMI protected mode. MoonRock began as a pet project of Rowan Crowe in late 1994. It seems to be worked on nowadays, and maybe a new version, entirely written in MoonRock, will be released one day.
This tutorial is about the installation of MoonRock 0.50 on FreeDOS 1.3 RC5. It should apply to MS-DOS 6.22 and other DOS platforms, too.
MoonRock can be downloaded from Rowan Crowe's website. The download archive contains
the program’s folder structure typical for a FreeDOS package. I extracted the files on my Windows 10 and copied the folder FDOS with its subdirectories APPINFO, DEVEL,
DOC and LINKS to a floppy diskette. On my FreeDOS machine, I copied the files of APPINFO and LINKS to the corresponding FreeDOS directory, using the following commands
(supposed that the FreeDOS installation directory is c:\freedos and that the actual directory is a:\fdos):
cd appinfo
copy *.* c:\freedos\appinfo
cd ..\links
copy *.* c:\freedos\links
I then created directories for the main program files (executables, examples) and the documentation, and copied the content of the other two subdirectories of a:\fdos
to there; here are the commands (supposed that c:\devel exists):
mkdir c:\freedos\doc\moonrock
mkdir c:\devel\moonrock
cd \fdos\doc\moonrock
copy *.* c:\freedos\doc\moonrock
cd \fdos\devel\moonrock
xcopy *.* c:\devel\moonrock /E /I /H /Q
The screenshot shows the content of c:\devel\moonrock.
By default (creation of a real mode executable), building a MoonRock program requires these 3 steps:
- Transforming the source file (.moo) into an assembly file (.asm).
- Assembling the assembly file into an object file (.obj).
- Linking the object file into an executable (.com).
Thus, an assembler is needed. The MoonRock installation files include the free ArrowSoft assembler. Normally, other assemblers, in particular
MASM, should also do it. The build can be done with one command, running the program mrc.exe. A batch file, called
moonrock.bat has been copied to c:\freedos\links. It sets the MoonRock installation directory as current and runs mrc.exe. Check this file in
order to make sure that the path specified is correct. If your FreeDOS system is installed as mine (the DEVEL directory being located directly beneath the root of the
C: drive instead of being a subdirectory of the FreeDOS installation directory), the change directory command in moonrock.bat has to be changed from
cd \FDOS\devel\moonrock to cd \devel\moonrock. Now, you can build MoonRock programs by running the command
moonrock <source-filename> [options]
Whereas the MoonRock language is well documented in the .doc file, that we copied to c:\freedos\doc\moonrock, I did not find any indications concerning the options of mrc.exe. In the source listings of some programs, the options /-c and /-m are used. No idea, what they mean (should we possibly always use them?). I also don't know, how to proceed to build DPMI protected mode programs...
The screenshots below show the build of the included sample program hello.moo (screenshot on the left), resp. the files created by the build and the execution of hello.com (screenshot on the right).
The intermediate assembly file might be interesting for people who do programming in both BASIC and assembly. The screenshot below shows the assembly code of hello.asm, created when building hello.moo.
As MoonRock is a personal project of Rowan Crowe, rather than an official programming language, you will only find some rare sample MoonRock code on the Internet. The examples included with the installation files are rather demos than "real-world" programs. Really nice done, and maybe serving as inspiration for your DOS programs, is the demo of simple windows created with MoonRock. The screenshot on the left shows the screen when the program starts up. The windows may then moved around on the screen and positioned where you want. Pushing the F1 key will open the window shown on the screenshot on the right.
I did not further try out MoonRock programming, so I can't say how useful this language is in the practice. Based on the documentation, I would say that you'll have to consider that some features aren't yet implemented. On the other hand, the executables produced are really small and possibly also faster than those cretaed by official BASIC compilers (in particular, if graphics are involved). Also, the language includes several featrures that you normally don't find in BASIC, as well as some interesting ways to do things. Here are some points that I think are worth to be mentioned:
- MoonRock includes a whole bunch of screen, file, port, and memory related functions and commands. It gives programmers the possibility to do themselves memory segment allocation, to declare pointers to near, high and far memory, to use the stack.
- Strings may be declared as C type (null terminator), Pascal type (one string length byte at offset 0), or MoonRock type (two string length bytes at offset 0, allowing strings with a length of over 65,000 characters).
- Using so-called bundels, you can define C-like structures (normally not possible in BASIC, I think).
- Using inline assembly (also normally not possible in BASIC, I think).
- It's the programmer, who can decide how data is written to the screen: call to the DOS API, call of the BIOS functions, or direct access of the video memory!
- There is an option to produce the code in a way that the functions written in MoonRock can easily be called from a QuickBASIC program. Perhaps a way to make QuickBASIC graphics programs faster by using a mixture of QuickBASIC and MoonRock code (?).
If you find this text helpful, please, support me and this website by signing my guestbook.