Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
quajak committed Mar 9, 2024
1 parent bf28c6d commit a1bdba4
Show file tree
Hide file tree
Showing 2 changed files with 207 additions and 213 deletions.
18 changes: 6 additions & 12 deletions articles/Compiler/il2cpu.html
Original file line number Diff line number Diff line change
Expand Up @@ -190,18 +190,12 @@
<article class="content wrap" id="_content" data-uid="">
<h1 id="il2cpu">IL2CPU</h1>

<p>This is one of the most important pieces of code in Cosmos. It's an AOT
(Ahead-Of-Time) compiler.</p>
<p>When you compile your C# (or any .NET language) program, it is compiled into the IL (intermediate
language). The IL is then interpreted and executed by a Virtual Machine when
you open your exe.</p>
<p>Cosmos is written in C# and Visual Studio compiles it into IL as always. But a
PC does not come with an interpreter for the IL code. And writing a virtual
machine for running an operating system is not always ideal.</p>
<p>This is where IL2CPU comes in. IL2CPU takes the IL code and translates it to processor opcodes. Currently, only x86 opcodes are available at the moment. However, more architectures are planned for the future (ARM, PowerPC, x86-64).</p>
<p>At this point, IL2CPU performs some more magic before finally converting the entire file into a bootable binary file, which can be loaded by a bootloader on any system (Cosmos uses Syslinux).</p>
<p>As you might think, IL2CPU is a fundamental part of the development
of Cosmos. IL2CPU is responsible for the final output, which is why most optimizations added are for IL2CPU.</p>
<p>This is one of the most important pieces of code in Cosmos. It's an AOT (Ahead-Of-Time) compiler.</p>
<p>When you compile your C# (or any .NET language) program, it is compiled into CIL (common intermediate language). The CIL is then interpreted and executed by a virtual machine when you open your exe.</p>
<p>Cosmos is written in C# and Visual Studio compiles it into CIL as always. But a PC does not come with an interpreter for the CIL code. And writing a virtual machine for running an operating system is not always ideal.</p>
<p>This is where IL2CPU comes in. IL2CPU takes the CIL code and translates it to processor opcodes. Currently, only x86 opcodes are available at the moment. However, more architectures are planned for the future (ARM, PowerPC, x86-64).</p>
<p>At this point, IL2CPU performs some more magic before finally converting the entire file into a bootable binary file, which can be loaded by a bootloader on any system (Cosmos uses the <a href="https://github.com/limine-bootloader/limine">Limine bootloader</a>).</p>
<p>As you might think, IL2CPU is a fundamental part of the development of Cosmos. IL2CPU is responsible for the final output, which is why most optimizations added are for IL2CPU.</p>
</article>
</div>

Expand Down
Loading

0 comments on commit a1bdba4

Please sign in to comment.