1 /* tc-pdp11.c - pdp11-specific -
2 Copyright 2001 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 2, 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
21 Apparently unused functions:
23 md_estimate_size_before_relax
29 #include "safe-ctype.h"
30 #include "opcode/pdp11.h"
32 static int set_option
PARAMS ((char *arg
));
33 static int set_cpu_model
PARAMS ((char *arg
));
34 static int set_machine_model
PARAMS ((char *arg
));
40 * A representation for PDP-11 machine code.
46 int additional
; /* is there an additional word? */
47 int word
; /* additional word, if any */
50 bfd_reloc_code_real_type type
;
57 * Instruction set extensions.
59 * If you change this from an array to something else, please update
60 * the "PDP-11 instruction set extensions" comment in pdp11.h.
62 int pdp11_extension
[PDP11_EXT_NUM
];
71 int asm_option
[ASM_OPT_NUM
];
73 /* These chars start a comment anywhere in a source file (except inside
75 CONST
char comment_chars
[] = "#/";
77 /* These chars only start a comment at the beginning of a line. */
78 CONST
char line_comment_chars
[] = "#/";
80 CONST
char line_separator_chars
[] = ";";
82 /* Chars that can be used to separate mant from exp in floating point nums */
83 CONST
char EXP_CHARS
[] = "eE";
85 /* Chars that mean this number is a floating point constant */
87 /* or 0H1.234E-12 (see exp chars above) */
88 CONST
char FLT_CHARS
[] = "dDfFgGhH";
90 void pseudo_even (int);
91 void pseudo_bss (int);
93 CONST pseudo_typeS md_pseudo_table
[] =
95 { "bss", pseudo_bss
, 0 },
96 { "even", pseudo_even
, 0 },
103 static int first
= 1;
107 set_option ("all-extensions");
113 static struct hash_control
*insn_hash
= NULL
;
122 insn_hash
= hash_new ();
123 if (insn_hash
== NULL
)
124 as_fatal ("Virtual memory exhausted");
126 for (i
= 0; i
< pdp11_num_opcodes
; i
++)
127 hash_insert (insn_hash
, pdp11_opcodes
[i
].name
, (PTR
)(pdp11_opcodes
+ i
));
128 for (i
= 0; i
< pdp11_num_aliases
; i
++)
129 hash_insert (insn_hash
, pdp11_aliases
[i
].name
, (PTR
)(pdp11_aliases
+ i
));
133 md_number_to_chars (con
, value
, nbytes
)
138 /* On a PDP-11, 0x1234 is stored as "\x12\x34", and
139 * 0x12345678 is stored as "\x56\x78\x12\x34". It's
140 * anyones guess what 0x123456 would be stored like.
148 con
[0] = value
& 0xff;
151 con
[0] = value
& 0xff;
152 con
[1] = (value
>> 8) & 0xff;
155 con
[0] = (value
>> 16) & 0xff;
156 con
[1] = (value
>> 24) & 0xff;
157 con
[2] = value
& 0xff;
158 con
[3] = (value
>> 8) & 0xff;
165 /* Fix up some data or instructions after we find out the value of a symbol
166 that they reference. */
168 int /* Knows about order of bytes in address. */
169 md_apply_fix (fixP
, value
)
179 buf
= fixP
->fx_where
+ fixP
->fx_frag
->fr_literal
;
180 size
= fixP
->fx_size
;
181 code
= md_chars_to_number (buf
, size
);
183 switch (fixP
->fx_r_type
)
186 case BFD_RELOC_16_PCREL
:
190 case BFD_RELOC_PDP11_DISP_8_PCREL
:
194 case BFD_RELOC_PDP11_DISP_6_PCREL
:
199 BAD_CASE (fixP
->fx_r_type
);
202 if (fixP
->fx_addsy
!= NULL
)
203 *value
+= symbol_get_bfdsym (fixP
->fx_addsy
)->section
->vma
;
204 /* *value += fixP->fx_addsy->bsym->section->vma; */
207 code
|= (*value
>> shift
) & mask
;
208 number_to_chars_littleendian (buf
, code
, size
);
213 md_chars_to_number (con
, nbytes
)
214 unsigned char con
[]; /* Low order byte 1st. */
215 int nbytes
; /* Number of bytes in the input. */
217 /* On a PDP-11, 0x1234 is stored as "\x12\x34", and
218 * 0x12345678 is stored as "\x56\x78\x12\x34". It's
219 * anyones guess what 0x123456 would be stored like.
229 return (con
[1] << BITS_PER_CHAR
) | con
[0];
232 (((con
[1] << BITS_PER_CHAR
) | con
[0]) << (2 * BITS_PER_CHAR
)) |
233 ((con
[3] << BITS_PER_CHAR
) | con
[2]);
241 skip_whitespace (char *str
)
243 while (*str
== ' ' || *str
== '\t')
249 find_whitespace (char *str
)
251 while (*str
!= ' ' && *str
!= '\t' && *str
!= 0)
257 parse_reg (char *str
, struct pdp11_code
*operand
)
259 str
= skip_whitespace (str
);
260 if (TOLOWER (*str
) == 'r')
265 case '0': case '1': case '2': case '3':
266 case '4': case '5': case '6': case '7':
267 operand
->code
= *str
- '0';
271 operand
->error
= "Bad register name";
275 else if (strncmp (str
, "sp", 2) == 0 ||
276 strncmp (str
, "SP", 2) == 0)
281 else if (strncmp (str
, "pc", 2) == 0 ||
282 strncmp (str
, "PC", 2) == 0)
289 operand
->error
= "Bad register name";
297 parse_ac (char *str
, struct pdp11_code
*operand
)
299 str
= skip_whitespace (str
);
300 if (strncmp (str
, "fr", 2) == 0 ||
301 strncmp (str
, "FR", 2) == 0 ||
302 strncmp (str
, "ac", 2) == 0 ||
303 strncmp (str
, "AC", 2) == 0)
308 case '0': case '1': case '2': case '3':
309 operand
->code
= *str
- '0';
313 operand
->error
= "Bad register name";
319 operand
->error
= "Bad register name";
327 parse_expression (char *str
, struct pdp11_code
*operand
)
329 char *save_input_line_pointer
;
332 save_input_line_pointer
= input_line_pointer
;
333 input_line_pointer
= str
;
334 seg
= expression (&operand
->reloc
.exp
);
337 input_line_pointer
= save_input_line_pointer
;
338 operand
->error
= "Error in expression";
342 str
= input_line_pointer
;
343 input_line_pointer
= save_input_line_pointer
;
345 operand
->reloc
.pc_rel
= 0;
347 if (operand
->reloc
.exp
.X_op
== O_constant
)
353 /* FIXME: buffer overflow! */
357 sprintf (buf
, "%ld", operand
->reloc
.exp
.X_add_number
);
358 operand
->reloc
.exp
.X_add_number
= strtol (buf
, &end
, 8);
366 parse_op_no_deferred (char *str
, struct pdp11_code
*operand
)
368 str
= skip_whitespace (str
);
372 case '(': /* (rn) and (rn)+ */
373 str
= parse_reg (str
+ 1, operand
);
376 str
= skip_whitespace (str
);
379 operand
->error
= "Missing ')'";
385 operand
->code
|= 020;
390 operand
->code
|= 010;
394 case '#': /* immediate */
396 str
= parse_expression (str
+ 1, operand
);
399 operand
->additional
= TRUE
;
400 operand
->word
= operand
->reloc
.exp
.X_add_number
;
401 switch (operand
->reloc
.exp
.X_op
)
408 operand
->reloc
.type
= BFD_RELOC_16
;
409 operand
->reloc
.pc_rel
= 0;
412 operand
->error
= "Error in expression";
418 default: /* label, d(rn), -(rn) */
422 if (strncmp (str
, "-(", 2) == 0) /* -(rn) */
424 str
= parse_reg (str
+ 2, operand
);
427 str
= skip_whitespace (str
);
430 operand
->error
= "Missing ')'";
433 operand
->code
|= 040;
438 str
= parse_expression (str
, operand
);
442 str
= skip_whitespace (str
);
444 if (*str
!= '(') /* label */
446 if (operand
->reloc
.exp
.X_op
!= O_symbol
)
448 operand
->error
= "Label expected";
452 operand
->additional
= 1;
454 operand
->reloc
.type
= BFD_RELOC_16_PCREL
;
455 operand
->reloc
.pc_rel
= 1;
460 str
= parse_reg (str
, operand
);
464 str
= skip_whitespace (str
);
468 operand
->error
= "Missing ')'";
473 operand
->additional
= TRUE
;
474 operand
->code
|= 060;
475 switch (operand
->reloc
.exp
.X_op
)
479 operand
->reloc
.pc_rel
= 1;
482 if ((operand
->code
& 7) == 7)
484 operand
->reloc
.pc_rel
= 1;
485 operand
->word
= operand
->reloc
.exp
.X_add_number
;
489 operand
->word
= operand
->reloc
.exp
.X_add_number
;
493 BAD_CASE (operand
->reloc
.exp
.X_op
);
503 parse_op (char *str
, struct pdp11_code
*operand
)
505 str
= skip_whitespace (str
);
507 str
= parse_reg (str
, operand
);
510 operand
->error
= NULL
;
512 if (*str
== '@' || *str
== '*')
514 str
= parse_op_no_deferred (str
+ 1, operand
);
517 operand
->code
|= 010;
520 str
= parse_op_no_deferred (str
, operand
);
526 parse_separator (char *str
, int *error
)
528 str
= skip_whitespace (str
);
529 *error
= (*str
!= ',');
536 md_assemble (instruction_string
)
537 char *instruction_string
;
539 CONST
struct pdp11_opcode
*op
;
540 struct pdp11_code insn
, op1
, op2
;
548 str
= skip_whitespace (instruction_string
);
549 p
= find_whitespace (str
);
552 as_bad ("No instruction found");
558 op
= (struct pdp11_opcode
*)hash_find (insn_hash
, str
);
564 op1
.additional
= FALSE
;
565 op1
.reloc
.type
= BFD_RELOC_NONE
;
568 str
= parse_expression (str
, &op1
);
576 char *to
= frag_more (2);
578 md_number_to_chars (to
, op1
.code
, 2);
579 if (insn
.reloc
.type
!= BFD_RELOC_NONE
)
580 fix_new_exp (frag_now
, to
- frag_now
->fr_literal
, 2,
581 &insn
.reloc
.exp
, insn
.reloc
.pc_rel
, insn
.reloc
.type
);
584 as_warn ("Unknown instruction");
590 if (!pdp11_extension
[op
->extension
])
592 as_warn ("Unsupported instruction set extension: %s", op
->name
);
597 insn
.code
= op
->opcode
;
598 insn
.reloc
.type
= BFD_RELOC_NONE
;
600 op1
.additional
= FALSE
;
601 op1
.reloc
.type
= BFD_RELOC_NONE
;
603 op2
.additional
= FALSE
;
604 op2
.reloc
.type
= BFD_RELOC_NONE
;
611 case PDP11_OPCODE_NO_OPS
:
612 str
= skip_whitespace (str
);
617 case PDP11_OPCODE_IMM3
:
618 case PDP11_OPCODE_IMM6
:
619 case PDP11_OPCODE_IMM8
:
620 str
= skip_whitespace (str
);
621 if (*str
== '#' || *str
== '$')
623 str
= parse_expression (str
, &op1
);
628 case PDP11_OPCODE_IMM3
:
631 op1
.error
= "3-bit immediate out of range";
635 case PDP11_OPCODE_IMM6
:
636 if (op1
.code
& ~0x3f)
638 op1
.error
= "6-bit immediate out of range";
642 case PDP11_OPCODE_IMM8
:
643 if (op1
.code
& ~0xff)
645 op1
.error
= "8-bit immediate out of range";
650 insn
.code
|= op1
.code
;
653 case PDP11_OPCODE_DISPL
:
656 new = parse_expression (str
, &op1
);
658 op1
.reloc
.pc_rel
= 1;
659 op1
.reloc
.type
= BFD_RELOC_PDP11_DISP_8_PCREL
;
660 if (op1
.reloc
.exp
.X_op
!= O_symbol
)
662 op1
.error
= "Symbol expected";
665 if (op1
.code
& ~0xff)
667 err
= "8-bit displacement out of range";
671 insn
.code
|= op1
.code
;
672 insn
.reloc
= op1
.reloc
;
676 case PDP11_OPCODE_REG
:
677 str
= parse_reg (str
, &op1
);
680 insn
.code
|= op1
.code
;
683 case PDP11_OPCODE_OP
:
684 str
= parse_op (str
, &op1
);
687 insn
.code
|= op1
.code
;
692 case PDP11_OPCODE_REG_OP
:
693 str
= parse_reg (str
, &op2
);
696 insn
.code
|= op2
.code
<< 6;
697 str
= parse_separator (str
, &error
);
700 op2
.error
= "Missing ','";
703 str
= parse_op (str
, &op1
);
706 insn
.code
|= op1
.code
;
711 case PDP11_OPCODE_REG_OP_REV
:
712 str
= parse_op (str
, &op1
);
715 insn
.code
|= op1
.code
;
718 str
= parse_separator (str
, &error
);
721 op2
.error
= "Missing ','";
724 str
= parse_reg (str
, &op2
);
727 insn
.code
|= op2
.code
<< 6;
730 case PDP11_OPCODE_AC_OP
:
731 str
= parse_ac (str
, &op2
);
734 insn
.code
|= op2
.code
<< 6;
735 str
= parse_separator (str
, &error
);
738 op1
.error
= "Missing ','";
741 str
= parse_op (str
, &op1
);
744 insn
.code
|= op1
.code
;
749 case PDP11_OPCODE_OP_OP
:
750 str
= parse_op (str
, &op1
);
753 insn
.code
|= op1
.code
<< 6;
756 str
= parse_separator (str
, &error
);
759 op2
.error
= "Missing ','";
762 str
= parse_op (str
, &op2
);
765 insn
.code
|= op2
.code
;
770 case PDP11_OPCODE_REG_DISPL
:
773 str
= parse_reg (str
, &op2
);
776 insn
.code
|= op2
.code
<< 6;
777 str
= parse_separator (str
, &error
);
780 op1
.error
= "Missing ','";
783 new = parse_expression (str
, &op1
);
785 op1
.reloc
.pc_rel
= 1;
786 op1
.reloc
.type
= BFD_RELOC_PDP11_DISP_6_PCREL
;
787 if (op1
.reloc
.exp
.X_op
!= O_symbol
)
789 op1
.error
= "Symbol expected";
792 if (op1
.code
& ~0x3f)
794 err
= "6-bit displacement out of range";
798 insn
.code
|= op1
.code
;
799 insn
.reloc
= op1
.reloc
;
813 str
= skip_whitespace (str
);
815 err
= "Too many operands";
827 to
= frag_more (size
);
829 md_number_to_chars (to
, insn
.code
, 2);
830 if (insn
.reloc
.type
!= BFD_RELOC_NONE
)
831 fix_new_exp (frag_now
, to
- frag_now
->fr_literal
, 2,
832 &insn
.reloc
.exp
, insn
.reloc
.pc_rel
, insn
.reloc
.type
);
837 md_number_to_chars (to
, op1
.word
, 2);
838 if (op1
.reloc
.type
!= BFD_RELOC_NONE
)
839 fix_new_exp (frag_now
, to
- frag_now
->fr_literal
, 2,
840 &op1
.reloc
.exp
, op1
.reloc
.pc_rel
, op1
.reloc
.type
);
846 md_number_to_chars (to
, op2
.word
, 2);
847 if (op2
.reloc
.type
!= BFD_RELOC_NONE
)
848 fix_new_exp (frag_now
, to
- frag_now
->fr_literal
, 2,
849 &op2
.reloc
.exp
, op2
.reloc
.pc_rel
, op2
.reloc
.type
);
855 md_estimate_size_before_relax (fragP
, segment
)
856 fragS
*fragP ATTRIBUTE_UNUSED
;
857 segT segment ATTRIBUTE_UNUSED
;
863 md_convert_frag (headers
, seg
, fragP
)
864 bfd
*headers ATTRIBUTE_UNUSED
;
865 segT seg ATTRIBUTE_UNUSED
;
866 fragS
*fragP ATTRIBUTE_UNUSED
;
870 CONST
int md_short_jump_size
= 2;
871 CONST
int md_long_jump_size
= 4;
874 md_create_short_jump (ptr
, from_addr
, to_addr
, frag
, to_symbol
)
875 char *ptr ATTRIBUTE_UNUSED
;
876 addressT from_addr ATTRIBUTE_UNUSED
;
877 addressT to_addr ATTRIBUTE_UNUSED
;
878 fragS
*frag ATTRIBUTE_UNUSED
;
879 symbolS
*to_symbol ATTRIBUTE_UNUSED
;
884 md_create_long_jump (ptr
, from_addr
, to_addr
, frag
, to_symbol
)
885 char *ptr ATTRIBUTE_UNUSED
;
886 addressT from_addr ATTRIBUTE_UNUSED
;
887 addressT to_addr ATTRIBUTE_UNUSED
;
888 fragS
*frag ATTRIBUTE_UNUSED
;
889 symbolS
*to_symbol ATTRIBUTE_UNUSED
;
899 if (strcmp (arg
, "all-extensions") == 0 ||
900 strcmp (arg
, "all") == 0)
902 memset (pdp11_extension
, ~0, sizeof pdp11_extension
);
903 pdp11_extension
[PDP11_NONE
] = 0;
906 else if (strcmp (arg
, "no-extensions") == 0)
908 memset (pdp11_extension
, 0, sizeof pdp11_extension
);
909 pdp11_extension
[PDP11_BASIC
] = 1;
913 if (strncmp (arg
, "no-", 3) == 0)
919 if (strcmp (arg
, "cis") == 0) /* commersial instructions */
920 pdp11_extension
[PDP11_CIS
] = yes
;
921 else if (strcmp (arg
, "csm") == 0) /* call supervisor mode */
922 pdp11_extension
[PDP11_CSM
] = yes
;
923 else if (strcmp (arg
, "eis") == 0) /* extended instruction set */
924 pdp11_extension
[PDP11_EIS
] = pdp11_extension
[PDP11_LEIS
] = yes
;
925 else if (strcmp (arg
, "fis") == 0 || /* KEV11 floating-point */
926 strcmp (arg
, "kev11") == 0 ||
927 strcmp (arg
, "kev-11") == 0)
928 pdp11_extension
[PDP11_FIS
] = yes
;
929 else if (strcmp (arg
, "fpp") == 0 || /* FP-11 floating-point */
930 strcmp (arg
, "fpu") == 0 ||
931 strcmp (arg
, "fp11") == 0 ||
932 strcmp (arg
, "fp-11") == 0 ||
933 strcmp (arg
, "fpj11") == 0 ||
934 strcmp (arg
, "fp-j11") == 0 ||
935 strcmp (arg
, "fpj-11") == 0)
936 pdp11_extension
[PDP11_FPP
] = yes
;
937 else if (strcmp (arg
, "limited-eis") == 0) /* limited extended insns */
939 pdp11_extension
[PDP11_LEIS
] = yes
;
940 if (!pdp11_extension
[PDP11_LEIS
])
941 pdp11_extension
[PDP11_EIS
] = 0;
943 else if (strcmp (arg
, "mfpt") == 0) /* move from processor type */
944 pdp11_extension
[PDP11_MFPT
] = yes
;
945 else if (strncmp (arg
, "mproc", 5) == 0 || /* multiprocessor insns: */
946 strncmp (arg
, "multiproc", 9) == 0 ) /* TSTSET, WRTLCK */
947 pdp11_extension
[PDP11_MPROC
] = yes
;
948 else if (strcmp (arg
, "mxps") == 0) /* move from/to proc status */
949 pdp11_extension
[PDP11_MXPS
] = yes
;
950 else if (strcmp (arg
, "pic") == 0) /* position-independent code */
951 asm_option
[ASM_OPT_PIC
] = yes
;
952 else if (strcmp (arg
, "spl") == 0) /* set priority level */
953 pdp11_extension
[PDP11_SPL
] = yes
;
954 else if (strcmp (arg
, "ucode") == 0 || /* microcode instructions: */
955 strcmp (arg
, "microcode") == 0) /* LDUB, MED, XFC */
956 pdp11_extension
[PDP11_UCODE
] = yes
;
975 if (strchr ("abdx", model
[-1]) == NULL
)
978 if (model
[-1] == 'd')
984 else if (model
[-1] == 'x')
993 if (strncmp (arg
, "11", 2) != 0)
1003 /* allow up to two revision letters */
1011 set_option ("no-extensions");
1013 if (strncmp (buf
, "a", 1) == 0) /* KA11 (11/15/20) */
1014 return 1; /* no extensions */
1016 else if (strncmp (buf
, "b", 1) == 0) /* KB11 (11/45/50/55/70) */
1017 return set_option ("eis") &&
1020 else if (strncmp (buf
, "da", 2) == 0) /* KD11-A (11/35/40) */
1021 return set_option ("limited-eis");
1023 else if (strncmp (buf
, "db", 2) == 0 || /* KD11-B (11/05/10) */
1024 strncmp (buf
, "dd", 2) == 0) /* KD11-D (11/04) */
1025 return 1; /* no extensions */
1027 else if (strncmp (buf
, "de", 2) == 0) /* KD11-E (11/34) */
1028 return set_option ("eis") &&
1029 set_option ("mxps");
1031 else if (strncmp (buf
, "df", 2) == 0 || /* KD11-F (11/03) */
1032 strncmp (buf
, "dh", 2) == 0 || /* KD11-H (11/03) */
1033 strncmp (buf
, "dq", 2) == 0) /* KD11-Q (11/03) */
1034 return set_option ("limited-eis") &&
1035 set_option ("mxps");
1037 else if (strncmp (buf
, "dk", 2) == 0) /* KD11-K (11/60) */
1038 return set_option ("eis") &&
1039 set_option ("mxps") &&
1040 set_option ("ucode");
1042 else if (strncmp (buf
, "dz", 2) == 0) /* KD11-Z (11/44) */
1043 return set_option ("csm") &&
1044 set_option ("eis") &&
1045 set_option ("mfpt") &&
1046 set_option ("mxps") &&
1049 else if (strncmp (buf
, "f", 1) == 0) /* F11 (11/23/24) */
1050 return set_option ("eis") &&
1051 set_option ("mfpt") &&
1052 set_option ("mxps");
1054 else if (strncmp (buf
, "j", 1) == 0) /* J11 (11/53/73/83/84/93/94)*/
1055 return set_option ("csm") &&
1056 set_option ("eis") &&
1057 set_option ("mfpt") &&
1058 set_option ("multiproc") &&
1059 set_option ("mxps") &&
1062 else if (strncmp (buf
, "t", 1) == 0) /* T11 (11/21) */
1063 return set_option ("limited-eis") &&
1064 set_option ("mxps");
1071 set_machine_model (arg
)
1074 if (strncmp (arg
, "pdp-11/", 7) != 0 &&
1075 strncmp (arg
, "pdp11/", 6) != 0 &&
1076 strncmp (arg
, "11/", 3) != 0)
1079 if (strncmp (arg
, "pdp", 3) == 0)
1083 if (strncmp (arg
, "11/", 3) == 0)
1086 if (strcmp (arg
, "03") == 0) /* 11/03 */
1087 return set_cpu_model ("kd11f"); /* KD11-F */
1089 else if (strcmp (arg
, "04") == 0) /* 11/04 */
1090 return set_cpu_model ("kd11d"); /* KD11-D */
1092 else if (strcmp (arg
, "05") == 0 || /* 11/05 or 11/10 */
1093 strcmp (arg
, "10") == 0)
1094 return set_cpu_model ("kd11b"); /* KD11-B */
1096 else if (strcmp (arg
, "15") == 0 || /* 11/15 or 11/20 */
1097 strcmp (arg
, "20") == 0)
1098 return set_cpu_model ("ka11"); /* KA11 */
1100 else if (strcmp (arg
, "21") == 0) /* 11/21 */
1101 return set_cpu_model ("t11"); /* T11 */
1103 else if (strcmp (arg
, "23") == 0 || /* 11/23 or 11/24 */
1104 strcmp (arg
, "24") == 0)
1105 return set_cpu_model ("f11"); /* F11 */
1107 else if (strcmp (arg
, "34") == 0 || /* 11/34 or 11/34a */
1108 strcmp (arg
, "34a") == 0)
1109 return set_cpu_model ("kd11e"); /* KD11-E */
1111 else if (strcmp (arg
, "35") == 0 || /* 11/35 or 11/40 */
1112 strcmp (arg
, "40") == 0)
1113 return set_cpu_model ("kd11da"); /* KD11-A */
1115 else if (strcmp (arg
, "44") == 0) /* 11/44 */
1116 return set_cpu_model ("kd11dz"); /* KD11-Z */
1118 else if (strcmp (arg
, "45") == 0 || /* 11/45/50/55/70 */
1119 strcmp (arg
, "50") == 0 ||
1120 strcmp (arg
, "55") == 0 ||
1121 strcmp (arg
, "70") == 0)
1122 return set_cpu_model ("kb11"); /* KB11 */
1124 else if (strcmp (arg
, "60") == 0) /* 11/60 */
1125 return set_cpu_model ("kd11k"); /* KD11-K */ /* FPP? */
1127 else if (strcmp (arg
, "53") == 0 || /* 11/53/73/83/84/93/94 */
1128 strcmp (arg
, "73") == 0 ||
1129 strcmp (arg
, "83") == 0 ||
1130 strcmp (arg
, "84") == 0 ||
1131 strcmp (arg
, "93") == 0 ||
1132 strcmp (arg
, "94") == 0)
1133 return set_cpu_model ("j11") && /* J11 */
1134 set_option ("fpp"); /* All J11 machines come */
1135 /* with FPP installed. */
1140 CONST
char *md_shortopts
= "m:";
1142 struct option md_longopts
[] =
1144 #define OPTION_CPU 257
1145 { "cpu", required_argument
, NULL
, OPTION_CPU
},
1146 #define OPTION_MACHINE 258
1147 { "machine", required_argument
, NULL
, OPTION_MACHINE
},
1148 #define OPTION_PIC 259
1149 { "pic", no_argument
, NULL
, OPTION_PIC
},
1150 { NULL
, no_argument
, NULL
, 0 }
1153 size_t md_longopts_size
= sizeof (md_longopts
);
1157 * Invocation line includes a switch not recognized by the base assembler.
1158 * See if it's a processor-specific option.
1162 md_parse_option (c
, arg
)
1171 if (set_option (arg
))
1173 if (set_cpu_model (arg
))
1175 if (set_machine_model (arg
))
1180 if (set_cpu_model (arg
))
1184 case OPTION_MACHINE
:
1185 if (set_machine_model (arg
))
1190 if (set_option ("pic"))
1198 as_bad ("unrecognized option `-%c%s'", c
, arg
? arg
: "");
1204 One possible way of parsing options.
1215 CONST char *pattern;
1217 CONST char *description;
1220 static struct options extension_opts[] =
1222 { "Ncsm", OPTION_CSM,
1223 "allow (disallow) CSM instruction" },
1224 { "Ncis", OPTION_CIS,
1225 "allow (disallow) commersial instruction set" },
1226 { "Neis", OPTION_EIS,
1227 "allow (disallow) extended instruction set" },
1229 { "all-extensions", OPTION_ALL_EXTENSIONS,
1230 "allow all instruction set extensions\n\
1231 (this is the default)" },
1232 { "no-extensions", OPTION_NO_EXTENSIONS,
1233 "disallow all instruction set extensions" },
1234 { "pic", OPTION_PIC,
1235 "position-independent code" },
1238 static struct options cpu_opts[] =
1240 { "Ka_11_*", OPTION_KA11, "KA11 CPU. ..." },
1241 { "Kb_11_*", OPTION_KB11, "KB11 CPU. ..." },
1242 { "Kd_11_a*", OPTION_KD11A, "KD11-A CPU. ..." },
1243 { "Kd_11_b*", OPTION_KD11B, "KD11-B CPU. ..." },
1244 { "Kd_11_d*", OPTION_KD11D, "KD11-D CPU. ..." },
1245 { "Kd_11_e*", OPTION_KD11E, "KD11-E CPU. ..." },
1246 { "Kd_11_f*", OPTION_KD11F, "KD11-F CPU. ..." },
1247 { "Kd_11_h*", OPTION_KD11H, "KD11-H CPU. ..." },
1248 { "Kd_11_q*", OPTION_KD11Q, "KD11-Q CPU. ..." },
1249 { "Kd_11_z*", OPTION_KD11Z, "KD11-Z CPU. ..." },
1250 { "Df_11_*", OPTION_F11, "F11 CPU. ..." },
1251 { "Dj_11_*", OPTION_J11, "J11 CPU. ..." },
1252 { "Dt_11_*", OPTION_T11, "T11 CPU. ..." },
1255 static struct options model_opts[] =
1257 { "P03", OPTION_PDP11_03, "same as ..." },
1258 { "P04", OPTION_PDP11_04, "same as ..." },
1259 { "P05", OPTION_PDP11_05, "same as ..." },
1260 { "P10", OPTION_PDP11_10, "same as ..." },
1261 { "P15", OPTION_PDP11_15, "same as ..." },
1262 { "P20", OPTION_PDP11_20, "same as ..." },
1263 { "P21", OPTION_PDP11_21, "same as ..." },
1264 { "P24", OPTION_PDP11_24, "same as ..." },
1265 { "P34", OPTION_PDP11_34, "same as ..." },
1266 { "P34a", OPTION_PDP11_34A, "same as ..." },
1267 { "P40", OPTION_PDP11_40, "same as ..." },
1268 { "P44", OPTION_PDP11_44, "same as ..." },
1269 { "P45", OPTION_PDP11_45, "same as ..." },
1270 { "P50", OPTION_PDP11_50, "same as ..." },
1271 { "P53", OPTION_PDP11_53, "same as ..." },
1272 { "P55", OPTION_PDP11_55, "same as ..." },
1273 { "P60", OPTION_PDP11_60, "same as ..." },
1274 { "P70", OPTION_PDP11_70, "same as ..." },
1275 { "P73", OPTION_PDP11_73, "same as ..." },
1276 { "P83", OPTION_PDP11_83, "same as ..." },
1277 { "P84", OPTION_PDP11_84, "same as ..." },
1278 { "P93", OPTION_PDP11_93, "same as ..." },
1279 { "P94", OPTION_PDP11_94, "same as ..." },
1285 struct options *opts;
1289 { "PDP-11 instruction set extentions",
1291 sizeof extension_opts / sizeof extension_opts[0] },
1292 { "PDP-11 CPU model options",
1294 sizeof cpu_opts / sizeof cpu_opts[0] },
1295 { "PDP-11 machine model options",
1297 sizeof model_opts / sizeof model_opts[0] },
1301 parse_match (char *arg, char *pattern)
1310 if (strncmp (arg, "no-") == 0)
1323 if (strncmp (arg, "kd", 2) == 0)
1328 if (strncmp (arg, "pdp-11/", 7) == 0)
1330 else if (strncmp (arg, "pdp11/", 6) == 0)
1332 else if (strncmp (arg, "11/", 3) == 0)
1348 if (*arg++ != pattern[-1])
1357 fprint_opt (stream, pattern)
1359 CONST char *pattern;
1368 n += fprintf (stream, "(no-)");
1372 n += fprintf (stream, "k");
1376 n += fprintf (stream "11/");
1385 fputc (pattern[-1], stream);
1394 parse_option (char *arg)
1398 for (i = 0; i < sizeof all_opts / sizeof all_opts[0]; i++)
1400 for (j = 0; j < all_opts[i].num; j++)
1402 if (parse_match (arg, all_opts[i].opts[j].pattern))
1404 set_option (all_opts[i].opts[j].opt);
1414 fprint_space (stream, n)
1419 fputc (' ', stream);
1423 md_show_usage (stream)
1428 for (i = 0; i < sizeof all_opts / sizeof all_opts[0]; i++)
1430 fprintf (stream "\n%s:\n\n", all_opts[i].title);
1432 for (j = 0; j < all_opts[i].num; j++)
1434 fprintf (stream, "-m");
1435 n = fprintf_opt (stream, all_opts[i].opts[j].pattern);
1436 fprint_space (stream, 22 - n);
1437 fprintf (stream, "%s\n", all_opts[i].opts[j].description);
1444 md_show_usage (stream
)
1449 PDP-11 instruction set extentions:\n\
1451 -m(no-)cis allow (disallow) commersial instruction set\n\
1452 -m(no-)csm allow (disallow) CSM instruction\n\
1453 -m(no-)eis allow (disallow) full extended instruction set\n\
1454 -m(no-)fis allow (disallow) KEV11 floating-point instructions\n\
1455 -m(no-)fpp allow (disallow) FP-11 floating-point instructions\n\
1456 -m(no-)fpu allow (disallow) FP-11 floating-point instructions\n\
1457 -m(no-)limited-eis allow (disallow) limited extended instruction set\n\
1458 -m(no-)mfpt allow (disallow) processor type instruction\n\
1459 -m(no-)multiproc allow (disallow) multiprocessor instructions\n\
1460 -m(no-)mxps allow (disallow) processor status instructions\n\
1461 -m(no-)spl allow (disallow) SPL instruction\n\
1462 -m(no-)ucode allow (disallow) microcode instructions\n\
1463 -mall-extensions allow all instruction set extensions\n\
1464 (this is the default)\n\
1465 -mno-extentions disallow all instruction set extensions\n\
1466 -pic generate position-indepenent code\n\
1468 PDP-11 CPU model options:\n\
1470 -mka11* KA11 CPU. base line instruction set only\n\
1471 -mkb11* KB11 CPU. enable full EIS and SPL\n\
1472 -mkd11a* KD11-A CPU. enable limited EIS\n\
1473 -mkd11b* KD11-B CPU. base line instruction set only\n\
1474 -mkd11d* KD11-D CPU. base line instruction set only\n\
1475 -mkd11e* KD11-E CPU. enable full EIS, MTPS, and MFPS\n\
1476 -mkd11f* KD11-F CPU. enable limited EIS, MTPS, and MFPS\n\
1477 -mkd11h* KD11-H CPU. enable limited EIS, MTPS, and MFPS\n\
1478 -mkd11q* KD11-Q CPU. enable limited EIS, MTPS, and MFPS\n\
1479 -mkd11k* KD11-K CPU. enable full EIS, MTPS, MFPS, LDUB, MED,\n\
1481 -mkd11z* KD11-Z CPU. enable full EIS, MTPS, MFPS, MFPT, SPL,\n\
1483 -mf11* F11 CPU. enable full EIS, MFPS, MTPS, and MFPT\n\
1484 -mj11* J11 CPU. enable full EIS, MTPS, MFPS, MFPT, SPL,\n\
1485 CSM, TSTSET, and WRTLCK\n\
1486 -mt11* T11 CPU. enable limited EIS, MTPS, and MFPS\n\
1488 PDP-11 machine model options:\n\
1490 -m11/03 same as -mkd11f\n\
1491 -m11/04 same as -mkd11d\n\
1492 -m11/05 same as -mkd11b\n\
1493 -m11/10 same as -mkd11b\n\
1494 -m11/15 same as -mka11\n\
1495 -m11/20 same as -mka11\n\
1496 -m11/21 same as -mt11\n\
1497 -m11/23 same as -mf11\n\
1498 -m11/24 same as -mf11\n\
1499 -m11/34 same as -mkd11e\n\
1500 -m11/34a same as -mkd11e -mfpp\n\
1501 -m11/35 same as -mkd11a\n\
1502 -m11/40 same as -mkd11a\n\
1503 -m11/44 same as -mkd11z\n\
1504 -m11/45 same as -mkb11\n\
1505 -m11/50 same as -mkb11\n\
1506 -m11/53 same as -mj11\n\
1507 -m11/55 same as -mkb11\n\
1508 -m11/60 same as -mkd11k\n\
1509 -m11/70 same as -mkb11\n\
1510 -m11/73 same as -mj11\n\
1511 -m11/83 same as -mj11\n\
1512 -m11/84 same as -mj11\n\
1513 -m11/93 same as -mj11\n\
1514 -m11/94 same as -mj11\n\
1519 md_undefined_symbol (name
)
1520 char *name ATTRIBUTE_UNUSED
;
1526 md_section_align (segment
, size
)
1527 segT segment ATTRIBUTE_UNUSED
;
1530 return (size
+ 1) & ~1;
1534 md_pcrel_from (fixP
)
1537 return fixP
->fx_frag
->fr_address
+ fixP
->fx_where
+ fixP
->fx_size
;
1540 /* Translate internal representation of relocation info to BFD target
1543 tc_gen_reloc (section
, fixp
)
1544 asection
*section ATTRIBUTE_UNUSED
;
1548 bfd_reloc_code_real_type code
;
1550 reloc
= (arelent
*) xmalloc (sizeof (arelent
));
1552 reloc
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
1553 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
1554 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
1556 /* this is taken account for in md_apply_fix() */
1557 reloc
->addend
= -symbol_get_bfdsym (fixp
->fx_addsy
)->section
->vma
;
1559 switch (fixp
->fx_r_type
)
1563 code
= BFD_RELOC_16_PCREL
;
1565 code
= BFD_RELOC_16
;
1568 case BFD_RELOC_16_PCREL
:
1569 code
= BFD_RELOC_16_PCREL
;
1573 BAD_CASE (fixp
->fx_r_type
);
1577 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, code
);
1579 if (reloc
->howto
== NULL
)
1581 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
1582 "Can not represent %s relocation in this object file format",
1583 bfd_get_reloc_code_name (code
));
1592 int c ATTRIBUTE_UNUSED
;
1596 temp
= get_absolute_expression ();
1597 subseg_set (bss_section
, temp
);
1598 demand_empty_rest_of_line ();
1603 int c ATTRIBUTE_UNUSED
;
1605 int alignment
= 1; /* 2^1 */
1606 frag_align (alignment
, 0, 1);
1607 record_alignment (now_seg
, alignment
);
1610 /* end of tc-pdp11.c */