Category : Utilities for DOS and Windows Machines
Archive   : BTEASY12.ZIP
Filename : BOOT.ASM

Output of file : BOOT.ASM contained in archive : BTEASY12.ZIP
; BOOTEASY, version 1.2.
; Developed from BOOTANY, with many imrovements.
; The main idea was to simplify the installation
; procedure and to remove unnecessary partition type
; switching.
; Second hard disk switching added.
; Author: Serge Vakulenko,

F1_scancode equ 59 ; scancode of 'F1' key
Enter_scancode equ 28 ; scancode of 'Enter' key
Timeout equ 5 ; wait up to 5 seconds for reply

StdBase equ 7c00h ; address where DOS loads us
Base equ 600h ; address where we rewrite itself
Partab equ 1beh ; partition table offset
NumDisks equ 475h ; number of disk drives (BIOS data area)

BootIndicator equ 0 ; partition record: boot indicator
BeginHead equ 1 ; first partition sector: head number
BeginSector equ 2 ; sector and cylinder
SystemId equ 4 ; system type

; -------------------------------

dummy segment at 0
assume cs:dummy
org Base ; address where we rewrite itself
org StdBase ; address where DOS loads us
dummy ends

; -------------------------------

code segment
assume cs:code, ds:code, es:code, ss:code
org 0
; Setup the stack and segment registers
xor AX,AX ; Zero register
mov ES,AX ; ES := 0
mov DS,AX ; DS := 0
cli ; Disable interrupts
mov SS,AX ; SS := 0
mov SP,StdBase ; SP at 7c00
sti ; Enable interrupts
; DOS loads this pgm at 0000:7C00. Any boot routine
; we call also expects to execute there so the first
; exercise is to move this code somewhere else.
cld ; Clear direction
mov SI,SP ; Copy from 7c00h...
mov DI,Base ; 600h...
mov CX,256 ; ...512 bytes, or 256 words
repne movsw ; Move itself to new location

jmp FAR PTR BaseEntry+(Entry-Boot)

; -------------------------------
; A valid function key was depressed (or defaulted)
; Attempt to boot the corresponding partition.
mov DX,BP ; restore drive number
; Save boot block default partition settings
mov AX,0301h ; write sector
mov BX,Base ; ES already == 0
mov CX,0001h ; cylinder 0, sector 1
xor DH,DH ; drive #, head 0
int 13h ; replace boot record

mov Base+default,'?' ; reset default
mov AL,16
mul Base+Key ; AX = key * 16
cmp AX,'5'*16
je SwitchDrive
add AX,Base+Partab-'1'*16 ; subtract '1'
mov SI,AX
; Only boot bootable partitions.
mov AL,SystemId[SI]
cmp AL,0 ; unused partition?
je Menu ; Yes - display menu again

mov BYTE PTR BootIndicator[SI],80h ; Mark partition as bootable
; Read in and validate the partition's boot sector.
mov DH,BeginHead[SI] ; head from partition table
mov CX,BeginSector[SI]
jmp loadboot
; Read in the boot sector from second disk.
xor DL,1 ; switch drive
mov CX,0001h ; cylinder 0, sector 1
mov BX,StdBase ; ES already == 0
mov AX,0201h ; function, # of sectors
int 13h ; read system boot record
jc Menu ; exit if error
cmp WORD PTR 510[BX],0aa55h ; test signature
jne Menu ; reprompt if invalid
; Jump to secondary boot.
; DL now contains boot disk number (80h or 81h);
; ES:SI contains the address of partition table
; entry to boot.
jmp FAR PTR StdBaseEntry

; -------------------------------
; The main entry to the boot
mov BP,DX ; DL contains current drive number
inc DX ; 80h -> 81h, 81h -> 82h
xor DL,80h+'3' ; 80h -> '2', 81h -> '1'
mov Base+diskNum,DL
; Display the menu
mov DI,Base+Partab ; set index
mov CX,4 ; set loop count
mov Base+key,'1' ; set key number in message
xor DH,DH ; count of partitions
mov BYTE PTR BootIndicator[DI],CH ; Clear active flag
mov AL,SystemId[DI]
cmp AL,0 ; unused partition?
je next
cmp AL,5 ; extended DOS partition?
je next
inc DH ; increment partition count

