OpenCores
URL https://opencores.org/ocsvn/System09/System09/trunk

Subversion Repositories System09

[/] [System09/] [rev_86/] [Tools/] [as09/] [as.h] - Blame information for rev 112

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 83 davidgb
/*
2
 *      machine independent definitions and global variables
3
 */
4
 
5
#define YES     1
6
#define NO      0
7
#define ERR     (-1)
8
 
9
#define MAXBUF  128
10
#define MAXOP   10      /* longest mnemonic */
11
#define MAXLAB  16
12
#define E_LIMIT 32
13
#define P_LIMIT 64
14
#define MAXINCFILES  30 /* nestinf levels for  INCLUDE files at one time */
15
                        /* ver TER_2.0 6/17/89 */
16
#define MAXIFD    30    /* max nesting levels for IFD/IFND statements */
17
                        /* ver TER_2.0 2 Jul 89 */
18
#define IF_FALSE  0     /* tokens for IfMachine (conditional assembly) */
19
#define IF_TRUE   1     /* added ver TER_2.0 27Jun89 */
20
#define IF_ELSE   2
21
#define IF_ENDIF  3
22
#define IF_NORMAL 4
23
#define IF_END    5
24
#define IF_EOF    6     /* end tokens */
25
 
26
/*      Character Constants     */
27
#define NEWLINE '\n'
28
#define CR      0x0D    /* <CR> or ^M ver TER_1.1 June 3, 1989 */
29
#define TAB     '\t'
30
#define BLANK   ' '
31
#define EOS     '\0'
32
 
33
/*      Opcode Classes          */
34
#define INH     0       /* Inherent                     */
35
#define GEN     1       /* General Addressing           */
36
#define IMM     2       /* Immediate only               */
37
#define REL     3       /* Short Relative               */
38
#define P2REL   4       /* Long Relative                */
39
#define P1REL   5       /* Long Relative (LBRA and LBSR)*/
40
#define NOIMM   6       /* General except for Immediate */
41
#define P2GEN   7       /* Page 2 General               */
42
#define P3GEN   8       /* Page 3 General               */
43
#define RTOR    9       /* Register To Register         */
44
#define INDEXED 10      /* Indexed only                 */
45
#define RLIST   11      /* Register List                */
46
#define P2NOIMM 12      /* Page 2 No Immediate          */
47
#define P2INH   13      /* Page 2 Inherent              */
48
#define P3INH   14      /* Page 3 Inherent              */
49
#define GRP2    15      /* Group 2 (Read/Modify/Write)  */
50
#define LONGIMM 16      /* Immediate mode takes 2 bytes */
51
#define BTB     17      /* Bit test and branch          */
52
#define SETCLR  18      /* Bit set or clear             */
53
#define CPD     19      /* compare d               6811 */
54
#define XLIMM   20      /* LONGIMM for X           6811 */
55
#define XNOIMM  21      /* NOIMM for X             6811 */
56
#define YLIMM   22      /* LONGIMM for Y           6811 */
57
#define YNOIMM  23      /* NOIMM for Y             6811 */
58
#define FAKE    24      /* convenience mnemonics   6804 */
59
#define APOST   25      /* A accum after opcode    6804 */
60
#define BPM     26      /* branch reg plus/minus   6804 */
61
#define CLRX    27      /* mvi x,0                 6804 */
62
#define CLRY    28      /* mvi y,0                 6804 */
63
#define LDX     29      /* mvi x,expr              6804 */
64
#define LDY     30      /* mvi y,expr              6804 */
65
#define MVI     31      /* mvi                     6804 */
66
#define EXT     32      /* extended                6804 */
67
#define BIT     33      /* bit manipulation        6301 */
68
#define SYS     34      /* syscalls (really swi)        */
69
#define PSEUDO  35      /* Pseudo ops                   */
70
 
71
/* global variables */
72
int     Line_num =0;            /* current line number          */
73
int     Err_count =0;           /* total number of errors       */
74
char    Line[MAXBUF] = {0};     /* input line buffer            */
75
char    Label[MAXLAB] = {0};    /* label on current line        */
76
char    Op[MAXOP] = {0};        /* opcode mnemonic on current line      */
77
char    Operand[MAXBUF] = {0};  /* remainder of line after op           */
78
                                /* (up to ';' rel TER_2.0) */
79
char    *Optr =0;               /* pointer into current Operand field   */
80
int     Result =0;              /* result of expression evaluation      */
81
int     Force_word =0;          /* Result should be a word when set     */
82
int     Force_byte =0;          /* Result should be a byte when set     */
83
int     Pc =0;                  /* Program Counter              */
84
int     Old_pc =0;              /* Program Counter at beginning */
85
 
