1 /* tc-h8500.c -- Assemble code for the Hitachi H8/500
2 Copyright (C) 1993 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
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
21 Written By Steve Chamberlain
30 #define ASSEMBLER_TABLE
31 #include "../opcodes/h8500-opc.h"
34 const char comment_chars
[] = "!";
35 const char line_separator_chars
[] = ";";
36 const char line_comment_chars
[] = "!";
38 /* This table describes all the machine specific pseudo-ops the assembler
39 has to support. The fields are:
40 pseudo-op name without dot
41 function to call to execute this pseudo-op
42 Integer arg to pass to the function
47 const pseudo_typeS md_pseudo_table
[] =
53 {"form", listing_psize
, 0},
54 {"heading", listing_title
, 0},
55 {"import", s_ignore
, 0},
56 {"page", listing_eject
, 0},
57 {"program", s_ignore
, 0},
61 const int md_reloc_size
;
63 const char EXP_CHARS
[] = "eE";
65 /* Chars that mean this number is a floating point constant */
68 const char FLT_CHARS
[] = "rRsSfFdDxXpP";
70 #define C(a,b) ENCODE_RELAX(a,b)
71 #define ENCODE_RELAX(what,length) (((what) << 2) + (length))
73 #define GET_WHAT(x) ((x>>2))
77 #define UNDEF_BYTE_DISP 0
78 #define UNDEF_WORD_DISP 3
90 const relax_typeS md_relax_table
[C (END
, 0)];
92 static struct hash_control
*opcode_hash_control
; /* Opcode mnemonics */
95 This function is called once, at assembler startup time. This should
96 set up all the tables, etc that the MD part of the assembler needs
102 h8500_opcode_info
*opcode
;
103 char prev_buffer
[100];
106 opcode_hash_control
= hash_new ();
109 /* Insert unique names into hash table */
110 for (opcode
= h8500_table
; opcode
->name
; opcode
++)
112 if (idx
!= opcode
->idx
)
114 hash_insert (opcode_hash_control
, opcode
->name
, (char *) opcode
);
119 /* Initialize the relax table */
120 md_relax_table
[C (BRANCH
, BYTE_DISP
)].rlx_forward
= BYTE_F
;
121 md_relax_table
[C (BRANCH
, BYTE_DISP
)].rlx_backward
= BYTE_B
;
122 md_relax_table
[C (BRANCH
, BYTE_DISP
)].rlx_length
= 2;
123 md_relax_table
[C (BRANCH
, BYTE_DISP
)].rlx_more
= C (BRANCH
, WORD_DISP
);
125 md_relax_table
[C (BRANCH
, WORD_DISP
)].rlx_forward
= WORD_F
;
126 md_relax_table
[C (BRANCH
, WORD_DISP
)].rlx_backward
= WORD_B
;
127 md_relax_table
[C (BRANCH
, WORD_DISP
)].rlx_length
= 3;
128 md_relax_table
[C (BRANCH
, WORD_DISP
)].rlx_more
= 0;
130 md_relax_table
[C (SCB_F
, BYTE_DISP
)].rlx_forward
= BYTE_F
;
131 md_relax_table
[C (SCB_F
, BYTE_DISP
)].rlx_backward
= BYTE_B
;
132 md_relax_table
[C (SCB_F
, BYTE_DISP
)].rlx_length
= 3;
133 md_relax_table
[C (SCB_F
, BYTE_DISP
)].rlx_more
= C (SCB_F
, WORD_DISP
);
135 md_relax_table
[C (SCB_F
, WORD_DISP
)].rlx_forward
= WORD_F
;
136 md_relax_table
[C (SCB_F
, WORD_DISP
)].rlx_backward
= WORD_B
;
137 md_relax_table
[C (SCB_F
, WORD_DISP
)].rlx_length
= 8;
138 md_relax_table
[C (SCB_F
, WORD_DISP
)].rlx_more
= 0;
140 md_relax_table
[C (SCB_TST
, BYTE_DISP
)].rlx_forward
= BYTE_F
;
141 md_relax_table
[C (SCB_TST
, BYTE_DISP
)].rlx_backward
= BYTE_B
;
142 md_relax_table
[C (SCB_TST
, BYTE_DISP
)].rlx_length
= 3;
143 md_relax_table
[C (SCB_TST
, BYTE_DISP
)].rlx_more
= C (SCB_TST
, WORD_DISP
);
145 md_relax_table
[C (SCB_TST
, WORD_DISP
)].rlx_forward
= WORD_F
;
146 md_relax_table
[C (SCB_TST
, WORD_DISP
)].rlx_backward
= WORD_B
;
147 md_relax_table
[C (SCB_TST
, WORD_DISP
)].rlx_length
= 10;
148 md_relax_table
[C (SCB_TST
, WORD_DISP
)].rlx_more
= 0;
152 static int rn
; /* register number used by RN */
153 static int rs
; /* register number used by RS */
154 static int rd
; /* register number used by RD */
155 static int crb
; /* byte size cr */
156 static int crw
; /* word sized cr */
157 static int cr
; /* unknown size cr */
159 static expressionS displacement
;/* displacement expression */
160 static int displacement_size
; /* and size if given */
162 static int immediate_inpage
;
163 static expressionS immediate
; /* immediate expression */
164 static int immediate_size
; /* and size if given */
166 static expressionS absolute
; /* absolute expression */
167 static int absolute_size
; /* and size if given */
179 /* try and parse a reg name, returns number of chars consumed */
181 parse_reg (src
, mode
, reg
)
188 if (src
[1] >= '0' && src
[1] <= '7')
191 *reg
= (src
[1] - '0');
196 if (src
[0] == 's' && src
[1] == 'p')
202 if (src
[0] == 'c' && src
[1] == 'c' && src
[2] == 'r')
208 if (src
[0] == 's' && src
[1] == 'r')
215 if (src
[0] == 'b' && src
[1] == 'r')
222 if (src
[0] == 'e' && src
[1] == 'p')
229 if (src
[0] == 'd' && src
[1] == 'p')
236 if (src
[0] == 't' && src
[1] == 'p')
243 if (src
[0] == 'f' && src
[1] == 'p')
254 parse_exp (s
, op
, page
)
263 save
= input_line_pointer
;
268 if (s
[1] == 'p' && s
[2] == 'a' && s
[3] == 'g' && s
[4] == 'e')
274 else if (s
[1] == 'o' && s
[2] == 'f' && s
[3] == 'f')
281 input_line_pointer
= s
;
284 new = input_line_pointer
;
285 input_line_pointer
= save
;
286 if (SEG_NORMAL (seg
))
297 as_bad ("Missing operand");
300 as_bad ("Don't understand operand of type %s", segment_name (seg
));
307 exp_signed
, exp_unsigned
, exp_sandu
312 skip_colonthing (sign
, ptr
, exp
, def
, size8
, size16
, size24
)
315 h8500_operand_info
*exp
;
321 ptr
= parse_exp (ptr
, &exp
->exp
, &exp
->page
);
330 else if (ptr
[0] == '1' & ptr
[1] == '6')
335 else if (ptr
[0] == '2' & ptr
[1] == '4')
339 as_bad (":24 not valid for this opcode");
346 as_bad ("expect :8,:16 or :24");
352 if (exp
->page
== 'p')
358 /* Let's work out the size from the context */
359 int n
= exp
->exp
.X_add_number
;
361 && exp
->exp
.X_seg
== SEG_ABSOLUTE
362 && ((sign
== exp_signed
&& (n
>= -128 && n
<= 127))
363 || (sign
== exp_unsigned
&& (n
>= 0 && (n
<= 255)))
364 || (sign
== exp_sandu
&& (n
>= -128 && (n
<= 255)))))
378 parse_reglist (src
, op
)
380 h8500_operand_info
*op
;
386 int idx
= 1; /* skip ( */
388 while (src
[idx
] && src
[idx
] != ')')
390 int done
= parse_reg (src
+ idx
, &mode
, &rn
);
399 as_bad ("syntax error in reg list");
405 done
= parse_reg (src
+ idx
, &mode
, &rm
);
417 as_bad ("missing final register in range");
424 op
->exp
.X_add_symbol
= 0;
425 op
->exp
.X_subtract_symbol
= 0;
426 op
->exp
.X_add_number
= mask
;
427 op
->exp
.X_seg
= SEG_ABSOLUTE
;
433 /* The many forms of operand:
436 @Rn Register indirect
437 @(disp[:size], Rn) Register indirect with displacement
441 #xx[:size] immediate data
446 get_operand (ptr
, op
, ispage
)
448 h8500_operand_info
*op
;
456 if (src
[0] == '(' && src
[1] == 'r')
458 /* This is a register list */
459 *ptr
= src
+ parse_reglist (src
, op
);
463 len
= parse_reg (src
, &op
->type
, &op
->reg
);
477 len
= parse_reg (src
, &mode
, &num
);
480 /* Oops, not a reg after all, must be ordinary exp */
482 /* must be a symbol */
483 *ptr
= skip_colonthing (exp_unsigned
, src
,
484 op
, ABS16
, ABS8
, ABS16
, ABS24
);
498 src
= skip_colonthing (exp_signed
, src
,
499 op
, RNIND_D16
, RNIND_D8
, RNIND_D16
, 0);
503 as_bad ("expected @(exp, Rn)");
507 len
= parse_reg (src
, &mode
, &op
->reg
);
508 if (len
== 0 || mode
!= RN
)
510 as_bad ("expected @(exp, Rn)");
516 as_bad ("expected @(exp, Rn)");
522 len
= parse_reg (src
, &mode
, &num
);
532 as_bad ("@Rn+ needs word register");
542 as_bad ("@Rn needs word register");
552 /* must be a symbol */
554 skip_colonthing (exp_unsigned
, src
, op
,
555 ispage
? ABS24
: ABS16
, ABS8
, ABS16
, ABS24
);
563 *ptr
= skip_colonthing (exp_sandu
, src
, op
, IMM16
, IMM8
, IMM16
, ABS24
);
568 *ptr
= skip_colonthing (exp_signed
, src
, op
,
569 ispage
? ABS24
: PCREL8
, PCREL8
, PCREL16
, ABS24
);
575 get_operands (info
, args
, operand
)
576 h8500_opcode_info
*info
;
578 h8500_operand_info
*operand
;
592 get_operand (&ptr
, operand
+ 0, info
->name
[0] == 'p');
598 get_operand (&ptr
, operand
+ 0, 0);
601 get_operand (&ptr
, operand
+ 1, 0);
611 /* Passed a pointer to a list of opcodes which use different
612 addressing modes, return the opcode which matches the opcodes
616 int pcrel8
; /* Set when we've seen a pcrel operand */
620 get_specific (opcode
, operands
)
621 h8500_opcode_info
*opcode
;
622 h8500_operand_info
*operands
;
624 h8500_opcode_info
*this_try
= opcode
;
626 unsigned int noperands
= opcode
->nargs
;
628 unsigned int this_index
= opcode
->idx
;
630 while (this_index
== opcode
->idx
&& !found
)
636 /* look at both operands needed by the opcodes and provided by
638 for (i
= 0; i
< noperands
; i
++)
640 h8500_operand_info
*user
= operands
+ i
;
642 switch (this_try
->arg_type
[i
])
645 /* Opcode needs (disp:8,fp) */
646 if (user
->type
== RNIND_D8
&& user
->reg
== 6)
648 displacement
= user
->exp
;
653 if (user
->type
== RNIND_D16
)
655 displacement
= user
->exp
;
661 if (user
->type
== RNIND_D8
)
663 displacement
= user
->exp
;
670 if (user
->type
== this_try
->arg_type
[i
])
672 displacement
= user
->exp
;
679 if (user
->type
== RNDEC
&& user
->reg
== 7)
685 if (user
->type
== RNINC
&& user
->reg
== 7)
691 if (user
->type
== ABS16
)
693 absolute
= user
->exp
;
698 if (user
->type
== ABS8
)
700 absolute
= user
->exp
;
705 if (user
->type
== ABS24
)
707 absolute
= user
->exp
;
713 if ((user
->type
== CRB
|| user
->type
== CR
) && user
->reg
!= 0)
720 if ((user
->type
== CRW
|| user
->type
== CR
) && user
->reg
== 0)
727 if (user
->type
== DISP16
)
729 displacement
= user
->exp
;
734 if (user
->type
== DISP8
)
736 displacement
= user
->exp
;
741 if (user
->type
== RN
&& user
->reg
== 6)
747 if (user
->type
== PCREL16
)
749 displacement
= user
->exp
;
754 if (user
->type
== PCREL8
)
756 displacement
= user
->exp
;
763 if (user
->type
== IMM16
764 || user
->type
== IMM8
)
766 immediate_inpage
= user
->page
;
767 immediate
= user
->exp
;
773 if (user
->type
== IMM8
)
775 immediate_inpage
= user
->page
;
776 immediate
= user
->exp
;
781 if (user
->type
== IMM8
)
783 immediate_inpage
= user
->page
;
784 immediate
= user
->exp
;
789 if (user
->type
== IMM8
790 && user
->exp
.X_seg
== SEG_ABSOLUTE
792 (user
->exp
.X_add_number
== -2
793 || user
->exp
.X_add_number
== -1
794 || user
->exp
.X_add_number
== 1
795 || user
->exp
.X_add_number
== 2))
797 immediate_inpage
= user
->page
;
798 immediate
= user
->exp
;
803 if (user
->type
== RN
)
810 if (user
->type
== RN
)
817 if (user
->type
== RNIND
)
829 if (user
->type
== this_try
->arg_type
[i
])
836 if (user
->type
== RN
&& user
->reg
== 7)
842 printf ("unhandled %d\n", this_try
->arg_type
[i
]);
846 /* If we get here this didn't work out */
861 check (operand
, low
, high
)
862 expressionS
*operand
;
866 if (operand
->X_seg
!= SEG_ABSOLUTE
867 || operand
->X_add_number
< low
868 || operand
->X_add_number
> high
)
870 as_bad ("operand must be absolute in range %d..%d", low
, high
);
872 return operand
->X_add_number
;
877 insert (output
, index
, exp
, reloc
, pcrel
)
885 output
- frag_now
->fr_literal
+ index
,
886 4, /* always say size is 4, but we know better */
888 exp
->X_subtract_symbol
,
895 build_relaxable_instruction (opcode
, operand
)
896 h8500_opcode_info
*opcode
;
897 h8500_operand_info
*operand
;
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 scb
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, lets build the bytes -
938 build_bytes (opcode
, operand
)
939 h8500_opcode_info
*opcode
;
940 h8500_operand_info
*operand
;
948 build_relaxable_instruction (opcode
, operand
);
952 char *output
= frag_more (opcode
->length
);
954 memset (output
, 0, opcode
->length
);
955 for (index
= 0; index
< opcode
->length
; index
++)
957 output
[index
] = opcode
->bytes
[index
].contents
;
959 switch (opcode
->bytes
[index
].insert
)
962 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);
986 insert (output
, index
, &immediate
, immediate_inpage
?
987 R_H8500_LOW16
: R_H8500_IMM16
, 0);
992 if (immediate_inpage
)
994 insert (output
, index
, &immediate
, R_H8500_HIGH8
, 0);
998 insert (output
, index
, &immediate
, R_H8500_IMM8
, 0);
1002 insert (output
, index
, &displacement
, R_H8500_PCREL16
, 1);
1006 insert (output
, index
, &displacement
, R_H8500_PCREL8
, 1);
1009 output
[index
] |= check (&immediate
, 0, 15);
1013 output
[index
] |= cr
;
1026 output
[index
] |= crb
;
1030 output
[index
] |= crw
;
1034 insert (output
, index
, &absolute
, R_H8500_IMM24
, 0);
1038 insert (output
, index
, &absolute
, R_H8500_IMM16
, 0);
1042 insert (output
, index
, &absolute
, R_H8500_IMM8
, 0);
1045 switch (immediate
.X_add_number
)
1048 output
[index
] |= 0x5;
1051 output
[index
] |= 0x4;
1066 /* This is the guts of the machine-dependent assembler. STR points to a
1067 machine dependent instruction. This funciton is supposed to emit
1068 the frags/bytes it assembles to.
1072 DEFUN (md_assemble
, (str
),
1077 h8500_operand_info operand
[2];
1078 h8500_opcode_info
*opcode
;
1079 h8500_opcode_info
*prev_opcode
;
1084 /* Drop leading whitespace */
1088 /* find the op code end */
1089 for (op_start
= op_end
= str
;
1091 !is_end_of_line
[*op_end
] && *op_end
!= ' ';
1094 if ( /**op_end != '.'
1098 name
[nlen
++] = *op_end
;
1103 if (op_end
== op_start
)
1105 as_bad ("can't find opcode ");
1108 opcode
= (h8500_opcode_info
*) hash_find (opcode_hash_control
, name
);
1112 as_bad ("unknown opcode");
1116 input_line_pointer
= 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
);
1137 DEFUN (tc_crawl_symbol_chain
, (headers
),
1138 object_headers
* headers
)
1140 printf ("call to tc_crawl_symbol_chain \n");
1144 DEFUN (md_undefined_symbol
, (name
),
1151 DEFUN (tc_headers_hook
, (headers
),
1152 object_headers
* headers
)
1154 printf ("call to tc_headers_hook \n");
1162 /* Various routines to kill one day */
1163 /* Equal to MAX_PRECISION in atof-ieee.c */
1164 #define MAX_LITTLENUMS 6
1166 /* Turn a string in input_line_pointer into a floating point constant of type
1167 type, and store the appropriate bytes in *litP. The number of LITTLENUMS
1168 emitted is stored in *sizeP . An error message is returned, or NULL on OK.
1171 md_atof (type
, litP
, sizeP
)
1177 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
1178 LITTLENUM_TYPE
*wordP
;
1210 return "Bad call to MD_ATOF()";
1212 t
= atof_ieee (input_line_pointer
, type
, words
);
1214 input_line_pointer
= t
;
1216 *sizeP
= prec
* sizeof (LITTLENUM_TYPE
);
1217 for (wordP
= words
; prec
--;)
1219 md_number_to_chars (litP
, (long) (*wordP
++), sizeof (LITTLENUM_TYPE
));
1220 litP
+= sizeof (LITTLENUM_TYPE
);
1222 return ""; /* Someone should teach Dean about null pointers */
1226 md_parse_option (argP
, cntP
, vecP
)
1235 int md_short_jump_size
;
1238 tc_aout_fix_to_chars ()
1240 printf ("call to tc_aout_fix_to_chars \n");
1245 md_create_short_jump (ptr
, from_addr
, to_addr
, frag
, to_symbol
)
1252 as_fatal ("failed sanity check.");
1256 md_create_long_jump (ptr
, from_addr
, to_addr
, frag
, to_symbol
)
1258 long from_addr
, to_addr
;
1262 as_fatal ("failed sanity check.");
1267 wordify_scb (buffer
, disp_size
, inst_size
)
1272 int rn
= buffer
[1] & 0x7;
1276 case 0x0e: /* BSR */
1310 *buffer
++ = 0x26; /* bne + 8 */
1316 *buffer
++ = 0x27; /* bne + 8 */
1321 *buffer
++ = 0xa8 | rn
; /* addq -1,rn */
1323 *buffer
++ = 0x04; /* cmp #0xff:8, rn */
1325 *buffer
++ = 0x70 | rn
;
1326 *buffer
++ = 0x36; /* bne ... */
1332 called after relaxing, change the frags so they know how big they are
1335 md_convert_frag (headers
, fragP
)
1336 object_headers
*headers
;
1342 char *buffer
= fragP
->fr_fix
+ fragP
->fr_literal
;
1344 switch (fragP
->fr_subtype
)
1346 case C (BRANCH
, BYTE_DISP
):
1351 case C (SCB_F
, BYTE_DISP
):
1352 case C (SCB_TST
, BYTE_DISP
):
1357 /* Branches to a known 16 bit displacement */
1359 /* Turn on the 16bit bit */
1360 case C (BRANCH
, WORD_DISP
):
1361 case C (SCB_F
, WORD_DISP
):
1362 case C (SCB_TST
, WORD_DISP
):
1363 wordify_scb (buffer
, &disp_size
, &inst_size
);
1366 case C (BRANCH
, UNDEF_WORD_DISP
):
1367 case C (SCB_F
, UNDEF_WORD_DISP
):
1368 case C (SCB_TST
, UNDEF_WORD_DISP
):
1369 /* This tried to be relaxed, but didn't manage it, it now needs a
1371 wordify_scb (buffer
, &disp_size
, &inst_size
);
1375 fragP
->fr_fix
+ inst_size
,
1383 fragP
->fr_fix
+= disp_size
+ inst_size
;
1392 /* Get the address of the end of the instruction */
1393 int next_inst
= fragP
->fr_fix
+ fragP
->fr_address
+ disp_size
+ inst_size
;
1394 int targ_addr
= (S_GET_VALUE (fragP
->fr_symbol
) +
1396 int disp
= targ_addr
- next_inst
;
1398 md_number_to_chars (buffer
+ inst_size
, disp
, disp_size
);
1399 fragP
->fr_fix
+= disp_size
+ inst_size
;
1406 DEFUN (md_section_align
, (seg
, size
),
1410 return ((size
+ (1 << section_alignment
[(int) seg
]) - 1)
1411 & (-1 << section_alignment
[(int) seg
]));
1416 md_apply_fix (fixP
, val
)
1420 char *buf
= fixP
->fx_where
+ fixP
->fx_frag
->fr_literal
;
1422 if (fixP
->fx_r_type
== 0)
1424 fixP
->fx_r_type
= fixP
->fx_size
== 4 ? R_H8500_IMM32
: R_H8500_IMM16
;
1427 switch (fixP
->fx_r_type
)
1431 case R_H8500_PCREL8
:
1436 case R_H8500_PCREL16
:
1437 *buf
++ = (val
>> 8);
1444 *buf
++ = (val
>> 16);
1445 *buf
++ = (val
>> 8);
1449 *buf
++ = (val
>> 24);
1450 *buf
++ = (val
>> 16);
1451 *buf
++ = (val
>> 8);
1461 DEFUN (md_operand
, (expressionP
), expressionS
* expressionP
)
1465 int md_long_jump_size
;
1468 called just before address relaxation, return the length
1469 by which a fragment must grow to reach it's destination
1472 md_estimate_size_before_relax (fragP
, segment_type
)
1473 register fragS
*fragP
;
1474 register segT segment_type
;
1476 int what
= GET_WHAT (fragP
->fr_subtype
);
1478 switch (fragP
->fr_subtype
)
1482 case C (BRANCH
, UNDEF_BYTE_DISP
):
1483 case C (SCB_F
, UNDEF_BYTE_DISP
):
1484 case C (SCB_TST
, UNDEF_BYTE_DISP
):
1485 /* used to be a branch to somewhere which was unknown */
1486 if (S_GET_SEGMENT (fragP
->fr_symbol
) == segment_type
)
1488 /* Got a symbol and it's defined in this segment, become byte
1489 sized - maybe it will fix up */
1490 fragP
->fr_subtype
= C (what
, BYTE_DISP
);
1491 fragP
->fr_var
= md_relax_table
[C (what
, BYTE_DISP
)].rlx_length
;
1495 /* Its got a segment, but its not ours, so it will always be long */
1496 fragP
->fr_subtype
= C (what
, UNDEF_WORD_DISP
);
1497 fragP
->fr_var
= md_relax_table
[C (what
, WORD_DISP
)].rlx_length
;
1498 return md_relax_table
[C (what
, WORD_DISP
)].rlx_length
;
1501 return fragP
->fr_var
;
1504 /* Put number into target byte order */
1507 md_number_to_chars (ptr
, use
, nbytes
)
1515 *ptr
++ = (use
>> 24) & 0xff;
1517 *ptr
++ = (use
>> 16) & 0xff;
1519 *ptr
++ = (use
>> 8) & 0xff;
1521 *ptr
++ = (use
>> 0) & 0xff;
1528 md_pcrel_from (fixP
)
1532 return fixP
->fx_size
+ fixP
->fx_where
+ fixP
->fx_frag
->fr_address
;
1536 tc_coff_symbol_emit_hook ()
1541 tc_coff_fix2rtype (fix_ptr
)
1544 if (fix_ptr
->fx_r_type
== RELOC_32
)
1546 /* cons likes to create reloc32's whatever the size of the reloc..
1548 switch (fix_ptr
->fx_size
)
1551 return R_H8500_IMM16
;
1554 return R_H8500_IMM8
;
1560 return fix_ptr
->fx_r_type
;
1564 tc_reloc_mangle (fix_ptr
, intr
, base
)
1566 struct internal_reloc
*intr
;
1570 symbolS
*symbol_ptr
;
1572 symbol_ptr
= fix_ptr
->fx_addsy
;
1574 /* If this relocation is attached to a symbol then it's ok
1576 if (fix_ptr
->fx_r_type
== RELOC_32
)
1578 /* cons likes to create reloc32's whatever the size of the reloc..
1580 switch (fix_ptr
->fx_size
)
1583 intr
->r_type
= R_IMM16
;
1586 intr
->r_type
= R_IMM8
;
1594 intr
->r_type
= fix_ptr
->fx_r_type
;
1597 intr
->r_vaddr
= fix_ptr
->fx_frag
->fr_address
+ fix_ptr
->fx_where
+ base
;
1598 intr
->r_offset
= fix_ptr
->fx_offset
;
1600 /* Turn the segment of the symbol into an offset. */
1605 dot
= segment_info
[S_GET_SEGMENT (symbol_ptr
)].dot
;
1608 /* intr->r_offset -=
1609 segment_info[S_GET_SEGMENT(symbol_ptr)].scnhdr.s_paddr;*/
1610 intr
->r_offset
+= S_GET_VALUE (symbol_ptr
);
1611 intr
->r_symndx
= dot
->sy_number
;
1615 intr
->r_symndx
= symbol_ptr
->sy_number
;
1621 intr
->r_symndx
= -1;
1632 /* Check for :s.w */
1633 if (isalpha (ptr
[1]) && ptr
[2] == '.')
1636 if (isalpha (ptr
[1]) && !isalpha (ptr
[2]))
1641 /* end of tc-h8500.c */