lea SI,Base+FkeyMsg ; get msg addr
call Output

lea SI,Base+nameTable-2
inc SI
inc SI
mov BX,[SI]
or BH,BH
je endnameloop
cmp BH,SystemId[DI]
jne nameloop
xor BH,BH
lea SI,Base+namtab[BX]
call Output
add DI,16 ; next entry address
inc Base+key
loop menuloop

cmp BYTE PTR DS:NumDisks,2 ; is the second disk present?
je have2disks ; have disk 2

lea SI,Base+defaultMsg ; prepare 'Default' message
or DH,DH ; no disk 2; do we have valid partitions?
jne prompt ; several partitions, wait for reply

int 18h ; no partitions, load ROM basic
jmp Menu ; repeat, if no ROM basic
lea SI,Base+FkeyMsg ; print 'F5'
call Output ; now SI points to "disk 2\nDefault..."
call Output ; print 'Default' message
mov AH,1 ; SetTickCount
xor CX,CX ; hi-order tick count
xor DX,DX ; lo-order tick count
int 1ah ; BiosTimerService
; Get the reply
mov AH,1 ; keyboard status
int 16h ; keybd bios service
jnz reply ; jump if reply
xor AH,AH ; GetTickCount
int 1ah ; BiosTimerService
cmp DX,192*Timeout/10 ; check for timeout
jb waitkey ; wait for scancode
mov AL,Base+default ; prior system id
jmp testkey ; boot default system
xor AH,AH ; read keyboard
int 16h ; keybd bios service
mov AL,AH ; Copy to AL
cmp AL,Enter_scancode
je loaddefault
add AL,'1'-F1_scancode ; Turn into index
mov Base+key,AL ; save function key number
cmp AL,'1' ; max Function key
jb reprompt ; Invalid code check
cmp AL,'5' ; max Function key
jnbe reprompt ; if not F1..F5, branch
mov Base+default,AL ; save function key number

lea SI,Base+newLine ; new line
lea BX,Base+Load
push BX ; call Output; jmp Load

; -------------------------------

cld ; reset direction flag
lodsb ; load argument from string
push AX ; save byte
and AL,7fh ; insure valid character
mov AH,14 ; write tty
int 10h ; bios video service
pop AX ; restore byte
test AL,80h ; test for end of string
jz Output ; do until end of string
ret ; return to caller

; -------------------------------

newLine db 13,10+80h
FkeyMsg db 13,10,'F'
key db '0 . . .',' '+80h,'disk '
diskNum db '1'
defaultMsg db 13,10,10,'Default: F'
default db '?',' '+80h

nameTable db type01-namtab, 1
db type01-namtab, 4
db type01-namtab, 6
db type07-namtab, 7
db type08-namtab, 8
db type09-namtab, 9
db type0A-namtab, 0Ah
db type63-namtab, 63h
db type64-namtab, 64h
db type64-namtab, 65h
db type81-namtab, 80h
db type81-namtab, 81h
db type82-namtab, 82h
db type93-namtab, 93h
db typeA5-namtab, 0A5h
db typeB7-namtab, 0B7h
db type75-namtab, 75h
db typedb-namtab, 52h
db typedb-namtab, 0dbh
db type40-namtab, 40h
db typeF2-namtab, 0F2h
db unknownPart-namtab, 0

type01 db 'do','s'+80h
type07 db 'hpf','s'+80h
type08 db 'fs '
type09 db 'ai','x'+80h
type0A db 'os','2'+80h
type63 db 'uni','x'+80h
type64 db 'novel','l'+80h
type81 db 'mini','x'+80h
type82 db 'linu','x'+80h
type93 db 'amoeb','a'+80h
typeA5 db '386bs','d'+80h
typeB7 db 'bsd','i'+80h
type75 db 'pci','x'+80h
typedb db 'cp','m'+80h
type40 db 'veni','x'+80h
typeF2 db 'dosse','c'+80h
unknownPart db '?','?'+80h

used equ $ - Boot
db (1beh - used + 1) dup (0) ; error if code too big
db 63 dup (0) ; clear rest of record
dw 0aa55h ; magic

code ends

  3 Responses to “Category : Utilities for DOS and Windows Machines
Archive   : BTEASY12.ZIP
Filename : BOOT.ASM

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: