400e7dcf9f620fc9ac577cb6e6b142f282b437ca
[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 issfr;
36         int isreg;      /* 1 if a register, 0 otehrwise */
37         int global ;    /* is defined as global */
38         char mode;      /* Absolute, Relative, Tmplabel, eXternal */
39         short lk_index; /* symbol index for the linker */
40         int area;       /* the area that this symbol is in */
41         struct symbol *next; };
42
43 /* a list of all the symbols that are branch targets */
44 /* (and will need to get aligned on 4 byte boundries) */
45
46 struct target {
47         char *name;
48         struct target *next; };
49
50 struct area_struct {
51         int start;
52         int alloc_position;
53         int defsEmitted;
54         int size;
55 };
56
57 extern int current_area;
58
59 #define MEM_POS (area[current_area].alloc_position)
60
61 enum {
62   AREA_CSEG=1,
63   AREA_DSEG,
64   // AREA_OSEG,
65   // AREA_ISEG,
66   AREA_BSEG,
67   AREA_XSEG,
68   AREA_XISEG,
69   AREA_XINIT,
70   AREA_GSINIT,
71   AREA_GSFINAL,
72   AREA_HOME,
73   AREA_SSEG,
74   NUM_AREAS=AREA_SSEG
75 };
76
77 extern struct area_struct area[NUM_AREAS];
78
79 extern FILE *yyin;
80 extern char *yytext;
81 extern int lineno;
82 extern int p1, p2, p3, mem, m_len;
83
84 extern struct symbol * build_sym_list(char *thename);
85 extern int assign_value(char *thename, int thevalue, char mode);
86 extern int mk_bit(char *thename, int current_area);
87 extern int mk_reg(char *thename);
88 extern void out(int *byte_list, int num);
89 extern int is_target(char *thename);
90 extern void pad_with_nop();
91 extern int binary2int(char *str);
92 extern int is_bit(char *thename);
93 extern int is_reg(char *thename);
94 extern struct symbol * is_def(char *thename);
95 extern struct symbol * is_ref(char *thename);
96 extern int get_value(char *thename);
97 extern struct symbol *findSymbol (char *thename);
98 extern char rel_line[2][132];
99 extern char operand[2][MAX_SYMBOL];
100 extern void error(char*);
101 int mk_bit(char*, int);
102 int mk_sfr(char*);
103 int mk_global(char*);
104 struct target * build_target_list(char *thename);
105 struct symbol * build_sym_list(char *);
106 int find_size_reg(int op1spec);
107 int find_size0(int isize);
108 int find_size1(int isize, int op1spec);
109 int find_size2(int isize, int op1spec, int op2spec);
110 int yyerror(char *s);
111 int imm_data4_signed(int value);
112 int imm_data4_unsigned(int value);
113 int imm_data5_unsigned(int value);
114 int imm_data8(int value);
115 int imm_data16(int value);
116 int reg(int reg_spec);
117 int reg_indirect(int reg_spec);
118 int lsb(int value);
119 int msb(int value);
120 int direct_addr(int value);
121 int bit_addr(int value);
122 int rel16(int pos, int dest);
123 int rel8(int pos, int dest);
124 char *areaToString (int area);
125
126 FILE *frel, *fmem, *list_fp, *sym_fp;
127
128 extern void relout();