Subversion Repositories tendra.SVN

Rev

Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2 Rev 7
Line -... Line 1...
-
 
1
/*
-
 
2
 * Copyright (c) 2002-2005 The TenDRA Project <http://www.tendra.org/>.
-
 
3
 * All rights reserved.
-
 
4
 *
-
 
5
 * Redistribution and use in source and binary forms, with or without
-
 
6
 * modification, are permitted provided that the following conditions are met:
-
 
7
 *
-
 
8
 * 1. Redistributions of source code must retain the above copyright notice,
-
 
9
 *    this list of conditions and the following disclaimer.
-
 
10
 * 2. Redistributions in binary form must reproduce the above copyright notice,
-
 
11
 *    this list of conditions and the following disclaimer in the documentation
-
 
12
 *    and/or other materials provided with the distribution.
-
 
13
 * 3. Neither the name of The TenDRA Project nor the names of its contributors
-
 
14
 *    may be used to endorse or promote products derived from this software
-
 
15
 *    without specific, prior written permission.
-
 
16
 *
-
 
17
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
-
 
18
 * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-
 
19
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-
 
20
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
-
 
21
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-
 
22
 * EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-
 
23
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-
 
24
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-
 
25
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-
 
26
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-
 
27
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
 
28
 *
-
 
29
 * $Id$
-
 
30
 */
1
/*
31
/*
2
    		 Crown Copyright (c) 1997
32
    		 Crown Copyright (c) 1997
3
 
33
 
4
    This TenDRA(r) Computer Program is subject to Copyright
34
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
35
    owned by the United Kingdom Secretary of State for Defence
Line 75... Line 105...
75
 
105
 
76
int sco_gas = 0;
106
int sco_gas = 0;
77
 
107
 
78
/* PROCEDURES */
108
/* PROCEDURES */
79
 
109
 
80
void dot_align
110
void
81
    PROTO_N ( (n) )
-
 
82
    PROTO_T ( int n )
111
dot_align(int n)
83
{
112
{
84
  if (!sco_gas && n> 4)
113
  if (!sco_gas && n> 4) {
85
    n = 4;
114
    n = 4;
-
 
115
  }
86
  outs(".align "); outn((long)n); outnl();
116
  outs(".align ");
-
 
117
  outn((long)n);
-
 
118
  outnl();
87
  return;
119
  return;
88
}
120
}
89
 
121
 
90
 
122
 
91
void outbyte
123
void
92
    PROTO_Z ()
124
outbyte(void)
93
{
125
{
94
  outs(".byte ");
126
  outs(".byte ");
95
  return;
127
  return;
96
}
128
}
97
 
129
 
98
void outshort
130
void
99
    PROTO_Z ()
131
outshort(void)
100
{
132
{
101
  outs(".value ");
133
  outs(".value ");
102
  return;
134
  return;
103
}
135
}
104
 
136
 
105
void outlong
137
void
106
    PROTO_Z ()
138
outlong(void)
107
{
139
{
108
  outs(".long ");
140
  outs(".long ");
109
  return;
141
  return;
110
}
142
}
111
 
143
 
112
void align_label
144
void
113
    PROTO_N ( (f, jr) )
-
 
114
    PROTO_T ( int f X exp jr )
145
align_label(int f, exp jr)
115
{
146
{
116
  UNUSED(f);
147
  UNUSED(f);
117
  UNUSED(jr);
148
  UNUSED(jr);
118
  if (is80486 && !is80586) {
149
  if (is80486 && !is80586) {
119
    outs(".align 4\n");
150
    outs(".align 4\n");
120
  };
151
  }
121
  return;
152
  return;
122
}
153
}
123
 
154
 
124
void eval_postlude
155
void
125
    PROTO_N ( (s, c) )
-
 
126
    PROTO_T ( char * s X exp c )
156
eval_postlude(char *s, exp c)
127
{
157
{
-
 
158
  UNUSED(s);
128
  UNUSED(s); UNUSED(c);
159
  UNUSED(c);
129
    return;
160
  return;
130
}
161
}
131
 
162
 
-
 
163
void
132
void out_readonly_section
164
out_readonly_section(void)
133
    PROTO_Z ()
-
 
134
{
165
{
135
  outs (".text");
166
  outs(".text");
136
  return;
167
  return;
137
}
168
}
138
 
