All Projects → alexfru → BootProg

alexfru / BootProg

Licence: other
FAT12/16/32 Bootsector for .COMs/.EXEs

Programming Languages

assembly
5116 projects
c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to BootProg

stoomboot
An x86 real mode multiboot-ish ELF bootloader
Stars: ✭ 19 (-74.32%)
Mutual labels:  x86, bootloader, fat32
Limine
x86/x86_64 BIOS Bootloader
Stars: ✭ 288 (+289.19%)
Mutual labels:  x86, bootloader, bios
mbr-boot-manager
💾 Master Boot Record with a boot menu written in Assembly
Stars: ✭ 57 (-22.97%)
Mutual labels:  x86, bootloader, bios
Bootmine
Bootable minesweeper game in a 512-byte boot sector
Stars: ✭ 136 (+83.78%)
Mutual labels:  x86, bootloader, bios
Krabs
An x86 bootloader written in Rust.
Stars: ✭ 413 (+458.11%)
Mutual labels:  bootloader, bios
TravorOS
A simple OS running on Intel x86 architecture | No longer updating
Stars: ✭ 24 (-67.57%)
Mutual labels:  x86, bootloader
Pillman
Pillman boot sector game, a yellow thing eats pills and is chased by monsters.
Stars: ✭ 298 (+302.7%)
Mutual labels:  x86, bootloader
Radical-OS
Radical kernel source tree
Stars: ✭ 45 (-39.19%)
Mutual labels:  x86, bios
Toaruos
A completely-from-scratch hobby operating system: bootloader, kernel, drivers, C library, and userspace including a composited graphical UI, dynamic linker, syntax-highlighting text editor, network stack, etc.
Stars: ✭ 4,687 (+6233.78%)
Mutual labels:  x86, bootloader
Nemesis
💾 x86 operation system writen on fasm
Stars: ✭ 29 (-60.81%)
Mutual labels:  x86, bootloader
Toaru Nih
NOTICE: The ToaruOS-NIH Project has been MERGED UPSTREAM. This repository is now archived.
Stars: ✭ 66 (-10.81%)
Mutual labels:  x86, bootloader
Invaders
Invaders game in 512 bytes (boot sector)
Stars: ✭ 461 (+522.97%)
Mutual labels:  x86, bootloader
Toledo Atomchess
Toledo Atomchess is the world's smallest chess program in x86 assembly code
Stars: ✭ 69 (-6.76%)
Mutual labels:  x86, bootloader
Asm Space Invaders
A small, bootable game written in x86 Assembly inspired by Space Invaders
Stars: ✭ 202 (+172.97%)
Mutual labels:  x86, bootloader
Macaron
A sweet hobby made operating system written in C++ for x86 CPUs with GUI
Stars: ✭ 34 (-54.05%)
Mutual labels:  x86
cpuwhat
Nim utilities for advanced CPU operations: CPU identification, ISA extension detection, bindings to assorted intrinsics
Stars: ✭ 25 (-66.22%)
Mutual labels:  x86
creating-controls-in-assembler
Gitbook: https://mrfearless.gitbooks.io/creating-controls-in-assembler
Stars: ✭ 20 (-72.97%)
Mutual labels:  x86
biefircate
Running x86-16 or x86-32 code from x86-64 UEFI; _very experimental_ • mirror of https://gitlab.com/tkchia/biefircate • developer notes at https://gitlab.com/tkchia/biefircate/-/blob/main/doc/NOTES.asciidoc
Stars: ✭ 47 (-36.49%)
Mutual labels:  bios
opcodesDB
x86-64 | ARM (AArch32/AArch64/THUMB) full instruction set.
Stars: ✭ 49 (-33.78%)
Mutual labels:  x86
Inflame
User-mode Windows DLL injector written in Assembly language (FASM syntax) with WinAPI.
Stars: ✭ 63 (-14.86%)
Mutual labels:  x86
The "BootProg" Boot Sector


What is BootProg?

BootProg is a collection of 512-byte boot sectors (for the x86 PC) capable of
loading and executing a program from a FAT12-formatted floppy or a FAT16/32-
formatted hard disk (bootable USB sticks and CDs can also be made with
BootProg).

BootProg understands programs in the MS-DOS .COM or .EXE format. This makes
it possible to use existing 16-bit compilers such as Borland/Turbo C/C++,
Sybase/Open Watcom C/C++ and Smaller C and a variety of assemblers such as
NASM, FASM, TASM and MASM among the others.

BootProg doesn't require that the program occupy a contiguous span of sectors
or FAT clusters or reside at a specific fixed location on the disk. BootProg
faithfully parses the root directory and the chain of FAT clusters in order to
locate the program contents. The only requirement is that the program be named
"STARTUP.BIN" (without quotes). This makes updating the program easy. You just
need to update the file and you can reboot and execute it immediately.


