1 /* tc-h8300.c -- Assemble code for the Hitachi H8/300
2 Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000, 2001
3 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"
36 #define R_MOV24B1 BFD_RELOC_H8_DIR24A8
37 #define R_MOVL1 BFD_RELOC_H8_DIR32A16
38 #define R_MOV24B1 BFD_RELOC_H8_DIR24A8
39 #define R_MOVL1 BFD_RELOC_H8_DIR32A16
40 #define R_RELLONG BFD_RELOC_32
41 #define R_MOV16B1 BFD_RELOC_H8_DIR16A8
42 #define R_RELWORD BFD_RELOC_16
43 #define R_RELBYTE BFD_RELOC_8
44 #define R_PCRWORD BFD_RELOC_16_PCREL
45 #define R_PCRBYTE BFD_RELOC_8_PCREL
46 #define R_JMPL1 BFD_RELOC_H8_DIR24R8
49 const char comment_chars[] = ";";
50 const char line_comment_chars[] = "#";
51 const char line_separator_chars[] = "";
53 /* This table describes all the machine specific pseudo-ops the assembler
54 has to support. The fields are:
55 pseudo-op name without dot
56 function to call to execute this pseudo-op
57 Integer arg to pass to the function
64 #define PSIZE (Hmode ? L_32 : L_16)
66 #define DSYMMODE (Hmode ? L_24 : L_16)
67 int bsize = L_8; /* default branch displacement */
75 if (!bfd_set_arch_mach (stdoutput, bfd_arch_h8300, bfd_mach_h8300h))
76 as_warn (_("could not set architecture and machine"));
86 if (!bfd_set_arch_mach (stdoutput, bfd_arch_h8300, bfd_mach_h8300s))
87 as_warn (_("could not set architecture and machine"));
101 cons (Hmode ? 4 : 2);
104 const pseudo_typeS md_pseudo_table[] =
106 {"h8300h", h8300hmode, 0},
107 {"h8300s", h8300smode, 0},
108 {"sbranch", sbranch, L_8},
109 {"lbranch", sbranch, L_16},
115 {"form", listing_psize, 0},
116 {"heading", listing_title, 0},
117 {"import", s_ignore, 0},
118 {"page", listing_eject, 0},
119 {"program", s_ignore, 0},
123 const int md_reloc_size;
125 const char EXP_CHARS[] = "eE";
127 /* Chars that mean this number is a floating point constant */
130 const char FLT_CHARS[] = "rRsSfFdDxXpP";
132 static struct hash_control *opcode_hash_control; /* Opcode mnemonics */
134 /* This function is called once, at assembler startup time. This
135 should set up all the tables, etc. that the MD part of the assembler
140 struct h8_opcode *opcode;
141 char prev_buffer[100];
145 if (!bfd_set_arch_mach (stdoutput, bfd_arch_h8300, bfd_mach_h8300))
146 as_warn (_("could not set architecture and machine"));
149 opcode_hash_control = hash_new ();
152 for (opcode = h8_opcodes; opcode->name; opcode++)
154 /* Strip off any . part when inserting the opcode and only enter
155 unique codes into the hash table. */
156 char *src = opcode->name;
157 unsigned int len = strlen (src);
158 char *dst = malloc (len + 1);
173 if (strcmp (buffer, prev_buffer))
175 hash_insert (opcode_hash_control, buffer, (char *) opcode);
176 strcpy (prev_buffer, buffer);
181 /* Find the number of operands. */
182 opcode->noperands = 0;
183 while (opcode->args.nib[opcode->noperands] != E)
186 /* Find the length of the opcode in bytes. */
188 while (opcode->data.nib[opcode->length * 2] != E)
203 int opsize; /* Set when a register size is seen */
214 WREG r0,r1,r2,r3,r4,r5,r6,r7,fp,sp
223 /* Try to parse a reg name. Return the number of chars consumed. */
226 parse_reg (src, mode, reg, direction)
236 /* Cribbed from get_symbol_end. */
237 if (!is_name_beginner (*src) || *src == '\001')
240 while (is_part_of_name (*end) || *end == '\001')
244 if (len == 2 && src[0] == 's' && src[1] == 'p')
246 *mode = PSIZE | REG | direction;
250 if (len == 3 && src[0] == 'c' && src[1] == 'c' && src[2] == 'r')
256 if (len == 3 && src[0] == 'e' && src[1] == 'x' && src[2] == 'r')
262 if (len == 2 && src[0] == 'f' && src[1] == 'p')
264 *mode = PSIZE | REG | direction;
268 if (len == 3 && src[0] == 'e' && src[1] == 'r'
269 && src[2] >= '0' && src[2] <= '7')
271 *mode = L_32 | REG | direction;
274 as_warn (_("Reg not valid for H8/300"));
277 if (len == 2 && src[0] == 'e' && src[1] >= '0' && src[1] <= '7')
279 *mode = L_16 | REG | direction;
280 *reg = src[1] - '0' + 8;
282 as_warn (_("Reg not valid for H8/300"));
288 if (src[1] >= '0' && src[1] <= '7')
290 if (len == 3 && src[2] == 'l')
292 *mode = L_8 | REG | direction;
293 *reg = (src[1] - '0') + 8;
296 if (len == 3 && src[2] == 'h')
298 *mode = L_8 | REG | direction;
299 *reg = (src[1] - '0');
304 *mode = L_16 | REG | direction;
305 *reg = (src[1] - '0');
319 char *save = input_line_pointer;
322 input_line_pointer = s;
324 if (op->X_op == O_absent)
325 as_bad (_("missing operand"));
326 new = input_line_pointer;
327 input_line_pointer = save;
332 skip_colonthing (ptr, exp, mode)
334 expressionS *exp ATTRIBUTE_UNUSED;
344 /* ff fill any 8 bit quantity */
345 /* exp->X_add_number -= 0x100; */
354 else if (*ptr == '3')
358 else if (*ptr == '1')
362 while (isdigit (*ptr))
369 /* The many forms of operand:
372 @Rn Register indirect
373 @(exp[:16], Rn) Register indirect with displacement
377 @aa:16 absolute 16 bit
380 #xx[:size] immediate data
381 @(exp:[8], pc) pc rel
382 @@aa[:8] memory indirect
393 src = skip_colonthing (src, &op->exp, &mode);
397 /* Choose a default mode. */
398 if (op->exp.X_add_number < -32768
399 || op->exp.X_add_number > 32767)
406 else if (op->exp.X_add_symbol
407 || op->exp.X_op_symbol)
418 get_operand (ptr, op, dst, direction)
421 unsigned int dst ATTRIBUTE_UNUSED;
431 /* Gross. Gross. ldm and stm have a format not easily handled
432 by get_operand. We deal with it explicitly here. */
433 if (src[0] == 'e' && src[1] == 'r' && isdigit (src[2])
434 && src[3] == '-' && src[4] == 'e' && src[5] == 'r' && isdigit (src[6]))
442 as_bad (_("Invalid register list for ldm/stm\n"));
445 as_bad (_("Invalid register list for ldm/stm\n"));
448 as_bad (_("Invalid register list for ldm/stm\n"));
452 as_bad (_("Invalid register list for ldm/stm\n"));
454 /* Even sicker. We encode two registers into op->reg. One
455 for the low register to save, the other for the high
456 register to save; we also set the high bit in op->reg
457 so we know this is "very special". */
458 op->reg = 0x80000000 | (high << 8) | low;
464 len = parse_reg (src, &op->mode, &op->reg, direction);
477 src = parse_exp (src, &op->exp);
479 src = skip_colonthing (src, &op->exp, &op->mode);
490 len = parse_reg (src, &mode, &num, direction);
493 /* Oops, not a reg after all, must be ordinary exp. */
495 /* Must be a symbol. */
496 op->mode = ABS | PSIZE | direction;
497 *ptr = skip_colonthing (parse_exp (src, &op->exp),
498 &op->exp, &op->mode);
503 if ((mode & SIZE) != PSIZE)
504 as_bad (_("Wrong size pointer register for architecture."));
515 /* Start off assuming a 16 bit offset. */
517 src = parse_exp (src, &op->exp);
519 src = colonmod24 (op, src);
524 op->mode |= ABS | direction;
531 as_bad (_("expected @(exp, reg16)"));
537 len = parse_reg (src, &mode, &op->reg, direction);
538 if (len == 0 || !(mode & REG))
540 as_bad (_("expected @(exp, reg16)"));
543 op->mode |= DISP | direction;
546 src = skip_colonthing (src, &op->exp, &op->mode);
548 if (*src != ')' && '(')
550 as_bad (_("expected @(exp, reg16)"));
557 len = parse_reg (src, &mode, &num, direction);
565 if ((mode & SIZE) != PSIZE)
566 as_bad (_("Wrong size pointer register for architecture."));
572 if ((mode & SIZE) != PSIZE)
573 as_bad (_("Wrong size pointer register for architecture."));
575 op->mode = direction | IND | PSIZE;
583 /* must be a symbol */
585 op->mode = ABS | direction;
586 src = parse_exp (src, &op->exp);
588 *ptr = colonmod24 (op, src);
598 src = parse_exp (src, &op->exp);
599 *ptr = skip_colonthing (src, &op->exp, &op->mode);
603 else if (strncmp (src, "mach", 4) == 0
604 || strncmp (src, "macl", 4) == 0)
606 op->reg = src[3] == 'l';
613 src = parse_exp (src, &op->exp);
614 /* Trailing ':' size ? */
617 if (src[1] == '1' && src[2] == '6')
619 op->mode = PCREL | L_16;
622 else if (src[1] == '8')
624 op->mode = PCREL | L_8;
629 as_bad (_("expect :8 or :16 here"));
634 op->mode = PCREL | bsize;
641 get_operands (noperands, op_end, operand)
642 unsigned int noperands;
644 struct h8_op *operand;
657 get_operand (&ptr, operand + 0, 0, SRC);
661 get_operand (&ptr, operand + 1, 1, DST);
671 get_operand (&ptr, operand + 0, 0, SRC);
674 get_operand (&ptr, operand + 1, 1, DST);
684 /* Passed a pointer to a list of opcodes which use different
685 addressing modes, return the opcode which matches the opcodes
687 static struct h8_opcode *
688 get_specific (opcode, operands, size)
689 struct h8_opcode *opcode;
690 struct h8_op *operands;
693 struct h8_opcode *this_try = opcode;
696 unsigned int this_index = opcode->idx;
698 /* There's only one ldm/stm and it's easier to just
699 get out quick for them. */
700 if (strcmp (opcode->name, "stm.l") == 0
701 || strcmp (opcode->name, "ldm.l") == 0)
704 while (this_index == opcode->idx && !found)
709 if (this_try->noperands == 0)
713 this_size = this_try->how & SN;
714 if (this_size != size && (this_size != SB || size != SN))
721 for (i = 0; i < this_try->noperands && found; i++)
723 op_type op = this_try->args.nib[i];
724 int x = operands[i].mode;
726 if ((op & (DISP | REG)) == (DISP | REG)
727 && ((x & (DISP | REG)) == (DISP | REG)))
729 dispreg = operands[i].reg;
737 x = (x & ~L_P) | (Hmode ? L_32 : L_16);
739 op = (op & ~L_P) | (Hmode ? L_32 : L_16);
743 /* The size of the reg is v important. */
744 if ((op & SIZE) != (x & SIZE))
747 else if ((op & ABSJMP) && (x & ABS))
749 operands[i].mode &= ~ABS;
750 operands[i].mode |= ABSJMP;
751 /* But it may not be 24 bits long. */
754 operands[i].mode &= ~SIZE;
755 operands[i].mode |= L_16;
758 else if ((op & (KBIT | DBIT)) && (x & IMM))
760 /* This is ok if the immediate value is sensible. */
764 /* The size of the displacement is important. */
765 if ((op & SIZE) != (x & SIZE))
768 else if ((op & (DISP | IMM | ABS))
769 && (op & (DISP | IMM | ABS)) == (x & (DISP | IMM | ABS)))
771 /* Promote a L_24 to L_32 if it makes us match. */
772 if ((x & L_24) && (op & L_32))
777 /* Promote an L8 to L_16 if it makes us match. */
778 if (op & ABS && op & L_8 && op & DISP)
783 else if ((x & SIZE) != 0
784 && ((op & SIZE) != (x & SIZE)))
787 else if ((op & MACREG) != (x & MACREG))
791 else if ((op & MODE) != (x & MODE))
805 check_operand (operand, width, string)
806 struct h8_op *operand;
810 if (operand->exp.X_add_symbol == 0
811 && operand->exp.X_op_symbol == 0)
813 /* No symbol involved, let's look at offset, it's dangerous if
814 any of the high bits are not 0 or ff's, find out by oring or
815 anding with the width and seeing if the answer is 0 or all
818 if ((operand->exp.X_add_number & ~width) != 0 &&
819 (operand->exp.X_add_number | width) != (~0))
822 && (operand->exp.X_add_number & 0xff00) == 0xff00)
824 /* Just ignore this one - which happens when trying to
825 fit a 16 bit address truncated into an 8 bit address
826 of something like bset. */
830 as_warn (_("operand %s0x%lx out of range."), string,
831 (unsigned long) operand->exp.X_add_number);
837 /* RELAXMODE has one of 3 values:
839 0 Output a "normal" reloc, no relaxing possible for this insn/reloc
841 1 Output a relaxable 24bit absolute mov.w address relocation
842 (may relax into a 16bit absolute address).
844 2 Output a relaxable 16/24 absolute mov.b address relocation
845 (may relax into an 8bit absolute address). */
848 do_a_fix_imm (offset, operand, relaxmode)
850 struct h8_op *operand;
857 char *t = operand->mode & IMM ? "#" : "@";
859 if (operand->exp.X_add_symbol == 0)
861 char *bytes = frag_now->fr_literal + offset;
862 switch (operand->mode & SIZE)
865 check_operand (operand, 0x3, t);
866 bytes[0] |= (operand->exp.X_add_number) << 4;
869 check_operand (operand, 0x7, t);
870 bytes[0] |= (operand->exp.X_add_number) << 4;
873 check_operand (operand, 0xff, t);
874 bytes[0] = operand->exp.X_add_number;
877 check_operand (operand, 0xffff, t);
878 bytes[0] = operand->exp.X_add_number >> 8;
879 bytes[1] = operand->exp.X_add_number >> 0;
882 check_operand (operand, 0xffffff, t);
883 bytes[0] = operand->exp.X_add_number >> 16;
884 bytes[1] = operand->exp.X_add_number >> 8;
885 bytes[2] = operand->exp.X_add_number >> 0;
889 /* This should be done with bfd. */
890 bytes[0] = operand->exp.X_add_number >> 24;
891 bytes[1] = operand->exp.X_add_number >> 16;
892 bytes[2] = operand->exp.X_add_number >> 8;
893 bytes[3] = operand->exp.X_add_number >> 0;
896 idx = (relaxmode == 2) ? R_MOV24B1 : R_MOVL1;
897 fix_new_exp (frag_now, offset, 4, &operand->exp, 0, idx);
904 switch (operand->mode & SIZE)
909 where = (operand->mode & SIZE) == L_24 ? -1 : 0;
912 else if (relaxmode == 1)
918 as_bad (_("Can't work out size of operand.\n"));
926 operand->exp.X_add_number =
927 ((operand->exp.X_add_number & 0xffff) ^ 0x8000) - 0x8000;
933 operand->exp.X_add_number =
934 ((operand->exp.X_add_number & 0xff) ^ 0x80) - 0x80;
937 fix_new_exp (frag_now,
946 /* Now we know what sort of opcodes it is, let's build the bytes. */
948 build_bytes (this_try, operand)
949 struct h8_opcode *this_try;
950 struct h8_op *operand;
954 char *output = frag_more (this_try->length);
955 op_type *nibble_ptr = this_try->data.nib;
957 unsigned int nibble_count = 0;
965 if (!(this_try->inbase || Hmode))
966 as_warn (_("Opcode `%s' with these operand types not available in H8/300 mode"),
969 while (*nibble_ptr != E)
974 d = (c & (DST | SRC_IN_DST)) != 0;
982 if (c & (REG | IND | INC | DEC))
984 nib = operand[d].reg;
986 else if ((c & DISPREG) == (DISPREG))
993 absat = nibble_count / 2;
996 else if (c & (IMM | PCREL | ABS | ABSJMP | DISP))
999 immat = nibble_count / 2;
1002 else if (c & IGNORE)
1008 switch (operand[0].exp.X_add_number)
1017 as_bad (_("Need #1 or #2 here"));
1022 switch (operand[0].exp.X_add_number)
1032 as_warn (_("#4 not valid on H8/300."));
1037 as_bad (_("Need #1 or #2 here"));
1040 /* Stop it making a fix. */
1041 operand[0].mode = 0;
1046 operand[d].mode |= MEMRELAX;
1056 if (operand[0].mode == MACREG)
1057 /* stmac has mac[hl] as the first operand. */
1058 nib = 2 + operand[0].reg;
1060 /* ldmac has mac[hl] as the second operand. */
1061 nib = 2 + operand[1].reg;
1069 /* Disgusting. Why, oh why didn't someone ask us for advice
1070 on the assembler format. */
1071 if (strcmp (this_try->name, "stm.l") == 0
1072 || strcmp (this_try->name, "ldm.l") == 0)
1075 high = (operand[this_try->name[0] == 'l' ? 1 : 0].reg >> 8) & 0xf;
1076 low = operand[this_try->name[0] == 'l' ? 1 : 0].reg & 0xf;
1078 asnibbles[2] = high - low;
1079 asnibbles[7] = (this_try->name[0] == 'l') ? high : low;
1082 for (i = 0; i < this_try->length; i++)
1084 output[i] = (asnibbles[i * 2] << 4) | asnibbles[i * 2 + 1];
1087 /* Note if this is a movb instruction -- there's a special relaxation
1088 which only applies to them. */
1089 if (strcmp (this_try->name, "mov.b") == 0)
1092 /* Output any fixes. */
1093 for (i = 0; i < 2; i++)
1095 int x = operand[i].mode;
1097 if (x & (IMM | DISP))
1099 do_a_fix_imm (output - frag_now->fr_literal + immat,
1100 operand + i, x & MEMRELAX != 0);
1104 do_a_fix_imm (output - frag_now->fr_literal + absat,
1105 operand + i, x & MEMRELAX ? movb + 1 : 0);
1109 int size16 = x & L_16;
1110 int where = size16 ? 2 : 1;
1111 int size = size16 ? 2 : 1;
1112 int type = size16 ? R_PCRWORD : R_PCRBYTE;
1114 check_operand (operand + i, size16 ? 0x7fff : 0x7f, "@");
1116 if (operand[i].exp.X_add_number & 1)
1118 as_warn (_("branch operand has odd offset (%lx)\n"),
1119 (unsigned long) operand->exp.X_add_number);
1122 operand[i].exp.X_add_number -= 1;
1123 operand[i].exp.X_add_number =
1124 ((operand[i].exp.X_add_number & 0xff) ^ 0x80) - 0x80;
1126 fix_new_exp (frag_now,
1127 output - frag_now->fr_literal + where,
1133 else if (x & MEMIND)
1135 check_operand (operand + i, 0xff, "@@");
1136 fix_new_exp (frag_now,
1137 output - frag_now->fr_literal + 1,
1143 else if (x & ABSJMP)
1145 /* This jmp may be a jump or a branch. */
1147 check_operand (operand + i, Hmode ? 0xffffff : 0xffff, "@");
1148 if (operand[i].exp.X_add_number & 1)
1150 as_warn (_("branch operand has odd offset (%lx)\n"),
1151 (unsigned long) operand->exp.X_add_number);
1154 operand[i].exp.X_add_number =
1155 ((operand[i].exp.X_add_number & 0xffff) ^ 0x8000) - 0x8000;
1156 fix_new_exp (frag_now,
1157 output - frag_now->fr_literal,
1166 /* Try to give an intelligent error message for common and simple to
1169 clever_message (opcode, operand)
1170 struct h8_opcode *opcode;
1171 struct h8_op *operand;
1173 /* Find out if there was more than one possible opcode. */
1175 if ((opcode + 1)->idx != opcode->idx)
1179 /* Only one opcode of this flavour, try to guess which operand
1181 for (argn = 0; argn < opcode->noperands; argn++)
1183 switch (opcode->args.nib[argn])
1186 if (operand[argn].mode != RD16)
1188 as_bad (_("destination operand must be 16 bit register"));
1195 if (operand[argn].mode != RS8)
1197 as_bad (_("source operand must be 8 bit register"));
1203 if (operand[argn].mode != ABS16DST)
1205 as_bad (_("destination operand must be 16bit absolute address"));
1210 if (operand[argn].mode != RD8)
1212 as_bad (_("destination operand must be 8 bit register"));
1218 if (operand[argn].mode != ABS16SRC)
1220 as_bad (_("source operand must be 16bit absolute address"));
1228 as_bad (_("invalid operands"));
1231 /* This is the guts of the machine-dependent assembler. STR points to
1232 a machine dependent instruction. This function is supposed to emit
1233 the frags/bytes it assembles. */
1240 struct h8_op operand[2];
1241 struct h8_opcode *opcode;
1242 struct h8_opcode *prev_opcode;
1248 /* Drop leading whitespace. */
1252 /* Find the op code end. */
1253 for (op_start = op_end = str;
1254 *op_end != 0 && *op_end != ' ';
1266 if (op_end == op_start)
1268 as_bad (_("can't find opcode "));
1274 opcode = (struct h8_opcode *) hash_find (opcode_hash_control,
1279 as_bad (_("unknown opcode"));
1283 /* We used to set input_line_pointer to the result of get_operands,
1284 but that is wrong. Our caller assumes we don't change it. */
1286 (void) get_operands (opcode->noperands, op_end, operand);
1288 prev_opcode = opcode;
1308 opcode = get_specific (opcode, operand, size);
1312 /* Couldn't find an opcode which matched the operands. */
1313 char *where = frag_more (2);
1317 clever_message (prev_opcode, operand);
1321 if (opcode->size && dot)
1323 if (opcode->size != *dot)
1325 as_warn (_("mismatch between opcode size and operand size"));
1329 build_bytes (opcode, operand);
1332 #ifndef BFD_ASSEMBLER
1334 tc_crawl_symbol_chain (headers)
1335 object_headers *headers ATTRIBUTE_UNUSED;
1337 printf (_("call to tc_crawl_symbol_chain \n"));
1342 md_undefined_symbol (name)
1343 char *name ATTRIBUTE_UNUSED;
1348 #ifndef BFD_ASSEMBLER
1350 tc_headers_hook (headers)
1351 object_headers *headers ATTRIBUTE_UNUSED;
1353 printf (_("call to tc_headers_hook \n"));
1357 /* Various routines to kill one day */
1358 /* Equal to MAX_PRECISION in atof-ieee.c */
1359 #define MAX_LITTLENUMS 6
1361 /* Turn a string in input_line_pointer into a floating point constant
1362 of type TYPE, and store the appropriate bytes in *LITP. The number
1363 of LITTLENUMS emitted is stored in *SIZEP. An error message is
1364 returned, or NULL on OK. */
1367 md_atof (type, litP, sizeP)
1373 LITTLENUM_TYPE words[MAX_LITTLENUMS];
1374 LITTLENUM_TYPE *wordP;
1406 return _("Bad call to MD_ATOF()");
1408 t = atof_ieee (input_line_pointer, type, words);
1410 input_line_pointer = t;
1412 *sizeP = prec * sizeof (LITTLENUM_TYPE);
1413 for (wordP = words; prec--;)
1415 md_number_to_chars (litP, (long) (*wordP++), sizeof (LITTLENUM_TYPE));
1416 litP += sizeof (LITTLENUM_TYPE);
1421 CONST char *md_shortopts = "";
1422 struct option md_longopts[] = {
1423 {NULL, no_argument, NULL, 0}
1426 size_t md_longopts_size = sizeof (md_longopts);
1429 md_parse_option (c, arg)
1430 int c ATTRIBUTE_UNUSED;
1431 char *arg ATTRIBUTE_UNUSED;
1437 md_show_usage (stream)
1438 FILE *stream ATTRIBUTE_UNUSED;
1443 tc_aout_fix_to_chars ()
1445 printf (_("call to tc_aout_fix_to_chars \n"));
1450 md_convert_frag (headers, seg, fragP)
1451 object_headers *headers ATTRIBUTE_UNUSED;
1452 segT seg ATTRIBUTE_UNUSED;
1453 fragS *fragP ATTRIBUTE_UNUSED;
1455 printf (_("call to md_convert_frag \n"));
1460 md_section_align (seg, size)
1464 return ((size + (1 << section_alignment[(int) seg]) - 1)
1465 & (-1 << section_alignment[(int) seg]));
1469 md_apply_fix (fixP, val)
1473 char *buf = fixP->fx_where + fixP->fx_frag->fr_literal;
1475 switch (fixP->fx_size)
1481 *buf++ = (val >> 8);
1485 *buf++ = (val >> 24);
1486 *buf++ = (val >> 16);
1487 *buf++ = (val >> 8);
1496 md_estimate_size_before_relax (fragP, segment_type)
1497 register fragS *fragP ATTRIBUTE_UNUSED;
1498 register segT segment_type ATTRIBUTE_UNUSED;
1500 printf (_("call tomd_estimate_size_before_relax \n"));
1504 /* Put number into target byte order. */
1506 md_number_to_chars (ptr, use, nbytes)
1511 number_to_chars_bigendian (ptr, use, nbytes);
1515 md_pcrel_from (fixP)
1516 fixS *fixP ATTRIBUTE_UNUSED;
1521 #ifndef BFD_ASSEMBLER
1523 tc_reloc_mangle (fix_ptr, intr, base)
1525 struct internal_reloc *intr;
1529 symbolS *symbol_ptr;
1531 symbol_ptr = fix_ptr->fx_addsy;
1533 /* If this relocation is attached to a symbol then it's ok
1535 if (fix_ptr->fx_r_type == TC_CONS_RELOC)
1537 /* cons likes to create reloc32's whatever the size of the reloc..
1539 switch (fix_ptr->fx_size)
1542 intr->r_type = R_RELLONG;
1545 intr->r_type = R_RELWORD;
1548 intr->r_type = R_RELBYTE;
1556 intr->r_type = fix_ptr->fx_r_type;
1559 intr->r_vaddr = fix_ptr->fx_frag->fr_address + fix_ptr->fx_where + base;
1560 intr->r_offset = fix_ptr->fx_offset;
1564 if (symbol_ptr->sy_number != -1)
1565 intr->r_symndx = symbol_ptr->sy_number;
1570 /* This case arises when a reference is made to `.'. */
1571 segsym = seg_info (S_GET_SEGMENT (symbol_ptr))->dot;
1573 intr->r_symndx = -1;
1576 intr->r_symndx = segsym->sy_number;
1577 intr->r_offset += S_GET_VALUE (symbol_ptr);
1582 intr->r_symndx = -1;
1584 #else /* BFD_ASSEMBLER */
1586 tc_gen_reloc (section, fixp)
1587 asection *section ATTRIBUTE_UNUSED;
1591 bfd_reloc_code_real_type r_type;
1593 rel = (arelent *) xmalloc (sizeof (arelent));
1594 rel->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
1595 *rel->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
1596 rel->address = fixp->fx_frag->fr_address + fixp->fx_where;
1597 rel->addend = fixp->fx_offset;
1599 r_type = fixp->fx_r_type;
1603 fprintf (stderr, "%s\n", bfd_get_reloc_code_name (r_type));
1606 rel->howto = bfd_reloc_type_lookup (stdoutput, r_type);
1607 if (rel->howto == NULL)
1609 as_bad_where (fixp->fx_file, fixp->fx_line,
1610 _("Cannot represent relocation type %s"),
1611 bfd_get_reloc_code_name (r_type));