Subversion Repositories tendra.SVN

Rev

Rev 2 | Details | Compare with Previous | 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
$Author: release $
33
$Date: 1998/02/04 10:43:49 $
34
$Revision: 1.2 $
35
$Log: out_ba.c,v $
36
 * Revision 1.2  1998/02/04  10:43:49  release
37
 * Changes during testing.
38
 *
39
 * Revision 1.1.1.1  1998/01/17  15:56:04  release
40
 * First version to be checked into rolling release.
41
 *
42
 * Revision 1.1  1995/04/13  09:33:41  currie
43
 * Initial revision
44
 *
45
***********************************************************************/
46
/* ****************************************************************
47
                              out_ba.c
48
   Procs for outputting binary assembly files.
49
   Each record in binasm is 16 bytes, coded in various ways depending
50
   on class of instruction or directtive.
51
*****************************************************************/
52
#include "config.h"
53
#include "ibinasm.h"
54
#include "out_ba.h"
55
 
56
extern  FILE * ba_file;
57
 
58
static  binasm ba;
59
 
60
 
61
 
62
#define  OUT out_one(  ba.data)
63
#define C(x)  ba.x.symno = symno; ba.x.fill0a =0;ba.x.asmtype = asmtype
64
 
65
void out_one
66
    PROTO_N ( (d) )
67
    PROTO_T ( char *d )
68
{	/* output one binasm record */
69
  int   i;
70
  for (i = 0; i < 16; i++) {
71
    putc (d[i], ba_file);
72
    d[i] = 0;
73
  }
74
  return ;
75
}
76
 
77
void out_data
78
    PROTO_N ( (s, size) )
79
    PROTO_T ( char *s X int size )
80
{
81
				/* output string as set of binasm records
82
				*/
83
  int   i;
84
  int   j = ((size + 15) >> 4) << 4;
85
  for (i = 0; i < size; i++) {
86
    putc (s[i], ba_file);
87
  }
88
  for (i = size; i < j; i++) {
89
    putc (' ', ba_file);
90
  }
91
}
92
 
93
 
94
 
95
 
96
void out_common
97
    PROTO_N ( (symno, asmtype) )
98
    PROTO_T ( asmsym symno X unsigned asmtype )
99
{
100
				/* things like label settings */
101
  C (common);
102
  OUT;
103
}
104
 
105
void out_ent
106
    PROTO_N ( (symno, asmtype, lexlev) )
107
    PROTO_T ( asmsym symno X unsigned asmtype X unsigned lexlev )
108
{
109
				/* output enter binasm record */
110
  C (ent);
111
  ba.ent.lexlev = lexlev;
112
  OUT;
113
}
114
 
115
void out_frame
116
    PROTO_N ( (symno,asmtype, frameoffset, framereg, pcreg) )
117
    PROTO_T ( asmsym symno X unsigned asmtype X asmint frameoffset X asmreg framereg X asmreg pcreg )
118
{/* output frame binasm record */
119
  C (frame);
120
  ba.frame.frameoffset = frameoffset;
121
  ba.frame.framereg = framereg;
122
  ba.frame.pcreg = pcreg;
123
  OUT;
124
}
125
 
126
void out_mask
127
    PROTO_N ( (symno, asmtype, regmask, regoffset) )
128
    PROTO_T ( asmsym symno X unsigned asmtype X unsigned regmask X asmint regoffset )
129
{		/* output mask binasm record */
130
  C (mask);
131
  ba.mask.regmask = regmask;
132
  ba.mask.regoffset = regoffset;
133
  OUT;
134
}
135
 
136
 
137
void out_verstamp
138
    PROTO_N ( ( majornumber, minornumber) )
139
    PROTO_T ( int majornumber X int minornumber )
140
{
141
				/* output version stamp binasm record */
142
  ba.verstamp.symno = 0;
143
  ba.verstamp.fill0a = 0;
144
  ba.verstamp.asmtype = iverstamp;
145
  ba.verstamp.majornumber = majornumber;
146
  ba.verstamp.minornumber = minornumber;
147
  OUT;
148
}
149
 
150
void out_loc
151
    PROTO_N ( (filenumber, linenumber) )
152
    PROTO_T ( unsigned filenumber X unsigned linenumber )
153
{
154
				/* output line-no binasm record */
155
  ba.loc.symno = 0;
156
  ba.loc.fill0a = 0;
157
  ba.loc.asmtype = iloc;
158
  ba.loc.filenumber = filenumber;
159
  ba.loc.linenumber = linenumber;
160
  OUT;
161
  fflush (ba_file);
162
}
163
 
164
void out_chars
165
    PROTO_N ( (symno, asmtype, expression, repeat) )
166
    PROTO_T ( asmsym symno X unsigned asmtype X asmint expression X unsigned short repeat )
167
{	/* output some data directive binasm
168
				   record */
169
  C (value);
170
  ba.value.expression = expression;
171
  ba.value.repeat = repeat;
172
  OUT;
173
}
174
 
175
void out_option
176
    PROTO_N ( (optype, opint) )
177
    PROTO_T ( int optype X int opint )
178
{
179
				/* output option binasm record */
180
  ba.option.symno = 0;
181
  ba.option.fill0a = 0;
182
  ba.option.asmtype = ioption;
183
  ba.option.optype = optype;
184
  ba.option.opint = opint;
185
  OUT;
186
}
187
 
188
void out_value
189
    PROTO_N ( ( symno, asmtype, expression, repeat) )
190
    PROTO_T ( asmsym symno X unsigned asmtype X asmint expression X unsigned long repeat )
191
{	/* output some data directive binasm
192
  				   record */
193
    C (value);
194
    ba.value.expression = expression;
195
    ba.value.repeat = (repeat>0xffff)?0xffff:repeat;
196
    OUT;
197
    if (repeat>0xffff) out_value(symno, asmtype, expression, repeat-0xffff);
198
}
199
 
200
void out_alias
201
    PROTO_N ( ( symno, asmtype, basereg1, basereg2) )
202
    PROTO_T ( asmsym symno X unsigned asmtype X asmreg basereg1 X asmreg basereg2 )
203
{		/* output alias binasm record */
204
  C (alias);
205
  ba.alias.basereg1 = basereg1;
206
  ba.alias.basereg2 = basereg2;
207
  OUT;
208
}
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.fill0a = 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.fill0a = 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.immediate = immediate;
242
  OUT;
243
}
244
 
245
 
246
void out_cpload
247
    PROTO_N ( (symno, reg) )
248
    PROTO_T ( asmsym symno X asmreg reg )
249
{ /* This is not called - here to retain same souces for bigenian */
250
	;
251
}