What can BootProg be used for?

You can make a boot loader for your OS. The program that BootProg loads can be
your 2nd stage boot loader. Or, if your OS is relatively small, STARTUP.BIN
could contain the entire OS.

You can write low-level utilities to work with your PC's hardware and load them
with BootProg without having to jump through the hoops with your Windows, Linux
or even DOS.

You can make cool graphics demos or games that run on bare hardware.


What can't BootProg be used for?

Many things. Most importantly, if you make a DOS program that uses any MS-DOS
service functions (e.g. int 21h) or data structures, it will not work when
loaded by BootProg. It must use either BIOS services (e.g. int 10h, int 16h,
int 13h and such) or access hardware directly or both.

However, it is possible to create universal/hybrid programs that would work
both in DOS and when loaded by BootProg. BootProg will set registers si, di and
bp to the values 16381, 32749 and 65521 respectively before transferring control
to your program. Your program can then check the values in these registers and
use DOS services in DOS or something else instead on bare hardware. You can also
choose to make the program run with reduced functionality if not on DOS or
vice versa.


How does it work?

Nothing special. It just finds STARTUP.BIN, loads it, performs any relocations
necessary for the .EXE type of programs, sets the magic numbers 16381, 32749
and 65521 in registers si, di and bp respectively and passes control to your
program.

If BootProg can't find STARTUP.BIN, it will print "NF" to the screen. If it
fails to load the file due to a read error, it will print "RE". This is how the
FAT12 and FAT16 versions of BootProg work. The FAT32 version has much less space
for these errors and so in both above cases it will simply print "E".


How do I put BootProg on my disk?

If you have a 1.44MB 3"5 floppy, just format it regularly with FAT12 in DOS or
Windows and then write flp144.bin to the very first sector of the floppy with
whatever tools you find/have for that. After that you can copy STARTUP.BIN to
the floppy and off you go.

If you want to create an image of a 1.44MB 3"5 floppy, it might be even easier.
Compile the mkimg144.c program contained here with your favorite C compiler
and use it:

  mkimg144 [option(s)] [file(s)]

  Options:

  -bs <file>  Specifies the boot sector to use, e.g. "-bs flp144.bin"

  -o <file>   Specifies the name of the output file ("floppy.img" is the
              default, if this option isn't specified)

  -us         Uses the current time to set the volume ID of the FAT to a unique
              value (the volume ID is used to distinguish between different
              removable disks and detect disk change more accurately)

E.g: "mkimg144 -bs flp144.bin -o flp144.img -us startup.bin".
Btw, you can rename the supplied file "demo1.com" to "startup.bin" to try it
out.

For all other cases you'll need to become a little more familiar with FAT and
a little more intimate with disk tools and BootProg's source code.

You will need to populate the BPB's of boot16.asm and boot32.asm with the
values appropriate to the type and size of the file system that you already have
on a disk or that you intend to create on the disk.
See the source code, these places are marked with question marks, for example:
  bpbBytesPerSector       DW      ?               ; 0x0B

The best is to format your disk with some standard tools (e.g. FORMAT.COM in
DOS), extract the BPB values from the FAT-formatted disk, put them into BootProg
and then write thusly adjusted BootProg over the original boot sector.

You may find a disk editor handy when manipulating BPB values and/or
reading/writing boot sectors.


Limitations and implementation details

boot12.asm (flp144.asm) and boot16.asm require an i80186/i80188/i80286 or a
better CPU. boot32.asm naturally requires an i80386 or a better CPU.

boot12.asm (flp144.asm) was not tested on hard disks (but it might work as the
boot sector on FAT12 primary partitions (file system ID 1)).

boot16.asm was written for and tested on primary FAT16 partitions (file system
IDs 4 and 6). Its expected use is the boot sector of the partition and not the
MBR. The FAT16 version may allocate up to 128KB of RAM for the entire FAT16,
leaving less room for STARTUP.BIN. But ~400KB left should still be plenty of
space for its code, data and stack.

boot32.asm was written for and tested on primary FAT32 partitions (file system
IDs 0Bh and 0Ch) and for BIOSes supporting function 42h of int 13h (IOW, for
systems supporting HDDs larger than 8GB). Its expected use is the boot sector
of the partition and not the MBR.

BootProg does not check the size of STARTUP.BIN and reads into memory all of its
clusters, which means that up to 32767 extra bytes may be read from the disk
and written to the memory after the last byte of STARTUP.BIN (max cluster size
is 32KB). It also means that you may append data to your program and it will be
loaded. You may create oversized .COM-style STARTUP.BIN larger than ~64KB,
however, note that the stack will naturally overwrite its contents from offset
65535 of the program segment (offset 65279 of the file) downwards.

If your PC has the full 640KB of conventional/DOS memory, you should be able to
load program files of size of up to ~400KB.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].