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
/*
7 7u83 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
 */
31
/*
2 7u83 32
    		 Crown Copyright (c) 1997
33
 
34
    This TenDRA(r) Computer Program is subject to Copyright
35
    owned by the United Kingdom Secretary of State for Defence
36
    acting through the Defence Evaluation and Research Agency
37
    (DERA).  It is made available to Recipients with a
38
    royalty-free licence for its use, reproduction, transfer
39
    to other parties and amendment for any purpose not excluding
40
    product development provided that any such use et cetera
41
    shall be deemed to be acceptance of the following conditions:-
42
 
43
        (1) Its Recipients shall ensure that this Notice is
44
        reproduced upon any copies or amended versions of it;
45
 
46
        (2) Any amended version of it shall be clearly marked to
47
        show both the nature of and the organisation responsible
48
        for the relevant amendment or amendments;
49
 
50
        (3) Its onward transfer from a recipient to another
51
        party shall be deemed to be that party's acceptance of
52
        these conditions;
53
 
54
        (4) DERA gives no warranty or assurance as to its
55
        quality or suitability for any purpose and DERA accepts
56
        no liability whatsoever in relation to any use to which
57
        it may be put.
58
*/
59
 
60
 
61
/* sco/assembler.c */
62
 
63
/**********************************************************************
64
$Author: release $
65
$Date: 1998/01/17 15:55:51 $
66
$Revision: 1.1.1.1 $
67
$Log: assembler.c,v $
68
 * Revision 1.1.1.1  1998/01/17  15:55:51  release
69
 * First version to be checked into rolling release.
70
 *
71
 * Revision 1.8  1997/03/24  12:43:33  pwe
72
 * outn int->long
73
 *
74
 * Revision 1.7  1995/10/09  15:14:29  pwe
75
 * dynamic initialisation etc
76
 *
77
 * Revision 1.6  1995/03/16  09:13:41  pwe
78
 * sco_gas now install time option
79
 *
80
 * Revision 1.5  1995/01/30  12:57:17  pwe
81
 * Ownership -> PWE, tidy banners
82
 *
83
 * Revision 1.4  1994/10/28  11:17:30  jmf
84
 * Changed out_switch_jump to subtract lower
85
 *
86
 * Revision 1.3  1994/07/15  14:00:48  jmf
87
 * Round .comm to 8 (?but bss may not start aligned 8.
88
 *
89
 * Revision 1.2  1994/07/13  07:57:06  jmf
90
 * Added Log
91
 *
92
**********************************************************************/
93
 
94
 
95
 
96
#include "config.h"
97
#include "common_types.h"
98
#include "out.h"
99
#include "expmacs.h"
100
#include "operand.h"
101
#include "machine.h"
102
#include "localflags.h"
103
#include "basicread.h"
104
 
105
 
106
int sco_gas = 0;
107
 
108
/* PROCEDURES */
109
 
7 7u83 110
void
111
dot_align(int n)
2 7u83 112
{
7 7u83 113
  if (!sco_gas && n> 4) {
2 7u83 114
    n = 4;
7 7u83 115
  }
116
  outs(".align ");
117
  outn((long)n);
118
  outnl();
2 7u83 119
  return;
120
}
121
 
122
 
7 7u83 123
void
124
outbyte(void)
2 7u83 125
{
126
  outs(".byte ");
127
  return;
128
}
129
 
7 7u83 130
void
131
outshort(void)
2 7u83 132
{
133
  outs(".value ");
134
  return;
135
}
136
 
7 7u83 137
void
138
outlong(void)
2 7u83 139
{
140
  outs(".long ");
141
  return;
142
}
143
 
7 7u83 144
void
145
align_label(int f, exp jr)
2 7u83 146
{
147
  UNUSED(f);
148
  UNUSED(jr);
149
  if (is80486 && !is80586) {
150
    outs(".align 4\n");
7 7u83 151
  }
2 7u83 152
  return;
153
}
154
 
7 7u83 155
void
156
eval_postlude(char *s, exp c)
2 7u83 157
{
7 7u83 158
  UNUSED(s);
159
  UNUSED(c);
160
  return;
2 7u83 161
}
162
 
7 7u83 163
void
164
out_readonly_section(void)
2 7u83 165
{
7 7u83 166
  outs(".text");
2 7u83 167
  return;
168
}
169
 
