I am working on some boot sector code, and have come across a minor dilema.

I can switch into 'Real Big Mode' or 'Flat Real Mode' or whatever you know it as (std CS, 4GB DS/ES).

The minor problem I have noticed is that after calling the FDD Reset (INT 0x13, AH=0) the base of the selector in DS & ES has changed.

Normally, it is Selector 0x10, Base=0, Limit=0xFFFFF (This is a 4GB Selector from 0).

After calling INT 0x13, the selector becomes Base=0x100, Limit=0xFFFFF (hence, both DS and ES are changed)

If this is confusing, the code follows:

MOV ECX, CR0
OR ECX, 1
MOV CR0, ECX ; Enable Protected Mode

MOV AX, 10h
MOV DS, AX ; DS = Flat 4GB (Sel #2)
MOV ES, AX ; ES = Flat 4GB (Sel #2)

AND ECX, 0FFFFFFFEh
MOV CR0, ECX ; Leave Protected Mode

;

MOV CX, 0
MOV AH, 0
MOV DL, 0
INT 13h

The confusing part really is that INT0x13 with AH=0 doesnt actually use DS or ES, so why does the base change?!?

Thanks in advance
Posted on 2004-02-24 23:26:45 by Sentient
Oh, it probably does. It has to use DS or ES to get at the BIOS data area, which contains floppy related info. Well, all you have to do is to set DS and ES to 0 after leaving protected mode. Then they will be consistent with the bases.
Posted on 2004-02-25 11:06:06 by Sephiroth3
Thanks... I managed to figure out the answer after a bit of reading.

Thankfully, I have everything working properly now..... and its only 7am :)
Posted on 2004-02-25 11:54:03 by Sentient