diff --git a/c02.exe b/c02.exe index b39aaab..afd8e5e 100644 Binary files a/c02.exe and b/c02.exe differ diff --git a/c02.tag b/c02.tag index bd7fe93..bf23542 100644 Binary files a/c02.tag and b/c02.tag differ diff --git a/label.c b/label.c index 9a54957..23d6383 100644 --- a/label.c +++ b/label.c @@ -13,20 +13,21 @@ #include "parse.h" #include "label.h" +const char lblflg[] = {LFNONE, LFNONE, LFBGN, LFEND, LFBGN, LFEND, LFEND, LFNONE, LFNONE}; //Label Type Flags + /* Find Last Label of Specified Types * * Args: lbtyp1: First label type * * lbtyp2: Second label type * * Sets: tmplbl - Label name * * Returns: Index into label table * * (-1 if not found) */ -int lstlbl(int lbtyp1, int lbtyp2) +int lstlbl(int lbflag) { int i; - DEBUG("Searching for label type %d ", lbtyp1); - DEBUG("and label type %d\n",lbtyp2); + DEBUG("Searching for label flag %d\n", lbflag); for (i = lblcnt - 1; i>-1; i--) { - if (lbltyp[i] == lbtyp1) break; - if (lbltyp[i] == lbtyp2) break; + //DEBUG("Comparing against flag %d", lblflg[lbltyp[i]]); + if (lblflg[lbltyp[i]] == lbflag) break; } DEBUG("Search produced label index %d\n", i); if (i>=0) diff --git a/label.h b/label.h index d95ef0b..78a9474 100644 --- a/label.h +++ b/label.h @@ -19,6 +19,7 @@ int lblnxt; //Sequence of next label to be generated char lbltmp[LABLEN+1]; //Label Temporary Storage enum ltypes {LTNONE, LTIF, LTLOOP, LTEND, LTDO, LTDWHL, LTSLCT, LTCASE, LTFUNC}; //Label Types +enum lflags {LFNONE, LFBGN, LFEND}; //Label Flag Types void prslbl(); //Parse Label From Code void newlbl(char* lbname); //Generate New Block Label diff --git a/py65/testslct.c02 b/py65/testslct.c02 index 512b47f..0e12fe6 100644 --- a/py65/testslct.c02 +++ b/py65/testslct.c02 @@ -39,7 +39,8 @@ for (c=0; c<10; c++) { } newlin(); -for (c=$18; c<$23; c++) { +for (c=$18; c<$22; c++) { + if (c & 15 > 9) continue; //Skip $1A - $1F prbyte(c); putc(' '); select (c) { @@ -48,8 +49,8 @@ for (c=$18; c<$23; c++) { putln("BREAK ONE-NINE"); if (c==$19) break; putln("OOPS!"); - case $22: putln("BLACKJACK!"); - default: //putln("*"); + case $21: putln("BLACKJACK!"); + default: putln("*"); } } diff --git a/stmnt.c b/stmnt.c index aa74ef3..64b09e7 100644 --- a/stmnt.c +++ b/stmnt.c @@ -139,10 +139,10 @@ void prsasn(char trmntr) } /* parse and compile 'break'/'continue' statement */ -void pbrcnt(int lbtyp1, int lbtyp2) +void pbrcnt(int lbflag) { DEBUG("Parsing BREAK/CONTINUE statement\n", 0); - if (lstlbl(lbtyp1, lbtyp2) < 0) + if (lstlbl(lbflag) < 0) ERROR("Break/continue statement outside of loop\n", 0, EXIT_FAILURE); DEBUG("Found Label '%s'\n", tmplbl); asmlin("JMP", tmplbl); @@ -312,8 +312,8 @@ void pslct() { expect('('); prsxpr(')'); //Parse Expression newlbl(endlbl); //Create New Label - pshlbl(LTSLCT,endlbl); //Push Onto Stack - bgnblk('{'); //Require Beginning of Block + pshlbl(LTSLCT,endlbl); //Push Onto Stack + bgnblk('{'); //Require Beginning of Block strcpy(xstmnt, "CASE"); //Require Next Statement to be CASE } @@ -466,9 +466,9 @@ void pstmnt() if (wordis("ASM")) pasm(); else if (wordis("BREAK")) - pbrcnt(LTEND, LTDWHL); + pbrcnt(LFEND); else if (wordis("CONTINUE")) - pbrcnt(LTLOOP, LTDO); + pbrcnt(LFBGN); else if (wordis("GOTO")) pgoto(); else if (wordis("INLINE"))