The Ranish Compact Boot
Manager MBR

 


As seen in Memory during Execution:



7C00 33ED          XOR     BP,BP      ; Zero-out the Base Pointer,
7C02 8EDD          MOV     DS,BP      ;  DS (Data Segment),
7C04 8EC5          MOV     ES,BP      ;  ES (Extra Segment) and
7C06 8ED5          MOV     SS,BP      ;  SS (Stack Segment).
7C08 BC007C        MOV     SP,7C00    ; Set Stack Pointer to 7C00.
7C0B FC            CLD                ; Clear Direction Flag
7C0C 8BF4          MOV     SI,SP      ; Set Source Index to 7C00.
7C0E BF0006        MOV     DI,0600    ; Set Destination Index to 600
7C11 B90001        MOV     CX,0100    ; Set Count Register to 100h
                                      ; (for 256 Words, or 512 bytes)
7C14 F3            REPZ
7C15 A5            MOVSW              ; Move the whole sector from 7C00
                                      ; to 600 (just like an MBR does).
7C16 E9008A        JMP     0619       ; Continue executing code at new
                                      ;  location in memory: 0000:0600.

0619 807DB800      CMP     BYTE PTR [DI-48],00
061D 741F          JZ      063E
061F BB7300        MOV     BX,0073
0622 83EB04        SUB     BX,+04
0625 7217          JB      063E
0627 803FC0        CMP     BYTE PTR [BX],C0
062A 73F6          JNB     0622
062C B37A          MOV     BL,7A
062E E8E700        CALL    0718
0631 B400          MOV     AH,00
0633 CD16          INT     16

0635 3C0D          CMP     AL,0D
0637 75F8          JNZ     0631
0639 B3B2          MOV     BL,B2
063B E8DA00        CALL    0718
063E 80FA80        CMP     DL,80
0641 7302          JNB     0645
0643 B280          MOV     DL,80
0645 8AC2          MOV     AL,DL
0647 2C4F          SUB     AL,4F
0649 88459D        MOV     [DI-63],AL
064C B38D          MOV     BL,8D
064E E8C700        CALL    0718
0651 8A45B9        MOV     AL,[DI-47]
0654 3C00          CMP     AL,00
0656 755C          JNZ     06B4
0658 B031          MOV     AL,31       ; Drive "1"
065A B700          MOV     BH,00
065C BFBE07        MOV     DI,07BE     ; First entry in the Partition Table
065F 383D          CMP     [DI],BH
0661 8815          MOV     [DI],DL
0663 7517          JNZ     067C
0665 883D          MOV     [DI],BH
0667 83C710        ADD     DI,+10
066A 40            INC     AX
066B 3C34          CMP     AL,34       ; Drive "4"
066D 76F0          JBE     065F
066F BFBA07        MOV     DI,07BA     ;
0672 383D          CMP     [DI],BH
0674 B01A          MOV     AL,1A
0676 7504          JNZ     067C
0678 B041          MOV     AL,41       ; Display an "A" on the screen.
067A 33ED          XOR     BP,BP
067C B40E          MOV     AH,0E       ; Function 0Eh of INT 10:
067E CD10          INT     10          ;  "Teletype Output" (Display a
                                       ;  character on the screen.)
0680 BE0300        MOV     SI,0003
0683 52            PUSH    DX
0684 B80102        MOV     AX,0201
0687 BB007C        MOV     BX,7C00
068A 8B4D02        MOV     CX,[DI+02]
068D 8B15          MOV     DX,[DI]
068F CD13          INT     13

0691 5A            POP     DX
0692 7308          JNB     069C
0694 B400          MOV     AH,00
0696 CD13          INT     13

0698 4E            DEC     SI
0699 75E8          JNZ     0683
069B F9            STC
069C B384          MOV     BL,84
069E 720D          JB      06AD
06A0 E88700        CALL    072A
06A3 7358          JNB     06FD
06A5 B300          MOV     BL,00
06A7 3C20          CMP     AL,20
06A9 7509          JNZ     06B4
06AB B38D          MOV     BL,8D
06AD E86800        CALL    0718
06B0 B400          MOV     AH,00
06B2 CD16          INT     16

06B4 BEBA07        MOV     SI,07BA
06B7 B400          MOV     AH,00
06B9 3C41          CMP     AL,41       ; Is it an "A" ?
06BB 7428          JZ      06E5
06BD 3C61          CMP     AL,61       ; Is it  a "a" ?
06BF 7424          JZ      06E5
06C1 8AE2          MOV     AH,DL
06C3 FEC4          INC     AH
06C5 3C09          CMP     AL,09
06C7 741C          JZ      06E5
06C9 2C31          SUB     AL,31
06CB 3C04          CMP     AL,04
06CD 7206          JB      06D5
06CF 0ADB          OR      BL,BL
06D1 742A          JZ      06FD
06D3 EBDB          JMP     06B0

