; BestBoot System ; (C)1997, Kispitye Software ; compile with TASM .286 CODE SEGMENT PARA PUBLIC 'CODE' ASSUME CS:CODE,DS:CODE,SS:CODE,ES:CODE ; Bootstrap loader (int 19h) loads this to 0:7c00 ; we move it to 0600h to be able to load selected boot sector to 0:7c00 old_start=7c00h org 0600h; new program entry point start: cli xor bx,bx ;bx=0 mov ss,bx ;ss=0 mov sp, old_start ;begin stack below us mov si,sp ;si=7c00 mov es, bx ;es=0 mov ds, bx ;ds=0 sti cld lea di, start mov cx,0100h; length of MBR in words rep movsw ;0:600-0:7ff:=0:7c00-0:7dff mov disk_id, dl ;bootdisk id lea bx, showmenu jmp bx; text_table db 'BestBoot by KISPITYE SOFTWARE (1997)', 13, 10, 13, 10, 13, 10 db '[Ctrl+]Enter or F1=fd, F2=hd, F3=cd' menu_table db 'NTWINMELINUX'; must be right after text_table menu_lengths db 2, 5, 5; lengts of menuitems part_numbers db 1, 2, 3; must be right after menu_lengths, partitions begin with 1, 4 > means extended disks_ids db 0, 80h, 1 disk_id db 80h; must be right after disks_ids showmenu: mov di, 1; default partition<=-------------------------------------------- mov ah, 2 int 16h; get shift status or al, al jnz l_1 jmp load; load default partition l_1: push di mov ax, 600h; mov bh, 01bh; blank screen attribute<------------------------------------ mov dx, 184fh; lower right corner (cx=0; upper right corner) int 10h ;clear color screen mov cx, 0ffffh ;cx=ffff mov ah,1 int 10h ;hide cursor pop di; selected index menudisplay: mov ax, 1301h; mov bx, 0b1h; bh=0; display page, bh=attribute<------------------------------ mov cx, menu_table-text_table; start text length mov dx, 0; start text position<------------------------------------------- lea bp, text_table int 10h lea bp, menu_table mov dx, 0725h; dl=start column, dh=start row<----------------------------- xor si, si listitem: mov ax, 1301h; mov bl, 01bh; bx=0007h; display attribute<------------------------------- cmp si, di jne normal mov bl, 7bh; selected display attribute<---------------------------------- normal: mov cl, menu_lengths[si]; push bp push si push di int 10h; write text pop di pop si pop bp add bp, cx; next text add dh, 3; next row; row increment<----------------------------------- inc si; next iteration cmp si, part_numbers - menu_lengths ; number of listitems jb listitem xor ah,ah int 16h; read key xchg al, ah; reverse scan code or ah, ah jnz enter_ or di, di jz down cmp al, 48h; up arrow scan code jne down last: dec di jmp menudisplay down: cmp al, 50h; down arrow scan code jne f1 inc di cmp di, si je last l_2: jne menudisplay f1: cmp al, 3bh; f1 scan code, change drive jb enter_ cmp al, 3bh + disk_id-disks_ids jg enter_ lea bx, disks_ids - 3bh xlat mov cx, 1 mov dx, ax call _load je boot enter_: cmp ax, 0a1ch; ctrl-enter reverse scan code jne _enter mov word ptr showmenu+1, di mov ax, 0301h lea bx, start mov cx, 1; xor dh, dh mov dl, disk_id; int 13h jc error_f jnc load _enter: cmp ax, 0d1ch; enter reverse scan-code jne l_2; load: push di pop ax; al=selected item lea bx, part_numbers xlat; al=selected partition search: mov cx, 4; cx=4 lea di, part_table; last partition cmp al, cl jg ext_part; extended partition selected dec al shl al, cl xor ah, ah add di, ax call sector_load mov byte ptr [di], 80h ; set bootable flag mov si, di mov bp, si; this must be set for the boot record boot: pusha mov ax,0003h int 10h; clear screen popa mov bx, old_start jmp bx ;start boot ext_part: cmp byte ptr [di+4],5 je this_ext add di,10h loop ext_part error_f: mov bx, 472h mov [bx], 1234h mov bx, 0ffffh push bx push ds retf ; warm reboot : ffff:0000 this_ext: push ax call sector_load pop ax mov cx,20h lea di, part_table mov si, old_start+1beh; copy extended parttable rep movsw sub al, 4 jmp search sector_load:; load boot record for partition at di mov dh,[di+1] mov cx,[di+2] mov dl, disk_id _load: mov bp,3; try 3 times again_load: mov bx,old_start mov ax,0201h int 13h; load boot record jnc ok_load xor ax,ax int 13h; reset drive dec bp jnz again_load jz error_f ok_load: mov bx, old_start+1feh; end of boot record cmp [bx],0aa55h; signature found? jne error_f ret db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 org start+01beh; partition table part_table: CODE ENDS END