Re: Is je more effective than jg




"leon800219@xxxxxxxxx 写道:
"
Hi all:

I wonder is jne more effective than jbe, if so why?

The statement:
for(i=0;i<=10;++i)
{
}
seems slower than:
for(i=0;i!=10;++i)
{
}
?
When I disassembled the above C code the asm I got:
; 9 : int i;
; 10 : for(i=0;i<=10;++i)

mov DWORD PTR _i$[ebp], 0
jmp SHORT $LN6@wmain
$LN5@wmain:
mov eax, DWORD PTR _i$[ebp]
add eax, 1
mov DWORD PTR _i$[ebp], eax
$LN6@wmain:
cmp DWORD PTR _i$[ebp], 10 ; 0000000aH
jg SHORT $LN4@wmain

; 11 : {
; 12 : ;
; 13 : }

jmp SHORT $LN5@wmain
$LN4@wmain:

; 14 :
; 15 : int j;
; 16 : for(i=0;i!=10;++i)

mov DWORD PTR _i$[ebp], 0
jmp SHORT $LN3@wmain
$LN2@wmain:
mov eax, DWORD PTR _i$[ebp]
add eax, 1
mov DWORD PTR _i$[ebp], eax
$LN3@wmain:
cmp DWORD PTR _i$[ebp], 10 ; 0000000aH
je SHORT $LN1@wmain

; 17 : {
; 18 : ;
; 19 : }

jmp SHORT $LN2@wmain
$LN1@wmain:

So the real difference is:
jg SHORT $LN1@wmain
and
je SHORT $LN1@wmain

Is there any performance difference? I wonder.

.



Relevant Pages

  • Re: Is je more effective than jg
    ... I wonder is jne more effective than jbe, ... seems slower than: ... Have you considered that the first loop is executed 11 times and the ...
    (alt.lang.asm)
  • Re: Is je more effective than jg
    ... I wonder is jne more effective than jbe, ... seems slower than: ... Have you considered that the first loop is executed 11 times and the ...
    (alt.lang.asm)
  • Re: Is je more effective than jg
    ... I wonder is jne more effective than jbe, ... seems slower than: ... Ratch ...
    (alt.lang.asm)
  • Re: Is je more effective than jg
    ... I wonder is jne more effective than jbe, ... seems slower than: ... Have you considered that the first loop is executed 11 times and the ...
    (alt.lang.asm)