* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2.
*
- * Foobar is distributed in the hope that it will be useful,
+ * Paul's XA51 Assembler is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
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};
%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
}
linenosym: directive EOL {
- if (p3) out(op, $1);
+ if (p3) out(op, $1);
$$ = $1;
}
| instruction EOL {
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 {
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);
$$ = 0;
}
- | db_directive bytes {
+ | '.' db_directive bytes {
$$ = db_count;
}
- | dw_directive words {
+ | '.' dw_directive words {
$$ = dw_count;
}
| '.' AREA AREA_NAME AREA_DESC {
/* ignore global symbol declaration */
$$ = 0;
}
+ | '.' GLOBL bit {
+ /* ignore bit symbol declaration */
+ $$ = 0;
+ }
| '.' DS expr {
/* todo: if CSEG, emit some filler bytes */
$$ = $3;
db_directive: DB {db_count = 0;}
-linesymbol: WORD {
+linesymbol: normal_or_bit_symbol {
strcpy(symbol_name, lex_sym_name);
if (!strchr(lex_sym_name, ':')) {
/* non-local label, remember base name */
if (is_target(symbol_name)) pad_with_nop();
}
+normal_or_bit_symbol: WORD {$$ = $1;}
+ | BIT {$$ = $1;}
+
bytes: byte_element
| bytes ',' byte_element
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;
}
void error(char *s)
-{
- yyerror(s);
-}
-
-void fatal_error(char *s)
{
yyerror(s);
exit(1);