Creating a self-booting ZIP archive
The author built boot.zip, a ZIP archive that is also a polyglot[1] file: it is a normal archive that can also boot a PC. The archive contains its own source code and the file boot/ZIPHEAD.COM, which holds code that runs when the archive is booted. To rebuild it, you fix the execute permissions of mk.sh, install Zlib, and run mk.sh from its directory.
The archive can be passed to QEMU with direct kernel boot, which works because of a Multiboot[2] header. It can also be written to a floppy image with dd and started with -fda, or placed on a hard drive, where the code detects which INT 13h drive it was loaded from and queries the disk geometry. The author tested booting from a real floppy on a Pentium MMX, and also on an i486 DX2 and an Am386DX-40.
The first 512 bytes form a boot sector[3] that loads more code from the second sector, enables the A20 line, and switches the processor to 32-bit protected mode. The first bytes of the file are a valid ZIP local file header, and the bytes after it spell the Multiboot magic number 1BADB002. ZIP is read from the back: the footer points to the central directory[4], which lists the files in the archive.
Read the original goliath32.comDiscussion
Sources
-
goliath32.com
Creating a self booting ZIP archive


