PR26467 UBSAN: cgen.c:762 shift exponent 18446744073709551615
[deliverable/binutils-gdb.git] / gas / config / tc-pdp11.c
CommitLineData
e135f41b 1/* tc-pdp11.c - pdp11-specific -
b3adc24a 2 Copyright (C) 2001-2020 Free Software Foundation, Inc.
e135f41b
NC
3
4 This file is part of GAS, the GNU Assembler.
5
6 GAS is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
ec2655a6 8 the Free Software Foundation; either version 3, or (at your option)
e135f41b
NC
9 any later version.
10
11 GAS is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GAS; see the file COPYING. If not, write to
bb0a86e1
NC
18 the Free Software Foundation, 51 Franklin Street - Fifth Floor,
19 Boston, MA 02110-1301, USA. */
e135f41b 20
e135f41b 21#include "as.h"
3882b010 22#include "safe-ctype.h"
e135f41b
NC
23#include "opcode/pdp11.h"
24
4d5f9b2a 25extern int flonum_gen2vax (int, FLONUM_TYPE * f, LITTLENUM_TYPE *);
cd3cde86 26
4d5f9b2a 27#define TRUE 1
e135f41b
NC
28#define FALSE 0
29
4d5f9b2a 30/* A representation for PDP-11 machine code. */
e135f41b
NC
31struct pdp11_code
32{
6d4af3c2 33 const char *error;
e135f41b 34 int code;
4d5f9b2a
NC
35 int additional; /* Is there an additional word? */
36 int word; /* Additional word, if any. */
e135f41b
NC
37 struct
38 {
39 bfd_reloc_code_real_type type;
40 expressionS exp;
41 int pc_rel;
42 } reloc;
43};
44
4d5f9b2a
NC
45/* Instruction set extensions.
46
47 If you change this from an array to something else, please update
48 the "PDP-11 instruction set extensions" comment in pdp11.h. */
e135f41b
NC
49int pdp11_extension[PDP11_EXT_NUM];
50
4d5f9b2a 51/* Assembly options. */
e135f41b
NC
52
53#define ASM_OPT_PIC 1
54#define ASM_OPT_NUM 2
55
56int asm_option[ASM_OPT_NUM];
57
58/* These chars start a comment anywhere in a source file (except inside
4d5f9b2a 59 another comment. */
5a38dc70 60const char comment_chars[] = "#/";
e135f41b 61
5cd4edbe 62/* These chars only start a comment at the beginning of a line. */
5a38dc70 63const char line_comment_chars[] = "#/";
e135f41b 64
5a38dc70 65const char line_separator_chars[] = ";";
e135f41b 66
4d5f9b2a 67/* Chars that can be used to separate mant from exp in floating point nums. */
5a38dc70 68const char EXP_CHARS[] = "eE";
e135f41b 69
4d5f9b2a
NC
70/* Chars that mean this number is a floating point constant. */
71/* as in 0f123.456. */
72/* or 0H1.234E-12 (see exp chars above). */
5a38dc70 73const char FLT_CHARS[] = "dDfF";
e135f41b
NC
74
75void pseudo_even (int);
76void pseudo_bss (int);
77
5a38dc70 78const pseudo_typeS md_pseudo_table[] =
e135f41b
NC
79{
80 { "bss", pseudo_bss, 0 },
81 { "even", pseudo_even, 0 },
82 { 0, 0, 0 },
83};
84
629310ab 85static htab_t insn_hash = NULL;
4d5f9b2a
NC
86\f
87static int
17b9d67d 88set_option (const char *arg)
4d5f9b2a
NC
89{
90 int yes = 1;
91
92 if (strcmp (arg, "all-extensions") == 0
93 || strcmp (arg, "all") == 0)
94 {
95 memset (pdp11_extension, ~0, sizeof pdp11_extension);
96 pdp11_extension[PDP11_NONE] = 0;
97 return 1;
98 }
99 else if (strcmp (arg, "no-extensions") == 0)
100 {
101 memset (pdp11_extension, 0, sizeof pdp11_extension);
102 pdp11_extension[PDP11_BASIC] = 1;
103 return 1;
104 }
105
106 if (strncmp (arg, "no-", 3) == 0)
107 {
108 yes = 0;
109 arg += 3;
110 }
111
33eaf5de 112 /* Commercial instructions. */
4d5f9b2a
NC
113 if (strcmp (arg, "cis") == 0)
114 pdp11_extension[PDP11_CIS] = yes;
115 /* Call supervisor mode. */
116 else if (strcmp (arg, "csm") == 0)
117 pdp11_extension[PDP11_CSM] = yes;
118 /* Extended instruction set. */
119 else if (strcmp (arg, "eis") == 0)
120 pdp11_extension[PDP11_EIS] = pdp11_extension[PDP11_LEIS] = yes;
121 /* KEV11 floating-point. */
122 else if (strcmp (arg, "fis") == 0
123 || strcmp (arg, "kev11") == 0
124 || strcmp (arg, "kev-11") == 0)
125 pdp11_extension[PDP11_FIS] = yes;
126 /* FP-11 floating-point. */
127 else if (strcmp (arg, "fpp") == 0
128 || strcmp (arg, "fpu") == 0
129 || strcmp (arg, "fp11") == 0
130 || strcmp (arg, "fp-11") == 0
131 || strcmp (arg, "fpj11") == 0
132 || strcmp (arg, "fp-j11") == 0
133 || strcmp (arg, "fpj-11") == 0)
134 pdp11_extension[PDP11_FPP] = yes;
135 /* Limited extended insns. */
136 else if (strcmp (arg, "limited-eis") == 0)
137 {
138 pdp11_extension[PDP11_LEIS] = yes;
139 if (!pdp11_extension[PDP11_LEIS])
140 pdp11_extension[PDP11_EIS] = 0;
141 }
142 /* Move from processor type. */
143 else if (strcmp (arg, "mfpt") == 0)
144 pdp11_extension[PDP11_MFPT] = yes;
145 /* Multiprocessor insns: */
146 else if (strncmp (arg, "mproc", 5) == 0
147 /* TSTSET, WRTLCK */
148 || strncmp (arg, "multiproc", 9) == 0)
149 pdp11_extension[PDP11_MPROC] = yes;
150 /* Move from/to proc status. */
151 else if (strcmp (arg, "mxps") == 0)
152 pdp11_extension[PDP11_MXPS] = yes;
153 /* Position-independent code. */
154 else if (strcmp (arg, "pic") == 0)
155 asm_option[ASM_OPT_PIC] = yes;
156 /* Set priority level. */
157 else if (strcmp (arg, "spl") == 0)
158 pdp11_extension[PDP11_SPL] = yes;
159 /* Microcode instructions: */
160 else if (strcmp (arg, "ucode") == 0
161 /* LDUB, MED, XFC */
162 || strcmp (arg, "microcode") == 0)
163 pdp11_extension[PDP11_UCODE] = yes;
164 else
165 return 0;
166
167 return 1;
168}
169
170
e135f41b 171static void
4d5f9b2a 172init_defaults (void)
e135f41b
NC
173{
174 static int first = 1;
175
176 if (first)
177 {
178 set_option ("all-extensions");
179 set_option ("pic");
180 first = 0;
181 }
182}
183
e135f41b 184void
4d5f9b2a 185md_begin (void)
e135f41b
NC
186{
187 int i;
188
189 init_defaults ();
190
629310ab 191 insn_hash = str_htab_create ();
5cd4edbe 192
e135f41b 193 for (i = 0; i < pdp11_num_opcodes; i++)
fe0e921f 194 str_hash_insert (insn_hash, pdp11_opcodes[i].name, pdp11_opcodes + i, 0);
e135f41b 195 for (i = 0; i < pdp11_num_aliases; i++)
fe0e921f 196 str_hash_insert (insn_hash, pdp11_aliases[i].name, pdp11_aliases + i, 0);
e135f41b
NC
197}
198
199void
4d5f9b2a 200md_number_to_chars (char con[], valueT value, int nbytes)
e135f41b
NC
201{
202 /* On a PDP-11, 0x1234 is stored as "\x12\x34", and
4d5f9b2a 203 0x12345678 is stored as "\x56\x78\x12\x34". It's
33eaf5de 204 anyone's guess what 0x123456 would be stored like. */
e135f41b
NC
205
206 switch (nbytes)
207 {
208 case 0:
209 break;
210 case 1:
211 con[0] = value & 0xff;
212 break;
213 case 2:
4d5f9b2a 214 con[0] = value & 0xff;
e135f41b
NC
215 con[1] = (value >> 8) & 0xff;
216 break;
217 case 4:
218 con[0] = (value >> 16) & 0xff;
219 con[1] = (value >> 24) & 0xff;
4d5f9b2a 220 con[2] = value & 0xff;
e135f41b
NC
221 con[3] = (value >> 8) & 0xff;
222 break;
66e3eb08
SC
223 case 8:
224 con[0] = (value >> 48) & 0xff;
225 con[1] = (value >> 56) & 0xff;
226 con[2] = (value >> 32) & 0xff;
227 con[3] = (value >> 40) & 0xff;
228 con[4] = (value >> 16) & 0xff;
229 con[5] = (value >> 24) & 0xff;
230 con[6] = value & 0xff;
231 con[7] = (value >> 8) & 0xff;
232 break;
e135f41b
NC
233 default:
234 BAD_CASE (nbytes);
5cd4edbe 235 }
e135f41b
NC
236}
237
238/* Fix up some data or instructions after we find out the value of a symbol
94f592af 239 that they reference. Knows about order of bytes in address. */
e135f41b 240
94f592af 241void
55cf6793 242md_apply_fix (fixS *fixP,
4d5f9b2a
NC
243 valueT * valP,
244 segT seg ATTRIBUTE_UNUSED)
e135f41b
NC
245{
246 valueT code;
247 valueT mask;
94f592af 248 valueT val = * valP;
e135f41b
NC
249 char *buf;
250 int shift;
251 int size;
252
253 buf = fixP->fx_where + fixP->fx_frag->fr_literal;
254 size = fixP->fx_size;
3ec2b351 255 code = md_chars_to_number ((unsigned char *) buf, size);
e135f41b
NC
256
257 switch (fixP->fx_r_type)
258 {
7553c869
AM
259 case BFD_RELOC_8:
260 mask = 0xff;
261 shift = 0;
262 break;
e135f41b
NC
263 case BFD_RELOC_16:
264 case BFD_RELOC_16_PCREL:
265 mask = 0xffff;
266 shift = 0;
267 break;
10a95fcc
AM
268 case BFD_RELOC_32:
269 mask = 0xffffffff;
270 shift = 0;
271 break;
e135f41b
NC
272 case BFD_RELOC_PDP11_DISP_8_PCREL:
273 mask = 0x00ff;
274 shift = 1;
275 break;
276 case BFD_RELOC_PDP11_DISP_6_PCREL:
277 mask = 0x003f;
278 shift = 1;
14127cc4 279 val = -val;
e135f41b
NC
280 break;
281 default:
282 BAD_CASE (fixP->fx_r_type);
283 }
284
285 if (fixP->fx_addsy != NULL)
94f592af 286 val += symbol_get_bfdsym (fixP->fx_addsy)->section->vma;
e135f41b
NC
287 /* *value += fixP->fx_addsy->bsym->section->vma; */
288
289 code &= ~mask;
94f592af 290 code |= (val >> shift) & mask;
e135f41b 291 number_to_chars_littleendian (buf, code, size);
94f592af
NC
292
293 if (fixP->fx_addsy == NULL && fixP->fx_pcrel == 0)
294 fixP->fx_done = 1;
e135f41b
NC
295}
296
297long
e046cf80 298md_chars_to_number (unsigned char *con, int nbytes)
e135f41b
NC
299{
300 /* On a PDP-11, 0x1234 is stored as "\x12\x34", and
4d5f9b2a 301 0x12345678 is stored as "\x56\x78\x12\x34". It's
33eaf5de 302 anyone's guess what 0x123456 would be stored like. */
e135f41b
NC
303 switch (nbytes)
304 {
305 case 0:
306 return 0;
307 case 1:
308 return con[0];
309 case 2:
310 return (con[1] << BITS_PER_CHAR) | con[0];
311 case 4:
312 return
4d5f9b2a
NC
313 (((con[1] << BITS_PER_CHAR) | con[0]) << (2 * BITS_PER_CHAR))
314 |((con[3] << BITS_PER_CHAR) | con[2]);
e135f41b
NC
315 default:
316 BAD_CASE (nbytes);
317 return 0;
5cd4edbe 318 }
e135f41b
NC
319}
320\f
321static char *
322skip_whitespace (char *str)
323{
324 while (*str == ' ' || *str == '\t')
325 str++;
326 return str;
327}
328
329static char *
330find_whitespace (char *str)
331{
332 while (*str != ' ' && *str != '\t' && *str != 0)
333 str++;
334 return str;
335}
336
e135f41b
NC
337static char *
338parse_reg (char *str, struct pdp11_code *operand)
339{
340 str = skip_whitespace (str);
3882b010 341 if (TOLOWER (*str) == 'r')
e135f41b
NC
342 {
343 str++;
344 switch (*str)
345 {
346 case '0': case '1': case '2': case '3':
347 case '4': case '5': case '6': case '7':
348 operand->code = *str - '0';
349 str++;
350 break;
351 default:
20203fb9 352 operand->error = _("Bad register name");
e135f41b
NC
353 return str - 1;
354 }
355 }
4d5f9b2a
NC
356 else if (strncmp (str, "sp", 2) == 0
357 || strncmp (str, "SP", 2) == 0)
e135f41b
NC
358 {
359 operand->code = 6;
360 str += 2;
361 }
4d5f9b2a
NC
362 else if (strncmp (str, "pc", 2) == 0
363 || strncmp (str, "PC", 2) == 0)
e135f41b
NC
364 {
365 operand->code = 7;
366 str += 2;
367 }
368 else
1c912705
SC
369 {
370 operand->error = _("Bad register name");
371 return str;
372 }
e135f41b 373
1c912705
SC
374 if (ISALNUM (*str) || *str == '_' || *str == '.')
375 {
376 operand->error = _("Bad register name");
377 str -= 2;
378 }
379
e135f41b
NC
380 return str;
381}
382
383static char *
cd3cde86 384parse_ac5 (char *str, struct pdp11_code *operand)
e135f41b
NC
385{
386 str = skip_whitespace (str);
4d5f9b2a
NC
387 if (strncmp (str, "fr", 2) == 0
388 || strncmp (str, "FR", 2) == 0
389 || strncmp (str, "ac", 2) == 0
390 || strncmp (str, "AC", 2) == 0)
e135f41b
NC
391 {
392 str += 2;
393 switch (*str)
394 {
395 case '0': case '1': case '2': case '3':
cd3cde86 396 case '4': case '5':
e135f41b
NC
397 operand->code = *str - '0';
398 str++;
399 break;
400 default:
20203fb9 401 operand->error = _("Bad register name");
e135f41b
NC
402 return str - 2;
403 }
404 }
405 else
406 {
20203fb9 407 operand->error = _("Bad register name");
e135f41b
NC
408 return str;
409 }
410
411 return str;
412}
413
cd3cde86
AM
414static char *
415parse_ac (char *str, struct pdp11_code *operand)
416{
417 str = parse_ac5 (str, operand);
418 if (!operand->error && operand->code > 3)
419 {
20203fb9 420 operand->error = _("Bad register name");
cd3cde86
AM
421 return str - 3;
422 }
423
424 return str;
425}
426
e135f41b
NC
427static char *
428parse_expression (char *str, struct pdp11_code *operand)
429{
430 char *save_input_line_pointer;
431 segT seg;
432
433 save_input_line_pointer = input_line_pointer;
434 input_line_pointer = str;
435 seg = expression (&operand->reloc.exp);
436 if (seg == NULL)
437 {
438 input_line_pointer = save_input_line_pointer;
20203fb9 439 operand->error = _("Error in expression");
e135f41b
NC
440 return str;
441 }
442
443 str = input_line_pointer;
444 input_line_pointer = save_input_line_pointer;
445
446 operand->reloc.pc_rel = 0;
447
e135f41b
NC
448 return str;
449}
450
451static char *
452parse_op_no_deferred (char *str, struct pdp11_code *operand)
453{
cd3cde86
AM
454 LITTLENUM_TYPE literal_float[2];
455
e135f41b
NC
456 str = skip_whitespace (str);
457
458 switch (*str)
459 {
460 case '(': /* (rn) and (rn)+ */
461 str = parse_reg (str + 1, operand);
462 if (operand->error)
463 return str;
464 str = skip_whitespace (str);
465 if (*str != ')')
466 {
20203fb9 467 operand->error = _("Missing ')'");
e135f41b
NC
468 return str;
469 }
470 str++;
471 if (*str == '+')
472 {
473 operand->code |= 020;
474 str++;
475 }
476 else
477 {
478 operand->code |= 010;
479 }
480 break;
481
4d5f9b2a
NC
482 /* Immediate. */
483 case '#':
5cd4edbe 484 case '$':
e135f41b
NC
485 str = parse_expression (str + 1, operand);
486 if (operand->error)
487 return str;
488 operand->additional = TRUE;
489 operand->word = operand->reloc.exp.X_add_number;
490 switch (operand->reloc.exp.X_op)
491 {
492 case O_constant:
493 break;
494 case O_symbol:
495 case O_add:
496 case O_subtract:
497 operand->reloc.type = BFD_RELOC_16;
498 operand->reloc.pc_rel = 0;
499 break;
cd3cde86
AM
500 case O_big:
501 if (operand->reloc.exp.X_add_number > 0)
502 {
20203fb9 503 operand->error = _("Error in expression");
cd3cde86
AM
504 break;
505 }
4d5f9b2a 506 /* It's a floating literal... */
cd3cde86
AM
507 know (operand->reloc.exp.X_add_number < 0);
508 flonum_gen2vax ('f', &generic_floating_point_number, literal_float);
509 operand->word = literal_float[0];
510 if (literal_float[1] != 0)
511 as_warn (_("Low order bits truncated in immediate float operand"));
512 break;
e135f41b 513 default:
20203fb9 514 operand->error = _("Error in expression");
e135f41b
NC
515 break;
516 }
517 operand->code = 027;
518 break;
519
4d5f9b2a
NC
520 /* label, d(rn), -(rn) */
521 default:
e135f41b 522 {
e135f41b
NC
523 if (strncmp (str, "-(", 2) == 0) /* -(rn) */
524 {
525 str = parse_reg (str + 2, operand);
526 if (operand->error)
527 return str;
528 str = skip_whitespace (str);
529 if (*str != ')')
530 {
20203fb9 531 operand->error = _("Missing ')'");
e135f41b
NC
532 return str;
533 }
534 operand->code |= 040;
535 str++;
536 break;
537 }
538
539 str = parse_expression (str, operand);
540 if (operand->error)
541 return str;
542
543 str = skip_whitespace (str);
544
4d5f9b2a 545 if (*str != '(')
e135f41b 546 {
e135f41b
NC
547 operand->code = 067;
548 operand->additional = 1;
549 operand->word = 0;
550 operand->reloc.type = BFD_RELOC_16_PCREL;
551 operand->reloc.pc_rel = 1;
552 break;
553 }
554
4d5f9b2a
NC
555 /* d(rn) */
556 str++;
e135f41b
NC
557 str = parse_reg (str, operand);
558 if (operand->error)
559 return str;
560
561 str = skip_whitespace (str);
562
563 if (*str != ')')
564 {
20203fb9 565 operand->error = _("Missing ')'");
e135f41b
NC
566 return str;
567 }
568
569 str++;
570 operand->additional = TRUE;
571 operand->code |= 060;
572 switch (operand->reloc.exp.X_op)
573 {
574 case O_symbol:
bb0a86e1
NC
575 operand->reloc.type = BFD_RELOC_16;
576 operand->reloc.pc_rel = 0;
e135f41b
NC
577 break;
578 case O_constant:
579 if ((operand->code & 7) == 7)
580 {
581 operand->reloc.pc_rel = 1;
582 operand->word = operand->reloc.exp.X_add_number;
583 }
584 else
4d5f9b2a
NC
585 operand->word = operand->reloc.exp.X_add_number;
586
e135f41b
NC
587 break;
588 default:
589 BAD_CASE (operand->reloc.exp.X_op);
590 }
591 break;
592 }
593 }
594
595 return str;
596}
597
598static char *
cd3cde86 599parse_op_noreg (char *str, struct pdp11_code *operand)
e135f41b
NC
600{
601 str = skip_whitespace (str);
e135f41b
NC
602 operand->error = NULL;
603
604 if (*str == '@' || *str == '*')
605 {
3cf2b669
JPC
606 /* @(Rn) == @0(Rn): Mode 7, Indexed deferred.
607 Check for auto-increment deferred. */
608 if (str[1] == '('
609 && str[2] != 0
610 && str[3] != 0
611 && str[4] != 0
612 && str[5] != '+')
613 {
614 /* Change implied to explicit index deferred. */
615 *str = '0';
616 str = parse_op_no_deferred (str, operand);
617 }
618 else
8f9ea98b
JPC
619 {
620 /* @Rn == (Rn): Register deferred. */
621 str = parse_reg (str + 1, operand);
622
623 /* Not @Rn */
624 if (operand->error)
625 {
626 operand->error = NULL;
627 str = parse_op_no_deferred (str, operand);
628 }
629 }
3cf2b669 630
e135f41b
NC
631 if (operand->error)
632 return str;
8f9ea98b 633
e135f41b
NC
634 operand->code |= 010;
635 }
636 else
637 str = parse_op_no_deferred (str, operand);
638
639 return str;
640}
641
cd3cde86
AM
642static char *
643parse_op (char *str, struct pdp11_code *operand)
644{
645 str = skip_whitespace (str);
646
647 str = parse_reg (str, operand);
648 if (!operand->error)
649 return str;
650
651 operand->error = NULL;
652 parse_ac5 (str, operand);
653 if (!operand->error)
654 {
20203fb9 655 operand->error = _("Float AC not legal as integer operand");
cd3cde86
AM
656 return str;
657 }
5d6255fe 658
cd3cde86
AM
659 return parse_op_noreg (str, operand);
660}
661
662static char *
663parse_fop (char *str, struct pdp11_code *operand)
664{
665 str = skip_whitespace (str);
666
667 str = parse_ac5 (str, operand);
668 if (!operand->error)
669 return str;
670
671 operand->error = NULL;
672 parse_reg (str, operand);
673 if (!operand->error)
674 {
20203fb9 675 operand->error = _("General register not legal as float operand");
cd3cde86
AM
676 return str;
677 }
678
679 return parse_op_noreg (str, operand);
680}
681
e135f41b
NC
682static char *
683parse_separator (char *str, int *error)
684{
685 str = skip_whitespace (str);
686 *error = (*str != ',');
687 if (!*error)
688 str++;
689 return str;
690}
691
692void
4d5f9b2a 693md_assemble (char *instruction_string)
e135f41b 694{
5a38dc70 695 const struct pdp11_opcode *op;
e135f41b
NC
696 struct pdp11_code insn, op1, op2;
697 int error;
698 int size;
6d4af3c2 699 const char *err = NULL;
e135f41b
NC
700 char *str;
701 char *p;
702 char c;
703
704 str = skip_whitespace (instruction_string);
705 p = find_whitespace (str);
706 if (p - str == 0)
707 {
20203fb9 708 as_bad (_("No instruction found"));
e135f41b
NC
709 return;
710 }
711
712 c = *p;
713 *p = '\0';
629310ab 714 op = (struct pdp11_opcode *)str_hash_find (insn_hash, str);
e135f41b
NC
715 *p = c;
716 if (op == 0)
717 {
cd3cde86 718 as_bad (_("Unknown instruction '%s'"), str);
e135f41b
NC
719 return;
720 }
721
722 if (!pdp11_extension[op->extension])
723 {
20203fb9 724 as_warn (_("Unsupported instruction set extension: %s"), op->name);
e135f41b
NC
725 return;
726 }
727
728 insn.error = NULL;
729 insn.code = op->opcode;
730 insn.reloc.type = BFD_RELOC_NONE;
731 op1.error = NULL;
732 op1.additional = FALSE;
733 op1.reloc.type = BFD_RELOC_NONE;
734 op2.error = NULL;
735 op2.additional = FALSE;
736 op2.reloc.type = BFD_RELOC_NONE;
737
738 str = p;
739 size = 2;
740
741 switch (op->type)
742 {
743 case PDP11_OPCODE_NO_OPS:
744 str = skip_whitespace (str);
e135f41b
NC
745 break;
746
747 case PDP11_OPCODE_IMM3:
748 case PDP11_OPCODE_IMM6:
749 case PDP11_OPCODE_IMM8:
750 str = skip_whitespace (str);
751 if (*str == '#' || *str == '$')
752 str++;
753 str = parse_expression (str, &op1);
754 if (op1.error)
755 break;
cd3cde86
AM
756 if (op1.reloc.exp.X_op != O_constant || op1.reloc.type != BFD_RELOC_NONE)
757 {
20203fb9 758 op1.error = _("operand is not an absolute constant");
cd3cde86
AM
759 break;
760 }
e135f41b
NC
761 switch (op->type)
762 {
763 case PDP11_OPCODE_IMM3:
cd3cde86 764 if (op1.reloc.exp.X_add_number & ~7)
e135f41b 765 {
20203fb9 766 op1.error = _("3-bit immediate out of range");
e135f41b
NC
767 break;
768 }
769 break;
770 case PDP11_OPCODE_IMM6:
cd3cde86 771 if (op1.reloc.exp.X_add_number & ~0x3f)
e135f41b 772 {
20203fb9 773 op1.error = _("6-bit immediate out of range");
e135f41b
NC
774 break;
775 }
776 break;
777 case PDP11_OPCODE_IMM8:
cd3cde86 778 if (op1.reloc.exp.X_add_number & ~0xff)
e135f41b 779 {
20203fb9 780 op1.error = _("8-bit immediate out of range");
e135f41b
NC
781 break;
782 }
783 break;
784 }
cd3cde86 785 insn.code |= op1.reloc.exp.X_add_number;
e135f41b
NC
786 break;
787
788 case PDP11_OPCODE_DISPL:
789 {
d3ce72d0
NC
790 char *new_pointer;
791 new_pointer = parse_expression (str, &op1);
e135f41b
NC
792 op1.code = 0;
793 op1.reloc.pc_rel = 1;
794 op1.reloc.type = BFD_RELOC_PDP11_DISP_8_PCREL;
795 if (op1.reloc.exp.X_op != O_symbol)
796 {
20203fb9 797 op1.error = _("Symbol expected");
e135f41b
NC
798 break;
799 }
800 if (op1.code & ~0xff)
801 {
20203fb9 802 err = _("8-bit displacement out of range");
e135f41b
NC
803 break;
804 }
d3ce72d0 805 str = new_pointer;
e135f41b
NC
806 insn.code |= op1.code;
807 insn.reloc = op1.reloc;
808 }
809 break;
810
811 case PDP11_OPCODE_REG:
812 str = parse_reg (str, &op1);
813 if (op1.error)
814 break;
815 insn.code |= op1.code;
816 break;
817
818 case PDP11_OPCODE_OP:
819 str = parse_op (str, &op1);
820 if (op1.error)
821 break;
822 insn.code |= op1.code;
823 if (op1.additional)
824 size += 2;
825 break;
826
cd3cde86
AM
827 case PDP11_OPCODE_FOP:
828 str = parse_fop (str, &op1);
829 if (op1.error)
830 break;
831 insn.code |= op1.code;
832 if (op1.additional)
833 size += 2;
834 break;
835
e135f41b
NC
836 case PDP11_OPCODE_REG_OP:
837 str = parse_reg (str, &op2);
838 if (op2.error)
839 break;
840 insn.code |= op2.code << 6;
841 str = parse_separator (str, &error);
842 if (error)
843 {
20203fb9 844 op2.error = _("Missing ','");
e135f41b
NC
845 break;
846 }
847 str = parse_op (str, &op1);
848 if (op1.error)
849 break;
850 insn.code |= op1.code;
851 if (op1.additional)
852 size += 2;
853 break;
854
855 case PDP11_OPCODE_REG_OP_REV:
856 str = parse_op (str, &op1);
857 if (op1.error)
858 break;
859 insn.code |= op1.code;
860 if (op1.additional)
861 size += 2;
862 str = parse_separator (str, &error);
863 if (error)
864 {
20203fb9 865 op2.error = _("Missing ','");
e135f41b
NC
866 break;
867 }
868 str = parse_reg (str, &op2);
869 if (op2.error)
870 break;
871 insn.code |= op2.code << 6;
872 break;
873
cd3cde86
AM
874 case PDP11_OPCODE_AC_FOP:
875 str = parse_ac (str, &op2);
876 if (op2.error)
877 break;
878 insn.code |= op2.code << 6;
879 str = parse_separator (str, &error);
880 if (error)
881 {
20203fb9 882 op1.error = _("Missing ','");
cd3cde86
AM
883 break;
884 }
885 str = parse_fop (str, &op1);
886 if (op1.error)
887 break;
888 insn.code |= op1.code;
889 if (op1.additional)
890 size += 2;
891 break;
892
893 case PDP11_OPCODE_FOP_AC:
894 str = parse_fop (str, &op1);
895 if (op1.error)
896 break;
897 insn.code |= op1.code;
898 if (op1.additional)
899 size += 2;
900 str = parse_separator (str, &error);
901 if (error)
902 {
20203fb9 903 op1.error = _("Missing ','");
cd3cde86
AM
904 break;
905 }
906 str = parse_ac (str, &op2);
907 if (op2.error)
908 break;
909 insn.code |= op2.code << 6;
910 break;
911
e135f41b
NC
912 case PDP11_OPCODE_AC_OP:
913 str = parse_ac (str, &op2);
914 if (op2.error)
915 break;
916 insn.code |= op2.code << 6;
917 str = parse_separator (str, &error);
918 if (error)
919 {
20203fb9 920 op1.error = _("Missing ','");
e135f41b
NC
921 break;
922 }
923 str = parse_op (str, &op1);
924 if (op1.error)
925 break;
926 insn.code |= op1.code;
927 if (op1.additional)
928 size += 2;
929 break;
930
cd3cde86
AM
931 case PDP11_OPCODE_OP_AC:
932 str = parse_op (str, &op1);
933 if (op1.error)
934 break;
935 insn.code |= op1.code;
936 if (op1.additional)
937 size += 2;
938 str = parse_separator (str, &error);
939 if (error)
940 {
20203fb9 941 op1.error = _("Missing ','");
cd3cde86
AM
942 break;
943 }
944 str = parse_ac (str, &op2);
945 if (op2.error)
946 break;
947 insn.code |= op2.code << 6;
948 break;
949
e135f41b
NC
950 case PDP11_OPCODE_OP_OP:
951 str = parse_op (str, &op1);
952 if (op1.error)
953 break;
954 insn.code |= op1.code << 6;
955 if (op1.additional)
956 size += 2;
957 str = parse_separator (str, &error);
958 if (error)
959 {
20203fb9 960 op2.error = _("Missing ','");
e135f41b
NC
961 break;
962 }
963 str = parse_op (str, &op2);
964 if (op2.error)
965 break;
966 insn.code |= op2.code;
967 if (op2.additional)
968 size += 2;
969 break;
970
971 case PDP11_OPCODE_REG_DISPL:
972 {
d3ce72d0 973 char *new_pointer;
e135f41b
NC
974 str = parse_reg (str, &op2);
975 if (op2.error)
976 break;
977 insn.code |= op2.code << 6;
978 str = parse_separator (str, &error);
979 if (error)
980 {
20203fb9 981 op1.error = _("Missing ','");
e135f41b
NC
982 break;
983 }
d3ce72d0 984 new_pointer = parse_expression (str, &op1);
e135f41b
NC
985 op1.code = 0;
986 op1.reloc.pc_rel = 1;
987 op1.reloc.type = BFD_RELOC_PDP11_DISP_6_PCREL;
988 if (op1.reloc.exp.X_op != O_symbol)
989 {
20203fb9 990 op1.error = _("Symbol expected");
e135f41b
NC
991 break;
992 }
993 if (op1.code & ~0x3f)
994 {
20203fb9 995 err = _("6-bit displacement out of range");
e135f41b
NC
996 break;
997 }
d3ce72d0 998 str = new_pointer;
e135f41b
NC
999 insn.code |= op1.code;
1000 insn.reloc = op1.reloc;
1001 }
1002 break;
5cd4edbe 1003
e135f41b
NC
1004 default:
1005 BAD_CASE (op->type);
1006 }
1007
1008 if (op1.error)
1009 err = op1.error;
1010 else if (op2.error)
1011 err = op2.error;
1012 else
1013 {
1014 str = skip_whitespace (str);
1015 if (*str)
20203fb9 1016 err = _("Too many operands");
e135f41b
NC
1017 }
1018
1019 {
1020 char *to = NULL;
5cd4edbe 1021
e135f41b
NC
1022 if (err)
1023 {
20203fb9 1024 as_bad ("%s", err);
e135f41b
NC
1025 return;
1026 }
1027
1028 to = frag_more (size);
1029
1030 md_number_to_chars (to, insn.code, 2);
1031 if (insn.reloc.type != BFD_RELOC_NONE)
1032 fix_new_exp (frag_now, to - frag_now->fr_literal, 2,
1033 &insn.reloc.exp, insn.reloc.pc_rel, insn.reloc.type);
1034 to += 2;
1035
1036 if (op1.additional)
1037 {
1038 md_number_to_chars (to, op1.word, 2);
1039 if (op1.reloc.type != BFD_RELOC_NONE)
1040 fix_new_exp (frag_now, to - frag_now->fr_literal, 2,
1041 &op1.reloc.exp, op1.reloc.pc_rel, op1.reloc.type);
1042 to += 2;
1043 }
1044
1045 if (op2.additional)
1046 {
1047 md_number_to_chars (to, op2.word, 2);
1048 if (op2.reloc.type != BFD_RELOC_NONE)
1049 fix_new_exp (frag_now, to - frag_now->fr_literal, 2,
1050 &op2.reloc.exp, op2.reloc.pc_rel, op2.reloc.type);
1051 }
1052 }
1053}
1054
1055int
4d5f9b2a
NC
1056md_estimate_size_before_relax (fragS *fragP ATTRIBUTE_UNUSED,
1057 segT segment ATTRIBUTE_UNUSED)
e135f41b
NC
1058{
1059 return 0;
1060}
1061
1062void
4d5f9b2a
NC
1063md_convert_frag (bfd *headers ATTRIBUTE_UNUSED,
1064 segT seg ATTRIBUTE_UNUSED,
1065 fragS *fragP ATTRIBUTE_UNUSED)
e135f41b
NC
1066{
1067}
1068
2b4f075a
HPN
1069int md_short_jump_size = 2;
1070int md_long_jump_size = 4;
e135f41b
NC
1071
1072void
4d5f9b2a
NC
1073md_create_short_jump (char *ptr ATTRIBUTE_UNUSED,
1074 addressT from_addr ATTRIBUTE_UNUSED,
1075 addressT to_addr ATTRIBUTE_UNUSED,
1076 fragS *frag ATTRIBUTE_UNUSED,
1077 symbolS *to_symbol ATTRIBUTE_UNUSED)
e135f41b
NC
1078{
1079}
1080
1081void
4d5f9b2a
NC
1082md_create_long_jump (char *ptr ATTRIBUTE_UNUSED,
1083 addressT from_addr ATTRIBUTE_UNUSED,
1084 addressT to_addr ATTRIBUTE_UNUSED,
1085 fragS *frag ATTRIBUTE_UNUSED,
1086 symbolS *to_symbol ATTRIBUTE_UNUSED)
e135f41b
NC
1087{
1088}
1089
1090static int
17b9d67d 1091set_cpu_model (const char *arg)
e135f41b
NC
1092{
1093 char buf[4];
1094 char *model = buf;
1095
1096 if (arg[0] == 'k')
1097 arg++;
1098
1099 *model++ = *arg++;
1100
1101 if (strchr ("abdx", model[-1]) == NULL)
1102 return 0;
1103
1104 if (model[-1] == 'd')
1105 {
4d5f9b2a 1106 if (arg[0] == 'f' || arg[0] == 'j')
e135f41b
NC
1107 model[-1] = *arg++;
1108 }
1109 else if (model[-1] == 'x')
1110 {
1111 if (arg[0] == 't')
1112 model[-1] = *arg++;
1113 }
1114
1115 if (arg[0] == '-')
1116 arg++;
1117
1118 if (strncmp (arg, "11", 2) != 0)
1119 return 0;
1120 arg += 2;
1121
1122 if (arg[0] == '-')
1123 {
1124 if (*++arg == 0)
1125 return 0;
1126 }
1127
4d5f9b2a 1128 /* Allow up to two revision letters. */
e135f41b
NC
1129 if (arg[0] != 0)
1130 *model++ = *arg++;
1131 if (arg[0] != 0)
1132 *model++ = *arg++;
1133
1134 *model++ = 0;
1135
1136 set_option ("no-extensions");
1137
4d5f9b2a
NC
1138 /* KA11 (11/15/20). */
1139 if (strncmp (buf, "a", 1) == 0)
1140 return 1; /* No extensions. */
e135f41b 1141
4d5f9b2a
NC
1142 /* KB11 (11/45/50/55/70). */
1143 else if (strncmp (buf, "b", 1) == 0)
1144 return set_option ("eis") && set_option ("spl");
e135f41b 1145
4d5f9b2a
NC
1146 /* KD11-A (11/35/40). */
1147 else if (strncmp (buf, "da", 2) == 0)
e135f41b
NC
1148 return set_option ("limited-eis");
1149
4d5f9b2a
NC
1150 /* KD11-B (11/05/10). */
1151 else if (strncmp (buf, "db", 2) == 0
1152 /* KD11-D (11/04). */
1153 || strncmp (buf, "dd", 2) == 0)
e135f41b
NC
1154 return 1; /* no extensions */
1155
4d5f9b2a
NC
1156 /* KD11-E (11/34). */
1157 else if (strncmp (buf, "de", 2) == 0)
1158 return set_option ("eis") && set_option ("mxps");
1159
1160 /* KD11-F (11/03). */
1161 else if (strncmp (buf, "df", 2) == 0
1162 /* KD11-H (11/03). */
1163 || strncmp (buf, "dh", 2) == 0
1164 /* KD11-Q (11/03). */
1165 || strncmp (buf, "dq", 2) == 0)
1166 return set_option ("limited-eis") && set_option ("mxps");
1167
1168 /* KD11-K (11/60). */
1169 else if (strncmp (buf, "dk", 2) == 0)
1170 return set_option ("eis")
1171 && set_option ("mxps")
1172 && set_option ("ucode");
1173
1174 /* KD11-Z (11/44). */
1175 else if (strncmp (buf, "dz", 2) == 0)
1176 return set_option ("csm")
1177 && set_option ("eis")
1178 && set_option ("mfpt")
1179 && set_option ("mxps")
1180 && set_option ("spl");
1181
1182 /* F11 (11/23/24). */
1183 else if (strncmp (buf, "f", 1) == 0)
1184 return set_option ("eis")
1185 && set_option ("mfpt")
1186 && set_option ("mxps");
1187
1188 /* J11 (11/53/73/83/84/93/94). */
1189 else if (strncmp (buf, "j", 1) == 0)
1190 return set_option ("csm")
1191 && set_option ("eis")
1192 && set_option ("mfpt")
1193 && set_option ("multiproc")
1194 && set_option ("mxps")
1195 && set_option ("spl");
1196
1197 /* T11 (11/21). */
1198 else if (strncmp (buf, "t", 1) == 0)
1199 return set_option ("limited-eis")
1200 && set_option ("mxps");
e135f41b
NC
1201
1202 else
1203 return 0;
1204}
1205
1206static int
17b9d67d 1207set_machine_model (const char *arg)
e135f41b 1208{
4d5f9b2a
NC
1209 if (strncmp (arg, "pdp-11/", 7) != 0
1210 && strncmp (arg, "pdp11/", 6) != 0
1211 && strncmp (arg, "11/", 3) != 0)
e135f41b
NC
1212 return 0;
1213
1214 if (strncmp (arg, "pdp", 3) == 0)
1215 arg += 3;
1216 if (arg[0] == '-')
1217 arg++;
1218 if (strncmp (arg, "11/", 3) == 0)
1219 arg += 3;
1220
4d5f9b2a
NC
1221 if (strcmp (arg, "03") == 0)
1222 return set_cpu_model ("kd11f");
1223
1224 else if (strcmp (arg, "04") == 0)
1225 return set_cpu_model ("kd11d");
e135f41b 1226
4d5f9b2a
NC
1227 else if (strcmp (arg, "05") == 0
1228 || strcmp (arg, "10") == 0)
1229 return set_cpu_model ("kd11b");
e135f41b 1230
4d5f9b2a
NC
1231 else if (strcmp (arg, "15") == 0
1232 || strcmp (arg, "20") == 0)
1233 return set_cpu_model ("ka11");
e135f41b 1234
4d5f9b2a
NC
1235 else if (strcmp (arg, "21") == 0)
1236 return set_cpu_model ("t11");
e135f41b 1237
4d5f9b2a
NC
1238 else if (strcmp (arg, "23") == 0
1239 || strcmp (arg, "24") == 0)
1240 return set_cpu_model ("f11");
e135f41b 1241
4d5f9b2a
NC
1242 else if (strcmp (arg, "34") == 0
1243 || strcmp (arg, "34a") == 0)
1244 return set_cpu_model ("kd11e");
e135f41b 1245
4d5f9b2a
NC
1246 else if (strcmp (arg, "35") == 0
1247 || strcmp (arg, "40") == 0)
1248 return set_cpu_model ("kd11da");
e135f41b 1249
4d5f9b2a
NC
1250 else if (strcmp (arg, "44") == 0)
1251 return set_cpu_model ("kd11dz");
e135f41b 1252
4d5f9b2a
NC
1253 else if (strcmp (arg, "45") == 0
1254 || strcmp (arg, "50") == 0
1255 || strcmp (arg, "55") == 0
1256 || strcmp (arg, "70") == 0)
1257 return set_cpu_model ("kb11");
e135f41b 1258
4d5f9b2a
NC
1259 else if (strcmp (arg, "60") == 0)
1260 return set_cpu_model ("kd11k");
e135f41b 1261
4d5f9b2a
NC
1262 else if (strcmp (arg, "53") == 0
1263 || strcmp (arg, "73") == 0
1264 || strcmp (arg, "83") == 0
1265 || strcmp (arg, "84") == 0
1266 || strcmp (arg, "93") == 0
1267 || strcmp (arg, "94") == 0)
1268 return set_cpu_model ("j11")
1269 && set_option ("fpp");
e135f41b 1270
e135f41b
NC
1271 else
1272 return 0;
1273}
1274
5a38dc70 1275const char *md_shortopts = "m:";
e135f41b
NC
1276
1277struct option md_longopts[] =
1278{
1279#define OPTION_CPU 257
1280 { "cpu", required_argument, NULL, OPTION_CPU },
1281#define OPTION_MACHINE 258
1282 { "machine", required_argument, NULL, OPTION_MACHINE },
1283#define OPTION_PIC 259
1284 { "pic", no_argument, NULL, OPTION_PIC },
1285 { NULL, no_argument, NULL, 0 }
1286};
1287
07726851 1288size_t md_longopts_size = sizeof (md_longopts);
e135f41b 1289
4d5f9b2a
NC
1290/* Invocation line includes a switch not recognized by the base assembler.
1291 See if it's a processor-specific option. */
e135f41b
NC
1292
1293int
17b9d67d 1294md_parse_option (int c, const char *arg)
e135f41b
NC
1295{
1296 init_defaults ();
1297
1298 switch (c)
1299 {
1300 case 'm':
1301 if (set_option (arg))
1302 return 1;
1303 if (set_cpu_model (arg))
1304 return 1;
1305 if (set_machine_model (arg))
1306 return 1;
1307 break;
1308
1309 case OPTION_CPU:
1310 if (set_cpu_model (arg))
1311 return 1;
1312 break;
1313
1314 case OPTION_MACHINE:
1315 if (set_machine_model (arg))
1316 return 1;
1317 break;
1318
1319 case OPTION_PIC:
1320 if (set_option ("pic"))
1321 return 1;
1322 break;
1323
1324 default:
1325 break;
1326 }
1327
e135f41b
NC
1328 return 0;
1329}
1330
e135f41b 1331void
4d5f9b2a 1332md_show_usage (FILE *stream)
e135f41b
NC
1333{
1334 fprintf (stream, "\
1335\n\
2b0f3761 1336PDP-11 instruction set extensions:\n\
e135f41b 1337\n\
33eaf5de 1338-m(no-)cis allow (disallow) commercial instruction set\n\
e135f41b
NC
1339-m(no-)csm allow (disallow) CSM instruction\n\
1340-m(no-)eis allow (disallow) full extended instruction set\n\
1341-m(no-)fis allow (disallow) KEV11 floating-point instructions\n\
1342-m(no-)fpp allow (disallow) FP-11 floating-point instructions\n\
1343-m(no-)fpu allow (disallow) FP-11 floating-point instructions\n\
1344-m(no-)limited-eis allow (disallow) limited extended instruction set\n\
1345-m(no-)mfpt allow (disallow) processor type instruction\n\
1346-m(no-)multiproc allow (disallow) multiprocessor instructions\n\
1347-m(no-)mxps allow (disallow) processor status instructions\n\
1348-m(no-)spl allow (disallow) SPL instruction\n\
1349-m(no-)ucode allow (disallow) microcode instructions\n\
1350-mall-extensions allow all instruction set extensions\n\
1351 (this is the default)\n\
33eaf5de
NC
1352-mno-extensions disallow all instruction set extensions\n\
1353-pic generate position-independent code\n\
e135f41b
NC
1354\n\
1355PDP-11 CPU model options:\n\
1356\n\
1357-mka11* KA11 CPU. base line instruction set only\n\
1358-mkb11* KB11 CPU. enable full EIS and SPL\n\
1359-mkd11a* KD11-A CPU. enable limited EIS\n\
1360-mkd11b* KD11-B CPU. base line instruction set only\n\
1361-mkd11d* KD11-D CPU. base line instruction set only\n\
1362-mkd11e* KD11-E CPU. enable full EIS, MTPS, and MFPS\n\
1363-mkd11f* KD11-F CPU. enable limited EIS, MTPS, and MFPS\n\
1364-mkd11h* KD11-H CPU. enable limited EIS, MTPS, and MFPS\n\
1365-mkd11q* KD11-Q CPU. enable limited EIS, MTPS, and MFPS\n\
1366-mkd11k* KD11-K CPU. enable full EIS, MTPS, MFPS, LDUB, MED,\n\
1367 XFC, and MFPT\n\
1368-mkd11z* KD11-Z CPU. enable full EIS, MTPS, MFPS, MFPT, SPL,\n\
1369 and CSM\n\
1370-mf11* F11 CPU. enable full EIS, MFPS, MTPS, and MFPT\n\
1371-mj11* J11 CPU. enable full EIS, MTPS, MFPS, MFPT, SPL,\n\
1372 CSM, TSTSET, and WRTLCK\n\
1373-mt11* T11 CPU. enable limited EIS, MTPS, and MFPS\n\
1374\n\
1375PDP-11 machine model options:\n\
1376\n\
1377-m11/03 same as -mkd11f\n\
1378-m11/04 same as -mkd11d\n\
1379-m11/05 same as -mkd11b\n\
1380-m11/10 same as -mkd11b\n\
1381-m11/15 same as -mka11\n\
1382-m11/20 same as -mka11\n\
1383-m11/21 same as -mt11\n\
1384-m11/23 same as -mf11\n\
1385-m11/24 same as -mf11\n\
1386-m11/34 same as -mkd11e\n\
1387-m11/34a same as -mkd11e -mfpp\n\
1388-m11/35 same as -mkd11a\n\
1389-m11/40 same as -mkd11a\n\
1390-m11/44 same as -mkd11z\n\
1391-m11/45 same as -mkb11\n\
1392-m11/50 same as -mkb11\n\
1393-m11/53 same as -mj11\n\
1394-m11/55 same as -mkb11\n\
1395-m11/60 same as -mkd11k\n\
1396-m11/70 same as -mkb11\n\
1397-m11/73 same as -mj11\n\
1398-m11/83 same as -mj11\n\
1399-m11/84 same as -mj11\n\
1400-m11/93 same as -mj11\n\
1401-m11/94 same as -mj11\n\
1402");
1403}
1404
1405symbolS *
4d5f9b2a 1406md_undefined_symbol (char *name ATTRIBUTE_UNUSED)
e135f41b
NC
1407{
1408 return 0;
1409}
1410
1411valueT
4d5f9b2a
NC
1412md_section_align (segT segment ATTRIBUTE_UNUSED,
1413 valueT size)
e135f41b
NC
1414{
1415 return (size + 1) & ~1;
1416}
1417
1418long
4d5f9b2a 1419md_pcrel_from (fixS *fixP)
e135f41b
NC
1420{
1421 return fixP->fx_frag->fr_address + fixP->fx_where + fixP->fx_size;
1422}
1423
1424/* Translate internal representation of relocation info to BFD target
1425 format. */
4d5f9b2a 1426
e135f41b 1427arelent *
4d5f9b2a
NC
1428tc_gen_reloc (asection *section ATTRIBUTE_UNUSED,
1429 fixS *fixp)
e135f41b
NC
1430{
1431 arelent *reloc;
1432 bfd_reloc_code_real_type code;
1433
325801bd 1434 reloc = XNEW (arelent);
e135f41b 1435
325801bd 1436 reloc->sym_ptr_ptr = XNEW (asymbol *);
e135f41b
NC
1437 *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
1438 reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
1439
55cf6793 1440 /* This is taken account for in md_apply_fix(). */
e135f41b
NC
1441 reloc->addend = -symbol_get_bfdsym (fixp->fx_addsy)->section->vma;
1442
10a95fcc
AM
1443 code = fixp->fx_r_type;
1444 if (fixp->fx_pcrel)
e135f41b 1445 {
10a95fcc
AM
1446 switch (code)
1447 {
1448 case BFD_RELOC_16:
1449 code = BFD_RELOC_16_PCREL;
1450 break;
e135f41b 1451
10a95fcc
AM
1452 case BFD_RELOC_16_PCREL:
1453 break;
e135f41b 1454
10a95fcc
AM
1455 default:
1456 BAD_CASE (code);
1457 return NULL;
1458 }
e135f41b
NC
1459 }
1460
1461 reloc->howto = bfd_reloc_type_lookup (stdoutput, code);
1462
1463 if (reloc->howto == NULL)
1464 {
1465 as_bad_where (fixp->fx_file, fixp->fx_line,
20203fb9 1466 _("Can not represent %s relocation in this object file format"),
e135f41b
NC
1467 bfd_get_reloc_code_name (code));
1468 return NULL;
1469 }
1470
1471 return reloc;
1472}
1473
1474void
4d5f9b2a 1475pseudo_bss (int c ATTRIBUTE_UNUSED)
e135f41b
NC
1476{
1477 int temp;
1478
1479 temp = get_absolute_expression ();
1480 subseg_set (bss_section, temp);
1481 demand_empty_rest_of_line ();
1482}
1483
1484void
4d5f9b2a 1485pseudo_even (int c ATTRIBUTE_UNUSED)
e135f41b
NC
1486{
1487 int alignment = 1; /* 2^1 */
1488 frag_align (alignment, 0, 1);
1489 record_alignment (now_seg, alignment);
1490}
499ac353 1491
6d4af3c2 1492const char *
499ac353
NC
1493md_atof (int type, char * litP, int * sizeP)
1494{
1495 return vax_md_atof (type, litP, sizeP);
1496}
This page took 0.982819 seconds and 4 git commands to generate.