From 55ce618bf2e64b2b4331a7f7a41223e3e6933492 Mon Sep 17 00:00:00 2001 From: Lauri Kasanen Date: Mon, 15 Apr 2019 19:27:23 +0300 Subject: [PATCH] Document computed gotos --- doc/cc65.sgml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/doc/cc65.sgml b/doc/cc65.sgml index a66854095..11b112f6f 100644 --- a/doc/cc65.sgml +++ b/doc/cc65.sgml @@ -776,6 +776,25 @@ This cc65 version has some extensions to the ISO C standard. size zero, even if it is initialized.

+ Computed gotos, a GCC extension, has limited support. With it you can + use fast jump tables from C. You can take the address of a label with + a double ampersand, putting them in a static const array of type void *. + Then you can jump to one of these labels as follows: + + + static const void * const jumptable[] = { + &&add, + &&sub + }; + goto *jumptable[somevar]; + + add: + ...code... + + + In the jump table, no expressions are supported. The array index + used in the goto must be a simple variable or a constant. +

-- 2.39.2