, 10 tweets, 3 min read
My Authors
Read all threads
1/n It has always bugged me that I can't run my 64-bit C# games on MS-DOS. Today I fixed that. A thread.
2/n Windows EXE files consist of two parts: a DOS program that prints "This program cannot be run in DOS mode", followed by a header that Windows understands.
3/n In a way, all EXEs are DOS programs - they're just not very useful DOS programs. One day I found this project (that deserves way more GitHub stars than it has): github.com/Baron-von-Ried…
4/n Dos64-stub is a small program that replaces the useless "Cannot run in DOS" with code that loads the Windows-specific portion of the EXE and teleports the process into 21. century. By teleporting I mean setting up paging and switching the CPU into 64-bit ("long") mode
5/n I started with my C# 8 kB self-contained Windows snake game:
6/n Of course DOS doesn't have Windows APIs, so I had to rewrite how the game talks to the world. This is Environment.TickCount on DOS:
7/n Once we have the number of ticks, we can do Thread.Sleep:
8/n Or Console.Write:
9/n From there, it's easy: C# compiler -> CoreRT AOT compiler -> Linker. We tell the linker to use Dos64-stub instead of generating the useless "Cannot be run in DOS" program.
10/n Here's the pull request with all of it: github.com/MichalStrehovs…
Missing some Tweet in this thread? You can try to force a refresh.

Enjoying this thread?

Keep Current with Michal Strehovský

Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

Twitter may remove this content at anytime, convert it as a PDF, save and print for later use!

Try unrolling a thread yourself!

how to unroll video

1) Follow Thread Reader App on Twitter so you can easily mention us!

2) Go to a Twitter thread (series of Tweets by the same owner) and mention us with a keyword "unroll" @threadreaderapp unroll

You can practice here first or read more on our help page!

Follow Us on Twitter!

Did Thread Reader help you today?

Support us! We are indie developers!

This site is made by just three indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3.00/month or $30.00/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!