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 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, 59 Temple Place - Suite 330, Boston, MA
22 /* Written By Steve Chamberlain <sac@cygnus.com>. */
29 #define h8_opcodes ops
30 #include "opcode/h8300.h"
31 #include "safe-ctype.h"
37 const char comment_chars[] = ";";
38 const char line_comment_chars[] = "#";
39 const char line_separator_chars[] = "";
41 void cons PARAMS ((int));
42 void sbranch PARAMS ((int));
43 void h8300hmode PARAMS ((int));
44 void h8300smode PARAMS ((int));
45 static void pint PARAMS ((int));
50 #define PSIZE (Hmode ? L_32 : L_16)
52 #define DSYMMODE (Hmode ? L_24 : L_16)
54 int bsize = L_8; /* Default branch displacement. */
62 const struct h8_opcode *opcode;
65 struct h8_instruction *h8_instructions;
69 int arg ATTRIBUTE_UNUSED;
74 if (!bfd_set_arch_mach (stdoutput, bfd_arch_h8300, bfd_mach_h8300h))
75 as_warn (_("could not set architecture and machine"));
81 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"));
100 int arg ATTRIBUTE_UNUSED;
102 cons (Hmode ? 4 : 2);
105 /* This table describes all the machine specific pseudo-ops the assembler
106 has to support. The fields are:
107 pseudo-op name without dot
108 function to call to execute this pseudo-op
109 Integer arg to pass to the function. */
111 const pseudo_typeS md_pseudo_table[] =
113 {"h8300h", h8300hmode, 0},
114 {"h8300s", h8300smode, 0},
115 {"sbranch", sbranch, L_8},
116 {"lbranch", sbranch, L_16},
122 {"form", listing_psize, 0},
123 {"heading", listing_title, 0},
124 {"import", s_ignore, 0},
125 {"page", listing_eject, 0},
126 {"program", s_ignore, 0},
130 const int md_reloc_size;
132 const char EXP_CHARS[] = "eE";
134 /* Chars that mean this number is a floating point constant
137 const char FLT_CHARS[] = "rRsSfFdDxXpP";
139 static struct hash_control *opcode_hash_control; /* Opcode mnemonics. */
141 /* This function is called once, at assembler startup time. This
142 should set up all the tables, etc. that the MD part of the assembler
148 unsigned int nopcodes;
149 const struct h8_opcode *p;
150 struct h8_instruction *pi;
151 char prev_buffer[100];
155 if (!bfd_set_arch_mach (stdoutput, bfd_arch_h8300, bfd_mach_h8300))
156 as_warn (_("could not set architecture and machine"));
159 opcode_hash_control = hash_new ();
162 nopcodes = sizeof (h8_opcodes) / sizeof (struct h8_opcode);
164 h8_instructions = (struct h8_instruction *)
165 xmalloc (nopcodes * sizeof (struct h8_instruction));
167 for (p = h8_opcodes, pi = h8_instructions; p->name; p++, pi++)
169 /* Strip off any . part when inserting the opcode and only enter
170 unique codes into the hash table. */
172 unsigned int len = strlen (src);
173 char *dst = malloc (len + 1);
188 if (strcmp (buffer, prev_buffer))
190 hash_insert (opcode_hash_control, buffer, (char *) pi);
191 strcpy (prev_buffer, buffer);
196 /* Find the number of operands. */
198 while (p->args.nib[pi->noperands] != E)
201 /* Find the length of the opcode in bytes. */
203 while (p->data.nib[pi->length * 2] != E)
209 /* Add entry for the NULL vector terminator. */
227 int opsize; /* Set when a register size is seen. */
236 static void clever_message PARAMS ((const struct h8_instruction *, struct h8_op *));
237 static void build_bytes PARAMS ((const struct h8_instruction *, struct h8_op *));
238 static void do_a_fix_imm PARAMS ((int, struct h8_op *, int));
239 static void check_operand PARAMS ((struct h8_op *, unsigned int, char *));
240 static const struct h8_instruction * get_specific PARAMS ((const struct h8_instruction *, struct h8_op *, int));
241 static char * get_operands PARAMS ((unsigned, char *, struct h8_op *));
242 static void get_operand PARAMS ((char **, struct h8_op *, unsigned, int));
243 static char * skip_colonthing PARAMS ((char *, expressionS *, int *));
244 static char * parse_exp PARAMS ((char *, expressionS *));
245 static int parse_reg PARAMS ((char *, op_type *, unsigned *, int));
246 char * colonmod24 PARAMS ((struct h8_op *, char *));
250 WREG r0,r1,r2,r3,r4,r5,r6,r7,fp,sp
259 /* Try to parse a reg name. Return the number of chars consumed. */
262 parse_reg (src, mode, reg, direction)
271 /* Cribbed from get_symbol_end. */
272 if (!is_name_beginner (*src) || *src == '\001')
275 while (is_part_of_name (*end) || *end == '\001')
279 if (len == 2 && src[0] == 's' && src[1] == 'p')
281 *mode = PSIZE | REG | direction;
285 if (len == 3 && src[0] == 'c' && src[1] == 'c' && src[2] == 'r')
291 if (len == 3 && src[0] == 'e' && src[1] == 'x' && src[2] == 'r')
297 if (len == 2 && src[0] == 'f' && src[1] == 'p')
299 *mode = PSIZE | REG | direction;
303 if (len == 3 && src[0] == 'e' && src[1] == 'r'
304 && src[2] >= '0' && src[2] <= '7')
306 *mode = L_32 | REG | direction;
309 as_warn (_("Reg not valid for H8/300"));
312 if (len == 2 && src[0] == 'e' && src[1] >= '0' && src[1] <= '7')
314 *mode = L_16 | REG | direction;
315 *reg = src[1] - '0' + 8;
317 as_warn (_("Reg not valid for H8/300"));
323 if (src[1] >= '0' && src[1] <= '7')
325 if (len == 3 && src[2] == 'l')
327 *mode = L_8 | REG | direction;
328 *reg = (src[1] - '0') + 8;
331 if (len == 3 && src[2] == 'h')
333 *mode = L_8 | REG | direction;
334 *reg = (src[1] - '0');
339 *mode = L_16 | REG | direction;
340 *reg = (src[1] - '0');
354 char *save = input_line_pointer;
357 input_line_pointer = s;
359 if (op->X_op == O_absent)
360 as_bad (_("missing operand"));
361 new = input_line_pointer;
362 input_line_pointer = save;
367 skip_colonthing (ptr, exp, mode)
369 expressionS *exp ATTRIBUTE_UNUSED;
379 /* ff fill any 8 bit quantity. */
380 /* exp->X_add_number -= 0x100; */
389 else if (*ptr == '3')
393 else if (*ptr == '1')
397 while (ISDIGIT (*ptr))
404 /* The many forms of operand:
407 @Rn Register indirect
408 @(exp[:16], Rn) Register indirect with displacement
412 @aa:16 absolute 16 bit
415 #xx[:size] immediate data
416 @(exp:[8], pc) pc rel
417 @@aa[:8] memory indirect. */
425 src = skip_colonthing (src, &op->exp, &mode);
429 /* Choose a default mode. */
430 if (op->exp.X_add_number < -32768
431 || op->exp.X_add_number > 32767)
438 else if (op->exp.X_add_symbol
439 || op->exp.X_op_symbol)
450 get_operand (ptr, op, dst, direction)
453 unsigned int dst ATTRIBUTE_UNUSED;
463 /* Check for '(' and ')' for instructions ldm and stm. */
464 if (src[0] == '(' && src[8] == ')')
467 /* Gross. Gross. ldm and stm have a format not easily handled
468 by get_operand. We deal with it explicitly here. */
469 if (src[0] == 'e' && src[1] == 'r' && ISDIGIT (src[2])
470 && src[3] == '-' && src[4] == 'e' && src[5] == 'r' && ISDIGIT (src[6]))
478 as_bad (_("Invalid register list for ldm/stm\n"));
481 as_bad (_("Invalid register list for ldm/stm\n"));
484 as_bad (_("Invalid register list for ldm/stm\n"));
488 as_bad (_("Invalid register list for ldm/stm\n"));
490 /* Even sicker. We encode two registers into op->reg. One
491 for the low register to save, the other for the high
492 register to save; we also set the high bit in op->reg
493 so we know this is "very special". */
494 op->reg = 0x80000000 | (high << 8) | low;
503 len = parse_reg (src, &op->mode, &op->reg, direction);
516 src = parse_exp (src, &op->exp);
518 src = skip_colonthing (src, &op->exp, &op->mode);
529 len = parse_reg (src, &mode, &num, direction);
532 /* Oops, not a reg after all, must be ordinary exp. */
534 /* Must be a symbol. */
535 op->mode = ABS | PSIZE | direction;
536 *ptr = skip_colonthing (parse_exp (src, &op->exp),
537 &op->exp, &op->mode);
542 if ((mode & SIZE) != PSIZE)
543 as_bad (_("Wrong size pointer register for architecture."));
554 /* Start off assuming a 16 bit offset. */
556 src = parse_exp (src, &op->exp);
558 src = colonmod24 (op, src);
563 op->mode |= ABS | direction;
570 as_bad (_("expected @(exp, reg16)"));
576 len = parse_reg (src, &mode, &op->reg, direction);
577 if (len == 0 || !(mode & REG))
579 as_bad (_("expected @(exp, reg16)"));
582 op->mode |= DISP | direction;
585 src = skip_colonthing (src, &op->exp, &op->mode);
587 if (*src != ')' && '(')
589 as_bad (_("expected @(exp, reg16)"));
596 len = parse_reg (src, &mode, &num, direction);
604 if ((mode & SIZE) != PSIZE)
605 as_bad (_("Wrong size pointer register for architecture."));
611 if ((mode & SIZE) != PSIZE)
612 as_bad (_("Wrong size pointer register for architecture."));
614 op->mode = direction | IND | PSIZE;
622 /* must be a symbol */
624 op->mode = ABS | direction;
625 src = parse_exp (src, &op->exp);
627 *ptr = colonmod24 (op, src);
637 src = parse_exp (src, &op->exp);
638 *ptr = skip_colonthing (src, &op->exp, &op->mode);
642 else if (strncmp (src, "mach", 4) == 0
643 || strncmp (src, "macl", 4) == 0)
645 op->reg = src[3] == 'l';
652 src = parse_exp (src, &op->exp);
653 /* Trailing ':' size ? */
656 if (src[1] == '1' && src[2] == '6')
658 op->mode = PCREL | L_16;
661 else if (src[1] == '8')
663 op->mode = PCREL | L_8;
667 as_bad (_("expect :8 or :16 here"));
670 op->mode = PCREL | bsize;
677 get_operands (noperands, op_end, operand)
678 unsigned int noperands;
680 struct h8_op *operand;
693 get_operand (&ptr, operand + 0, 0, SRC);
697 get_operand (&ptr, operand + 1, 1, DST);
707 get_operand (&ptr, operand + 0, 0, SRC);
710 get_operand (&ptr, operand + 1, 1, DST);
720 /* Passed a pointer to a list of opcodes which use different
721 addressing modes, return the opcode which matches the opcodes
724 static const struct h8_instruction *
725 get_specific (instruction, operands, size)
726 const struct h8_instruction *instruction;
727 struct h8_op *operands;
730 const struct h8_instruction *this_try = instruction;
732 int this_index = instruction->idx;
734 /* There's only one ldm/stm and it's easier to just
735 get out quick for them. */
736 if (strcmp (instruction->opcode->name, "stm.l") == 0
737 || strcmp (instruction->opcode->name, "ldm.l") == 0)
740 while (this_index == instruction->idx && !found)
744 this_try = instruction++;
745 if (this_try->noperands == 0)
749 this_size = this_try->opcode->how & SN;
750 if (this_size != size && (this_size != SB || size != SN))
757 for (i = 0; i < this_try->noperands && found; i++)
759 op_type op = this_try->opcode->args.nib[i];
760 int x = operands[i].mode;
762 if ((op & (DISP | REG)) == (DISP | REG)
763 && ((x & (DISP | REG)) == (DISP | REG)))
765 dispreg = operands[i].reg;
773 x = (x & ~L_P) | (Hmode ? L_32 : L_16);
775 op = (op & ~L_P) | (Hmode ? L_32 : L_16);
779 /* The size of the reg is v important. */
780 if ((op & SIZE) != (x & SIZE))
783 else if ((op & ABSJMP) && (x & ABS))
785 operands[i].mode &= ~ABS;
786 operands[i].mode |= ABSJMP;
787 /* But it may not be 24 bits long. */
790 operands[i].mode &= ~SIZE;
791 operands[i].mode |= L_16;
794 else if ((op & (KBIT | DBIT)) && (x & IMM))
796 /* This is ok if the immediate value is sensible. */
800 /* The size of the displacement is important. */
801 if ((op & SIZE) != (x & SIZE))
804 else if ((op & (DISP | IMM | ABS))
805 && (op & (DISP | IMM | ABS)) == (x & (DISP | IMM | ABS)))
807 /* Promote a L_24 to L_32 if it makes us match. */
808 if ((x & L_24) && (op & L_32))
813 /* Promote an L8 to L_16 if it makes us match. */
814 if (op & ABS && op & L_8 && op & DISP)
819 else if ((x & SIZE) != 0
820 && ((op & SIZE) != (x & SIZE)))
823 else if ((op & MACREG) != (x & MACREG))
827 else if ((op & MODE) != (x & MODE))
841 check_operand (operand, width, string)
842 struct h8_op *operand;
846 if (operand->exp.X_add_symbol == 0
847 && operand->exp.X_op_symbol == 0)
849 /* No symbol involved, let's look at offset, it's dangerous if
850 any of the high bits are not 0 or ff's, find out by oring or
851 anding with the width and seeing if the answer is 0 or all
854 if ((operand->exp.X_add_number & ~width) != 0 &&
855 (operand->exp.X_add_number | width) != (unsigned)(~0))
858 && (operand->exp.X_add_number & 0xff00) == 0xff00)
860 /* Just ignore this one - which happens when trying to
861 fit a 16 bit address truncated into an 8 bit address
862 of something like bset. */
864 else if (strcmp (string, "@") == 0
866 && (operand->exp.X_add_number & 0xff8000) == 0xff8000)
868 /* Just ignore this one - which happens when trying to
869 fit a 24 bit address truncated into a 16 bit address
870 of something like mov.w. */
874 as_warn (_("operand %s0x%lx out of range."), string,
875 (unsigned long) operand->exp.X_add_number);
881 /* RELAXMODE has one of 3 values:
883 0 Output a "normal" reloc, no relaxing possible for this insn/reloc
885 1 Output a relaxable 24bit absolute mov.w address relocation
886 (may relax into a 16bit absolute address).
888 2 Output a relaxable 16/24 absolute mov.b address relocation
889 (may relax into an 8bit absolute address). */
892 do_a_fix_imm (offset, operand, relaxmode)
894 struct h8_op *operand;
901 char *t = operand->mode & IMM ? "#" : "@";
903 if (operand->exp.X_add_symbol == 0)
905 char *bytes = frag_now->fr_literal + offset;
906 switch (operand->mode & SIZE)
909 check_operand (operand, 0x3, t);
910 bytes[0] |= (operand->exp.X_add_number) << 4;
913 check_operand (operand, 0x7, t);
914 bytes[0] |= (operand->exp.X_add_number) << 4;
917 check_operand (operand, 0xff, t);
918 bytes[0] = operand->exp.X_add_number;
921 check_operand (operand, 0xffff, t);
922 bytes[0] = operand->exp.X_add_number >> 8;
923 bytes[1] = operand->exp.X_add_number >> 0;
926 check_operand (operand, 0xffffff, t);
927 bytes[0] = operand->exp.X_add_number >> 16;
928 bytes[1] = operand->exp.X_add_number >> 8;
929 bytes[2] = operand->exp.X_add_number >> 0;
933 /* This should be done with bfd. */
934 bytes[0] = operand->exp.X_add_number >> 24;
935 bytes[1] = operand->exp.X_add_number >> 16;
936 bytes[2] = operand->exp.X_add_number >> 8;
937 bytes[3] = operand->exp.X_add_number >> 0;
940 idx = (relaxmode == 2) ? R_MOV24B1 : R_MOVL1;
941 fix_new_exp (frag_now, offset, 4, &operand->exp, 0, idx);
948 switch (operand->mode & SIZE)
953 where = (operand->mode & SIZE) == L_24 ? -1 : 0;
956 else if (relaxmode == 1)
962 as_bad (_("Can't work out size of operand.\n"));
970 operand->exp.X_add_number =
971 ((operand->exp.X_add_number & 0xffff) ^ 0x8000) - 0x8000;
977 operand->exp.X_add_number =
978 ((operand->exp.X_add_number & 0xff) ^ 0x80) - 0x80;
981 fix_new_exp (frag_now,
990 /* Now we know what sort of opcodes it is, let's build the bytes. */
993 build_bytes (this_try, operand)
994 const struct h8_instruction *this_try;
995 struct h8_op *operand;
998 char *output = frag_more (this_try->length);
999 op_type *nibble_ptr = this_try->opcode->data.nib;
1001 unsigned int nibble_count = 0;
1007 char *p = asnibbles;
1009 if (!(this_try->opcode->inbase || Hmode))
1010 as_warn (_("Opcode `%s' with these operand types not available in H8/300 mode"),
1011 this_try->opcode->name);
1013 while (*nibble_ptr != E)
1018 d = (c & (DST | SRC_IN_DST)) != 0;
1024 if (c & (REG | IND | INC | DEC))
1025 nib = operand[d].reg;
1027 else if ((c & DISPREG) == (DISPREG))
1032 operand[d].mode = c;
1033 absat = nibble_count / 2;
1036 else if (c & (IMM | PCREL | ABS | ABSJMP | DISP))
1038 operand[d].mode = c;
1039 immat = nibble_count / 2;
1042 else if (c & IGNORE)
1047 switch (operand[0].exp.X_add_number)
1056 as_bad (_("Need #1 or #2 here"));
1061 switch (operand[0].exp.X_add_number)
1071 as_warn (_("#4 not valid on H8/300."));
1076 as_bad (_("Need #1 or #2 here"));
1079 /* Stop it making a fix. */
1080 operand[0].mode = 0;
1084 operand[d].mode |= MEMRELAX;
1091 if (operand[0].mode == MACREG)
1092 /* stmac has mac[hl] as the first operand. */
1093 nib = 2 + operand[0].reg;
1095 /* ldmac has mac[hl] as the second operand. */
1096 nib = 2 + operand[1].reg;
1104 /* Disgusting. Why, oh why didn't someone ask us for advice
1105 on the assembler format. */
1106 if (strcmp (this_try->opcode->name, "stm.l") == 0
1107 || strcmp (this_try->opcode->name, "ldm.l") == 0)
1110 high = (operand[this_try->opcode->name[0] == 'l' ? 1 : 0].reg >> 8) & 0xf;
1111 low = operand[this_try->opcode->name[0] == 'l' ? 1 : 0].reg & 0xf;
1113 asnibbles[2] = high - low;
1114 asnibbles[7] = (this_try->opcode->name[0] == 'l') ? high : low;
1117 for (i = 0; i < this_try->length; i++)
1118 output[i] = (asnibbles[i * 2] << 4) | asnibbles[i * 2 + 1];
1120 /* Note if this is a movb instruction -- there's a special relaxation
1121 which only applies to them. */
1122 if (strcmp (this_try->opcode->name, "mov.b") == 0)
1125 /* Output any fixes. */
1126 for (i = 0; i < 2; i++)
1128 int x = operand[i].mode;
1130 if (x & (IMM | DISP))
1131 do_a_fix_imm (output - frag_now->fr_literal + immat,
1132 operand + i, (x & MEMRELAX) != 0);
1135 do_a_fix_imm (output - frag_now->fr_literal + absat,
1136 operand + i, (x & MEMRELAX) ? movb + 1 : 0);
1140 int size16 = x & (L_16);
1141 int where = size16 ? 2 : 1;
1142 int size = size16 ? 2 : 1;
1143 int type = size16 ? R_PCRWORD : R_PCRBYTE;
1146 check_operand (operand + i, size16 ? 0x7fff : 0x7f, "@");
1148 if (operand[i].exp.X_add_number & 1)
1149 as_warn (_("branch operand has odd offset (%lx)\n"),
1150 (unsigned long) operand->exp.X_add_number);
1152 /* The COFF port has always been off by one, changing it
1153 now would be an incompatible change, so we leave it as-is.
1155 We don't want to do this for ELF as we want to be
1156 compatible with the proposed ELF format from Hitachi. */
1157 operand[i].exp.X_add_number -= 1;
1159 operand[i].exp.X_add_number =
1160 ((operand[i].exp.X_add_number & 0xff) ^ 0x80) - 0x80;
1162 fixP = fix_new_exp (frag_now,
1163 output - frag_now->fr_literal + where,
1168 fixP->fx_signed = 1;
1170 else if (x & MEMIND)
1172 check_operand (operand + i, 0xff, "@@");
1173 fix_new_exp (frag_now,
1174 output - frag_now->fr_literal + 1,
1180 else if (x & ABSJMP)
1185 /* To be compatible with the proposed H8 ELF format, we
1186 want the relocation's offset to point to the first byte
1187 that will be modified, not to the start of the instruction. */
1191 /* This jmp may be a jump or a branch. */
1193 check_operand (operand + i, Hmode ? 0xffffff : 0xffff, "@");
1195 if (operand[i].exp.X_add_number & 1)
1196 as_warn (_("branch operand has odd offset (%lx)\n"),
1197 (unsigned long) operand->exp.X_add_number);
1200 operand[i].exp.X_add_number =
1201 ((operand[i].exp.X_add_number & 0xffff) ^ 0x8000) - 0x8000;
1202 fix_new_exp (frag_now,
1203 output - frag_now->fr_literal + where,
1212 /* Try to give an intelligent error message for common and simple to
1216 clever_message (instruction, operand)
1217 const struct h8_instruction *instruction;
1218 struct h8_op *operand;
1220 /* Find out if there was more than one possible opcode. */
1222 if ((instruction + 1)->idx != instruction->idx)
1226 /* Only one opcode of this flavour, try to guess which operand
1228 for (argn = 0; argn < instruction->noperands; argn++)
1230 switch (instruction->opcode->args.nib[argn])
1233 if (operand[argn].mode != RD16)
1235 as_bad (_("destination operand must be 16 bit register"));
1242 if (operand[argn].mode != RS8)
1244 as_bad (_("source operand must be 8 bit register"));
1250 if (operand[argn].mode != ABS16DST)
1252 as_bad (_("destination operand must be 16bit absolute address"));
1257 if (operand[argn].mode != RD8)
1259 as_bad (_("destination operand must be 8 bit register"));
1265 if (operand[argn].mode != ABS16SRC)
1267 as_bad (_("source operand must be 16bit absolute address"));
1275 as_bad (_("invalid operands"));
1278 /* This is the guts of the machine-dependent assembler. STR points to
1279 a machine dependent instruction. This function is supposed to emit
1280 the frags/bytes it assembles. */
1288 struct h8_op operand[2];
1289 const struct h8_instruction *instruction;
1290 const struct h8_instruction *prev_instruction;
1296 /* Drop leading whitespace. */
1300 /* Find the op code end. */
1301 for (op_start = op_end = str;
1302 *op_end != 0 && *op_end != ' ';
1314 if (op_end == op_start)
1316 as_bad (_("can't find opcode "));
1322 instruction = (const struct h8_instruction *)
1323 hash_find (opcode_hash_control, op_start);
1325 if (instruction == NULL)
1327 as_bad (_("unknown opcode"));
1331 /* We used to set input_line_pointer to the result of get_operands,
1332 but that is wrong. Our caller assumes we don't change it. */
1334 (void) get_operands (instruction->noperands, op_end, operand);
1336 prev_instruction = instruction;
1356 instruction = get_specific (instruction, operand, size);
1358 if (instruction == 0)
1360 /* Couldn't find an opcode which matched the operands. */
1361 char *where = frag_more (2);
1365 clever_message (prev_instruction, operand);
1369 if (instruction->size && dot)
1371 if (instruction->size != *dot)
1373 as_warn (_("mismatch between opcode size and operand size"));
1377 build_bytes (instruction, operand);
1380 #ifndef BFD_ASSEMBLER
1382 tc_crawl_symbol_chain (headers)
1383 object_headers *headers ATTRIBUTE_UNUSED;
1385 printf (_("call to tc_crawl_symbol_chain \n"));
1390 md_undefined_symbol (name)
1391 char *name ATTRIBUTE_UNUSED;
1396 #ifndef BFD_ASSEMBLER
1398 tc_headers_hook (headers)
1399 object_headers *headers ATTRIBUTE_UNUSED;
1401 printf (_("call to tc_headers_hook \n"));
1405 /* Various routines to kill one day */
1406 /* Equal to MAX_PRECISION in atof-ieee.c */
1407 #define MAX_LITTLENUMS 6
1409 /* Turn a string in input_line_pointer into a floating point constant
1410 of type TYPE, and store the appropriate bytes in *LITP. The number
1411 of LITTLENUMS emitted is stored in *SIZEP. An error message is
1412 returned, or NULL on OK. */
1415 md_atof (type, litP, sizeP)
1421 LITTLENUM_TYPE words[MAX_LITTLENUMS];
1422 LITTLENUM_TYPE *wordP;
1453 return _("Bad call to MD_ATOF()");
1455 t = atof_ieee (input_line_pointer, type, words);
1457 input_line_pointer = t;
1459 *sizeP = prec * sizeof (LITTLENUM_TYPE);
1460 for (wordP = words; prec--;)
1462 md_number_to_chars (litP, (long) (*wordP++), sizeof (LITTLENUM_TYPE));
1463 litP += sizeof (LITTLENUM_TYPE);
1468 const char *md_shortopts = "";
1469 struct option md_longopts[] = {
1470 {NULL, no_argument, NULL, 0}
1473 size_t md_longopts_size = sizeof (md_longopts);
1476 md_parse_option (c, arg)
1477 int c ATTRIBUTE_UNUSED;
1478 char *arg ATTRIBUTE_UNUSED;
1484 md_show_usage (stream)
1485 FILE *stream ATTRIBUTE_UNUSED;
1489 void tc_aout_fix_to_chars PARAMS ((void));
1492 tc_aout_fix_to_chars ()
1494 printf (_("call to tc_aout_fix_to_chars \n"));
1499 md_convert_frag (headers, seg, fragP)
1500 #ifdef BFD_ASSEMBLER
1501 bfd *headers ATTRIBUTE_UNUSED;
1503 object_headers *headers ATTRIBUTE_UNUSED;
1505 segT seg ATTRIBUTE_UNUSED;
1506 fragS *fragP ATTRIBUTE_UNUSED;
1508 printf (_("call to md_convert_frag \n"));
1512 #ifdef BFD_ASSEMBLER
1514 md_section_align (segment, size)
1518 int align = bfd_get_section_alignment (stdoutput, segment);
1519 return ((size + (1 << align) - 1) & (-1 << align));
1523 md_section_align (seg, size)
1527 return ((size + (1 << section_alignment[(int) seg]) - 1)
1528 & (-1 << section_alignment[(int) seg]));
1534 md_apply_fix3 (fixP, valP, seg)
1537 segT seg ATTRIBUTE_UNUSED;
1539 char *buf = fixP->fx_where + fixP->fx_frag->fr_literal;
1542 switch (fixP->fx_size)
1548 *buf++ = (val >> 8);
1552 *buf++ = (val >> 24);
1553 *buf++ = (val >> 16);
1554 *buf++ = (val >> 8);
1561 if (fixP->fx_addsy == NULL && fixP->fx_pcrel == 0)
1566 md_estimate_size_before_relax (fragP, segment_type)
1567 register fragS *fragP ATTRIBUTE_UNUSED;
1568 register segT segment_type ATTRIBUTE_UNUSED;
1570 printf (_("call tomd_estimate_size_before_relax \n"));
1574 /* Put number into target byte order. */
1576 md_number_to_chars (ptr, use, nbytes)
1581 number_to_chars_bigendian (ptr, use, nbytes);
1585 md_pcrel_from (fixP)
1586 fixS *fixP ATTRIBUTE_UNUSED;
1591 #ifndef BFD_ASSEMBLER
1593 tc_reloc_mangle (fix_ptr, intr, base)
1595 struct internal_reloc *intr;
1599 symbolS *symbol_ptr;
1601 symbol_ptr = fix_ptr->fx_addsy;
1603 /* If this relocation is attached to a symbol then it's ok
1605 if (fix_ptr->fx_r_type == TC_CONS_RELOC)
1607 /* cons likes to create reloc32's whatever the size of the reloc..
1609 switch (fix_ptr->fx_size)
1612 intr->r_type = R_RELLONG;
1615 intr->r_type = R_RELWORD;
1618 intr->r_type = R_RELBYTE;
1626 intr->r_type = fix_ptr->fx_r_type;
1629 intr->r_vaddr = fix_ptr->fx_frag->fr_address + fix_ptr->fx_where + base;
1630 intr->r_offset = fix_ptr->fx_offset;
1634 if (symbol_ptr->sy_number != -1)
1635 intr->r_symndx = symbol_ptr->sy_number;
1640 /* This case arises when a reference is made to `.'. */
1641 segsym = seg_info (S_GET_SEGMENT (symbol_ptr))->dot;
1643 intr->r_symndx = -1;
1646 intr->r_symndx = segsym->sy_number;
1647 intr->r_offset += S_GET_VALUE (symbol_ptr);
1652 intr->r_symndx = -1;
1654 #else /* BFD_ASSEMBLER */
1656 tc_gen_reloc (section, fixp)
1657 asection *section ATTRIBUTE_UNUSED;
1661 bfd_reloc_code_real_type r_type;
1663 if (fixp->fx_addsy && fixp->fx_subsy)
1665 if ((S_GET_SEGMENT (fixp->fx_addsy) != S_GET_SEGMENT (fixp->fx_subsy))
1666 || S_GET_SEGMENT (fixp->fx_addsy) == undefined_section)
1668 as_bad_where (fixp->fx_file, fixp->fx_line,
1669 "Difference of symbols in different sections is not supported");
1674 rel = (arelent *) xmalloc (sizeof (arelent));
1675 rel->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
1676 *rel->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
1677 rel->address = fixp->fx_frag->fr_address + fixp->fx_where;
1678 rel->addend = fixp->fx_offset;
1680 r_type = fixp->fx_r_type;
1684 fprintf (stderr, "%s\n", bfd_get_reloc_code_name (r_type));
1687 rel->howto = bfd_reloc_type_lookup (stdoutput, r_type);
1688 if (rel->howto == NULL)
1690 as_bad_where (fixp->fx_file, fixp->fx_line,
1691 _("Cannot represent relocation type %s"),
1692 bfd_get_reloc_code_name (r_type));