Peter Otten <[EMAIL PROTECTED]> wrote:

> Let's see if I understand the above: In C a call
> 
> f(g(), g())
> 
> may result in machine code equivalent to either
> 
> x = g()
> y = g()
> f(x, y)
> 
> or
> 
> y = g()
> x = g()
> f(x, y)
> 
> Is that it?
> 

Yes, or changing one of the calls to h() and compiling with 
"cl -Fat.asm -Ox -c t.c":

------ t.c --------
extern int f(int a, int b);
extern int g();
extern int h();

int main(int argc, char **argv) {
    return f(g(), h());
}
-------------------

The output file:
------- t.asm -----
; Listing generated by Microsoft (R) Optimizing Compiler Version 13.10.3077 

        TITLE   t.c
        .386P
include listing.inc
if @Version gt 510
.model FLAT
else
_TEXT   SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT   ENDS
_DATA   SEGMENT DWORD USE32 PUBLIC 'DATA'
_DATA   ENDS
CONST   SEGMENT DWORD USE32 PUBLIC 'CONST'
CONST   ENDS
_BSS    SEGMENT DWORD USE32 PUBLIC 'BSS'
_BSS    ENDS
$$SYMBOLS       SEGMENT BYTE USE32 'DEBSYM'
$$SYMBOLS       ENDS
_TLS    SEGMENT DWORD USE32 PUBLIC 'TLS'
_TLS    ENDS
FLAT    GROUP _DATA, CONST, _BSS
        ASSUME  CS: FLAT, DS: FLAT, SS: FLAT
endif

INCLUDELIB LIBC
INCLUDELIB OLDNAMES

PUBLIC  _main
EXTRN   _f:NEAR
EXTRN   _g:NEAR
EXTRN   _h:NEAR
; Function compile flags: /Ogty
_TEXT   SEGMENT
_argc$ = 8                                              ; size = 4
_argv$ = 12                                             ; size = 4
_main   PROC NEAR
; File c:\temp\t.c
; Line 6
        call    _h
        push    eax
        call    _g
        push    eax
        call    _f
        add     esp, 8
; Line 7
        ret     0
_main   ENDP
_TEXT   ENDS
END
-------------------------
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to