access byte- segmentation

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.
Post Reply
clavin123
Posts: 23
Joined: Mon Mar 19, 2012 2:01 am

access byte- segmentation

Post by clavin123 »

when setting access byte of code segement and data segment we use 0x9a and 0x92
well its alright for code segement but setting 0x92 for data segment makes the segment executable bit 1.
so why is 0x92 used for data segment.(in the wiki its written that for data selector executable bit is 0)
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: access byte- segmentation

Post by bluemoon »

clavin123 wrote:but setting 0x92 for data segment makes the segment executable bit 1.
No, according to intel manual 3.4.5.1 Code- and Data-Segment Descriptor Types,
The byte layout is [P][DPL][TYPE]
So, 0x92 means [Present][DPL=0] [Type=Read/Write Data]
It is not executable.
clavin123
Posts: 23
Joined: Mon Mar 19, 2012 2:01 am

Re: access byte- segmentation

Post by clavin123 »

even so, for both code and data segment the S bit is same. now isnt that wrong?
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: access byte- segmentation

Post by bluemoon »

It is 50% chance intel was wrong, and 50% you misunderstood the manual.

You should re-read the table for those 4 bits for descriptor type.
User avatar
iansjack
Member
Member
Posts: 4711
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: access byte- segmentation

Post by iansjack »

It is the highest bit of the Type field that determines whether a segment contains code or data, not the S bit. Hence A and 2 (1xxx for a code segment, 0xxx for a data segment).

You are correct that the S bit is the same in both cases - showing that it represents a data or code segment as opposed to a system selector of some sort. As advised, read the manual to see what the various bits do.
Post Reply