1
0
mirror of https://github.com/RevCurtisP/C02.git synced 2024-11-22 01:31:33 +00:00

Fixed break/continue bug in DO/WHILE loop

This commit is contained in:
Curtis F Kaylor 2018-07-18 23:49:39 -04:00
parent 33118c0222
commit 818174a15a
6 changed files with 30 additions and 6 deletions

View File

@ -69,6 +69,19 @@ for (i=0;i<10;i++) {
}
newlin();
/* Test Do with Break and Continue*/
i = 0;
puts("DO BC ");
do {
i++;
if (!i&1) continue;
if (i>15) break;
prbyte(i);
putc(' ');
} while ($FF);
newlin();
newlin();
/* Test Block If */

View File

@ -136,6 +136,7 @@ int pmodfr(void) {
int result = TRUE;
if (wordis("ALIGNED")) { getwrd(); ptype(MTALGN); }
else if (wordis("ZEROPAGE")) { getwrd(); ptype(MTZP); }
else if (wordis("ALIAS")) { getwrd(); ptype(MTALS); }
else result = FALSE;
return result;
}

View File

@ -13,7 +13,8 @@
#include "parse.h"
#include "label.h"
const char lblflg[] = {LFNONE, LFNONE, LFBGN, LFEND, LFBGN, LFEND, LFEND, LFNONE, LFNONE}; //Label Type Flags
const char lblflg[] = {LFNONE, LFNONE, LFNONE, LFBGN, LFEND, LFBGN, LFEND, LFEND, LFNONE, LFNONE}; //Label Type Flags
// enum ltypes {LTNONE, LTIF, LTELSE, LTLOOP, LTEND, LTDO, LTDWHL, LTSLCT, LTCASE, LTFUNC}; //Label Types
/* Find Last Label of Specified Types *
* Args: lbtyp1: First label type *

View File

@ -381,7 +381,7 @@ void pwhile(void) {
expect('(');
newlbl(endlbl); //Create End Label
pshlbl(LTEND, endlbl); //and Push onto Stack
reqlbl(loplbl); //Get or Create/Set Loop Label
reqlbl(loplbl); //Get or Create/Set Loop Label
pshlbl(LTLOOP, loplbl); //Push onto Stack
if (!look(')')) {
newlbl(cndlbl); //Create Conditional Skip Label

View File

@ -209,7 +209,16 @@ void addvar(int m, int t) {
setlbl(vrname);
sprintf(word, "$%hhX", zpaddr++);
asmlin(EQUOP, word);
strcpy(value, "*"); //Set Variable Type to Zero Page
strcpy(value, "*"); //Set Variable to Non Allocated
}
else if (m == MTALS) {
setlbl(vrname);
skpspc();
expect('=');
skpspc();
if (isnpre()) prsnum(0xFFFF); else prsvar(FALSE);
asmlin(EQUOP, word);
strcpy(value, "*"); //Set Variable to Non Allocated
}
else {
if (t == VTSTRUCT) {
@ -226,9 +235,9 @@ void addvar(int m, int t) {
}
else value[0] = 0;
if (!alcvar) strcpy(value, "*");
setvar(m, t); //Add to Variable Table
}
if (m != MTZP && t != VTSTRUCT ) prsdat(); //Parse Variable Data
setvar(m, t); //Add to Variable Table
if (m < MTZP && t != VTSTRUCT ) prsdat(); //Parse Variable Data
varcnt++; //Increment Variable Counter
}

View File

@ -48,7 +48,7 @@ int dsize; //Total Data Length
enum dtypes {DTBYTE, DTSTR, DTARRY}; //Variable Data Types
enum mtypes {MTNONE, MTALGN, MTZP}; //Variable Modifier Types
enum mtypes {MTNONE, MTALGN, MTZP, MTALS}; //Variable Modifier Types
int symdef(char *name); //Is Variable defined (TRUE or FALSE)
int zpaddr; //Current Zero-Page Address