0000:7C00 FA                cli
0000:7C01 33C0              xor ax,ax
0000:7C03 8ED0              mov ss,ax
0000:7C05 BC007C            mov sp,0x7c00           ; set stack
0000:7C08 8BF4              mov si,sp
0000:7C0A 50                push ax
0000:7C0B 07                pop es
0000:7C0C 50                push ax
0000:7C0D 1F                pop ds
0000:7C0E FB                sti
0000:7C0F FC                cld
0000:7C10 BF0006            mov di,0x600            ; copy self to
0000:7C13 B90001            mov cx,0x100            ; 0000:0600
0000:7C16 F2A5              repne movsw
0000:7C18 EA1D060000        jmp 0x0:0x61d           ; ...and jump there

0000:061D BEBE07            mov si,0x7be            ; check partition table
0000:0620 B304              mov bl,0x4              ; all 4 primary part'ns
0000:0622 803C80            cmp byte [si],0x80
0000:0625 740E              jz 0x635                ; it's active (bootable)
0000:0627 803C00            cmp byte [si],0x0
0000:062A 751C              jnz 0x648               ; uh-oh; not 80h, not 0
0000:062C 83C610            add si,byte +0x10
0000:062F FECB              dec bl
0000:0631 75EF              jnz 0x622
0000:0633 CD18              int 0x18                ; "NO ROM BASIC"

0000:0635 8B14              mov dx,[si]             ; CX:DX=INT 13h CHS
0000:0637 8B4C02            mov cx,[si+0x2]         ; value of sector 0
0000:063A 8BEE              mov bp,si               ; of partition
0000:063C 83C610            add si,byte +0x10
0000:063F FECB              dec bl
0000:0641 741A              jz 0x65d                ; other partitions must
0000:0643 803C00            cmp byte [si],0x0       ; have flag byte == 0
0000:0646 74F4              jz 0x63c

0000:0648 BE8B06            mov si,0x68b            ; "Invalid partition..."
0000:064B AC                lodsb
0000:064C 3C00              cmp al,0x0
0000:064E 740B              jz 0x65b
0000:0650 56                push si
0000:0651 BB0700            mov bx,0x7
0000:0654 B40E              mov ah,0xe
0000:0656 CD10              int 0x10
0000:0658 5E                pop si
0000:0659 EBF0              jmp short 0x64b
0000:065B EBFE              jmp short 0x65b         ; halt

0000:065D BF0500            mov di,0x5              ; try 5 times
0000:0660 BB007C            mov bx,0x7c00           ; read to 0000:7C00
0000:0663 B80102            mov ax,0x201            ; (CX, DX were set above)
0000:0666 57                push di
0000:0667 CD13              int 0x13                ; read 1 disk sector
0000:0669 5F                pop di
0000:066A 730C              jnc 0x678
0000:066C 33C0              xor ax,ax               ; reset disk
0000:066E CD13              int 0x13
0000:0670 4F                dec di                  ; try again
0000:0671 75ED              jnz 0x660
0000:0673 BEA306            mov si,0x6a3            ; "Error loading..."
0000:0676 EBD3              jmp short 0x64b

0000:0678 BEC206            mov si,0x6c2            ; "Missing operating..."
0000:067B BFFE7D            mov di,0x7dfe
0000:067E 813D55AA          cmp word [di],0xaa55    ; check for boot magic
0000:0682 75C7              jnz 0x64b

0000:0684 8BF5              mov si,bp               ; SI->partition table entry
0000:0686 EA007C0000        jmp 0x0:0x7c00          ; jump to loaded code

0000:068B 496E76616C696420  db "Invalid "
0000:0693 706172746974696F  db "partitio"
0000:069B 6E207461626C6500  db "n table", 0

0000:06A3 4572726F72206C6F  db "Error lo"
0000:06AB 6164696E67206F70  db "ading op"
0000:06B3 65726174696E6720  db "erating "
0000:06BB 73797374656D00    db "system", 0

0000:06C2 4D697373696E6720  db "Missing "
0000:06CA 6F7065726174696E  db "operatin"
0000:06D2 672073797374656D  db "g system"
0000:06DA 00                db 0

; from here (6DB) to the partition table seems to be unused

; partition table. I have three FAT16 partitions (system indicator 06)
; and one ext2 (Linux) partition (system indicator 83h)

0000:07BE 8000010106FE7F05  db 80h, 0, 1, 1, 6, 0FEh, 7Fh, 5
0000:07C6 C13E0000C5FA3F00  dd 00003EC1h, 003FFAC5h

0000:07CE 0000410606FEBF0A  db 0, 0, 41h, 6, 6, 0FEh, 0BFh, 0Ah
0000:07D6 86394000C5FA3F00  dd 00403986h, 003FFAC5h

0000:07DE 0000810B06FEFF0F  db 0, 0, 81h, 0Bh, 6, 0FEh, 0FFh, 0Fh
0000:07E6 4B348000C5FA3F00  dd 0080344Bh, 003FFAC5h

0000:07EE 0000C11083FEFFFE  db 0, 0, 0C1h, 10h, 83h, 0FEh, 0FFh, 0FEh
0000:07F6 102FC0002F963A00  dd 00C02F10h, 003A962Fh

0000:07FE 55AA              db 55h, 0AAh    ; magic boot signature

Format of partition record:
Offset	Size	Description	(Table 00651)
 00h	BYTE	boot indicator (80h = active partition)
 01h	BYTE	partition start head
 02h	BYTE	partition start sector (bits 0-5)
 03h	BYTE	partition start track (bits 8,9 in bits 6,7 of sector)
 04h	BYTE	operating system indicator (see #00652)
 05h	BYTE	partition end head
 06h	BYTE	partition end sector (bits 0-5)
 07h	BYTE	partition end track (bits 8,9 in bits 6,7 of sector)
 08h	DWORD	sectors preceding partition
 0Ch	DWORD	length of partition in sectors
SeeAlso: #00650
