mov [CS:bp],ax --cause error?

Programming, for all ages and all languages.
Post Reply
earlz
Member
Member
Posts: 1546
Joined: Thu Jul 07, 2005 11:00 pm
Contact:

mov [CS:bp],ax --cause error?

Post by earlz »

should mov [CS:bp],ax cause an error? In realmode this is...

it seems like it logically would cause an error, but also it seems to be valid if it just copies the segment value...
SpooK
Member
Member
Posts: 260
Joined: Sun Jun 18, 2006 7:21 pm

Re: mov [CS:bp],ax --cause error?

Post by SpooK »

hckr83 wrote:should mov [CS:bp],ax cause an error? In realmode this is...

it seems like it logically would cause an error, but also it seems to be valid if it just copies the segment value...
I would hope it to be invalid, since accessing CS does not include write privileges.
User avatar
JAAman
Member
Member
Posts: 879
Joined: Wed Oct 27, 2004 11:00 pm
Location: WA

Post by JAAman »

it shouldnt ever cause an error in RMode, though in PMode it might (GPF--segment permissions violation)

it is a perfectly valid encoding, so it should assemble and execute without any trouble
I would hope it to be invalid, since accessing CS does not include write privileges.
there are no restrictions on the use of any segment register (including CS) only on the permissions of the selector in the GDT -- which are completely open under RMode
it seems like it logically would cause an error, but also it seems to be valid if it just copies the segment value...
not exactly sure what you mean by this, no segment value is copied...

this simply uses a segment override (CS -- that is prefix 0010 1110) and BP as an index into the segment (overridden to CS rather than the default SS), and moves the value in AX to that location
SpooK
Member
Member
Posts: 260
Joined: Sun Jun 18, 2006 7:21 pm

Post by SpooK »

JAAman wrote: there are no restrictions on the use of any segment register (including CS) only on the permissions of the selector in the GDT -- which are completely open under RMode
Thanks for catching that oversight, I didn't even register his mentioning of 16-bit real mode :shock:

More sleep, less typing :P
Post Reply