7 7u83 170
void
171
out_dot_comm(char *id, shape sha)
2 7u83 172
{
7 7u83 173
	outs(".comm ");
174
	outs(id);
175
	outs(",");
176
	if (sco_gas) {
177
	  outn((long)(((shape_size(sha) / 8) + 3) / 4) * 4);
178
	} else {
179
	  outn((long)(((shape_size(sha) / 8) + 7) / 8) * 8);
180
	}
2 7u83 181
 
7 7u83 182
	outnl();
2 7u83 183
  return;
184
}
185
 
7 7u83 186
void
187
out_dot_lcomm(char *id, shape sha)
2 7u83 188
{
7 7u83 189
	outs(".lcomm ");
190
	outs(id);
191
	outs(",");
192
	if (sco_gas) {
193
	  outn((long)(((shape_size(sha) / 8) + 3) / 4) * 4);
194
	} else {
195
	  outn((long)(((shape_size(sha) / 8) + 7) / 8) * 8);
196
	}
2 7u83 197
 
7 7u83 198
	outnl();
2 7u83 199
  return;
200
}
201
 
7 7u83 202
void
203
out_bss(char *id, shape sha)
2 7u83 204
{
7 7u83 205
	outs(".bss ");
206
	outs(id);
207
	outs(",");
208
	if (sco_gas) {
209
	  outn((long)(((shape_size(sha) / 8) + 3) / 4) * 4);
210
	} else {
211
	  outn((long)(((shape_size(sha) / 8) + 7) / 8) * 8);
212
	}
2 7u83 213
 
7 7u83 214
	outnl();
2 7u83 215
  return;
216
}
217
 
7 7u83 218
void
219
pic_prelude(void)
2 7u83 220
{
221
  return;
222
}
223
 
7 7u83 224
void
225
out_rename(char *oldid, char *newid)
2 7u83 226
{
7 7u83 227
  UNUSED(oldid);
228
  UNUSED(newid);
2 7u83 229
  return;
230
}
231
 
232
 
7 7u83 233
void
234
out_switch_jump(int tab, where a, int min)
2 7u83 235
{
7 7u83 236
    outs(" jmp *");
2 7u83 237
    outs(local_prefix);
238
    outn((long)tab);
239
    outs("-");
240
    outn((long)(4 * min));
7 7u83 241
    outs("(,");
242
    operand(32, a, 1, 0);
243
    outs(",4)");
244
    outnl();
2 7u83 245
    return;
246
}
247
 
7 7u83 248
void
249
out_switch_table(int tab, int min, int max, int *v, int absent)
2 7u83 250
{
251
  int i;
252
 
253
  dot_align(4);
254
  outnl();
255
 
256
  outs(local_prefix);
7 7u83 257
  outn((long)tab);
258
  outs(":");
259
  outnl();
2 7u83 260
 
261
  for (i = min; i <= max; ++i) {
7 7u83 262
    outs(".long ");
263
    if (v[i - min]!= -1) {
2 7u83 264
      outs(local_prefix);
7 7u83 265
      outn((long)v[i - min]);
266
    } else {
267
      if (absent == -1) {
2 7u83 268
	outn((long)0);
7 7u83 269
      } else {
2 7u83 270
        outs(local_prefix);
7 7u83 271
        outn((long)absent);
272
      }
273
    }
274
    outnl();
275
  }
2 7u83 276
}
277
 
7 7u83 278
void
279
proc_size(char *s)
2 7u83 280
{
281
  UNUSED(s);
282
  return;
283
}
284
 
7 7u83 285
void
286
proc_type(char *s)
2 7u83 287
{
288
  UNUSED(s);
289
  return;
290
}
291
 
7 7u83 292
void
293
outend(void)
2 7u83 294
{
7 7u83 295
  int st;
2 7u83 296
 
297
  if (sco_gas) {
298
    outs(".text");
299
    outnl();
300
    dot_align(16);
7 7u83 301
  }
2 7u83 302
 
7 7u83 303
  st = fclose(fpout);
2 7u83 304
  if (st == EOF) {
7 7u83 305
    failer("failed to close file");
306
    exit(EXIT_FAILURE);
307
  }
2 7u83 308
}
309
 
7 7u83 310
void
311
outopenbr(void)
2 7u83 312
{
313
  return;
314
}
315
 
7 7u83 316
void
317
outclosebr(void)
2 7u83 318
{
319
  return;
320
}
321
 
7 7u83 322
void
323
outdivsym(void)
2 7u83 324
{
325
  outs("/");
326
  return;
327
}
328
 
7 7u83 329
void
330
out_initialiser(char *id)
2 7u83 331
{
7 7u83 332
  outs(".section .init,\"x\"\n");
333
  outs(" call ");
334
  outs(id);
335
  outnl();
336
  outnl();
2 7u83 337
  return;
338
}
339
 
340