Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2001:
[Freeciv-Dev] Re: [PATCH] is_normal_tile function
Home

[Freeciv-Dev] Re: [PATCH] is_normal_tile function

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: rf13@xxxxxxxxxxxxxxxxxxxxxx
Cc: "Ross W. Wetmore" <rwetmore@xxxxxxxxxxxx>, Roy Tate <roy_tate@xxxxxxxxx>, Trent Piepho <xyzzy@xxxxxxxxxxxxx>, freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: [PATCH] is_normal_tile function
From: "Ross W. Wetmore" <rwetmore@xxxxxxxxxxxx>
Date: Fri, 17 Aug 2001 09:40:28 -0400

At 11:41 AM 01/08/17 +0200, Raimar Falke wrote:
>On Thu, Aug 16, 2001 at 08:15:04PM -0400, Ross W. Wetmore wrote:
>> At 09:32 AM 01/08/16 +0200, Raimar Falke wrote:
[...]
>> I know you hate this, but if you look at most machine instruction sets
>> they have indexing operations that are perverted into 3-way adds by gcc
>> and other compilers. So, ...
[...]
>> This also means that when people cleanup map.xsize-1 they are usually 
>> wasting their time :-).
>
>I don't understand this one.

In 386 assembler, the instruction is LEA disp(index,base). But the
equivalent exists on most other platforms because hardware indexed array
operations are a big payoff.

Compilers fold constants into the disp field, and can add an index to a
base as well. This means  x - (map.xsize-1) is LEA 1(-map.xsize,x) with the
condition set for the branch. Or something like this ...

Constant additions or subtractions from a base value as are typical in most
array index computations are very fast single instructions. So you
shouldn't worry about a few being used in any computation as the compiler
will find them.

Cheers,
RossW


>       Raimar
>
>-- 
> email: rf13@xxxxxxxxxxxxxxxxx
>



[Prev in Thread] Current Thread [Next in Thread]