NASM · 8086 · real DOSBox, in the browser

Conway's Doomsday algorithm, written in 8086 assembly.

The trick for working out the weekday of any date in your head — implemented in 723 lines of NASM, and running on this site inside a real DOS machine. No install, no DOSBox setup, no server.

C:\> doomsday.com

Opens the program with its source on the left and a live DOS machine on the right. Click the screen and type a date.

Two ways in

The algorithm

Every year has a weekday — its doomsday — that a set of easy dates all fall on: 4/4, 6/6, 8/8, 10/10, 12/12, and the last day of February. Work out that one weekday for the year and any date is a short hop from the nearest anchor. It is designed to be done in your head; doing it in 8086 assembly means doing the division yourself.

The same algorithm was implemented in C++ first. That version, and a longer explanation of the arithmetic, live in the Doomsday project. This repository is the third implementation.

What is actually running

Real DOSBox, compiled to WebAssembly, with real NASM installed inside it. Your source is written into the emulated filesystem as prog.asm, assembled with nasm -f bin, and the resulting .COM is executed. Nothing is sent anywhere; there is no backend.

Because it is genuinely DOS and genuinely NASM, anything that works here works in a real DOSBox. This is a faster way to run the same toolchain, not a simulation of it.
If the screen freezes, check the tab is in front. js-dos drives the emulator from requestAnimationFrame, so a backgrounded tab stops the machine dead. It looks exactly like a hang, and it isn't one.

Writing code for it