What means this segment:
MOV SI,SP
PUSH AX
POP ES
How does ES get 0000:7c00 (and further DS)
In this MBR model?
0000:7C00 FA CLI disable int's
0000:7C01 33C0 XOR AX,AX set stack seg to 0000
0000:7C03 8ED0 MOV SS,AX
0000:7C05 BC007C MOV SP,7C00 set stack ptr to 7c00
0000:7C08 8BF4 MOV SI,SP SI now 7c00
0000:7C0A 50 PUSH AX
0000:7C0B 07 POP ES ES now 0000:7c00
0000:7C0C 50 PUSH AX
0000:7C0D 1F POP DS DS now 0000:7c00
0000:7C0E FB STI allow int's
0000:7C0F FC CLD clear direction
0000:7C10 BF0006 MOV DI,0600 DI now 0600
I released that it’s like some special case (or undocumented procedure) – before and after interruption CLI / STI , is blocked.
/upd
source added: http://www.nondot.org/sabre/os/files/Booting/mbr.txt
Here’s my interpretation of the code:
I made up the last 3 instructions; but I can almost guarantee this is what the actual MBR does. The reason for this is that the MBR normally loads an OS’s boot sector at 0x7C00 and can’t overwrite itself, and therefore has to relocate itself first.
I don’t know why they didn’t use
MOV ES,AXandMOV DS,AXinstead of push/pop. Both versions cost 2 bytes though (e.g. 2 bytes forMOV ES,AXvs. one byte forPUSH AXplus another byte forPOP ES) so the difference is irrelevant (code size is the most important thing when you’ve only got 512 bytes to use and 66 of them must be partition table and magic signature at the end).