I think you should look at the average.  My routine is dramatically 
faster if
largest number is the first parameter.  Other patterns will also deliver 
different
times.   I would be interested in what results your tests reveal. 

Thanks again to Wilfried for his original ASM code.  It was so easy to 
understand
that I was inspired to take my first stab at an ASM routine.  And, 
thanks to Rob
for giving me the idea to count the comparisons and assignments as a 
metric.  I
don't think there is any way to improve on his Pascal code.   What a great
community this is.

Kind regards,
Jon P. Grewer


> Message: 1
> Date: Wed, 29 Aug 2007 11:58:57 +0200
> From: CubicDesign <[EMAIL PROTECTED]>
> Subject: Re: maximum of 3 numbers
> To: Borland's Delphi Discussion List <[email protected]>
> Message-ID: <[EMAIL PROTECTED]>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> Hi Jon,
>
> You function returns the best time.
>
> Still I wonder if I should make and average of all times or to look only 
> for the smallest time.
> I think I should look for the smallest time.
>
>
>
>
> Jon P. Grewer wrote:
>   
>> Using Wilfried's asm code and Rob's tight Delphi code as inspiration and
>> jumping off point:  This is my first ASM routine ever. 
>>
>> function Max3(a, b, c: integer): integer;
>> // eax : first param & Result
>> // ecx : second param
>> // edx : third param
>> asm
>>    cmp eax, ecx
>>    jl @less       // ecx > eax
>>    cmp eax, edx
>>    jl @less2      // eax > ecx but less than edx. edx is max.  2 
>> compares, 1, assignment, 1 jump
>>    ret            // eax is max.  2 compares, 0 assignments, 0 jumps
>>
>>    @less:          // ecx > eax.. Is ecx greater than edx?
>>    cmp ecx, edx
>>    jl  @less2     // edx is max.  2 compares, 1 assignment,  2 jumps
>>    mov eax, ecx   // ecx is max.  2 compares, 1 assignment, 1 jump
>>    ret          
>>
>>    @less2:
>>    mov eax, edx   // edx is max
>> end;
>>
>> Warmest regards and thanks for the inspiration,
>> -- Jon Grewer
>>
>>   
>>     

_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi

Reply via email to