]> git.gag.com Git - fw/sdcc/blob - as/xa51/xa_main.h
xa51, 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   int area;       /* the area that this symbol is in */
38         struct symbol *next; };
39
40 /* a list of all the symbols that are branch targets */
41 /* (and will need to get aligned on 4 byte boundries) */
42
43 struct target {
44         char *name;
45         struct target *next; };
46
47 struct area_struct {
48         int start;
49         int alloc_position;
50 };
51
52 extern int current_area;
53
54 #define MEM_POS (area[current_area].alloc_position)
55
56 enum {
57   AREA_CSEG=0,
58   AREA_DSEG,
59   // AREA_OSEG,
60   // AREA_ISEG,
61   AREA_BSEG,
62   AREA_XSEG,
63   AREA_XISEG,
64   AREA_XINIT,
65   AREA_GSINIT,
66   AREA_GSFINAL,
67   AREA_HOME,
68   AREA_SSEG,
69   NUM_AREAS
70 };
71
72 extern struct area_struct area[NUM_AREAS];
73
74 extern FILE *yyin;
75 extern char *yytext;
76 extern int lineno;
77 extern int p1, p2, p3, mem, m_len;
78
79 extern struct symbol * build_sym_list(char *thename);
80 extern int assign_value(char *thename, int thevalue);
81 extern int mk_bit(char *thename);
82 extern int mk_reg(char *thename);
83 extern void out(int *byte_list, int num);
84 extern int is_target(char *thename);
85 extern void pad_with_nop();
86 extern int binary2int(char *str);
87 extern int is_def(char *thename);
88 extern int get_value(char *thename);
89