Subversion Repositories tendra.SVN

Rev

Go to most recent revision | 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
/* sco/assembler.c */
32
 
33
/**********************************************************************
34
$Author: release $
35
$Date: 1998/01/17 15:55:51 $
36
$Revision: 1.1.1.1 $
37
$Log: assembler.c,v $
38
 * Revision 1.1.1.1  1998/01/17  15:55:51  release
39
 * First version to be checked into rolling release.
40
 *
41
 * Revision 1.8  1997/03/24  12:43:33  pwe
42
 * outn int->long
43
 *
44
 * Revision 1.7  1995/10/09  15:14:29  pwe
45
 * dynamic initialisation etc
46
 *
47
 * Revision 1.6  1995/03/16  09:13:41  pwe
48
 * sco_gas now install time option
49
 *
50
 * Revision 1.5  1995/01/30  12:57:17  pwe
51
 * Ownership -> PWE, tidy banners
52
 *
53
 * Revision 1.4  1994/10/28  11:17:30  jmf
54
 * Changed out_switch_jump to subtract lower
55
 *
56
 * Revision 1.3  1994/07/15  14:00:48  jmf
57
 * Round .comm to 8 (?but bss may not start aligned 8.
58
 *
59
 * Revision 1.2  1994/07/13  07:57:06  jmf
60
 * Added Log
61
 *
62
**********************************************************************/
63
 
64
 
65
 
66
#include "config.h"
67
#include "common_types.h"
68
#include "out.h"
69
#include "expmacs.h"
70
#include "operand.h"
71
#include "machine.h"
72
#include "localflags.h"
73
#include "basicread.h"
74
 
75
 
76
int sco_gas = 0;
77
 
78
/* PROCEDURES */
79
 
80
void dot_align
81
    PROTO_N ( (n) )
82
    PROTO_T ( int n )
83
{
84
  if (!sco_gas && n> 4)
85
    n = 4;
86
  outs(".align "); outn((long)n); outnl();
87
  return;
88
}
89
 
90
 
91
void outbyte
92
    PROTO_Z ()
93
{
94
  outs(".byte ");
95
  return;
96
}
97
 
98
void outshort
99
    PROTO_Z ()
100
{
101
  outs(".value ");
102
  return;
103
}
104
 
105
void outlong
106
    PROTO_Z ()
107
{
108
  outs(".long ");
109
  return;
110
}
111
 
112
void align_label
113
    PROTO_N ( (f, jr) )
114
    PROTO_T ( int f X exp jr )
115
{
116
  UNUSED(f);
117
  UNUSED(jr);
118
  if (is80486 && !is80586) {
119
    outs(".align 4\n");
120
  };
121
  return;
122
}
123
 
124
void eval_postlude
125
    PROTO_N ( (s, c) )
126
    PROTO_T ( char * s X exp c )
127
{
128
  UNUSED(s); UNUSED(c);
129
    return;
130
}
131
 
132
void out_readonly_section
133
    PROTO_Z ()
134
{
135
  outs (".text");
136
  return;
137
}
138
 
139
void out_dot_comm
140
    PROTO_N ( (id, sha) )
141
    PROTO_T ( char * id X shape sha )
142
{
143
	outs (".comm ");
144
	outs (id);
145
	outs (",");
146
	if (sco_gas)
147
	  outn ((long)((( shape_size(sha)/ 8) + 3) / 4) * 4);
148
	else
149
	  outn ((long)((( shape_size(sha)/ 8) + 7) / 8) * 8);
150
 
151
	outnl ();
152
  return;
153
}
154
 
155
void out_dot_lcomm
156
    PROTO_N ( (id, sha) )
157
    PROTO_T ( char * id X shape sha )
158
{
159
	outs (".lcomm ");
160
	outs (id);
161
	outs (",");
162
	if (sco_gas)
163
	  outn ((long)((( shape_size(sha)/ 8) + 3) / 4) * 4);
164
	else
165
	  outn ((long)((( shape_size(sha)/ 8) + 7) / 8) * 8);
166
 
167
	outnl ();
168
  return;
169
}
170
 
171
void out_bss
172
    PROTO_N ( (id, sha) )
173
    PROTO_T ( char * id X shape sha )
174
{
175
	outs (".bss ");
176
	outs (id);
177
	outs (",");
178
	if (sco_gas)
179
	  outn ((long)((( shape_size(sha)/ 8) + 3) / 4) * 4);
180
	else
181
	  outn ((long)((( shape_size(sha)/ 8) + 7) / 8) * 8);
182
 
183
	outnl ();
184
  return;
185
}
186
 
187
void pic_prelude
188
    PROTO_Z ()
189
{
190
  return;
191
}
192
 
193
void out_rename
194
    PROTO_N ( (oldid, newid) )
195
    PROTO_T ( char * oldid X char * newid )
196
{
197
  UNUSED(oldid); UNUSED(newid);
198
  return;
199
}
200
 
201
 
202
void out_switch_jump
203
    PROTO_N ( (tab, a, min) )
204
    PROTO_T ( int tab X where a X int min )
205
{
206
    outs (" jmp *");
207
    outs(local_prefix);
208
    outn((long)tab);
209
    outs("-");
210
    outn((long)(4 * min));
211
    outs ("(,");
212
    operand (32, a, 1, 0);
213
    outs (",4)");
214
    outnl ();
215
    return;
216
}
217
 
218
void out_switch_table
219
    PROTO_N ( (tab, min, max, v, absent) )
220
    PROTO_T ( int tab X int min X int max X int * v X int absent )
221
{
222
  int i;
223
 
224
  dot_align(4);
225
  outnl();
226
 
227
  outs(local_prefix);
228
  outn ((long)tab);
229
  outs (":");
230
  outnl ();
231
 
232
  for (i = min; i <= max; ++i) {
233
    outs (".long ");
234
    if (v[i - min] != -1)  {
235
      outs(local_prefix);
236
      outn ((long)v[i - min]);
237
    }
238
    else  {
239
      if (absent == -1)
240
	outn((long)0);
241
      else {
242
        outs(local_prefix);
243
        outn ((long)absent);
244
      };
245
    };
246
    outnl ();
247
 
248
  };
249
 
250
}
251
 
252
void proc_size
253
    PROTO_N ( (s) )
254
    PROTO_T ( char * s )
255
{
256
  UNUSED(s);
257
  return;
258
}
259
 
260
void proc_type
261
    PROTO_N ( (s) )
262
    PROTO_T ( char * s )
263
{
264
  UNUSED(s);
265
  return;
266
}
267
 
268
void outend
269
    PROTO_Z ()
270
{
271
  int   st;
272
 
273
  if (sco_gas) {
274
    outs(".text");
275
    outnl();
276
    dot_align(16);
277
  };
278
 
279
  st = fclose (fpout);
280
  if (st == EOF) {
281
    failer ("failed to close file");
282
    exit (EXIT_FAILURE);
283
  };
284
}
285
 
286
void outopenbr
287
    PROTO_Z ()
288
{
289
  return;
290
}
291
 
292
void outclosebr
293
    PROTO_Z ()
294
{
295
  return;
296
}
297
 
298
void outdivsym
299
    PROTO_Z ()
300
{
301
  outs("/");
302
  return;
303
}
304
 
305
void out_initialiser
306
    PROTO_N ( (id) )
307
    PROTO_T ( char* id )
308
{
309
  outs (".section .init,\"x\"\n");
310
  outs (" call ");
311
  outs (id);
312
  outnl ();
313
  outnl ();
314
  return;
315
}
316
 
317