Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – tendra.SVN – Blame – /branches/tendra5-amd64/src/installers/80x86/openbsd/assembler.c – Rev 6

Subversion Repositories tendra.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
6 7u83 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
 */
31
/*
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
/* openbsd/assembler.c */
62
 
63
#include "config.h"
64
#include "common_types.h"
65
#include "out.h"
66
#include "expmacs.h"
67
#include "operand.h"
68
#include "machine.h"
69
#include "localflags.h"
70
#include "basicread.h"
71
#include "coder.h"
72
 
73
 
74
/* PROCEDURES */
75
 
76
void
77
dot_align(int n)
78
{
79
  if (n == 1) {
80
    return;
81
  }
82
  outs(".align ");
83
  switch (n) {
84
    case 16:
85
      n = 4; break;
86
    case 8:
87
      n = 3; break;
88
    case 4:
89
      n = 2; break;
90
    default:
91
      n = 1; break;
92
  }
93
  outn((long)n);
94
  outnl();
95
  return;
96
}
97
 
98
 
99
void
100
outbyte(void)
101
{
102
  outs(".byte ");
103
  return;
104
}
105
 
106
void
107
outshort(void)
108
{
109
  outs(".value ");
110
  return;
111
}
112
 
113
void
114
outlong(void)
115
{
116
  outs(".long ");
117
  return;
118
}
119
 
120
void
121
align_label(int f, exp jr)
122
{
123
  if (is80486 && !is80586 && ptno(jr) != last_jump_label) {
124
    if (f == 1) {	/* repeat jump */
125
      outs(".align 3,0x90");
126
    }
127
    if (f == 2) {	/* preceded by a jmp or ret */
128
      outs(".align 4,0x90");
129
    }
130
    if (f == 3) {
131
      outs(".align 2,0x90");
132
    }
133
    outs("\n");
134
  }
135
  if (is80586 && ptno(jr)!= last_jump_label) {
136
    if (f >= 1 && f <= 3) {
137
      outs(".align 2,0x90\n");
138
    }
139
  }
140
  return;
141
}
142
 
143
void
144
eval_postlude(char *s, exp c)
145
{
146
  UNUSED(s);
147
  UNUSED(c);
148
  return;
149
}
150
 
151
void
152
out_readonly_section(void)
153
{
154
  outs(".text");
155
  return;
156
}
157
 
158
void
159
out_dot_comm(char *id, shape sha)
160
{
161
  outs(".comm ");
162
  outs(id);
163
  outs(",");
164
  outn((long)(((shape_size(sha) / 8) + 3) / 4) * 4);
165
  outnl();
166
  return;
167
}
168
 
169
void
170
out_dot_lcomm(char *id, shape sha)
171
{
172
  outs(".lcomm ");
173
  outs(id);
174
  outs(",");
175
  outn((long)(((shape_size(sha) / 8) + 3) / 4) * 4);
176
  outnl();
177
  return;
178
}
179
 
180
void
181
out_bss(char *id, shape sha)
182
{
183
  outs(".bss ");
184
  outs(id);
185
  outs(",");
186
  outn((long)(((shape_size(sha) / 8) + 3) / 4) * 4);
187
  outnl();
188
  return;
189
}
190
 
191
void
192
pic_prelude(void)
193
{
194
  return;
195
}
196
 
197
void
198
out_rename(char *oldid, char *newid)
199
{
200
  UNUSED(oldid);
201
  UNUSED(newid);
202
  return;
203
}
204
 
205
void
206
out_switch_jump(int tab, where a, int min)
207
{
208
  outs(" jmp *");
209
  outs(local_prefix);
210
  outn((long)tab);
211
  outs("-");
212
  outn((long)(4 * min));
213
  outs("(,");
214
  operand(32, a, 1, 0);
215
  outs(",4)");
216
  outnl();
217
  return;
218
}
219
 
220
void
221
out_switch_table(int tab, int min, int max, int *v, int absent)
222
{
223
  int i;
224
 
225
  dot_align(4);
226
  outnl();
227
 
228
  outs(local_prefix);
229
  outn((long)tab);
230
  outs(":");
231
  outnl();
232
 
233
  for (i = min; i <= max; ++i) {
234
    outs(".long ");
235
    if (v[i - min]!= -1) {
236
      outs(local_prefix);
237
      outn((long)v[i - min]);
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
  outnl();
249
  return;
250
}
251
 
252
void
253
proc_size(char *s)
254
{
255
  outs(".align 4");
256
  outnl();
257
  outs(".size ");
258
  outs(s);
259
  outs(", .-");
260
  outs(s);
261
  outnl();
262
  return;
263
}
264
 
265
void
266
proc_type(char *s)
267
{
268
  outs(".type ");
269
  outs(s);
270
  outs(",@function");
271
  outnl();
272
  return;
273
}
274
 
275
void
276
outend(void)
277
{
278
  int st;
279
  outs(".text");
280
  outnl();
281
  dot_align(16);
282
  outnl();
283
  outs("___tdf_end:");
284
  outnl();
285
  st = fclose(fpout);
286
  if (st == EOF) {
287
    failer("failed to close file");
288
    exit(EXIT_FAILURE);
289
  }
290
}
291
 
292
void
293
outopenbr(void)
294
{
295
  return;
296
}
297
 
298
void
299
outclosebr(void)
300
{
301
  return;
302
}
303
 
304
void
305
outdivsym(void)
306
{
307
  outs("/");
308
  return;
309
}
310
 
311
void
312
out_initialiser(char *id)
313
{
314
  outs(".stabs \"___TDFI_LIST__\",22,0,0,");
315
  outs(id);
316
  outnl();
317
  outnl();
318
  return;
319
}
320
 
321
 
322
void
323
out_main_prelude(void)
324
{
325
  int nl1 = next_lab();
326
  int nl2 = next_lab();
327
  min_rfree |= 0x8;
328
  outs(" movl $___TDFI_LIST__+4, %ebx\n");
329
  outs(local_prefix);
330
  outn((long)nl1);
331
  outs(":\n");
332
  outs(" movl (%ebx),%eax\n");
333
  outs(" cmpl $0,%eax\n");
334
  simple_branch("je", nl2);
335
  outs(" call *%eax\n");
336
  outs(" addl $4,%ebx\n");
337
  simple_branch("jmp", nl1);
338
  outs(local_prefix);
339
  outn((long)nl2);
340
  outs(":\n");
341
  return;
342
}
343
 
344
void
345
out_main_postlude(void)
346
{
347
  char *sdummy = "Idummy";
348
  char *pdummy = (char *)xcalloc(((int)strlen(local_prefix) +
349
				  (int)strlen(sdummy) + 1), sizeof(char));
350
  strcpy(pdummy, local_prefix);
351
  strcat(pdummy, sdummy);
352
  outs(".text\n");
353
  outs(pdummy);
354
  outs(":\n");
355
  outs(" ret\n");
356
  out_initialiser(pdummy);
357
  return;
358
}