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