Subversion Repositories tendra.SVN

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 7u83 1
/*
2
    		 Crown Copyright (c) 1997
3
 
4
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
12
 
13
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
15
 
16
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
19
 
20
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
22
        these conditions;
23
 
24
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
27
        it may be put.
28
*/
29
 
30
 
31
/* ****************************************************************
32
                              out_ba.c
33
   Procs for outputting binary assembly files.
34
   Each record in binasm is 16 bytes, coded in various ways depending
35
   on class of instruction or directtive.
36
*****************************************************************/
37
#include "config.h"
38
#include "ibinasm.h"
39
#include "out_ba.h"
40
 
41
extern  FILE * ba_file;
42
 
43
static  binasm ba;
44
 
45
 
46
 
47
#define  OUT out_one(  ba.data)
48
#define C(x)  ba.x.symno = symno; ba.x.fill07 =0;\
49
ba.x.formextn = 0; ba.x.asmtype = asmtype
50
 
51
void out_one
52
    PROTO_N ( (d) )
53
    PROTO_T ( char *d )
54
{	/* output one binasm record */
55
  int   i;
56
  for (i = 0; i < 16; i++) {
57
    putc (d[i], ba_file);
58
    d[i] = 0;
59
  }
60
  return;
61
}
62
 
63
void out_data
64
    PROTO_N ( (s, size) )
65
    PROTO_T ( char *s X int size )
66
{
67
				/* output string as set of binasm records
68
				*/
69
  int   i;
70
  int   j = ((size + 15) >> 4) << 4;
71
  for (i = 0; i < size; i++) {
72
    putc (s[i], ba_file);
73
  }
74
  for (i = size; i < j; i++)
75
    putc (' ', ba_file);
76
}
77
 
78
 
79
 
80
 
81
void out_common
82
    PROTO_N ( (symno, asmtype) )
83
    PROTO_T ( asmsym symno X unsigned asmtype )
84
{
85
				/* things like label settings */
86
  C (common);
87
  OUT;
88
}
89
 
90
void out_ent
91
    PROTO_N ( (symno, asmtype, lexlev) )
92
    PROTO_T ( asmsym symno X unsigned asmtype X unsigned lexlev )
93
{
94
				/* output enter binasm record */
95
  C (ent);
96
  ba.ent.lexlev = lexlev;
97
  OUT;
98
}
99
 
100
void out_frame
101
    PROTO_N ( (symno,asmtype, frameoffset, framereg, pcreg) )
102
    PROTO_T ( asmsym symno X unsigned asmtype X asmint frameoffset X asmreg framereg X asmreg pcreg )
103
{/* output frame binasm record */
104
  C (frame);
105
  ba.frame.frameoffset = frameoffset;
106
  ba.frame.framereg = framereg;
107
  ba.frame.pcreg = pcreg;
108
  OUT;
109
}
110
 
111
void out_mask
112
    PROTO_N ( (symno, asmtype, regmask, regoffset) )
113
    PROTO_T ( asmsym symno X unsigned asmtype X unsigned regmask X asmint regoffset )
114
{		/* output mask binasm record */
115
  C (mask);
116
  ba.mask.regmask = regmask;
117
  ba.mask.regoffset = regoffset;
118
  OUT;
119
}
120
 
121
 
122
void out_verstamp
123
    PROTO_N ( ( majornumber, minornumber) )
124
    PROTO_T ( int majornumber X int minornumber )
125
{
126
				/* output version stamp binasm record */
127
  ba.verstamp.symno = 0;
128
  ba.verstamp.fill07 = 0; ba.verstamp.formextn = 0;
129
  ba.verstamp.asmtype = iverstamp;
130
  ba.verstamp.majornumber = majornumber;
131
  ba.verstamp.minornumber = minornumber;
132
  OUT;
133
}
134
 
135
void out_loc
136
    PROTO_N ( (filenumber, linenumber) )
137
    PROTO_T ( unsigned filenumber X unsigned linenumber )
138
{
139
				/* output line-no binasm record */
140
  ba.loc.symno = 0;
141
  ba.loc.fill07 = 0; ba.loc.formextn = 0;
142
  ba.loc.asmtype = iloc;
143
  ba.loc.filenumber = filenumber;
144
  ba.loc.linenumber = linenumber;
145
  OUT;
146
  fflush (ba_file);
147
}
148
 