86
int     Last_sym =0;            /* result of last lookup        */
87
 
88
int     Pass =0;                /* Current pass #               */
89
int     N_files =0;             /* Number of files to assemble  */
90
FILE    *Fd =0;                 /* Current input file structure */
91
int     Cfn =0;                 /* Current file number 1...n    */
92
int     Ffn =0;                 /* forward ref file #           */
93
int     F_ref =0;               /* next line with forward ref   */
94
char    **Argv =0;              /* pointer to file names        */
95
 
96
int     E_total =0;             /* total # bytes for one line   */
97
int     E_bytes[E_LIMIT] = {0}; /* Emitted held bytes           */
98
int     E_pc =0;                /* Pc at beginning of collection*/
99
 
100
int     Lflag = 0;              /* listing flag 0=nolist, 1=list*/
101
 
102
int     P_force = 0;            /* force listing line to include Old_pc */
103
int     P_total =0;             /* current number of bytes collected    */
104
int     P_bytes[P_LIMIT] = {0}; /* Bytes collected for listing  */
105
 
106
int     Cflag = 0;              /* cycle count flag */
107
int     Cycles = 0;             /* # of cycles per instruction  */
108
long    Ctotal = 0;             /* # of cycles seen so far */
109
int     Sflag = 0;              /* symbol table flag, 0=no symbol */
110
int     N_page = 0;             /* new page flag */
111
int     Page_num = 2;           /* page number */
112
int     CREflag = 0;            /* cross reference table flag */
113
int     CRflag = 0;             /* flag to add <CR><LF> to S record */
114
                                /* added ver TER_1.1 June 3, 1989 */
115
int     nfFlag = 1;             /* if=1 number INCLUDE files separate */
116
                                /* ver TER_2.0 June 17, 1989 */
117
int     FdCount = 0;            /* INCLUDE files "stack" pointer */
118
                                /* ver TER_2.0 June 17, 1989 */
119
char    InclFName[MAXBUF]={0};  /* current INCLUDE file name */
120
int     F_total = 0;            /* total bytes emitted in S file */
121
                                /* ver (TER) 2.02 19 Jun 89 */
122
int     Page_lines = 0;         /* total lines this page */
123
                                /* ver (TER) 2.02 19 Jun 89 */
124
int     Pflag50 = 0;            /* if 1 then form feed every 50 lines */
125
                                /* ver (TER) 2.02 19 Jun 89 */
126
int     Pflag75 = 0;            /* if 1 then form feed every 75 lines */
127
                                /* ver (DWC) 2.10 8 Oct 2001 */
128
int     PC_Save[4] = {0,0,0,0}; /* saved contents of CODE,DATA,BSS,AUTO PCs */
129
                                /* ver TER_2.09 25 July 89 */
130
int     PC_ptr = 0;             /* index or pointer to current PC */
131
                        /* initialized to CODE ver TER_2.09 25 July 89 */
132
 
133
struct link { /* linked list to hold line numbers */
134
       int L_num; /* line number */
135
       struct link *next; /* pointer to next node */
136
};
137
 
138
struct nlist { /* basic symbol table entry */
139
        char    *name;
140
        int     def;    /* value of symbol, assigned by user */
141
        int     def2;   /* value assign by assembler, e.g. defined this pass? */
142
                        /* added ver TER_2.0 4 Jul 89 */
143
        struct nlist *Lnext ; /* left node of the tree leaf */
144
        struct nlist *Rnext; /* right node of the tree leaf */
145
        struct link *L_list; /* pointer to linked list of line numbers */
146
};
147
 
148
struct oper {   /* an entry in the mnemonic table */
149
        char    *mnemonic;      /* its name */
150
        char    class;          /* its class */
151
        int     opcode;         /* its base opcode */
152
        char    cycles;         /* its base # of cycles */
153
};
154
 
155
struct  nlist *root;            /* root node of the tree */
156
 
157
FILE    *Objfil =0;             /* object file's file descriptor*/
158
char    Obj_name[] = {"             "};
159
 
160
struct  InclFile {      /* The INCLUDE files nesting "stack" */
161
                        /* added ver TER_2.0 6/17/89 */
162
        FILE    *fp;            /* saved file pointer (next level up) */
163
        int     line_num;       /* saved line number count */
164
        char    *name;  /* saved file name */
165
                  };
166
 
167
struct  InclFile InclFiles[MAXINCFILES];        /* the nesting stack itself */
168
 
169
/* defined in doXX.c */
170
void do_op(int opcode,int class);
171
 
172
/* defined in symtab.c */
173
struct nlist * lookup(char *name);
174
 
175
/* defined in util.c */
176
void pouterror();
177
void f_record();
178
void NewPage();

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.