~ubuntu-branches/ubuntu/hoary/binutils/hoary

« back to all changes in this revision

Viewing changes to gas/config/tc-z8k.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2005-03-18 13:07:52 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20050318130752-j4i37zgqclj53b94
Tags: 2.15-5ubuntu2
debian/rules: Call pkgstriptranslations if present (the package does not
use debhelper, thus it does not happen automatically).

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
/* This is non-zero if target was set from the command line.  */
42
42
static int z8k_target_from_cmdline;
43
43
 
44
 
static void s_segm PARAMS ((int));
45
 
static void even PARAMS ((int));
46
 
static int tohex PARAMS ((int));
47
 
static void sval PARAMS ((int));
48
 
 
49
44
static void
50
 
s_segm (segm)
51
 
     int segm;
 
45
s_segm (int segm)
52
46
{
53
47
  if (segm)
54
48
    {
55
 
  segmented_mode = 1;
56
 
  machine = bfd_mach_z8001;
57
 
  coff_flags = F_Z8001;
 
49
      segmented_mode = 1;
 
50
      machine = bfd_mach_z8001;
 
51
      coff_flags = F_Z8001;
58
52
    }
59
53
  else
60
54
    {
61
 
  segmented_mode = 0;
62
 
  machine = bfd_mach_z8002;
63
 
  coff_flags = F_Z8002;
 
55
      segmented_mode = 0;
 
56
      machine = bfd_mach_z8002;
 
57
      coff_flags = F_Z8002;
64
58
    }
65
59
}
66
60
 
67
61
static void
68
 
even (ignore)
69
 
     int ignore ATTRIBUTE_UNUSED;
 
62
even (int ignore ATTRIBUTE_UNUSED)
70
63
{
71
64
  frag_align (1, 0, 0);
72
65
  record_alignment (now_seg, 1);
73
66
}
74
67
 
75
68
static int
76
 
tohex (c)
77
 
     int c;
 
69
tohex (int c)
78
70
{
79
71
  if (ISDIGIT (c))
80
72
    return c - '0';
84
76
}
85
77
 
86
78
static void
87
 
sval (ignore)
88
 
     int ignore ATTRIBUTE_UNUSED;
 
79
sval (int ignore ATTRIBUTE_UNUSED)
89
80
{
90
81
  SKIP_WHITESPACE ();
91
82
  if (*input_line_pointer == '\'')
155
146
static struct hash_control *opcode_hash_control;
156
147
 
157
148
void
158
 
md_begin ()
 
149
md_begin (void)
159
150
{
160
151
  const opcode_entry_type *opcode;
161
152
  int idx = -1;
186
177
    }
187
178
}
188
179
 
189
 
struct z8k_exp {
190
 
  char *e_beg;
191
 
  char *e_end;
192
 
