xa_asm: fixed parsing of symbols used with DS directive in BSEG (pass 2&3).
[fw/sdcc] / as / xa51 / xa_main.h
1 #define SIZE8 0
2 #define SIZE16 1
3 #define SIZE32 2
4 #define UNKNOWN -1
5 #define WORD_REG 16384
6 #define BYTE_REG 32768
7
8 /* max # of bytes in db directive */
9 #define MAX_DB          2500
10
11 /* max # char in symbol name */
12 #define MAX_SYMBOL      1024
13
14 /* max # of bytes per line */
15 #define MAX_LINE        4096
16
17 /* REL() computes branch operand from dest and memory */
18 /* location of the jump instruction itself */
19 /* this is later adjusted by one for jcu, of course */
20 #define BRANCH_SPACING 2
21 #define REL(dest, mem) (((dest)-((((mem)+1)/(\
22 BRANCH_SPACING))*(BRANCH_SPACING)))/(BRANCH_SPACING))
23
24 #define NOP_OPCODE 0    /* opcode for NOP */
25
26 /* a linked list of all the symbols */
27
28 struct symbol {
29         char *name;
30         int value;
31         int istarget;   /* 1 if a branch target, 0 otherwise */
32         int isdef;      /* 1 if defined, 0 if no value yet */
33         int line_def;   /* line in which is was defined */
34         int isbit;      /* 1 if a bit address, 0 otherwise */
35         int isreg;      /* 1 if a register, 0 otehrwise */
36   int area;       /* the area that this symbol is in */
37         struct symbol *next; };
38
39 /* a list of all the symbols that are branch targets */
40 /* (and will need to get aligned on 4 byte boundries) */
41
42 struct target {
43         char *name;
44         struct target *next; };
45
46 struct area_struct {
47         int alloc_position;
48 };
49
50 extern int current_area;
51
52 #define MEM_POS (area[current_area].alloc_position)
53
54 #define AREA_CSEG       0
55 #define AREA_DSEG       1
56 #define AREA_OSEG       2
57 #define AREA_ISEG       3
58 #define AREA_BSEG       4
59 #define AREA_XSEG       5
60 #define AREA_XISEG      6
61 #define AREA_XINIT      7
62 #define AREA_GSINIT     8
63 #define AREA_GSFINAL    9
64 #define AREA_HOME       10
65 #define NUM_AREAS       11
66
67 extern struct area_struct area[NUM_AREAS];
68
69 extern FILE *yyin;
70 extern char *yytext;
71 extern int lineno;
72 extern int p1, p2, p3, mem, m_len;
73
74 extern struct symbol * build_sym_list(char *thename);
75 extern int assign_value(char *thename, int thevalue);
76 extern int mk_bit(char *thename);
77 extern int mk_reg(char *thename);
78 extern void out(int *byte_list, int num);
79 extern int is_target(char *thename);
80 extern void pad_with_nop();
81 extern int binary2int(char *str);
82 extern int is_def(char *thename);
83 extern int get_value(char *thename);
84