Kernel Compiler Fling OS

An overview of the Kernel Compiler and its architecture are presented below.

General Overview

The Kernel Compiler is an IL to assembly (ASM) language compiler. The Microsoft MSBuild compiler handles much of the complex compilation from C# to IL. IL language itself is very close to assembly language and so the compilation from IL to ASM is relatively simple. Most of the work comes from:

  • Scanning all the IL code and converting it to ASM
  • Finding methods that are ASM plugged and loading/inserting the ASM plugs
  • Sequencing the ASM into one continuous .ASM (text) file
  • Saving debug information into a .PDB (database) file
Processing Flow

This section is given in much more detail in Processing Flow Details.

Fling OS - Kernel Compiler Model 1

This model gives a short overview of how the Kernel Compiler should work. Initially, MSBuild converts C# to IL code. The Kernel Compiler then reads in that IL code (IL Reader) into a full list of classes (List of classes) and a list of classes that contain one or more plugged methods (List of plugged classes). These two lists are handed to the IL Scanner. The IL Scanner then loops through:

  1. The list of plugged classes

    1. For each class, loop through all plugged methods
    2. Load the relevant plug ASM file
    3. Create an ASM chunk and add it to the full list of ASM chunks (List of ASM chunks)
  2. The list of all classes

    1. For each class, loop through all not-plugged methods
    2. Loop through all the IL ops for each method
    3. Convert the IL ops to ASM
    4. Create an ASM chunk and add it to the full list of ASM chunks (List of ASM chunks)

N.B. An ASM chunk is essentially a piece of ASM text but may have / require peripheral information.

After the full list of ASM chunks has been compiled (List of ASM chunks), each chunk is sequenced into the continuous ASM file and written to the file. By sequencing the chunks, we mean placing them in the correct order. Some chunks, such as the initial boot code, needs to go first. Other chunks may not matter where they go in the file.

Finally, once the ASM file has been written, an existing tool, such as NASM, can compile it from ASM into actually binary code and thus into something like a .ISO file which can be run in a virtual machine for testing.

One thing missed by this model is the output of debug information. The debug information must contain things like method signatures, stack info, type info, and relation of ASM line to C# line/method etc. However, none of this is central to the compiler so is not included in this model.

See Also

Other Resources