**************************************************************************** Disassembled Master Boot Record **************************************************************************** 0000 FA cli 0001 33C0 xor ax,ax 0003 8ED0 mov ss,ax 0005 BC007C mov sp,0x7c00 ; set stack top at 0000:7C00 0008 8BF4 mov si,sp ; SI = 7C00 000A 50 push ax 000B 07 pop es 000C 50 push ax 000D 1F pop ds ; DS = ES = 0 000E FB sti ; enable interrupts 000F FC cld 0010 BF0006 mov di,0x600 ; DI = 0600 0013 B90001 mov cx,0x100 ; 256 words (= 512 bytes) 0016 F2A5 repne movsw ; copy ourselves to 0000:0600 0018 EA1D060000 jmp 0x0:0x61d ; and jump to the new location 001D BEBE07 mov si,0x7be ; SI = 07BE 0020 B304 mov bl,0x4 ; 4 entries 0022 803C80 cmp byte [si],0x80 ; check bootable flag 0025 740E jz 0x35 0027 803C00 cmp byte [si],0x0 ; check if valid entry 002A 751C jnz 0x48 ; jump if invalid 002C 83C610 add si,byte +0x10 002F FECB dec bl 0031 75EF jnz 0x22 ; try next entry 0033 CD18 int 0x18 ; no bootable partitions, GOTO BASIC 0035 8B14 mov dx,[si] ; get drive nr, head 0037 8B4C02 mov cx,[si+0x2] ; get cyl, sect 003A 8BEE mov bp,si ; keep ptr to parttable entry 003C 83C610 add si,byte +0x10 ; verify next entries 003F FECB dec bl 0041 741A jz 0x5d 0043 803C00 cmp byte [si],0x0 0046 74F4 jz 0x3c 0048 BE8B06 mov si,0x68b ; "Invalid partition table" 004B AC lodsb ; print message 004C 3C00 cmp al,0x0 004E 740B jz 0x5b 0050 56 push si 0051 BB0700 mov bx,0x7 0054 B40E mov ah,0xe 0056 CD10 int 0x10 0058 5E pop si 0059 EBF0 jmp short 0x4b 005B EBFE jmp short 0x5b ; hang system 005D BF0500 mov di,0x5 ; try 5 times 0060 BB007C mov bx,0x7c00 0063 B80102 mov ax,0x201 0066 57 push di 0067 CD13 int 0x13 ; read bootsector to 0000:7c00 0069 5F pop di 006A 730C jnc 0x78 ; ok, proceed 006C 33C0 xor ax,ax 006E CD13 int 0x13 0070 4F dec di 0071 75ED jnz 0x60 ; try again 0073 BEA306 mov si,0x6a3 ; "Error loading operating system" 0076 EBD3 jmp short 0x4b ; print message 0078 BEC206 mov si,0x6c2 ; "Missing operating system" 007B BFFE7D mov di,0x7dfe 007E 813D55AA cmp word [di],0xaa55 ; check if valid bootsector 0082 75C7 jnz 0x4b ; print message if invalid 0084 8BF5 mov si,bp ; SI = ptr to parttable entry 0086 EA007C0000 jmp 0x0:0x7c00 ; jump to bootsector --------------------------------------- Disassembled MS-DOS 6.2 boot sector Joris, Jan 2001. --------------------------------------- Hard disk and floppy disk boot sectors only differ in the first 62 bytes (the bootsector data structure). The example below is from a 3.5 inch floppy disk. The bootsector image is loaded and executed at 0000:7C00 0A78:0000 EB 3C 90 4D 53 44 4F 53-35 2E 30 00 02 01 01 00 .<.MSDOS5.0..... 0A78:0010 02 E0 00 40 0B F0 09 00-12 00 02 00 00 00 00 00 ...@............ 0A78:0020 00 00 00 00 00 00 29 11-05 3B 11 4E 4F 20 4E 41 ......)..;.NO NA 0A78:0030 4D 45 20 20 20 20 46 41-54 31 32 20 20 20 FA 33 ME FAT12 .3 0000 EB3C jmp short 0x3e; Jump over data section 0002 90 nop 003E FA cli 003F 33C0 xor ax,ax 0041 8ED0 mov ss,ax 0043 BC007C mov sp,0x7c00; Set stack top at 0000:7c00 0046 16 push ss 0047 07 pop es 0048 BB7800 mov bx,0x78; Load int vector 1E 004B 36C537 lds si,[ss:bx]; (floppy parameter table) 004E 1E push ds 004F 56 push si 0050 16 push ss 0051 53 push bx 0052 BF3E7C mov di,0x7c3e 0055 B90B00 mov cx,0xb; Copy 11 byte parameter 0058 FC cld; table to 0000:7c3e 0059 F3A4 rep movsb 005B 06 push es 005C 1F pop ds 005D C645FE0F mov byte [di-0x2],0xf; Modify head settle time 0061 8B0E187C mov cx,[0x7c18]; bsSecPerTrack 0065 884DF9 mov [di-0x7],cl; Modify sectors per track 0068 894702 mov [bx+0x2],ax; Point int vector 1E 006B C7073E7C mov word [bx],0x7c3e; at 0000:7c3e (new table) 006F FB sti 0070 CD13 int 0x13; Reset disk controller 0072 7279 jc 0xed 0074 33C0 xor ax,ax 0076 3906137C cmp [0x7c13],ax; bsSectors == 0 ? 007A 7408 jz 0x84 007C 8B0E137C mov cx,[0x7c13] 0080 890E207C mov [0x7c20],cx; bsHugeSectors = bsSectors 0084 A0107C mov al,[0x7c10]; bsFATs 0087 F726167C mul word [0x7c16]; * bsFATsecs 008B 03061C7C add ax,[0x7c1c]; + bsHiddenSecs 008F 13161E7C adc dx,[0x7c1e] 0093 03060E7C add ax,[0x7c0e]; + bsResSectors 0097 83D200 adc dx,byte +0x0 009A A3507C mov [0x7c50],ax; Store first root dir sector 009D 8916527C mov [0x7c52],dx; at 0000:7c50 00A1 A3497C mov [0x7c49],ax; and at 0000:7c49 00A4 89164B7C mov [0x7c4b],dx 00A8 B82000 mov ax,0x20 00AB F726117C mul word [0x7c11]; 32 * bsRootDirEnts 00AF 8B1E0B7C mov bx,[0x7c0b]; bx = bsBytesPerSec 00B3 03C3 add ax,bx 00B5 48 dec ax 00B6 F7F3 div bx; ax = # root dir sectors 00B8 0106497C add [0x7c49],ax; Add to get 1st data sector 00BC 83164B7C00 adc word [0x7c4b],byte +0x0 ; at 0000:7c49 00C1 BB0005 mov bx,0x500 00C4 8B16527C mov dx,[0x7c52] 00C8 A1507C mov ax,[0x7c50]; Find CHS address of first 00CB E89200 call 0x160; root dir sector 00CE 721D jc 0xed 00D0 B001 mov al,0x1 00D2 E8AC00 call 0x181; read 1 sector to 0000:0500 00D5 7216 jc 0xed 00D7 8BFB mov di,bx 00D9 B90B00 mov cx,0xb 00DC BEE67D mov si,0x7de6; 1st entry should be IO.SYS 00DF F3A6 repe cmpsb 00E1 750A jnz 0xed 00E3 8D7F20 lea di,[bx+0x20]; 2nd should be MSDOS.SYS 00E6 B90B00 mov cx,0xb 00E9 F3A6 repe cmpsb 00EB 7418 jz 0x105; Ok, continue 00ED BE9E7D mov si,0x7d9e; "Non-System disk ..." 00F0 E85F00 call 0x152 00F3 33C0 xor ax,ax 00F5 CD16 int 0x16; Wait for keystroke 00F7 5E pop si 00F8 1F pop ds 00F9 8F04 pop word [si]; Restore int vector 1E 00FB 8F4402 pop word [si+0x2] 00FE CD19 int 0x19; Re-try boot process 0100 58 pop ax 0101 58 pop ax 0102 58 pop ax 0103 EBE8 jmp short 0xed ; Proceed to load the kernel 0105 8B471A mov ax,[bx+0x1a]; First cluster of IO.SYS 0108 48 dec ax; - 2 reserved clusters 0109 48 dec ax 010A 8A1E0D7C mov bl,[0x7c0d]; bsSecPerClust 010E 32FF xor bh,bh 0110 F7E3 mul bx; ax = IO.SYS sector 0112 0306497C add ax,[0x7c49] 0116 13164B7C adc dx,[0x7c4b]; + 1st data sector 011A BB0007 mov bx,0x700 011D B90300 mov cx,0x3; read 1st 3 sectors 0120 50 push ax 0121 52 push dx 0122 51 push cx 0123 E83A00 call 0x160; convert to CHS 0126 72D8 jc 0x100 0128 B001 mov al,0x1 012A E85400 call 0x181; read 1st sector to 0000:0700 012D 59 pop cx 012E 5A pop dx 012F 58 pop ax 0130 72BB jc 0xed 0132 050100 add ax,0x1; next sector number 0135 83D200 adc dx,byte +0x0 0138 031E0B7C add bx,[0x7c0b]; add bsBytesPerSec to ptr 013C E2E2 loop 0x120; read next sector 013E 8A2E157C mov ch,[0x7c15]; CH = 0142 8A16247C mov dl,[0x7c24]; DL = drive number 0146 8B1E497C mov bx,[0x7c49]; BX:AX = 1st data sector 014A A14B7C mov ax,[0x7c4b] 014D EA00007000 jmp 0x70:0x0; jump into IO.SYS ; Display a string on the screen ; IN: ds:si = ASCIIZ string 0152 AC lodsb; Load string byte 0153 0AC0 or al,al; Stop at '\0' 0155 7429 jz 0x180 0157 B40E mov ah,0xe; Put on screen 0159 BB0700 mov bx,0x7 015C CD10 int 0x10 015E EBF2 jmp short 0x152 ; Convert from logical sector to CHS ; IN: dx:ax = sector number ; OUT: [7c4f]=sector, [7c25]=head, [7c4d]=cylinder ; cary flag on overflow (dx > bsSecPerTrack) ; The 16-bit arithmetic effectively limits dx:ax to 22 bits ; (6 bits sector + 16 bits head/cylinder). This causes a 2Gb limit ; (2^22 * 512 byte) for bootable DOS hard disk partitions. 0160 3B16187C cmp dx,[0x7c18]; Check for overflow 0164 7319 jnc 0x17f 0166 F736187C div word [0x7c18]; Convert from logical sector 016A FEC2 inc dl; to Cyl:Head:Sector 016C 88164F7C mov [0x7c4f],dl; sector number 0170 33D2 xor dx,dx 0172 F7361A7C div word [0x7c1a] 0176 8816257C mov [0x7c25],dl; head number 017A A34D7C mov [0x7c4d],ax; cylinder number 017D F8 clc 017E C3 ret 017F F9 stc 0180 C3 ret ; Read sectors from the disk ; IN: al = nr of sectors, [7c4f]=sector, [7c25]=head, [7c4d]=cylinder ; es:bx = data buffer 0181 B402 mov ah,0x2 0183 8B164D7C mov dx,[0x7c4d] 0187 B106 mov cl,0x6 0189 D2E6 shl dh,cl 018B 0A364F7C or dh,[0x7c4f]; Join upper 2 bits of cyl 018F 8BCA mov cx,dx; and 6 bits sector number 0191 86E9 xchg ch,cl 0193 8A16247C mov dl,[0x7c24]; bsDriveNumber 0197 8A36257C mov dh,[0x7c25] 019B CD13 int 0x13; read sectors 019D C3 ret 0190 CA 86 E9 8A 16 24 7C 8A-36 25 7C CD 13 C3 0D 0A .....$|.6%|..... 01A0 4E 6F 6E 2D 53 79 73 74-65 6D 20 64 69 73 6B 20 Non-System disk 01B0 6F 72 20 64 69 73 6B 20-65 72 72 6F 72 0D 0A 52 or disk error..R 01C0 65 70 6C 61 63 65 20 61-6E 64 20 70 72 65 73 73 eplace and press 01D0 20 61 6E 79 20 6B 65 79-20 77 68 65 6E 20 72 65 any key when re 01E0 61 64 79 0D 0A 00 49 4F-20 20 20 20 20 20 53 59 ady...IO SY 01F0 53 4D 53 44 4F 53 20 20-20 53 59 53 00 00 55 AA SMSDOS SYS..U. ------------------------------------------- Disassembled Windows NT 4.0 boot sector Joris, Jan 2001. ------------------------------------------- The bootsector below is from a FAT style hard disk partition during the setup phase of Windows NT 4.0. The bootsector image is loaded and executed at 0000:7C00. 0000 EB 3C 90 4D 53 57 49 4E-34 2E 30 00 02 10 01 00 .<.MSWIN4.0..... 0010 02 00 02 00 00 F8 C1 00-3F 00 FF 00 4E C2 EE 00 ........?...N... 0020 F1 02 0C 00 80 00 29 EE-14 1E 19 57 49 4E 4E 54 ......)....WINNT 0030 20 20 20 20 20 20 46 41-54 31 36 20 20 20 33 C0 FAT16 3. 0000 EB3C jmp short 0x3e; Jump over data section 0002 90 nop 003E 33C0 xor ax,ax 0040 8ED0 mov ss,ax 0042 BC007C mov sp,0x7c00; Set stack top at 0000:7c00 0045 68C007 push word 0x7c0 0048 1F pop ds; Point DS:0000 at bootsector 0049 A01000 mov al,[0x10]; bsFATs 004C F7261600 mul word [0x16]; * bsFATsecs 0050 03060E00 add ax,[0xe]; + bsResSectors 0054 50 push ax; ax = 1st root dir sector 0055 91 xchg ax,cx 0056 B82000 mov ax,0x20 0059 F7261100 mul word [0x11]; 32 * bsRootDirEnts 005D 8B1E0B00 mov bx,[0xb]; bsBytesPerSec 0061 03C3 add ax,bx 0063 48 dec ax 0064 F7F3 div bx; ax = root dir secs (rnd up) 0066 03C8 add cx,ax 0068 890E0802 mov [0x208],cx; dword [0208] = 1st data sect 006C 680010 push word 0x1000 006F 07 pop es 0070 33DB xor bx,bx; ES:BX = 1000:0000 0072 8F061302 pop word [0x213]; dword [0213] = rootdir sect 0076 891E1502 mov [0x215],bx 007A 0E push cs 007B E89000 call 0x10e; read root directory 007E 7257 jc 0xd7 0080 33DB xor bx,bx 0082 8B0E1100 mov cx,[0x11]; bsRootDirEnts 0086 8BFB mov di,bx 0088 51 push cx 0089 B90B00 mov cx,0xb 008C BEDC01 mov si,0x1dc; Look for "NTLDR" file 008F F3A6 repe cmpsb 0091 59 pop cx 0092 7405 jz 0x99 0094 83C320 add bx,byte +0x20; try next root dir entry 0097 E2ED loop 0x86 0099 E337 jcxz 0xd2; Jump if not found 009B 268B571A mov dx,[es:bx+0x1a]; DX = 1st cluster of NTLDR 009F 52 push dx 00A0 B80100 mov ax,0x1 00A3 680020 push word 0x2000 00A6 07 pop es 00A7 33DB xor bx,bx; ES:BX = 2000:0000 00A9 0E push cs 00AA E84800 call 0xf5; Read 1 cluster 00AD 7228 jc 0xd7 00AF 5B pop bx; BX = 1st cluster of NTLDR 00B0 8D360B00 lea si,[0xb] 00B4 8D3E0B02 lea di,[0x20b] 00B8 1E push ds 00B9 8F4502 pop word [di+0x2]; dword [020b] points to 00BC C705F500 mov word [di],0xf5 ; cluster read function 00C0 1E push ds 00C1 8F4506 pop word [di+0x6]; dword [020f] points to 00C4 C745040E01 mov word [di+0x4],0x10e ; sector read function 00C9 8A162400 mov dl,[0x24]; DL = disk nr 00CD EA03000020 jmp 0x2000:0x3; Jump into NTLDR 00D2 BE8601 mov si,0x186; "Couldn't find NTLDR ..." 00D5 EB03 jmp short 0xda 00D7 BEA201 mov si,0x1a2; "I/O Error ..." 00DA E80900 call 0xe6; Display on screen 00DD BEC101 mov si,0x1c1; "Please insert ..." 00E0 E80300 call 0xe6 00E3 FB sti 00E4 EBFE jmp short 0xe4; Hang machine ; Print string on screen ; IN: DS:SI points to ASCIIZ string 00E6 AC lodsb 00E7 0AC0 or al,al 00E9 7409 jz 0xf4 00EB B40E mov ah,0xe 00ED BB0700 mov bx,0x7 00F0 CD10 int 0x10 00F2 EBF2 jmp short 0xe6 00F4 C3 ret ; Read sectors from disk (starting at specified cluster nr) ; IN: al = nr of sectors to read ; es:bx = pointer to data buffer ; dx = cluster number 00F5 50 push ax 00F6 4A dec dx; cluster nr - 2 reserved clst 00F7 4A dec dx 00F8 A00D00 mov al,[0xd]; bsSecPerClust 00FB 32E4 xor ah,ah 00FD F7E2 mul dx; * cluster number 00FF 03060802 add ax,[0x208]; + 1st data sector 0103 83D200 adc dx,byte +0x0 0106 A31302 mov [0x213],ax; dword [0213] = real sector# 0109 89161502 mov [0x215],dx 010D 58 pop ax ; Read sectors from disk (starting at specified sector nr) ; IN: al = nr of sectors to read ; es:bx = pointer to data buffer ; dword [0213] = logical start sector 010E A20702 mov [0x207],al; nr of sectors 0111 A11302 mov ax,[0x213]; DX:AX = start sector 0114 8B161502 mov dx,[0x215] 0118 03061C00 add ax,[0x1c]; + bsHiddenSecs 011C 13161E00 adc dx,[0x1e] 0120 F7361800 div word [0x18]; / bsSecPerTrack ; This division fails when the cylinder/head combination doesn't ; fit in a 16 bit register. This effectively limits the sector number ; to 22 bits (6 bit sector + 16 bit cylinder/head), causing a 2 Gb ; (2^22 * 512 byte) limit for a bootable NT hard disk partition. 0124 FEC2 inc dl 0126 88160602 mov [0x206],dl; sector number 012A 33D2 xor dx,dx 012C F7361A00 div word [0x1a]; / bsHeads 0130 88162500 mov [0x25],dl; head number 0134 A30402 mov [0x204],ax; cylinder number 0137 A11800 mov ax,[0x18] 013A 2A060602 sub al,[0x206] 013E 40 inc ax; ax = max sects in this call 013F 3A060702 cmp al,[0x207]; Get them all ? 0143 7605 jna 0x14a 0145 A00702 mov al,[0x207]; AL = sectors to read 0148 32E4 xor ah,ah 014A 50 push ax 014B B402 mov ah,0x2 014D 8B0E0402 mov cx,[0x204]; CX = cylinder nr 0151 C0E506 shl ch,0x6 0154 0A2E0602 or ch,[0x206] 0158 86E9 xchg ch,cl; CX = cylinder/sector address 015A 8B162400 mov dx,[0x24]; DX = disk/head address 015E CD13 int 0x13; read sectors 0160 0F830500 jnc near 0x169 0164 83C402 add sp,byte +0x2; discard pushed ax 0167 F9 stc; return error code 0168 CB retf 0169 58 pop ax 016A 28060702 sub [0x207],al; more sectors to read ? 016E 7611 jna 0x181 0170 01061302 add [0x213],ax; update start sector address 0174 8316150200 adc word [0x215],byte +0x0 0179 F7260B00 mul word [0xb] 017D 03D8 add bx,ax; update buffer pointer 017F EB90 jmp short 0x111; loop to read rest of sectors 0181 A20702 mov [0x207],al 0184 F8 clc; return success 0185 CB retf 0180 90 A2 07 02 F8 CB 42 4F-4F 54 3A 20 43 6F 75 6C ......BOOT: Coul 0190 64 6E 27 74 20 66 69 6E-64 20 4E 54 4C 44 52 0D dn't find NTLDR. 01A0 0A 00 42 4F 4F 54 3A 20-49 2F 4F 20 65 72 72 6F ..BOOT: I/O erro 01B0 72 20 72 65 61 64 69 6E-67 20 64 69 73 6B 0D 0A r reading disk.. 01C0 00 50 6C 65 61 73 65 20-69 6E 73 65 72 74 20 61 .Please insert a 01D0 6E 6F 74 68 65 72 20 64-69 73 6B 00 4E 54 4C 44 nother disk.NTLD 01E0 52 20 20 20 20 20 20 00-00 00 00 00 00 00 00 00 R ......... 01F0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 55 AA ..............U. **************************************************************************** Disassembled Windows 95 bootsector **************************************************************************** 7C00 EB 3E 90 4D 53 57 49 4E-34 2E 30 00 02 20 01 00 .>.MSWIN4.0.. .. 7C10 02 00 02 00 00 F8 FA 00-3F 00 80 00 3F 00 00 00 ........?...?... 7C20 C1 40 1F 00 80 00 29 98-8C 39 22 20 20 20 20 20 .@....)..9" 7C30 20 20 20 20 20 20 46 41-54 31 36 20 20 20 F1 7D FAT16 .} ; *** Entry point *** 7C00 EB3E JMP 7C40 7C02 90 NOP 7C40 FA CLI 7C41 33C9 XOR CX,CX ; CX = 0 7C43 8ED1 MOV SS,CX 7C45 BCFC7B MOV SP,7BFC ; Setup stack 7C48 16 PUSH SS 7C49 07 POP ES ; ES = 0 7C4A BD7800 MOV BP,0078 : SS:BP => vect 1Eh (DDPT) 7C4D C57600 LDS SI,[BP+00] ; DS:SI => DDPT 7C50 1E PUSH DS 7C51 56 PUSH SI 7C52 16 PUSH SS 7C53 55 PUSH BP 7C54 BF2205 MOV DI,0522 ; ES:DI = 0:522 7C57 897E00 MOV [BP+00],DI 7C5A 894E02 MOV [BP+02],CX ; vect 1Eh = 0:522 7C5D B10B MOV CL,0B 7C5F FC CLD 7C60 F3 REPZ ; Copy old DDPT to new DDPT 7C61 A4 MOVSB 7C62 06 PUSH ES 7C63 1F POP DS ; DS = 0 7C64 BD007C MOV BP,7C00 ; SS:BP => bootsector 7C67 C645FE0F MOV BYTE PTR [DI-02],0F ; HeadSettleTime 7C6B 8B4618 MOV AX,[BP+18] ; Secs / Track 7C6E 8845F9 MOV [DI-07],AL ; Secs / Track 7C71 FB STI 7C72 386624 CMP [BP+24],AH ; DriveNumber 7C75 7C04 JL 7C7B ; Jump if harddisk 7C77 CD13 INT 13 ; AH = 0, Reset diskdrive 7C79 723C JB 7CB7 ; Jump if error ; *** Look up our file in the RootDir *** 7C7B 8A4610 MOV AL,[BP+10] ; AL = Nr of FATs 7C7E 98 CBW 7C7F F76616 MUL WORD PTR [BP+16] ; DX:AX = AX * FATsecs 7C82 03461C ADD AX,[BP+1C] ; DX:AX += HiddenSecs 7C85 13561E ADC DX,[BP+1E] 7C88 03460E ADD AX,[BP+0E] ; DX:AX += ResSectors 7C8B 13D1 ADC DX,CX 7C8D 50 PUSH AX ; DX:AX = first RootDir sect# 7C8E 52 PUSH DX 7C8F 8946FC MOV [BP-04],AX ; Save 7C92 8956FE MOV [BP-02],DX 7C95 B82000 MOV AX,0020 ; Bytes / DirEntry 7C98 8B7611 MOV SI,[BP+11] ; SI = Nr of RootdirEnts 7C9B F7E6 MUL SI ; AX = Bytes in RootDir 7C9D 8B5E0B MOV BX,[BP+0B] ; BX = Bytes / Sect 7CA0 03C3 ADD AX,BX 7CA2 48 DEC AX 7CA3 F7F3 DIV BX ; AX = Secs in RootDir 7CA5 0146FC ADD [BP-04],AX ; Save first Data sect# 7CA8 114EFE ADC [BP-02],CX 7CAB 5A POP DX ; Pop first RootDir sect# 7CAC 58 POP AX 7CAD BB0007 MOV BX,0700 ;** Read next RootDir sector 7CB0 8BFB MOV DI,BX 7CB2 B101 MOV CL,01 7CB4 E89400 CALL 7D4B ; Read 1 sect => 0:700 7CB7 7247 JB 7D00 ; Jump if error 7CB9 382D CMP [DI],CH ;** Check next DirEntry 7CBB 7419 JZ 7CD6 ; Jump if End of Dir 7CBD B10B MOV CL,0B 7CBF 56 PUSH SI 7CC0 8B763E MOV SI,[BP+3E] 7CC3 F3 REPZ ; Compare filename's 7CC4 A6 CMPSB 7CC5 5E POP SI 7CC6 744A JZ 7D12 ; Jump if file found 7CC8 4E DEC SI 7CC9 740B JZ 7CD6 ; Jump if End of Dir 7CCB 03F9 ADD DI,CX 7CCD 83C715 ADD DI,+15 ; DI => next DirEntry 7CD0 3BFB CMP DI,BX ; End of Sector ? 7CD2 72E5 JB 7CB9 ; No, check next DirEntry ! 7CD4 EBD7 JMP 7CAD ; Yes, get next sector ! ;** File not found 7CD6 2BC9 SUB CX,CX 7CD8 B8D87D MOV AX,7DD8 ; Second file 7CDB 87463E XCHG AX,[BP+3E] 7CDE 3CD8 CMP AL,D8 ; Alreay tried ? 7CE0 7599 JNZ 7C7B ; No, lets do it ! ;** Both files not found 7CE2 BE807D MOV SI,7D80 ; => 'Invalid sy...' ; *** Print error message *** 7CE5 AC LODSB 7CE6 98 CBW 7CE7 03F0 ADD SI,AX ; Get ptr to msg 7CE9 AC LODSB 7CEA 84C0 TEST AL,AL 7CEC 7417 JZ 7D05 ; Jump if end of msg 7CEE 3CFF CMP AL,FF 7CF0 7409 JZ 7CFB ; Jump if end of msg 7CF2 B40E MOV AH,0E 7CF4 BB0700 MOV BX,0007 7CF7 CD10 INT 10 ; AH = 0Eh, Write char 7CF9 EBEE JMP 7CE9 ; Do next char ! 7CFB BE837D MOV SI,7D83 ; => 'Replace th...' 7CFE EBE5 JMP 7CE5 ; Print it ! ; *** Disk error *** 7D00 BE817D MOV SI,7D81 ; => 'Disk I/O e...' 7D03 EBE0 JMP 7CE5 ; Print it ! ; *** Wait for key and reboot *** 7D05 33C0 XOR AX,AX 7D07 CD16 INT 16 ; AH = 0, wait for key 7D09 5E POP SI 7D0A 1F POP DS ; DS:SI = vect 1Eh 7D0B 8F04 POP [SI] 7D0D 8F4402 POP [SI+02] ; restore original DDPT 7D10 CD19 INT 19 ; Reboot !! ; *** Found our system file *** 7D12 BE827D MOV SI,7D82 ; => 'Invalid sy...' 7D15 8B7D0F MOV DI,[DI+0F] ; Start cluster 7D18 83FF02 CMP DI,+02 7D1B 72C8 JB 7CE5 ; Jump if invalid 7D1D 8BC7 MOV AX,DI 7D1F 48 DEC AX 7D20 48 DEC AX 7D21 8A4E0D MOV CL,[BP+0D] ; Secs / Clust 7D24 F7E1 MUL CX 7D26 0346FC ADD AX,[BP-04] ; => first Data sect 7D29 1356FE ADC DX,[BP-02] 7D2C BB0007 MOV BX,0700 ; DX:AX = start sect of file 7D2F 53 PUSH BX 7D30 B104 MOV CL,04 7D32 E81600 CALL 7D4B ; Read 4 sectors => 0:700 7D35 5B POP BX 7D36 72C8 JB 7D00 ; Jump if error 7D38 813F4D5A CMP WORD PTR [BX],5A4D ; Check file ! 7D3C 75A7 JNZ 7CE5 ; Jump if invalid 7D3E 81BF0002424A CMP WORD PTR [BX+0200],4A42 7D44 759F JNZ 7CE5 7D46 EA00027000 JMP 0070:0200 ; Jump to entry point ; *** Disk read subroutine *** ; DX:AX = sect nr, CX = count 7D4B 50 PUSH AX ; ES:BX => buffer 7D4C 52 PUSH DX 7D4D 51 PUSH CX 7D4E 91 XCHG CX,AX 7D4F 92 XCHG DX,AX 7D50 33D2 XOR DX,DX ; DX:CX:AX = sect nr 7D52 F77618 DIV WORD PTR [BP+18] ; Secs / Track 7D55 91 XCHG CX,AX 7D56 F77618 DIV WORD PTR [BP+18] 7D59 42 INC DX 7D5A 87CA XCHG CX,DX ; DX:AX = track, CX = sect 7D5C F7761A DIV WORD PTR [BP+1A] ; Heads 7D5F 8AF2 MOV DH,DL ; DH = head 7D61 8A5624 MOV DL,[BP+24] ; DL = drive nr 7D64 8AE8 MOV CH,AL 7D66 D0CC ROR AH,1 7D68 D0CC ROR AH,1 7D6A 0ACC OR CL,AH ; CX = track-sect 7D6C B80102 MOV AX,0201 7D6F CD13 INT 13 ; AX = 0201, Read 1 sector 7D71 59 POP CX 7D72 5A POP DX 7D73 58 POP AX 7D74 7209 JB 7D7F ; Jump if error 7D76 40 INC AX 7D77 7501 JNZ 7D7A 7D79 42 INC DX ; Point to next sector nr 7D7A 035E0B ADD BX,[BP+0B] ; Point to next memory loc 7D7D E2CC LOOP 7D4B ; Read next sector 7D7F C3 RET ; Done 7D80 03 18 01 27 0D 0A 49 6E-76 61 6C 69 64 20 73 79 ...'..Invalid sy 7D90 73 74 65 6D 20 64 69 73-6B FF 0D 0A 44 69 73 6B stem disk...Disk 7DA0 20 49 2F 4F 20 65 72 72-6F 72 FF 0D 0A 52 65 70 I/O error...Rep 7DB0 6C 61 63 65 20 74 68 65-20 64 69 73 6B 2C 20 61 lace the disk, a 7DC0 6E 64 20 74 68 65 6E 20-70 72 65 73 73 20 61 6E nd then press an 7DD0 79 20 6B 65 79 0D 0A 00-49 4F 20 20 20 20 20 20 y key...IO 7DE0 53 59 53 4D 53 44 4F 53-20 20 20 53 59 53 80 01 SYSMSDOS SYS.. 7DF0 00 57 49 4E 42 4F 4F 54-20 53 59 53 00 00 55 AA .WINBOOT SYS..U. ****************************************************************************