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];
105 register relax_typeS
*table
;
107 opcode_hash_control
= hash_new ();
110 /* Insert unique names into hash table */
111 for (opcode
= h8500_table
; opcode
->name
; opcode
++)
113 if (idx
!= opcode
->idx
)
115 hash_insert (opcode_hash_control
, opcode
->name
, (char *) opcode
);
120 /* Initialize the relax table. We use a local variable to avoid
121 warnings about modifying a supposedly const data structure. */
122 table
= (relax_typeS
*) md_relax_table
;
123 table
[C (BRANCH
, BYTE_DISP
)].rlx_forward
= BYTE_F
;
124 table
[C (BRANCH
, BYTE_DISP
)].rlx_backward
= BYTE_B
;
125 table
[C (BRANCH
, BYTE_DISP
)].rlx_length
= 2;
126 table
[C (BRANCH
, BYTE_DISP
)].rlx_more
= C (BRANCH
, WORD_DISP
);
128 table
[C (BRANCH
, WORD_DISP
)].rlx_forward
= WORD_F
;
129 table
[C (BRANCH
, WORD_DISP
)].rlx_backward
= WORD_B
;
130 table
[C (BRANCH
, WORD_DISP
)].rlx_length
= 3;
131 table
[C (BRANCH
, WORD_DISP
)].rlx_more
= 0;
133 table
[C (SCB_F
, BYTE_DISP
)].rlx_forward
= BYTE_F
;
134 table
[C (SCB_F
, BYTE_DISP
)].rlx_backward
= BYTE_B
;
135 table
[C (SCB_F
, BYTE_DISP
)].rlx_length
= 3;
136 table
[C (SCB_F
, BYTE_DISP
)].rlx_more
= C (SCB_F
, WORD_DISP
);
138 table
[C (SCB_F
, WORD_DISP
)].rlx_forward
= WORD_F
;
139 table
[C (SCB_F
, WORD_DISP
)].rlx_backward
= WORD_B
;
140 table
[C (SCB_F
, WORD_DISP
)].rlx_length
= 8;
141 table
[C (SCB_F
, WORD_DISP
)].rlx_more
= 0;
143 table
[C (SCB_TST
, BYTE_DISP
)].rlx_forward
= BYTE_F
;
144 table
[C (SCB_TST
, BYTE_DISP
)].rlx_backward
= BYTE_B
;
145 table
[C (SCB_TST
, BYTE_DISP
)].rlx_length
= 3;
146 table
[C (SCB_TST
, BYTE_DISP
)].rlx_more
= C (SCB_TST
, WORD_DISP
);
148 table
[C (SCB_TST
, WORD_DISP
)].rlx_forward
= WORD_F
;
149 table
[C (SCB_TST
, WORD_DISP
)].rlx_backward
= WORD_B
;
150 table
[C (SCB_TST
, WORD_DISP
)].rlx_length
= 10;
151 table
[C (SCB_TST
, WORD_DISP
)].rlx_more
= 0;
155 static int rn
; /* register number used by RN */
156 static int rs
; /* register number used by RS */
157 static int rd
; /* register number used by RD */
158 static int crb
; /* byte size cr */
159 static int crw
; /* word sized cr */
160 static int cr
; /* unknown size cr */
162 static expressionS displacement
;/* displacement expression */
163 static int displacement_size
; /* and size if given */
165 static int immediate_inpage
;
166 static expressionS immediate
; /* immediate expression */
167 static int immediate_size
; /* and size if given */
169 static expressionS absolute
; /* absolute expression */
170 static int absolute_size
; /* and size if given */
182 /* try and parse a reg name, returns number of chars consumed */
184 parse_reg (src
, mode
, reg
)
191 if (src
[1] >= '0' && src
[1] <= '7')
194 *reg
= (src
[1] - '0');
199 if (src
[0] == 's' && src
[1] == 'p')
205 if (src
[0] == 'c' && src
[1] == 'c' && src
[2] == 'r')
211 if (src
[0] == 's' && src
[1] == 'r')
218 if (src
[0] == 'b' && src
[1] == 'r')
225 if (src
[0] == 'e' && src
[1] == 'p')
232 if (src
[0] == 'd' && src
[1] == 'p')
239 if (src
[0] == 't' && src
[1] == 'p')
246 if (src
[0] == 'f' && src
[1] == 'p')
257 parse_exp (s
, op
, page
)
265 save
= input_line_pointer
;
270 if (s
[1] == 'p' && s
[2] == 'a' && s
[3] == 'g' && s
[4] == 'e')
275 if (s
[1] == 'h' && s
[2] == 'i' && s
[3] == '1' && s
[4] == '6')
280 else if (s
[1] == 'o' && s
[2] == 'f' && s
[3] == 'f')
287 input_line_pointer
= s
;
289 if (expression (op
) == O_absent
)
290 as_bad ("missing operand");
291 new = input_line_pointer
;
292 input_line_pointer
= save
;
298 exp_signed
, exp_unsigned
, exp_sandu
303 skip_colonthing (sign
, ptr
, exp
, def
, size8
, size16
, size24
)
306 h8500_operand_info
*exp
;
312 ptr
= parse_exp (ptr
, &exp
->exp
, &exp
->page
);
321 else if (ptr
[0] == '1' & ptr
[1] == '6')
326 else if (ptr
[0] == '2' & ptr
[1] == '4')
330 as_bad (":24 not valid for this opcode");
337 as_bad ("expect :8,:16 or :24");
343 if (exp
->page
== 'p')
347 else if (exp
->page
== 'h')
353 /* Let's work out the size from the context */
354 int n
= exp
->exp
.X_add_number
;
356 && exp
->exp
.X_op
== O_constant
357 && ((sign
== exp_signed
&& (n
>= -128 && n
<= 127))
358 || (sign
== exp_unsigned
&& (n
>= 0 && (n
<= 255)))
359 || (sign
== exp_sandu
&& (n
>= -128 && (n
<= 255)))))
373 parse_reglist (src
, op
)
375 h8500_operand_info
*op
;
381 int idx
= 1; /* skip ( */
383 while (src
[idx
] && src
[idx
] != ')')
385 int done
= parse_reg (src
+ idx
, &mode
, &rn
);
394 as_bad ("syntax error in reg list");
400 done
= parse_reg (src
+ idx
, &mode
, &rm
);
412 as_bad ("missing final register in range");
419 op
->exp
.X_add_symbol
= 0;
420 op
->exp
.X_op_symbol
= 0;
421 op
->exp
.X_add_number
= mask
;
422 op
->exp
.X_op
= O_constant
;
428 /* The many forms of operand:
431 @Rn Register indirect
432 @(disp[:size], Rn) Register indirect with displacement
436 #xx[:size] immediate data
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
);
570 get_operands (info
, args
, operand
)
571 h8500_opcode_info
*info
;
573 h8500_operand_info
*operand
;
587 get_operand (&ptr
, operand
+ 0, info
->name
[0] == 'p');
593 get_operand (&ptr
, operand
+ 0, 0);
596 get_operand (&ptr
, operand
+ 1, 0);
606 /* Passed a pointer to a list of opcodes which use different
607 addressing modes, return the opcode which matches the opcodes
611 int pcrel8
; /* Set when we've seen a pcrel operand */
615 get_specific (opcode
, operands
)
616 h8500_opcode_info
*opcode
;
617 h8500_operand_info
*operands
;
619 h8500_opcode_info
*this_try
= opcode
;
621 unsigned int noperands
= opcode
->nargs
;
623 unsigned int this_index
= opcode
->idx
;
625 while (this_index
== opcode
->idx
&& !found
)
631 /* look at both operands needed by the opcodes and provided by
633 for (i
= 0; i
< noperands
; i
++)
635 h8500_operand_info
*user
= operands
+ i
;
637 switch (this_try
->arg_type
[i
])
640 /* Opcode needs (disp:8,fp) */
641 if (user
->type
== RNIND_D8
&& user
->reg
== 6)
643 displacement
= user
->exp
;
648 if (user
->type
== RNIND_D16
)
650 displacement
= user
->exp
;
656 if (user
->type
== RNIND_D8
)
658 displacement
= user
->exp
;
665 if (user
->type
== this_try
->arg_type
[i
])
667 displacement
= user
->exp
;
674 if (user
->type
== RNDEC
&& user
->reg
== 7)
680 if (user
->type
== RNINC
&& user
->reg
== 7)
686 if (user
->type
== ABS16
)
688 absolute
= user
->exp
;
693 if (user
->type
== ABS8
)
695 absolute
= user
->exp
;
700 if (user
->type
== ABS24
)
702 absolute
= user
->exp
;
708 if ((user
->type
== CRB
|| user
->type
== CR
) && user
->reg
!= 0)
715 if ((user
->type
== CRW
|| user
->type
== CR
) && user
->reg
== 0)
722 if (user
->type
== DISP16
)
724 displacement
= user
->exp
;
729 if (user
->type
== DISP8
)
731 displacement
= user
->exp
;
736 if (user
->type
== RN
&& user
->reg
== 6)
742 if (user
->type
== PCREL16
)
744 displacement
= user
->exp
;
749 if (user
->type
== PCREL8
)
751 displacement
= user
->exp
;
758 if (user
->type
== IMM16
759 || user
->type
== IMM8
)
761 immediate_inpage
= user
->page
;
762 immediate
= user
->exp
;
768 if (user
->type
== IMM8
)
770 immediate_inpage
= user
->page
;
771 immediate
= user
->exp
;
776 if (user
->type
== IMM8
)
778 immediate_inpage
= user
->page
;
779 immediate
= user
->exp
;
784 if (user
->type
== IMM8
785 && user
->exp
.X_op
== O_constant
787 (user
->exp
.X_add_number
== -2
788 || user
->exp
.X_add_number
== -1
789 || user
->exp
.X_add_number
== 1
790 || user
->exp
.X_add_number
== 2))
792 immediate_inpage
= user
->page
;
793 immediate
= user
->exp
;
798 if (user
->type
== RN
)
805 if (user
->type
== RN
)
812 if (user
->type
== RNIND
)
824 if (user
->type
== this_try
->arg_type
[i
])
831 if (user
->type
== RN
&& user
->reg
== 7)
837 printf ("unhandled %d\n", this_try
->arg_type
[i
]);
841 /* If we get here this didn't work out */
856 check (operand
, low
, high
)
857 expressionS
*operand
;
861 if (operand
->X_op
!= O_constant
862 || operand
->X_add_number
< low
863 || operand
->X_add_number
> high
)
865 as_bad ("operand must be absolute in range %d..%d", low
, high
);
867 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 scb
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, lets 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
);
971 insert (output
, index
, &displacement
, R_H8500_IMM16
, 0);
976 insert (output
, index
, &displacement
, R_H8500_IMM8
, 0);
982 switch (immediate_inpage
) {
994 insert (output
, index
, &immediate
,p
, 0);
1001 if (immediate_inpage
)
1003 insert (output
, index
, &immediate
, R_H8500_HIGH8
, 0);
1007 insert (output
, index
, &immediate
, R_H8500_IMM8
, 0);
1011 insert (output
, index
, &displacement
, R_H8500_PCREL16
, 1);
1015 insert (output
, index
, &displacement
, R_H8500_PCREL8
, 1);
1018 output
[index
] |= check (&immediate
, 0, 15);
1022 output
[index
] |= cr
;
1035 output
[index
] |= crb
;
1039 output
[index
] |= crw
;
1043 insert (output
, index
, &absolute
, R_H8500_IMM24
, 0);
1047 insert (output
, index
, &absolute
, R_H8500_IMM16
, 0);
1051 insert (output
, index
, &absolute
, R_H8500_IMM8
, 0);
1054 switch (immediate
.X_add_number
)
1057 output
[index
] |= 0x5;
1060 output
[index
] |= 0x4;
1075 /* This is the guts of the machine-dependent assembler. STR points to a
1076 machine dependent instruction. This funciton is supposed to emit
1077 the frags/bytes it assembles to.
1081 DEFUN (md_assemble
, (str
),
1086 h8500_operand_info operand
[2];
1087 h8500_opcode_info
*opcode
;
1088 h8500_opcode_info
*prev_opcode
;
1093 /* Drop leading whitespace */
1097 /* find the op code end */
1098 for (op_start
= op_end
= str
;
1100 !is_end_of_line
[*op_end
] && *op_end
!= ' ';
1103 if ( /**op_end != '.'
1107 name
[nlen
++] = *op_end
;
1112 if (op_end
== op_start
)
1114 as_bad ("can't find opcode ");
1117 opcode
= (h8500_opcode_info
*) hash_find (opcode_hash_control
, name
);
1121 as_bad ("unknown opcode");
1125 input_line_pointer
= get_operands (opcode
, op_end
, operand
);
1126 prev_opcode
= opcode
;
1128 opcode
= get_specific (opcode
, operand
);
1132 /* Couldn't find an opcode which matched the operands */
1133 char *where
= frag_more (2);
1137 as_bad ("invalid operands for opcode");
1141 build_bytes (opcode
, operand
);
1146 DEFUN (tc_crawl_symbol_chain
, (headers
),
1147 object_headers
* headers
)
1149 printf ("call to tc_crawl_symbol_chain \n");
1153 DEFUN (md_undefined_symbol
, (name
),
1160 DEFUN (tc_headers_hook
, (headers
),
1161 object_headers
* headers
)
1163 printf ("call to tc_headers_hook \n");
1171 /* Various routines to kill one day */
1172 /* Equal to MAX_PRECISION in atof-ieee.c */
1173 #define MAX_LITTLENUMS 6
1175 /* Turn a string in input_line_pointer into a floating point constant of type
1176 type, and store the appropriate bytes in *litP. The number of LITTLENUMS
1177 emitted is stored in *sizeP . An error message is returned, or NULL on OK.
1180 md_atof (type
, litP
, sizeP
)
1186 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
1187 LITTLENUM_TYPE
*wordP
;
1219 return "Bad call to MD_ATOF()";
1221 t
= atof_ieee (input_line_pointer
, type
, words
);
1223 input_line_pointer
= t
;
1225 *sizeP
= prec
* sizeof (LITTLENUM_TYPE
);
1226 for (wordP
= words
; prec
--;)
1228 md_number_to_chars (litP
, (long) (*wordP
++), sizeof (LITTLENUM_TYPE
));
1229 litP
+= sizeof (LITTLENUM_TYPE
);
1231 return ""; /* Someone should teach Dean about null pointers */
1235 md_parse_option (argP
, cntP
, vecP
)
1244 int md_short_jump_size
;
1247 tc_aout_fix_to_chars ()
1249 printf ("call to tc_aout_fix_to_chars \n");
1254 md_create_short_jump (ptr
, from_addr
, to_addr
, frag
, to_symbol
)
1261 as_fatal ("failed sanity check.");
1265 md_create_long_jump (ptr
, from_addr
, to_addr
, frag
, to_symbol
)
1267 addressT from_addr
, to_addr
;
1271 as_fatal ("failed sanity check.");
1276 wordify_scb (buffer
, disp_size
, inst_size
)
1281 int rn
= buffer
[1] & 0x7;
1285 case 0x0e: /* BSR */
1319 *buffer
++ = 0x26; /* bne + 8 */
1325 *buffer
++ = 0x27; /* bne + 8 */
1330 *buffer
++ = 0xa8 | rn
; /* addq -1,rn */
1332 *buffer
++ = 0x04; /* cmp #0xff:8, rn */
1334 *buffer
++ = 0x70 | rn
;
1335 *buffer
++ = 0x36; /* bne ... */
1341 called after relaxing, change the frags so they know how big they are
1344 md_convert_frag (headers
, fragP
)
1345 object_headers
*headers
;
1351 char *buffer
= fragP
->fr_fix
+ fragP
->fr_literal
;
1353 switch (fragP
->fr_subtype
)
1355 case C (BRANCH
, BYTE_DISP
):
1360 case C (SCB_F
, BYTE_DISP
):
1361 case C (SCB_TST
, BYTE_DISP
):
1366 /* Branches to a known 16 bit displacement */
1368 /* Turn on the 16bit bit */
1369 case C (BRANCH
, WORD_DISP
):
1370 case C (SCB_F
, WORD_DISP
):
1371 case C (SCB_TST
, WORD_DISP
):
1372 wordify_scb (buffer
, &disp_size
, &inst_size
);
1375 case C (BRANCH
, UNDEF_WORD_DISP
):
1376 case C (SCB_F
, UNDEF_WORD_DISP
):
1377 case C (SCB_TST
, UNDEF_WORD_DISP
):
1378 /* This tried to be relaxed, but didn't manage it, it now needs a
1380 wordify_scb (buffer
, &disp_size
, &inst_size
);
1384 fragP
->fr_fix
+ inst_size
,
1391 fragP
->fr_fix
+= disp_size
+ inst_size
;
1400 /* Get the address of the end of the instruction */
1401 int next_inst
= fragP
->fr_fix
+ fragP
->fr_address
+ disp_size
+ inst_size
;
1402 int targ_addr
= (S_GET_VALUE (fragP
->fr_symbol
) +
1404 int disp
= targ_addr
- next_inst
;
1406 md_number_to_chars (buffer
+ inst_size
, disp
, disp_size
);
1407 fragP
->fr_fix
+= disp_size
+ inst_size
;
1414 md_section_align (seg
, size
)
1418 return ((size
+ (1 << section_alignment
[(int) seg
]) - 1)
1419 & (-1 << section_alignment
[(int) seg
]));
1424 md_apply_fix (fixP
, val
)
1428 char *buf
= fixP
->fx_where
+ fixP
->fx_frag
->fr_literal
;
1430 if (fixP
->fx_r_type
== 0)
1432 fixP
->fx_r_type
= fixP
->fx_size
== 4 ? R_H8500_IMM32
: R_H8500_IMM16
;
1435 switch (fixP
->fx_r_type
)
1439 case R_H8500_PCREL8
:
1444 case R_H8500_PCREL16
:
1445 *buf
++ = (val
>> 8);
1451 case R_H8500_HIGH16
:
1456 *buf
++ = (val
>> 16);
1457 *buf
++ = (val
>> 8);
1461 *buf
++ = (val
>> 24);
1462 *buf
++ = (val
>> 16);
1463 *buf
++ = (val
>> 8);
1473 DEFUN (md_operand
, (expressionP
), expressionS
* expressionP
)
1477 int md_long_jump_size
;
1480 called just before address relaxation, return the length
1481 by which a fragment must grow to reach it's destination
1484 md_estimate_size_before_relax (fragP
, segment_type
)
1485 register fragS
*fragP
;
1486 register segT segment_type
;
1488 int what
= GET_WHAT (fragP
->fr_subtype
);
1490 switch (fragP
->fr_subtype
)
1494 case C (BRANCH
, UNDEF_BYTE_DISP
):
1495 case C (SCB_F
, UNDEF_BYTE_DISP
):
1496 case C (SCB_TST
, UNDEF_BYTE_DISP
):
1497 /* used to be a branch to somewhere which was unknown */
1498 if (S_GET_SEGMENT (fragP
->fr_symbol
) == segment_type
)
1500 /* Got a symbol and it's defined in this segment, become byte
1501 sized - maybe it will fix up */
1502 fragP
->fr_subtype
= C (what
, BYTE_DISP
);
1503 fragP
->fr_var
= md_relax_table
[C (what
, BYTE_DISP
)].rlx_length
;
1507 /* Its got a segment, but its not ours, so it will always be long */
1508 fragP
->fr_subtype
= C (what
, UNDEF_WORD_DISP
);
1509 fragP
->fr_var
= md_relax_table
[C (what
, WORD_DISP
)].rlx_length
;
1510 return md_relax_table
[C (what
, WORD_DISP
)].rlx_length
;
1513 return fragP
->fr_var
;
1516 /* Put number into target byte order */
1519 md_number_to_chars (ptr
, use
, nbytes
)
1527 *ptr
++ = (use
>> 24) & 0xff;
1529 *ptr
++ = (use
>> 16) & 0xff;
1531 *ptr
++ = (use
>> 8) & 0xff;
1533 *ptr
++ = (use
>> 0) & 0xff;
1540 md_pcrel_from (fixP
)
1544 return fixP
->fx_size
+ fixP
->fx_where
+ fixP
->fx_frag
->fr_address
;
1548 tc_coff_symbol_emit_hook ()
1553 tc_coff_fix2rtype (fix_ptr
)
1556 if (fix_ptr
->fx_r_type
== RELOC_32
)
1558 /* cons likes to create reloc32's whatever the size of the reloc..
1560 switch (fix_ptr
->fx_size
)
1563 return R_H8500_IMM16
;
1566 return R_H8500_IMM8
;
1572 return fix_ptr
->fx_r_type
;
1576 tc_reloc_mangle (fix_ptr
, intr
, base
)
1578 struct internal_reloc
*intr
;
1582 symbolS
*symbol_ptr
;
1584 symbol_ptr
= fix_ptr
->fx_addsy
;
1586 /* If this relocation is attached to a symbol then it's ok
1588 if (fix_ptr
->fx_r_type
== RELOC_32
)
1590 /* cons likes to create reloc32's whatever the size of the reloc..
1592 switch (fix_ptr
->fx_size
)
1595 intr
->r_type
= R_IMM16
;
1598 intr
->r_type
= R_IMM8
;
1606 intr
->r_type
= fix_ptr
->fx_r_type
;
1609 intr
->r_vaddr
= fix_ptr
->fx_frag
->fr_address
+ fix_ptr
->fx_where
+ base
;
1610 intr
->r_offset
= fix_ptr
->fx_offset
;
1612 /* Turn the segment of the symbol into an offset. */
1617 dot
= segment_info
[S_GET_SEGMENT (symbol_ptr
)].dot
;
1620 /* intr->r_offset -=
1621 segment_info[S_GET_SEGMENT(symbol_ptr)].scnhdr.s_paddr;*/
1622 intr
->r_offset
+= S_GET_VALUE (symbol_ptr
);
1623 intr
->r_symndx
= dot
->sy_number
;
1627 intr
->r_symndx
= symbol_ptr
->sy_number
;
1633 intr
->r_symndx
= -1;
1644 /* Check for :s.w */
1645 if (isalpha (ptr
[1]) && ptr
[2] == '.')
1648 if (isalpha (ptr
[1]) && !isalpha (ptr
[2]))
1653 /* end of tc-h8500.c */