From 792c67507f365b77119e7d79ea7f0a15ccb3d110 Mon Sep 17 00:00:00 2001 From: Curtis F Kaylor Date: Mon, 26 Feb 2018 23:21:01 -0500 Subject: [PATCH] Added ENUM directive --- c02.c | 2 ++ include.c | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/c02.c b/c02.c index a62e5d7..fb2ff16 100644 --- a/c02.c +++ b/c02.c @@ -72,6 +72,8 @@ void pdrctv() DEBUG("Processing directive '%s'\n", word); if (wordis("DEFINE")) pdefin(); //Parse Define + else if (wordis("ENUM")) + penumd(); //Parse Enum Directive else if (wordis("INCLUDE")) pincfl(); //Parse Include File else if (wordis("ERROR")) { diff --git a/include.c b/include.c index 1051458..71c0f93 100644 --- a/include.c +++ b/include.c @@ -72,6 +72,23 @@ void pdefin() DEBUG("Defined as '%s'\n", value); } +/* Process enum directive */ +void penumd() +{ + int enmval = 0; + do { + getwrd(); //get defined identifier + DEBUG("Enumerating '%s'\n", word); + strncpy(defnam[defcnt], word, VARLEN); + setlbl(word); //Set label Assembler Line + defval[defcnt++] = enmval; //Set Value + sprintf(value, "%d", enmval); + asmlin(EQUOP, value); //Write Definition + DEBUG("Defined as '%s'\n", value); + enmval++; + } while (look(',')); +} + /* Parse ASCII Subdirective */ void pascii() { @@ -135,7 +152,7 @@ void pincdr() DEBUG("Processing include file directive '%s'\n", word); if (wordis("DEFINE")) pdefin(); - if (wordis("PRAGMA")) + else if (wordis("PRAGMA")) pprgma(); else { fprintf(stderr, "Unrecognized directive '%s'\n", word);