1 /* tc-h8300.c -- Assemble code for the Renesas H8/300
2 Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000,
3 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
5 This file is part of GAS, the GNU Assembler.
7 GAS is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GAS is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GAS; see the file COPYING. If not, write to the Free
19 Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
22 /* Written By Steve Chamberlain <sac@cygnus.com>. */
28 #include "dwarf2dbg.h"
31 #define h8_opcodes ops
32 #include "opcode/h8300.h"
33 #include "safe-ctype.h"
39 const char comment_chars
[] = ";";
40 const char line_comment_chars
[] = "#";
41 const char line_separator_chars
[] = "";
43 static void sbranch (int);
44 static void h8300hmode (int);
45 static void h8300smode (int);
46 static void h8300hnmode (int);
47 static void h8300snmode (int);
48 static void h8300sxmode (int);
49 static void h8300sxnmode (int);
50 static void pint (int);
57 #define PSIZE (Hmode && !Nmode ? L_32 : L_16)
59 static int bsize
= L_8
; /* Default branch displacement. */
67 const struct h8_opcode
*opcode
;
70 static struct h8_instruction
*h8_instructions
;
73 h8300hmode (int arg ATTRIBUTE_UNUSED
)
77 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_h8300
, bfd_mach_h8300h
))
78 as_warn (_("could not set architecture and machine"));
82 h8300smode (int arg ATTRIBUTE_UNUSED
)
86 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_h8300
, bfd_mach_h8300s
))
87 as_warn (_("could not set architecture and machine"));
91 h8300hnmode (int arg ATTRIBUTE_UNUSED
)
96 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_h8300
, bfd_mach_h8300hn
))
97 as_warn (_("could not set architecture and machine"));
101 h8300snmode (int arg ATTRIBUTE_UNUSED
)
106 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_h8300
, bfd_mach_h8300sn
))
107 as_warn (_("could not set architecture and machine"));
111 h8300sxmode (int arg ATTRIBUTE_UNUSED
)
116 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_h8300
, bfd_mach_h8300sx
))
117 as_warn (_("could not set architecture and machine"));
121 h8300sxnmode (int arg ATTRIBUTE_UNUSED
)
127 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_h8300
, bfd_mach_h8300sxn
))
128 as_warn (_("could not set architecture and machine"));
138 pint (int arg ATTRIBUTE_UNUSED
)
140 cons (Hmode
? 4 : 2);
143 /* This table describes all the machine specific pseudo-ops the assembler
144 has to support. The fields are:
145 pseudo-op name without dot
146 function to call to execute this pseudo-op
147 Integer arg to pass to the function. */
149 const pseudo_typeS md_pseudo_table
[] =
151 {"h8300h", h8300hmode
, 0},
152 {"h8300hn", h8300hnmode
, 0},
153 {"h8300s", h8300smode
, 0},
154 {"h8300sn", h8300snmode
, 0},
155 {"h8300sx", h8300sxmode
, 0},
156 {"h8300sxn", h8300sxnmode
, 0},
157 {"sbranch", sbranch
, L_8
},
158 {"lbranch", sbranch
, L_16
},
164 {"form", listing_psize
, 0},
165 {"heading", listing_title
, 0},
166 {"import", s_ignore
, 0},
167 {"page", listing_eject
, 0},
168 {"program", s_ignore
, 0},
172 const char EXP_CHARS
[] = "eE";
174 /* Chars that mean this number is a floating point constant
177 const char FLT_CHARS
[] = "rRsSfFdDxXpP";
179 static struct hash_control
*opcode_hash_control
; /* Opcode mnemonics. */
181 /* This function is called once, at assembler startup time. This
182 should set up all the tables, etc. that the MD part of the assembler
188 unsigned int nopcodes
;
189 struct h8_opcode
*p
, *p1
;
190 struct h8_instruction
*pi
;
191 char prev_buffer
[100];
194 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_h8300
, bfd_mach_h8300
))
195 as_warn (_("could not set architecture and machine"));
197 opcode_hash_control
= hash_new ();
200 nopcodes
= sizeof (h8_opcodes
) / sizeof (struct h8_opcode
);
202 h8_instructions
= (struct h8_instruction
*)
203 xmalloc (nopcodes
* sizeof (struct h8_instruction
));
205 pi
= h8_instructions
;
207 /* We do a minimum amount of sorting on the opcode table; this is to
208 make it easy to describe the mova instructions without unnecessary
210 Sorting only takes place inside blocks of instructions of the form
211 X/Y, so for example mova/b, mova/w and mova/l can be intermixed. */
214 struct h8_opcode
*first_skipped
= 0;
216 char *src
= p1
->name
;
221 /* Strip off any . part when inserting the opcode and only enter
222 unique codes into the hash table. */
223 dst
= buffer
= malloc (strlen (src
) + 1);
232 cmplen
= src
- p1
->name
+ 1;
239 hash_insert (opcode_hash_control
, buffer
, (char *) pi
);
240 strcpy (prev_buffer
, buffer
);
243 for (p
= p1
; p
->name
; p
++)
245 /* A negative TIME is used to indicate that we've added this opcode
249 if (strncmp (p
->name
, buffer
, cmplen
) != 0
250 || (p
->name
[cmplen
] != '\0' && p
->name
[cmplen
] != '.'
251 && p
->name
[cmplen
- 1] != '/'))
253 if (first_skipped
== 0)
257 if (strncmp (p
->name
, buffer
, len
) != 0)
259 if (first_skipped
== 0)
265 pi
->size
= p
->name
[len
] == '.' ? p
->name
[len
+ 1] : 0;
268 /* Find the number of operands. */
270 while (pi
->noperands
< 3 && p
->args
.nib
[pi
->noperands
] != (op_type
) E
)
273 /* Find the length of the opcode in bytes. */
275 while (p
->data
.nib
[pi
->length
* 2] != (op_type
) E
)
284 /* Add entry for the NULL vector terminator. */
301 static void clever_message (const struct h8_instruction
*, struct h8_op
*);
302 static void fix_operand_size (struct h8_op
*, int);
303 static void build_bytes (const struct h8_instruction
*, struct h8_op
*);
304 static void do_a_fix_imm (int, int, struct h8_op
*, int);
305 static void check_operand (struct h8_op
*, unsigned int, char *);
306 static const struct h8_instruction
* get_specific (const struct h8_instruction
*, struct h8_op
*, int) ;
307 static char *get_operands (unsigned, char *, struct h8_op
*);
308 static void get_operand (char **, struct h8_op
*, int);
309 static int parse_reg (char *, op_type
*, unsigned *, int);
310 static char *skip_colonthing (char *, int *);
311 static char *parse_exp (char *, struct h8_op
*);
313 static int constant_fits_width_p (struct h8_op
*, unsigned int);
314 static int constant_fits_size_p (struct h8_op
*, int, int);
318 WREG r0,r1,r2,r3,r4,r5,r6,r7,fp,sp
327 /* Try to parse a reg name. Return the number of chars consumed. */
330 parse_reg (char *src
, op_type
*mode
, unsigned int *reg
, int direction
)
335 /* Cribbed from get_symbol_end. */
336 if (!is_name_beginner (*src
) || *src
== '\001')
339 while ((is_part_of_name (*end
) && *end
!= '.') || *end
== '\001')
343 if (len
== 2 && TOLOWER (src
[0]) == 's' && TOLOWER (src
[1]) == 'p')
345 *mode
= PSIZE
| REG
| direction
;
350 TOLOWER (src
[0]) == 'c' &&
351 TOLOWER (src
[1]) == 'c' &&
352 TOLOWER (src
[2]) == 'r')
359 TOLOWER (src
[0]) == 'e' &&
360 TOLOWER (src
[1]) == 'x' &&
361 TOLOWER (src
[2]) == 'r')
368 TOLOWER (src
[0]) == 'v' &&
369 TOLOWER (src
[1]) == 'b' &&
370 TOLOWER (src
[2]) == 'r')
377 TOLOWER (src
[0]) == 's' &&
378 TOLOWER (src
[1]) == 'b' &&
379 TOLOWER (src
[2]) == 'r')
385 if (len
== 2 && TOLOWER (src
[0]) == 'f' && TOLOWER (src
[1]) == 'p')
387 *mode
= PSIZE
| REG
| direction
;
391 if (len
== 3 && TOLOWER (src
[0]) == 'e' && TOLOWER (src
[1]) == 'r' &&
392 src
[2] >= '0' && src
[2] <= '7')
394 *mode
= L_32
| REG
| direction
;
397 as_warn (_("Reg not valid for H8/300"));
400 if (len
== 2 && TOLOWER (src
[0]) == 'e' && src
[1] >= '0' && src
[1] <= '7')
402 *mode
= L_16
| REG
| direction
;
403 *reg
= src
[1] - '0' + 8;
405 as_warn (_("Reg not valid for H8/300"));
409 if (TOLOWER (src
[0]) == 'r')
411 if (src
[1] >= '0' && src
[1] <= '7')
413 if (len
== 3 && TOLOWER (src
[2]) == 'l')
415 *mode
= L_8
| REG
| direction
;
416 *reg
= (src
[1] - '0') + 8;
419 if (len
== 3 && TOLOWER (src
[2]) == 'h')
421 *mode
= L_8
| REG
| direction
;
422 *reg
= (src
[1] - '0');
427 *mode
= L_16
| REG
| direction
;
428 *reg
= (src
[1] - '0');
438 /* Parse an immediate or address-related constant and store it in OP.
439 If the user also specifies the operand's size, store that size
440 in OP->MODE, otherwise leave it for later code to decide. */
443 parse_exp (char *src
, struct h8_op
*op
)
447 save
= input_line_pointer
;
448 input_line_pointer
= src
;
449 expression (&op
->exp
);
450 if (op
->exp
.X_op
== O_absent
)
451 as_bad (_("missing operand"));
452 src
= input_line_pointer
;
453 input_line_pointer
= save
;
455 return skip_colonthing (src
, &op
->mode
);
459 /* If SRC starts with an explicit operand size, skip it and store the size
460 in *MODE. Leave *MODE unchanged otherwise. */
463 skip_colonthing (char *src
, int *mode
)
469 if (src
[0] == '8' && !ISDIGIT (src
[1]))
471 else if (src
[0] == '2' && !ISDIGIT (src
[1]))
473 else if (src
[0] == '3' && !ISDIGIT (src
[1]))
475 else if (src
[0] == '4' && !ISDIGIT (src
[1]))
477 else if (src
[0] == '5' && !ISDIGIT (src
[1]))
479 else if (src
[0] == '2' && src
[1] == '4' && !ISDIGIT (src
[2]))
481 else if (src
[0] == '3' && src
[1] == '2' && !ISDIGIT (src
[2]))
483 else if (src
[0] == '1' && src
[1] == '6' && !ISDIGIT (src
[2]))
486 as_bad (_("invalid operand size requested"));
488 while (ISDIGIT (*src
))
494 /* The many forms of operand:
497 @Rn Register indirect
498 @(exp[:16], Rn) Register indirect with displacement
502 @aa:16 absolute 16 bit
505 #xx[:size] immediate data
506 @(exp:[8], pc) pc rel
507 @@aa[:8] memory indirect. */
510 constant_fits_width_p (struct h8_op
*operand
, unsigned int width
)
512 return ((operand
->exp
.X_add_number
& ~width
) == 0
513 || (operand
->exp
.X_add_number
| width
) == (unsigned)(~0));
517 constant_fits_size_p (struct h8_op
*operand
, int size
, int no_symbols
)
519 offsetT num
= operand
->exp
.X_add_number
;
521 && (operand
->exp
.X_add_symbol
!= 0 || operand
->exp
.X_op_symbol
!= 0))
526 return (num
& ~3) == 0;
528 return (num
& ~7) == 0;
530 return num
>= 1 && num
< 8;
532 return (num
& ~15) == 0;
534 return num
>= 1 && num
< 32;
536 return (num
& ~0xFF) == 0 || ((unsigned)num
| 0x7F) == ~0u;
538 return (num
& ~0xFF) == 0;
540 return (num
& ~0xFFFF) == 0 || ((unsigned)num
| 0x7FFF) == ~0u;
542 return (num
& ~0xFFFF) == 0;
551 get_operand (char **ptr
, struct h8_op
*op
, int direction
)
560 /* Check for '(' and ')' for instructions ldm and stm. */
561 if (src
[0] == '(' && src
[8] == ')')
564 /* Gross. Gross. ldm and stm have a format not easily handled
565 by get_operand. We deal with it explicitly here. */
566 if (TOLOWER (src
[0]) == 'e' && TOLOWER (src
[1]) == 'r' &&
567 ISDIGIT (src
[2]) && src
[3] == '-' &&
568 TOLOWER (src
[4]) == 'e' && TOLOWER (src
[5]) == 'r' && ISDIGIT (src
[6]))
575 /* Check register pair's validity as per tech note TN-H8*-193A/E
576 from Renesas for H8S and H8SX hardware manual. */
577 if ( !(low
== 0 && (high
== 1 || high
== 2 || high
== 3))
578 && !(low
== 1 && (high
== 2 || high
== 3 || high
== 4) && SXmode
)
579 && !(low
== 2 && (high
== 3 || ((high
== 4 || high
== 5) && SXmode
)))
580 && !(low
== 3 && (high
== 4 || high
== 5 || high
== 6) && SXmode
)
581 && !(low
== 4 && (high
== 5 || high
== 6))
582 && !(low
== 4 && high
== 7 && SXmode
)
583 && !(low
== 5 && (high
== 6 || high
== 7) && SXmode
)
584 && !(low
== 6 && high
== 7 && SXmode
))
585 as_bad (_("Invalid register list for ldm/stm\n"));
587 /* Even sicker. We encode two registers into op->reg. One
588 for the low register to save, the other for the high
589 register to save; we also set the high bit in op->reg
590 so we know this is "very special". */
591 op
->reg
= 0x80000000 | (high
<< 8) | low
;
600 len
= parse_reg (src
, &op
->mode
, &op
->reg
, direction
);
606 int size
= op
->mode
& SIZE
;
611 as_warn (_("mismatch between register and suffix"));
612 op
->mode
= (op
->mode
& ~MODE
) | LOWREG
;
615 if (size
!= L_32
&& size
!= L_16
)
616 as_warn (_("mismatch between register and suffix"));
617 op
->mode
= (op
->mode
& ~MODE
) | LOWREG
;
618 op
->mode
= (op
->mode
& ~SIZE
) | L_16
;
621 op
->mode
= (op
->mode
& ~MODE
) | LOWREG
;
622 if (size
!= L_32
&& size
!= L_8
)
623 as_warn (_("mismatch between register and suffix"));
624 op
->mode
= (op
->mode
& ~MODE
) | LOWREG
;
625 op
->mode
= (op
->mode
& ~SIZE
) | L_8
;
628 as_warn ("invalid suffix after register.");
642 *ptr
= parse_exp (src
+ 1, op
);
643 if (op
->exp
.X_add_number
>= 0x100)
648 /* FIXME : 2? or 4? */
649 if (op
->exp
.X_add_number
>= 0x400)
650 as_bad (_("address too high for vector table jmp/jsr"));
651 else if (op
->exp
.X_add_number
>= 0x200)
656 op
->exp
.X_add_number
= op
->exp
.X_add_number
/ divisor
- 0x80;
663 if (*src
== '-' || *src
== '+')
665 len
= parse_reg (src
+ 1, &mode
, &num
, direction
);
668 /* Oops, not a reg after all, must be ordinary exp. */
669 op
->mode
= ABS
| direction
;
670 *ptr
= parse_exp (src
, op
);
674 if (((mode
& SIZE
) != PSIZE
)
675 /* For Normal mode accept 16 bit and 32 bit pointer registers. */
676 && (!Nmode
|| ((mode
& SIZE
) != L_32
)))
677 as_bad (_("Wrong size pointer register for architecture."));
679 op
->mode
= src
[0] == '-' ? RDPREDEC
: RDPREINC
;
681 *ptr
= src
+ 1 + len
;
688 /* See if this is @(ERn.x, PC). */
689 len
= parse_reg (src
, &mode
, &op
->reg
, direction
);
690 if (len
!= 0 && (mode
& MODE
) == REG
&& src
[len
] == '.')
692 switch (TOLOWER (src
[len
+ 1]))
695 mode
= PCIDXB
| direction
;
698 mode
= PCIDXW
| direction
;
701 mode
= PCIDXL
| direction
;
708 && src
[len
+ 2] == ','
709 && TOLOWER (src
[len
+ 3]) != 'p'
710 && TOLOWER (src
[len
+ 4]) != 'c'
711 && src
[len
+ 5] != ')')
713 *ptr
= src
+ len
+ 6;
717 /* Fall through into disp case - the grammar is somewhat
718 ambiguous, so we should try whether it's a DISP operand
719 after all ("ER3.L" might be a poorly named label...). */
724 /* Start off assuming a 16 bit offset. */
726 src
= parse_exp (src
, op
);
729 op
->mode
|= ABS
| direction
;
736 as_bad (_("expected @(exp, reg16)"));
741 len
= parse_reg (src
, &mode
, &op
->reg
, direction
);
742 if (len
== 0 || (mode
& MODE
) != REG
)
744 as_bad (_("expected @(exp, reg16)"));
750 switch (TOLOWER (src
[1]))
753 op
->mode
|= INDEXB
| direction
;
756 op
->mode
|= INDEXW
| direction
;
759 op
->mode
|= INDEXL
| direction
;
762 as_bad (_("expected .L, .W or .B for register in indexed addressing mode"));
768 op
->mode
|= DISP
| direction
;
769 src
= skip_colonthing (src
, &op
->mode
);
771 if (*src
!= ')' && '(')
773 as_bad (_("expected @(exp, reg16)"));
779 len
= parse_reg (src
, &mode
, &num
, direction
);
784 if (*src
== '+' || *src
== '-')
786 if (((mode
& SIZE
) != PSIZE
)
787 /* For Normal mode accept 16 bit and 32 bit pointer registers. */
788 && (!Nmode
|| ((mode
& SIZE
) != L_32
)))
789 as_bad (_("Wrong size pointer register for architecture."));
790 op
->mode
= *src
== '+' ? RSPOSTINC
: RSPOSTDEC
;
796 if (((mode
& SIZE
) != PSIZE
)
797 /* For Normal mode accept 16 bit and 32 bit pointer registers. */
798 && (!Nmode
|| ((mode
& SIZE
) != L_32
)))
799 as_bad (_("Wrong size pointer register for architecture."));
801 op
->mode
= direction
| IND
| PSIZE
;
809 /* must be a symbol */
811 op
->mode
= ABS
| direction
;
812 *ptr
= parse_exp (src
, op
);
820 *ptr
= parse_exp (src
+ 1, op
);
823 else if (strncmp (src
, "mach", 4) == 0 ||
824 strncmp (src
, "macl", 4) == 0 ||
825 strncmp (src
, "MACH", 4) == 0 ||
826 strncmp (src
, "MACL", 4) == 0)
828 op
->reg
= TOLOWER (src
[3]) == 'l';
836 *ptr
= parse_exp (src
, op
);
841 get_operands (unsigned int noperands
, char *op_end
, struct h8_op
*operand
)
852 get_operand (&ptr
, operand
+ 0, SRC
);
856 get_operand (&ptr
, operand
+ 1, DST
);
862 get_operand (&ptr
, operand
+ 0, SRC
);
865 get_operand (&ptr
, operand
+ 1, DST
);
870 get_operand (&ptr
, operand
+ 0, SRC
);
873 get_operand (&ptr
, operand
+ 1, DST
);
876 get_operand (&ptr
, operand
+ 2, OP3
);
886 /* MOVA has special requirements. Rather than adding twice the amount of
887 addressing modes, we simply special case it a bit. */
889 get_mova_operands (char *op_end
, struct h8_op
*operand
)
893 if (ptr
[1] != '@' || ptr
[2] != '(')
897 ptr
= parse_exp (ptr
, &operand
[0]);
902 get_operand (&ptr
, operand
+ 1, DST
);
910 operand
[0].mode
= (operand
[0].mode
& ~MODE
) | INDEXB
;
913 operand
[0].mode
= (operand
[0].mode
& ~MODE
) | INDEXW
;
916 operand
[0].mode
= (operand
[0].mode
& ~MODE
) | INDEXL
;
922 else if ((operand
[1].mode
& MODE
) == LOWREG
)
924 switch (operand
[1].mode
& SIZE
)
927 operand
[0].mode
= (operand
[0].mode
& ~MODE
) | INDEXB
;
930 operand
[0].mode
= (operand
[0].mode
& ~MODE
) | INDEXW
;
933 operand
[0].mode
= (operand
[0].mode
& ~MODE
) | INDEXL
;
942 if (*ptr
++ != ')' || *ptr
++ != ',')
944 get_operand (&ptr
, operand
+ 2, OP3
);
945 /* See if we can use the short form of MOVA. */
946 if (((operand
[1].mode
& MODE
) == REG
|| (operand
[1].mode
& MODE
) == LOWREG
)
947 && (operand
[2].mode
& MODE
) == REG
948 && (operand
[1].reg
& 7) == (operand
[2].reg
& 7))
950 operand
[1].mode
= operand
[2].mode
= 0;
951 operand
[0].reg
= operand
[2].reg
& 7;
956 as_bad (_("expected valid addressing mode for mova: \"@(disp, ea.sz),ERn\""));
960 get_rtsl_operands (char *ptr
, struct h8_op
*operand
)
962 int mode
, len
, type
= 0;
963 unsigned int num
, num2
;
971 len
= parse_reg (ptr
, &mode
, &num
, SRC
);
972 if (len
== 0 || (mode
& MODE
) != REG
)
974 as_bad (_("expected register"));
980 len
= parse_reg (++ptr
, &mode
, &num2
, SRC
);
981 if (len
== 0 || (mode
& MODE
) != REG
)
983 as_bad (_("expected register"));
987 /* CONST_xxx are used as placeholders in the opcode table. */
991 as_bad (_("invalid register list"));
997 if (type
== 1 && *ptr
++ != ')')
999 as_bad (_("expected closing paren"));
1002 operand
[0].mode
= RS32
;
1003 operand
[1].mode
= RD32
;
1004 operand
[0].reg
= num
;
1005 operand
[1].reg
= num2
;
1008 /* Passed a pointer to a list of opcodes which use different
1009 addressing modes, return the opcode which matches the opcodes
1012 static const struct h8_instruction
*
1013 get_specific (const struct h8_instruction
*instruction
,
1014 struct h8_op
*operands
, int size
)
1016 const struct h8_instruction
*this_try
= instruction
;
1017 const struct h8_instruction
*found_other
= 0, *found_mismatched
= 0;
1019 int this_index
= instruction
->idx
;
1022 /* There's only one ldm/stm and it's easier to just
1023 get out quick for them. */
1024 if (OP_KIND (instruction
->opcode
->how
) == O_LDM
1025 || OP_KIND (instruction
->opcode
->how
) == O_STM
)
1028 while (noperands
< 3 && operands
[noperands
].mode
!= 0)
1031 while (this_index
== instruction
->idx
&& !found
)
1036 this_try
= instruction
++;
1037 this_size
= this_try
->opcode
->how
& SN
;
1039 if (this_try
->noperands
!= noperands
)
1041 else if (this_try
->noperands
> 0)
1045 for (i
= 0; i
< this_try
->noperands
&& found
; i
++)
1047 op_type op
= this_try
->opcode
->args
.nib
[i
];
1048 int op_mode
= op
& MODE
;
1049 int op_size
= op
& SIZE
;
1050 int x
= operands
[i
].mode
;
1051 int x_mode
= x
& MODE
;
1052 int x_size
= x
& SIZE
;
1054 if (op_mode
== LOWREG
&& (x_mode
== REG
|| x_mode
== LOWREG
))
1056 if ((x_size
== L_8
&& (operands
[i
].reg
& 8) == 0)
1057 || (x_size
== L_16
&& (operands
[i
].reg
& 8) == 8))
1058 as_warn (_("can't use high part of register in operand %d"), i
);
1060 if (x_size
!= op_size
)
1063 else if (op_mode
== REG
)
1065 if (x_mode
== LOWREG
)
1071 x_size
= (Hmode
? L_32
: L_16
);
1073 op_size
= (Hmode
? L_32
: L_16
);
1075 /* The size of the reg is v important. */
1076 if (op_size
!= x_size
)
1079 else if (op_mode
& CTRL
) /* control register */
1081 if (!(x_mode
& CTRL
))
1087 if (op_mode
!= CCR
&&
1088 op_mode
!= CCR_EXR
&&
1089 op_mode
!= CC_EX_VB_SB
)
1093 if (op_mode
!= EXR
&&
1094 op_mode
!= CCR_EXR
&&
1095 op_mode
!= CC_EX_VB_SB
)
1099 if (op_mode
!= MACH
&&
1104 if (op_mode
!= MACL
&&
1109 if (op_mode
!= VBR
&&
1110 op_mode
!= VBR_SBR
&&
1111 op_mode
!= CC_EX_VB_SB
)
1115 if (op_mode
!= SBR
&&
1116 op_mode
!= VBR_SBR
&&
1117 op_mode
!= CC_EX_VB_SB
)
1122 else if ((op
& ABSJMP
) && (x_mode
== ABS
|| x_mode
== PCREL
))
1124 operands
[i
].mode
&= ~MODE
;
1125 operands
[i
].mode
|= ABSJMP
;
1126 /* But it may not be 24 bits long. */
1127 if (x_mode
== ABS
&& !Hmode
)
1129 operands
[i
].mode
&= ~SIZE
;
1130 operands
[i
].mode
|= L_16
;
1132 if ((operands
[i
].mode
& SIZE
) == L_32
1133 && (op_mode
& SIZE
) != L_32
)
1136 else if (x_mode
== IMM
&& op_mode
!= IMM
)
1138 offsetT num
= operands
[i
].exp
.X_add_number
;
1139 if (op_mode
== KBIT
|| op_mode
== DBIT
)
1140 /* This is ok if the immediate value is sensible. */;
1141 else if (op_mode
== CONST_2
)
1143 else if (op_mode
== CONST_4
)
1145 else if (op_mode
== CONST_8
)
1147 else if (op_mode
== CONST_16
)
1152 else if (op_mode
== PCREL
&& op_mode
== x_mode
)
1154 /* movsd, bsr/bc and bsr/bs only come in PCREL16 flavour:
1155 If x_size is L_8, promote it. */
1156 if (OP_KIND (this_try
->opcode
->how
) == O_MOVSD
1157 || OP_KIND (this_try
->opcode
->how
) == O_BSRBC
1158 || OP_KIND (this_try
->opcode
->how
) == O_BSRBS
)
1162 /* The size of the displacement is important. */
1163 if (op_size
!= x_size
)
1166 else if ((op_mode
== DISP
|| op_mode
== IMM
|| op_mode
== ABS
1167 || op_mode
== INDEXB
|| op_mode
== INDEXW
1168 || op_mode
== INDEXL
)
1169 && op_mode
== x_mode
)
1171 /* Promote a L_24 to L_32 if it makes us match. */
1172 if (x_size
== L_24
&& op_size
== L_32
)
1178 if (((x_size
== L_16
&& op_size
== L_16U
)
1179 || (x_size
== L_8
&& op_size
== L_8U
)
1180 || (x_size
== L_3
&& op_size
== L_3NZ
))
1181 /* We're deliberately more permissive for ABS modes. */
1183 || constant_fits_size_p (operands
+ i
, op_size
,
1187 if (x_size
!= 0 && op_size
!= x_size
)
1189 else if (x_size
== 0
1190 && ! constant_fits_size_p (operands
+ i
, op_size
,
1194 else if (op_mode
!= x_mode
)
1202 if ((this_try
->opcode
->available
== AV_H8SX
&& ! SXmode
)
1203 || (this_try
->opcode
->available
== AV_H8S
&& ! Smode
)
1204 || (this_try
->opcode
->available
== AV_H8H
&& ! Hmode
))
1205 found
= 0, found_other
= this_try
;
1206 else if (this_size
!= size
&& (this_size
!= SN
&& size
!= SN
))
1207 found_mismatched
= this_try
, found
= 0;
1215 as_warn (_("Opcode `%s' with these operand types not available in %s mode"),
1216 found_other
->opcode
->name
,
1217 (! Hmode
&& ! Smode
? "H8/300"
1222 else if (found_mismatched
)
1224 as_warn (_("mismatch between opcode size and operand size"));
1225 return found_mismatched
;
1231 check_operand (struct h8_op
*operand
, unsigned int width
, char *string
)
1233 if (operand
->exp
.X_add_symbol
== 0
1234 && operand
->exp
.X_op_symbol
== 0)
1236 /* No symbol involved, let's look at offset, it's dangerous if
1237 any of the high bits are not 0 or ff's, find out by oring or
1238 anding with the width and seeing if the answer is 0 or all
1241 if (! constant_fits_width_p (operand
, width
))
1244 && (operand
->exp
.X_add_number
& 0xff00) == 0xff00)
1246 /* Just ignore this one - which happens when trying to
1247 fit a 16 bit address truncated into an 8 bit address
1248 of something like bset. */
1250 else if (strcmp (string
, "@") == 0
1252 && (operand
->exp
.X_add_number
& 0xff8000) == 0xff8000)
1254 /* Just ignore this one - which happens when trying to
1255 fit a 24 bit address truncated into a 16 bit address
1256 of something like mov.w. */
1260 as_warn (_("operand %s0x%lx out of range."), string
,
1261 (unsigned long) operand
->exp
.X_add_number
);
1267 /* RELAXMODE has one of 3 values:
1269 0 Output a "normal" reloc, no relaxing possible for this insn/reloc
1271 1 Output a relaxable 24bit absolute mov.w address relocation
1272 (may relax into a 16bit absolute address).
1274 2 Output a relaxable 16/24 absolute mov.b address relocation
1275 (may relax into an 8bit absolute address). */
1278 do_a_fix_imm (int offset
, int nibble
, struct h8_op
*operand
, int relaxmode
)
1283 char *bytes
= frag_now
->fr_literal
+ offset
;
1285 char *t
= ((operand
->mode
& MODE
) == IMM
) ? "#" : "@";
1287 if (operand
->exp
.X_add_symbol
== 0)
1289 switch (operand
->mode
& SIZE
)
1292 check_operand (operand
, 0x3, t
);
1293 bytes
[0] |= (operand
->exp
.X_add_number
& 3) << (nibble
? 0 : 4);
1297 check_operand (operand
, 0x7, t
);
1298 bytes
[0] |= (operand
->exp
.X_add_number
& 7) << (nibble
? 0 : 4);
1301 check_operand (operand
, 0xF, t
);
1302 bytes
[0] |= (operand
->exp
.X_add_number
& 15) << (nibble
? 0 : 4);
1305 check_operand (operand
, 0x1F, t
);
1306 bytes
[0] |= operand
->exp
.X_add_number
& 31;
1310 check_operand (operand
, 0xff, t
);
1311 bytes
[0] |= operand
->exp
.X_add_number
;
1315 check_operand (operand
, 0xffff, t
);
1316 bytes
[0] |= operand
->exp
.X_add_number
>> 8;
1317 bytes
[1] |= operand
->exp
.X_add_number
>> 0;
1320 check_operand (operand
, 0xffffff, t
);
1321 bytes
[0] |= operand
->exp
.X_add_number
>> 16;
1322 bytes
[1] |= operand
->exp
.X_add_number
>> 8;
1323 bytes
[2] |= operand
->exp
.X_add_number
>> 0;
1327 /* This should be done with bfd. */
1328 bytes
[0] |= operand
->exp
.X_add_number
>> 24;
1329 bytes
[1] |= operand
->exp
.X_add_number
>> 16;
1330 bytes
[2] |= operand
->exp
.X_add_number
>> 8;
1331 bytes
[3] |= operand
->exp
.X_add_number
>> 0;
1334 idx
= (relaxmode
== 2) ? R_MOV24B1
: R_MOVL1
;
1335 fix_new_exp (frag_now
, offset
, 4, &operand
->exp
, 0, idx
);
1342 switch (operand
->mode
& SIZE
)
1347 where
= (operand
->mode
& SIZE
) == L_24
? -1 : 0;
1350 else if (relaxmode
== 1)
1356 as_bad (_("Can't work out size of operand.\n"));
1365 operand
->exp
.X_add_number
=
1366 ((operand
->exp
.X_add_number
& 0xffff) ^ 0x8000) - 0x8000;
1367 operand
->exp
.X_add_number
|= (bytes
[0] << 8) | bytes
[1];
1373 operand
->exp
.X_add_number
=
1374 ((operand
->exp
.X_add_number
& 0xff) ^ 0x80) - 0x80;
1375 operand
->exp
.X_add_number
|= bytes
[0];
1378 fix_new_exp (frag_now
,
1387 /* Now we know what sort of opcodes it is, let's build the bytes. */
1390 build_bytes (const struct h8_instruction
*this_try
, struct h8_op
*operand
)
1393 char *output
= frag_more (this_try
->length
);
1394 op_type
*nibble_ptr
= this_try
->opcode
->data
.nib
;
1396 unsigned int nibble_count
= 0;
1400 char asnibbles
[100];
1401 char *p
= asnibbles
;
1404 if (!Hmode
&& this_try
->opcode
->available
!= AV_H8
)
1405 as_warn (_("Opcode `%s' with these operand types not available in H8/300 mode"),
1406 this_try
->opcode
->name
);
1408 && this_try
->opcode
->available
!= AV_H8
1409 && this_try
->opcode
->available
!= AV_H8H
)
1410 as_warn (_("Opcode `%s' with these operand types not available in H8/300H mode"),
1411 this_try
->opcode
->name
);
1413 && this_try
->opcode
->available
!= AV_H8
1414 && this_try
->opcode
->available
!= AV_H8H
1415 && this_try
->opcode
->available
!= AV_H8S
)
1416 as_warn (_("Opcode `%s' with these operand types not available in H8/300S mode"),
1417 this_try
->opcode
->name
);
1419 while (*nibble_ptr
!= (op_type
) E
)
1426 d
= (c
& OP3
) == OP3
? 2 : (c
& DST
) == DST
? 1 : 0;
1434 if (c2
== REG
|| c2
== LOWREG
1435 || c2
== IND
|| c2
== PREINC
|| c2
== PREDEC
1436 || c2
== POSTINC
|| c2
== POSTDEC
)
1438 nib
= operand
[d
].reg
;
1443 else if (c
& CTRL
) /* Control reg operand. */
1444 nib
= operand
[d
].reg
;
1446 else if ((c
& DISPREG
) == (DISPREG
))
1448 nib
= operand
[d
].reg
;
1452 operand
[d
].mode
= c
;
1453 op_at
[d
] = nibble_count
;
1456 else if (c2
== IMM
|| c2
== PCREL
|| c2
== ABS
1457 || (c
& ABSJMP
) || c2
== DISP
)
1459 operand
[d
].mode
= c
;
1460 op_at
[d
] = nibble_count
;
1463 else if ((c
& IGNORE
) || (c
& DATA
))
1466 else if (c2
== DBIT
)
1468 switch (operand
[0].exp
.X_add_number
)
1477 as_bad (_("Need #1 or #2 here"));
1480 else if (c2
== KBIT
)
1482 switch (operand
[0].exp
.X_add_number
)
1492 as_warn (_("#4 not valid on H8/300."));
1497 as_bad (_("Need #1 or #2 here"));
1500 /* Stop it making a fix. */
1501 operand
[0].mode
= 0;
1505 operand
[d
].mode
|= MEMRELAX
;
1521 if (operand
[0].mode
== MACREG
)
1522 /* stmac has mac[hl] as the first operand. */
1523 nib
= 2 + operand
[0].reg
;
1525 /* ldmac has mac[hl] as the second operand. */
1526 nib
= 2 + operand
[1].reg
;
1534 /* Disgusting. Why, oh why didn't someone ask us for advice
1535 on the assembler format. */
1536 if (OP_KIND (this_try
->opcode
->how
) == O_LDM
)
1538 high
= (operand
[1].reg
>> 8) & 0xf;
1539 low
= (operand
[1].reg
) & 0xf;
1540 asnibbles
[2] = high
- low
;
1541 asnibbles
[7] = high
;
1543 else if (OP_KIND (this_try
->opcode
->how
) == O_STM
)
1545 high
= (operand
[0].reg
>> 8) & 0xf;
1546 low
= (operand
[0].reg
) & 0xf;
1547 asnibbles
[2] = high
- low
;
1551 for (i
= 0; i
< this_try
->length
; i
++)
1552 output
[i
] = (asnibbles
[i
* 2] << 4) | asnibbles
[i
* 2 + 1];
1554 /* Note if this is a movb or a bit manipulation instruction
1555 there is a special relaxation which only applies. */
1556 if ( this_try
->opcode
->how
== O (O_MOV
, SB
)
1557 || this_try
->opcode
->how
== O (O_BCLR
, SB
)
1558 || this_try
->opcode
->how
== O (O_BAND
, SB
)
1559 || this_try
->opcode
->how
== O (O_BIAND
, SB
)
1560 || this_try
->opcode
->how
== O (O_BILD
, SB
)
1561 || this_try
->opcode
->how
== O (O_BIOR
, SB
)
1562 || this_try
->opcode
->how
== O (O_BIST
, SB
)
1563 || this_try
->opcode
->how
== O (O_BIXOR
, SB
)
1564 || this_try
->opcode
->how
== O (O_BLD
, SB
)
1565 || this_try
->opcode
->how
== O (O_BNOT
, SB
)
1566 || this_try
->opcode
->how
== O (O_BOR
, SB
)
1567 || this_try
->opcode
->how
== O (O_BSET
, SB
)
1568 || this_try
->opcode
->how
== O (O_BST
, SB
)
1569 || this_try
->opcode
->how
== O (O_BTST
, SB
)
1570 || this_try
->opcode
->how
== O (O_BXOR
, SB
))
1573 /* Output any fixes. */
1574 for (i
= 0; i
< this_try
->noperands
; i
++)
1576 int x
= operand
[i
].mode
;
1577 int x_mode
= x
& MODE
;
1579 if (x_mode
== IMM
|| x_mode
== DISP
)
1580 do_a_fix_imm (output
- frag_now
->fr_literal
+ op_at
[i
] / 2,
1581 op_at
[i
] & 1, operand
+ i
, (x
& MEMRELAX
) != 0);
1583 else if (x_mode
== ABS
)
1584 do_a_fix_imm (output
- frag_now
->fr_literal
+ op_at
[i
] / 2,
1585 op_at
[i
] & 1, operand
+ i
,
1586 (x
& MEMRELAX
) ? movb
+ 1 : 0);
1588 else if (x_mode
== PCREL
)
1590 int size16
= (x
& SIZE
) == L_16
;
1591 int size
= size16
? 2 : 1;
1592 int type
= size16
? R_PCRWORD
: R_PCRBYTE
;
1595 check_operand (operand
+ i
, size16
? 0x7fff : 0x7f, "@");
1597 if (operand
[i
].exp
.X_add_number
& 1)
1598 as_warn (_("branch operand has odd offset (%lx)\n"),
1599 (unsigned long) operand
->exp
.X_add_number
);
1601 /* The COFF port has always been off by one, changing it
1602 now would be an incompatible change, so we leave it as-is.
1604 We don't want to do this for ELF as we want to be
1605 compatible with the proposed ELF format from Hitachi. */
1606 operand
[i
].exp
.X_add_number
-= 1;
1610 operand
[i
].exp
.X_add_number
=
1611 ((operand
[i
].exp
.X_add_number
& 0xffff) ^ 0x8000) - 0x8000;
1615 operand
[i
].exp
.X_add_number
=
1616 ((operand
[i
].exp
.X_add_number
& 0xff) ^ 0x80) - 0x80;
1621 operand
[i
].exp
.X_add_number
|= output
[op_at
[i
] / 2];
1623 fixP
= fix_new_exp (frag_now
,
1624 output
- frag_now
->fr_literal
+ op_at
[i
] / 2,
1629 fixP
->fx_signed
= 1;
1631 else if (x_mode
== MEMIND
)
1633 check_operand (operand
+ i
, 0xff, "@@");
1634 fix_new_exp (frag_now
,
1635 output
- frag_now
->fr_literal
+ 1,
1641 else if (x_mode
== VECIND
)
1643 check_operand (operand
+ i
, 0x7f, "@@");
1644 /* FIXME: approximating the effect of "B31" here...
1645 This is very hackish, and ought to be done a better way. */
1646 operand
[i
].exp
.X_add_number
|= 0x80;
1647 fix_new_exp (frag_now
,
1648 output
- frag_now
->fr_literal
+ 1,
1654 else if (x
& ABSJMP
)
1657 bfd_reloc_code_real_type reloc_type
= R_JMPL1
;
1660 /* To be compatible with the proposed H8 ELF format, we
1661 want the relocation's offset to point to the first byte
1662 that will be modified, not to the start of the instruction. */
1664 if ((operand
->mode
& SIZE
) == L_32
)
1667 reloc_type
= R_RELLONG
;
1673 /* This jmp may be a jump or a branch. */
1675 check_operand (operand
+ i
,
1676 SXmode
? 0xffffffff : Hmode
? 0xffffff : 0xffff,
1679 if (operand
[i
].exp
.X_add_number
& 1)
1680 as_warn (_("branch operand has odd offset (%lx)\n"),
1681 (unsigned long) operand
->exp
.X_add_number
);
1684 operand
[i
].exp
.X_add_number
=
1685 ((operand
[i
].exp
.X_add_number
& 0xffff) ^ 0x8000) - 0x8000;
1686 fix_new_exp (frag_now
,
1687 output
- frag_now
->fr_literal
+ where
,
1696 /* Try to give an intelligent error message for common and simple to
1700 clever_message (const struct h8_instruction
*instruction
,
1701 struct h8_op
*operand
)
1703 /* Find out if there was more than one possible opcode. */
1705 if ((instruction
+ 1)->idx
!= instruction
->idx
)
1709 /* Only one opcode of this flavour, try to guess which operand
1711 for (argn
= 0; argn
< instruction
->noperands
; argn
++)
1713 switch (instruction
->opcode
->args
.nib
[argn
])
1716 if (operand
[argn
].mode
!= RD16
)
1718 as_bad (_("destination operand must be 16 bit register"));
1725 if (operand
[argn
].mode
!= RS8
)
1727 as_bad (_("source operand must be 8 bit register"));
1733 if (operand
[argn
].mode
!= ABS16DST
)
1735 as_bad (_("destination operand must be 16bit absolute address"));
1740 if (operand
[argn
].mode
!= RD8
)
1742 as_bad (_("destination operand must be 8 bit register"));
1748 if (operand
[argn
].mode
!= ABS16SRC
)
1750 as_bad (_("source operand must be 16bit absolute address"));
1758 as_bad (_("invalid operands"));
1762 /* If OPERAND is part of an address, adjust its size and value given
1763 that it addresses SIZE bytes.
1765 This function decides how big non-immediate constants are when no
1766 size was explicitly given. It also scales down the assembly-level
1767 displacement in an @(d:2,ERn) operand. */
1770 fix_operand_size (struct h8_op
*operand
, int size
)
1772 if (SXmode
&& (operand
->mode
& MODE
) == DISP
)
1774 /* If the user didn't specify an operand width, see if we
1775 can use @(d:2,ERn). */
1776 if ((operand
->mode
& SIZE
) == 0
1777 && operand
->exp
.X_add_symbol
== 0
1778 && operand
->exp
.X_op_symbol
== 0
1779 && (operand
->exp
.X_add_number
== size
1780 || operand
->exp
.X_add_number
== size
* 2
1781 || operand
->exp
.X_add_number
== size
* 3))
1782 operand
->mode
|= L_2
;
1784 /* Scale down the displacement in an @(d:2,ERn) operand.
1785 X_add_number then contains the desired field value. */
1786 if ((operand
->mode
& SIZE
) == L_2
)
1788 if (operand
->exp
.X_add_number
% size
!= 0)
1789 as_warn (_("operand/size mis-match"));
1790 operand
->exp
.X_add_number
/= size
;
1794 if ((operand
->mode
& SIZE
) == 0)
1795 switch (operand
->mode
& MODE
)
1802 /* Pick a 24-bit address unless we know that a 16-bit address
1803 is safe. get_specific() will relax L_24 into L_32 where
1807 && (operand
->exp
.X_add_number
< -32768
1808 || operand
->exp
.X_add_number
> 32767
1809 || operand
->exp
.X_add_symbol
!= 0
1810 || operand
->exp
.X_op_symbol
!= 0))
1811 operand
->mode
|= L_24
;
1813 operand
->mode
|= L_16
;
1817 /* This condition is long standing, though somewhat suspect. */
1818 if (operand
->exp
.X_add_number
> -128
1819 && operand
->exp
.X_add_number
< 127)
1820 operand
->mode
|= L_8
;
1822 operand
->mode
|= L_16
;
1828 /* This is the guts of the machine-dependent assembler. STR points to
1829 a machine dependent instruction. This function is supposed to emit
1830 the frags/bytes it assembles. */
1833 md_assemble (char *str
)
1837 struct h8_op operand
[3];
1838 const struct h8_instruction
*instruction
;
1839 const struct h8_instruction
*prev_instruction
;
1846 /* Drop leading whitespace. */
1850 /* Find the op code end. */
1851 for (op_start
= op_end
= str
;
1852 *op_end
!= 0 && *op_end
!= ' ';
1862 else if (*op_end
== '/' && ! slash
)
1866 if (op_end
== op_start
)
1868 as_bad (_("can't find opcode "));
1874 /* The assembler stops scanning the opcode at slashes, so it fails
1875 to make characters following them lower case. Fix them. */
1878 *slash
= TOLOWER (*slash
);
1880 instruction
= (const struct h8_instruction
*)
1881 hash_find (opcode_hash_control
, op_start
);
1883 if (instruction
== NULL
)
1885 as_bad (_("unknown opcode"));
1889 /* We used to set input_line_pointer to the result of get_operands,
1890 but that is wrong. Our caller assumes we don't change it. */
1892 operand
[0].mode
= 0;
1893 operand
[1].mode
= 0;
1894 operand
[2].mode
= 0;
1896 if (OP_KIND (instruction
->opcode
->how
) == O_MOVAB
1897 || OP_KIND (instruction
->opcode
->how
) == O_MOVAW
1898 || OP_KIND (instruction
->opcode
->how
) == O_MOVAL
)
1899 get_mova_operands (op_end
, operand
);
1900 else if (OP_KIND (instruction
->opcode
->how
) == O_RTEL
1901 || OP_KIND (instruction
->opcode
->how
) == O_RTSL
)
1902 get_rtsl_operands (op_end
, operand
);
1904 get_operands (instruction
->noperands
, op_end
, operand
);
1907 prev_instruction
= instruction
;
1909 /* Now we have operands from instruction.
1910 Let's check them out for ldm and stm. */
1911 if (OP_KIND (instruction
->opcode
->how
) == O_LDM
)
1913 /* The first operand must be @er7+, and the
1914 second operand must be a register pair. */
1915 if ((operand
[0].mode
!= RSINC
)
1916 || (operand
[0].reg
!= 7)
1917 || ((operand
[1].reg
& 0x80000000) == 0))
1918 as_bad (_("invalid operand in ldm"));
1920 else if (OP_KIND (instruction
->opcode
->how
) == O_STM
)
1922 /* The first operand must be a register pair,
1923 and the second operand must be @-er7. */
1924 if (((operand
[0].reg
& 0x80000000) == 0)
1925 || (operand
[1].mode
!= RDDEC
)
1926 || (operand
[1].reg
!= 7))
1927 as_bad (_("invalid operand in stm"));
1933 switch (TOLOWER (*dot
))
1948 if (OP_KIND (instruction
->opcode
->how
) == O_MOVAB
||
1949 OP_KIND (instruction
->opcode
->how
) == O_MOVAW
||
1950 OP_KIND (instruction
->opcode
->how
) == O_MOVAL
)
1952 switch (operand
[0].mode
& MODE
)
1956 fix_operand_size (&operand
[1], 1);
1959 fix_operand_size (&operand
[1], 2);
1962 fix_operand_size (&operand
[1], 4);
1968 for (i
= 0; i
< 3 && operand
[i
].mode
!= 0; i
++)
1974 fix_operand_size (&operand
[i
], 1);
1977 fix_operand_size (&operand
[i
], 2);
1980 fix_operand_size (&operand
[i
], 4);
1985 instruction
= get_specific (instruction
, operand
, size
);
1987 if (instruction
== 0)
1989 /* Couldn't find an opcode which matched the operands. */
1990 char *where
= frag_more (2);
1994 clever_message (prev_instruction
, operand
);
1999 build_bytes (instruction
, operand
);
2001 dwarf2_emit_insn (instruction
->length
);
2005 md_undefined_symbol (char *name ATTRIBUTE_UNUSED
)
2010 /* Various routines to kill one day */
2011 /* Equal to MAX_PRECISION in atof-ieee.c */
2012 #define MAX_LITTLENUMS 6
2014 /* Turn a string in input_line_pointer into a floating point constant
2015 of type TYPE, and store the appropriate bytes in *LITP. The number
2016 of LITTLENUMS emitted is stored in *SIZEP. An error message is
2017 returned, or NULL on OK. */
2020 md_atof (int type
, char *litP
, int *sizeP
)
2023 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
2024 LITTLENUM_TYPE
*wordP
;
2055 return _("Bad call to MD_ATOF()");
2057 t
= atof_ieee (input_line_pointer
, type
, words
);
2059 input_line_pointer
= t
;
2061 *sizeP
= prec
* sizeof (LITTLENUM_TYPE
);
2062 for (wordP
= words
; prec
--;)
2064 md_number_to_chars (litP
, (long) (*wordP
++), sizeof (LITTLENUM_TYPE
));
2065 litP
+= sizeof (LITTLENUM_TYPE
);
2070 const char *md_shortopts
= "";
2071 struct option md_longopts
[] = {
2072 {NULL
, no_argument
, NULL
, 0}
2075 size_t md_longopts_size
= sizeof (md_longopts
);
2078 md_parse_option (int c ATTRIBUTE_UNUSED
, char *arg ATTRIBUTE_UNUSED
)
2084 md_show_usage (FILE *stream ATTRIBUTE_UNUSED
)
2088 void tc_aout_fix_to_chars (void);
2091 tc_aout_fix_to_chars (void)
2093 printf (_("call to tc_aout_fix_to_chars \n"));
2098 md_convert_frag (bfd
*headers ATTRIBUTE_UNUSED
,
2099 segT seg ATTRIBUTE_UNUSED
,
2100 fragS
*fragP ATTRIBUTE_UNUSED
)
2102 printf (_("call to md_convert_frag \n"));
2107 md_section_align (segT segment
, valueT size
)
2109 int align
= bfd_get_section_alignment (stdoutput
, segment
);
2110 return ((size
+ (1 << align
) - 1) & (-1 << align
));
2114 md_apply_fix (fixS
*fixP
, valueT
*valP
, segT seg ATTRIBUTE_UNUSED
)
2116 char *buf
= fixP
->fx_where
+ fixP
->fx_frag
->fr_literal
;
2119 switch (fixP
->fx_size
)
2125 *buf
++ = (val
>> 8);
2129 *buf
++ = (val
>> 24);
2130 *buf
++ = (val
>> 16);
2131 *buf
++ = (val
>> 8);
2138 if (fixP
->fx_addsy
== NULL
&& fixP
->fx_pcrel
== 0)
2143 md_estimate_size_before_relax (register fragS
*fragP ATTRIBUTE_UNUSED
,
2144 register segT segment_type ATTRIBUTE_UNUSED
)
2146 printf (_("call tomd_estimate_size_before_relax \n"));
2150 /* Put number into target byte order. */
2152 md_number_to_chars (char *ptr
, valueT use
, int nbytes
)
2154 number_to_chars_bigendian (ptr
, use
, nbytes
);
2158 md_pcrel_from (fixS
*fixP ATTRIBUTE_UNUSED
)
2164 tc_gen_reloc (asection
*section ATTRIBUTE_UNUSED
, fixS
*fixp
)
2167 bfd_reloc_code_real_type r_type
;
2169 if (fixp
->fx_addsy
&& fixp
->fx_subsy
)
2171 if ((S_GET_SEGMENT (fixp
->fx_addsy
) != S_GET_SEGMENT (fixp
->fx_subsy
))
2172 || S_GET_SEGMENT (fixp
->fx_addsy
) == undefined_section
)
2174 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
2175 "Difference of symbols in different sections is not supported");
2180 rel
= (arelent
*) xmalloc (sizeof (arelent
));
2181 rel
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
2182 *rel
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
2183 rel
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2184 rel
->addend
= fixp
->fx_offset
;
2186 r_type
= fixp
->fx_r_type
;
2190 fprintf (stderr
, "%s\n", bfd_get_reloc_code_name (r_type
));
2193 rel
->howto
= bfd_reloc_type_lookup (stdoutput
, r_type
);
2194 if (rel
->howto
== NULL
)
2196 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
2197 _("Cannot represent relocation type %s"),
2198 bfd_get_reloc_code_name (r_type
));