-
Notifications
You must be signed in to change notification settings - Fork 1
/
as31.h
140 lines (120 loc) · 3.47 KB
/
as31.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/* ----------------------------------------------------------------------
* FILE: as31.h
* PACKAGE: as31 - 8031/8051 Assembler.
*
* DESCRIPTION:
* The sole header file for the 8031/8051 assembler package.
* It defines several structures used by the yacc stack.
* It defines several macros for testing the bitsize of numeric
* quantities.
*
* Some macros to extract information from the mode structure.
*
* REVISION HISTORY:
* Jan. 19, 1990 - Created. (Ken Stauffer)
*
* AUTHOR:
* All code in this file written by Ken Stauffer (University of Calgary).
* January, 1990.
*
*/
/* ----------------------------------------------------------------------
* user / keyword symbol structures:
*/
struct opcode {
char *name;
int type;
unsigned char *bytes;
};
struct symbol {
char *name;
int type;
long value;
struct symbol *next;
};
#define UNDEF 0
#define LABEL 1
/* ----------------------------------------------------------------------
* addressing mode stuff:
*/
struct mode {
unsigned char mode; /* value to index with */
unsigned char size; /* # of bytes used */
unsigned char orval; /* value OR'd to obcode */
unsigned char byte1; /* extra byte 1 */
unsigned char byte2; /* extra byte 2 */
};
#define set_md(m,a) ((m).mode=(a))
#define set_sz(m,a) ((m).size=(a))
#define set_ov(m,a) ((m).orval=(a))
#define set_b1(m,a) ((m).byte1=(a))
#define set_b2(m,a) ((m).byte2=(a))
#define get_md(m) ((m).mode)
#define get_sz(m) ((m).size)
#define get_ov(m) ((m).orval)
#define get_b1(m) ((m).byte1)
#define get_b2(m) ((m).byte2)
/* ----------------------------------------------------------------------
* yacc stack stuff:
*/
struct value {
long v;
unsigned char d; /* expression defined flag */
};
union ystack {
long value;
struct value val;
struct opcode *op;
struct symbol *sym;
struct mode mode;
char *str;
};
/* ----------------------------------------------------------------------
* IS_BIT_MAPPED_RAM:
* True is the byte 'a' is the byte address of a bit mapped
* RAM location.
*/
#define isbmram(a) (((a)&0xf0)==0x20)
/* ----------------------------------------------------------------------
* IS_BIT_MAPPED_SFR:
* True is the byte 'a' is the byte address of a bit mapped
* SPECIAL FUCTION REGISTER.
*/
#define isbmsfr(a) (((a)&0x80) && !((a) & 0x07))
/* ----------------------------------------------------------------------
* isbit8, ...
* Macros to check the sizes of values and to convert
* a value to a certain, size.
*
*/
#define size8 (~0x00ff)
#define size11 (~0x07ff)
#define size13 (~0x1fff)
#define size16 (~0xffff)
#define size10 (~0x03ff)
#define size12 (~0x0fff)
#define size15 (~0x7fff)
#define isbit8(v) ( !( ((v)>=0) ? (v)&size8 : -(v)>=128) )
#define isbit11(v) ( !( ((v)>=0) ? (v)&size11 : (-(v))&size10 ) )
#define isbit13(v) ( !( ((v)>=0) ? (v)&size13 : (-(v))&size12 ) )
#define isbit16(v) ( !( ((v)>=0) ? (v)&size16 : (-(v))&size15 ) )
/* ----------------------------------------------------------------------
* Size of user hash table.
*/
#define HASHTABSIZE 1000
/* ----------------------------------------------------------------------
* Macros to nicely test which pass we are in.
*/
#define pass1 (!pass)
#define pass2 (pass)
/* -------- TOKENS ------------------------------------------------------
*
* This includes the header file generated by yacc -d.
* NOPE is defined inside of as31.y, which does not
* need to re-include the tokens twice, thus NOPE prevents this.
*
*/
#ifdef NOPE
#else
#include "y.tab.h"
#endif