See https://ebruneton.github.io/toypc/ and the assembly instructions.
This toy computer includes a small self-hosting operating system (less than 3300 lines) with:
- a boot loader,
- a monolithic, monotasking kernel with 3 drivers, a file system, and 10 system calls,
- a tiny C-like compiler,
- a text editor, a shell, and a few commands (ls, cp, etc)
It is written from scratch (i.e. from machine code) in order to introduce how compilers and operating systems work, via a practical example.