smbmbr  Small Multi-Boot Master-Boot-Record
Version 3.0, Dec 17, 1997
Sample code
by John S. Fine  johnfine@erols.com
I do not place any restrictions on your use of this source code
I do not provide any warranty of the correctness of this source code
_____________________________________________________________________________

Included in the zip file with this text there should be:

   smbmbr.asm   Source code
   smbmbr.lnk   JLOC control file for for linking

You will also need the following programs to install and build smbmbr:

NASM      http://www.cryogen.com/Nasm/
JLOC      http://www.erols.com/johnfine/#jloc
PARTCOPY  http://www.erols.com/johnfine/#partcopy

I tested with NASM 0.95 and 0.97 and with JLOC 0.2 and 0.3.  I think NASM 0.96
has bugs in generation of obj files, so you should not use it.

SMBMBR is a replacement for your master boot record to provide a menu of
choices on every boot-up.  In order to configure SMBMBR for your system
you must edit and rebuild it.  My intent is to provide a well commented
example of the key methods used in small multi-boot program, not to
provide a "product quality" package.  A product quality package should
have a smart installation program that does whatever customizing is
required.  A product quality package probably should get information
from the partition table at run time to reduce the amount of install
time customization that is required.

  As a programmer, you may prefer SMBMBR to a full product package,
because, by forcing (and helping, with good comments) you do all
customization in the source code, it is ultimately more flexible than
a product package.

SMBMBR presents a fixed text menu and waits up to 5 seconds for a keystroke.
_____________________________________________________________________________

WARNING:

   Please follow the instructions in PCOPY??.ZIP for backing up your old
master boot record right away, so you don't forget to do it before installing
SMBMBR.
_____________________________________________________________________________

Building and installing SMBMBR

1)  Backup your old MBR

2)  Try to figure out which primary partitions on your hard drive correspond
    to which entries in the partition table.  If you don't know how to do
    this, you can set up SMBMBR to have choices for all four.  Then simply
    test it to see which is which and then reinstall.

3)  Edit smbmbr.asm, change at least the choice table and the message to fit
    your system.

4)  Build it:
    NASM -f obj smbmbr.asm
    JLOC smbmbr.lnk smbmbr.bin smbmbr.map

5)  JLOC version 0.3 generates no warning message when sections overlap within
    the image.  Check the map to be sure everything fits.

6)  Make sure your old MBR is safely backed up on a bootable diskette with all
    the tools you will need to restore it.

7)  Install SMBMBR overwriting your old MBR:
    PARTCOPY smbmbr.bin 0 1be -h0

8)  Reboot and try it.
_____________________________________________________________________________

If no key is pressed, it uses the last stored default keystroke.

The key is looked up in a table which translates it to either a drive
number or a partition number.

I included drive number support primarily for booting A:.  For virus
protection and convenience, I always disable booting from floppy in the
BIOS setup (on machines that support that).  On those occasions when I
want to boot a floppy, I don't like the hassle of changing setup, booting,
and remembering to change it back later for virus protection.  With SMBMBR,
I have a one-shot keystroke to boot A: when I want and never need to
remember to turn it off afterwards.  I have also used it to boot from B:
and D:, but most OS's won't start correctly when booted from B: or D:.

When a partition is selected, SMBMBR will save that selection as the default
and will mark that partition as active (Many OS's reread the partition table
and only work correctly if the partition they booted from is the active one).
It rewrites the MBR / partition table sector, reads the bootstrap from the
selected partition and transfers control to it.

When a drive is selected it does not change the default (to be used in
subsequent 5 second timeouts).  I did this because I generally want
booting from a drive other than C: to occur only when manually requested.

The menu and the choice table are hard coded in the ASM file.  They match
the first system on which I used SMBMBR.