149
void out_chars
150
    PROTO_N ( (symno, asmtype, expression, repeat) )
151
    PROTO_T ( asmsym symno X unsigned asmtype X asmint expression X unsigned short repeat )
152
{	/* output some data directive binasm
153
				   record */
154
  C (value);
155
  ba.value.expression = expression;
156
  ba.value.repeat = repeat;
157
  OUT;
158
}
159
 
160
void out_option
161
    PROTO_N ( (optype, opint) )
162
    PROTO_T ( int optype X int opint )
163
{
164
				/* output option binasm record */
165
  ba.voption.symno = 0;
166
  ba.voption.fill07 = 0; ba.voption.formextn = 0;
167
  ba.voption.asmtype = ioption;
168
  ba.voption.option = optype;
169
  ba.voption.opt_int_value = opint;
170
  OUT;
171
}
172
 
173
void out_value
174
    PROTO_N ( ( symno, asmtype, expression, repeat) )
175
    PROTO_T ( asmsym symno X unsigned asmtype X asmint expression X unsigned long repeat )
176
{	/* output some data directive binasm
177
  				   record */
178
    C (value);
179
    ba.value.expression = expression;
180
    ba.value.repeat = (repeat>0xffff)?0xffff:repeat;
181
    OUT;
182
    if (repeat>0xffff) out_value(symno, asmtype, expression, repeat-0xffff);
183
}
184
 
185
void out_alias
186
    PROTO_N ( ( symno, asmtype, basereg1, basereg2) )
187
    PROTO_T ( asmsym symno X unsigned asmtype X asmreg basereg1 X asmreg basereg2 )
188
{		/* output alias binasm record */
189
  C (alias);
190
  ba.alias.basereg1 = basereg1;
191
  ba.alias.basereg2 = basereg2;
192
  OUT;
193
}
194
 
195
void out_cpload
196
    PROTO_N ( (symno, reg) )
197
    PROTO_T ( asmsym symno X asmreg reg )
198
{
199
  ba.rinst.symno = symno;
200
  ba.rinst.asmtype = icpload;
201
  ba.rinst.fill07 = 0; ba.rinst.formextn = 0;
202
  ba.rinst.fill03 = 0;
203
  ba.rinst.op = 0;
204
  ba.rinst.reg1 = reg;
205
  ba.rinst.reg2 = 0;
206
  ba.rinst.form = 0;
207
  ba.rinst.reg3 = 0;
208
  OUT;
209
}
210
void out_rinst
211
    PROTO_N ( ( symno, opcode, reg1, reg2, form, reg3) )
212
    PROTO_T ( asmsym symno X unsigned char opcode X asmreg reg1 X asmreg reg2 X asmformat form X asmreg reg3 )
213
{/* output binasm for instruction with no
214
				   immediate operand */
215
  ba.rinst.symno = symno;
216
  ba.rinst.asmtype = iocode;
217
  ba.rinst.fill07 = 0; ba.rinst.formextn = 0;
218
  ba.rinst.fill03 = 0;
219
  ba.rinst.op = opcode;
220
  ba.rinst.reg1 = reg1;
221
  ba.rinst.reg2 = reg2;
222
  ba.rinst.form = form;
223
  ba.rinst.reg3 = reg3;
224
  OUT;
225
}
226
 
227
void out_iinst
228
    PROTO_N ( ( symno, opcode, reg1, reg2, form, immediate) )
229
    PROTO_T ( asmsym symno X unsigned char opcode X asmreg reg1 X asmreg reg2 X asmformat form X asmint immediate )
230
{
231
				/* output binasm for instruction with
232
				   immediate operand */
233
  ba.iinst.symno = symno;
234
  ba.iinst.asmtype = iocode;
235
  ba.iinst.fill07 = 0; ba.iinst.formextn = 0;
236
  ba.iinst.fill03 = 0;
237
  ba.iinst.op = opcode;
238
  ba.iinst.reg1 = reg1;
239
  ba.iinst.reg2 = reg2;
240
  ba.iinst.form = form;
241
  ba.iinst.mem_tag = 0; /*????*/
242
  ba.iinst.immediate = immediate;
243
  OUT;
244
}