TITLE "BootThru.Asm" v1.1
;
; written on fri 02-11-1994 by ed beroset
; released to the public domain by the author
;
; copies the mbr from the hard drive indicated by targetdrive, modifies it
; for boot from floppy, and copies to boot record of floppy. this is sample
; code only, and not meant as a fully developed utility. as written, this
; should boot the first hard drive from a:
;
; *** use this code at your own risk! ***
TARGETDRIVE equ 0 ; hard drive (0, 1, ...)
cseg segment
assume cs:cseg
org 100h ; .com format
Start:
mov dx,80h + TARGETDRIVE ; read mbr of target drive
mov cx,1h ; it's always the first sector
mov bx, OFFSET buffer ; point to our buffer
mov ax, 0201h ; read one sector
int 13h
mov cx,4h ; read up to four entries
mov si, OFFSET buffer + 1BEh; scan our partition table
find_bootable:
test byte ptr[si],80h ; load it up
jz skip_it ; if it's not bootable, skip it
add byte ptr[si],TARGETDRIVE; add target drive
skip_it:
add si,10h ; v1.1 bugfix
loop find_bootable
xor dx,dx ; zero dx (drive a: head 0)
mov cx,1h ; first sector (v1.1 clarity fix)
mov ax,0301h ; bx still points to buffer
int 13h ; write to floppy in a:
mov ax, 4C00h ; exit to dos.
int 21h
buffer db 0 ;dynamic buffer, 512 bytes.
cseg ends
end Start