Re: Keywords and Namesapces

new topic     » goto parent     » topic index » view thread      » older message » newer message
Vinoba said...

IT ALWAYS WORKS TO SET THE Z FLAG

I wasn't saying it does not work, I was saying it is unnecessarily slow.

A quick experiment (this is Phix inline assembly):

atom t0,t1,t2 
 t0 = time() 
constant LIM=1000000000 
for i=1 to LIM do 
    #ilasm{mov_eax_mem32,%isVar,0,0,i, 
           cmp_eax_imm8,1, 
           jz_rel32,%isJmp,0,0,:l1, 
           cmp_eax_imm8,2, 
           jz_rel32,%isJmp,0,0,:l1, 
           cmp_eax_imm8,3, 
           jz_rel32,%isJmp,0,0,:l1, 
           cmp_eax_imm8,4, 
           jz_rel32,%isJmp,0,0,:l1, 
           cmp_eax_imm8,5, 
           jz_rel32,%isJmp,0,0,:l1, 
           cmp_eax_imm8,6, 
           jz_rel32,%isJmp,0,0,:l1, 
           cmp_eax_imm8,7, 
           jz_rel32,%isJmp,0,0,:l1, 
           cmp_eax_imm8,8, 
           jz_rel32,%isJmp,0,0,:l1, 
        ::l1 } 
end for 
t1 = time() 
for i=1 to LIM do 
    #ilasm{mov_eax_mem32,%isVar,0,0,i, 
           dec_eax, 
           jz_rel32,%isJmp,0,0,:l1, 
           dec_eax, 
           jz_rel32,%isJmp,0,0,:l1, 
           dec_eax, 
           jz_rel32,%isJmp,0,0,:l1, 
           dec_eax, 
           jz_rel32,%isJmp,0,0,:l1, 
           dec_eax, 
           jz_rel32,%isJmp,0,0,:l1, 
           dec_eax, 
           jz_rel32,%isJmp,0,0,:l1, 
           dec_eax, 
           jz_rel32,%isJmp,0,0,:l1, 
           dec_eax, 
           jz_rel32,%isJmp,0,0,:l1, 
        ::l1 } 
end for 
t2 = time() 
printf(1,"cmp:%f, dec:%f\n",{t1-t0,t2-t1}) 
if getc(0) then end if 

Result is cmp:6s, dec: 8s, so the cmp does it in 75% of the time dec does. If you're really interested in finding out why, I'll have to refer you to Agner Fog.

Regards, Pete

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu