* x86 D flag: what's its status thru the program?
@ 2004-07-04 15:37 Denis Zaitsev
2004-07-05 13:23 ` Lukasz Michal Rak
0 siblings, 1 reply; 7+ messages in thread
From: Denis Zaitsev @ 2004-07-04 15:37 UTC (permalink / raw)
To: gcc; +Cc: linux-gcc
Is this Direction flag (for the movs instructions) has some assumed
value (say, as after cld)? I ask because the many program sources
show interesting behaviour: from one side, this flag is always set
before the string insns (cld or std), but from the other side, if the
programs does std then it always does cld after. So, nobody leaves it
set, but nevertheless, everybody set it clear. Why?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: x86 D flag: what's its status thru the program?
2004-07-04 15:37 x86 D flag: what's its status thru the program? Denis Zaitsev
@ 2004-07-05 13:23 ` Lukasz Michal Rak
2004-07-05 16:26 ` Denis Zaitsev
0 siblings, 1 reply; 7+ messages in thread
From: Lukasz Michal Rak @ 2004-07-05 13:23 UTC (permalink / raw)
To: Denis Zaitsev; +Cc: gcc, linux-gcc
Hi all!
The convention is that the D flag in IA32 is cleared. So if you call a
subroutine you have to clear D flag before making call. The subroutine can
change the state of D flag, but before returning the routine has to clear
the D flag.
Hope I helped.
Regards,
Lukasz
> Is this Direction flag (for the movs instructions) has some assumed
> value (say, as after cld)? I ask because the many program sources
> show interesting behaviour: from one side, this flag is always set
> before the string insns (cld or std), but from the other side, if the
> programs does std then it always does cld after. So, nobody leaves it
> set, but nevertheless, everybody set it clear. Why?
> -
> To unsubscribe from this list: send the line "unsubscribe linux-gcc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: x86 D flag: what's its status thru the program?
2004-07-05 13:23 ` Lukasz Michal Rak
@ 2004-07-05 16:26 ` Denis Zaitsev
2004-07-05 17:19 ` Lukasz Michal Rak
0 siblings, 1 reply; 7+ messages in thread
From: Denis Zaitsev @ 2004-07-05 16:26 UTC (permalink / raw)
To: Lukasz Michal Rak; +Cc: gcc, linux-gcc
On Mon, Jul 05, 2004 at 03:23:44PM +0200, Lukasz Michal Rak wrote:
>
> Hi all!
>
> The convention is that the D flag in IA32 is cleared. So if you call a
> subroutine you have to clear D flag before making call.
Do you mean that 'I have to clear the D flag if I had set it somewhere
before?' Else what is the sense of the convention?
> The subroutine can change the state of D flag, but before returning
> the routine has to clear the D flag.
If the subroutine can change the flag, that it will violate the
convention, won't it? And what is the strength of the convention,
again?
> Hope I helped.
Thanks, but I still don't understand something. Again: if every
procedure keeps the flag clear at exit, then why the same every
procedure clears it at entry? In a suspicion, that caller has changed
the flag against the rules?
> Regards,
>
> Lukasz
>
>
> > Is this Direction flag (for the movs instructions) has some assumed
> > value (say, as after cld)? I ask because the many program sources
> > show interesting behaviour: from one side, this flag is always set
> > before the string insns (cld or std), but from the other side, if the
> > programs does std then it always does cld after. So, nobody leaves it
> > set, but nevertheless, everybody set it clear. Why?
> > -
> > To unsubscribe from this list: send the line "unsubscribe linux-gcc" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
> >
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: x86 D flag: what's its status thru the program?
2004-07-05 16:26 ` Denis Zaitsev
@ 2004-07-05 17:19 ` Lukasz Michal Rak
2004-07-05 19:04 ` Denis Zaitsev
0 siblings, 1 reply; 7+ messages in thread
From: Lukasz Michal Rak @ 2004-07-05 17:19 UTC (permalink / raw)
To: Denis Zaitsev; +Cc: Lukasz Michal Rak, gcc, linux-gcc
> > The convention is that the D flag in IA32 is cleared. So if you call a
> > subroutine you have to clear D flag before making call.
>
> Do you mean that 'I have to clear the D flag if I had set it somewhere
> before?' Else what is the sense of the convention?
Yes. Other code may assume that D is cleared and for example after calling
your code will not check state of D flag, so if you will left D flag set
this may cause errors.
> > The subroutine can change the state of D flag, but before returning
> > the routine has to clear the D flag.
>
> If the subroutine can change the flag, that it will violate the
> convention, won't it? And what is the strength of the convention,
> again?
>
Subroutine can change the D flag, but before exiting must clear it.
The convention should make you free from checking the state of flag
and clearing at the beginning of your code.
> > Hope I helped.
>
> Thanks, but I still don't understand something. Again: if every
> procedure keeps the flag clear at exit, then why the same every
> procedure clears it at entry? In a suspicion, that caller has changed
> the flag against the rules?
Just to be sure that the D flag is cleared. The convetion is one thing and
reality other.
Lukasz
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: x86 D flag: what's its status thru the program?
2004-07-05 17:19 ` Lukasz Michal Rak
@ 2004-07-05 19:04 ` Denis Zaitsev
2004-07-06 14:05 ` Lukasz Michal Rak
2004-07-07 0:32 ` Jim Wilson
0 siblings, 2 replies; 7+ messages in thread
From: Denis Zaitsev @ 2004-07-05 19:04 UTC (permalink / raw)
To: Lukasz Michal Rak; +Cc: gcc, linux-gcc
On Mon, Jul 05, 2004 at 07:19:06PM +0200, Lukasz Michal Rak wrote:
> > > The convention is that the D flag in IA32 is cleared. So if you call a
> > > subroutine you have to clear D flag before making call.
> >
> > Do you mean that 'I have to clear the D flag if I had set it somewhere
> > before?' Else what is the sense of the convention?
> Yes. Other code may assume that D is cleared and for example after calling
> your code will not check state of D flag, so if you will left D flag set
> this may cause errors.
>
> > > The subroutine can change the state of D flag, but before returning
> > > the routine has to clear the D flag.
> >
> > If the subroutine can change the flag, that it will violate the
> > convention, won't it? And what is the strength of the convention,
> > again?
> >
> Subroutine can change the D flag, but before exiting must clear it.
>
> The convention should make you free from checking the state of flag
> and clearing at the beginning of your code.
>
> > > Hope I helped.
> >
> > Thanks, but I still don't understand something. Again: if every
> > procedure keeps the flag clear at exit, then why the same every
> > procedure clears it at entry? In a suspicion, that caller has changed
> > the flag against the rules?
> Just to be sure that the D flag is cleared. The convetion is one thing and
> reality other.
Ok. Thanks! It's the thing that I didn't understand. BTW, where is
this convention documented, if either?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: x86 D flag: what's its status thru the program?
2004-07-05 19:04 ` Denis Zaitsev
@ 2004-07-06 14:05 ` Lukasz Michal Rak
2004-07-07 0:32 ` Jim Wilson
1 sibling, 0 replies; 7+ messages in thread
From: Lukasz Michal Rak @ 2004-07-06 14:05 UTC (permalink / raw)
To: Denis Zaitsev; +Cc: gcc, linux-gcc
On Tue, 6 Jul 2004, Denis Zaitsev wrote:
> On Mon, Jul 05, 2004 at 07:19:06PM +0200, Lukasz Michal Rak wrote:
> > > > The convention is that the D flag in IA32 is cleared. So if you call a
> > > > subroutine you have to clear D flag before making call.
> > >
> > > Do you mean that 'I have to clear the D flag if I had set it somewhere
> > > before?' Else what is the sense of the convention?
> > Yes. Other code may assume that D is cleared and for example after calling
> > your code will not check state of D flag, so if you will left D flag set
> > this may cause errors.
> >
> > > > The subroutine can change the state of D flag, but before returning
> > > > the routine has to clear the D flag.
> > >
> > > If the subroutine can change the flag, that it will violate the
> > > convention, won't it? And what is the strength of the convention,
> > > again?
> > >
> > Subroutine can change the D flag, but before exiting must clear it.
> >
> > The convention should make you free from checking the state of flag
> > and clearing at the beginning of your code.
> >
> > > > Hope I helped.
> > >
> > > Thanks, but I still don't understand something. Again: if every
> > > procedure keeps the flag clear at exit, then why the same every
> > > procedure clears it at entry? In a suspicion, that caller has changed
> > > the flag against the rules?
> > Just to be sure that the D flag is cleared. The convetion is one thing and
> > reality other.
>
> Ok. Thanks! It's the thing that I didn't understand. BTW, where is
> this convention documented, if either?
>
I don't know where it is documented. Maybe in some documents about C
calling convention. I let you know if I will find something.
Lukasz
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: x86 D flag: what's its status thru the program?
2004-07-05 19:04 ` Denis Zaitsev
2004-07-06 14:05 ` Lukasz Michal Rak
@ 2004-07-07 0:32 ` Jim Wilson
1 sibling, 0 replies; 7+ messages in thread
From: Jim Wilson @ 2004-07-07 0:32 UTC (permalink / raw)
To: Denis Zaitsev; +Cc: gcc, linux-gcc
Denis Zaitsev wrote:
>
> Ok. Thanks! It's the thing that I didn't understand. BTW, where is
> this convention documented, if either?
The Linux Standard Base is a good source of info like this. See
http://www.linuxbase.org/spec/refspecs/LSB_1.3.0/IA32/spec/rstandards.html#AEN34
Look at the one titled "System V Application Binary Interface -
Intel386™ Architecture Processor Supplement, Fourth Edition".
http://www.caldera.com/developers/devspecs/abi386-4.pdf
Then search for EFLAGS in that document.
--
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2004-07-07 0:32 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-07-04 15:37 x86 D flag: what's its status thru the program? Denis Zaitsev
2004-07-05 13:23 ` Lukasz Michal Rak
2004-07-05 16:26 ` Denis Zaitsev
2004-07-05 17:19 ` Lukasz Michal Rak
2004-07-05 19:04 ` Denis Zaitsev
2004-07-06 14:05 ` Lukasz Michal Rak
2004-07-07 0:32 ` Jim Wilson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).