+ /* Eat the label name */
+ NextToken ();
+
+ } else if (CurTok.Tok == TOK_STAR && IS_Get (&Standard) >= STD_CC65) {
+ SymEntry *arr, *idx, *cur;
+ SymTable *tab;
+ ExprDesc desc;
+ CodeEntry *E;
+ unsigned char val;
+ unsigned I;
+
+ NextToken ();
+
+ /* arr[foo], we only support simple foo for now */
+ if (CurTok.Tok == TOK_IDENT &&
+ (arr = FindSym (CurTok.Ident))) {
+ NextToken ();
+ ConsumeLBrack ();
+
+ /* Find array size */
+ if (!IsTypeArray(arr->Type) || SizeOf(arr->Type) == 0 ||
+ SizeOf(GetElementType(arr->Type)) != 2)
+ Error ("Expected array");
+ if (GetElementCount(arr->Type) > 127)
+ Error ("Only arrays with <= 127 labels are supported, got %lu",
+ GetElementCount(arr->Type));
+
+ if (CurTok.Tok == TOK_ICONST) {
+ val = CurTok.IVal;
+ NextToken ();
+
+ if (CPUIsets[CPU] & CPU_ISET_65SC02) {
+ AddCodeLine ("ldx #$%02X", val * 2);
+ AddCodeLine ("jmp (%s,x)", arr->AsmName);
+ } else {
+ AddCodeLine ("ldy #$%02X", val * 2);
+ AddCodeLine ("lda %s,y", arr->AsmName);
+ AddCodeLine ("ldx %s+1,y", arr->AsmName);
+ AddCodeLine ("jmp callax");
+ }
+ } else if (CurTok.Tok == TOK_IDENT &&
+ (idx = FindSym (CurTok.Ident))) {
+ hie10 (&desc);
+ LoadExpr (CF_NONE, &desc);
+ AddCodeLine ("asl a");
+
+ if (CPUIsets[CPU] & CPU_ISET_65SC02) {
+ AddCodeLine ("tax");
+ AddCodeLine ("jmp (%s,x)", arr->AsmName);
+ } else {
+ AddCodeLine ("tay");
+ AddCodeLine ("lda %s,y", arr->AsmName);
+ AddCodeLine ("ldx %s+1,y", arr->AsmName);
+ AddCodeLine ("jmp callax");
+ }
+ } else {
+ Error ("Only simple expressions are supported for computed goto");
+ }
+
+ ConsumeRBrack ();
+
+ /* Loop over all target labels, specifying this as a jump point.
+ ** It's not exact - if there's multiple gotos, the last will be used,
+ ** but it's only needed so the optimizer does not remove the labels.
+ */
+ I = CS_GetEntryCount (CS->Code) - 1;
+ E = CS_GetEntry (CS->Code, I);
+
+ tab = GetLabelSymTab ();
+ if (tab) {
+ cur = tab->SymHead;
+ while (cur) {
+ if ((cur->Flags & (SC_LABEL|SC_GOTO_IND)) == (SC_LABEL|SC_GOTO_IND)) {
+ cur->V.L.IndJumpFrom = E;
+ }
+ cur = cur->NextSym;
+ }
+ }
+ }
+ } else {
+
+ Error ("Label name expected");
+ }