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