169
 
139
void out_dot_comm
170
void
140
    PROTO_N ( (id, sha) )
-
 
141
    PROTO_T ( char * id X shape sha )
171
out_dot_comm(char *id, shape sha)
142
{
172
{
143
	outs (".comm ");
173
	outs(".comm ");
144
	outs (id);
174
	outs(id);
145
	outs (",");
175
	outs(",");
146
	if (sco_gas)
176
	if (sco_gas) {
147
	  outn ((long)((( shape_size(sha)/ 8) + 3) / 4) * 4);
177
	  outn((long)(((shape_size(sha) / 8) + 3) / 4) * 4);
148
	else
178
	} else {
149
	  outn ((long)((( shape_size(sha)/ 8) + 7) / 8) * 8);
179
	  outn((long)(((shape_size(sha) / 8) + 7) / 8) * 8);
-
 
180
	}
150
 
181
 
151
	outnl ();
182
	outnl();
152
  return;
183
  return;
153
}
184
}
154
 
185
 
155
void out_dot_lcomm
186
void
156
    PROTO_N ( (id, sha) )
-
 
157
    PROTO_T ( char * id X shape sha )
187
out_dot_lcomm(char *id, shape sha)
158
{
188
{
159
	outs (".lcomm ");
189
	outs(".lcomm ");
160
	outs (id);
190
	outs(id);
161
	outs (",");
191
	outs(",");
162
	if (sco_gas)
192
	if (sco_gas) {
163
	  outn ((long)((( shape_size(sha)/ 8) + 3) / 4) * 4);
193
	  outn((long)(((shape_size(sha) / 8) + 3) / 4) * 4);
164
	else
194
	} else {
165
	  outn ((long)((( shape_size(sha)/ 8) + 7) / 8) * 8);
195
	  outn((long)(((shape_size(sha) / 8) + 7) / 8) * 8);
-
 
196
	}
166
 
197
 
167
	outnl ();
198
	outnl();
168
  return;
199
  return;
169
}
200
}
170
 
201
 
171
void out_bss
202
void
172
    PROTO_N ( (id, sha) )
-
 
173
    PROTO_T ( char * id X shape sha )
203
out_bss(char *id, shape sha)
174
{
204
{
175
	outs (".bss ");
205
	outs(".bss ");
176
	outs (id);
206
	outs(id);
177
	outs (",");
207
	outs(",");
178
	if (sco_gas)
208
	if (sco_gas) {
179
	  outn ((long)((( shape_size(sha)/ 8) + 3) / 4) * 4);
209
	  outn((long)(((shape_size(sha) / 8) + 3) / 4) * 4);
180
	else
210
	} else {
181
	  outn ((long)((( shape_size(sha)/ 8) + 7) / 8) * 8);
211
	  outn((long)(((shape_size(sha) / 8) + 7) / 8) * 8);
-
 
212
	}
182
 
213
 
183
	outnl ();
214
	outnl();
184
  return;
215
  return;
185
}
216
}
186
 
217
 
187
void pic_prelude
218
void
188
    PROTO_Z ()
219
pic_prelude(void)
189
{
220
{
190
  return;
221
  return;
191
}
222
}
192
 
223
 
193
void out_rename
224
void
194
    PROTO_N ( (oldid, newid) )
-
 
195
    PROTO_T ( char * oldid X char * newid )
225
out_rename(char *oldid, char *newid)
196
{
226
{
-
 
227
  UNUSED(oldid);
197
  UNUSED(oldid); UNUSED(newid);
228
  UNUSED(newid);
198
  return;
229
  return;
199
}
230
}
200
 
231
 
201
 
232
 
202
void out_switch_jump
233
void
203
    PROTO_N ( (tab, a, min) )
-
 
204
    PROTO_T ( int tab X where a X int min )
234
out_switch_jump(int tab, where a, int min)
205
{
235
{
206
    outs (" jmp *");
236
    outs(" jmp *");
207
    outs(local_prefix);
237
    outs(local_prefix);
208
    outn((long)tab);
238
    outn((long)tab);
209
    outs("-");
239
    outs("-");
210
    outn((long)(4 * min));
240
    outn((long)(4 * min));
211
    outs ("(,");
241
    outs("(,");
212
    operand (32, a, 1, 0);
242
    operand(32, a, 1, 0);
213
    outs (",4)");
243
    outs(",4)");
214
    outnl ();
244
    outnl();
215
    return;
245
    return;
216
}
246
}
217
 
