OSDN Git Service

3af7dc815fa4a177911cb346c0976858b06754e4
[pf3gnuchains/pf3gnuchains3x.git] / gas / config / tc-pdp11.c
1 /* tc-pdp11.c - pdp11-specific -
2    Copyright 2001 Free Software Foundation, Inc.
3
4    This file is part of GAS, the GNU Assembler.
5
6    GAS is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2, or (at your option)
9    any later version.
10
11    GAS is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with GAS; see the file COPYING.  If not, write to
18    the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
19
20 /*
21   Apparently unused functions:
22     md_convert_frag
23     md_estimate_size_before_relax
24     md_create_short_jump
25     md_create_long_jump
26 */
27
28 #include "as.h"
29 #include "opcode/pdp11.h"
30
31 static int set_option PARAMS ((char *arg));
32 static int set_cpu_model PARAMS ((char *arg));
33 static int set_machine_model PARAMS ((char *arg));
34
35 #define TRUE 1
36 #define FALSE 0
37
38 /*
39  * A representation for PDP-11 machine code.
40  */
41 struct pdp11_code
42 {
43   char *error;
44   int code;
45   int additional;       /* is there an additional word? */
46   int word;             /* additional word, if any */
47   struct
48   {
49     bfd_reloc_code_real_type type;
50     expressionS exp;
51     int pc_rel;
52   } reloc;
53 };
54
55 /*
56  * Instruction set extensions.
57  *
58  * If you change this from an array to something else, please update
59  * the "PDP-11 instruction set extensions" comment in pdp11.h.
60  */
61 int pdp11_extension[PDP11_EXT_NUM];
62
63 /*
64  * Assembly options.
65  */
66
67 #define ASM_OPT_PIC 1
68 #define ASM_OPT_NUM 2
69
70 int asm_option[ASM_OPT_NUM];
71
72 /* These chars start a comment anywhere in a source file (except inside
73    another comment */
74 CONST char comment_chars[] = "#/";
75
76 /* These chars only start a comment at the beginning of a line.  */
77 CONST char line_comment_chars[] = "#/";
78
79 CONST char line_separator_chars[] = ";";
80
81 /* Chars that can be used to separate mant from exp in floating point nums */
82 CONST char EXP_CHARS[] = "eE";
83
84 /* Chars that mean this number is a floating point constant */
85 /* as in 0f123.456 */
86 /* or    0H1.234E-12 (see exp chars above) */
87 CONST char FLT_CHARS[] = "dDfFgGhH";
88
89 void pseudo_even (int);
90 void pseudo_bss (int);
91
92 CONST pseudo_typeS md_pseudo_table[] =
93 {
94   { "bss", pseudo_bss, 0 },
95   { "even", pseudo_even, 0 },
96   { 0, 0, 0 },
97 };
98
99 static void
100 init_defaults ()
101 {
102   static int first = 1;
103
104   if (first)
105     {
106       set_option ("all-extensions");
107       set_option ("pic");
108       first = 0;
109     }
110 }
111
112 static struct hash_control *insn_hash = NULL;
113
114 void
115 md_begin ()
116 {
117   int i;
118
119   init_defaults ();
120
121   insn_hash = hash_new ();
122   if (insn_hash == NULL)
123     as_fatal ("Virtual memory exhausted");
124
125   for (i = 0; i < pdp11_num_opcodes; i++)
126     hash_insert (insn_hash, pdp11_opcodes[i].name, (PTR)(pdp11_opcodes + i));
127   for (i = 0; i < pdp11_num_aliases; i++)
128     hash_insert (insn_hash, pdp11_aliases[i].name, (PTR)(pdp11_aliases + i));
129 }
130
131 void
132 md_number_to_chars (con, value, nbytes)
133      char con[];
134      valueT value;
135      int nbytes;
136 {
137   /* On a PDP-11, 0x1234 is stored as "\x12\x34", and
138    * 0x12345678 is stored as "\x56\x78\x12\x34". It's
139    * anyones guess what 0x123456 would be stored like.
140    */
141
142   switch (nbytes)
143     {
144     case 0:
145       break;
146     case 1:
147       con[0] =  value       & 0xff;
148       break;
149     case 2:
150       con[0] =  value       & 0xff;
151       con[1] = (value >>  8) & 0xff;
152       break;
153     case 4:
154       con[0] = (value >> 16) & 0xff;
155       con[1] = (value >> 24) & 0xff;
156       con[2] =  value       & 0xff;
157       con[3] = (value >>  8) & 0xff;
158       break;
159     default:
160       BAD_CASE (nbytes);
161     }
162 }
163
164 /* Fix up some data or instructions after we find out the value of a symbol
165    that they reference.  */
166
167 int                             /* Knows about order of bytes in address.  */
168 md_apply_fix (fixP, value)
169      fixS *fixP;
170      valueT *value;
171 {
172   valueT code;
173   valueT mask;
174   char *buf;
175   int shift;
176   int size;
177
178   buf = fixP->fx_where + fixP->fx_frag->fr_literal;
179   size = fixP->fx_size;
180   code = md_chars_to_number (buf, size);
181
182   switch (fixP->fx_r_type)
183     {
184     case BFD_RELOC_16:
185     case BFD_RELOC_16_PCREL:
186       mask = 0xffff;
187       shift = 0;
188       break;
189     case BFD_RELOC_PDP11_DISP_8_PCREL:
190       mask = 0x00ff;
191       shift = 1;
192       break;
193     case BFD_RELOC_PDP11_DISP_6_PCREL:
194       mask = 0x003f;
195       shift = 1;
196       break;
197     default:
198       BAD_CASE (fixP->fx_r_type);
199     }
200
201   if (fixP->fx_addsy != NULL)
202     *value += symbol_get_bfdsym (fixP->fx_addsy)->section->vma;
203     /* *value += fixP->fx_addsy->bsym->section->vma; */
204
205   code &= ~mask;
206   code |= (*value >> shift) & mask;
207   number_to_chars_littleendian (buf, code, size);
208   return 0;
209 }
210
211 long
212 md_chars_to_number (con, nbytes)
213      unsigned char con[];       /* Low order byte 1st.  */
214      int nbytes;                /* Number of bytes in the input.  */
215 {
216   /* On a PDP-11, 0x1234 is stored as "\x12\x34", and
217    * 0x12345678 is stored as "\x56\x78\x12\x34". It's
218    * anyones guess what 0x123456 would be stored like.
219    */
220
221   switch (nbytes)
222     {
223     case 0:
224       return 0;
225     case 1:
226       return con[0];
227     case 2:
228       return (con[1] << BITS_PER_CHAR) | con[0];
229     case 4:
230       return
231         (((con[1] << BITS_PER_CHAR) | con[0]) << (2 * BITS_PER_CHAR)) |
232          ((con[3] << BITS_PER_CHAR) | con[2]);
233     default:
234       BAD_CASE (nbytes);
235       return 0;
236     }
237 }
238 \f
239 static char *
240 skip_whitespace (char *str)
241 {
242   while (*str == ' ' || *str == '\t')
243     str++;
244   return str;
245 }
246
247 static char *
248 find_whitespace (char *str)
249 {
250   while (*str != ' ' && *str != '\t' && *str != 0)
251     str++;
252   return str;
253 }
254
255 static char
256 mklower (char c)
257 {
258   if (isupper (c))
259     return tolower (c);
260   return c;
261 }
262
263 static char *
264 parse_reg (char *str, struct pdp11_code *operand)
265 {
266   str = skip_whitespace (str);
267   if (mklower (*str) == 'r')
268     {
269       str++;
270       switch (*str)
271         {
272         case '0': case '1': case '2': case '3':
273         case '4': case '5': case '6': case '7':
274           operand->code = *str - '0';
275           str++;
276           break;
277         default:
278           operand->error = "Bad register name";
279           return str - 1;
280         }
281     }
282   else if (strncmp (str, "sp", 2) == 0 ||
283            strncmp (str, "SP", 2) == 0)
284     {
285       operand->code = 6;
286       str += 2;
287     }
288   else if (strncmp (str, "pc", 2) == 0 ||
289            strncmp (str, "PC", 2) == 0)
290     {
291       operand->code = 7;
292       str += 2;
293     }
294   else
295     {
296       operand->error = "Bad register name";
297       return str;
298     }
299
300   return str;
301 }
302
303 static char *
304 parse_ac (char *str, struct pdp11_code *operand)
305 {
306   str = skip_whitespace (str);
307   if (strncmp (str, "fr", 2) == 0 ||
308       strncmp (str, "FR", 2) == 0 ||
309       strncmp (str, "ac", 2) == 0 ||
310       strncmp (str, "AC", 2) == 0)
311     {
312       str += 2;
313       switch (*str)
314         {
315         case '0': case '1': case '2': case '3':
316           operand->code = *str - '0';
317           str++;
318           break;
319         default:
320           operand->error = "Bad register name";
321           return str - 2;
322         }
323     }
324   else
325     {
326       operand->error = "Bad register name";
327       return str;
328     }
329
330   return str;
331 }
332
333 static char *
334 parse_expression (char *str, struct pdp11_code *operand)
335 {
336   char *save_input_line_pointer;
337   segT seg;
338
339   save_input_line_pointer = input_line_pointer;
340   input_line_pointer = str;
341   seg = expression (&operand->reloc.exp);
342   if (seg == NULL)
343     {
344       input_line_pointer = save_input_line_pointer;
345       operand->error = "Error in expression";
346       return str;
347     }
348
349   str = input_line_pointer;
350   input_line_pointer = save_input_line_pointer;
351
352   operand->reloc.pc_rel = 0;
353
354   if (operand->reloc.exp.X_op == O_constant)
355     {
356       if (*str == '.')
357         str++;
358       else
359         {
360           /* FIXME: buffer overflow! */
361           char buf[100];
362           char *end;
363
364           sprintf (buf, "%ld", operand->reloc.exp.X_add_number);
365           operand->reloc.exp.X_add_number = strtol (buf, &end, 8);
366         }
367     }
368
369   return str;
370 }
371
372 static char *
373 parse_op_no_deferred (char *str, struct pdp11_code *operand)
374 {
375   str = skip_whitespace (str);
376
377   switch (*str)
378     {
379     case '(':                           /* (rn) and (rn)+ */
380       str = parse_reg (str + 1, operand);
381       if (operand->error)
382         return str;
383       str = skip_whitespace (str);
384       if (*str != ')')
385         {
386           operand->error = "Missing ')'";
387           return str;
388         }
389       str++;
390       if (*str == '+')
391         {
392           operand->code |= 020;
393           str++;
394         }
395       else
396         {
397           operand->code |= 010;
398         }
399       break;
400
401     case '#':                           /* immediate */
402     case '$':
403       str = parse_expression (str + 1, operand);
404       if (operand->error)
405         return str;
406       operand->additional = TRUE;
407       operand->word = operand->reloc.exp.X_add_number;
408       switch (operand->reloc.exp.X_op)
409         {
410         case O_constant:
411           break;
412         case O_symbol:
413         case O_add:
414         case O_subtract:
415           operand->reloc.type = BFD_RELOC_16;
416           operand->reloc.pc_rel = 0;
417           break;
418         default:
419           operand->error = "Error in expression";
420           break;
421         }
422       operand->code = 027;
423       break;
424
425     default:                            /* label, d(rn), -(rn) */
426       {
427         char *old = str;
428
429         if (strncmp (str, "-(", 2) == 0)        /* -(rn) */
430           {
431             str = parse_reg (str + 2, operand);
432             if (operand->error)
433               return str;
434             str = skip_whitespace (str);
435             if (*str != ')')
436               {
437                 operand->error = "Missing ')'";
438                 return str;
439               }
440             operand->code |= 040;
441             str++;
442             break;
443           }
444
445         str = parse_expression (str, operand);
446         if (operand->error)
447           return str;
448
449         str = skip_whitespace (str);
450
451         if (*str != '(')                /* label */
452           {
453             if (operand->reloc.exp.X_op != O_symbol)
454               {
455                 operand->error = "Label expected";
456                 return old;
457               }
458             operand->code = 067;
459             operand->additional = 1;
460             operand->word = 0;
461             operand->reloc.type = BFD_RELOC_16_PCREL;
462             operand->reloc.pc_rel = 1;
463             break;
464           }
465
466         str++;                          /* d(rn) */
467         str = parse_reg (str, operand);
468         if (operand->error)
469           return str;
470
471         str = skip_whitespace (str);
472
473         if (*str != ')')
474           {
475             operand->error = "Missing ')'";
476             return str;
477           }
478
479         str++;
480         operand->additional = TRUE;
481         operand->code |= 060;
482         switch (operand->reloc.exp.X_op)
483           {
484           case O_symbol:
485             operand->word = 0;
486             operand->reloc.pc_rel = 1;
487             break;
488           case O_constant:
489             if ((operand->code & 7) == 7)
490               {
491                 operand->reloc.pc_rel = 1;
492                 operand->word = operand->reloc.exp.X_add_number;
493               }
494             else
495               {
496                 operand->word = operand->reloc.exp.X_add_number;
497               }
498             break;
499           default:
500             BAD_CASE (operand->reloc.exp.X_op);
501           }
502         break;
503       }
504     }
505
506   return str;
507 }
508
509 static char *
510 parse_op (char *str, struct pdp11_code *operand)
511 {
512   str = skip_whitespace (str);
513
514   str = parse_reg (str, operand);
515   if (!operand->error)
516     return str;
517   operand->error = NULL;
518
519   if (*str == '@' || *str == '*')
520     {
521       str = parse_op_no_deferred (str + 1, operand);
522       if (operand->error)
523         return str;
524       operand->code |= 010;
525     }
526   else
527     str = parse_op_no_deferred (str, operand);
528
529   return str;
530 }
531
532 static char *
533 parse_separator (char *str, int *error)
534 {
535   str = skip_whitespace (str);
536   *error = (*str != ',');
537   if (!*error)
538     str++;
539   return str;
540 }
541
542 void
543 md_assemble (instruction_string)
544      char *instruction_string;
545 {
546   CONST struct pdp11_opcode *op;
547   struct pdp11_code insn, op1, op2;
548   int error;
549   int size;
550   char *err = NULL;
551   char *str;
552   char *p;
553   char c;
554
555   str = skip_whitespace (instruction_string);
556   p = find_whitespace (str);
557   if (p - str == 0)
558     {
559       as_bad ("No instruction found");
560       return;
561     }
562
563   c = *p;
564   *p = '\0';
565   op = (struct pdp11_opcode *)hash_find (insn_hash, str);
566   *p = c;
567   if (op == 0)
568     {
569 #if 0
570       op1.error = NULL;
571       op1.additional = FALSE;
572       op1.reloc.type = BFD_RELOC_NONE;
573       op1.code = 0;
574       op1.word = 0;
575       str = parse_expression (str, &op1);
576       if (op1.error)
577         {
578           as_bad (op1.error);
579           return;
580         }
581
582       {
583         char *to = frag_more (2);
584
585         md_number_to_chars (to, op1.code, 2);
586         if (insn.reloc.type != BFD_RELOC_NONE)
587           fix_new_exp (frag_now, to - frag_now->fr_literal, 2,
588                        &insn.reloc.exp, insn.reloc.pc_rel, insn.reloc.type);
589       }
590 #else
591       as_warn ("Unknown instruction");
592 #endif
593
594       return;
595     }
596
597   if (!pdp11_extension[op->extension])
598     {
599       as_warn ("Unsupported instruction set extension: %s", op->name);
600       return;
601     }
602
603   insn.error = NULL;
604   insn.code = op->opcode;
605   insn.reloc.type = BFD_RELOC_NONE;
606   op1.error = NULL;
607   op1.additional = FALSE;
608   op1.reloc.type = BFD_RELOC_NONE;
609   op2.error = NULL;
610   op2.additional = FALSE;
611   op2.reloc.type = BFD_RELOC_NONE;
612
613   str = p;
614   size = 2;
615
616   switch (op->type)
617     {
618     case PDP11_OPCODE_NO_OPS:
619       str = skip_whitespace (str);
620       if (*str == 0)
621         str = "";
622       break;
623
624     case PDP11_OPCODE_IMM3:
625     case PDP11_OPCODE_IMM6:
626     case PDP11_OPCODE_IMM8:
627       str = skip_whitespace (str);
628       if (*str == '#' || *str == '$')
629         str++;
630       str = parse_expression (str, &op1);
631       if (op1.error)
632         break;
633       switch (op->type)
634         {
635         case PDP11_OPCODE_IMM3:
636           if (op1.code & ~7)
637             {
638               op1.error = "3-bit immediate out of range";
639               break;
640             }
641           break;
642         case PDP11_OPCODE_IMM6:
643           if (op1.code & ~0x3f)
644             {
645               op1.error = "6-bit immediate out of range";
646               break;
647             }
648           break;
649         case PDP11_OPCODE_IMM8:
650           if (op1.code & ~0xff)
651             {
652               op1.error = "8-bit immediate out of range";
653               break;
654             }
655           break;
656         }
657       insn.code |= op1.code;
658       break;
659
660     case PDP11_OPCODE_DISPL:
661       {
662         char *new;
663         new = parse_expression (str, &op1);
664         op1.code = 0;
665         op1.reloc.pc_rel = 1;
666         op1.reloc.type = BFD_RELOC_PDP11_DISP_8_PCREL;
667         if (op1.reloc.exp.X_op != O_symbol)
668           {
669             op1.error = "Symbol expected";
670             break;
671           }
672         if (op1.code & ~0xff)
673           {
674             err = "8-bit displacement out of range";
675             break;
676           }
677         str = new;
678         insn.code |= op1.code;
679         insn.reloc = op1.reloc;
680       }
681       break;
682
683     case PDP11_OPCODE_REG:
684       str = parse_reg (str, &op1);
685       if (op1.error)
686         break;
687       insn.code |= op1.code;
688       break;
689
690     case PDP11_OPCODE_OP:
691       str = parse_op (str, &op1);
692       if (op1.error)
693         break;
694       insn.code |= op1.code;
695       if (op1.additional)
696         size += 2;
697       break;
698
699     case PDP11_OPCODE_REG_OP:
700       str = parse_reg (str, &op2);
701       if (op2.error)
702         break;
703       insn.code |= op2.code << 6;
704       str = parse_separator (str, &error);
705       if (error)
706         {
707           op2.error = "Missing ','";
708           break;
709         }
710       str = parse_op (str, &op1);
711       if (op1.error)
712         break;
713       insn.code |= op1.code;
714       if (op1.additional)
715         size += 2;
716       break;
717
718     case PDP11_OPCODE_REG_OP_REV:
719       str = parse_op (str, &op1);
720       if (op1.error)
721         break;
722       insn.code |= op1.code;
723       if (op1.additional)
724         size += 2;
725       str = parse_separator (str, &error);
726       if (error)
727         {
728           op2.error = "Missing ','";
729           break;
730         }
731       str = parse_reg (str, &op2);
732       if (op2.error)
733         break;
734       insn.code |= op2.code << 6;
735       break;
736
737     case PDP11_OPCODE_AC_OP:
738       str = parse_ac (str, &op2);
739       if (op2.error)
740         break;
741       insn.code |= op2.code << 6;
742       str = parse_separator (str, &error);
743       if (error)
744         {
745           op1.error = "Missing ','";
746           break;
747         }
748       str = parse_op (str, &op1);
749       if (op1.error)
750         break;
751       insn.code |= op1.code;
752       if (op1.additional)
753         size += 2;
754       break;
755
756     case PDP11_OPCODE_OP_OP:
757       str = parse_op (str, &op1);
758       if (op1.error)
759         break;
760       insn.code |= op1.code << 6;
761       if (op1.additional)
762         size += 2;
763       str = parse_separator (str, &error);
764       if (error)
765         {
766           op2.error = "Missing ','";
767           break;
768         }
769       str = parse_op (str, &op2);
770       if (op2.error)
771         break;
772       insn.code |= op2.code;
773       if (op2.additional)
774         size += 2;
775       break;
776
777     case PDP11_OPCODE_REG_DISPL:
778       {
779         char *new;
780         str = parse_reg (str, &op2);
781         if (op2.error)
782           break;
783         insn.code |= op2.code << 6;
784         str = parse_separator (str, &error);
785         if (error)
786           {
787             op1.error = "Missing ','";
788             break;
789           }
790         new = parse_expression (str, &op1);
791         op1.code = 0;
792         op1.reloc.pc_rel = 1;
793         op1.reloc.type = BFD_RELOC_PDP11_DISP_6_PCREL;
794         if (op1.reloc.exp.X_op != O_symbol)
795           {
796             op1.error = "Symbol expected";
797             break;
798           }
799         if (op1.code & ~0x3f)
800           {
801             err = "6-bit displacement out of range";
802             break;
803           }
804         str = new;
805         insn.code |= op1.code;
806         insn.reloc = op1.reloc;
807       }
808       break;
809
810     default:
811       BAD_CASE (op->type);
812     }
813
814   if (op1.error)
815     err = op1.error;
816   else if (op2.error)
817     err = op2.error;
818   else
819     {
820       str = skip_whitespace (str);
821       if (*str)
822         err = "Too many operands";
823     }
824
825   {
826     char *to = NULL;
827
828     if (err)
829       {
830         as_bad (err);
831         return;
832       }
833
834     to = frag_more (size);
835
836     md_number_to_chars (to, insn.code, 2);
837     if (insn.reloc.type != BFD_RELOC_NONE)
838       fix_new_exp (frag_now, to - frag_now->fr_literal, 2,
839                    &insn.reloc.exp, insn.reloc.pc_rel, insn.reloc.type);
840     to += 2;
841
842     if (op1.additional)
843       {
844         md_number_to_chars (to, op1.word, 2);
845         if (op1.reloc.type != BFD_RELOC_NONE)
846           fix_new_exp (frag_now, to - frag_now->fr_literal, 2,
847                        &op1.reloc.exp, op1.reloc.pc_rel, op1.reloc.type);
848         to += 2;
849       }
850
851     if (op2.additional)
852       {
853         md_number_to_chars (to, op2.word, 2);
854         if (op2.reloc.type != BFD_RELOC_NONE)
855           fix_new_exp (frag_now, to - frag_now->fr_literal, 2,
856                        &op2.reloc.exp, op2.reloc.pc_rel, op2.reloc.type);
857       }
858   }
859 }
860
861 int
862 md_estimate_size_before_relax (fragP, segment)
863      fragS *fragP ATTRIBUTE_UNUSED;
864      segT segment ATTRIBUTE_UNUSED;
865 {
866   return 0;
867 }
868
869 void
870 md_convert_frag (headers, seg, fragP)
871      bfd *headers ATTRIBUTE_UNUSED;
872      segT seg ATTRIBUTE_UNUSED;
873      fragS *fragP ATTRIBUTE_UNUSED;
874 {
875 }
876
877 CONST int md_short_jump_size = 2;
878 CONST int md_long_jump_size = 4;
879
880 void
881 md_create_short_jump (ptr, from_addr, to_addr, frag, to_symbol)
882      char *ptr ATTRIBUTE_UNUSED;
883      addressT from_addr ATTRIBUTE_UNUSED;
884      addressT to_addr ATTRIBUTE_UNUSED;
885      fragS *frag ATTRIBUTE_UNUSED;
886      symbolS *to_symbol ATTRIBUTE_UNUSED;
887 {
888 }
889
890 void
891 md_create_long_jump (ptr, from_addr, to_addr, frag, to_symbol)
892      char *ptr ATTRIBUTE_UNUSED;
893      addressT from_addr ATTRIBUTE_UNUSED;
894      addressT to_addr ATTRIBUTE_UNUSED;
895      fragS *frag ATTRIBUTE_UNUSED;
896      symbolS *to_symbol ATTRIBUTE_UNUSED;
897 {
898 }
899
900 static int
901 set_option (arg)
902      char *arg;
903 {
904   int yes = 1;
905
906   if (strcmp (arg, "all-extensions") == 0 ||
907       strcmp (arg, "all") == 0)
908     {
909       memset (pdp11_extension, ~0, sizeof pdp11_extension);
910       pdp11_extension[PDP11_NONE] = 0;
911       return 1;
912     }
913   else if (strcmp (arg, "no-extensions") == 0)
914     {
915       memset (pdp11_extension, 0, sizeof pdp11_extension);
916       pdp11_extension[PDP11_BASIC] = 1;
917       return 1;
918     }
919
920   if (strncmp (arg, "no-", 3) == 0)
921     {
922       yes = 0;
923       arg += 3;
924     }
925
926   if (strcmp (arg, "cis") == 0)                 /* commersial instructions */
927     pdp11_extension[PDP11_CIS] = yes;
928   else if (strcmp (arg, "csm") == 0)            /* call supervisor mode */
929     pdp11_extension[PDP11_CSM] = yes;
930   else if (strcmp (arg, "eis") == 0)            /* extended instruction set */
931     pdp11_extension[PDP11_EIS] = pdp11_extension[PDP11_LEIS] = yes;
932   else if (strcmp (arg, "fis") == 0 ||          /* KEV11 floating-point */
933            strcmp (arg, "kev11") == 0 ||
934            strcmp (arg, "kev-11") == 0)
935     pdp11_extension[PDP11_FIS] = yes;
936   else if (strcmp (arg, "fpp") == 0 ||          /* FP-11 floating-point */
937            strcmp (arg, "fpu") == 0 ||
938            strcmp (arg, "fp11") == 0 ||
939            strcmp (arg, "fp-11") == 0 ||
940            strcmp (arg, "fpj11") == 0 ||
941            strcmp (arg, "fp-j11") == 0 ||
942            strcmp (arg, "fpj-11") == 0)
943     pdp11_extension[PDP11_FPP] = yes;
944   else if (strcmp (arg, "limited-eis") == 0)    /* limited extended insns */
945     {
946       pdp11_extension[PDP11_LEIS] = yes;
947       if (!pdp11_extension[PDP11_LEIS])
948         pdp11_extension[PDP11_EIS] = 0;
949     }
950   else if (strcmp (arg, "mfpt") == 0)           /* move from processor type */
951     pdp11_extension[PDP11_MFPT] = yes;
952   else if (strncmp (arg, "mproc", 5) == 0 ||    /* multiprocessor insns: */
953            strncmp (arg, "multiproc", 9) == 0 ) /* TSTSET, WRTLCK */
954     pdp11_extension[PDP11_MPROC] = yes;
955   else if (strcmp (arg, "mxps") == 0)           /* move from/to proc status */
956     pdp11_extension[PDP11_MXPS] = yes;
957   else if (strcmp (arg, "pic") == 0)            /* position-independent code */
958     asm_option[ASM_OPT_PIC] = yes;
959   else if (strcmp (arg, "spl") == 0)            /* set priority level */
960     pdp11_extension[PDP11_SPL] = yes;
961   else if (strcmp (arg, "ucode") == 0 ||        /* microcode instructions: */
962            strcmp (arg, "microcode") == 0)      /* LDUB, MED, XFC */
963     pdp11_extension[PDP11_UCODE] = yes;
964   else
965     return 0;
966
967   return 1;
968 }
969
970 static int
971 set_cpu_model (arg)
972      char *arg;
973 {
974   char buf[4];
975   char *model = buf;
976
977   if (arg[0] == 'k')
978     arg++;
979
980   *model++ = *arg++;
981
982   if (strchr ("abdx", model[-1]) == NULL)
983     return 0;
984
985   if (model[-1] == 'd')
986     {
987       if (arg[0] == 'f' ||
988           arg[0] == 'j')
989         model[-1] = *arg++;
990     }
991   else if (model[-1] == 'x')
992     {
993       if (arg[0] == 't')
994         model[-1] = *arg++;
995     }
996
997   if (arg[0] == '-')
998     arg++;
999
1000   if (strncmp (arg, "11", 2) != 0)
1001     return 0;
1002   arg += 2;
1003
1004   if (arg[0] == '-')
1005     {
1006       if (*++arg == 0)
1007         return 0;
1008     }
1009
1010   /* allow up to two revision letters */
1011   if (arg[0] != 0)
1012     *model++ = *arg++;
1013   if (arg[0] != 0)
1014     *model++ = *arg++;
1015
1016   *model++ = 0;
1017
1018   set_option ("no-extensions");
1019
1020   if (strncmp (buf, "a", 1) == 0)               /* KA11 (11/15/20) */
1021     return 1; /* no extensions */
1022
1023   else if (strncmp (buf, "b", 1) == 0)          /* KB11 (11/45/50/55/70) */
1024     return set_option ("eis") &&
1025            set_option ("spl");
1026
1027   else if (strncmp (buf, "da", 2) == 0)         /* KD11-A (11/35/40) */
1028     return set_option ("limited-eis");
1029
1030   else if (strncmp (buf, "db", 2) == 0 ||       /* KD11-B (11/05/10) */
1031            strncmp (buf, "dd", 2) == 0)         /* KD11-D (11/04) */
1032     return 1; /* no extensions */
1033
1034   else if (strncmp (buf, "de", 2) == 0)         /* KD11-E (11/34) */
1035     return set_option ("eis") &&
1036            set_option ("mxps");
1037
1038   else if (strncmp (buf, "df", 2) == 0 ||       /* KD11-F (11/03) */
1039            strncmp (buf, "dh", 2) == 0 ||       /* KD11-H (11/03) */
1040            strncmp (buf, "dq", 2) == 0)         /* KD11-Q (11/03) */
1041     return set_option ("limited-eis") &&
1042            set_option ("mxps");
1043
1044   else if (strncmp (buf, "dk", 2) == 0)         /* KD11-K (11/60) */
1045     return set_option ("eis") &&
1046            set_option ("mxps") &&
1047            set_option ("ucode");
1048
1049   else if (strncmp (buf, "dz", 2) == 0)         /* KD11-Z (11/44) */
1050     return set_option ("csm") &&
1051            set_option ("eis") &&
1052            set_option ("mfpt") &&
1053            set_option ("mxps") &&
1054            set_option ("spl");
1055
1056   else if (strncmp (buf, "f", 1) == 0)          /* F11 (11/23/24) */
1057     return set_option ("eis") &&
1058            set_option ("mfpt") &&
1059            set_option ("mxps");
1060
1061   else if (strncmp (buf, "j", 1) == 0)          /* J11 (11/53/73/83/84/93/94)*/
1062     return set_option ("csm") &&
1063            set_option ("eis") &&
1064            set_option ("mfpt") &&
1065            set_option ("multiproc") &&
1066            set_option ("mxps") &&
1067            set_option ("spl");
1068
1069   else if (strncmp (buf, "t", 1) == 0)          /* T11 (11/21) */
1070     return set_option ("limited-eis") &&
1071            set_option ("mxps");
1072
1073   else
1074     return 0;
1075 }
1076
1077 static int
1078 set_machine_model (arg)
1079      char *arg;
1080 {
1081   if (strncmp (arg, "pdp-11/", 7) != 0 &&
1082       strncmp (arg, "pdp11/", 6) != 0 &&
1083       strncmp (arg, "11/", 3) != 0)
1084     return 0;
1085
1086   if (strncmp (arg, "pdp", 3) == 0)
1087     arg += 3;
1088   if (arg[0] == '-')
1089     arg++;
1090   if (strncmp (arg, "11/", 3) == 0)
1091     arg += 3;
1092
1093   if (strcmp (arg, "03") == 0)                  /* 11/03 */
1094     return set_cpu_model ("kd11f");             /* KD11-F */
1095
1096   else if (strcmp (arg, "04") == 0)             /* 11/04 */
1097     return set_cpu_model ("kd11d");             /* KD11-D */
1098
1099   else if (strcmp (arg, "05") == 0 ||           /* 11/05 or 11/10 */
1100            strcmp (arg, "10") == 0)
1101     return set_cpu_model ("kd11b");             /* KD11-B */
1102
1103   else if (strcmp (arg, "15") == 0 ||           /* 11/15 or 11/20 */
1104            strcmp (arg, "20") == 0)
1105     return set_cpu_model ("ka11");              /* KA11 */
1106
1107   else if (strcmp (arg, "21") == 0)             /* 11/21 */
1108     return set_cpu_model ("t11");               /* T11 */
1109
1110   else if (strcmp (arg, "23") == 0 ||           /* 11/23 or 11/24 */
1111            strcmp (arg, "24") == 0)
1112     return set_cpu_model ("f11");               /* F11 */
1113
1114   else if (strcmp (arg, "34") == 0 ||           /* 11/34 or 11/34a */
1115            strcmp (arg, "34a") == 0)
1116     return set_cpu_model ("kd11e");             /* KD11-E */
1117
1118   else if (strcmp (arg, "35") == 0 ||           /* 11/35 or 11/40 */
1119            strcmp (arg, "40") == 0)
1120     return set_cpu_model ("kd11da");            /* KD11-A */
1121
1122   else if (strcmp (arg, "44") == 0)             /* 11/44 */
1123     return set_cpu_model ("kd11dz");            /* KD11-Z */
1124
1125   else if (strcmp (arg, "45") == 0 ||           /* 11/45/50/55/70 */
1126            strcmp (arg, "50") == 0 ||
1127            strcmp (arg, "55") == 0 ||
1128            strcmp (arg, "70") == 0)
1129     return set_cpu_model ("kb11");              /* KB11 */
1130
1131   else if (strcmp (arg, "60") == 0)             /* 11/60 */
1132     return set_cpu_model ("kd11k");             /* KD11-K */ /* FPP? */
1133
1134   else if (strcmp (arg, "53") == 0 ||           /* 11/53/73/83/84/93/94 */
1135            strcmp (arg, "73") == 0 ||
1136            strcmp (arg, "83") == 0 ||
1137            strcmp (arg, "84") == 0 ||
1138            strcmp (arg, "93") == 0 ||
1139            strcmp (arg, "94") == 0)
1140     return set_cpu_model ("j11") &&             /* J11 */
1141            set_option ("fpp");                  /* All J11 machines come */
1142                                                 /* with FPP installed.  */
1143   else
1144     return 0;
1145 }
1146
1147 CONST char *md_shortopts = "m:";
1148
1149 struct option md_longopts[] =
1150 {
1151 #define OPTION_CPU 257
1152   { "cpu", required_argument, NULL, OPTION_CPU },
1153 #define OPTION_MACHINE 258
1154   { "machine", required_argument, NULL, OPTION_MACHINE },
1155 #define OPTION_PIC 259
1156   { "pic", no_argument, NULL, OPTION_PIC },
1157   { NULL, no_argument, NULL, 0 }
1158 };
1159
1160 size_t md_longopts_size = sizeof (md_longopts);
1161
1162 /*
1163  * md_parse_option
1164  *      Invocation line includes a switch not recognized by the base assembler.
1165  *      See if it's a processor-specific option.
1166  */
1167
1168 int
1169 md_parse_option (c, arg)
1170      int c;
1171      char *arg;
1172 {
1173   init_defaults ();
1174
1175   switch (c)
1176     {
1177     case 'm':
1178       if (set_option (arg))
1179         return 1;
1180       if (set_cpu_model (arg))
1181         return 1;
1182       if (set_machine_model (arg))
1183         return 1;
1184       break;
1185
1186     case OPTION_CPU:
1187       if (set_cpu_model (arg))
1188         return 1;
1189       break;
1190
1191     case OPTION_MACHINE:
1192       if (set_machine_model (arg))
1193         return 1;
1194       break;
1195
1196     case OPTION_PIC:
1197       if (set_option ("pic"))
1198         return 1;
1199       break;
1200
1201     default:
1202       break;
1203     }
1204
1205   as_bad ("unrecognized option `-%c%s'", c, arg ? arg : "");
1206
1207   return 0;
1208 }
1209
1210 /*
1211 One possible way of parsing options.
1212
1213 enum
1214 {
1215   OPTION_CSM,
1216   OPTION_CIS,
1217   ...
1218 };
1219
1220 struct
1221 {
1222   CONST char *pattern;
1223   int opt;
1224   CONST char *description;
1225 } options;
1226
1227 static struct options extension_opts[] =
1228 {
1229   { "Ncsm", OPTION_CSM,
1230                         "allow (disallow) CSM instruction" },
1231   { "Ncis", OPTION_CIS,
1232                         "allow (disallow) commersial instruction set" },
1233   { "Neis", OPTION_EIS,
1234                         "allow (disallow) extended instruction set" },
1235   ...
1236   { "all-extensions", OPTION_ALL_EXTENSIONS,
1237                         "allow all instruction set extensions\n\
1238                         (this is the default)" },
1239   { "no-extensions", OPTION_NO_EXTENSIONS,
1240                         "disallow all instruction set extensions" },
1241   { "pic", OPTION_PIC,
1242                         "position-independent code" },
1243 };
1244
1245 static struct options cpu_opts[] =
1246 {
1247   { "Ka_11_*", OPTION_KA11, "KA11 CPU. ..." },
1248   { "Kb_11_*", OPTION_KB11, "KB11 CPU. ..." },
1249   { "Kd_11_a*", OPTION_KD11A, "KD11-A CPU. ..." },
1250   { "Kd_11_b*", OPTION_KD11B, "KD11-B CPU. ..." },
1251   { "Kd_11_d*", OPTION_KD11D, "KD11-D CPU. ..." },
1252   { "Kd_11_e*", OPTION_KD11E, "KD11-E CPU. ..." },
1253   { "Kd_11_f*", OPTION_KD11F, "KD11-F CPU. ..." },
1254   { "Kd_11_h*", OPTION_KD11H, "KD11-H CPU. ..." },
1255   { "Kd_11_q*", OPTION_KD11Q, "KD11-Q CPU. ..." },
1256   { "Kd_11_z*", OPTION_KD11Z, "KD11-Z CPU. ..." },
1257   { "Df_11_*", OPTION_F11, "F11 CPU. ..." },
1258   { "Dj_11_*", OPTION_J11, "J11 CPU. ..." },
1259   { "Dt_11_*", OPTION_T11, "T11 CPU. ..." },
1260 };
1261
1262 static struct options model_opts[] =
1263 {
1264   { "P03", OPTION_PDP11_03, "same as ..." },
1265   { "P04", OPTION_PDP11_04, "same as ..." },
1266   { "P05", OPTION_PDP11_05, "same as ..." },
1267   { "P10", OPTION_PDP11_10, "same as ..." },
1268   { "P15", OPTION_PDP11_15, "same as ..." },
1269   { "P20", OPTION_PDP11_20, "same as ..." },
1270   { "P21", OPTION_PDP11_21, "same as ..." },
1271   { "P24", OPTION_PDP11_24, "same as ..." },
1272   { "P34", OPTION_PDP11_34, "same as ..." },
1273   { "P34a", OPTION_PDP11_34A, "same as ..." },
1274   { "P40", OPTION_PDP11_40, "same as ..." },
1275   { "P44", OPTION_PDP11_44, "same as ..." },
1276   { "P45", OPTION_PDP11_45, "same as ..." },
1277   { "P50", OPTION_PDP11_50, "same as ..." },
1278   { "P53", OPTION_PDP11_53, "same as ..." },
1279   { "P55", OPTION_PDP11_55, "same as ..." },
1280   { "P60", OPTION_PDP11_60, "same as ..." },
1281   { "P70", OPTION_PDP11_70, "same as ..." },
1282   { "P73", OPTION_PDP11_73, "same as ..." },
1283   { "P83", OPTION_PDP11_83, "same as ..." },
1284   { "P84", OPTION_PDP11_84, "same as ..." },
1285   { "P93", OPTION_PDP11_93, "same as ..." },
1286   { "P94", OPTION_PDP11_94, "same as ..." },
1287 };
1288
1289 struct
1290 {
1291   CONST char *title;
1292   struct options *opts;
1293   int num;
1294 } all_opts[] =
1295 {
1296   { "PDP-11 instruction set extentions",
1297     extension_opts,
1298     sizeof extension_opts / sizeof extension_opts[0] },
1299   { "PDP-11 CPU model options",
1300     cpu_opts,
1301     sizeof cpu_opts / sizeof cpu_opts[0] },
1302   { "PDP-11 machine model options",
1303     model_opts,
1304     sizeof model_opts / sizeof model_opts[0] },
1305 };
1306
1307 int
1308 parse_match (char *arg, char *pattern)
1309 {
1310   int yes = 1;
1311
1312   while (*pattern)
1313     {
1314       switch (*pattern++)
1315         {
1316         case 'N':
1317           if (strncmp (arg, "no-") == 0)
1318             {
1319               yes = 0;
1320               arg += 3;
1321             }
1322           break;
1323
1324         case 'K':
1325           if (arg[0] == 'k')
1326             arg++;
1327           break;
1328
1329         case 'D':
1330           if (strncmp (arg, "kd", 2) == 0)
1331             arg +=2;
1332           break;
1333
1334         case 'P':
1335           if (strncmp (arg, "pdp-11/", 7) == 0)
1336             arg += 7;
1337           else if (strncmp (arg, "pdp11/", 6) == 0)
1338             arg += 6;
1339           else if (strncmp (arg, "11/", 3) == 0)
1340             arg += 3;
1341           break;
1342
1343         case '_':
1344           if (arg[0] == "-")
1345             {
1346               if (*++arg == 0)
1347                 return 0;
1348             }
1349           break;
1350
1351         case '*':
1352           return 1;
1353
1354         default:
1355           if (*arg++ != pattern[-1])
1356             return 0;
1357         }
1358     }
1359
1360   return arg[0] == 0;
1361 }
1362
1363 int
1364 fprint_opt (stream, pattern)
1365      FILE *stream;
1366      CONST char *pattern;
1367 {
1368   int n;
1369
1370   while (*pattern)
1371     {
1372       switch (*pattern++)
1373         {
1374         case 'N':
1375           n += fprintf (stream, "(no-)");
1376           break;
1377
1378         case 'K':
1379           n += fprintf (stream, "k");
1380           break;
1381
1382         case 'P':
1383           n += fprintf (stream "11/");
1384           break;
1385
1386         case 'D':
1387         case '_':
1388         case '*':
1389           break;
1390
1391         default:
1392           fputc (pattern[-1], stream);
1393           n++;
1394         }
1395     }
1396
1397   return n;
1398 }
1399
1400 int
1401 parse_option (char *arg)
1402 {
1403   int i, j;
1404
1405   for (i = 0; i < sizeof all_opts / sizeof all_opts[0]; i++)
1406     {
1407       for (j = 0; j < all_opts[i].num; j++)
1408         {
1409           if (parse_match (arg, all_opts[i].opts[j].pattern))
1410             {
1411               set_option (all_opts[i].opts[j].opt);
1412               return 1;
1413             }
1414         }
1415     }
1416
1417   return 0;
1418 }
1419
1420 static void
1421 fprint_space (stream, n)
1422      FILE *stream;
1423      int n;
1424 {
1425   while (n--)
1426     fputc (' ', stream);
1427 }
1428
1429 void
1430 md_show_usage (stream)
1431      FILE *stream;
1432 {
1433   int i, j, n;
1434
1435   for (i = 0; i < sizeof all_opts / sizeof all_opts[0]; i++)
1436     {
1437       fprintf (stream "\n%s:\n\n", all_opts[i].title);
1438
1439       for (j = 0; j < all_opts[i].num; j++)
1440         {
1441           fprintf (stream, "-m");
1442           n = fprintf_opt (stream, all_opts[i].opts[j].pattern);
1443           fprint_space (stream, 22 - n);
1444           fprintf (stream, "%s\n", all_opts[i].opts[j].description);
1445         }
1446     }
1447 }
1448 */
1449
1450 void
1451 md_show_usage (stream)
1452      FILE *stream;
1453 {
1454   fprintf (stream, "\
1455 \n\
1456 PDP-11 instruction set extentions:\n\
1457 \n\
1458 -m(no-)cis              allow (disallow) commersial instruction set\n\
1459 -m(no-)csm              allow (disallow) CSM instruction\n\
1460 -m(no-)eis              allow (disallow) full extended instruction set\n\
1461 -m(no-)fis              allow (disallow) KEV11 floating-point instructions\n\
1462 -m(no-)fpp              allow (disallow) FP-11 floating-point instructions\n\
1463 -m(no-)fpu              allow (disallow) FP-11 floating-point instructions\n\
1464 -m(no-)limited-eis      allow (disallow) limited extended instruction set\n\
1465 -m(no-)mfpt             allow (disallow) processor type instruction\n\
1466 -m(no-)multiproc        allow (disallow) multiprocessor instructions\n\
1467 -m(no-)mxps             allow (disallow) processor status instructions\n\
1468 -m(no-)spl              allow (disallow) SPL instruction\n\
1469 -m(no-)ucode            allow (disallow) microcode instructions\n\
1470 -mall-extensions        allow all instruction set extensions\n\
1471                         (this is the default)\n\
1472 -mno-extentions         disallow all instruction set extensions\n\
1473 -pic                    generate position-indepenent code\n\
1474 \n\
1475 PDP-11 CPU model options:\n\
1476 \n\
1477 -mka11*                 KA11 CPU.  base line instruction set only\n\
1478 -mkb11*                 KB11 CPU.  enable full EIS and SPL\n\
1479 -mkd11a*                KD11-A CPU.  enable limited EIS\n\
1480 -mkd11b*                KD11-B CPU.  base line instruction set only\n\
1481 -mkd11d*                KD11-D CPU.  base line instruction set only\n\
1482 -mkd11e*                KD11-E CPU.  enable full EIS, MTPS, and MFPS\n\
1483 -mkd11f*                KD11-F CPU.  enable limited EIS, MTPS, and MFPS\n\
1484 -mkd11h*                KD11-H CPU.  enable limited EIS, MTPS, and MFPS\n\
1485 -mkd11q*                KD11-Q CPU.  enable limited EIS, MTPS, and MFPS\n\
1486 -mkd11k*                KD11-K CPU.  enable full EIS, MTPS, MFPS, LDUB, MED,\n\
1487                         XFC, and MFPT\n\
1488 -mkd11z*                KD11-Z CPU.  enable full EIS, MTPS, MFPS, MFPT, SPL,\n\
1489                         and CSM\n\
1490 -mf11*                  F11 CPU.  enable full EIS, MFPS, MTPS, and MFPT\n\
1491 -mj11*                  J11 CPU.  enable full EIS, MTPS, MFPS, MFPT, SPL,\n\
1492                         CSM, TSTSET, and WRTLCK\n\
1493 -mt11*                  T11 CPU.  enable limited EIS, MTPS, and MFPS\n\
1494 \n\
1495 PDP-11 machine model options:\n\
1496 \n\
1497 -m11/03                 same as -mkd11f\n\
1498 -m11/04                 same as -mkd11d\n\
1499 -m11/05                 same as -mkd11b\n\
1500 -m11/10                 same as -mkd11b\n\
1501 -m11/15                 same as -mka11\n\
1502 -m11/20                 same as -mka11\n\
1503 -m11/21                 same as -mt11\n\
1504 -m11/23                 same as -mf11\n\
1505 -m11/24                 same as -mf11\n\
1506 -m11/34                 same as -mkd11e\n\
1507 -m11/34a                same as -mkd11e -mfpp\n\
1508 -m11/35                 same as -mkd11a\n\
1509 -m11/40                 same as -mkd11a\n\
1510 -m11/44                 same as -mkd11z\n\
1511 -m11/45                 same as -mkb11\n\
1512 -m11/50                 same as -mkb11\n\
1513 -m11/53                 same as -mj11\n\
1514 -m11/55                 same as -mkb11\n\
1515 -m11/60                 same as -mkd11k\n\
1516 -m11/70                 same as -mkb11\n\
1517 -m11/73                 same as -mj11\n\
1518 -m11/83                 same as -mj11\n\
1519 -m11/84                 same as -mj11\n\
1520 -m11/93                 same as -mj11\n\
1521 -m11/94                 same as -mj11\n\
1522 ");
1523 }
1524
1525 symbolS *
1526 md_undefined_symbol (name)
1527      char *name ATTRIBUTE_UNUSED;
1528 {
1529   return 0;
1530 }
1531
1532 valueT
1533 md_section_align (segment, size)
1534      segT segment ATTRIBUTE_UNUSED;
1535      valueT size;
1536 {
1537   return (size + 1) & ~1;
1538 }
1539
1540 long
1541 md_pcrel_from (fixP)
1542      fixS *fixP;
1543 {
1544   return fixP->fx_frag->fr_address + fixP->fx_where + fixP->fx_size;
1545 }
1546
1547 /* Translate internal representation of relocation info to BFD target
1548    format.  */
1549 arelent *
1550 tc_gen_reloc (section, fixp)
1551      asection *section ATTRIBUTE_UNUSED;
1552      fixS *fixp;
1553 {
1554   arelent *reloc;
1555   bfd_reloc_code_real_type code;
1556
1557   reloc = (arelent *) xmalloc (sizeof (arelent));
1558
1559   reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
1560   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
1561   reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
1562
1563   /* this is taken account for in md_apply_fix() */
1564   reloc->addend = -symbol_get_bfdsym (fixp->fx_addsy)->section->vma;
1565
1566   switch (fixp->fx_r_type)
1567     {
1568     case BFD_RELOC_16:
1569       if (fixp->fx_pcrel)
1570         code = BFD_RELOC_16_PCREL;
1571       else
1572         code = BFD_RELOC_16;
1573       break;
1574
1575     case BFD_RELOC_16_PCREL:
1576       code = BFD_RELOC_16_PCREL;
1577       break;
1578
1579     default:
1580       BAD_CASE (fixp->fx_r_type);
1581       return NULL;
1582     }
1583
1584   reloc->howto = bfd_reloc_type_lookup (stdoutput, code);
1585
1586   if (reloc->howto == NULL)
1587     {
1588       as_bad_where (fixp->fx_file, fixp->fx_line,
1589                     "Can not represent %s relocation in this object file format",
1590                     bfd_get_reloc_code_name (code));
1591       return NULL;
1592     }
1593
1594   return reloc;
1595 }
1596
1597 void
1598 pseudo_bss (c)
1599      int c ATTRIBUTE_UNUSED;
1600 {
1601   int temp;
1602
1603   temp = get_absolute_expression ();
1604   subseg_set (bss_section, temp);
1605   demand_empty_rest_of_line ();
1606 }
1607
1608 void
1609 pseudo_even (c)
1610      int c ATTRIBUTE_UNUSED;
1611 {
1612   int alignment = 1; /* 2^1 */
1613   frag_align (alignment, 0, 1);
1614   record_alignment (now_seg, alignment);
1615 }
1616
1617 /* end of tc-pdp11.c */