Mail Archives: djgpp/1998/04/28/23:42:32
At 03:25 4/27/1998 +0200, Archee/CoNTRACT wrote:
>hi !
>
>It is not strange.
>You have to put $16000 in %ecx, not %cx.
>you have to save %es by pushing it.
That is true. Just note, that with regard to pushing, that there is a caveat
for it. This example is dangerous:
asm("pushl %%es ;"
"movl %0, %%es ;"
/* stuff */
"popl %%es"
: : "g" (selector));
If you use an operand with an "m" or "g" constraint inside a push/pop pair,
and compile with `-fomit-frame-pointer' (very commonly used for
optimization), you will get bad code. The "%1" will be replaced with a
%esp-relative address, and the compiler is unaware that the stack pointer
has changed. So: Either use register constraints on operands you use inside
push/pop, or save registers some other way. (Perhaps store it in a register
you don't need?)
Nate Eldredge
nate AT cartsys DOT com
- Raw text -