1 /* tc-h8300.c -- Assemble code for the Hitachi H8/300
2 Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000
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"
33 const char comment_chars[] = ";";
34 const char line_comment_chars[] = "#";
35 const char line_separator_chars[] = "";
37 /* This table describes all the machine specific pseudo-ops the assembler
38 has to support. The fields are:
39 pseudo-op name without dot
40 function to call to execute this pseudo-op
41 Integer arg to pass to the function
48 #define PSIZE (Hmode ? L_32 : L_16)
50 #define DSYMMODE (Hmode ? L_24 : L_16)
51 int bsize = L_8; /* default branch displacement */
59 if (!bfd_set_arch_mach (stdoutput, bfd_arch_h8300, bfd_mach_h8300h))
60 as_warn (_("could not set architecture and machine"));
70 if (!bfd_set_arch_mach (stdoutput, bfd_arch_h8300, bfd_mach_h8300s))
71 as_warn (_("could not set architecture and machine"));
88 const pseudo_typeS md_pseudo_table[] =
90 {"h8300h", h8300hmode, 0},
91 {"h8300s", h8300smode, 0},
92 {"sbranch", sbranch, L_8},
93 {"lbranch", sbranch, L_16},
99 {"form", listing_psize, 0},
100 {"heading", listing_title, 0},
101 {"import", s_ignore, 0},
102 {"page", listing_eject, 0},
103 {"program", s_ignore, 0},
107 const int md_reloc_size;
109 const char EXP_CHARS[] = "eE";
111 /* Chars that mean this number is a floating point constant */
114 const char FLT_CHARS[] = "rRsSfFdDxXpP";
116 static struct hash_control *opcode_hash_control; /* Opcode mnemonics */
118 /* This function is called once, at assembler startup time. This
119 should set up all the tables, etc. that the MD part of the assembler
124 struct h8_opcode *opcode;
125 char prev_buffer[100];
129 if (!bfd_set_arch_mach (stdoutput, bfd_arch_h8300, bfd_mach_h8300))
130 as_warn (_("could not set architecture and machine"));
133 opcode_hash_control = hash_new ();
136 for (opcode = h8_opcodes; opcode->name; opcode++)
138 /* Strip off any . part when inserting the opcode and only enter
139 unique codes into the hash table. */
140 char *src = opcode->name;
141 unsigned int len = strlen (src);
142 char *dst = malloc (len + 1);
157 if (strcmp (buffer, prev_buffer))
159 hash_insert (opcode_hash_control, buffer, (char *) opcode);
160 strcpy (prev_buffer, buffer);
165 /* Find the number of operands. */
166 opcode->noperands = 0;
167 while (opcode->args.nib[opcode->noperands] != E)
170 /* Find the length of the opcode in bytes. */
172 while (opcode->data.nib[opcode->length * 2] != E)
187 int opsize; /* Set when a register size is seen */
198 WREG r0,r1,r2,r3,r4,r5,r6,r7,fp,sp
207 /* Try to parse a reg name. Return the number of chars consumed. */
210 parse_reg (src, mode, reg, direction)
220 /* Cribbed from get_symbol_end. */
221 if (!is_name_beginner (*src) || *src == '\001')
224 while (is_part_of_name (*end) || *end == '\001')
228 if (len == 2 && src[0] == 's' && src[1] == 'p')
230 *mode = PSIZE | REG | direction;
234 if (len == 3 && src[0] == 'c' && src[1] == 'c' && src[2] == 'r')
240 if (len == 3 && src[0] == 'e' && src[1] == 'x' && src[2] == 'r')
246 if (len == 2 && src[0] == 'f' && src[1] == 'p')
248 *mode = PSIZE | REG | direction;
252 if (len == 3 && src[0] == 'e' && src[1] == 'r'
253 && src[2] >= '0' && src[2] <= '7')
255 *mode = L_32 | REG | direction;
258 as_warn (_("Reg not valid for H8/300"));
261 if (len == 2 && src[0] == 'e' && src[1] >= '0' && src[1] <= '7')
263 *mode = L_16 | REG | direction;
264 *reg = src[1] - '0' + 8;
266 as_warn (_("Reg not valid for H8/300"));
272 if (src[1] >= '0' && src[1] <= '7')
274 if (len == 3 && src[2] == 'l')
276 *mode = L_8 | REG | direction;
277 *reg = (src[1] - '0') + 8;
280 if (len == 3 && src[2] == 'h')
282 *mode = L_8 | REG | direction;
283 *reg = (src[1] - '0');
288 *mode = L_16 | REG | direction;
289 *reg = (src[1] - '0');
303 char *save = input_line_pointer;
306 input_line_pointer = s;
308 if (op->X_op == O_absent)
309 as_bad (_("missing operand"));
310 new = input_line_pointer;
311 input_line_pointer = save;
316 skip_colonthing (ptr, exp, mode)
318 expressionS *exp ATTRIBUTE_UNUSED;
328 /* ff fill any 8 bit quantity */
329 /* exp->X_add_number -= 0x100; */
338 else if (*ptr == '3')
342 else if (*ptr == '1')
346 while (isdigit (*ptr))
353 /* The many forms of operand:
356 @Rn Register indirect
357 @(exp[:16], Rn) Register indirect with displacement
361 @aa:16 absolute 16 bit
364 #xx[:size] immediate data
365 @(exp:[8], pc) pc rel
366 @@aa[:8] memory indirect
377 src = skip_colonthing (src, &op->exp, &mode);
381 /* Choose a default mode. */
382 if (op->exp.X_add_number < -32768
383 || op->exp.X_add_number > 32767)
390 else if (op->exp.X_add_symbol
391 || op->exp.X_op_symbol)
402 get_operand (ptr, op, dst, direction)
405 unsigned int dst ATTRIBUTE_UNUSED;
415 /* Gross. Gross. ldm and stm have a format not easily handled
416 by get_operand. We deal with it explicitly here. */
417 if (src[0] == 'e' && src[1] == 'r' && isdigit (src[2])
418 && src[3] == '-' && src[4] == 'e' && src[5] == 'r' && isdigit (src[6]))
426 as_bad (_("Invalid register list for ldm/stm\n"));
429 as_bad (_("Invalid register list for ldm/stm\n"));
432 as_bad (_("Invalid register list for ldm/stm\n"));
436 as_bad (_("Invalid register list for ldm/stm\n"));
438 /* Even sicker. We encode two registers into op->reg. One
439 for the low register to save, the other for the high
440 register to save; we also set the high bit in op->reg
441 so we know this is "very special". */
442 op->reg = 0x80000000 | (high << 8) | low;
448 len = parse_reg (src, &op->mode, &op->reg, direction);
461 src = parse_exp (src, &op->exp);
463 src = skip_colonthing (src, &op->exp, &op->mode);
474 len = parse_reg (src, &mode, &num, direction);
477 /* Oops, not a reg after all, must be ordinary exp. */
479 /* Must be a symbol. */
480 op->mode = ABS | PSIZE | direction;
481 *ptr = skip_colonthing (parse_exp (src, &op->exp),
482 &op->exp, &op->mode);
487 if ((mode & SIZE) != PSIZE)
488 as_bad (_("Wrong size pointer register for architecture."));
499 /* Start off assuming a 16 bit offset. */
501 src = parse_exp (src, &op->exp);
503 src = colonmod24 (op, src);
508 op->mode |= ABS | direction;
515 as_bad (_("expected @(exp, reg16)"));
521 len = parse_reg (src, &mode, &op->reg, direction);
522 if (len == 0 || !(mode & REG))
524 as_bad (_("expected @(exp, reg16)"));
527 op->mode |= DISP | direction;
530 src = skip_colonthing (src, &op->exp, &op->mode);
532 if (*src != ')' && '(')
534 as_bad (_("expected @(exp, reg16)"));
541 len = parse_reg (src, &mode, &num, direction);
549 if ((mode & SIZE) != PSIZE)
550 as_bad (_("Wrong size pointer register for architecture."));
556 if ((mode & SIZE) != PSIZE)
557 as_bad (_("Wrong size pointer register for architecture."));
559 op->mode = direction | IND | PSIZE;
567 /* must be a symbol */
569 op->mode = ABS | direction;
570 src = parse_exp (src, &op->exp);
572 *ptr = colonmod24 (op, src);
582 src = parse_exp (src, &op->exp);
583 *ptr = skip_colonthing (src, &op->exp, &op->mode);
587 else if (strncmp (src, "mach", 4) == 0
588 || strncmp (src, "macl", 4) == 0)
590 op->reg = src[3] == 'l';
597 src = parse_exp (src, &op->exp);
598 /* Trailing ':' size ? */
601 if (src[1] == '1' && src[2] == '6')
603 op->mode = PCREL | L_16;
606 else if (src[1] == '8')
608 op->mode = PCREL | L_8;
613 as_bad (_("expect :8 or :16 here"));
618 op->mode = PCREL | bsize;
625 get_operands (noperands, op_end, operand)
626 unsigned int noperands;
628 struct h8_op *operand;
641 get_operand (&ptr, operand + 0, 0, SRC);
645 get_operand (&ptr, operand + 1, 1, DST);
655 get_operand (&ptr, operand + 0, 0, SRC);
658 get_operand (&ptr, operand + 1, 1, DST);
668 /* Passed a pointer to a list of opcodes which use different
669 addressing modes, return the opcode which matches the opcodes
671 static struct h8_opcode *
672 get_specific (opcode, operands, size)
673 struct h8_opcode *opcode;
674 struct h8_op *operands;
677 struct h8_opcode *this_try = opcode;
680 unsigned int this_index = opcode->idx;
682 /* There's only one ldm/stm and it's easier to just
683 get out quick for them. */
684 if (strcmp (opcode->name, "stm.l") == 0
685 || strcmp (opcode->name, "ldm.l") == 0)
688 while (this_index == opcode->idx && !found)
693 if (this_try->noperands == 0)
697 this_size = this_try->how & SN;
698 if (this_size != size && (this_size != SB || size != SN))
705 for (i = 0; i < this_try->noperands && found; i++)
707 op_type op = this_try->args.nib[i];
708 int x = operands[i].mode;
710 if ((op & (DISP | REG)) == (DISP | REG)
711 && ((x & (DISP | REG)) == (DISP | REG)))
713 dispreg = operands[i].reg;
721 x = (x & ~L_P) | (Hmode ? L_32 : L_16);
723 op = (op & ~L_P) | (Hmode ? L_32 : L_16);
727 /* The size of the reg is v important. */
728 if ((op & SIZE) != (x & SIZE))
731 else if ((op & ABSJMP) && (x & ABS))
733 operands[i].mode &= ~ABS;
734 operands[i].mode |= ABSJMP;
735 /* But it may not be 24 bits long. */
738 operands[i].mode &= ~SIZE;
739 operands[i].mode |= L_16;
742 else if ((op & (KBIT | DBIT)) && (x & IMM))
744 /* This is ok if the immediate value is sensible. */
748 /* The size of the displacement is important. */
749 if ((op & SIZE) != (x & SIZE))
752 else if ((op & (DISP | IMM | ABS))
753 && (op & (DISP | IMM | ABS)) == (x & (DISP | IMM | ABS)))
755 /* Promote a L_24 to L_32 if it makes us match. */
756 if ((x & L_24) && (op & L_32))
761 /* Promote an L8 to L_16 if it makes us match. */
762 if (op & ABS && op & L_8 && op & DISP)
767 else if ((x & SIZE) != 0
768 && ((op & SIZE) != (x & SIZE)))
771 else if ((op & MACREG) != (x & MACREG))
775 else if ((op & MODE) != (x & MODE))
789 check_operand (operand, width, string)
790 struct h8_op *operand;
794 if (operand->exp.X_add_symbol == 0
795 && operand->exp.X_op_symbol == 0)
797 /* No symbol involved, let's look at offset, it's dangerous if
798 any of the high bits are not 0 or ff's, find out by oring or
799 anding with the width and seeing if the answer is 0 or all
802 if ((operand->exp.X_add_number & ~width) != 0 &&
803 (operand->exp.X_add_number | width) != (~0))
806 && (operand->exp.X_add_number & 0xff00) == 0xff00)
808 /* Just ignore this one - which happens when trying to
809 fit a 16 bit address truncated into an 8 bit address
810 of something like bset. */
814 as_warn (_("operand %s0x%lx out of range."), string,
815 (unsigned long) operand->exp.X_add_number);
821 /* RELAXMODE has one of 3 values:
823 0 Output a "normal" reloc, no relaxing possible for this insn/reloc
825 1 Output a relaxable 24bit absolute mov.w address relocation
826 (may relax into a 16bit absolute address).
828 2 Output a relaxable 16/24 absolute mov.b address relocation
829 (may relax into an 8bit absolute address). */
832 do_a_fix_imm (offset, operand, relaxmode)
834 struct h8_op *operand;
841 char *t = operand->mode & IMM ? "#" : "@";
843 if (operand->exp.X_add_symbol == 0)
845 char *bytes = frag_now->fr_literal + offset;
846 switch (operand->mode & SIZE)
849 check_operand (operand, 0x3, t);
850 bytes[0] |= (operand->exp.X_add_number) << 4;
853 check_operand (operand, 0x7, t);
854 bytes[0] |= (operand->exp.X_add_number) << 4;
857 check_operand (operand, 0xff, t);
858 bytes[0] = operand->exp.X_add_number;
861 check_operand (operand, 0xffff, t);
862 bytes[0] = operand->exp.X_add_number >> 8;
863 bytes[1] = operand->exp.X_add_number >> 0;
866 check_operand (operand, 0xffffff, t);
867 bytes[0] = operand->exp.X_add_number >> 16;
868 bytes[1] = operand->exp.X_add_number >> 8;
869 bytes[2] = operand->exp.X_add_number >> 0;
873 /* This should be done with bfd. */
874 bytes[0] = operand->exp.X_add_number >> 24;
875 bytes[1] = operand->exp.X_add_number >> 16;
876 bytes[2] = operand->exp.X_add_number >> 8;
877 bytes[3] = operand->exp.X_add_number >> 0;
880 idx = (relaxmode == 2) ? R_MOV24B1 : R_MOVL1;
881 fix_new_exp (frag_now, offset, 4, &operand->exp, 0, idx);
888 switch (operand->mode & SIZE)
893 where = (operand->mode & SIZE) == L_24 ? -1 : 0;
896 else if (relaxmode == 1)
902 as_bad (_("Can't work out size of operand.\n"));
910 operand->exp.X_add_number =
911 ((operand->exp.X_add_number & 0xffff) ^ 0x8000) - 0x8000;
917 operand->exp.X_add_number =
918 ((operand->exp.X_add_number & 0xff) ^ 0x80) - 0x80;
921 fix_new_exp (frag_now,
930 /* Now we know what sort of opcodes it is, let's build the bytes. */
932 build_bytes (this_try, operand)
933 struct h8_opcode *this_try;
934 struct h8_op *operand;
938 char *output = frag_more (this_try->length);
939 op_type *nibble_ptr = this_try->data.nib;
941 unsigned int nibble_count = 0;
949 if (!(this_try->inbase || Hmode))
950 as_warn (_("Opcode `%s' with these operand types not available in H8/300 mode"),
953 while (*nibble_ptr != E)
958 d = (c & (DST | SRC_IN_DST)) != 0;
966 if (c & (REG | IND | INC | DEC))
968 nib = operand[d].reg;
970 else if ((c & DISPREG) == (DISPREG))
977 absat = nibble_count / 2;
980 else if (c & (IMM | PCREL | ABS | ABSJMP | DISP))
983 immat = nibble_count / 2;
992 switch (operand[0].exp.X_add_number)
1001 as_bad (_("Need #1 or #2 here"));
1006 switch (operand[0].exp.X_add_number)
1016 as_warn (_("#4 not valid on H8/300."));
1021 as_bad (_("Need #1 or #2 here"));
1024 /* Stop it making a fix. */
1025 operand[0].mode = 0;
1030 operand[d].mode |= MEMRELAX;
1040 if (operand[0].mode == MACREG)
1041 /* stmac has mac[hl] as the first operand. */
1042 nib = 2 + operand[0].reg;
1044 /* ldmac has mac[hl] as the second operand. */
1045 nib = 2 + operand[1].reg;
1053 /* Disgusting. Why, oh why didn't someone ask us for advice
1054 on the assembler format. */
1055 if (strcmp (this_try->name, "stm.l") == 0
1056 || strcmp (this_try->name, "ldm.l") == 0)
1059 high = (operand[this_try->name[0] == 'l' ? 1 : 0].reg >> 8) & 0xf;
1060 low = operand[this_try->name[0] == 'l' ? 1 : 0].reg & 0xf;
1062 asnibbles[2] = high - low;
1063 asnibbles[7] = (this_try->name[0] == 'l') ? high : low;
1066 for (i = 0; i < this_try->length; i++)
1068 output[i] = (asnibbles[i * 2] << 4) | asnibbles[i * 2 + 1];
1071 /* Note if this is a movb instruction -- there's a special relaxation
1072 which only applies to them. */
1073 if (strcmp (this_try->name, "mov.b") == 0)
1076 /* Output any fixes. */
1077 for (i = 0; i < 2; i++)
1079 int x = operand[i].mode;
1081 if (x & (IMM | DISP))
1083 do_a_fix_imm (output - frag_now->fr_literal + immat,
1084 operand + i, x & MEMRELAX != 0);
1088 do_a_fix_imm (output - frag_now->fr_literal + absat,
1089 operand + i, x & MEMRELAX ? movb + 1 : 0);
1093 int size16 = x & L_16;
1094 int where = size16 ? 2 : 1;
1095 int size = size16 ? 2 : 1;
1096 int type = size16 ? R_PCRWORD : R_PCRBYTE;
1098 check_operand (operand + i, size16 ? 0x7fff : 0x7f, "@");
1100 if (operand[i].exp.X_add_number & 1)
1102 as_warn (_("branch operand has odd offset (%lx)\n"),
1103 (unsigned long) operand->exp.X_add_number);
1106 operand[i].exp.X_add_number -= 1;
1107 operand[i].exp.X_add_number =
1108 ((operand[i].exp.X_add_number & 0xff) ^ 0x80) - 0x80;
1110 fix_new_exp (frag_now,
1111 output - frag_now->fr_literal + where,
1117 else if (x & MEMIND)
1119 check_operand (operand + i, 0xff, "@@");
1120 fix_new_exp (frag_now,
1121 output - frag_now->fr_literal + 1,
1127 else if (x & ABSJMP)
1129 /* This jmp may be a jump or a branch. */
1131 check_operand (operand + i, Hmode ? 0xffffff : 0xffff, "@");
1132 if (operand[i].exp.X_add_number & 1)
1134 as_warn (_("branch operand has odd offset (%lx)\n"),
1135 (unsigned long) operand->exp.X_add_number);
1138 operand[i].exp.X_add_number =
1139 ((operand[i].exp.X_add_number & 0xffff) ^ 0x8000) - 0x8000;
1140 fix_new_exp (frag_now,
1141 output - frag_now->fr_literal,
1150 /* Try to give an intelligent error message for common and simple to
1153 clever_message (opcode, operand)
1154 struct h8_opcode *opcode;
1155 struct h8_op *operand;
1157 /* Find out if there was more than one possible opcode. */
1159 if ((opcode + 1)->idx != opcode->idx)
1163 /* Only one opcode of this flavour, try to guess which operand
1165 for (argn = 0; argn < opcode->noperands; argn++)
1167 switch (opcode->args.nib[argn])
1170 if (operand[argn].mode != RD16)
1172 as_bad (_("destination operand must be 16 bit register"));
1179 if (operand[argn].mode != RS8)
1181 as_bad (_("source operand must be 8 bit register"));
1187 if (operand[argn].mode != ABS16DST)
1189 as_bad (_("destination operand must be 16bit absolute address"));
1194 if (operand[argn].mode != RD8)
1196 as_bad (_("destination operand must be 8 bit register"));
1202 if (operand[argn].mode != ABS16SRC)
1204 as_bad (_("source operand must be 16bit absolute address"));
1212 as_bad (_("invalid operands"));
1215 /* This is the guts of the machine-dependent assembler. STR points to
1216 a machine dependent instruction. This function is supposed to emit
1217 the frags/bytes it assembles. */
1224 struct h8_op operand[2];
1225 struct h8_opcode *opcode;
1226 struct h8_opcode *prev_opcode;
1232 /* Drop leading whitespace. */
1236 /* Find the op code end. */
1237 for (op_start = op_end = str;
1238 *op_end != 0 && *op_end != ' ';
1250 if (op_end == op_start)
1252 as_bad (_("can't find opcode "));
1258 opcode = (struct h8_opcode *) hash_find (opcode_hash_control,
1263 as_bad (_("unknown opcode"));
1267 /* We used to set input_line_pointer to the result of get_operands,
1268 but that is wrong. Our caller assumes we don't change it. */
1270 (void) get_operands (opcode->noperands, op_end, operand);
1272 prev_opcode = opcode;
1292 opcode = get_specific (opcode, operand, size);
1296 /* Couldn't find an opcode which matched the operands. */
1297 char *where = frag_more (2);
1301 clever_message (prev_opcode, operand);
1305 if (opcode->size && dot)
1307 if (opcode->size != *dot)
1309 as_warn (_("mismatch between opcode size and operand size"));
1313 build_bytes (opcode, operand);
1317 tc_crawl_symbol_chain (headers)
1318 object_headers *headers ATTRIBUTE_UNUSED;
1320 printf (_("call to tc_crawl_symbol_chain \n"));
1324 md_undefined_symbol (name)
1325 char *name ATTRIBUTE_UNUSED;
1331 tc_headers_hook (headers)
1332 object_headers *headers ATTRIBUTE_UNUSED;
1334 printf (_("call to tc_headers_hook \n"));
1337 /* Various routines to kill one day */
1338 /* Equal to MAX_PRECISION in atof-ieee.c */
1339 #define MAX_LITTLENUMS 6
1341 /* Turn a string in input_line_pointer into a floating point constant
1342 of type TYPE, and store the appropriate bytes in *LITP. The number
1343 of LITTLENUMS emitted is stored in *SIZEP. An error message is
1344 returned, or NULL on OK. */
1347 md_atof (type, litP, sizeP)
1353 LITTLENUM_TYPE words[MAX_LITTLENUMS];
1354 LITTLENUM_TYPE *wordP;
1386 return _("Bad call to MD_ATOF()");
1388 t = atof_ieee (input_line_pointer, type, words);
1390 input_line_pointer = t;
1392 *sizeP = prec * sizeof (LITTLENUM_TYPE);
1393 for (wordP = words; prec--;)
1395 md_number_to_chars (litP, (long) (*wordP++), sizeof (LITTLENUM_TYPE));
1396 litP += sizeof (LITTLENUM_TYPE);
1401 CONST char *md_shortopts = "";
1402 struct option md_longopts[] = {
1403 {NULL, no_argument, NULL, 0}
1406 size_t md_longopts_size = sizeof (md_longopts);
1409 md_parse_option (c, arg)
1410 int c ATTRIBUTE_UNUSED;
1411 char *arg ATTRIBUTE_UNUSED;
1417 md_show_usage (stream)
1418 FILE *stream ATTRIBUTE_UNUSED;
1423 tc_aout_fix_to_chars ()
1425 printf (_("call to tc_aout_fix_to_chars \n"));
1430 md_convert_frag (headers, seg, fragP)
1431 object_headers *headers ATTRIBUTE_UNUSED;
1432 segT seg ATTRIBUTE_UNUSED;
1433 fragS *fragP ATTRIBUTE_UNUSED;
1435 printf (_("call to md_convert_frag \n"));
1440 md_section_align (seg, size)
1444 return ((size + (1 << section_alignment[(int) seg]) - 1)
1445 & (-1 << section_alignment[(int) seg]));
1449 md_apply_fix (fixP, val)
1453 char *buf = fixP->fx_where + fixP->fx_frag->fr_literal;
1455 switch (fixP->fx_size)
1461 *buf++ = (val >> 8);
1465 *buf++ = (val >> 24);
1466 *buf++ = (val >> 16);
1467 *buf++ = (val >> 8);
1476 md_estimate_size_before_relax (fragP, segment_type)
1477 register fragS *fragP ATTRIBUTE_UNUSED;
1478 register segT segment_type ATTRIBUTE_UNUSED;
1480 printf (_("call tomd_estimate_size_before_relax \n"));
1484 /* Put number into target byte order. */
1486 md_number_to_chars (ptr, use, nbytes)
1491 number_to_chars_bigendian (ptr, use, nbytes);
1495 md_pcrel_from (fixP)
1496 fixS *fixP ATTRIBUTE_UNUSED;
1502 tc_reloc_mangle (fix_ptr, intr, base)
1504 struct internal_reloc *intr;
1508 symbolS *symbol_ptr;
1510 symbol_ptr = fix_ptr->fx_addsy;
1512 /* If this relocation is attached to a symbol then it's ok
1514 if (fix_ptr->fx_r_type == TC_CONS_RELOC)
1516 /* cons likes to create reloc32's whatever the size of the reloc..
1518 switch (fix_ptr->fx_size)
1521 intr->r_type = R_RELLONG;
1524 intr->r_type = R_RELWORD;
1527 intr->r_type = R_RELBYTE;
1535 intr->r_type = fix_ptr->fx_r_type;
1538 intr->r_vaddr = fix_ptr->fx_frag->fr_address + fix_ptr->fx_where + base;
1539 intr->r_offset = fix_ptr->fx_offset;
1543 if (symbol_ptr->sy_number != -1)
1544 intr->r_symndx = symbol_ptr->sy_number;
1549 /* This case arises when a reference is made to `.'. */
1550 segsym = seg_info (S_GET_SEGMENT (symbol_ptr))->dot;
1552 intr->r_symndx = -1;
1555 intr->r_symndx = segsym->sy_number;
1556 intr->r_offset += S_GET_VALUE (symbol_ptr);
1561 intr->r_symndx = -1;