Page 1 of 1

Hey, how to compile CSharp to machine code?

Posted: Sun Feb 14, 2021 12:47 am
by SiliconOS
I want to build a 64bit Graphical CSharp OS, named Silicon OS(such as my name).
I want to know:
How can I compile C Sharp code to machine code?
How can CSharp to operate filesystem(FAT32, NTFS)?

I'm a Chinese.Your advice are most welcome!

Re: Hey, how to compile CSharp to machine code?

Posted: Wed Feb 17, 2021 8:10 pm
by Octocontrabass
SiliconOS wrote:I want to build a 64bit Graphical CSharp OS, named Silicon OS(such as my name).
Welcome! That's an ambitious project. I suggest reading this post for information that will help you.
SiliconOS wrote:How can I compile C Sharp code to machine code?
Take a look at the C# OS projects listed on the wiki. Those should give you some ideas for how to do it.
SiliconOS wrote:How can CSharp to operate filesystem(FAT32, NTFS)?
It works the same way with any language. (But there's no official NTFS documentation, so NTFS will be difficult.)

Re: Hey, how to compile CSharp to machine code?

Posted: Wed Feb 17, 2021 8:18 pm
by SiliconOS
First, I need a tool to compile CS to native machine code.
Next, the OS need a bootloader, so I'm studying C and C++.
The C# library will be more difficult.

Re: Hey, how to compile CSharp to machine code?

Posted: Thu Feb 18, 2021 3:32 am
by bzt
SiliconOS wrote:First, I need a tool to compile CS to native machine code.
Which doesn't exists. There used to be one, but disappeared with tysos. Good luck with webarchive and latest C# versions...
SiliconOS wrote:Next, the OS need a bootloader, so I'm studying C and C++.
Try BOOTBOOT, it will load your x86_64 kernel no matter what language it was compiled from (if you can compile native machine code from C#, that is).
SiliconOS wrote:The C# library will be more difficult.
But a must. Languages need run-time support libraries, that's how they work. Some languages require less, others more. In general you can say that the most "advanced" a language is, the bigger run-time it requires and harder to use it for bare-metal development (like RTTI in C++ for example). C is the preferred choice because you can use it without any run-time whatsoever (so called freestanding mode), and it compiles to native machine code directly (not an interpreted language like C# and Java).

Cheers,
bzt

Re: Hey, how to compile CSharp to machine code?

Posted: Thu Feb 18, 2021 10:51 am
by nexos
Have you looked at FlingOS? They have a C# AOT compiler that turns C# IL to machine language.

Re: Hey, how to compile CSharp to machine code?

Posted: Thu Feb 18, 2021 5:08 pm
by Octocontrabass
bzt wrote:
SiliconOS wrote:First, I need a tool to compile CS to native machine code.
Which doesn't exists. There used to be one, but disappeared with tysos.
Tysos moved to GitHub. The CIL compiler is also on GitHub.

Re: Hey, how to compile CSharp to machine code?

Posted: Fri Feb 19, 2021 6:07 am
by SiliconOS
I'm in China and my OS is Windows
:(

Re: Hey, how to compile CSharp to machine code?

Posted: Fri Feb 19, 2021 6:15 am
by bzt
Octocontrabass wrote:
bzt wrote:
SiliconOS wrote:First, I need a tool to compile CS to native machine code.
Which doesn't exists. There used to be one, but disappeared with tysos.
Tysos moved to GitHub. The CIL compiler is also on GitHub.
Would you care to update our wiki with this info? Thanks a lot!

Cheers,
bzt