Re: Stack and calling convention questions

"Tzvetan Mikov" <>
12 Aug 1999 02:59:56 -0400

          From comp.compilers

Related articles
Stack and calling convention questions (Thelonious Georgia) (1999-08-01)
Re: Stack and calling convention questions (1999-08-07)
Re: Stack and calling convention questions (Tzvetan Mikov) (1999-08-12)
| List of all articles for this month |

From: "Tzvetan Mikov" <>
Newsgroups: comp.compilers
Date: 12 Aug 1999 02:59:56 -0400
Organization: Posted via Supernews,
References: 99-08-011 99-08-037
Keywords: code, practice

RKRayhawk wrote in message 99-08-037...
>But more importantly the XOR instruction is testing the EAX register.
>It is a nearly universal convention that EAX is used as the result
>register of simple scalars in C subroutine interfaces. (Not
>always. Sometimes larger entities must land in EAX/EDX.) So the XOR is
>testing the result.
>The XOR instruction will set the PF, SF and ZF. In effect the meaning
>of the contents of EAX is transfered to the status register, where it
>can subsequently be used for branches.

I don't think XOR is used for testing the register. "xor eax,eax" is
primarily used to clear a register, while testing is done with "or eax,eax"
or "test eax,eax".
Hypothetically, If the calling convention allowed using flags for return
values, "xor eax,eax" could be used instead of
        mov eax, 0
        or eax, eax
in order to set the value and the flags, so in this sense it would be

Btw, is there any compiler for x86 that utilizes flags for function
return values? May be Watcom C (it is pretty flexible in this regard)?
Now, for the superscalar x86-s this doesn't make much sense because it
would introduce a too strict dependancy. In the pre-Pentium days
however I can imagine a big space and perfrormance win. All functions
returning _bool_ and many C library functions which must be tested for
< 0...


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.