Il 17/08/2018 15:46, Marco Borsari via fpc-pascal ha scritto: I found that someone made that for me at link I modified your code, to add a jump table (as it is in the example you mention) and here it works just fine. The code which works is: program branch2; {$ASMMODE att} label stop,a,b,c; var idx:byte; Jtab: array [0..2] of pointer; begin // Fill up the Jump table with the addresses of jump targets Jtab[0] := @a; Jtab[1] := @b; Jtab[2] := @c; write('Index? '); readln(idx); asm mov $0x0,%eax // clear upper bits of eax movb idx,%al // so that it contains just idx jmpq *Jtab(,%eax,8) // 8 is for x86_64; replace with 4 for i386 end['EAX']; a: writeln('0'); goto stop; b: writeln('1'); goto stop; c: writeln('2'); stop: writeln('stop'); end.Enjoy programming! Giuliano -- Do not do to others as you would have them do to you.They might have different tastes. |
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal