1 /* tc-h8500.c -- Assemble code for the Hitachi H8/500
2 Copyright (C) 1993, 94, 95, 98, 2000 Free Software Foundation.
4 This file is part of GAS, the GNU Assembler.
6 GAS is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GAS is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GAS; see the file COPYING. If not, write to the Free
18 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
21 /* Written By Steve Chamberlain <sac@cygnus.com>. */
28 #define ASSEMBLER_TABLE
29 #include "opcodes/h8500-opc.h"
32 const char comment_chars
[] = "!";
33 const char line_separator_chars
[] = ";";
34 const char line_comment_chars
[] = "!#";
36 /* This table describes all the machine specific pseudo-ops the assembler
37 has to support. The fields are:
38 pseudo-op name without dot
39 function to call to execute this pseudo-op
40 Integer arg to pass to the function
45 const pseudo_typeS md_pseudo_table
[] =
51 {"form", listing_psize
, 0},
52 {"heading", listing_title
, 0},
53 {"import", s_ignore
, 0},
54 {"page", listing_eject
, 0},
55 {"program", s_ignore
, 0},
59 const int md_reloc_size
;
61 const char EXP_CHARS
[] = "eE";
63 /* Chars that mean this number is a floating point constant */
66 const char FLT_CHARS
[] = "rRsSfFdDxXpP";
68 #define C(a,b) ENCODE_RELAX(a,b)
69 #define ENCODE_RELAX(what,length) (((what) << 2) + (length))
71 #define GET_WHAT(x) ((x>>2))
75 #define UNDEF_BYTE_DISP 0
76 #define UNDEF_WORD_DISP 3
88 relax_typeS md_relax_table
[C (END
, 0)];
90 static struct hash_control
*opcode_hash_control
; /* Opcode mnemonics */
93 This function is called once, at assembler startup time. This should
94 set up all the tables, etc. that the MD part of the assembler needs
100 h8500_opcode_info
*opcode
;
101 char prev_buffer
[100];
103 register relax_typeS
*table
;
105 opcode_hash_control
= hash_new ();
108 /* Insert unique names into hash table */
109 for (opcode
= h8500_table
; opcode
->name
; opcode
++)
111 if (idx
!= opcode
->idx
)
113 hash_insert (opcode_hash_control
, opcode
->name
, (char *) opcode
);
118 /* Initialize the relax table. We use a local variable to avoid
119 warnings about modifying a supposedly const data structure. */
120 table
= (relax_typeS
*) md_relax_table
;
121 table
[C (BRANCH
, BYTE_DISP
)].rlx_forward
= BYTE_F
;
122 table
[C (BRANCH
, BYTE_DISP
)].rlx_backward
= BYTE_B
;
123 table
[C (BRANCH
, BYTE_DISP
)].rlx_length
= 2;
124 table
[C (BRANCH
, BYTE_DISP
)].rlx_more
= C (BRANCH
, WORD_DISP
);
126 table
[C (BRANCH
, WORD_DISP
)].rlx_forward
= WORD_F
;
127 table
[C (BRANCH
, WORD_DISP
)].rlx_backward
= WORD_B
;
128 table
[C (BRANCH
, WORD_DISP
)].rlx_length
= 3;
129 table
[C (BRANCH
, WORD_DISP
)].rlx_more
= 0;
131 table
[C (SCB_F
, BYTE_DISP
)].rlx_forward
= BYTE_F
;
132 table
[C (SCB_F
, BYTE_DISP
)].rlx_backward
= BYTE_B
;
133 table
[C (SCB_F
, BYTE_DISP
)].rlx_length
= 3;
134 table
[C (SCB_F
, BYTE_DISP
)].rlx_more
= C (SCB_F
, WORD_DISP
);
136 table
[C (SCB_F
, WORD_DISP
)].rlx_forward
= WORD_F
;
137 table
[C (SCB_F
, WORD_DISP
)].rlx_backward
= WORD_B
;
138 table
[C (SCB_F
, WORD_DISP
)].rlx_length
= 8;
139 table
[C (SCB_F
, WORD_DISP
)].rlx_more
= 0;
141 table
[C (SCB_TST
, BYTE_DISP
)].rlx_forward
= BYTE_F
;
142 table
[C (SCB_TST
, BYTE_DISP
)].rlx_backward
= BYTE_B
;
143 table
[C (SCB_TST
, BYTE_DISP
)].rlx_length
= 3;
144 table
[C (SCB_TST
, BYTE_DISP
)].rlx_more
= C (SCB_TST
, WORD_DISP
);
146 table
[C (SCB_TST
, WORD_DISP
)].rlx_forward
= WORD_F
;
147 table
[C (SCB_TST
, WORD_DISP
)].rlx_backward
= WORD_B
;
148 table
[C (SCB_TST
, WORD_DISP
)].rlx_length
= 10;
149 table
[C (SCB_TST
, WORD_DISP
)].rlx_more
= 0;
153 static int rn
; /* register number used by RN */
154 static int rs
; /* register number used by RS */
155 static int rd
; /* register number used by RD */
156 static int crb
; /* byte size cr */
157 static int crw
; /* word sized cr */
158 static int cr
; /* unknown size cr */
160 static expressionS displacement
;/* displacement expression */
161 static int displacement_size
; /* and size if given */
163 static int immediate_inpage
;
164 static expressionS immediate
; /* immediate expression */
165 static int immediate_size
; /* and size if given */
167 static expressionS absolute
; /* absolute expression */
168 static int absolute_size
; /* and size if given */
180 /* Try to parse a reg name. Return the number of chars consumed. */
183 parse_reg (src
, mode
, reg
)
191 /* Cribbed from get_symbol_end(). */
192 if (!is_name_beginner (*src
) || *src
== '\001')
195 while (is_part_of_name (*end
) || *end
== '\001')
199 if (len
== 2 && src
[0] == 'r')
201 if (src
[1] >= '0' && src
[1] <= '7')
204 *reg
= (src
[1] - '0');
208 if (len
== 2 && src
[0] == 's' && src
[1] == 'p')
214 if (len
== 3 && src
[0] == 'c' && src
[1] == 'c' && src
[2] == 'r')
220 if (len
== 2 && src
[0] == 's' && src
[1] == 'r')
226 if (len
== 2 && src
[0] == 'b' && src
[1] == 'r')
232 if (len
== 2 && src
[0] == 'e' && src
[1] == 'p')
238 if (len
== 2 && src
[0] == 'd' && src
[1] == 'p')
244 if (len
== 2 && src
[0] == 't' && src
[1] == 'p')
250 if (len
== 2 && src
[0] == 'f' && src
[1] == 'p')
260 parse_exp (s
, op
, page
)
268 save
= input_line_pointer
;
273 if (s
[1] == 'p' && s
[2] == 'a' && s
[3] == 'g' && s
[4] == 'e')
278 if (s
[1] == 'h' && s
[2] == 'i' && s
[3] == '1' && s
[4] == '6')
283 else if (s
[1] == 'o' && s
[2] == 'f' && s
[3] == 'f')
290 input_line_pointer
= s
;
293 if (op
->X_op
== O_absent
)
294 as_bad (_("missing operand"));
295 new = input_line_pointer
;
296 input_line_pointer
= save
;
302 exp_signed
, exp_unsigned
, exp_sandu
306 skip_colonthing (sign
, ptr
, exp
, def
, size8
, size16
, size24
)
309 h8500_operand_info
*exp
;
315 ptr
= parse_exp (ptr
, &exp
->exp
, &exp
->page
);
324 else if (ptr
[0] == '1' & ptr
[1] == '6')
329 else if (ptr
[0] == '2' & ptr
[1] == '4')
333 as_bad (_(":24 not valid for this opcode"));
340 as_bad (_("expect :8,:16 or :24"));
346 if (exp
->page
== 'p')
350 else if (exp
->page
== 'h')
356 /* Let's work out the size from the context */
357 int n
= exp
->exp
.X_add_number
;
359 && exp
->exp
.X_op
== O_constant
360 && ((sign
== exp_signed
&& (n
>= -128 && n
<= 127))
361 || (sign
== exp_unsigned
&& (n
>= 0 && (n
<= 255)))
362 || (sign
== exp_sandu
&& (n
>= -128 && (n
<= 255)))))
376 parse_reglist (src
, op
)
378 h8500_operand_info
*op
;
384 int idx
= 1; /* skip ( */
386 while (src
[idx
] && src
[idx
] != ')')
388 int done
= parse_reg (src
+ idx
, &mode
, &rn
);
397 as_bad (_("syntax error in reg list"));
403 done
= parse_reg (src
+ idx
, &mode
, &rm
);
415 as_bad (_("missing final register in range"));
422 op
->exp
.X_add_symbol
= 0;
423 op
->exp
.X_op_symbol
= 0;
424 op
->exp
.X_add_number
= mask
;
425 op
->exp
.X_op
= O_constant
;
426 op
->exp
.X_unsigned
= 1;
432 /* The many forms of operand:
435 @Rn Register indirect
436 @(disp[:size], Rn) Register indirect with displacement
440 #xx[:size] immediate data
445 get_operand (ptr
, op
, ispage
)
447 h8500_operand_info
*op
;
455 if (src
[0] == '(' && src
[1] == 'r')
457 /* This is a register list */
458 *ptr
= src
+ parse_reglist (src
, op
);
462 len
= parse_reg (src
, &op
->type
, &op
->reg
);
476 len
= parse_reg (src
, &mode
, &num
);
479 /* Oops, not a reg after all, must be ordinary exp */
481 /* must be a symbol */
482 *ptr
= skip_colonthing (exp_unsigned
, src
,
483 op
, ABS16
, ABS8
, ABS16
, ABS24
);
497 src
= skip_colonthing (exp_signed
, src
,
498 op
, RNIND_D16
, RNIND_D8
, RNIND_D16
, 0);
502 as_bad (_("expected @(exp, Rn)"));
506 len
= parse_reg (src
, &mode
, &op
->reg
);
507 if (len
== 0 || mode
!= RN
)
509 as_bad (_("expected @(exp, Rn)"));
515 as_bad (_("expected @(exp, Rn)"));
521 len
= parse_reg (src
, &mode
, &num
);
531 as_bad (_("@Rn+ needs word register"));
541 as_bad (_("@Rn needs word register"));
551 /* must be a symbol */
553 skip_colonthing (exp_unsigned
, src
, op
,
554 ispage
? ABS24
: ABS16
, ABS8
, ABS16
, ABS24
);
562 *ptr
= skip_colonthing (exp_sandu
, src
, op
, IMM16
, IMM8
, IMM16
, ABS24
);
567 *ptr
= skip_colonthing (exp_signed
, src
, op
,
568 ispage
? ABS24
: PCREL8
, PCREL8
, PCREL16
, ABS24
);
573 get_operands (info
, args
, operand
)
574 h8500_opcode_info
*info
;
576 h8500_operand_info
*operand
;
590 get_operand (&ptr
, operand
+ 0, info
->name
[0] == 'p');
596 get_operand (&ptr
, operand
+ 0, 0);
599 get_operand (&ptr
, operand
+ 1, 0);
609 /* Passed a pointer to a list of opcodes which use different
610 addressing modes, return the opcode which matches the opcodes
613 int pcrel8
; /* Set when we've seen a pcrel operand */
615 static h8500_opcode_info
*
616 get_specific (opcode
, operands
)
617 h8500_opcode_info
*opcode
;
618 h8500_operand_info
*operands
;
620 h8500_opcode_info
*this_try
= opcode
;
622 unsigned int noperands
= opcode
->nargs
;
624 unsigned 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 */
857 check (operand
, low
, high
)
858 expressionS
*operand
;
862 if (operand
->X_op
!= O_constant
863 || operand
->X_add_number
< low
864 || operand
->X_add_number
> high
)
866 as_bad (_("operand must be absolute in range %d..%d"), low
, high
);
868 return operand
->X_add_number
;
872 insert (output
, index
, exp
, reloc
, pcrel
)
879 fix_new_exp (frag_now
,
880 output
- frag_now
->fr_literal
+ index
,
881 4, /* always say size is 4, but we know better */
888 build_relaxable_instruction (opcode
, operand
)
889 h8500_opcode_info
*opcode
;
890 h8500_operand_info
*operand
;
892 /* All relaxable instructions start life as two bytes but can become
893 three bytes long if a lonely branch and up to 9 bytes if long
899 if (opcode
->bytes
[0].contents
== 0x01)
903 else if (opcode
->bytes
[0].contents
== 0x06
904 || opcode
->bytes
[0].contents
== 0x07)
913 p
= frag_var (rs_machine_dependent
,
914 md_relax_table
[C (type
, WORD_DISP
)].rlx_length
,
915 len
= md_relax_table
[C (type
, BYTE_DISP
)].rlx_length
,
916 C (type
, UNDEF_BYTE_DISP
),
917 displacement
.X_add_symbol
,
918 displacement
.X_add_number
,
921 p
[0] = opcode
->bytes
[0].contents
;
924 p
[1] = opcode
->bytes
[1].contents
| rs
;
928 /* Now we know what sort of opcodes it is, let's build the bytes. */
931 build_bytes (opcode
, operand
)
932 h8500_opcode_info
*opcode
;
933 h8500_operand_info
*operand
;
941 build_relaxable_instruction (opcode
, operand
);
945 char *output
= frag_more (opcode
->length
);
947 memset (output
, 0, opcode
->length
);
948 for (index
= 0; index
< opcode
->length
; index
++)
950 output
[index
] = opcode
->bytes
[index
].contents
;
952 switch (opcode
->bytes
[index
].insert
)
955 printf (_("failed for %d\n"), opcode
->bytes
[index
].insert
);
970 insert (output
, index
, &displacement
, R_H8500_IMM16
, 0);
975 insert (output
, index
, &displacement
, R_H8500_IMM8
, 0);
981 switch (immediate_inpage
)
993 insert (output
, index
, &immediate
, p
, 0);
999 if (immediate_inpage
)
1000 insert (output
, index
, &immediate
, R_H8500_HIGH8
, 0);
1002 insert (output
, index
, &immediate
, R_H8500_IMM8
, 0);
1005 insert (output
, index
, &displacement
, R_H8500_PCREL16
, 1);
1009 insert (output
, index
, &displacement
, R_H8500_PCREL8
, 1);
1012 output
[index
] |= check (&immediate
, 0, 15);
1015 output
[index
] |= cr
;
1022 output
[index
] |= crb
;
1026 output
[index
] |= crw
;
1030 insert (output
, index
, &absolute
, R_H8500_IMM24
, 0);
1034 insert (output
, index
, &absolute
, R_H8500_IMM16
, 0);
1038 insert (output
, index
, &absolute
, R_H8500_IMM8
, 0);
1041 switch (immediate
.X_add_number
)
1044 output
[index
] |= 0x5;
1047 output
[index
] |= 0x4;
1062 /* This is the guts of the machine-dependent assembler. STR points to
1063 a machine dependent instruction. This function is supposed to emit
1064 the frags/bytes it assembles to. */
1072 h8500_operand_info operand
[2];
1073 h8500_opcode_info
*opcode
;
1074 h8500_opcode_info
*prev_opcode
;
1079 /* Drop leading whitespace. */
1083 /* Find the op code end. */
1084 for (op_start
= op_end
= str
;
1085 !is_end_of_line
[(unsigned char) *op_end
] && *op_end
!= ' ';
1088 if ( /**op_end != '.'
1092 name
[nlen
++] = *op_end
;
1097 if (op_end
== op_start
)
1098 as_bad (_("can't find opcode "));
1100 opcode
= (h8500_opcode_info
*) hash_find (opcode_hash_control
, name
);
1104 as_bad (_("unknown opcode"));
1108 get_operands (opcode
, op_end
, operand
);
1109 prev_opcode
= opcode
;
1111 opcode
= get_specific (opcode
, operand
);
1115 /* Couldn't find an opcode which matched the operands */
1116 char *where
= frag_more (2);
1120 as_bad (_("invalid operands for opcode"));
1124 build_bytes (opcode
, operand
);
1128 tc_crawl_symbol_chain (headers
)
1129 object_headers
*headers
;
1131 printf (_("call to tc_crawl_symbol_chain \n"));
1135 md_undefined_symbol (name
)
1142 tc_headers_hook (headers
)
1143 object_headers
*headers
;
1145 printf (_("call to tc_headers_hook \n"));
1148 /* Various routines to kill one day. */
1149 /* Equal to MAX_PRECISION in atof-ieee.c. */
1150 #define MAX_LITTLENUMS 6
1152 /* Turn a string in input_line_pointer into a floating point constant
1153 of type type, and store the appropriate bytes in *LITP. The number
1154 of LITTLENUMS emitted is stored in *SIZEP. An error message is
1155 returned, or NULL on OK. */
1158 md_atof (type
, litP
, sizeP
)
1164 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
1165 LITTLENUM_TYPE
*wordP
;
1197 return _("Bad call to MD_ATOF()");
1199 t
= atof_ieee (input_line_pointer
, type
, words
);
1201 input_line_pointer
= t
;
1203 *sizeP
= prec
* sizeof (LITTLENUM_TYPE
);
1204 for (wordP
= words
; prec
--;)
1206 md_number_to_chars (litP
, (long) (*wordP
++), sizeof (LITTLENUM_TYPE
));
1207 litP
+= sizeof (LITTLENUM_TYPE
);
1212 CONST
char *md_shortopts
= "";
1213 struct option md_longopts
[] = {
1214 {NULL
, no_argument
, NULL
, 0}
1216 size_t md_longopts_size
= sizeof (md_longopts
);
1219 md_parse_option (c
, arg
)
1227 md_show_usage (stream
)
1233 tc_aout_fix_to_chars ()
1235 printf (_("call to tc_aout_fix_to_chars \n"));
1240 wordify_scb (buffer
, disp_size
, inst_size
)
1245 int rn
= buffer
[1] & 0x7;
1249 case 0x0e: /* BSR */
1283 *buffer
++ = 0x26; /* bne + 8 */
1289 *buffer
++ = 0x27; /* bne + 8 */
1294 *buffer
++ = 0xa8 | rn
; /* addq -1,rn */
1296 *buffer
++ = 0x04; /* cmp #0xff:8, rn */
1298 *buffer
++ = 0x70 | rn
;
1299 *buffer
++ = 0x36; /* bne ... */
1304 /* Called after relaxing, change the frags so they know how big they
1308 md_convert_frag (headers
, seg
, fragP
)
1309 object_headers
*headers
;
1315 char *buffer
= fragP
->fr_fix
+ fragP
->fr_literal
;
1317 switch (fragP
->fr_subtype
)
1319 case C (BRANCH
, BYTE_DISP
):
1324 case C (SCB_F
, BYTE_DISP
):
1325 case C (SCB_TST
, BYTE_DISP
):
1330 /* Branches to a known 16 bit displacement. */
1332 /* Turn on the 16bit bit. */
1333 case C (BRANCH
, WORD_DISP
):
1334 case C (SCB_F
, WORD_DISP
):
1335 case C (SCB_TST
, WORD_DISP
):
1336 wordify_scb (buffer
, &disp_size
, &inst_size
);
1339 case C (BRANCH
, UNDEF_WORD_DISP
):
1340 case C (SCB_F
, UNDEF_WORD_DISP
):
1341 case C (SCB_TST
, UNDEF_WORD_DISP
):
1342 /* This tried to be relaxed, but didn't manage it, it now needs
1344 wordify_scb (buffer
, &disp_size
, &inst_size
);
1348 fragP
->fr_fix
+ inst_size
,
1355 fragP
->fr_fix
+= disp_size
+ inst_size
;
1364 /* Get the address of the end of the instruction */
1365 int next_inst
= fragP
->fr_fix
+ fragP
->fr_address
+ disp_size
+ inst_size
;
1366 int targ_addr
= (S_GET_VALUE (fragP
->fr_symbol
) +
1368 int disp
= targ_addr
- next_inst
;
1370 md_number_to_chars (buffer
+ inst_size
, disp
, disp_size
);
1371 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_fix (fixP
, val
)
1391 char *buf
= fixP
->fx_where
+ fixP
->fx_frag
->fr_literal
;
1393 if (fixP
->fx_r_type
== 0)
1395 fixP
->fx_r_type
= fixP
->fx_size
== 4 ? R_H8500_IMM32
: R_H8500_IMM16
;
1398 switch (fixP
->fx_r_type
)
1402 case R_H8500_PCREL8
:
1407 case R_H8500_PCREL16
:
1408 *buf
++ = (val
>> 8);
1414 case R_H8500_HIGH16
:
1419 *buf
++ = (val
>> 16);
1420 *buf
++ = (val
>> 8);
1424 *buf
++ = (val
>> 24);
1425 *buf
++ = (val
>> 16);
1426 *buf
++ = (val
>> 8);
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
;
1444 int what
= GET_WHAT (fragP
->fr_subtype
);
1446 switch (fragP
->fr_subtype
)
1450 case C (BRANCH
, UNDEF_BYTE_DISP
):
1451 case C (SCB_F
, UNDEF_BYTE_DISP
):
1452 case C (SCB_TST
, UNDEF_BYTE_DISP
):
1453 /* used to be a branch to somewhere which was unknown */
1454 if (S_GET_SEGMENT (fragP
->fr_symbol
) == segment_type
)
1456 /* Got a symbol and it's defined in this segment, become byte
1457 sized - maybe it will fix up. */
1458 fragP
->fr_subtype
= C (what
, BYTE_DISP
);
1459 fragP
->fr_var
= md_relax_table
[C (what
, BYTE_DISP
)].rlx_length
;
1463 /* Its got a segment, but its not ours, so it will always be
1465 fragP
->fr_subtype
= C (what
, UNDEF_WORD_DISP
);
1466 fragP
->fr_var
= md_relax_table
[C (what
, WORD_DISP
)].rlx_length
;
1467 return md_relax_table
[C (what
, WORD_DISP
)].rlx_length
;
1470 return fragP
->fr_var
;
1473 /* Put number into target byte order. */
1476 md_number_to_chars (ptr
, use
, nbytes
)
1481 number_to_chars_bigendian (ptr
, use
, nbytes
);
1485 md_pcrel_from (fixP
)
1488 return fixP
->fx_size
+ fixP
->fx_where
+ fixP
->fx_frag
->fr_address
;
1492 tc_coff_symbol_emit_hook (ignore
)
1498 tc_coff_fix2rtype (fix_ptr
)
1501 if (fix_ptr
->fx_r_type
== RELOC_32
)
1503 /* cons likes to create reloc32's whatever the size of the reloc..
1505 switch (fix_ptr
->fx_size
)
1508 return R_H8500_IMM16
;
1511 return R_H8500_IMM8
;
1517 return fix_ptr
->fx_r_type
;
1521 tc_reloc_mangle (fix_ptr
, intr
, base
)
1523 struct internal_reloc
*intr
;
1527 symbolS
*symbol_ptr
;
1529 symbol_ptr
= fix_ptr
->fx_addsy
;
1531 /* If this relocation is attached to a symbol then it's ok
1533 if (fix_ptr
->fx_r_type
== RELOC_32
)
1535 /* cons likes to create reloc32's whatever the size of the reloc..
1537 switch (fix_ptr
->fx_size
)
1540 intr
->r_type
= R_IMM16
;
1543 intr
->r_type
= R_IMM8
;
1551 intr
->r_type
= fix_ptr
->fx_r_type
;
1554 intr
->r_vaddr
= fix_ptr
->fx_frag
->fr_address
+ fix_ptr
->fx_where
+ base
;
1555 intr
->r_offset
= fix_ptr
->fx_offset
;
1557 /* Turn the segment of the symbol into an offset. */
1562 dot
= segment_info
[S_GET_SEGMENT (symbol_ptr
)].dot
;
1567 segment_info
[S_GET_SEGMENT (symbol_ptr
)].scnhdr
.s_paddr
;
1569 intr
->r_offset
+= S_GET_VALUE (symbol_ptr
);
1570 intr
->r_symndx
= dot
->sy_number
;
1574 intr
->r_symndx
= symbol_ptr
->sy_number
;
1580 intr
->r_symndx
= -1;
1589 /* Check for :s.w */
1590 if (isalpha (ptr
[1]) && ptr
[2] == '.')
1593 if (isalpha (ptr
[1]) && !isalpha (ptr
[2]))
1599 tc_coff_sizemachdep (frag
)
1602 return md_relax_table
[frag
->fr_subtype
].rlx_length
;