Re: [fpc-pascal] Branch table

2018-08-27 Thread Marco Borsari via fpc-pascal
On Sun, 26 Aug 2018 18:32:29 +0200 Florian Klämpfl wrote: > Am 26.08.2018 um 11:43 schrieb Giuliano Colla: > > Il 23/08/2018 11:34, Marco Borsari via fpc-pascal ha scritto: > > > >> It would be for the Wirth optimization in the access of an array, > >> when the index is 0 or 1, allowing the elim

Re: [fpc-pascal] Branch table

2018-08-26 Thread Florian Klämpfl
Am 26.08.2018 um 11:43 schrieb Giuliano Colla: > Il 23/08/2018 11:34, Marco Borsari via fpc-pascal ha scritto: > >> 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. > > I'm afraid that this sort of optimiz

Re: [fpc-pascal] Branch table

2018-08-26 Thread Giuliano Colla
Il 23/08/2018 11:34, Marco Borsari via fpc-pascal ha scritto: 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. I'm afraid that this sort of optimization is rather outdat

Re: [fpc-pascal] Branch table

2018-08-23 Thread Marco Borsari via fpc-pascal
On Thu, 23 Aug 2018 09:32:58 +0200 Florian Klämpfl 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 po

Re: [fpc-pascal] Branch table

2018-08-23 Thread Florian Klämpfl
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 >> m

Re: [fpc-pascal] Branch table

2018-08-21 Thread 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 compli

Re: [fpc-pascal] Branch table

2018-08-20 Thread Giuliano Colla
Il 18/08/2018 15:52, Marco Borsari via fpc-pascal ha scritto: it works only for index 0, and crashes otherwise. Maybe a problem of alignment? Or must be tab declared in data section? On the Intel architecture you cannot perform pointer arithmetic as if a pointer were just a number. A pointer

Re: [fpc-pascal] Branch table

2018-08-18 Thread Marco Borsari via fpc-pascal
Il 17/08/2018 18:04, Giuliano Colla ha scritto: I modified your code, to add a jump table (as it is in the example you mention) I came to that program branch; {$ASMMODE intel} label tab,stop,a,b,c; var idx:byte; begin write('Index? '); readln(idx); asm xor eax,eax; mov al,idx; shl ax,2; mov e

Re: [fpc-pascal] Branch table

2018-08-18 Thread Marco Borsari via fpc-pascal
Il 17/08/2018 18:04, Giuliano Colla ha scritto: Enjoy programming! Giuliano Thank you! ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Branch table

2018-08-17 Thread Giuliano Colla
Il 17/08/2018 15:46, Marco Borsari via fpc-pascal ha scritto: I found that someone made that for me at link http://www.mindfruit.co.uk/2012/01/switch-blocks-jump-tables.html and I have tried to rewrite the program in at&t syntax

Re: [fpc-pascal] Branch table

2018-08-17 Thread Marco Borsari via fpc-pascal
Il 16/08/2018 17:40, Giuliano Colla ha scritto: The first thing I notice is that you load BX, which is a 16 bit register (the lower 16 bits of EBX), with the value of "next", and then Jump to the content of EBX which is a 32 bit register, whose lower 16 bits have been loaded but whose upper 16 b

Re: [fpc-pascal] Branch table

2018-08-16 Thread Giuliano Colla
Il 14/08/2018 15:21, Marco Borsari via fpc-pascal ha scritto: Why the code below does exit gracefully without prints anything? Sure, it is for my poor knowledge of the assembler, but in some details, please... program branch; {$ASMMODE intel} label next,stop,a,b,c; var idx:byte; begin write('

[fpc-pascal] Branch table

2018-08-14 Thread Marco Borsari via fpc-pascal
Why the code below does exit gracefully without prints anything? Sure, it is for my poor knowledge of the assembler, but in some details, please... program branch; {$ASMMODE intel} label next,stop,a,b,c; var idx:byte; begin write('Index? '); readln(idx); asm mov ax,idx; shl ax,2; mov bx,next; a