The Mocka Modula-2 compiler using Slackware Linux.
This page describes my experiments with the Mocka Modula-2 compiler. The Mocka compiler is a quality product,
'Made in Germany'. People prefer German powertools (Metabo) over US (Black & Decker) or japanese brands
(Makita), and for a reason. The same goes for kitchens, cars and even holidays. So why should Modula-2
compilers be an exception to this rule?
The Mocka compiler is a product of Karlsruhe university's Mathematics department. It is available for just about any UNIX system. Also for Linux and FreeBSD. All Mocka compilers are somewhat commercial, but the versions for Linux and FreeBSD are GPL style FREE.
I decided to use Mocka while it is GNU GPL-style FREE and since this compiler supplies a framework of
functionality. So we (did I say 'we'?) still have to write the lot of the functions needed for our programs.
This is half the fun, so why get XDS if that compiler makes life TOO easy...
Another reason for using Mocka is that it has an IDE (Integrated Development Environment). It's not a fancy IDE, without colours and mousebars and beeps and bells. But still, it's fast, flexible and it guides you through the production of programs.
The IDE lets you edit, compile, run, your sources with very simple commands like 'i soup'. This will start your favorite editor for working on "soup.mod". With 'p soup' you start a compilation of that source.
If the compiler finds errors (which of course is very unlikely with people like us) it merges the error
messages into the source file, in the right places, so that debugging becomes a charm.
After you fixed the error, Mocka removes the error messages from the source file again and you can initiate a new compilation (by just pressing Enter).
If the source is now free of errors, it will immediately compile and link to an executable. You don't need MAKE files, the compiler takes care of all. Compilation is fast and it will take care of recompiling library modules if necessary. You can just concentrate on programming. Mocka takes care of all the accounting rules, implied on you when you think you need a C compiler.
Below you see a list with projects I made with the Mocka Modula-2 compiler. If you want to know more of a
specific project, just click on the related link in the navigator.
Have fun. If you find a dead link or other error in the site or the software, please send me a short E-mail describing the problem and I will try to fix it ASAP. Send your mail to the address in the navigator frame.
There's a myth that humans can read any text, as long as the first and last character of each word is correct, even
if all other letters are jumbled up. For simple textx this is true. But for complex texts?
I made a program that changes words such that the first and last characters remain the same but all other characters are randomly distributed across the word. Believe me: you wouldn't be able to comprehend a C++ manual anymore...
Determine average and stabdard deviation (sigma) for a data set in a file.
Graphic programming in X11 brought to you.... It's neat!
I published about this in the past but now it is time to make a MODULE for it: system commands. The modyule is called "Unix" since it will execute Unix system commands, i.e. the commands normally issued from the command line. But now from within a compiled program.
Published a random number generator plus support files (to check the trueness of the generator).
Murus got too big so it gets its own section. Use the navigator to get there.
In an upcoming project, involving Tcl/Tk programming, I need a way to discover the IO address of andf I/O port. So the 'findPort' program was made.
qMy digital camera's all are better than 6 MP. Yet my digital photo frame has only 800 x 480 or roughly 400 kilopixel. So I made a program to make a batch file to convert big pictures to smaller ones, using ImageMagick's "convert" program.
Some of you may know it, but I have been working for years now on my own small compiler. I tried to do it my
way with the m4m SynChk program. Then I tried it with Oberon0 but that was too complex. Then I tried the CoCo
package and started reading all Compiler Construction books written by Niklaus Wirth.
Then FP pointed me to PL/0, a demonstration language from the early releases from Wirth's compiler construction books. This was much better, alas: written for an obsolete compiler. And it was written by a genius whereas I am not one.
So now I have decidced to write my own Plov compiler, loosely based on Wirth's PL/0 and Oberon0 compilers, with the distinction that my sources are easier to read and understand. So no abbreviations or cryptical symbolnames. Let's see how far we get. Visit the Plov project via the navigator on the right.
Filter through the Webalizer access log files to find 404 error messages (for the time being) and later possibly also other messages or texts.
IOrd and IOwr
These are command line utillities for reading data from and writing data to discrete I/O ports. Developed to be used with Tcl/Tk scripts.
Parilux 1 : Feedback device for programmers
Your first program may well have been a version of "Hello world!". Your second program may well have been one that asked for a string which was later printed with all letters CAPitalised. Sooner or later you want to wet your appetite on something outside the computer. And this is where Parilux comes in. It does nothing mechanical, flashes some lights, yet is safe and has lots of potential. Estimated cost: €10 in parts.
Screen : use ANSI control codes to build up a text screen
Learn how to create colourful text terminal screens using simple ANSI control codes (just like in DOS) instead of learning the very difficult ncurses. Lots of source code examples.
Procs : consult '/proc/ioports' for determining IO port addresses
Determine IO port addresses by consulting /proc/ioports.
Conv : Create batchfiles
When I made seveal screenshots with the 'xine' movieplayer, I end up with lots of PNG files which need to be converted to JPG and sometimes they also need to be changed in size. I used to do this manually, or in a batch file. But the batch files were timeconsuming to make. So I wrote this small program. Read all about it.
Murus: the solution
While translating the Murus pages, I found out that Dr Maurer reinvented the wheel, so that his libraries with old functions are in line with the new libc libraries on which Linux is built. Many older Mocka libraries sometimes give strange results. The solution is: use Murus! You get a GUI development environment for free in the deal!
There's a problem when trying to find the filesize. Normally you use 'stat' and Linux returns a lot of data in a RECORD. But the current Mocka still uses the old stat-record definition which is 20 bytes shorter than the current definition. So I needed to find another way to stat a file.
After many years of reading about linked lists, I finally had to get familiar with one in Modula-2. I need some for my AVR projects. So I set out to write a short source to see how it works and IF it works at all... Use the navigator to visit the section about Linked lists. It really isn't very complicated, as soon as you know when to use the caret (shift '6').
From a friend who makes Atmel AVR development systems, I got one of his older boards to experiment with. It is the Easy ATmega8515 board. I was pleasantly surprised by the quality of the board and the features of the AVR. So I decided to see if I can build some tools for FotP (Followers of the Penguin). As of now, I have working:
The 0608m compiler was also adapted by Dr Maurer. Again, Dr Maurer changed a lot of things. The compiler
remnants are stored in the ./m2bin directory. But the executables are stored between the source files,
although they are symlinked into m2bin.
I removed the 9905m install instructions. 0608 is much better and it may well be the last update from Karlsruhe. Unless, of course, we start a media initiative and start a mailbomb (using picture postcards and delivered by snailmail) to convince the people there that they are doing a great job.
The 9905m compiler was adapted by Dr Maurer for easy working with his Murus project. It is more than just a few patches. Dr Maurer changed a lot of things. For one: the md and mi files are back to standard extensions 'def' and 'mod'. And Dr Maurer managed to adapt the Mocka libaries for use with X-windows!
Murus is about using the Mocka compiler for all kinds of usefull programs. Murus is developed by Dr Christian Maurer from the University of Berlin (germany). Most of his work is in german but I think it is so usefull that I want to (at least partly) translate it into english.
I am reading the books of professor Wirth now (all at once, of course) and in PIM I read the EBNF Scanner
sources. These contain a lot of nice functions for compiler builders plus a binary tree algorithm.
You may access the EBNF Scanner by selecting EBNF in the navigator frame on the right.
Many times, you need to know what's around in your environment. Like 'which JPG files are there in this
dirtectory?'. In those cases you need the power of the Unix system to help you out a bit.
Unix doesn't let you down here. It's not made by the Gates-Gang, you know. In the section 'System' you will find an example about how to issue the command
ls -l .. | grep ps | > /tmp/buffer.tmpso that your executable then safely can process the file called '/tmp/buffer.tmp'. Don't forget to erase it afterwards. Or make an executable that is started as a cron job each night.
I need some graphics in some programs. So instead of learning that dreadful Qt and the awful C++ language, I
stick to Modula-2 and extend it with the functions of the
This project involves making a FOREIGN MODULE and some alterations to the Mocka systemscripts. But it's all
Check it out by clicking on 'SVGAlib' in the navigator frame on the right.
I want to make a lot of CGI functionaility with the Mocka compiler. I'm still looking around and publishing my
first steps in this world on this website. So you don't need to make the same mistakes as I did and still
Check it out by clicking on 'Mocka & CGI' in the navigator frame on the right.
GetEnv (the program is called 'trye' for lazyness reasons) is a program to get your feet wet with accessing
Unix environment variables from within a running executable.
It is the prelude for a series of programs to be stored in the 'cgi-bin' to get rid of those nasty perl scripts.
IOport is a library that allows direct I/O port access from Mocka executables. It is based on a FOREIGN
MODULE, described in IOport.md, which refers to the assembly source in IOport.asm.
There are only three functions in this library, for the time being: IOperm, InPort and OutPort. But it is enough to make the geekport available under Linux! This webpage learns you how to use assembly language for use in Mocka DEFINITION MODULEs.
Go check it out. And remember: Mocka Rulez!
SOUP is the SOUrce Printer. Soup does two things: it takes its input from STDIN and reads it line by line. Each line is then prefixed by a number of spaces and sent out to STDOUT. After a number of lines, a footer is printed, and a formfeed is sent out. At the start of Soup, the printer is set to 17 CPI and 8 LPI, enabling 80 lines of 120 columns on an A4 page.
Emit is the companion of SOUP. Emit filters pages from a stream of data going to a printer device. Emit offers
a lot of command line options that can be mixed freely.
Some examples of it's use are 'emit odd' (only pass pages whose page number is odd), 'emit even' (you explain this one yourself), 'emit [3..7]' passes through pages 3 thru 7 to the output stream. But you can also combine options like 'emit [2..7] odd' for printing pages 3, 5 and 7.
In EMIT, I work with Modula-2 SET's and the accompanying operators INCL, EXCL and IN. It's not too difficult all of it, but it's a nice set of examples of SET operators.
ASCII module for Mocka. This short webpage shows the implementation of a simple IMPLEMENTATION MODULE. As you will see, the DEFINITION MODULE is more important in this project....
Command line parsing with a simple demonstration package, called 'try'. You can download the package as an
executable plus the accompanying sourcefile.
Don't expect high level code here; it's just an example how to access the commandline options from within a program compiled with Mocka.
In readcfg we will explore how textIO takes place and which functions are needed for a simple file reader.
You can download the package from the Download section.
Page created June 2003,
Page equipped with googleBuster technology