xa51, work in progress
[fw/sdcc] / as / xa51 / xa_asm.y
index 4567d7e33ca9c36fd0f48d6b43191bc9714dcfb2..4b87ea3f109abf8f7bb1419e8cc2a2a37f540fa1 100644 (file)
@@ -40,7 +40,6 @@ extern void yyrestart(FILE *new_file);
 extern char * disasm(int byte, int memory_location);
 extern void hexout(int byte, int memory_location, int end);
 void error(char *s);
-void fatal_error(char *s);
 
 static int bitmask[]={1, 2, 4, 8, 16, 32, 64, 128};
 
@@ -54,7 +53,7 @@ static int bitmask[]={1, 2, 4, 8, 16, 32, 64, 128};
 %token SETB SEXT SUB SUBB TRAP XCH XOR
 %token REG DPTR PC A C USP
 %token WORD BIT NUMBER CHAR STRING EOL LOCAL_LABEL
-%token ORG EQU DB DW BITDEF REGDEF LOW HIGH
+%token ORG EQU SFR DB DW BITDEF REGDEF LOW HIGH
 %token RSHIFT LSHIFT
 %token AREA AREA_NAME AREA_DESC DS
 %token MODULE GLOBL 
@@ -85,7 +84,7 @@ line:          linesymbol ':' linenosym {
                }
 
 linenosym:     directive EOL {
-                       if (p3) out(op, $1);
+                       if (p3) out(op, $1);
                        $$ = $1;
                }
              | instruction EOL {
@@ -112,9 +111,14 @@ directive:     '.' ORG expr {
                        if (p1 || p2) assign_value(symbol_name, $5);
                        $$ = 0;
                }
-            | symbol EQU expr {
+             | normal_or_bit_symbol '=' expr {
+                       if (p1) build_sym_list(symbol_name);
+                       if (p1 || p2) assign_value(symbol_name, $3);
+               }
+            | symbol SFR expr {
                        if (p1) build_sym_list(symbol_name);
                        if (p1 || p2) assign_value(symbol_name, $3);
+                       if (p1 || p2) mk_sfr(symbol_name);
                        $$ = 0;
                }
             | '.' BITDEF bitsymbol ',' bit {
@@ -133,6 +137,14 @@ directive:     '.' ORG expr {
                         if (p1 || p2) assign_value(symbol_name, $3);
                         $$ = 0;
                 }
+            | bitsymbol BITDEF expr {
+                       if (p1) {
+                                build_sym_list(symbol_name);
+                                mk_bit(symbol_name);
+                        }
+                        if (p1 || p2) assign_value(symbol_name, $3);
+                        $$ = 0;
+                }
             | '.' REGDEF regsymbol ',' REG {
                        if (p1) {
                                build_sym_list(symbol_name);
@@ -166,14 +178,16 @@ directive:     '.' ORG expr {
                }
             | '.' MODULE WORD {
                        /* ignore module definition */
-                       build_sym_list(lex_sym_name);
-                       assign_value(lex_sym_name, 0);
                        $$ = 0;
                }
             | '.' GLOBL WORD {
                        /* ignore global symbol declaration */
                        $$ = 0;
                }
+            | '.' GLOBL bit {
+                       /* ignore bit symbol declaration */
+                       $$ = 0;
+               }
             | '.' DS expr {
                        /* todo: if CSEG, emit some filler bytes */
                        $$ = $3;
@@ -1127,7 +1141,7 @@ int reg(int reg_spec)
 int reg_indirect(int reg_spec)
 {
        if (reg_spec & BYTE_REG)
-               error("Imdirect addressing may not use byte registers");
+               error("Indirect addressing may not use byte registers");
        if ((reg_spec & 15) > 7)
                error("Only R0 through R7 may be used for indirect addr");
        return reg_spec & 7;
@@ -1305,11 +1319,6 @@ int yyerror(char *s)
 }
 
 void error(char *s)
-{
-       yyerror(s);
-}
-
-void fatal_error(char *s)
 {
        yyerror(s);
        exit(1);