The boot sector moves <i>itself</i> to segment 96C0h:<p><pre><code> 0000:7c69 e8 00 00 CALL LAB_0000_7c6c
</code></pre>
pushes the address of the following instruction (7C6C) on the stack.<p><pre><code> 0000:7c6c 5b POP BX=>DAT_9000_6ffe
0000:7c6d 83 eb 6c SUB BX,0x6c
</code></pre>
BX is now 7C00, the beginning of the boot sector. This is a common trick to get the address of your own code when you don't know where it was loaded in memory. No idea why he did this though, since the PC BIOS boot process always uses the same address.<p><pre><code> 0000:7c70 c1 eb 04 SHR BX,0x4
0000:7c73 66 8c c8 MOV AX,CS
0000:7c76 03 c3 ADD AX,BX
0000:7c78 66 8e d8 MOV DS,AX
</code></pre>
DS:0000 now points to the boot sector. Note that this would fail if it were loaded at some address that isn't a multiple of 16, but of course this is never the case.<p><pre><code> 0000:7c7b b9 00 02 MOV CX,0x200
0000:7c7e 33 f6 XOR SI,SI
0000:7c80 33 ff XOR DI,DI
0000:7c82 f3 a4 MOVSB.REP ES:DI,SI
</code></pre>
Copy the 512 byte boot sector to segment 96C0<p><pre><code> 0000:7c84 b8 c0 96 MOV AX,0x96c0
0000:7c87 66 8e d8 MOV DS,AX
0000:7c8a ea a2 00 c0 96 JMPF LAB_9000_6ca2
</code></pre>
Jump to rest of code starting at offset 00A2.<p>The 0000Kernel.BIN.C file isn't loaded yet at this point, and would likely end up at a different address. I haven't looked at the rest of the code, but it seems to be not nearly enough there to parse any filesystem structures. It probably loads the second stage starting from a fixed sector number.<p>This may sound like blasphemy to some, but honestly, I'm not that impressed with the quality of this code. There are also superfluous 66h prefixes on the segment load instructions.<p>[edit:] the actual source code is available here: <a href="https://github.com/cia-foundation/TempleOS/blob/archive/Adam/Opt/Boot/BootHD.HC">https://github.com/cia-foundation/TempleOS/blob/archive/Adam...</a>