06D5 BEBE07        MOV     SI,07BE   ; First entry in the Partition Table
06D8 B410          MOV     AH,10
06DA F6E4          MUL     AH
06DC 03F0          ADD     SI,AX
06DE 8AE2          MOV     AH,DL
06E0 3824          CMP     [SI],AH
06E2 7501          JNZ     06E5
06E4 4D            DEC     BP
06E5 0ADB          OR      BL,BL
06E7 74C2          JZ      06AB
06E9 BFBE07        MOV     DI,07BE   ; First entry in the Partition Table
06EC B90400        MOV     CX,0004
06EF C60500        MOV     BYTE PTR [DI],00
06F2 83C710        ADD     DI,+10
06F5 E2F8          LOOP    06EF

06F7 8824          MOV     [SI],AH
06F9 45            INC     BP
06FA E95BFF        JMP     0658

06FD 0BED          OR      BP,BP
06FF 7412          JZ      0713
0701 B3A0          MOV     BL,A0
0703 E81200        CALL    0718
0706 B80103        MOV     AX,0301     ; Function 03h of INT 13:
0709 BB0006        MOV     BX,0600     ; ES:BX = 0000:0600 (this sector)
070C B90100        MOV     CX,0001     ; to: Drive Cylinder 0, Sector 1,
070F B600          MOV     DH,00       ;     Head 0.
0711 CD13          INT     13          ; "Write Disk Sector"

0713 8A15          MOV     DL,[DI]
0715 E9E874        JMP     7C00        ; Execute the code for whatever
                                       ; Operating System we loaded!


0718 B40E          MOV     AH,0E        ; Function 0Eh of INT 10:
071A B700          MOV     BH,00
071C 8DB70007      LEA     SI,[BX+0700] ; Pointer to string to display
0720 AC            LODSB                ; Load String byte
0721 0AC0          OR      AL,AL        ; Only a zero-byte will be zero.
0723 7404          JZ      0729         ; Hit a zero-byte; we're done!
0725 CD10          INT     10

0727 EBF7          JMP     0720
0729 C3            RET

072A 52            PUSH    DX
072B B82E09        MOV     AX,092E      ; Function 09h of INT 10:
072E BB0700        MOV     BX,0007
0731 8B8FAF07      MOV     CX,[BX+07AF]
0735 CD10          INT     10

0737 B401          MOV     AH,01        ; Function 01h of INT 16:
0739 CD16          INT     16

073B 740D          JZ      074A
073D 3C1B          CMP     AL,1B
073F 7403          JZ      0744
0741 F9            STC
0742 EB26          JMP     076A

0744 B400          MOV     AH,00        ; Function 00h of INT 16:
0746 CD16          INT     16

0748 EB1F          JMP     0769

074A B8200E        MOV     AX,0E20      ; Display a 'SPACE' (20h)
074D CD10          INT     10           ;   on the screen.

074F 53            PUSH    BX
0750 51            PUSH    CX
0751 B400          MOV     AH,00        ; Function 00h of INT 1A
0753 CD1A          INT     1A           ;  "Get System Time"
                                        ; CX:DX = Number of Clock Ticks
                                        ;         since midnight.
0755 8BDA          MOV     BX,DX
0757 CD1A          INT     1A

0759 3BDA          CMP     BX,DX
075B 74FA          JZ      0757
075D 8BDA          MOV     BX,DX
075F CD1A          INT     1A

0761 3BDA          CMP     BX,DX
0763 74FA          JZ      075F
0765 59            POP     CX
0766 5B            POP     BX
0767 E2CE          LOOP    0737

0769 F8            CLC
076A 50            PUSH    AX
076B 9C            PUSHF
076C B82009        MOV     AX,0920  ; Function 09h of INT 10:
076F CD10          INT     10       ; "Write Character and Attribute at    
                                    ;  Cursor Position"
0771 B3B2          MOV     BL,B2
0773 E8A2FF        CALL    0718
0776 9D            POPF
0777 58            POP     AX
0778 5A            POP     DX
0779 C3            RET


Error Messages and Partition Table

                                     A  B  C  D  E  F
077A                                56 69 72 75 73 21             Virus!
0780  21 21 20 00 20 45 72 72 6F 72 21 0D 0A 42 6F 6F   !! . Error!..Boo
0790  74 69 6E 67 20 66 72 6F 6D 3A 20 48 44 31 2F 00   ting from: HD1/.
07A0  57 72 69 74 69 6E 67 20 63 68 61 6E 67 65 73 2E   Writing changes.
07B0  2E 2E 0D 0A 00 00 30 00 01 00 00 00 01 00 80 01   ......0.........
07C0  01 00 0B 7F BF FD 3F 00 00 00 C1 40 5E 00 00 00   ......?....@^...
07D0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
07E0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
07F0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 AA   ..............U.
       0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F

 


Last Update: 18 AUG 2003.

You can write to me using this: online reply form. (It opens in a new window.)

The Starman's FREE TOOLS Page

MBR and Boot Records Index

The Starman's Realm Index Page

 

 

 

 

Hosted by uCoz