Please enable JavaScript to view this site.

KOL/MCK - User Guide

The purpose of this package is to further compress application code. In fact, this package is supported at the source code generation level by the Mirror Classes Kit. But, by default, the generation of the P-code for the Collapse machine is disabled, and to use this extension, you need to download the Collapse package, read the instructions, and follow it.

 

Now, in essence. As you know, the machine code of the IBM PC is far from perfect (in terms of compactness). The Delphi compiler is also far from perfect. Even manually rewriting a large part of the KOL library code into assembler is not very helpful in miniaturization. So I decided to develop a minimal virtual machine that could do everything the processor does, but with more compact code. Collapse is the result of these efforts.

 

I will briefly talk about the fundamental structure of the Collapse virtual machine, or P-machine. As it turned out as a result of successive approximations, a minimal machine should not be able to do anything on its own, except how to transfer control to subroutines (either in the same bytecode or to machine procedures), and transfer control within its own code. For implementation, a two-stack architecture of a pseudo-machine was initially chosen, the high efficiency of which for the purpose of minimizing code has been known for a very long time (recall the Forth systems that appeared in the early 70s of the XX century). The computational stack in the Collapse machine is the same as the normal IBM PC machine stack, and a dynamically allocated block of memory is used for the return stack.

 

The result of the work is a really very small bytecode emulator, less than 0.5 Kbytes in size, and the ability to reduce machine code by 2 or more times. But the main drawback is that P-code has to be written by someone before it can be compiled into bytecode. So far, no one has undertaken to make a compiler from the Pascal language to the P-code, therefore, as a compromise solution, the generation of an alternative P-code was added to the MCK library, in parallel with the generation of the main Pascal code. Of course, the generation is only for the form design function, that is, for the code that generates the MCK. But on large forms with a very large number of visual and non-visual elements, the size of the machine code can exceed ten kilobytes.

 

One detail: in order for the Collapse machine to start functioning, the Baselib.pas module must be connected to the application, which contains a "library" of basic procedures that perform most of the operations. Initially, quite a lot of functions from this module are connected to the executable module, so there is no particular point in using the Collapse system for very small applications. With further growth of the application itself, the increase in growth due to the inclusion of functions from the Baselib module comes to naught, so when the program reaches 40KB and above, you can already try to use this package.

 

The Collapse system is tried and tested and fully functional. No significant slowdown in application performance was noted when using it. Unfortunately, it can only be applied to MCK forms containing only a basic set of components (all mirrored components on the form must generate a P-code for themselves, only in this case the P-code for the form can be generated). Maybe someday a universal compiler will be written from the Pascal language to the P-code of the Collapse machine, and then the size of the entire application can be reduced by half more than the usual one.

 

KOL / MCK User Guide - Created by Carl Peeraer - Diamant Soft, based on the work of Vladimir Kladov - Artwerp.be

  

Keyboard Navigation

F7 for caret browsing
Hold ALT and press letter

This Info: ALT+q
Nav Header: ALT+n
Page Header: ALT+h
Topic Header: ALT+t
Topic Body: ALT+b
Exit Menu/Up: ESC