1 /* tc-pdp11.c - pdp11-specific -
2 Copyright (C) 2001-2016 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 /* Commersial 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 anyones 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
)
252 case BFD_RELOC_16_PCREL
:
256 case BFD_RELOC_PDP11_DISP_8_PCREL
:
260 case BFD_RELOC_PDP11_DISP_6_PCREL
:
266 BAD_CASE (fixP
->fx_r_type
);
269 if (fixP
->fx_addsy
!= NULL
)
270 val
+= symbol_get_bfdsym (fixP
->fx_addsy
)->section
->vma
;
271 /* *value += fixP->fx_addsy->bsym->section->vma; */
274 code
|= (val
>> shift
) & mask
;
275 number_to_chars_littleendian (buf
, code
, size
);
277 if (fixP
->fx_addsy
== NULL
&& fixP
->fx_pcrel
== 0)
282 md_chars_to_number (con
, nbytes
)
283 unsigned char con
[]; /* Low order byte 1st. */
284 int nbytes
; /* Number of bytes in the input. */
286 /* On a PDP-11, 0x1234 is stored as "\x12\x34", and
287 0x12345678 is stored as "\x56\x78\x12\x34". It's
288 anyones guess what 0x123456 would be stored like. */
296 return (con
[1] << BITS_PER_CHAR
) | con
[0];
299 (((con
[1] << BITS_PER_CHAR
) | con
[0]) << (2 * BITS_PER_CHAR
))
300 |((con
[3] << BITS_PER_CHAR
) | con
[2]);
308 skip_whitespace (char *str
)
310 while (*str
== ' ' || *str
== '\t')
316 find_whitespace (char *str
)
318 while (*str
!= ' ' && *str
!= '\t' && *str
!= 0)
324 parse_reg (char *str
, struct pdp11_code
*operand
)
326 str
= skip_whitespace (str
);
327 if (TOLOWER (*str
) == 'r')
332 case '0': case '1': case '2': case '3':
333 case '4': case '5': case '6': case '7':
334 operand
->code
= *str
- '0';
338 operand
->error
= _("Bad register name");
342 else if (strncmp (str
, "sp", 2) == 0
343 || strncmp (str
, "SP", 2) == 0)
348 else if (strncmp (str
, "pc", 2) == 0
349 || strncmp (str
, "PC", 2) == 0)
356 operand
->error
= _("Bad register name");
364 parse_ac5 (char *str
, struct pdp11_code
*operand
)
366 str
= skip_whitespace (str
);
367 if (strncmp (str
, "fr", 2) == 0
368 || strncmp (str
, "FR", 2) == 0
369 || strncmp (str
, "ac", 2) == 0
370 || strncmp (str
, "AC", 2) == 0)
375 case '0': case '1': case '2': case '3':
377 operand
->code
= *str
- '0';
381 operand
->error
= _("Bad register name");
387 operand
->error
= _("Bad register name");
395 parse_ac (char *str
, struct pdp11_code
*operand
)
397 str
= parse_ac5 (str
, operand
);
398 if (!operand
->error
&& operand
->code
> 3)
400 operand
->error
= _("Bad register name");
408 parse_expression (char *str
, struct pdp11_code
*operand
)
410 char *save_input_line_pointer
;
413 save_input_line_pointer
= input_line_pointer
;
414 input_line_pointer
= str
;
415 seg
= expression (&operand
->reloc
.exp
);
418 input_line_pointer
= save_input_line_pointer
;
419 operand
->error
= _("Error in expression");
423 str
= input_line_pointer
;
424 input_line_pointer
= save_input_line_pointer
;
426 operand
->reloc
.pc_rel
= 0;
432 parse_op_no_deferred (char *str
, struct pdp11_code
*operand
)
434 LITTLENUM_TYPE literal_float
[2];
436 str
= skip_whitespace (str
);
440 case '(': /* (rn) and (rn)+ */
441 str
= parse_reg (str
+ 1, operand
);
444 str
= skip_whitespace (str
);
447 operand
->error
= _("Missing ')'");
453 operand
->code
|= 020;
458 operand
->code
|= 010;
465 str
= parse_expression (str
+ 1, operand
);
468 operand
->additional
= TRUE
;
469 operand
->word
= operand
->reloc
.exp
.X_add_number
;
470 switch (operand
->reloc
.exp
.X_op
)
477 operand
->reloc
.type
= BFD_RELOC_16
;
478 operand
->reloc
.pc_rel
= 0;
481 if (operand
->reloc
.exp
.X_add_number
> 0)
483 operand
->error
= _("Error in expression");
486 /* It's a floating literal... */
487 know (operand
->reloc
.exp
.X_add_number
< 0);
488 flonum_gen2vax ('f', &generic_floating_point_number
, literal_float
);
489 operand
->word
= literal_float
[0];
490 if (literal_float
[1] != 0)
491 as_warn (_("Low order bits truncated in immediate float operand"));
494 operand
->error
= _("Error in expression");
500 /* label, d(rn), -(rn) */
503 if (strncmp (str
, "-(", 2) == 0) /* -(rn) */
505 str
= parse_reg (str
+ 2, operand
);
508 str
= skip_whitespace (str
);
511 operand
->error
= _("Missing ')'");
514 operand
->code
|= 040;
519 str
= parse_expression (str
, operand
);
523 str
= skip_whitespace (str
);
528 operand
->additional
= 1;
530 operand
->reloc
.type
= BFD_RELOC_16_PCREL
;
531 operand
->reloc
.pc_rel
= 1;
537 str
= parse_reg (str
, operand
);
541 str
= skip_whitespace (str
);
545 operand
->error
= _("Missing ')'");
550 operand
->additional
= TRUE
;
551 operand
->code
|= 060;
552 switch (operand
->reloc
.exp
.X_op
)
555 operand
->reloc
.type
= BFD_RELOC_16
;
556 operand
->reloc
.pc_rel
= 0;
559 if ((operand
->code
& 7) == 7)
561 operand
->reloc
.pc_rel
= 1;
562 operand
->word
= operand
->reloc
.exp
.X_add_number
;
565 operand
->word
= operand
->reloc
.exp
.X_add_number
;
569 BAD_CASE (operand
->reloc
.exp
.X_op
);
579 parse_op_noreg (char *str
, struct pdp11_code
*operand
)
581 str
= skip_whitespace (str
);
582 operand
->error
= NULL
;
584 if (*str
== '@' || *str
== '*')
586 str
= parse_op_no_deferred (str
+ 1, operand
);
589 operand
->code
|= 010;
592 str
= parse_op_no_deferred (str
, operand
);
598 parse_op (char *str
, struct pdp11_code
*operand
)
600 str
= skip_whitespace (str
);
602 str
= parse_reg (str
, operand
);
606 operand
->error
= NULL
;
607 parse_ac5 (str
, operand
);
610 operand
->error
= _("Float AC not legal as integer operand");
614 return parse_op_noreg (str
, operand
);
618 parse_fop (char *str
, struct pdp11_code
*operand
)
620 str
= skip_whitespace (str
);
622 str
= parse_ac5 (str
, operand
);
626 operand
->error
= NULL
;
627 parse_reg (str
, operand
);
630 operand
->error
= _("General register not legal as float operand");
634 return parse_op_noreg (str
, operand
);
638 parse_separator (char *str
, int *error
)
640 str
= skip_whitespace (str
);
641 *error
= (*str
!= ',');
648 md_assemble (char *instruction_string
)
650 const struct pdp11_opcode
*op
;
651 struct pdp11_code insn
, op1
, op2
;
659 str
= skip_whitespace (instruction_string
);
660 p
= find_whitespace (str
);
663 as_bad (_("No instruction found"));
669 op
= (struct pdp11_opcode
*)hash_find (insn_hash
, str
);
673 as_bad (_("Unknown instruction '%s'"), str
);
677 if (!pdp11_extension
[op
->extension
])
679 as_warn (_("Unsupported instruction set extension: %s"), op
->name
);
684 insn
.code
= op
->opcode
;
685 insn
.reloc
.type
= BFD_RELOC_NONE
;
687 op1
.additional
= FALSE
;
688 op1
.reloc
.type
= BFD_RELOC_NONE
;
690 op2
.additional
= FALSE
;
691 op2
.reloc
.type
= BFD_RELOC_NONE
;
698 case PDP11_OPCODE_NO_OPS
:
699 str
= skip_whitespace (str
);
702 case PDP11_OPCODE_IMM3
:
703 case PDP11_OPCODE_IMM6
:
704 case PDP11_OPCODE_IMM8
:
705 str
= skip_whitespace (str
);
706 if (*str
== '#' || *str
== '$')
708 str
= parse_expression (str
, &op1
);
711 if (op1
.reloc
.exp
.X_op
!= O_constant
|| op1
.reloc
.type
!= BFD_RELOC_NONE
)
713 op1
.error
= _("operand is not an absolute constant");
718 case PDP11_OPCODE_IMM3
:
719 if (op1
.reloc
.exp
.X_add_number
& ~7)
721 op1
.error
= _("3-bit immediate out of range");
725 case PDP11_OPCODE_IMM6
:
726 if (op1
.reloc
.exp
.X_add_number
& ~0x3f)
728 op1
.error
= _("6-bit immediate out of range");
732 case PDP11_OPCODE_IMM8
:
733 if (op1
.reloc
.exp
.X_add_number
& ~0xff)
735 op1
.error
= _("8-bit immediate out of range");
740 insn
.code
|= op1
.reloc
.exp
.X_add_number
;
743 case PDP11_OPCODE_DISPL
:
746 new_pointer
= parse_expression (str
, &op1
);
748 op1
.reloc
.pc_rel
= 1;
749 op1
.reloc
.type
= BFD_RELOC_PDP11_DISP_8_PCREL
;
750 if (op1
.reloc
.exp
.X_op
!= O_symbol
)
752 op1
.error
= _("Symbol expected");
755 if (op1
.code
& ~0xff)
757 err
= _("8-bit displacement out of range");
761 insn
.code
|= op1
.code
;
762 insn
.reloc
= op1
.reloc
;
766 case PDP11_OPCODE_REG
:
767 str
= parse_reg (str
, &op1
);
770 insn
.code
|= op1
.code
;
773 case PDP11_OPCODE_OP
:
774 str
= parse_op (str
, &op1
);
777 insn
.code
|= op1
.code
;
782 case PDP11_OPCODE_FOP
:
783 str
= parse_fop (str
, &op1
);
786 insn
.code
|= op1
.code
;
791 case PDP11_OPCODE_REG_OP
:
792 str
= parse_reg (str
, &op2
);
795 insn
.code
|= op2
.code
<< 6;
796 str
= parse_separator (str
, &error
);
799 op2
.error
= _("Missing ','");
802 str
= parse_op (str
, &op1
);
805 insn
.code
|= op1
.code
;
810 case PDP11_OPCODE_REG_OP_REV
:
811 str
= parse_op (str
, &op1
);
814 insn
.code
|= op1
.code
;
817 str
= parse_separator (str
, &error
);
820 op2
.error
= _("Missing ','");
823 str
= parse_reg (str
, &op2
);
826 insn
.code
|= op2
.code
<< 6;
829 case PDP11_OPCODE_AC_FOP
:
830 str
= parse_ac (str
, &op2
);
833 insn
.code
|= op2
.code
<< 6;
834 str
= parse_separator (str
, &error
);
837 op1
.error
= _("Missing ','");
840 str
= parse_fop (str
, &op1
);
843 insn
.code
|= op1
.code
;
848 case PDP11_OPCODE_FOP_AC
:
849 str
= parse_fop (str
, &op1
);
852 insn
.code
|= op1
.code
;
855 str
= parse_separator (str
, &error
);
858 op1
.error
= _("Missing ','");
861 str
= parse_ac (str
, &op2
);
864 insn
.code
|= op2
.code
<< 6;
867 case PDP11_OPCODE_AC_OP
:
868 str
= parse_ac (str
, &op2
);
871 insn
.code
|= op2
.code
<< 6;
872 str
= parse_separator (str
, &error
);
875 op1
.error
= _("Missing ','");
878 str
= parse_op (str
, &op1
);
881 insn
.code
|= op1
.code
;
886 case PDP11_OPCODE_OP_AC
:
887 str
= parse_op (str
, &op1
);
890 insn
.code
|= op1
.code
;
893 str
= parse_separator (str
, &error
);
896 op1
.error
= _("Missing ','");
899 str
= parse_ac (str
, &op2
);
902 insn
.code
|= op2
.code
<< 6;
905 case PDP11_OPCODE_OP_OP
:
906 str
= parse_op (str
, &op1
);
909 insn
.code
|= op1
.code
<< 6;
912 str
= parse_separator (str
, &error
);
915 op2
.error
= _("Missing ','");
918 str
= parse_op (str
, &op2
);
921 insn
.code
|= op2
.code
;
926 case PDP11_OPCODE_REG_DISPL
:
929 str
= parse_reg (str
, &op2
);
932 insn
.code
|= op2
.code
<< 6;
933 str
= parse_separator (str
, &error
);
936 op1
.error
= _("Missing ','");
939 new_pointer
= parse_expression (str
, &op1
);
941 op1
.reloc
.pc_rel
= 1;
942 op1
.reloc
.type
= BFD_RELOC_PDP11_DISP_6_PCREL
;
943 if (op1
.reloc
.exp
.X_op
!= O_symbol
)
945 op1
.error
= _("Symbol expected");
948 if (op1
.code
& ~0x3f)
950 err
= _("6-bit displacement out of range");
954 insn
.code
|= op1
.code
;
955 insn
.reloc
= op1
.reloc
;
969 str
= skip_whitespace (str
);
971 err
= _("Too many operands");
983 to
= frag_more (size
);
985 md_number_to_chars (to
, insn
.code
, 2);
986 if (insn
.reloc
.type
!= BFD_RELOC_NONE
)
987 fix_new_exp (frag_now
, to
- frag_now
->fr_literal
, 2,
988 &insn
.reloc
.exp
, insn
.reloc
.pc_rel
, insn
.reloc
.type
);
993 md_number_to_chars (to
, op1
.word
, 2);
994 if (op1
.reloc
.type
!= BFD_RELOC_NONE
)
995 fix_new_exp (frag_now
, to
- frag_now
->fr_literal
, 2,
996 &op1
.reloc
.exp
, op1
.reloc
.pc_rel
, op1
.reloc
.type
);
1002 md_number_to_chars (to
, op2
.word
, 2);
1003 if (op2
.reloc
.type
!= BFD_RELOC_NONE
)
1004 fix_new_exp (frag_now
, to
- frag_now
->fr_literal
, 2,
1005 &op2
.reloc
.exp
, op2
.reloc
.pc_rel
, op2
.reloc
.type
);
1011 md_estimate_size_before_relax (fragS
*fragP ATTRIBUTE_UNUSED
,
1012 segT segment ATTRIBUTE_UNUSED
)
1018 md_convert_frag (bfd
*headers ATTRIBUTE_UNUSED
,
1019 segT seg ATTRIBUTE_UNUSED
,
1020 fragS
*fragP ATTRIBUTE_UNUSED
)
1024 int md_short_jump_size
= 2;
1025 int md_long_jump_size
= 4;
1028 md_create_short_jump (char *ptr ATTRIBUTE_UNUSED
,
1029 addressT from_addr ATTRIBUTE_UNUSED
,
1030 addressT to_addr ATTRIBUTE_UNUSED
,
1031 fragS
*frag ATTRIBUTE_UNUSED
,
1032 symbolS
*to_symbol ATTRIBUTE_UNUSED
)
1037 md_create_long_jump (char *ptr ATTRIBUTE_UNUSED
,
1038 addressT from_addr ATTRIBUTE_UNUSED
,
1039 addressT to_addr ATTRIBUTE_UNUSED
,
1040 fragS
*frag ATTRIBUTE_UNUSED
,
1041 symbolS
*to_symbol ATTRIBUTE_UNUSED
)
1046 set_cpu_model (const char *arg
)
1056 if (strchr ("abdx", model
[-1]) == NULL
)
1059 if (model
[-1] == 'd')
1061 if (arg
[0] == 'f' || arg
[0] == 'j')
1064 else if (model
[-1] == 'x')
1073 if (strncmp (arg
, "11", 2) != 0)
1083 /* Allow up to two revision letters. */
1091 set_option ("no-extensions");
1093 /* KA11 (11/15/20). */
1094 if (strncmp (buf
, "a", 1) == 0)
1095 return 1; /* No extensions. */
1097 /* KB11 (11/45/50/55/70). */
1098 else if (strncmp (buf
, "b", 1) == 0)
1099 return set_option ("eis") && set_option ("spl");
1101 /* KD11-A (11/35/40). */
1102 else if (strncmp (buf
, "da", 2) == 0)
1103 return set_option ("limited-eis");
1105 /* KD11-B (11/05/10). */
1106 else if (strncmp (buf
, "db", 2) == 0
1107 /* KD11-D (11/04). */
1108 || strncmp (buf
, "dd", 2) == 0)
1109 return 1; /* no extensions */
1111 /* KD11-E (11/34). */
1112 else if (strncmp (buf
, "de", 2) == 0)
1113 return set_option ("eis") && set_option ("mxps");
1115 /* KD11-F (11/03). */
1116 else if (strncmp (buf
, "df", 2) == 0
1117 /* KD11-H (11/03). */
1118 || strncmp (buf
, "dh", 2) == 0
1119 /* KD11-Q (11/03). */
1120 || strncmp (buf
, "dq", 2) == 0)
1121 return set_option ("limited-eis") && set_option ("mxps");
1123 /* KD11-K (11/60). */
1124 else if (strncmp (buf
, "dk", 2) == 0)
1125 return set_option ("eis")
1126 && set_option ("mxps")
1127 && set_option ("ucode");
1129 /* KD11-Z (11/44). */
1130 else if (strncmp (buf
, "dz", 2) == 0)
1131 return set_option ("csm")
1132 && set_option ("eis")
1133 && set_option ("mfpt")
1134 && set_option ("mxps")
1135 && set_option ("spl");
1137 /* F11 (11/23/24). */
1138 else if (strncmp (buf
, "f", 1) == 0)
1139 return set_option ("eis")
1140 && set_option ("mfpt")
1141 && set_option ("mxps");
1143 /* J11 (11/53/73/83/84/93/94). */
1144 else if (strncmp (buf
, "j", 1) == 0)
1145 return set_option ("csm")
1146 && set_option ("eis")
1147 && set_option ("mfpt")
1148 && set_option ("multiproc")
1149 && set_option ("mxps")
1150 && set_option ("spl");
1153 else if (strncmp (buf
, "t", 1) == 0)
1154 return set_option ("limited-eis")
1155 && set_option ("mxps");
1162 set_machine_model (const char *arg
)
1164 if (strncmp (arg
, "pdp-11/", 7) != 0
1165 && strncmp (arg
, "pdp11/", 6) != 0
1166 && strncmp (arg
, "11/", 3) != 0)
1169 if (strncmp (arg
, "pdp", 3) == 0)
1173 if (strncmp (arg
, "11/", 3) == 0)
1176 if (strcmp (arg
, "03") == 0)
1177 return set_cpu_model ("kd11f");
1179 else if (strcmp (arg
, "04") == 0)
1180 return set_cpu_model ("kd11d");
1182 else if (strcmp (arg
, "05") == 0
1183 || strcmp (arg
, "10") == 0)
1184 return set_cpu_model ("kd11b");
1186 else if (strcmp (arg
, "15") == 0
1187 || strcmp (arg
, "20") == 0)
1188 return set_cpu_model ("ka11");
1190 else if (strcmp (arg
, "21") == 0)
1191 return set_cpu_model ("t11");
1193 else if (strcmp (arg
, "23") == 0
1194 || strcmp (arg
, "24") == 0)
1195 return set_cpu_model ("f11");
1197 else if (strcmp (arg
, "34") == 0
1198 || strcmp (arg
, "34a") == 0)
1199 return set_cpu_model ("kd11e");
1201 else if (strcmp (arg
, "35") == 0
1202 || strcmp (arg
, "40") == 0)
1203 return set_cpu_model ("kd11da");
1205 else if (strcmp (arg
, "44") == 0)
1206 return set_cpu_model ("kd11dz");
1208 else if (strcmp (arg
, "45") == 0
1209 || strcmp (arg
, "50") == 0
1210 || strcmp (arg
, "55") == 0
1211 || strcmp (arg
, "70") == 0)
1212 return set_cpu_model ("kb11");
1214 else if (strcmp (arg
, "60") == 0)
1215 return set_cpu_model ("kd11k");
1217 else if (strcmp (arg
, "53") == 0
1218 || strcmp (arg
, "73") == 0
1219 || strcmp (arg
, "83") == 0
1220 || strcmp (arg
, "84") == 0
1221 || strcmp (arg
, "93") == 0
1222 || strcmp (arg
, "94") == 0)
1223 return set_cpu_model ("j11")
1224 && set_option ("fpp");
1230 const char *md_shortopts
= "m:";
1232 struct option md_longopts
[] =
1234 #define OPTION_CPU 257
1235 { "cpu", required_argument
, NULL
, OPTION_CPU
},
1236 #define OPTION_MACHINE 258
1237 { "machine", required_argument
, NULL
, OPTION_MACHINE
},
1238 #define OPTION_PIC 259
1239 { "pic", no_argument
, NULL
, OPTION_PIC
},
1240 { NULL
, no_argument
, NULL
, 0 }
1243 size_t md_longopts_size
= sizeof (md_longopts
);
1245 /* Invocation line includes a switch not recognized by the base assembler.
1246 See if it's a processor-specific option. */
1249 md_parse_option (int c
, const char *arg
)
1256 if (set_option (arg
))
1258 if (set_cpu_model (arg
))
1260 if (set_machine_model (arg
))
1265 if (set_cpu_model (arg
))
1269 case OPTION_MACHINE
:
1270 if (set_machine_model (arg
))
1275 if (set_option ("pic"))
1287 md_show_usage (FILE *stream
)
1291 PDP-11 instruction set extentions:\n\
1293 -m(no-)cis allow (disallow) commersial instruction set\n\
1294 -m(no-)csm allow (disallow) CSM instruction\n\
1295 -m(no-)eis allow (disallow) full extended instruction set\n\
1296 -m(no-)fis allow (disallow) KEV11 floating-point instructions\n\
1297 -m(no-)fpp allow (disallow) FP-11 floating-point instructions\n\
1298 -m(no-)fpu allow (disallow) FP-11 floating-point instructions\n\
1299 -m(no-)limited-eis allow (disallow) limited extended instruction set\n\
1300 -m(no-)mfpt allow (disallow) processor type instruction\n\
1301 -m(no-)multiproc allow (disallow) multiprocessor instructions\n\
1302 -m(no-)mxps allow (disallow) processor status instructions\n\
1303 -m(no-)spl allow (disallow) SPL instruction\n\
1304 -m(no-)ucode allow (disallow) microcode instructions\n\
1305 -mall-extensions allow all instruction set extensions\n\
1306 (this is the default)\n\
1307 -mno-extentions disallow all instruction set extensions\n\
1308 -pic generate position-indepenent code\n\
1310 PDP-11 CPU model options:\n\
1312 -mka11* KA11 CPU. base line instruction set only\n\
1313 -mkb11* KB11 CPU. enable full EIS and SPL\n\
1314 -mkd11a* KD11-A CPU. enable limited EIS\n\
1315 -mkd11b* KD11-B CPU. base line instruction set only\n\
1316 -mkd11d* KD11-D CPU. base line instruction set only\n\
1317 -mkd11e* KD11-E CPU. enable full EIS, MTPS, and MFPS\n\
1318 -mkd11f* KD11-F CPU. enable limited EIS, MTPS, and MFPS\n\
1319 -mkd11h* KD11-H CPU. enable limited EIS, MTPS, and MFPS\n\
1320 -mkd11q* KD11-Q CPU. enable limited EIS, MTPS, and MFPS\n\
1321 -mkd11k* KD11-K CPU. enable full EIS, MTPS, MFPS, LDUB, MED,\n\
1323 -mkd11z* KD11-Z CPU. enable full EIS, MTPS, MFPS, MFPT, SPL,\n\
1325 -mf11* F11 CPU. enable full EIS, MFPS, MTPS, and MFPT\n\
1326 -mj11* J11 CPU. enable full EIS, MTPS, MFPS, MFPT, SPL,\n\
1327 CSM, TSTSET, and WRTLCK\n\
1328 -mt11* T11 CPU. enable limited EIS, MTPS, and MFPS\n\
1330 PDP-11 machine model options:\n\
1332 -m11/03 same as -mkd11f\n\
1333 -m11/04 same as -mkd11d\n\
1334 -m11/05 same as -mkd11b\n\
1335 -m11/10 same as -mkd11b\n\
1336 -m11/15 same as -mka11\n\
1337 -m11/20 same as -mka11\n\
1338 -m11/21 same as -mt11\n\
1339 -m11/23 same as -mf11\n\
1340 -m11/24 same as -mf11\n\
1341 -m11/34 same as -mkd11e\n\
1342 -m11/34a same as -mkd11e -mfpp\n\
1343 -m11/35 same as -mkd11a\n\
1344 -m11/40 same as -mkd11a\n\
1345 -m11/44 same as -mkd11z\n\
1346 -m11/45 same as -mkb11\n\
1347 -m11/50 same as -mkb11\n\
1348 -m11/53 same as -mj11\n\
1349 -m11/55 same as -mkb11\n\
1350 -m11/60 same as -mkd11k\n\
1351 -m11/70 same as -mkb11\n\
1352 -m11/73 same as -mj11\n\
1353 -m11/83 same as -mj11\n\
1354 -m11/84 same as -mj11\n\
1355 -m11/93 same as -mj11\n\
1356 -m11/94 same as -mj11\n\
1361 md_undefined_symbol (char *name ATTRIBUTE_UNUSED
)
1367 md_section_align (segT segment ATTRIBUTE_UNUSED
,
1370 return (size
+ 1) & ~1;
1374 md_pcrel_from (fixS
*fixP
)
1376 return fixP
->fx_frag
->fr_address
+ fixP
->fx_where
+ fixP
->fx_size
;
1379 /* Translate internal representation of relocation info to BFD target
1383 tc_gen_reloc (asection
*section ATTRIBUTE_UNUSED
,
1387 bfd_reloc_code_real_type code
;
1389 reloc
= xmalloc (sizeof (* reloc
));
1391 reloc
->sym_ptr_ptr
= xmalloc (sizeof (asymbol
*));
1392 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
1393 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
1395 /* This is taken account for in md_apply_fix(). */
1396 reloc
->addend
= -symbol_get_bfdsym (fixp
->fx_addsy
)->section
->vma
;
1398 switch (fixp
->fx_r_type
)
1402 code
= BFD_RELOC_16_PCREL
;
1404 code
= BFD_RELOC_16
;
1407 case BFD_RELOC_16_PCREL
:
1408 code
= BFD_RELOC_16_PCREL
;
1412 BAD_CASE (fixp
->fx_r_type
);
1416 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, code
);
1418 if (reloc
->howto
== NULL
)
1420 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
1421 _("Can not represent %s relocation in this object file format"),
1422 bfd_get_reloc_code_name (code
));
1430 pseudo_bss (int c ATTRIBUTE_UNUSED
)
1434 temp
= get_absolute_expression ();
1435 subseg_set (bss_section
, temp
);
1436 demand_empty_rest_of_line ();
1440 pseudo_even (int c ATTRIBUTE_UNUSED
)
1442 int alignment
= 1; /* 2^1 */
1443 frag_align (alignment
, 0, 1);
1444 record_alignment (now_seg
, alignment
);
1448 md_atof (int type
, char * litP
, int * sizeP
)
1450 return vax_md_atof (type
, litP
, sizeP
);