diff --git a/c02.exe b/c02.exe
index fddfa31..cc9eb5b 100644
Binary files a/c02.exe and b/c02.exe differ
diff --git a/c02.ppx b/c02.ppx
index 4fa8c84..917d7b1 100644
--- a/c02.ppx
+++ b/c02.ppx
@@ -3,16 +3,6 @@
-
- 78
- 78
- 786
- 388
- 0
- 0
-
-
-
0
0
@@ -22,7 +12,7 @@
0
-
+
26
26
@@ -32,58 +22,7 @@
0
-
-
- 52
- 52
- 760
- 362
- 0
- 0
-
-
-
-
- 52
- 52
- 1004
- 362
- 0
- 0
-
-
-
-
- 78
- 78
- 1030
- 388
- 0
- 0
-
-
-
-
- 104
- 104
- 1056
- 414
- 0
- 0
-
-
-
-
- 130
- 130
- 1082
- 440
- 0
- 0
-
-
-
-
+
-8
-31
@@ -93,8 +32,47 @@
1
-
-
+
+
+ 78
+ 78
+ 1030
+ 388
+ 0
+ 0
+
+
+
+
+ 104
+ 104
+ 1056
+ 414
+ 0
+ 0
+
+
+
+
+ 130
+ 130
+ 1082
+ 440
+ 0
+ 0
+
+
+
+
+ 0
+ 0
+ 952
+ 310
+ 0
+ 0
+
+
+
26
26
@@ -104,11 +82,33 @@
0
+
+
+
+ 52
+ 52
+ 1004
+ 362
+ 0
+ 0
+
+
+
+
+
+ 78
+ 78
+ 1030
+ 388
+ 0
+ 0
+
+
104
104
- 812
+ 1056
414
0
0
@@ -118,10 +118,20 @@
130
130
- 838
+ 1082
440
0
0
+
+
+ 0
+ 0
+ 952
+ 310
+ 0
+ 0
+
+
diff --git a/c02.tag b/c02.tag
index 2980189..be475c3 100644
Binary files a/c02.tag and b/c02.tag differ
diff --git a/label.c b/label.c
index b53dd05..9a54957 100644
--- a/label.c
+++ b/label.c
@@ -71,6 +71,13 @@ void newlbl(char* lbname)
DEBUG("Generated new label '%s'\n", lbname);
}
+/* if label is blank, generate a new one */
+void chklbl(char* lbname)
+{
+ if (lbname[0]) return;
+ newlbl(lbname);
+}
+
/* require label *
* if label is already set, returns that label *
* else generates new label and sets it */
@@ -81,8 +88,7 @@ void reqlbl(char* lbname)
else {
newlbl(lbname);
setlbl(lbname);
- }
-
+ }
}
/* Pop Label from Stack and Emit on Next Line */
diff --git a/stmnt.c b/stmnt.c
index eaf19ca..2c44952 100644
--- a/stmnt.c
+++ b/stmnt.c
@@ -329,16 +329,30 @@ void ecase() {
/* parse and compile select statement */
void pcase() {
- if (strcmp(xstmnt, "CASE") == 0)
+ int fcase = (strcmp(xstmnt, "CASE") == 0);
+ if (fcase)
xstmnt[0] = 0; //Clear xstmnt
else
ecase("CASE"); //Process end of case block
- prstrm(); //Parse CASE argument
- asmlin("CMP", term); //Emit Comparison
- expect(':');
+ skplbl[0] = 0; //Clear Skip Label
newlbl(cndlbl); //Create Conditional Label
pshlbl(LTCASE, cndlbl); //and Push onto Stack
- asmlin("BNE", cndlbl); //Emit skip of CASE body
+ while(TRUE) {
+ prstrm(); //Parse CASE argument
+ if (!fcase || valtyp != CONSTANT || cnstnt)
+ asmlin("CMP", term); //Emit Comparison
+ if (look(',')) {
+ chklbl(skplbl); //Emit skip to beginning of CASE block
+ asmlin("BEQ", skplbl);
+ fcase = 0;
+ continue; //Parse next argument
+ }
+ expect(':'); //Emit branch to end of CASE block
+ asmlin("BNE", cndlbl);
+ break;
+ }
+ if (skplbl[0])
+ setlbl(skplbl); //Set CASE block label if defined
}
/* parse and compile default statement */