1 /* tc-pdp11.c - pdp11-specific -
2 Copyright (C) 2001-2019 Free Software Foundation, Inc.
4 This file is part of GAS, the GNU Assembler.
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
8 the Free Software Foundation; either version 3, or (at your option)
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.
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
18 the Free Software Foundation, 51 Franklin Street - Fifth Floor,
19 Boston, MA 02110-1301, USA. */
22 #include "safe-ctype.h"
23 #include "opcode/pdp11.h"
25 extern int flonum_gen2vax (int, FLONUM_TYPE * f, LITTLENUM_TYPE *);
30 /* A representation for PDP-11 machine code. */
35 int additional; /* Is there an additional word? */
36 int word; /* Additional word, if any. */
39 bfd_reloc_code_real_type type;
45 /* Instruction set extensions.
47 If you change this from an array to something else, please update
48 the "PDP-11 instruction set extensions" comment in pdp11.h. */
49 int pdp11_extension[PDP11_EXT_NUM];
51 /* Assembly options. */
56 int asm_option[ASM_OPT_NUM];
58 /* These chars start a comment anywhere in a source file (except inside
60 const char comment_chars[] = "#/";
62 /* These chars only start a comment at the beginning of a line. */
63 const char line_comment_chars[] = "#/";
65 const char line_separator_chars[] = ";";
67 /* Chars that can be used to separate mant from exp in floating point nums. */
68 const char EXP_CHARS[] = "eE";
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). */
73 const char FLT_CHARS[] = "dDfF";
75 void pseudo_even (int);
76 void pseudo_bss (int);
78 const pseudo_typeS md_pseudo_table[] =
80 { "bss", pseudo_bss, 0 },
81 { "even", pseudo_even, 0 },
85 static struct hash_control *insn_hash = NULL;
88 set_option (const char *arg)
92 if (strcmp (arg, "all-extensions") == 0
93 || strcmp (arg, "all") == 0)
95 memset (pdp11_extension, ~0, sizeof pdp11_extension);
96 pdp11_extension[PDP11_NONE] = 0;
99 else if (strcmp (arg, "no-extensions") == 0)
101 memset (pdp11_extension, 0, sizeof pdp11_extension);
102 pdp11_extension[PDP11_BASIC] = 1;
106 if (strncmp (arg, "no-", 3) == 0)
112 /* Commercial instructions. */
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)
138 pdp11_extension[PDP11_LEIS] = yes;
139 if (!pdp11_extension[PDP11_LEIS])
140 pdp11_extension[PDP11_EIS] = 0;
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
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
162 || strcmp (arg, "microcode") == 0)
163 pdp11_extension[PDP11_UCODE] = yes;
174 static int first = 1;
178 set_option ("all-extensions");
191 insn_hash = hash_new ();
192 if (insn_hash == NULL)
193 as_fatal (_("Virtual memory exhausted"));
195 for (i = 0; i < pdp11_num_opcodes; i++)
196 hash_insert (insn_hash, pdp11_opcodes[i].name, (void *) (pdp11_opcodes + i));
197 for (i = 0; i < pdp11_num_aliases; i++)
198 hash_insert (insn_hash, pdp11_aliases[i].name, (void *) (pdp11_aliases + i));
202 md_number_to_chars (char con[], valueT value, int nbytes)
204 /* On a PDP-11, 0x1234 is stored as "\x12\x34", and
205 0x12345678 is stored as "\x56\x78\x12\x34". It's
206 anyone's guess what 0x123456 would be stored like. */
213 con[0] = value & 0xff;
216 con[0] = value & 0xff;
217 con[1] = (value >> 8) & 0xff;
220 con[0] = (value >> 16) & 0xff;
221 con[1] = (value >> 24) & 0xff;
222 con[2] = value & 0xff;
223 con[3] = (value >> 8) & 0xff;
230 /* Fix up some data or instructions after we find out the value of a symbol
231 that they reference. Knows about order of bytes in address. */
234 md_apply_fix (fixS *fixP,
236 segT seg ATTRIBUTE_UNUSED)
245 buf = fixP->fx_where + fixP->fx_frag->fr_literal;
246 size = fixP->fx_size;
247 code = md_chars_to_number ((unsigned char *) buf, size);
249 switch (fixP->fx_r_type)
256 case BFD_RELOC_16_PCREL:
260 case BFD_RELOC_PDP11_DISP_8_PCREL:
264 case BFD_RELOC_PDP11_DISP_6_PCREL:
270 BAD_CASE (fixP->fx_r_type);
273 if (fixP->fx_addsy != NULL)
274 val += symbol_get_bfdsym (fixP->fx_addsy)->section->vma;
275 /* *value += fixP->fx_addsy->bsym->section->vma; */
278 code |= (val >> shift) & mask;
279 number_to_chars_littleendian (buf, code, size);
281 if (fixP->fx_addsy == NULL && fixP->fx_pcrel == 0)
286 md_chars_to_number (unsigned char *con, int nbytes)
288 /* On a PDP-11, 0x1234 is stored as "\x12\x34", and
289 0x12345678 is stored as "\x56\x78\x12\x34". It's
290 anyone's guess what 0x123456 would be stored like. */
298 return (con[1] << BITS_PER_CHAR) | con[0];
301 (((con[1] << BITS_PER_CHAR) | con[0]) << (2 * BITS_PER_CHAR))
302 |((con[3] << BITS_PER_CHAR) | con[2]);
310 skip_whitespace (char *str)
312 while (*str == ' ' || *str == '\t')
318 find_whitespace (char *str)
320 while (*str != ' ' && *str != '\t' && *str != 0)
326 parse_reg (char *str, struct pdp11_code *operand)
328 str = skip_whitespace (str);
329 if (TOLOWER (*str) == 'r')
334 case '0': case '1': case '2': case '3':
335 case '4': case '5': case '6': case '7':
336 operand->code = *str - '0';
340 operand->error = _("Bad register name");
344 else if (strncmp (str, "sp", 2) == 0
345 || strncmp (str, "SP", 2) == 0)
350 else if (strncmp (str, "pc", 2) == 0
351 || strncmp (str, "PC", 2) == 0)
357 operand->error = _("Bad register name");
363 parse_ac5 (char *str, struct pdp11_code *operand)
365 str = skip_whitespace (str);
366 if (strncmp (str, "fr", 2) == 0
367 || strncmp (str, "FR", 2) == 0
368 || strncmp (str, "ac", 2) == 0
369 || strncmp (str, "AC", 2) == 0)
374 case '0': case '1': case '2': case '3':
376 operand->code = *str - '0';
380 operand->error = _("Bad register name");
386 operand->error = _("Bad register name");
394 parse_ac (char *str, struct pdp11_code *operand)
396 str = parse_ac5 (str, operand);
397 if (!operand->error && operand->code > 3)
399 operand->error = _("Bad register name");
407 parse_expression (char *str, struct pdp11_code *operand)
409 char *save_input_line_pointer;
412 save_input_line_pointer = input_line_pointer;
413 input_line_pointer = str;
414 seg = expression (&operand->reloc.exp);
417 input_line_pointer = save_input_line_pointer;
418 operand->error = _("Error in expression");
422 str = input_line_pointer;
423 input_line_pointer = save_input_line_pointer;
425 operand->reloc.pc_rel = 0;
431 parse_op_no_deferred (char *str, struct pdp11_code *operand)
433 LITTLENUM_TYPE literal_float[2];
435 str = skip_whitespace (str);
439 case '(': /* (rn) and (rn)+ */
440 str = parse_reg (str + 1, operand);
443 str = skip_whitespace (str);
446 operand->error = _("Missing ')'");
452 operand->code |= 020;
457 operand->code |= 010;
464 str = parse_expression (str + 1, operand);
467 operand->additional = TRUE;
468 operand->word = operand->reloc.exp.X_add_number;
469 switch (operand->reloc.exp.X_op)
476 operand->reloc.type = BFD_RELOC_16;
477 operand->reloc.pc_rel = 0;
480 if (operand->reloc.exp.X_add_number > 0)
482 operand->error = _("Error in expression");
485 /* It's a floating literal... */
486 know (operand->reloc.exp.X_add_number < 0);
487 flonum_gen2vax ('f', &generic_floating_point_number, literal_float);
488 operand->word = literal_float[0];
489 if (literal_float[1] != 0)
490 as_warn (_("Low order bits truncated in immediate float operand"));
493 operand->error = _("Error in expression");
499 /* label, d(rn), -(rn) */
502 if (strncmp (str, "-(", 2) == 0) /* -(rn) */
504 str = parse_reg (str + 2, operand);
507 str = skip_whitespace (str);
510 operand->error = _("Missing ')'");
513 operand->code |= 040;
518 str = parse_expression (str, operand);
522 str = skip_whitespace (str);
527 operand->additional = 1;
529 operand->reloc.type = BFD_RELOC_16_PCREL;
530 operand->reloc.pc_rel = 1;
536 str = parse_reg (str, operand);
540 str = skip_whitespace (str);
544 operand->error = _("Missing ')'");
549 operand->additional = TRUE;
550 operand->code |= 060;
551 switch (operand->reloc.exp.X_op)
554 operand->reloc.type = BFD_RELOC_16;
555 operand->reloc.pc_rel = 0;
558 if ((operand->code & 7) == 7)
560 operand->reloc.pc_rel = 1;
561 operand->word = operand->reloc.exp.X_add_number;
564 operand->word = operand->reloc.exp.X_add_number;
568 BAD_CASE (operand->reloc.exp.X_op);
578 parse_op_noreg (char *str, struct pdp11_code *operand)
580 str = skip_whitespace (str);
581 operand->error = NULL;
583 if (*str == '@' || *str == '*')
585 /* @(Rn) == @0(Rn): Mode 7, Indexed deferred.
586 Check for auto-increment deferred. */
593 /* Change implied to explicit index deferred. */
595 str = parse_op_no_deferred (str, operand);
599 /* @Rn == (Rn): Register deferred. */
600 str = parse_reg (str + 1, operand);
605 operand->error = NULL;
606 str = parse_op_no_deferred (str, operand);
613 operand->code |= 010;
616 str = parse_op_no_deferred (str, operand);
622 parse_op (char *str, struct pdp11_code *operand)
624 str = skip_whitespace (str);
626 str = parse_reg (str, operand);
630 operand->error = NULL;
631 parse_ac5 (str, operand);
634 operand->error = _("Float AC not legal as integer operand");
638 return parse_op_noreg (str, operand);
642 parse_fop (char *str, struct pdp11_code *operand)
644 str = skip_whitespace (str);
646 str = parse_ac5 (str, operand);
650 operand->error = NULL;
651 parse_reg (str, operand);
654 operand->error = _("General register not legal as float operand");
658 return parse_op_noreg (str, operand);
662 parse_separator (char *str, int *error)
664 str = skip_whitespace (str);
665 *error = (*str != ',');
672 md_assemble (char *instruction_string)
674 const struct pdp11_opcode *op;
675 struct pdp11_code insn, op1, op2;
678 const char *err = NULL;
683 str = skip_whitespace (instruction_string);
684 p = find_whitespace (str);
687 as_bad (_("No instruction found"));
693 op = (struct pdp11_opcode *)hash_find (insn_hash, str);
697 as_bad (_("Unknown instruction '%s'"), str);
701 if (!pdp11_extension[op->extension])
703 as_warn (_("Unsupported instruction set extension: %s"), op->name);
708 insn.code = op->opcode;
709 insn.reloc.type = BFD_RELOC_NONE;
711 op1.additional = FALSE;
712 op1.reloc.type = BFD_RELOC_NONE;
714 op2.additional = FALSE;
715 op2.reloc.type = BFD_RELOC_NONE;
722 case PDP11_OPCODE_NO_OPS:
723 str = skip_whitespace (str);
726 case PDP11_OPCODE_IMM3:
727 case PDP11_OPCODE_IMM6:
728 case PDP11_OPCODE_IMM8:
729 str = skip_whitespace (str);
730 if (*str == '#' || *str == '$')
732 str = parse_expression (str, &op1);
735 if (op1.reloc.exp.X_op != O_constant || op1.reloc.type != BFD_RELOC_NONE)
737 op1.error = _("operand is not an absolute constant");
742 case PDP11_OPCODE_IMM3:
743 if (op1.reloc.exp.X_add_number & ~7)
745 op1.error = _("3-bit immediate out of range");
749 case PDP11_OPCODE_IMM6:
750 if (op1.reloc.exp.X_add_number & ~0x3f)
752 op1.error = _("6-bit immediate out of range");
756 case PDP11_OPCODE_IMM8:
757 if (op1.reloc.exp.X_add_number & ~0xff)
759 op1.error = _("8-bit immediate out of range");
764 insn.code |= op1.reloc.exp.X_add_number;
767 case PDP11_OPCODE_DISPL:
770 new_pointer = parse_expression (str, &op1);
772 op1.reloc.pc_rel = 1;
773 op1.reloc.type = BFD_RELOC_PDP11_DISP_8_PCREL;
774 if (op1.reloc.exp.X_op != O_symbol)
776 op1.error = _("Symbol expected");
779 if (op1.code & ~0xff)
781 err = _("8-bit displacement out of range");
785 insn.code |= op1.code;
786 insn.reloc = op1.reloc;
790 case PDP11_OPCODE_REG:
791 str = parse_reg (str, &op1);
794 insn.code |= op1.code;
797 case PDP11_OPCODE_OP:
798 str = parse_op (str, &op1);
801 insn.code |= op1.code;
806 case PDP11_OPCODE_FOP:
807 str = parse_fop (str, &op1);
810 insn.code |= op1.code;
815 case PDP11_OPCODE_REG_OP:
816 str = parse_reg (str, &op2);
819 insn.code |= op2.code << 6;
820 str = parse_separator (str, &error);
823 op2.error = _("Missing ','");
826 str = parse_op (str, &op1);
829 insn.code |= op1.code;
834 case PDP11_OPCODE_REG_OP_REV:
835 str = parse_op (str, &op1);
838 insn.code |= op1.code;
841 str = parse_separator (str, &error);
844 op2.error = _("Missing ','");
847 str = parse_reg (str, &op2);
850 insn.code |= op2.code << 6;
853 case PDP11_OPCODE_AC_FOP:
854 str = parse_ac (str, &op2);
857 insn.code |= op2.code << 6;
858 str = parse_separator (str, &error);
861 op1.error = _("Missing ','");
864 str = parse_fop (str, &op1);
867 insn.code |= op1.code;
872 case PDP11_OPCODE_FOP_AC:
873 str = parse_fop (str, &op1);
876 insn.code |= op1.code;
879 str = parse_separator (str, &error);
882 op1.error = _("Missing ','");
885 str = parse_ac (str, &op2);
888 insn.code |= op2.code << 6;
891 case PDP11_OPCODE_AC_OP:
892 str = parse_ac (str, &op2);
895 insn.code |= op2.code << 6;
896 str = parse_separator (str, &error);
899 op1.error = _("Missing ','");
902 str = parse_op (str, &op1);
905 insn.code |= op1.code;
910 case PDP11_OPCODE_OP_AC:
911 str = parse_op (str, &op1);
914 insn.code |= op1.code;
917 str = parse_separator (str, &error);
920 op1.error = _("Missing ','");
923 str = parse_ac (str, &op2);
926 insn.code |= op2.code << 6;
929 case PDP11_OPCODE_OP_OP:
930 str = parse_op (str, &op1);
933 insn.code |= op1.code << 6;
936 str = parse_separator (str, &error);
939 op2.error = _("Missing ','");
942 str = parse_op (str, &op2);
945 insn.code |= op2.code;
950 case PDP11_OPCODE_REG_DISPL:
953 str = parse_reg (str, &op2);
956 insn.code |= op2.code << 6;
957 str = parse_separator (str, &error);
960 op1.error = _("Missing ','");
963 new_pointer = parse_expression (str, &op1);
965 op1.reloc.pc_rel = 1;
966 op1.reloc.type = BFD_RELOC_PDP11_DISP_6_PCREL;
967 if (op1.reloc.exp.X_op != O_symbol)
969 op1.error = _("Symbol expected");
972 if (op1.code & ~0x3f)
974 err = _("6-bit displacement out of range");
978 insn.code |= op1.code;
979 insn.reloc = op1.reloc;
993 str = skip_whitespace (str);
995 err = _("Too many operands");
1007 to = frag_more (size);
1009 md_number_to_chars (to, insn.code, 2);
1010 if (insn.reloc.type != BFD_RELOC_NONE)
1011 fix_new_exp (frag_now, to - frag_now->fr_literal, 2,
1012 &insn.reloc.exp, insn.reloc.pc_rel, insn.reloc.type);
1017 md_number_to_chars (to, op1.word, 2);
1018 if (op1.reloc.type != BFD_RELOC_NONE)
1019 fix_new_exp (frag_now, to - frag_now->fr_literal, 2,
1020 &op1.reloc.exp, op1.reloc.pc_rel, op1.reloc.type);
1026 md_number_to_chars (to, op2.word, 2);
1027 if (op2.reloc.type != BFD_RELOC_NONE)
1028 fix_new_exp (frag_now, to - frag_now->fr_literal, 2,
1029 &op2.reloc.exp, op2.reloc.pc_rel, op2.reloc.type);
1035 md_estimate_size_before_relax (fragS *fragP ATTRIBUTE_UNUSED,
1036 segT segment ATTRIBUTE_UNUSED)
1042 md_convert_frag (bfd *headers ATTRIBUTE_UNUSED,
1043 segT seg ATTRIBUTE_UNUSED,
1044 fragS *fragP ATTRIBUTE_UNUSED)
1048 int md_short_jump_size = 2;
1049 int md_long_jump_size = 4;
1052 md_create_short_jump (char *ptr ATTRIBUTE_UNUSED,
1053 addressT from_addr ATTRIBUTE_UNUSED,
1054 addressT to_addr ATTRIBUTE_UNUSED,
1055 fragS *frag ATTRIBUTE_UNUSED,
1056 symbolS *to_symbol ATTRIBUTE_UNUSED)
1061 md_create_long_jump (char *ptr ATTRIBUTE_UNUSED,
1062 addressT from_addr ATTRIBUTE_UNUSED,
1063 addressT to_addr ATTRIBUTE_UNUSED,
1064 fragS *frag ATTRIBUTE_UNUSED,
1065 symbolS *to_symbol ATTRIBUTE_UNUSED)
1070 set_cpu_model (const char *arg)
1080 if (strchr ("abdx", model[-1]) == NULL)
1083 if (model[-1] == 'd')
1085 if (arg[0] == 'f' || arg[0] == 'j')
1088 else if (model[-1] == 'x')
1097 if (strncmp (arg, "11", 2) != 0)
1107 /* Allow up to two revision letters. */
1115 set_option ("no-extensions");
1117 /* KA11 (11/15/20). */
1118 if (strncmp (buf, "a", 1) == 0)
1119 return 1; /* No extensions. */
1121 /* KB11 (11/45/50/55/70). */
1122 else if (strncmp (buf, "b", 1) == 0)
1123 return set_option ("eis") && set_option ("spl");
1125 /* KD11-A (11/35/40). */
1126 else if (strncmp (buf, "da", 2) == 0)
1127 return set_option ("limited-eis");
1129 /* KD11-B (11/05/10). */
1130 else if (strncmp (buf, "db", 2) == 0
1131 /* KD11-D (11/04). */
1132 || strncmp (buf, "dd", 2) == 0)
1133 return 1; /* no extensions */
1135 /* KD11-E (11/34). */
1136 else if (strncmp (buf, "de", 2) == 0)
1137 return set_option ("eis") && set_option ("mxps");
1139 /* KD11-F (11/03). */
1140 else if (strncmp (buf, "df", 2) == 0
1141 /* KD11-H (11/03). */
1142 || strncmp (buf, "dh", 2) == 0
1143 /* KD11-Q (11/03). */
1144 || strncmp (buf, "dq", 2) == 0)
1145 return set_option ("limited-eis") && set_option ("mxps");
1147 /* KD11-K (11/60). */
1148 else if (strncmp (buf, "dk", 2) == 0)
1149 return set_option ("eis")
1150 && set_option ("mxps")
1151 && set_option ("ucode");
1153 /* KD11-Z (11/44). */
1154 else if (strncmp (buf, "dz", 2) == 0)
1155 return set_option ("csm")
1156 && set_option ("eis")
1157 && set_option ("mfpt")
1158 && set_option ("mxps")
1159 && set_option ("spl");
1161 /* F11 (11/23/24). */
1162 else if (strncmp (buf, "f", 1) == 0)
1163 return set_option ("eis")
1164 && set_option ("mfpt")
1165 && set_option ("mxps");
1167 /* J11 (11/53/73/83/84/93/94). */
1168 else if (strncmp (buf, "j", 1) == 0)
1169 return set_option ("csm")
1170 && set_option ("eis")
1171 && set_option ("mfpt")
1172 && set_option ("multiproc")
1173 && set_option ("mxps")
1174 && set_option ("spl");
1177 else if (strncmp (buf, "t", 1) == 0)
1178 return set_option ("limited-eis")
1179 && set_option ("mxps");
1186 set_machine_model (const char *arg)
1188 if (strncmp (arg, "pdp-11/", 7) != 0
1189 && strncmp (arg, "pdp11/", 6) != 0
1190 && strncmp (arg, "11/", 3) != 0)
1193 if (strncmp (arg, "pdp", 3) == 0)
1197 if (strncmp (arg, "11/", 3) == 0)
1200 if (strcmp (arg, "03") == 0)
1201 return set_cpu_model ("kd11f");
1203 else if (strcmp (arg, "04") == 0)
1204 return set_cpu_model ("kd11d");
1206 else if (strcmp (arg, "05") == 0
1207 || strcmp (arg, "10") == 0)
1208 return set_cpu_model ("kd11b");
1210 else if (strcmp (arg, "15") == 0
1211 || strcmp (arg, "20") == 0)
1212 return set_cpu_model ("ka11");
1214 else if (strcmp (arg, "21") == 0)
1215 return set_cpu_model ("t11");
1217 else if (strcmp (arg, "23") == 0
1218 || strcmp (arg, "24") == 0)
1219 return set_cpu_model ("f11");
1221 else if (strcmp (arg, "34") == 0
1222 || strcmp (arg, "34a") == 0)
1223 return set_cpu_model ("kd11e");
1225 else if (strcmp (arg, "35") == 0
1226 || strcmp (arg, "40") == 0)
1227 return set_cpu_model ("kd11da");
1229 else if (strcmp (arg, "44") == 0)
1230 return set_cpu_model ("kd11dz");
1232 else if (strcmp (arg, "45") == 0
1233 || strcmp (arg, "50") == 0
1234 || strcmp (arg, "55") == 0
1235 || strcmp (arg, "70") == 0)
1236 return set_cpu_model ("kb11");
1238 else if (strcmp (arg, "60") == 0)
1239 return set_cpu_model ("kd11k");
1241 else if (strcmp (arg, "53") == 0
1242 || strcmp (arg, "73") == 0
1243 || strcmp (arg, "83") == 0
1244 || strcmp (arg, "84") == 0
1245 || strcmp (arg, "93") == 0
1246 || strcmp (arg, "94") == 0)
1247 return set_cpu_model ("j11")
1248 && set_option ("fpp");
1254 const char *md_shortopts = "m:";
1256 struct option md_longopts[] =
1258 #define OPTION_CPU 257
1259 { "cpu", required_argument, NULL, OPTION_CPU },
1260 #define OPTION_MACHINE 258
1261 { "machine", required_argument, NULL, OPTION_MACHINE },
1262 #define OPTION_PIC 259
1263 { "pic", no_argument, NULL, OPTION_PIC },
1264 { NULL, no_argument, NULL, 0 }
1267 size_t md_longopts_size = sizeof (md_longopts);
1269 /* Invocation line includes a switch not recognized by the base assembler.
1270 See if it's a processor-specific option. */
1273 md_parse_option (int c, const char *arg)
1280 if (set_option (arg))
1282 if (set_cpu_model (arg))
1284 if (set_machine_model (arg))
1289 if (set_cpu_model (arg))
1293 case OPTION_MACHINE:
1294 if (set_machine_model (arg))
1299 if (set_option ("pic"))
1311 md_show_usage (FILE *stream)
1315 PDP-11 instruction set extensions:\n\
1317 -m(no-)cis allow (disallow) commercial instruction set\n\
1318 -m(no-)csm allow (disallow) CSM instruction\n\
1319 -m(no-)eis allow (disallow) full extended instruction set\n\
1320 -m(no-)fis allow (disallow) KEV11 floating-point instructions\n\
1321 -m(no-)fpp allow (disallow) FP-11 floating-point instructions\n\
1322 -m(no-)fpu allow (disallow) FP-11 floating-point instructions\n\
1323 -m(no-)limited-eis allow (disallow) limited extended instruction set\n\
1324 -m(no-)mfpt allow (disallow) processor type instruction\n\
1325 -m(no-)multiproc allow (disallow) multiprocessor instructions\n\
1326 -m(no-)mxps allow (disallow) processor status instructions\n\
1327 -m(no-)spl allow (disallow) SPL instruction\n\
1328 -m(no-)ucode allow (disallow) microcode instructions\n\
1329 -mall-extensions allow all instruction set extensions\n\
1330 (this is the default)\n\
1331 -mno-extensions disallow all instruction set extensions\n\
1332 -pic generate position-independent code\n\
1334 PDP-11 CPU model options:\n\
1336 -mka11* KA11 CPU. base line instruction set only\n\
1337 -mkb11* KB11 CPU. enable full EIS and SPL\n\
1338 -mkd11a* KD11-A CPU. enable limited EIS\n\
1339 -mkd11b* KD11-B CPU. base line instruction set only\n\
1340 -mkd11d* KD11-D CPU. base line instruction set only\n\
1341 -mkd11e* KD11-E CPU. enable full EIS, MTPS, and MFPS\n\
1342 -mkd11f* KD11-F CPU. enable limited EIS, MTPS, and MFPS\n\
1343 -mkd11h* KD11-H CPU. enable limited EIS, MTPS, and MFPS\n\
1344 -mkd11q* KD11-Q CPU. enable limited EIS, MTPS, and MFPS\n\
1345 -mkd11k* KD11-K CPU. enable full EIS, MTPS, MFPS, LDUB, MED,\n\
1347 -mkd11z* KD11-Z CPU. enable full EIS, MTPS, MFPS, MFPT, SPL,\n\
1349 -mf11* F11 CPU. enable full EIS, MFPS, MTPS, and MFPT\n\
1350 -mj11* J11 CPU. enable full EIS, MTPS, MFPS, MFPT, SPL,\n\
1351 CSM, TSTSET, and WRTLCK\n\
1352 -mt11* T11 CPU. enable limited EIS, MTPS, and MFPS\n\
1354 PDP-11 machine model options:\n\
1356 -m11/03 same as -mkd11f\n\
1357 -m11/04 same as -mkd11d\n\
1358 -m11/05 same as -mkd11b\n\
1359 -m11/10 same as -mkd11b\n\
1360 -m11/15 same as -mka11\n\
1361 -m11/20 same as -mka11\n\
1362 -m11/21 same as -mt11\n\
1363 -m11/23 same as -mf11\n\
1364 -m11/24 same as -mf11\n\
1365 -m11/34 same as -mkd11e\n\
1366 -m11/34a same as -mkd11e -mfpp\n\
1367 -m11/35 same as -mkd11a\n\
1368 -m11/40 same as -mkd11a\n\
1369 -m11/44 same as -mkd11z\n\
1370 -m11/45 same as -mkb11\n\
1371 -m11/50 same as -mkb11\n\
1372 -m11/53 same as -mj11\n\
1373 -m11/55 same as -mkb11\n\
1374 -m11/60 same as -mkd11k\n\
1375 -m11/70 same as -mkb11\n\
1376 -m11/73 same as -mj11\n\
1377 -m11/83 same as -mj11\n\
1378 -m11/84 same as -mj11\n\
1379 -m11/93 same as -mj11\n\
1380 -m11/94 same as -mj11\n\
1385 md_undefined_symbol (char *name ATTRIBUTE_UNUSED)
1391 md_section_align (segT segment ATTRIBUTE_UNUSED,
1394 return (size + 1) & ~1;
1398 md_pcrel_from (fixS *fixP)
1400 return fixP->fx_frag->fr_address + fixP->fx_where + fixP->fx_size;
1403 /* Translate internal representation of relocation info to BFD target
1407 tc_gen_reloc (asection *section ATTRIBUTE_UNUSED,
1411 bfd_reloc_code_real_type code;
1413 reloc = XNEW (arelent);
1415 reloc->sym_ptr_ptr = XNEW (asymbol *);
1416 *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
1417 reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
1419 /* This is taken account for in md_apply_fix(). */
1420 reloc->addend = -symbol_get_bfdsym (fixp->fx_addsy)->section->vma;
1422 switch (fixp->fx_r_type)
1426 code = BFD_RELOC_16_PCREL;
1428 code = BFD_RELOC_16;
1431 case BFD_RELOC_16_PCREL:
1432 code = BFD_RELOC_16_PCREL;
1436 BAD_CASE (fixp->fx_r_type);
1440 reloc->howto = bfd_reloc_type_lookup (stdoutput, code);
1442 if (reloc->howto == NULL)
1444 as_bad_where (fixp->fx_file, fixp->fx_line,
1445 _("Can not represent %s relocation in this object file format"),
1446 bfd_get_reloc_code_name (code));
1454 pseudo_bss (int c ATTRIBUTE_UNUSED)
1458 temp = get_absolute_expression ();
1459 subseg_set (bss_section, temp);
1460 demand_empty_rest_of_line ();
1464 pseudo_even (int c ATTRIBUTE_UNUSED)
1466 int alignment = 1; /* 2^1 */
1467 frag_align (alignment, 0, 1);
1468 record_alignment (now_seg, alignment);
1472 md_atof (int type, char * litP, int * sizeP)
1474 return vax_md_atof (type, litP, sizeP);