delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/04/28/23:42:32

Mime-Version: 1.0
To: Archee/CoNTRACT <01dsolt AT Vpg17 DOT vpg DOT hu>, Aurelio <erigotti AT tinet DOT ch>
From: Nate Eldredge <nate AT cartsys DOT com>
Subject: Re: A strange memory problem
Cc: djgpp AT delorie DOT com
Date: Tue, 28 Apr 1998 20:37:27 -0700
Message-ID: <19980429033703.AAE3301@ppp104.cartsys.com>

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019