Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
why dh's value changed after 'mov ds, ax' in real mode?
Umm, cause your code sets DS to AX.
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
mov ax, cs ; makes AX = CS
mov ds, ax ; makes DS = AX
mov es, ax ; makes ES = AX
Can't get any more simpler than that.
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
when i set ds to a selector, the A(bit0) should be 1, so dh should be 0x00009300, but its value is 0x00009200. i can't understand. the code in protect mode.
david wrote:ds:s=0x07c0, dl=0x7c00ffff, dh=0x00009300, valid=1
...........................................
ds:s=0x0010, dl=0x0000ffff, dh=0x00009200, valid=1
Comparing the above two,not only dh has been changed from 0x00009300 to 0x00009200,but dl has been changed too.
I suggest you post more code ,so we can simulate and help you.
HeLU
david wrote:ds:s=0x07c0, dl=0x7c00ffff, dh=0x00009300, valid=1
...........................................
ds:s=0x0010, dl=0x0000ffff, dh=0x00009200, valid=1
Comparing the above two,not only dh has been changed from 0x00009300 to 0x00009200,but dl has been changed too.
Sure - the base address of the segment changed from 0x7C00 to 0x0000 in dl, and the segment type changed from "read/write accessed" to "read/write" in dh. I'd assume that as soon as you use the DS segment for something it'll change back to "read/write accessed".
Note: The segment limit, DPL, granularity flag, default operand size flag and "available" flag didn't change.
It all looks perfectly normal (for real mode) to me...
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.