1 /* tc-pdp11.c - pdp11-specific -
2 Copyright (C) 2001-2020 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 htab_t 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
= str_htab_create ();
193 for (i
= 0; i
< pdp11_num_opcodes
; i
++)
194 str_hash_insert (insn_hash
, pdp11_opcodes
[i
].name
, pdp11_opcodes
+ i
, 0);
195 for (i
= 0; i
< pdp11_num_aliases
; i
++)
196 str_hash_insert (insn_hash
, pdp11_aliases
[i
].name
, pdp11_aliases
+ i
, 0);
200 md_number_to_chars (char con
[], valueT value
, int nbytes
)
202 /* On a PDP-11, 0x1234 is stored as "\x12\x34", and
203 0x12345678 is stored as "\x56\x78\x12\x34". It's
204 anyone's guess what 0x123456 would be stored like. */
211 con
[0] = value
& 0xff;
214 con
[0] = value
& 0xff;
215 con
[1] = (value
>> 8) & 0xff;
218 con
[0] = (value
>> 16) & 0xff;
219 con
[1] = (value
>> 24) & 0xff;
220 con
[2] = value
& 0xff;
221 con
[3] = (value
>> 8) & 0xff;
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;
238 /* Fix up some data or instructions after we find out the value of a symbol
239 that they reference. Knows about order of bytes in address. */
242 md_apply_fix (fixS
*fixP
,
244 segT seg ATTRIBUTE_UNUSED
)
253 buf
= fixP
->fx_where
+ fixP
->fx_frag
->fr_literal
;
254 size
= fixP
->fx_size
;
255 code
= md_chars_to_number ((unsigned char *) buf
, size
);
257 switch (fixP
->fx_r_type
)
264 case BFD_RELOC_16_PCREL
:
272 case BFD_RELOC_PDP11_DISP_8_PCREL
:
276 case BFD_RELOC_PDP11_DISP_6_PCREL
:
282 BAD_CASE (fixP
->fx_r_type
);
285 if (fixP
->fx_addsy
!= NULL
)
286 val
+= symbol_get_bfdsym (fixP
->fx_addsy
)->section
->vma
;
287 /* *value += fixP->fx_addsy->bsym->section->vma; */
290 code
|= (val
>> shift
) & mask
;
291 number_to_chars_littleendian (buf
, code
, size
);
293 if (fixP
->fx_addsy
== NULL
&& fixP
->fx_pcrel
== 0)
298 md_chars_to_number (unsigned char *con
, int nbytes
)
300 /* On a PDP-11, 0x1234 is stored as "\x12\x34", and
301 0x12345678 is stored as "\x56\x78\x12\x34". It's
302 anyone's guess what 0x123456 would be stored like. */
310 return (con
[1] << BITS_PER_CHAR
) | con
[0];
313 (((con
[1] << BITS_PER_CHAR
) | con
[0]) << (2 * BITS_PER_CHAR
))
314 |((con
[3] << BITS_PER_CHAR
) | con
[2]);
322 skip_whitespace (char *str
)
324 while (*str
== ' ' || *str
== '\t')
330 find_whitespace (char *str
)
332 while (*str
!= ' ' && *str
!= '\t' && *str
!= 0)
338 parse_reg (char *str
, struct pdp11_code
*operand
)
340 str
= skip_whitespace (str
);
341 if (TOLOWER (*str
) == 'r')
346 case '0': case '1': case '2': case '3':
347 case '4': case '5': case '6': case '7':
348 operand
->code
= *str
- '0';
352 operand
->error
= _("Bad register name");
356 else if (strncmp (str
, "sp", 2) == 0
357 || strncmp (str
, "SP", 2) == 0)
362 else if (strncmp (str
, "pc", 2) == 0
363 || strncmp (str
, "PC", 2) == 0)
370 operand
->error
= _("Bad register name");
374 if (ISALNUM (*str
) || *str
== '_' || *str
== '.')
376 operand
->error
= _("Bad register name");
384 parse_ac5 (char *str
, struct pdp11_code
*operand
)
386 str
= skip_whitespace (str
);
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)
395 case '0': case '1': case '2': case '3':
397 operand
->code
= *str
- '0';
401 operand
->error
= _("Bad register name");
407 operand
->error
= _("Bad register name");
415 parse_ac (char *str
, struct pdp11_code
*operand
)
417 str
= parse_ac5 (str
, operand
);
418 if (!operand
->error
&& operand
->code
> 3)
420 operand
->error
= _("Bad register name");
428 parse_expression (char *str
, struct pdp11_code
*operand
)
430 char *save_input_line_pointer
;
433 save_input_line_pointer
= input_line_pointer
;
434 input_line_pointer
= str
;
435 seg
= expression (&operand
->reloc
.exp
);
438 input_line_pointer
= save_input_line_pointer
;
439 operand
->error
= _("Error in expression");
443 str
= input_line_pointer
;
444 input_line_pointer
= save_input_line_pointer
;
446 operand
->reloc
.pc_rel
= 0;
452 parse_op_no_deferred (char *str
, struct pdp11_code
*operand
)
454 LITTLENUM_TYPE literal_float
[2];
456 str
= skip_whitespace (str
);
460 case '(': /* (rn) and (rn)+ */
461 str
= parse_reg (str
+ 1, operand
);
464 str
= skip_whitespace (str
);
467 operand
->error
= _("Missing ')'");
473 operand
->code
|= 020;
478 operand
->code
|= 010;
485 str
= parse_expression (str
+ 1, operand
);
488 operand
->additional
= TRUE
;
489 operand
->word
= operand
->reloc
.exp
.X_add_number
;
490 switch (operand
->reloc
.exp
.X_op
)
497 operand
->reloc
.type
= BFD_RELOC_16
;
498 operand
->reloc
.pc_rel
= 0;
501 if (operand
->reloc
.exp
.X_add_number
> 0)
503 operand
->error
= _("Error in expression");
506 /* It's a floating literal... */
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"));
514 operand
->error
= _("Error in expression");
520 /* label, d(rn), -(rn) */
523 if (strncmp (str
, "-(", 2) == 0) /* -(rn) */
525 str
= parse_reg (str
+ 2, operand
);
528 str
= skip_whitespace (str
);
531 operand
->error
= _("Missing ')'");
534 operand
->code
|= 040;
539 str
= parse_expression (str
, operand
);
543 str
= skip_whitespace (str
);
548 operand
->additional
= 1;
550 operand
->reloc
.type
= BFD_RELOC_16_PCREL
;
551 operand
->reloc
.pc_rel
= 1;
557 str
= parse_reg (str
, operand
);
561 str
= skip_whitespace (str
);
565 operand
->error
= _("Missing ')'");
570 operand
->additional
= TRUE
;
571 operand
->code
|= 060;
572 switch (operand
->reloc
.exp
.X_op
)
575 operand
->reloc
.type
= BFD_RELOC_16
;
576 operand
->reloc
.pc_rel
= 0;
579 if ((operand
->code
& 7) == 7)
581 operand
->reloc
.pc_rel
= 1;
582 operand
->word
= operand
->reloc
.exp
.X_add_number
;
585 operand
->word
= operand
->reloc
.exp
.X_add_number
;
589 BAD_CASE (operand
->reloc
.exp
.X_op
);
599 parse_op_noreg (char *str
, struct pdp11_code
*operand
)
601 str
= skip_whitespace (str
);
602 operand
->error
= NULL
;
604 if (*str
== '@' || *str
== '*')
606 /* @(Rn) == @0(Rn): Mode 7, Indexed deferred.
607 Check for auto-increment deferred. */
614 /* Change implied to explicit index deferred. */
616 str
= parse_op_no_deferred (str
, operand
);
620 /* @Rn == (Rn): Register deferred. */
621 str
= parse_reg (str
+ 1, operand
);
626 operand
->error
= NULL
;
627 str
= parse_op_no_deferred (str
, operand
);
634 operand
->code
|= 010;
637 str
= parse_op_no_deferred (str
, operand
);
643 parse_op (char *str
, struct pdp11_code
*operand
)
645 str
= skip_whitespace (str
);
647 str
= parse_reg (str
, operand
);
651 operand
->error
= NULL
;
652 parse_ac5 (str
, operand
);
655 operand
->error
= _("Float AC not legal as integer operand");
659 return parse_op_noreg (str
, operand
);
663 parse_fop (char *str
, struct pdp11_code
*operand
)
665 str
= skip_whitespace (str
);
667 str
= parse_ac5 (str
, operand
);
671 operand
->error
= NULL
;
672 parse_reg (str
, operand
);
675 operand
->error
= _("General register not legal as float operand");
679 return parse_op_noreg (str
, operand
);
683 parse_separator (char *str
, int *error
)
685 str
= skip_whitespace (str
);
686 *error
= (*str
!= ',');
693 md_assemble (char *instruction_string
)
695 const struct pdp11_opcode
*op
;
696 struct pdp11_code insn
, op1
, op2
;
699 const char *err
= NULL
;
704 str
= skip_whitespace (instruction_string
);
705 p
= find_whitespace (str
);
708 as_bad (_("No instruction found"));
714 op
= (struct pdp11_opcode
*)str_hash_find (insn_hash
, str
);
718 as_bad (_("Unknown instruction '%s'"), str
);
722 if (!pdp11_extension
[op
->extension
])
724 as_warn (_("Unsupported instruction set extension: %s"), op
->name
);
729 insn
.code
= op
->opcode
;
730 insn
.reloc
.type
= BFD_RELOC_NONE
;
732 op1
.additional
= FALSE
;
733 op1
.reloc
.type
= BFD_RELOC_NONE
;
735 op2
.additional
= FALSE
;
736 op2
.reloc
.type
= BFD_RELOC_NONE
;
743 case PDP11_OPCODE_NO_OPS
:
744 str
= skip_whitespace (str
);
747 case PDP11_OPCODE_IMM3
:
748 case PDP11_OPCODE_IMM6
:
749 case PDP11_OPCODE_IMM8
:
750 str
= skip_whitespace (str
);
751 if (*str
== '#' || *str
== '$')
753 str
= parse_expression (str
, &op1
);
756 if (op1
.reloc
.exp
.X_op
!= O_constant
|| op1
.reloc
.type
!= BFD_RELOC_NONE
)
758 op1
.error
= _("operand is not an absolute constant");
763 case PDP11_OPCODE_IMM3
:
764 if (op1
.reloc
.exp
.X_add_number
& ~7)
766 op1
.error
= _("3-bit immediate out of range");
770 case PDP11_OPCODE_IMM6
:
771 if (op1
.reloc
.exp
.X_add_number
& ~0x3f)
773 op1
.error
= _("6-bit immediate out of range");
777 case PDP11_OPCODE_IMM8
:
778 if (op1
.reloc
.exp
.X_add_number
& ~0xff)
780 op1
.error
= _("8-bit immediate out of range");
785 insn
.code
|= op1
.reloc
.exp
.X_add_number
;
788 case PDP11_OPCODE_DISPL
:
791 new_pointer
= parse_expression (str
, &op1
);
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
)
797 op1
.error
= _("Symbol expected");
800 if (op1
.code
& ~0xff)
802 err
= _("8-bit displacement out of range");
806 insn
.code
|= op1
.code
;
807 insn
.reloc
= op1
.reloc
;
811 case PDP11_OPCODE_REG
:
812 str
= parse_reg (str
, &op1
);
815 insn
.code
|= op1
.code
;
818 case PDP11_OPCODE_OP
:
819 str
= parse_op (str
, &op1
);
822 insn
.code
|= op1
.code
;
827 case PDP11_OPCODE_FOP
:
828 str
= parse_fop (str
, &op1
);
831 insn
.code
|= op1
.code
;
836 case PDP11_OPCODE_REG_OP
:
837 str
= parse_reg (str
, &op2
);
840 insn
.code
|= op2
.code
<< 6;
841 str
= parse_separator (str
, &error
);
844 op2
.error
= _("Missing ','");
847 str
= parse_op (str
, &op1
);
850 insn
.code
|= op1
.code
;
855 case PDP11_OPCODE_REG_OP_REV
:
856 str
= parse_op (str
, &op1
);
859 insn
.code
|= op1
.code
;
862 str
= parse_separator (str
, &error
);
865 op2
.error
= _("Missing ','");
868 str
= parse_reg (str
, &op2
);
871 insn
.code
|= op2
.code
<< 6;
874 case PDP11_OPCODE_AC_FOP
:
875 str
= parse_ac (str
, &op2
);
878 insn
.code
|= op2
.code
<< 6;
879 str
= parse_separator (str
, &error
);
882 op1
.error
= _("Missing ','");
885 str
= parse_fop (str
, &op1
);
888 insn
.code
|= op1
.code
;
893 case PDP11_OPCODE_FOP_AC
:
894 str
= parse_fop (str
, &op1
);
897 insn
.code
|= op1
.code
;
900 str
= parse_separator (str
, &error
);
903 op1
.error
= _("Missing ','");
906 str
= parse_ac (str
, &op2
);
909 insn
.code
|= op2
.code
<< 6;
912 case PDP11_OPCODE_AC_OP
:
913 str
= parse_ac (str
, &op2
);
916 insn
.code
|= op2
.code
<< 6;
917 str
= parse_separator (str
, &error
);
920 op1
.error
= _("Missing ','");
923 str
= parse_op (str
, &op1
);
926 insn
.code
|= op1
.code
;
931 case PDP11_OPCODE_OP_AC
:
932 str
= parse_op (str
, &op1
);
935 insn
.code
|= op1
.code
;
938 str
= parse_separator (str
, &error
);
941 op1
.error
= _("Missing ','");
944 str
= parse_ac (str
, &op2
);
947 insn
.code
|= op2
.code
<< 6;
950 case PDP11_OPCODE_OP_OP
:
951 str
= parse_op (str
, &op1
);
954 insn
.code
|= op1
.code
<< 6;
957 str
= parse_separator (str
, &error
);
960 op2
.error
= _("Missing ','");
963 str
= parse_op (str
, &op2
);
966 insn
.code
|= op2
.code
;
971 case PDP11_OPCODE_REG_DISPL
:
974 str
= parse_reg (str
, &op2
);
977 insn
.code
|= op2
.code
<< 6;
978 str
= parse_separator (str
, &error
);
981 op1
.error
= _("Missing ','");
984 new_pointer
= parse_expression (str
, &op1
);
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
)
990 op1
.error
= _("Symbol expected");
993 if (op1
.code
& ~0x3f)
995 err
= _("6-bit displacement out of range");
999 insn
.code
|= op1
.code
;
1000 insn
.reloc
= op1
.reloc
;
1005 BAD_CASE (op
->type
);
1014 str
= skip_whitespace (str
);
1016 err
= _("Too many operands");
1028 to
= frag_more (size
);
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
);
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
);
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
);
1056 md_estimate_size_before_relax (fragS
*fragP ATTRIBUTE_UNUSED
,
1057 segT segment ATTRIBUTE_UNUSED
)
1063 md_convert_frag (bfd
*headers ATTRIBUTE_UNUSED
,
1064 segT seg ATTRIBUTE_UNUSED
,
1065 fragS
*fragP ATTRIBUTE_UNUSED
)
1069 int md_short_jump_size
= 2;
1070 int md_long_jump_size
= 4;
1073 md_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
)
1082 md_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
)
1091 set_cpu_model (const char *arg
)
1101 if (strchr ("abdx", model
[-1]) == NULL
)
1104 if (model
[-1] == 'd')
1106 if (arg
[0] == 'f' || arg
[0] == 'j')
1109 else if (model
[-1] == 'x')
1118 if (strncmp (arg
, "11", 2) != 0)
1128 /* Allow up to two revision letters. */
1136 set_option ("no-extensions");
1138 /* KA11 (11/15/20). */
1139 if (strncmp (buf
, "a", 1) == 0)
1140 return 1; /* No extensions. */
1142 /* KB11 (11/45/50/55/70). */
1143 else if (strncmp (buf
, "b", 1) == 0)
1144 return set_option ("eis") && set_option ("spl");
1146 /* KD11-A (11/35/40). */
1147 else if (strncmp (buf
, "da", 2) == 0)
1148 return set_option ("limited-eis");
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)
1154 return 1; /* no extensions */
1156 /* KD11-E (11/34). */
1157 else if (strncmp (buf
, "de", 2) == 0)
1158 return set_option ("eis") && set_option ("mxps");
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");
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");
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");
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");
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");
1198 else if (strncmp (buf
, "t", 1) == 0)
1199 return set_option ("limited-eis")
1200 && set_option ("mxps");
1207 set_machine_model (const char *arg
)
1209 if (strncmp (arg
, "pdp-11/", 7) != 0
1210 && strncmp (arg
, "pdp11/", 6) != 0
1211 && strncmp (arg
, "11/", 3) != 0)
1214 if (strncmp (arg
, "pdp", 3) == 0)
1218 if (strncmp (arg
, "11/", 3) == 0)
1221 if (strcmp (arg
, "03") == 0)
1222 return set_cpu_model ("kd11f");
1224 else if (strcmp (arg
, "04") == 0)
1225 return set_cpu_model ("kd11d");
1227 else if (strcmp (arg
, "05") == 0
1228 || strcmp (arg
, "10") == 0)
1229 return set_cpu_model ("kd11b");
1231 else if (strcmp (arg
, "15") == 0
1232 || strcmp (arg
, "20") == 0)
1233 return set_cpu_model ("ka11");
1235 else if (strcmp (arg
, "21") == 0)
1236 return set_cpu_model ("t11");
1238 else if (strcmp (arg
, "23") == 0
1239 || strcmp (arg
, "24") == 0)
1240 return set_cpu_model ("f11");
1242 else if (strcmp (arg
, "34") == 0
1243 || strcmp (arg
, "34a") == 0)
1244 return set_cpu_model ("kd11e");
1246 else if (strcmp (arg
, "35") == 0
1247 || strcmp (arg
, "40") == 0)
1248 return set_cpu_model ("kd11da");
1250 else if (strcmp (arg
, "44") == 0)
1251 return set_cpu_model ("kd11dz");
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");
1259 else if (strcmp (arg
, "60") == 0)
1260 return set_cpu_model ("kd11k");
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");
1275 const char *md_shortopts
= "m:";
1277 struct option md_longopts
[] =
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 }
1288 size_t md_longopts_size
= sizeof (md_longopts
);
1290 /* Invocation line includes a switch not recognized by the base assembler.
1291 See if it's a processor-specific option. */
1294 md_parse_option (int c
, const char *arg
)
1301 if (set_option (arg
))
1303 if (set_cpu_model (arg
))
1305 if (set_machine_model (arg
))
1310 if (set_cpu_model (arg
))
1314 case OPTION_MACHINE
:
1315 if (set_machine_model (arg
))
1320 if (set_option ("pic"))
1332 md_show_usage (FILE *stream
)
1336 PDP-11 instruction set extensions:\n\
1338 -m(no-)cis allow (disallow) commercial instruction set\n\
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\
1352 -mno-extensions disallow all instruction set extensions\n\
1353 -pic generate position-independent code\n\
1355 PDP-11 CPU model options:\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\
1368 -mkd11z* KD11-Z CPU. enable full EIS, MTPS, MFPS, MFPT, SPL,\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\
1375 PDP-11 machine model options:\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\
1406 md_undefined_symbol (char *name ATTRIBUTE_UNUSED
)
1412 md_section_align (segT segment ATTRIBUTE_UNUSED
,
1415 return (size
+ 1) & ~1;
1419 md_pcrel_from (fixS
*fixP
)
1421 return fixP
->fx_frag
->fr_address
+ fixP
->fx_where
+ fixP
->fx_size
;
1424 /* Translate internal representation of relocation info to BFD target
1428 tc_gen_reloc (asection
*section ATTRIBUTE_UNUSED
,
1432 bfd_reloc_code_real_type code
;
1434 reloc
= XNEW (arelent
);
1436 reloc
->sym_ptr_ptr
= XNEW (asymbol
*);
1437 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
1438 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
1440 /* This is taken account for in md_apply_fix(). */
1441 reloc
->addend
= -symbol_get_bfdsym (fixp
->fx_addsy
)->section
->vma
;
1443 code
= fixp
->fx_r_type
;
1449 code
= BFD_RELOC_16_PCREL
;
1452 case BFD_RELOC_16_PCREL
:
1461 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, code
);
1463 if (reloc
->howto
== NULL
)
1465 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
1466 _("Can not represent %s relocation in this object file format"),
1467 bfd_get_reloc_code_name (code
));
1475 pseudo_bss (int c ATTRIBUTE_UNUSED
)
1479 temp
= get_absolute_expression ();
1480 subseg_set (bss_section
, temp
);
1481 demand_empty_rest_of_line ();
1485 pseudo_even (int c ATTRIBUTE_UNUSED
)
1487 int alignment
= 1; /* 2^1 */
1488 frag_align (alignment
, 0, 1);
1489 record_alignment (now_seg
, alignment
);
1493 md_atof (int type
, char * litP
, int * sizeP
)
1495 return vax_md_atof (type
, litP
, sizeP
);