  expressionS e_exp;
193
 
};
194
 
 
195
180
typedef struct z8k_op {
196
181
  /* CLASS_REG_xxx.  */
197
182
  int regsize;
211
196
static expressionS *da_operand;
212
197
static expressionS *imm_operand;
213
198
 
214
 
int reg[16];
215
 
int the_cc;
216
 
int the_ctrl;
217
 
int the_flags;
218
 
int the_interrupt;
219
 
 
220
 
static char *whatreg PARAMS ((int *, char *));
221
 
static char *parse_reg PARAMS ((char *, int *, unsigned int *));
222
 
static char *parse_exp PARAMS ((char *, expressionS *));
223
 
static char *checkfor PARAMS ((char *, char));
224
 
static void regword PARAMS ((int, char *));
225
 
static void regaddr PARAMS ((int, char *));
226
 
static void get_ctrl_operand
227
 
  PARAMS ((char **, struct z8k_op *, unsigned int));
228
 
static void get_flags_operand
229
 
  PARAMS ((char **, struct z8k_op *, unsigned int));
230
 
static void get_interrupt_operand
231
 
  PARAMS ((char **, struct z8k_op *, unsigned int));
232
 
static void get_cc_operand
233
 
  PARAMS ((char **, struct z8k_op *, unsigned int));
234
 
static void get_operand
235
 
  PARAMS ((char **, struct z8k_op *, unsigned int));
236
 
static char *get_operands
237
 
  PARAMS ((const opcode_entry_type *, char *, op_type *));
238
 
static opcode_entry_type *get_specific
239
 
  PARAMS ((opcode_entry_type *, op_type *));
240
 
static void newfix
241
 
  PARAMS ((int, int, int, expressionS *));
242
 
static char *apply_fix
243
 
  PARAMS ((char *, int, expressionS *, int));
244
 
static void build_bytes
245
 
  PARAMS ((opcode_entry_type *, struct z8k_op *));
 
199
static int reg[16];
 
200
static int the_cc;
 
201
static int the_ctrl;
 
202
static int the_flags;
 
203
static int the_interrupt;
246
204
 
247
205
static char *
248
 
whatreg (reg, src)
249
 
     int *reg;
250
 
     char *src;
 
206
whatreg (int *reg, char *src)
251
207
{
252
208
  if (ISDIGIT (src[1]))
253
209
    {
279
235
   in SRC after the reg name.  */
280
236
 
281
237
static char *
282
 
parse_reg (src, mode, reg)
283
 
     char *src;
284
 
     int *mode;
285
 
     unsigned int *reg;
 
238
parse_reg (char *src, int *mode, unsigned int *reg)
286
239
{
287
240
  char *res = 0;
288
241
  char regno;
289
242
 
290
 
  if (src[0] == 's' && src[1] == 'p' && (src[2] == 0 || src[2] == ','))
 
243
  /* Check for stack pointer "sp" alias.  */
 
244
  if ((src[0] == 's' || src[0] == 'S')
 
245
      && (src[1] == 'p' || src[1] == 'P')
 
246
      && (src[2] == 0 || src[2] == ','))
291
247
    {
292
248
      if (segmented_mode)
293
249
        {
301
257
        }
302
258
      return src + 2;
303
259
    }
304
 
  if (src[0] == 'r')
 
260
 
 
261
  if (src[0] == 'r' || src[0] == 'R')
305
262
    {
306
 
      if (src[1] == 'r')
 
263
      if (src[1] == 'r' || src[1] == 'R')
307
264
        {
308
265
          if (src[2] < '0' || src[2] > '9')
309
266
            return res;  /* Assume no register name but a label starting with 'rr'.  */
315
272
          if (regno & 1)
316
273
            as_bad (_("register rr%d does not exist"), regno);
317
274
        }
318
 
      else if (src[1] == 'h')
 
275
      else if (src[1] == 'h' || src[1] == 'H')
319
276
        {
320
277
          if (src[2] < '0' || src[2] > '9')
321
278
            return res;  /* Assume no register name but a label starting with 'rh'.  */
325
282
          if (regno > 7)
326
283
            as_bad (_("register rh%d out of range"), regno);
327
284
        }
328
 
      else if (src[1] == 'l')
 
285
      else if (src[1] == 'l' || src[1] == 'L')
329
286
        {
330
287
          if (src[2] < '0' || src[2] > '9')
331
288
            return res;  /* Assume no register name but a label starting with 'rl'.  */
336
293
            as_bad (_("register rl%d out of range"), regno);
337
294
          *reg += 8;
338
295
        }
339
 
      else if (src[1] == 'q')
 
296
      else if (src[1] == 'q' || src[1] == 'Q')
340
297
        {
341
298
          if (src[2] < '0' || src[2] > '9')
342
299
            return res;  /* Assume no register name but a label starting with 'rq'.  */
363
320
}
364
321
 
365
322
static char *
366
 
parse_exp (s, op)
367
 
     char *s;
368
 
     expressionS *op;
 
323
parse_exp (char *s, expressionS *op)
369
324
{
370
325
  char *save = input_line_pointer;
371
326
  char *new;
394
349
   */
395
350
 
396
351
static char *
397
 
checkfor (ptr, what)
398
 
     char *ptr;
399
 
     char what;
 
352
checkfor (char *ptr, char what)
400
353
{
401
354
  if (*ptr == what)
402
355
    ptr++;
409
362
/* Make sure the mode supplied is the size of a word.  */
410
363
 
411
364
static void
412
 
regword (mode, string)
413
 
     int mode;
414
 
     char *string;
 
365
regword (int mode, char *string)
415
366
{
416
367
  int ok;
417
368
 
425
376
/* Make sure the mode supplied is the size of an address.  */
426
377
 
427
378
static void
428
 
regaddr (mode, string)
429
 
     int mode;
430
 
     char *string;
 
379
regaddr (int mode, char *string)
431
380
{
432
381
  int ok;
433
382
 
443
392
  char *name;
444
393
};
445
394
 
446
 
struct ctrl_names ctrl_table[] = {
447
 
  { 0x2, "fcw" },
 
395
static struct ctrl_names ctrl_table[] = {
 
396
  { 0x1, "flags" },   /* ldctlb only.  */
 
397
  { 0x2, "fcw" },     /* ldctl only.  Applies to all remaining control registers.  */
448
398
  { 0x3, "refresh" },
449
399
  { 0x4, "psapseg" },
450
400
  { 0x5, "psapoff" },
456
406
};
457
407
 
458
408
static void
459
 
get_ctrl_operand (ptr, mode, dst)
460
 
     char **ptr;
461
 
     struct z8k_op *mode;
462
 
     unsigned int dst ATTRIBUTE_UNUSED;
 
409
get_ctrl_operand (char **ptr, struct z8k_op *mode, unsigned int dst ATTRIBUTE_UNUSED)
463
410
{
464
411
  char *src = *ptr;
465
 
  int i;
 
412
  int i, l;
466
413
 
467
414
  while (*src == ' ')
468
415
    src++;
470
417
  mode->mode = CLASS_CTRL;
471
418
  for (i = 0; ctrl_table[i].name; i++)
472
419
    {
473
 
      int j;
474
 
 
475
 
      for (j = 0; ctrl_table[i].name[j]; j++)
476
 
        {
477
 
          if (ctrl_table[i].name[j] != src[j])
478
 
            goto fail;
479
 
        }
480
 
      the_ctrl = ctrl_table[i].value;
481
 
      *ptr = src + j;
482
 
      return;
483
 
    fail:
484
 
      ;
 
420
      l = strlen (ctrl_table[i].name);
 
421
      if (! strncasecmp (ctrl_table[i].name, src, l))
 
422
        {
 
423
          the_ctrl = ctrl_table[i].value;
 
424
          if (*(src + l) && *(src + l) != ',')
 
425
            break;
 
426
          *ptr = src + l;  /* Valid control name found: "consume" it.  */
 
427
          return;
 
428
        }
485
429
    }
486
430
  the_ctrl = 0;
487
 
  return;
488
431
}
489
432
 
490
433
struct flag_names {
491
434
  int value;
492
435
  char *name;
493
 
 
494
436
};
495
437
 
496
 
struct flag_names flag_table[] = {
497
 
  { 0x1, "p" },
498
 
  { 0x1, "v" },
499
 
  { 0x2, "s" },
500
 
  { 0x4, "z" },
501
 
  { 0x8, "c" },
 
438
static struct flag_names flag_table[] = {
 
439
  { 0x1, "P" },
 
440
  { 0x1, "V" },
 
441
  { 0x2, "S" },
 
442
  { 0x4, "Z" },
 
443
  { 0x8, "C" },
502
444
  { 0x0, "+" },
 
445
  { 0x0, "," },
503
446
  { 0, 0 }
504
447
};
505
448
 
506
449
static void
507
 
get_flags_operand (ptr, mode, dst)
508
 
     char **ptr;
509
 
     struct z8k_op *mode;
510
 
     unsigned int dst ATTRIBUTE_UNUSED;
 
450
get_flags_operand (char **ptr, struct z8k_op *mode, unsigned int dst ATTRIBUTE_UNUSED)
511
451
{
512
452
  char *src = *ptr;
 
453
  char c;
513
454
  int i;
514
455
  int j;
515
456
 
522
463
    {
523
464
      if (!src[j])
524
465
        goto done;
 
466
      c = TOUPPER(src[j]);
525
467
      for (i = 0; flag_table[i].name; i++)
526
468
        {
527
 
          if (flag_table[i].name[0] == src[j])
 
469
          if (flag_table[i].name[0] == c)
528
470
            {
529
471
              the_flags = the_flags | flag_table[i].value;
530
472
              goto match;
536
478
    }
537
479
 done:
538
480
  *ptr = src + j;
539
 
  return;
540
481
}
541
482
 
542
483
struct interrupt_names {
543
484
  int value;
544
485
  char *name;
545
 
 
546
486
};
547
487
 
548
 
struct interrupt_names intr_table[] = {
 
488
static struct interrupt_names intr_table[] = {
549
489
  { 0x1, "nvi" },
550
490
  { 0x2, "vi" },
551
491
  { 0x3, "both" },
554
494
};
555
495
 
556
496
static void
557
 
get_interrupt_operand (ptr, mode, dst)
558
 
     char **ptr;
559
 
     struct z8k_op *mode;
560
 
     unsigned int dst ATTRIBUTE_UNUSED;
 
497
get_interrupt_operand (char **ptr, struct z8k_op *mode, unsigned int dst ATTRIBUTE_UNUSED)
561
498
{
562
499
  char *src = *ptr;
563
 
  int i;
 
500
  int i, l;
564
501
 
565
502
  while (*src == ' ')
566
503
    src++;
567
504
 
568
505
  mode->mode = CLASS_IMM;
569
 
  for (i = 0; intr_table[i].name; i++)
 
506
  the_interrupt = 0;
 
507
 
 
508
  while (*src)
570
509
    {
571
 
      int j;
572
 
 
573
 
      for (j = 0; intr_table[i].name[j]; j++)
574
 
        {
575
 
          if (intr_table[i].name[j] != src[j])
576
 
            goto fail;
577
 
        }
578
 
      the_interrupt = intr_table[i].value;
579
 
      *ptr = src + j;
580
 
      return;
581
 
    fail:
582
 
      ;
 
510
      for (i = 0; intr_table[i].name; i++)
 
511
        {
 
512
          l = strlen (intr_table[i].name);
 
513
          if (! strncasecmp (intr_table[i].name, src, l))
 
514
            {
 
515
              the_interrupt |= intr_table[i].value;
 
516
              if (*(src + l) && *(src + l) != ',')
 
517
                {
 
518
                  *ptr = src + l;
 
519
                invalid:
 
520
                  as_bad (_("unknown interrupt %s"), src);
 
521
                  while (**ptr && ! is_end_of_line[(unsigned char) **ptr])
 
522
                    (*ptr)++;    /* Consume rest of line.  */
 
523
                  return;
 
524
                }
 
525
              src += l;
 
526
              if (! *src)
 
527
                {
 
528
                  *ptr = src;
 
529
                  return;
 
530
                }
 
531
            }
 
532
        }
 
533
      if (*src == ',')
 
534
        src++;
 
535
      else
 
536
        {
 
537
          *ptr = src;
 
538
          goto invalid;
 
539
        }
583
540
    }
 
541
 
584
542
  /* No interrupt type specified, opcode won't do anything.  */
585
543
  as_warn (_("opcode has no effect"));
586
544
  the_interrupt = 0x0;
587
 
  return;
588
545
}
589
546
 
590
547
struct cc_names {
592
549
  char *name;
593
550
};
594
551
 
595
 
struct cc_names table[] = {
 
552
static struct cc_names table[] = {
596
553
  { 0x0, "f" },
597
554
  { 0x1, "lt" },
598
555
  { 0x2, "le" },
599
556
  { 0x3, "ule" },
 
557
  { 0x4, "ov/pe" },
600
558
  { 0x4, "ov" },
 
559
  { 0x4, "pe/ov" },
601
560
  { 0x4, "pe" },
602
561
  { 0x5, "mi" },
603
562
  { 0x6, "eq" },
604
563
  { 0x6, "z" },
 
564
  { 0x7, "c/ult" },
605
565
  { 0x7, "c" },
 
566
  { 0x7, "ult/c" },
606
567
  { 0x7, "ult" },
607
568
  { 0x8, "t" },
608
569
  { 0x9, "ge" },
609
570
  { 0xa, "gt" },
610
571
  { 0xb, "ugt" },
 
572
  { 0xc, "nov/po" },
611
573
  { 0xc, "nov" },
 
574
  { 0xc, "po/nov" },
612
575
  { 0xc, "po" },
613
576
  { 0xd, "pl" },
614
577
  { 0xe, "ne" },
615
578
  { 0xe, "nz" },
 
579
  { 0xf, "nc/uge" },
616
580
  { 0xf, "nc" },
 
581
  { 0xf, "uge/nc" },
617
582
  { 0xf, "uge" },
618
583
  { 0  ,  0 }
619
584
};
620
585
 
621
586
static void
622
 
get_cc_operand (ptr, mode, dst)
623
 
     char **ptr;
624
 
     struct z8k_op *mode;
625
 
     unsigned int dst ATTRIBUTE_UNUSED;
 
587
get_cc_operand (char **ptr, struct z8k_op *mode, unsigned int dst ATTRIBUTE_UNUSED)
626
588
{
627
589
  char *src = *ptr;
628
 
  int i;
 
590
  int i, l;
629
591
 
630
592
  while (*src == ' ')
631
593
    src++;
633
595
  mode->mode = CLASS_CC;
634
596
  for (i = 0; table[i].name; i++)
635
597
    {
636
 
      int j;
637
 
 
638
 
      for (j = 0; table[i].name[j]; j++)
639
 
        {
640
 
          if (table[i].name[j] != src[j])
641
 
            goto fail;
642
 
        }
643
 
      the_cc = table[i].value;
644
 
      *ptr = src + j;
645
 
      return;
646
 
    fail:
647
 
      ;
 
598
      l = strlen (table[i].name);
 
599
      if (! strncasecmp (table[i].name, src, l))
 
600
        {
 
601
          the_cc = table[i].value;
 
602
          if (*(src + l) && *(src + l) != ',')
 
603
            break;
 
604
          *ptr = src + l;  /* Valid cc found: "consume" it.  */
 
605
          return;
 
606
        }
648
607
    }
649
 
  the_cc = 0x8;
 
608
  the_cc = 0x8;  /* Not recognizing the cc defaults to t.  (Assuming no cc present.)  */
650
609
}
651
610
 
652
611
static void
653
 
get_operand (ptr, mode, dst)
654
 
     char **ptr;
655
 
     struct z8k_op *mode;
656
 
     unsigned int dst ATTRIBUTE_UNUSED;
 
612
get_operand (char **ptr, struct z8k_op *mode, unsigned int dst ATTRIBUTE_UNUSED)
657
613
{
658
614
  char *src = *ptr;
659
615
  char *end;
755
711
}
756
712
 
757
713
static char *
758
 
get_operands (opcode, op_end, operand)
759
 
     const opcode_entry_type *opcode;
760
 
     char *op_end;
761
 
     op_type *operand;
 
714
get_operands (const opcode_entry_type *opcode, char *op_end, op_type *operand)
762
715
{
763
716
  char *ptr = op_end;
764
717
  char *savptr;
765
718
 
766
 
  ptr++;
767
719
  switch (opcode->noperands)
768
720
    {
769
721
    case 0:
770
722
      operand[0].mode = 0;
771
723
      operand[1].mode = 0;
 
724
      while (*ptr == ' ')
 
725
        ptr++;
772
726
      break;
773
727
 
774
728
    case 1:
775
729
      if (opcode->arg_info[0] == CLASS_CC)
776
 
        get_cc_operand (&ptr, operand + 0, 0);
777
 
 
 
730
        {
 
731
          get_cc_operand (&ptr, operand + 0, 0);
 
732
          while (*ptr == ' ')
 
733
            ptr++;
 
734
          if (*ptr && ! is_end_of_line[(unsigned char) *ptr])
 
735
            {
 
736
              as_bad (_("invalid condition code '%s'"), ptr);
 
737
              while (*ptr && ! is_end_of_line[(unsigned char) *ptr])
 
738
                ptr++;   /* Consume rest of line.  */
 
739
            }
 
740
        }
778
741
      else if (opcode->arg_info[0] == CLASS_FLAGS)
779
 
        get_flags_operand (&ptr, operand + 0, 0);
780
 
 
 
742
        {
 
743
          get_flags_operand (&ptr, operand + 0, 0);
 
744
          while (*ptr == ' ')
 
745
            ptr++;
 
746
          if (*ptr && ! is_end_of_line[(unsigned char) *ptr])
 
747
            {
 
748
              as_bad (_("invalid flag '%s'"), ptr);
 
749
              while (*ptr && ! is_end_of_line[(unsigned char) *ptr])
 
750
                ptr++;   /* Consume rest of line.  */
 
751
            }
 
752
        }
781
753
      else if (opcode->arg_info[0] == (CLASS_IMM + (ARG_IMM2)))
782
754
        get_interrupt_operand (&ptr, operand + 0, 0);
783
 
 
784
755
      else
785
756
        get_operand (&ptr, operand + 0, 0);
786
757
 
790
761
    case 2:
791
762
      savptr = ptr;
792
763
      if (opcode->arg_info[0] == CLASS_CC)
793
 
        get_cc_operand (&ptr, operand + 0, 0);
794
 
 
 
764
        {
 
765
          get_cc_operand (&ptr, operand + 0, 0);
 
766
          while (*ptr == ' ')
 
767
            ptr++;
 
768
          if (*ptr != ',' && strchr (ptr + 1, ','))
 
769
            {
 
770
              savptr = ptr;
 
771
              while (*ptr != ',')
 
772
                ptr++;
 
773
              *ptr = 0;
 
774
              ptr++;
 
775
              as_bad (_("invalid condition code '%s'"), savptr);
 
776
            }
 
777
        }
795
778
      else if (opcode->arg_info[0] == CLASS_CTRL)
796
779
        {
797
780
          get_ctrl_operand (&ptr, operand + 0, 0);
806
789
              if (*ptr == ',')
807
790
                ptr++;
808
791
              get_ctrl_operand (&ptr, operand + 1, 1);
 
792
              if (the_ctrl == 0)
 
793
                return NULL;
809
794
              return ptr;
810
795
            }
811
796
        }
854
839
   provided.  */
855
840
 
856
841
static opcode_entry_type *
857
 
get_specific (opcode, operands)
858
 
     opcode_entry_type *opcode;
859
 
     op_type *operands;
 
842
get_specific (opcode_entry_type *opcode, op_type *operands)
860
843
{
861
844
  opcode_entry_type *this_try = opcode;
862
845
  int found = 0;
937
920
            case CLASS_REGN0:
938
921
              reg[this_try->arg_info[i] & ARG_MASK] = operands[i].reg;
939
922
              break;
 
923
            case CLASS_CTRL:
 
924
              if (this_try->opcode == OPC_ldctlb && the_ctrl != 1)
 
925
                as_bad (_("invalid control register name"));
 
926
              break;
940
927
            }
941
928
        }
942
929
 
950
937
    return 0;
951
938
}
952
939
 
953
 
#if 0 /* Not used.  */
954
 
static void
955
 
check_operand (operand, width, string)
956
 
     struct z8k_op *operand;
957
 
     unsigned int width;
958
 
     char *string;
959
 
{
960
 
  if (operand->exp.X_add_symbol == 0
961
 
      && operand->exp.X_op_symbol == 0)
962
 
    {
963
 
 
964
 
      /* No symbol involved, let's look at offset, it's dangerous if
965
 
         any of the high bits are not 0 or ff's, find out by oring or
966
 
         anding with the width and seeing if the answer is 0 or all
967
 
         fs.  */
968
 
      if ((operand->exp.X_add_number & ~width) != 0 &&
969
 
          (operand->exp.X_add_number | width) != (~0))
970
 
        {
971
 
          as_warn (_("operand %s0x%x out of range"),
972
 
                   string, operand->exp.X_add_number);
973
 
        }
974
 
    }
975
 
 
976
 
}
977
 
#endif
978
 
 
979
940
static char buffer[20];
980
941
 
981
942
static void
982
 
newfix (ptr, type, size, operand)
983
 
     int ptr;
984
 
     int type;
985
 
     int size;   /* nibbles.  */
986
 
     expressionS *operand;
 
943
newfix (int ptr, int type, int size, expressionS *operand)
987
944
{
988
945
  int is_pcrel = 0;
989
946
 
 
947
  /* size is in nibbles.  */
 
948
 
990
949
  if (operand->X_add_symbol
991
950
      || operand->X_op_symbol
992
951
      || operand->X_add_number)
1008
967
}
1009
968
 
1010
969
static char *
1011
 
apply_fix (ptr, type, operand, size)
1012
 
     char *ptr;
1013
 
     int type;
1014
 
     expressionS *operand;
1015
 
     int size;   /* nibbles.  */
 
970
apply_fix (char *ptr, int type, expressionS *operand, int size)
1016
971
{
1017
972
  long n = operand->X_add_number;
1018
973
 
 
974
  /* size is in nibbles.  */
 
975
 
1019
976
  newfix ((ptr - buffer) / 2, type, size + 1, operand);
1020
977
  switch (size)
1021
978
    {
1041
998
#define INSERT(x,y) *x++ = y>>24; *x++ = y>> 16; *x++=y>>8; *x++ =y;
1042
999
 
1043
1000
static void
1044
 
build_bytes (this_try, operand)
1045
 
     opcode_entry_type *this_try;
1046
 
     struct z8k_op *operand ATTRIBUTE_UNUSED;
 
1001
build_bytes (opcode_entry_type *this_try, struct z8k_op *operand ATTRIBUTE_UNUSED)
1047
1002
{
1048
1003
  char *output_ptr = buffer;
1049
1004
  int c;
1115
1070
          *output_ptr++ = the_cc;
1116
1071
          break;
1117
1072
        case CLASS_0CCC:
 
1073
          if (the_ctrl < 2 || the_ctrl > 7)
 
1074
            as_bad (_("invalid control register name"));
1118
1075
          *output_ptr++ = the_ctrl;
1119
1076
          break;
1120
1077
        case CLASS_1CCC:
 
1078
          if (the_ctrl < 2 || the_ctrl > 7)
 
1079
            as_bad (_("invalid control register name"));
1121
1080
          *output_ptr++ = the_ctrl | 0x8;
1122
1081
          break;
1123
1082
        case CLASS_00II:
1222
1181
   the frags/bytes it assembles to.  */
1223
1182
 
1224
1183
void
1225
 
md_assemble (str)
1226
 
     char *str;
 
1184
md_assemble (char *str)
1227
1185
{
1228
1186
  char c;
1229
1187
  char *op_start;
1230
1188
  char *op_end;
1231
1189
  struct z8k_op operand[3];
1232
1190
  opcode_entry_type *opcode;
1233
 
  opcode_entry_type *prev_opcode;
1234
1191
 
1235
1192
  /* Drop leading whitespace.  */
1236
1193
  while (*str == ' ')
1238
1195
 
1239
1196
  /* Find the op code end.  */
1240
1197
  for (op_start = op_end = str;
1241
 
       *op_end != 0 && *op_end != ' ';
 
1198
       *op_end != 0 && *op_end != ' ' && ! is_end_of_line[(unsigned char) *op_end];
1242
1199
       op_end++)
1243
1200
    ;
1244
1201
 
1248
1205
    }
1249
1206
  c = *op_end;
1250
1207
 
1251
 
  *op_end = 0;
 
1208
  *op_end = 0;  /* Zero-terminate op code string for hash_find() call.  */
1252
1209
 
1253
1210
  opcode = (opcode_entry_type *) hash_find (opcode_hash_control, op_start);
1254
1211
 
1258
1215
      return;
1259
1216
    }
1260
1217
 
 
1218
  *op_end = c;  /* Restore original string.  */
 
1219
 
1261
1220
  if (opcode->opcode == 250)
1262
1221
    {
1263
1222
      pseudo_typeS *p;
1264
1223
      char oc;
1265
1224
      char *old = input_line_pointer;
1266
 
      *op_end = c;
1267
1225
 
1268
1226
      /* Was really a pseudo op.  */
1269
1227
 
1286
1244
      new_input_line_pointer = get_operands (opcode, op_end, operand);
1287
1245
      if (new_input_line_pointer)
1288
1246
        input_line_pointer = new_input_line_pointer;
1289
 
      prev_opcode = opcode; /* XXX is this used ?? */
1290
1247
 
1291
1248
      opcode = get_specific (opcode, operand);
1292
1249
 
1307
1264
}
1308
1265
 
1309
1266
void
1310
 
tc_crawl_symbol_chain (headers)
1311
 
     object_headers *headers ATTRIBUTE_UNUSED;
 
1267
tc_crawl_symbol_chain (object_headers *headers ATTRIBUTE_UNUSED)
1312
1268
{
1313
1269
  printf (_("call to tc_crawl_symbol_chain \n"));
1314
1270
}
1316
1272
/* We have no need to default values of symbols.  */
1317
1273
 
1318
1274
symbolS *
1319
 
md_undefined_symbol (name)
1320
 
     char *name ATTRIBUTE_UNUSED;
 
1275
md_undefined_symbol (char *name ATTRIBUTE_UNUSED)
1321
1276
{
1322
1277
  return 0;
1323
1278
}
1324
1279
 
1325
1280
void
1326
 
tc_headers_hook (headers)
1327
 
     object_headers *headers ATTRIBUTE_UNUSED;
 
1281
tc_headers_hook (object_headers *headers ATTRIBUTE_UNUSED)
1328
1282
{
1329
1283
  printf (_("call to tc_headers_hook \n"));
1330
1284
}
1339
1293
   returned, or NULL on OK.  */
1340
1294
 
1341
1295
char *
1342
 
md_atof (type, litP, sizeP)
1343
 
     char type;
1344
 
     char *litP;
1345
 
     int *sizeP;
 
1296
md_atof (int type, char *litP, int *sizeP)
1346
1297
{
1347
1298
  int prec;
1348
1299
  LITTLENUM_TYPE words[MAX_LITTLENUMS];
1404
1355
size_t md_longopts_size = sizeof (md_longopts);
1405
1356
 
1406
1357
int
1407
 
md_parse_option (c, arg)
1408
 
     int c;
1409
 
     char *arg;
 
1358
md_parse_option (int c, char *arg)
1410
1359
{
1411
1360
  switch (c)
1412
1361
    {
1435
1384
}
1436
1385
 
1437
1386
void
1438
 
md_show_usage (stream)
1439
 
     FILE *stream;
 
1387
md_show_usage (FILE *stream)
1440
1388
{
1441
1389
  fprintf (stream, _("\
1442
1390
 Z8K options:\n\
1446
1394
}
1447
1395
 
1448
1396
void
1449
 
md_convert_frag (headers, seg, fragP)
1450
 
     object_headers *headers ATTRIBUTE_UNUSED;
1451
 
     segT seg ATTRIBUTE_UNUSED;
1452
 
     fragS *fragP ATTRIBUTE_UNUSED;
 
1397
md_convert_frag (object_headers *headers ATTRIBUTE_UNUSED,
 
1398
                 segT seg ATTRIBUTE_UNUSED,
 
1399
                 fragS *fragP ATTRIBUTE_UNUSED)
1453
1400
{
1454
1401
  printf (_("call to md_convert_frag\n"));
1455
1402
  abort ();
1456
1403
}
1457
1404
 
1458
1405
valueT
1459
 
md_section_align (seg, size)
1460
 
     segT seg;
1461
 
     valueT size;
 
1406
md_section_align (segT seg, valueT size)
1462
1407
{
1463
1408
  return ((size + (1 << section_alignment[(int) seg]) - 1)
1464
1409
          & (-1 << section_alignment[(int) seg]));
1468
1413
   has been eliminated, set fix->fx_done. If fix->fx_addsy is non-NULL,
1469
1414
   we will have to generate a reloc entry.  */
1470
1415
void
1471
 
md_apply_fix3 (fixP, valP, segment)
1472
 
     fixS * fixP;
1473
 
     valueT * valP;
1474
 
     segT segment ATTRIBUTE_UNUSED;
 
1416
md_apply_fix3 (fixS *fixP, valueT *valP, segT segment ATTRIBUTE_UNUSED)
1475
1417
{
1476
1418
  long val = * (long *) valP;
1477
1419
  char *buf = fixP->fx_where + fixP->fx_frag->fr_literal;
1509
1451
        }
1510
1452
      else
1511
1453
        {
1512
 
      if (val & 1)
1513
 
        as_bad (_("cannot branch to odd address"));
1514
 
      val /= 2;
 
1454
          if (val & 1)
 
1455
            as_bad (_("cannot branch to odd address"));
 
1456
          val /= 2;
1515
1457
          if (val > 0 || val < -127)
1516
 
        as_bad (_("relative jump out of range"));
 
1458
            as_bad (_("relative jump out of range"));
1517
1459
          *buf = (*buf & 0x80) | (-val & 0x7f);
1518
 
      fixP->fx_no_overflow = 1;
 
1460
          fixP->fx_no_overflow = 1;
1519
1461
          fixP->fx_done = 1;
1520
1462
        }
1521
1463
      break;
1531
1473
          if (val & 1)
1532
1474
            as_bad (_("cannot branch to odd address"));
1533
1475
          if (val > 4096 || val < -4095)
1534
 
        as_bad (_("relative call out of range"));
 
1476
            as_bad (_("relative call out of range"));
1535
1477
          val = -val / 2;
1536
 
      *buf = (*buf & 0xf0) | ((val >> 8) & 0xf);
1537
 
      buf++;
1538
 
      *buf++ = val & 0xff;
 
1478
          *buf = (*buf & 0xf0) | ((val >> 8) & 0xf);
 
1479
          buf++;
 
1480
          *buf++ = val & 0xff;
1539
1481
          fixP->fx_no_overflow = 1;
1540
1482
          fixP->fx_done = 1;
1541
1483
        }
1589
1531
}
1590
1532
 
1591
1533
int
1592
 
md_estimate_size_before_relax (fragP, segment_type)
1593
 
     register fragS *fragP ATTRIBUTE_UNUSED;
1594
 
     register segT segment_type ATTRIBUTE_UNUSED;
 
1534
md_estimate_size_before_relax (fragS *fragP ATTRIBUTE_UNUSED,
 
1535
                               segT segment_type ATTRIBUTE_UNUSED)
1595
1536
{
1596
1537
  printf (_("call to md_estimate_size_before_relax\n"));
1597
1538
  abort ();
1600
1541
/* Put number into target byte order.  */
1601
1542
 
1602
1543
void
1603
 
md_number_to_chars (ptr, use, nbytes)
1604
 
     char *ptr;
1605
 
     valueT use;
1606
 
     int nbytes;
 
1544
md_number_to_chars (char *ptr, valueT use, int nbytes)
1607
1545
{
1608
1546
  number_to_chars_bigendian (ptr, use, nbytes);
1609
1547
}
1611
1549
/* On the Z8000, a PC-relative offset is relative to the address of the
1612
1550
   instruction plus its size.  */
1613
1551
long
1614
 
md_pcrel_from (fixP)
1615
 
     fixS *fixP;
 
1552
md_pcrel_from (fixS *fixP)
1616
1553
{
1617
1554
  return fixP->fx_size + fixP->fx_where + fixP->fx_frag->fr_address;
1618
1555
}
1619
1556
 
1620
1557
void
1621
 
tc_coff_symbol_emit_hook (s)
1622
 
     symbolS *s ATTRIBUTE_UNUSED;
 
1558
tc_coff_symbol_emit_hook (symbolS *s ATTRIBUTE_UNUSED)
1623
1559
{
1624
1560
}
1625
1561
 
1626
1562
void
1627
 
tc_reloc_mangle (fix_ptr, intr, base)
1628
 
     fixS *fix_ptr;
1629
 
     struct internal_reloc *intr;
1630
 
     bfd_vma base;
1631
 
 
 
1563
tc_reloc_mangle (fixS *fix_ptr, struct internal_reloc *intr, bfd_vma base)
1632
1564
{
1633
1565
  symbolS *symbol_ptr;
1634
1566