Page 1 of 1

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

Posted: Sat Nov 17, 2007 11:39 pm
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...

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

Posted: Sun Nov 18, 2007 12:00 am
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.

Posted: Sun Nov 18, 2007 10:29 am
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

Posted: Mon Nov 19, 2007 1:12 am
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