1 /* tc-h8500.c -- Assemble code for the Renesas H8/500
2 Copyright 1993, 1994, 1995, 1998, 2000, 2001, 2002, 2003
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 ASSEMBLER_TABLE
30 #include "opcodes/h8500-opc.h"
31 #include "safe-ctype.h"
33 const char comment_chars
[] = "!";
34 const char line_separator_chars
[] = ";";
35 const char line_comment_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
44 const pseudo_typeS md_pseudo_table
[] =
50 {"form", listing_psize
, 0},
51 {"heading", listing_title
, 0},
52 {"import", s_ignore
, 0},
53 {"page", listing_eject
, 0},
54 {"program", s_ignore
, 0},
58 const int md_reloc_size
;
60 const char EXP_CHARS
[] = "eE";
62 /* Chars that mean this number is a floating point constant */
65 const char FLT_CHARS
[] = "rRsSfFdDxXpP";
67 #define C(a,b) ENCODE_RELAX(a,b)
68 #define ENCODE_RELAX(what,length) (((what) << 2) + (length))
70 #define GET_WHAT(x) ((x>>2))
74 #define UNDEF_BYTE_DISP 0
75 #define UNDEF_WORD_DISP 3
87 relax_typeS md_relax_table
[C (END
, 0)] = {
95 { BYTE_F
, BYTE_B
, 2, C (BRANCH
, WORD_DISP
) },
96 { WORD_F
, WORD_B
, 3, 0 },
101 { BYTE_F
, BYTE_B
, 3, C (SCB_F
, WORD_DISP
) },
102 { WORD_F
, WORD_B
, 8, 0 },
107 { BYTE_F
, BYTE_B
, 3, C (SCB_TST
, WORD_DISP
) },
108 { WORD_F
, WORD_B
, 10, 0 },
113 static struct hash_control
*opcode_hash_control
; /* Opcode mnemonics */
116 This function is called once, at assembler startup time. This should
117 set up all the tables, etc. that the MD part of the assembler needs
123 const h8500_opcode_info
*opcode
;
124 char prev_buffer
[100];
127 opcode_hash_control
= hash_new ();
130 /* Insert unique names into hash table */
131 for (opcode
= h8500_table
; opcode
->name
; opcode
++)
133 if (idx
!= opcode
->idx
)
135 hash_insert (opcode_hash_control
, opcode
->name
, (char *) opcode
);
141 static int rn
; /* register number used by RN */
142 static int rs
; /* register number used by RS */
143 static int rd
; /* register number used by RD */
144 static int crb
; /* byte size cr */
145 static int crw
; /* word sized cr */
146 static int cr
; /* unknown size cr */
148 static expressionS displacement
;/* displacement expression */
150 static int immediate_inpage
;
151 static expressionS immediate
; /* immediate expression */
153 static expressionS absolute
; /* absolute expression */
165 /* Try to parse a reg name. Return the number of chars consumed. */
167 static int parse_reg
PARAMS ((char *, int *, int *));
170 parse_reg (src
, mode
, reg
)
178 /* Cribbed from get_symbol_end(). */
179 if (!is_name_beginner (*src
) || *src
== '\001')
182 while (is_part_of_name (*end
) || *end
== '\001')
186 if (len
== 2 && src
[0] == 'r')
188 if (src
[1] >= '0' && src
[1] <= '7')
191 *reg
= (src
[1] - '0');
195 if (len
== 2 && src
[0] == 's' && src
[1] == 'p')
201 if (len
== 3 && src
[0] == 'c' && src
[1] == 'c' && src
[2] == 'r')
207 if (len
== 2 && src
[0] == 's' && src
[1] == 'r')
213 if (len
== 2 && src
[0] == 'b' && src
[1] == 'r')
219 if (len
== 2 && src
[0] == 'e' && src
[1] == 'p')
225 if (len
== 2 && src
[0] == 'd' && src
[1] == 'p')
231 if (len
== 2 && src
[0] == 't' && src
[1] == 'p')
237 if (len
== 2 && src
[0] == 'f' && src
[1] == 'p')
246 static char *parse_exp
PARAMS ((char *, expressionS
*, int *));
249 parse_exp (s
, op
, page
)
257 save
= input_line_pointer
;
262 if (s
[1] == 'p' && s
[2] == 'a' && s
[3] == 'g' && s
[4] == 'e')
267 if (s
[1] == 'h' && s
[2] == 'i' && s
[3] == '1' && s
[4] == '6')
272 else if (s
[1] == 'o' && s
[2] == 'f' && s
[3] == 'f')
279 input_line_pointer
= s
;
282 if (op
->X_op
== O_absent
)
283 as_bad (_("missing operand"));
284 new = input_line_pointer
;
285 input_line_pointer
= save
;
291 exp_signed
, exp_unsigned
, exp_sandu
294 static char *skip_colonthing
295 PARAMS ((sign_type
, char *, h8500_operand_info
*, int, int, int, int));
298 skip_colonthing (sign
, ptr
, exp
, def
, size8
, size16
, size24
)
301 h8500_operand_info
*exp
;
307 ptr
= parse_exp (ptr
, &exp
->exp
, &exp
->page
);
316 else if (ptr
[0] == '1' && ptr
[1] == '6')
321 else if (ptr
[0] == '2' && ptr
[1] == '4')
325 as_bad (_(":24 not valid for this opcode"));
332 as_bad (_("expect :8,:16 or :24"));
338 if (exp
->page
== 'p')
342 else if (exp
->page
== 'h')
348 /* Let's work out the size from the context */
349 int n
= exp
->exp
.X_add_number
;
351 && exp
->exp
.X_op
== O_constant
352 && ((sign
== exp_signed
&& (n
>= -128 && n
<= 127))
353 || (sign
== exp_unsigned
&& (n
>= 0 && (n
<= 255)))
354 || (sign
== exp_sandu
&& (n
>= -128 && (n
<= 255)))))
367 static int parse_reglist
PARAMS ((char *, h8500_operand_info
*));
370 parse_reglist (src
, op
)
372 h8500_operand_info
*op
;
378 int idx
= 1; /* skip ( */
380 while (src
[idx
] && src
[idx
] != ')')
382 int done
= parse_reg (src
+ idx
, &mode
, &rn
);
391 as_bad (_("syntax error in reg list"));
397 done
= parse_reg (src
+ idx
, &mode
, &rm
);
409 as_bad (_("missing final register in range"));
416 op
->exp
.X_add_symbol
= 0;
417 op
->exp
.X_op_symbol
= 0;
418 op
->exp
.X_add_number
= mask
;
419 op
->exp
.X_op
= O_constant
;
420 op
->exp
.X_unsigned
= 1;
426 /* The many forms of operand:
429 @Rn Register indirect
430 @(disp[:size], Rn) Register indirect with displacement
434 #xx[:size] immediate data
438 static void get_operand
PARAMS ((char **, h8500_operand_info
*, char));
441 get_operand (ptr
, op
, ispage
)
443 h8500_operand_info
*op
;
451 if (src
[0] == '(' && src
[1] == 'r')
453 /* This is a register list */
454 *ptr
= src
+ parse_reglist (src
, op
);
458 len
= parse_reg (src
, &op
->type
, &op
->reg
);
472 len
= parse_reg (src
, &mode
, &num
);
475 /* Oops, not a reg after all, must be ordinary exp */
477 /* must be a symbol */
478 *ptr
= skip_colonthing (exp_unsigned
, src
,
479 op
, ABS16
, ABS8
, ABS16
, ABS24
);
493 src
= skip_colonthing (exp_signed
, src
,
494 op
, RNIND_D16
, RNIND_D8
, RNIND_D16
, 0);
498 as_bad (_("expected @(exp, Rn)"));
502 len
= parse_reg (src
, &mode
, &op
->reg
);
503 if (len
== 0 || mode
!= RN
)
505 as_bad (_("expected @(exp, Rn)"));
511 as_bad (_("expected @(exp, Rn)"));
517 len
= parse_reg (src
, &mode
, &num
);
527 as_bad (_("@Rn+ needs word register"));
537 as_bad (_("@Rn needs word register"));
547 /* must be a symbol */
549 skip_colonthing (exp_unsigned
, src
, op
,
550 ispage
? ABS24
: ABS16
, ABS8
, ABS16
, ABS24
);
558 *ptr
= skip_colonthing (exp_sandu
, src
, op
, IMM16
, IMM8
, IMM16
, ABS24
);
563 *ptr
= skip_colonthing (exp_signed
, src
, op
,
564 ispage
? ABS24
: PCREL8
, PCREL8
, PCREL16
, ABS24
);
568 static char *get_operands
569 PARAMS ((h8500_opcode_info
*, char *, h8500_operand_info
*));
572 get_operands (info
, args
, operand
)
573 h8500_opcode_info
*info
;
575 h8500_operand_info
*operand
;
588 get_operand (&ptr
, operand
+ 0, info
->name
[0] == 'p');
594 get_operand (&ptr
, operand
+ 0, 0);
597 get_operand (&ptr
, operand
+ 1, 0);
607 /* Passed a pointer to a list of opcodes which use different
608 addressing modes, return the opcode which matches the opcodes
611 int pcrel8
; /* Set when we've seen a pcrel operand */
613 static h8500_opcode_info
*get_specific
614 PARAMS ((h8500_opcode_info
*, h8500_operand_info
*));
616 static h8500_opcode_info
*
617 get_specific (opcode
, operands
)
618 h8500_opcode_info
*opcode
;
619 h8500_operand_info
*operands
;
621 h8500_opcode_info
*this_try
= opcode
;
623 unsigned int noperands
= opcode
->nargs
;
624 int this_index
= opcode
->idx
;
626 while (this_index
== opcode
->idx
&& !found
)
632 /* look at both operands needed by the opcodes and provided by
634 for (i
= 0; i
< noperands
; i
++)
636 h8500_operand_info
*user
= operands
+ i
;
638 switch (this_try
->arg_type
[i
])
641 /* Opcode needs (disp:8,fp) */
642 if (user
->type
== RNIND_D8
&& user
->reg
== 6)
644 displacement
= user
->exp
;
649 if (user
->type
== RNIND_D16
)
651 displacement
= user
->exp
;
657 if (user
->type
== RNIND_D8
)
659 displacement
= user
->exp
;
666 if (user
->type
== this_try
->arg_type
[i
])
668 displacement
= user
->exp
;
675 if (user
->type
== RNDEC
&& user
->reg
== 7)
681 if (user
->type
== RNINC
&& user
->reg
== 7)
687 if (user
->type
== ABS16
)
689 absolute
= user
->exp
;
694 if (user
->type
== ABS8
)
696 absolute
= user
->exp
;
701 if (user
->type
== ABS24
)
703 absolute
= user
->exp
;
709 if ((user
->type
== CRB
|| user
->type
== CR
) && user
->reg
!= 0)
716 if ((user
->type
== CRW
|| user
->type
== CR
) && user
->reg
== 0)
723 if (user
->type
== DISP16
)
725 displacement
= user
->exp
;
730 if (user
->type
== DISP8
)
732 displacement
= user
->exp
;
737 if (user
->type
== RN
&& user
->reg
== 6)
743 if (user
->type
== PCREL16
)
745 displacement
= user
->exp
;
750 if (user
->type
== PCREL8
)
752 displacement
= user
->exp
;
759 if (user
->type
== IMM16
760 || user
->type
== IMM8
)
762 immediate_inpage
= user
->page
;
763 immediate
= user
->exp
;
769 if (user
->type
== IMM8
)
771 immediate_inpage
= user
->page
;
772 immediate
= user
->exp
;
777 if (user
->type
== IMM8
)
779 immediate_inpage
= user
->page
;
780 immediate
= user
->exp
;
785 if (user
->type
== IMM8
786 && user
->exp
.X_op
== O_constant
788 (user
->exp
.X_add_number
== -2
789 || user
->exp
.X_add_number
== -1
790 || user
->exp
.X_add_number
== 1
791 || user
->exp
.X_add_number
== 2))
793 immediate_inpage
= user
->page
;
794 immediate
= user
->exp
;
799 if (user
->type
== RN
)
806 if (user
->type
== RN
)
813 if (user
->type
== RNIND
)
825 if (user
->type
== this_try
->arg_type
[i
])
832 if (user
->type
== RN
&& user
->reg
== 7)
838 printf (_("unhandled %d\n"), this_try
->arg_type
[i
]);
842 /* If we get here this didn't work out */
856 static int check
PARAMS ((expressionS
*, int, int));
859 check (operand
, low
, high
)
860 expressionS
*operand
;
864 if (operand
->X_op
!= O_constant
865 || operand
->X_add_number
< low
866 || operand
->X_add_number
> high
)
868 as_bad (_("operand must be absolute in range %d..%d"), low
, high
);
870 return operand
->X_add_number
;
873 static void insert
PARAMS ((char *, int, expressionS
*, int, int));
876 insert (output
, index
, exp
, reloc
, pcrel
)
883 fix_new_exp (frag_now
,
884 output
- frag_now
->fr_literal
+ index
,
885 4, /* always say size is 4, but we know better */
891 static void build_relaxable_instruction
892 PARAMS ((h8500_opcode_info
*, h8500_operand_info
*));
895 build_relaxable_instruction (opcode
, operand
)
896 h8500_opcode_info
*opcode
;
897 h8500_operand_info
*operand ATTRIBUTE_UNUSED
;
899 /* All relaxable instructions start life as two bytes but can become
900 three bytes long if a lonely branch and up to 9 bytes if long
906 if (opcode
->bytes
[0].contents
== 0x01)
910 else if (opcode
->bytes
[0].contents
== 0x06
911 || opcode
->bytes
[0].contents
== 0x07)
920 p
= frag_var (rs_machine_dependent
,
921 md_relax_table
[C (type
, WORD_DISP
)].rlx_length
,
922 len
= md_relax_table
[C (type
, BYTE_DISP
)].rlx_length
,
923 C (type
, UNDEF_BYTE_DISP
),
924 displacement
.X_add_symbol
,
925 displacement
.X_add_number
,
928 p
[0] = opcode
->bytes
[0].contents
;
931 p
[1] = opcode
->bytes
[1].contents
| rs
;
935 /* Now we know what sort of opcodes it is, let's build the bytes. */
937 static void build_bytes
PARAMS ((h8500_opcode_info
*, h8500_operand_info
*));
940 build_bytes (opcode
, operand
)
941 h8500_opcode_info
*opcode
;
942 h8500_operand_info
*operand
;
949 build_relaxable_instruction (opcode
, operand
);
953 char *output
= frag_more (opcode
->length
);
955 memset (output
, 0, opcode
->length
);
956 for (index
= 0; index
< opcode
->length
; index
++)
958 output
[index
] = opcode
->bytes
[index
].contents
;
960 switch (opcode
->bytes
[index
].insert
)
963 printf (_("failed for %d\n"), opcode
->bytes
[index
].insert
);
978 insert (output
, index
, &displacement
, R_H8500_IMM16
, 0);
983 insert (output
, index
, &displacement
, R_H8500_IMM8
, 0);
989 switch (immediate_inpage
)
1001 insert (output
, index
, &immediate
, p
, 0);
1007 if (immediate_inpage
)
1008 insert (output
, index
, &immediate
, R_H8500_HIGH8
, 0);
1010 insert (output
, index
, &immediate
, R_H8500_IMM8
, 0);
1013 insert (output
, index
, &displacement
, R_H8500_PCREL16
, 1);
1017 insert (output
, index
, &displacement
, R_H8500_PCREL8
, 1);
1020 output
[index
] |= check (&immediate
, 0, 15);
1023 output
[index
] |= cr
;
1030 output
[index
] |= crb
;
1034 output
[index
] |= crw
;
1038 insert (output
, index
, &absolute
, R_H8500_IMM24
, 0);
1042 insert (output
, index
, &absolute
, R_H8500_IMM16
, 0);
1046 insert (output
, index
, &absolute
, R_H8500_IMM8
, 0);
1049 switch (immediate
.X_add_number
)
1052 output
[index
] |= 0x5;
1055 output
[index
] |= 0x4;
1070 /* This is the guts of the machine-dependent assembler. STR points to
1071 a machine dependent instruction. This function is supposed to emit
1072 the frags/bytes it assembles to. */
1080 h8500_operand_info operand
[2];
1081 h8500_opcode_info
*opcode
;
1082 h8500_opcode_info
*prev_opcode
;
1087 /* Drop leading whitespace. */
1091 /* Find the op code end. */
1092 for (op_start
= op_end
= str
;
1093 !is_end_of_line
[(unsigned char) *op_end
] && *op_end
!= ' ';
1096 if ( /**op_end != '.'
1100 name
[nlen
++] = *op_end
;
1105 if (op_end
== op_start
)
1106 as_bad (_("can't find opcode "));
1108 opcode
= (h8500_opcode_info
*) hash_find (opcode_hash_control
, name
);
1112 as_bad (_("unknown opcode"));
1116 get_operands (opcode
, op_end
, operand
);
1117 prev_opcode
= opcode
;
1119 opcode
= get_specific (opcode
, operand
);
1123 /* Couldn't find an opcode which matched the operands */
1124 char *where
= frag_more (2);
1128 as_bad (_("invalid operands for opcode"));
1132 build_bytes (opcode
, operand
);
1136 tc_crawl_symbol_chain (headers
)
1137 object_headers
*headers ATTRIBUTE_UNUSED
;
1139 printf (_("call to tc_crawl_symbol_chain \n"));
1143 md_undefined_symbol (name
)
1144 char *name ATTRIBUTE_UNUSED
;
1150 tc_headers_hook (headers
)
1151 object_headers
*headers ATTRIBUTE_UNUSED
;
1153 printf (_("call to tc_headers_hook \n"));
1156 /* Various routines to kill one day. */
1157 /* Equal to MAX_PRECISION in atof-ieee.c. */
1158 #define MAX_LITTLENUMS 6
1160 /* Turn a string in input_line_pointer into a floating point constant
1161 of type type, and store the appropriate bytes in *LITP. The number
1162 of LITTLENUMS emitted is stored in *SIZEP. An error message is
1163 returned, or NULL on OK. */
1166 md_atof (type
, litP
, sizeP
)
1172 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
1173 LITTLENUM_TYPE
*wordP
;
1204 return _("Bad call to MD_ATOF()");
1206 t
= atof_ieee (input_line_pointer
, type
, words
);
1208 input_line_pointer
= t
;
1210 *sizeP
= prec
* sizeof (LITTLENUM_TYPE
);
1211 for (wordP
= words
; prec
--;)
1213 md_number_to_chars (litP
, (long) (*wordP
++), sizeof (LITTLENUM_TYPE
));
1214 litP
+= sizeof (LITTLENUM_TYPE
);
1219 const char *md_shortopts
= "";
1220 struct option md_longopts
[] = {
1221 {NULL
, no_argument
, NULL
, 0}
1223 size_t md_longopts_size
= sizeof (md_longopts
);
1226 md_parse_option (c
, arg
)
1227 int c ATTRIBUTE_UNUSED
;
1228 char *arg ATTRIBUTE_UNUSED
;
1234 md_show_usage (stream
)
1235 FILE *stream ATTRIBUTE_UNUSED
;
1239 static void wordify_scb
PARAMS ((char *, int *, int *));
1242 wordify_scb (buffer
, disp_size
, inst_size
)
1247 int rn
= buffer
[1] & 0x7;
1251 case 0x0e: /* BSR */
1285 *buffer
++ = 0x26; /* bne + 8 */
1291 *buffer
++ = 0x27; /* bne + 8 */
1296 *buffer
++ = 0xa8 | rn
; /* addq -1,rn */
1298 *buffer
++ = 0x04; /* cmp #0xff:8, rn */
1300 *buffer
++ = 0x70 | rn
;
1301 *buffer
++ = 0x36; /* bne ... */
1306 /* Called after relaxing, change the frags so they know how big they
1310 md_convert_frag (headers
, seg
, fragP
)
1311 object_headers
*headers ATTRIBUTE_UNUSED
;
1312 segT seg ATTRIBUTE_UNUSED
;
1317 char *buffer
= fragP
->fr_fix
+ fragP
->fr_literal
;
1319 switch (fragP
->fr_subtype
)
1321 case C (BRANCH
, BYTE_DISP
):
1326 case C (SCB_F
, BYTE_DISP
):
1327 case C (SCB_TST
, BYTE_DISP
):
1332 /* Branches to a known 16 bit displacement. */
1334 /* Turn on the 16bit bit. */
1335 case C (BRANCH
, WORD_DISP
):
1336 case C (SCB_F
, WORD_DISP
):
1337 case C (SCB_TST
, WORD_DISP
):
1338 wordify_scb (buffer
, &disp_size
, &inst_size
);
1341 case C (BRANCH
, UNDEF_WORD_DISP
):
1342 case C (SCB_F
, UNDEF_WORD_DISP
):
1343 case C (SCB_TST
, UNDEF_WORD_DISP
):
1344 /* This tried to be relaxed, but didn't manage it, it now needs
1346 wordify_scb (buffer
, &disp_size
, &inst_size
);
1350 fragP
->fr_fix
+ inst_size
,
1357 fragP
->fr_fix
+= disp_size
+ inst_size
;
1365 /* Get the address of the end of the instruction */
1366 int next_inst
= fragP
->fr_fix
+ fragP
->fr_address
+ disp_size
+ inst_size
;
1367 int targ_addr
= (S_GET_VALUE (fragP
->fr_symbol
) +
1369 int disp
= targ_addr
- next_inst
;
1371 md_number_to_chars (buffer
+ inst_size
, disp
, disp_size
);
1372 fragP
->fr_fix
+= disp_size
+ inst_size
;
1377 md_section_align (seg
, size
)
1381 return ((size
+ (1 << section_alignment
[(int) seg
]) - 1)
1382 & (-1 << section_alignment
[(int) seg
]));
1387 md_apply_fix3 (fixP
, valP
, seg
)
1390 segT seg ATTRIBUTE_UNUSED
;
1392 long val
= * (long *) valP
;
1393 char *buf
= fixP
->fx_where
+ fixP
->fx_frag
->fr_literal
;
1395 if (fixP
->fx_r_type
== 0)
1396 fixP
->fx_r_type
= fixP
->fx_size
== 4 ? R_H8500_IMM32
: R_H8500_IMM16
;
1398 switch (fixP
->fx_r_type
)
1401 case R_H8500_PCREL8
:
1406 case R_H8500_PCREL16
:
1407 *buf
++ = (val
>> 8);
1413 case R_H8500_HIGH16
:
1418 *buf
++ = (val
>> 16);
1419 *buf
++ = (val
>> 8);
1423 *buf
++ = (val
>> 24);
1424 *buf
++ = (val
>> 16);
1425 *buf
++ = (val
>> 8);
1432 if (fixP
->fx_addsy
== NULL
&& fixP
->fx_pcrel
== 0)
1436 /* Called just before address relaxation, return the length
1437 by which a fragment must grow to reach it's destination. */
1440 md_estimate_size_before_relax (fragP
, segment_type
)
1441 register fragS
*fragP
;
1442 register segT segment_type
;
1446 switch (fragP
->fr_subtype
)
1451 case C (BRANCH
, UNDEF_BYTE_DISP
):
1452 case C (SCB_F
, UNDEF_BYTE_DISP
):
1453 case C (SCB_TST
, UNDEF_BYTE_DISP
):
1454 what
= GET_WHAT (fragP
->fr_subtype
);
1455 /* used to be a branch to somewhere which was unknown */
1456 if (S_GET_SEGMENT (fragP
->fr_symbol
) == segment_type
)
1458 /* Got a symbol and it's defined in this segment, become byte
1459 sized - maybe it will fix up. */
1460 fragP
->fr_subtype
= C (what
, BYTE_DISP
);
1464 /* Its got a segment, but its not ours, so it will always be
1466 fragP
->fr_subtype
= C (what
, UNDEF_WORD_DISP
);
1470 case C (BRANCH
, BYTE_DISP
):
1471 case C (BRANCH
, WORD_DISP
):
1472 case C (BRANCH
, UNDEF_WORD_DISP
):
1473 case C (SCB_F
, BYTE_DISP
):
1474 case C (SCB_F
, WORD_DISP
):
1475 case C (SCB_F
, UNDEF_WORD_DISP
):
1476 case C (SCB_TST
, BYTE_DISP
):
1477 case C (SCB_TST
, WORD_DISP
):
1478 case C (SCB_TST
, UNDEF_WORD_DISP
):
1479 /* When relaxing a section for the second time, we don't need to
1480 do anything besides return the current size. */
1484 return md_relax_table
[fragP
->fr_subtype
].rlx_length
;
1487 /* Put number into target byte order. */
1490 md_number_to_chars (ptr
, use
, nbytes
)
1495 number_to_chars_bigendian (ptr
, use
, nbytes
);
1499 md_pcrel_from (fixP
)
1502 return fixP
->fx_size
+ fixP
->fx_where
+ fixP
->fx_frag
->fr_address
;
1506 tc_coff_symbol_emit_hook (ignore
)
1507 symbolS
*ignore ATTRIBUTE_UNUSED
;
1512 tc_coff_fix2rtype (fix_ptr
)
1515 if (fix_ptr
->fx_r_type
== RELOC_32
)
1517 /* cons likes to create reloc32's whatever the size of the reloc..
1519 switch (fix_ptr
->fx_size
)
1522 return R_H8500_IMM16
;
1525 return R_H8500_IMM8
;
1531 return fix_ptr
->fx_r_type
;
1535 tc_reloc_mangle (fix_ptr
, intr
, base
)
1537 struct internal_reloc
*intr
;
1541 symbolS
*symbol_ptr
;
1543 symbol_ptr
= fix_ptr
->fx_addsy
;
1545 /* If this relocation is attached to a symbol then it's ok
1547 if (fix_ptr
->fx_r_type
== RELOC_32
)
1549 /* cons likes to create reloc32's whatever the size of the reloc..
1551 switch (fix_ptr
->fx_size
)
1554 intr
->r_type
= R_IMM16
;
1557 intr
->r_type
= R_IMM8
;
1565 intr
->r_type
= fix_ptr
->fx_r_type
;
1568 intr
->r_vaddr
= fix_ptr
->fx_frag
->fr_address
+ fix_ptr
->fx_where
+ base
;
1569 intr
->r_offset
= fix_ptr
->fx_offset
;
1571 /* Turn the segment of the symbol into an offset. */
1576 dot
= segment_info
[S_GET_SEGMENT (symbol_ptr
)].dot
;
1581 segment_info
[S_GET_SEGMENT (symbol_ptr
)].scnhdr
.s_paddr
;
1583 intr
->r_offset
+= S_GET_VALUE (symbol_ptr
);
1584 intr
->r_symndx
= dot
->sy_number
;
1588 intr
->r_symndx
= symbol_ptr
->sy_number
;
1594 intr
->r_symndx
= -1;
1603 /* Check for :s.w */
1604 if (ISALPHA (ptr
[1]) && ptr
[2] == '.')
1607 if (ISALPHA (ptr
[1]) && !ISALPHA (ptr
[2]))
1613 tc_coff_sizemachdep (frag
)
1616 return md_relax_table
[frag
->fr_subtype
].rlx_length
;