[fpc-pascal] Branch table

Marco Borsari borsa77 at libero.it
Thu Aug 23 11:34:50 CEST 2018


On Thu, 23 Aug 2018 09:32:58 +0200
Florian Klämpfl <florian at freepascal.org> wrote:

> Am 21.08.2018 um 11:42 schrieb Marco Borsari via fpc-pascal:
> > Il 20/08/2018 17:32, Giuliano Colla ha scritto:
> > 
> >> On the Intel architecture you cannot perform pointer arithmetic as if a
> >> pointer were just a number.
> >> A pointer is composed of two parts: a "selector" and an "offset", which
> >> must be handled separately.
> > 
> > Ah, I saw, 32 bit segmentation is quite complicated.
> > Thank you twice, Marco
> 
> I still miss the point of a hand coded branch table ...

It would be for the Wirth optimization in the access of an array,
when the index is 0 or 1, allowing the elimination of a multiplication.

case idx of
0: (*adr:=adr*);
1: adr:=adr+lel;
end
else adr:=adr+idx*lel;

It's half for paranoia and half for the desire to learn, I am sorry,
Marco



More information about the fpc-pascal mailing list