2 * PROJECT: ReactOS MBR Boot Sector for ISO file system ("isohybrid mode")
3 * LICENSE: GNU GPLv2 or any later version as published by the Free Software Foundation
4 * COPYRIGHT: Copyright 2017 Colin Finck <colin@reactos.org>
11 // The "isohybrid" tool patching our ISO will write the LBA of the El Torito BIOS Boot Sector to this address.
12 pBootSectorLBA = start+432
14 // Our BIOS Boot Sector contains this signature at the specified position and our third-party imported "isohybrid" patching tool checks for it.
15 // This is also why it's the same signature ISOLINUX uses.
16 HybridSignature = HEX(7078C0FB)
17 pBootSectorHybridSignature = HEX(7C00)+64
18 pBootSectorHybridEntryPoint = HEX(7C00)+64+4
21 // The MBR needs to start with 33h, because some dumb BIOSes check for that (cf. syslinux commit d0f275981c9289dc4b8df64e72cd9902bf85aebe).
22 // The following line encodes a "xor ax, ax" (but it's not the only way to encode it, so we can't just write that instruction here).
23 .byte HEX(33), HEX(C0)
25 // Set up our stack and a flat addressing model.
35 // Our boot sector has been loaded to address 0x7C00.
36 // Relocate our 512 bytes boot sector to the given base address (should be 0x7000).
43 // Jump to the relocated code.
47 // Prepare the Disk Access Packet (DAP) for INT 13h, Function 42h: Extended Read Sectors from Drive.
48 // Read 4 sectors to address 7C00h, which is exactly our 2K-sized BIOS Boot Sector.
51 push dword ptr es:[pBootSectorLBA]
57 // Call the BIOS function. Note that we haven't clobbered DL up to this point, so the Drive Number passed by the BIOS is still there.
58 // Read errors are indicated by the Carry Flag.
64 // Verify the Hybrid Signature.
65 cmp dword ptr es:[pBootSectorHybridSignature], HybridSignature
68 // Signature is valid, so jump to the entry point for the hybrid code.
69 ljmp16 0, pBootSectorHybridEntryPoint
73 .ascii "ISOMBR: Read Error!", CR, LF
77 .ascii "ISOMBR: Invalid Boot Sector Hybrid Signature!", CR, LF
80 // Fetch the message to output stored at the return address on the stack.
83 // Call BIOS INT 10h, Function 0Eh to output a single character.
84 // Do this in a loop and stop after we have printed the newline LF character.
93 // Die gracefully, that means in an infinite HLT loop to not put any stress on the CPU.
98 // The "isohybrid" tool will add the remaining information, including the infamous 0xAA55 MBR signature.