4 ms·
I hope this is just a "for fun"/"to see if it can be done" type of thing, because otherwise it is more than a little disturbing when the source code in a high-l
by userbinator 8y ago
I hope this is just a "for fun"/"to see if it can be done" type of thing, because otherwise it is more than a little disturbing when the source code in a high-level language takes more lines of code than doing the same thing in pure Asm:
https://gist.github.com/yackx/a52010a05a430496ae11 https://gist.github.com/yackx/a52010a05a430496ae11
https://github.com/MichalStrehovsky/zerosharp/blob/master/efi-no-runtime/zerosharp.cs https://github.com/MichalStrehovsky/zerosharp/blob/master/ef...
(The Asm above was for good old BIOS, here's the EFI version: http://x86asm.net/articles/uefi-programming-first-steps/hello.asm http://x86asm.net/articles/uefi-programming-first-steps/hell... )
- keithnz 8y agoit's not disturbing at all, the actual code is tiny, just like asm. For the EFI version you are missing all of efi.inc, just like the C#, you have datastructure definitions. http://x86asm.net/articles/uefi-programming-first-steps/efi.inc http://x86asm.net/articles/uefi-programming-first-steps/efi....
- naasking 8y ago> otherwise it is more than a little disturbing when the source code in a high-level language takes more lines of code than doing the same thing in pure Asm The vast majority of the code is just defining the minimal set of standard C# data types needed to compile any C# program.
- molticrystal 8y agoThere is an analog in the efi asm example in the include file [1] with its structures and defines which have a few types but is mostly concerned with defining the same structures as in the C# program. Something that is very unique and interesting is the usage of the System.Runtime & System.Runtime.InteropService , I'm guessing that some of the contorting needed to get things working in the code lays with those functions. The other half would be the ilc and the linker having the EFI subsystem as an option. [1] http://x86asm.net/articles/uefi-programming-first-steps/efi.inc http://x86asm.net/articles/uefi-programming-first-steps/efi....
- naasking 8y agoRuntime and InteropServices are needed for .NET's P/Invoke FFI. It's used to declare the layout of structs, foreign pointers and marshalling code. You can see this being used starting at line 127, where it appears to define EFI handles, tables and headers.