247
 
218
void out_switch_table
248
void
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 )
249
out_switch_table(int tab, int min, int max, int *v, int absent)
221
{
250
{
222
  int i;
251
  int i;
223
 
252
 
224
  dot_align(4);
253
  dot_align(4);
225
  outnl();
254
  outnl();
226
 
255
 
227
  outs(local_prefix);
256
  outs(local_prefix);
228
  outn ((long)tab);
257
  outn((long)tab);
229
  outs (":");
258
  outs(":");
230
  outnl ();
259
  outnl();
231
 
260
 
232
  for (i = min; i <= max; ++i) {
261
  for (i = min; i <= max; ++i) {
233
    outs (".long ");
262
    outs(".long ");
234
    if (v[i - min] != -1)  {
263
    if (v[i - min]!= -1) {
235
      outs(local_prefix);
264
      outs(local_prefix);
236
      outn ((long)v[i - min]);
265
      outn((long)v[i - min]);
237
    }
-
 
238
    else  {
266
    } else {
239
      if (absent == -1)
267
      if (absent == -1) {
240
	outn((long)0);
268
	outn((long)0);
241
      else {
269
      } else {
242
        outs(local_prefix);
270
        outs(local_prefix);
243
        outn ((long)absent);
271
        outn((long)absent);
244
      };
272
      }
245
    };
273
    }
246
    outnl ();
274
    outnl();
247
 
-
 
248
  };
275
  }
249
 
-
 
250
}
276
}
251
 
277
 
252
void proc_size
278
void
253
    PROTO_N ( (s) )
-
 
254
    PROTO_T ( char * s )
279
proc_size(char *s)
255
{
280
{
256
  UNUSED(s);
281
  UNUSED(s);
257
  return;
282
  return;
258
}
283
}
259
 
284
 
260
void proc_type
285
void
261
    PROTO_N ( (s) )
-
 
262
    PROTO_T ( char * s )
286
proc_type(char *s)
263
{
287
{
264
  UNUSED(s);
288
  UNUSED(s);
265
  return;
289
  return;
266
}
290
}
267
 
291
 
268
void outend
292
void
269
    PROTO_Z ()
293
outend(void)
270
{
294
{
271
  int   st;
295
  int st;
272
 
296
 
273
  if (sco_gas) {
297
  if (sco_gas) {
274
    outs(".text");
298
    outs(".text");
275
    outnl();
299
    outnl();
276
    dot_align(16);
300
    dot_align(16);
277
  };
301
  }
278
 
302
 
279
  st = fclose (fpout);
303
  st = fclose(fpout);
280
  if (st == EOF) {
304
  if (st == EOF) {
281
    failer ("failed to close file");
305
    failer("failed to close file");
282
    exit (EXIT_FAILURE);
306
    exit(EXIT_FAILURE);
283
  };
307
  }
284
}
308
}
285
 
309
 
286
void outopenbr
310
void
287
    PROTO_Z ()
311
outopenbr(void)
288
{
312
{
289
  return;
313
  return;
290
}
314
}
291
 
315
 
292
void outclosebr
316
void
293
    PROTO_Z ()
317
outclosebr(void)
294
{
318
{
295
  return;
319
  return;
296
}
320
}
297
 
321
 
298
void outdivsym
322
void
299
    PROTO_Z ()
323
outdivsym(void)
300
{
324
{
301
  outs("/");
325
  outs("/");
302
  return;
326
  return;
303
}
327
}
304
 
328
 
305
void out_initialiser
329
void
306
    PROTO_N ( (id) )
-
 
307
    PROTO_T ( char* id )
330
out_initialiser(char *id)
308
{
331
{
309
  outs (".section .init,\"x\"\n");
332
  outs(".section .init,\"x\"\n");
310
  outs (" call ");
333
  outs(" call ");
311
  outs (id);
334
  outs(id);
312
  outnl ();
335
  outnl();
313
  outnl ();
336
  outnl();
314
  return;
337
  return;
315
}
338
}
316
 
339
 
317
 
340