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')
273 if (s
[1] == 'h' && s
[2] == 'i' && s
[3] == '1' && s
[4] == '6')
278 else if (s
[1] == 'o' && s
[2] == 'f' && s
[3] == 'f')
285 input_line_pointer
= s
;
288 new = input_line_pointer
;
289 input_line_pointer
= save
;
290 if (SEG_NORMAL (seg
))
301 as_bad ("Missing operand");
304 as_bad ("Don't understand operand of type %s", segment_name (seg
));
311 exp_signed
, exp_unsigned
, exp_sandu
316 skip_colonthing (sign
, ptr
, exp
, def
, size8
, size16
, size24
)
319 h8500_operand_info
*exp
;
325 ptr
= parse_exp (ptr
, &exp
->exp
, &exp
->page
);
334 else if (ptr
[0] == '1' & ptr
[1] == '6')
339 else if (ptr
[0] == '2' & ptr
[1] == '4')
343 as_bad (":24 not valid for this opcode");
350 as_bad ("expect :8,:16 or :24");
356 if (exp
->page
== 'p')
360 else if (exp
->page
== 'h')
366 /* Let's work out the size from the context */
367 int n
= exp
->exp
.X_add_number
;
369 && exp
->exp
.X_seg
== SEG_ABSOLUTE
370 && ((sign
== exp_signed
&& (n
>= -128 && n
<= 127))
371 || (sign
== exp_unsigned
&& (n
>= 0 && (n
<= 255)))
372 || (sign
== exp_sandu
&& (n
>= -128 && (n
<= 255)))))
386 parse_reglist (src
, op
)
388 h8500_operand_info
*op
;
394 int idx
= 1; /* skip ( */
396 while (src
[idx
] && src
[idx
] != ')')
398 int done
= parse_reg (src
+ idx
, &mode
, &rn
);
407 as_bad ("syntax error in reg list");
413 done
= parse_reg (src
+ idx
, &mode
, &rm
);
425 as_bad ("missing final register in range");
432 op
->exp
.X_add_symbol
= 0;
433 op
->exp
.X_subtract_symbol
= 0;
434 op
->exp
.X_add_number
= mask
;
435 op
->exp
.X_seg
= SEG_ABSOLUTE
;
441 /* The many forms of operand:
444 @Rn Register indirect
445 @(disp[:size], Rn) Register indirect with displacement
449 #xx[:size] immediate data
454 get_operand (ptr
, op
, ispage
)
456 h8500_operand_info
*op
;
464 if (src
[0] == '(' && src
[1] == 'r')
466 /* This is a register list */
467 *ptr
= src
+ parse_reglist (src
, op
);
471 len
= parse_reg (src
, &op
->type
, &op
->reg
);
485 len
= parse_reg (src
, &mode
, &num
);
488 /* Oops, not a reg after all, must be ordinary exp */
490 /* must be a symbol */
491 *ptr
= skip_colonthing (exp_unsigned
, src
,
492 op
, ABS16
, ABS8
, ABS16
, ABS24
);
506 src
= skip_colonthing (exp_signed
, src
,
507 op
, RNIND_D16
, RNIND_D8
, RNIND_D16
, 0);
511 as_bad ("expected @(exp, Rn)");
515 len
= parse_reg (src
, &mode
, &op
->reg
);
516 if (len
== 0 || mode
!= RN
)
518 as_bad ("expected @(exp, Rn)");
524 as_bad ("expected @(exp, Rn)");
530 len
= parse_reg (src
, &mode
, &num
);
540 as_bad ("@Rn+ needs word register");
550 as_bad ("@Rn needs word register");
560 /* must be a symbol */
562 skip_colonthing (exp_unsigned
, src
, op
,
563 ispage
? ABS24
: ABS16
, ABS8
, ABS16
, ABS24
);
571 *ptr
= skip_colonthing (exp_sandu
, src
, op
, IMM16
, IMM8
, IMM16
, ABS24
);
576 *ptr
= skip_colonthing (exp_signed
, src
, op
,
577 ispage
? ABS24
: PCREL8
, PCREL8
, PCREL16
, ABS24
);
583 get_operands (info
, args
, operand
)
584 h8500_opcode_info
*info
;
586 h8500_operand_info
*operand
;
600 get_operand (&ptr
, operand
+ 0, info
->name
[0] == 'p');
606 get_operand (&ptr
, operand
+ 0, 0);
609 get_operand (&ptr
, operand
+ 1, 0);
619 /* Passed a pointer to a list of opcodes which use different
620 addressing modes, return the opcode which matches the opcodes
624 int pcrel8
; /* Set when we've seen a pcrel operand */
628 get_specific (opcode
, operands
)
629 h8500_opcode_info
*opcode
;
630 h8500_operand_info
*operands
;
632 h8500_opcode_info
*this_try
= opcode
;
634 unsigned int noperands
= opcode
->nargs
;
636 unsigned int this_index
= opcode
->idx
;
638 while (this_index
== opcode
->idx
&& !found
)
644 /* look at both operands needed by the opcodes and provided by
646 for (i
= 0; i
< noperands
; i
++)
648 h8500_operand_info
*user
= operands
+ i
;
650 switch (this_try
->arg_type
[i
])
653 /* Opcode needs (disp:8,fp) */
654 if (user
->type
== RNIND_D8
&& user
->reg
== 6)
656 displacement
= user
->exp
;
661 if (user
->type
== RNIND_D16
)
663 displacement
= user
->exp
;
669 if (user
->type
== RNIND_D8
)
671 displacement
= user
->exp
;
678 if (user
->type
== this_try
->arg_type
[i
])
680 displacement
= user
->exp
;
687 if (user
->type
== RNDEC
&& user
->reg
== 7)
693 if (user
->type
== RNINC
&& user
->reg
== 7)
699 if (user
->type
== ABS16
)
701 absolute
= user
->exp
;
706 if (user
->type
== ABS8
)
708 absolute
= user
->exp
;
713 if (user
->type
== ABS24
)
715 absolute
= user
->exp
;
721 if ((user
->type
== CRB
|| user
->type
== CR
) && user
->reg
!= 0)
728 if ((user
->type
== CRW
|| user
->type
== CR
) && user
->reg
== 0)
735 if (user
->type
== DISP16
)
737 displacement
= user
->exp
;
742 if (user
->type
== DISP8
)
744 displacement
= user
->exp
;
749 if (user
->type
== RN
&& user
->reg
== 6)
755 if (user
->type
== PCREL16
)
757 displacement
= user
->exp
;
762 if (user
->type
== PCREL8
)
764 displacement
= user
->exp
;
771 if (user
->type
== IMM16
772 || user
->type
== IMM8
)
774 immediate_inpage
= user
->page
;
775 immediate
= user
->exp
;
781 if (user
->type
== IMM8
)
783 immediate_inpage
= user
->page
;
784 immediate
= user
->exp
;
789 if (user
->type
== IMM8
)
791 immediate_inpage
= user
->page
;
792 immediate
= user
->exp
;
797 if (user
->type
== IMM8
798 && user
->exp
.X_seg
== SEG_ABSOLUTE
800 (user
->exp
.X_add_number
== -2
801 || user
->exp
.X_add_number
== -1
802 || user
->exp
.X_add_number
== 1
803 || user
->exp
.X_add_number
== 2))
805 immediate_inpage
= user
->page
;
806 immediate
= user
->exp
;
811 if (user
->type
== RN
)
818 if (user
->type
== RN
)
825 if (user
->type
== RNIND
)
837 if (user
->type
== this_try
->arg_type
[i
])
844 if (user
->type
== RN
&& user
->reg
== 7)
850 printf ("unhandled %d\n", this_try
->arg_type
[i
]);
854 /* If we get here this didn't work out */
869 check (operand
, low
, high
)
870 expressionS
*operand
;
874 if (operand
->X_seg
!= SEG_ABSOLUTE
875 || operand
->X_add_number
< low
876 || operand
->X_add_number
> high
)
878 as_bad ("operand must be absolute in range %d..%d", low
, high
);
880 return operand
->X_add_number
;
885 insert (output
, index
, exp
, reloc
, pcrel
)
893 output
- frag_now
->fr_literal
+ index
,
894 4, /* always say size is 4, but we know better */
896 exp
->X_subtract_symbol
,
903 build_relaxable_instruction (opcode
, operand
)
904 h8500_opcode_info
*opcode
;
905 h8500_operand_info
*operand
;
907 /* All relaxable instructions start life as two bytes but can become
908 three bytes long if a lonely branch and up to 9 bytes if long scb
914 if (opcode
->bytes
[0].contents
== 0x01)
918 else if (opcode
->bytes
[0].contents
== 0x06
919 || opcode
->bytes
[0].contents
== 0x07)
928 p
= frag_var (rs_machine_dependent
,
929 md_relax_table
[C (type
, WORD_DISP
)].rlx_length
,
930 len
= md_relax_table
[C (type
, BYTE_DISP
)].rlx_length
,
931 C (type
, UNDEF_BYTE_DISP
),
932 displacement
.X_add_symbol
,
933 displacement
.X_add_number
,
936 p
[0] = opcode
->bytes
[0].contents
;
939 p
[1] = opcode
->bytes
[1].contents
| rs
;
943 /* Now we know what sort of opcodes it is, lets build the bytes -
946 build_bytes (opcode
, operand
)
947 h8500_opcode_info
*opcode
;
948 h8500_operand_info
*operand
;
956 build_relaxable_instruction (opcode
, operand
);
960 char *output
= frag_more (opcode
->length
);
962 memset (output
, 0, opcode
->length
);
963 for (index
= 0; index
< opcode
->length
; index
++)
965 output
[index
] = opcode
->bytes
[index
].contents
;
967 switch (opcode
->bytes
[index
].insert
)
970 printf ("failed for %d\n", opcode
->bytes
[index
].insert
);
986 insert (output
, index
, &displacement
, R_H8500_IMM16
, 0);
991 insert (output
, index
, &displacement
, R_H8500_IMM8
, 0);
997 switch (immediate_inpage
) {
1009 insert (output
, index
, &immediate
,p
, 0);
1016 if (immediate_inpage
)
1018 insert (output
, index
, &immediate
, R_H8500_HIGH8
, 0);
1022 insert (output
, index
, &immediate
, R_H8500_IMM8
, 0);
1026 insert (output
, index
, &displacement
, R_H8500_PCREL16
, 1);
1030 insert (output
, index
, &displacement
, R_H8500_PCREL8
, 1);
1033 output
[index
] |= check (&immediate
, 0, 15);
1037 output
[index
] |= cr
;
1050 output
[index
] |= crb
;
1054 output
[index
] |= crw
;
1058 insert (output
, index
, &absolute
, R_H8500_IMM24
, 0);
1062 insert (output
, index
, &absolute
, R_H8500_IMM16
, 0);
1066 insert (output
, index
, &absolute
, R_H8500_IMM8
, 0);
1069 switch (immediate
.X_add_number
)
1072 output
[index
] |= 0x5;
1075 output
[index
] |= 0x4;
1090 /* This is the guts of the machine-dependent assembler. STR points to a
1091 machine dependent instruction. This funciton is supposed to emit
1092 the frags/bytes it assembles to.
1096 DEFUN (md_assemble
, (str
),
1101 h8500_operand_info operand
[2];
1102 h8500_opcode_info
*opcode
;
1103 h8500_opcode_info
*prev_opcode
;
1108 /* Drop leading whitespace */
1112 /* find the op code end */
1113 for (op_start
= op_end
= str
;
1115 !is_end_of_line
[*op_end
] && *op_end
!= ' ';
1118 if ( /**op_end != '.'
1122 name
[nlen
++] = *op_end
;
1127 if (op_end
== op_start
)
1129 as_bad ("can't find opcode ");
1132 opcode
= (h8500_opcode_info
*) hash_find (opcode_hash_control
, name
);
1136 as_bad ("unknown opcode");
1140 input_line_pointer
= get_operands (opcode
, op_end
, operand
);
1141 prev_opcode
= opcode
;
1143 opcode
= get_specific (opcode
, operand
);
1147 /* Couldn't find an opcode which matched the operands */
1148 char *where
= frag_more (2);
1152 as_bad ("invalid operands for opcode");
1156 build_bytes (opcode
, operand
);
1161 DEFUN (tc_crawl_symbol_chain
, (headers
),
1162 object_headers
* headers
)
1164 printf ("call to tc_crawl_symbol_chain \n");
1168 DEFUN (md_undefined_symbol
, (name
),
1175 DEFUN (tc_headers_hook
, (headers
),
1176 object_headers
* headers
)
1178 printf ("call to tc_headers_hook \n");
1186 /* Various routines to kill one day */
1187 /* Equal to MAX_PRECISION in atof-ieee.c */
1188 #define MAX_LITTLENUMS 6
1190 /* Turn a string in input_line_pointer into a floating point constant of type
1191 type, and store the appropriate bytes in *litP. The number of LITTLENUMS
1192 emitted is stored in *sizeP . An error message is returned, or NULL on OK.
1195 md_atof (type
, litP
, sizeP
)
1201 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
1202 LITTLENUM_TYPE
*wordP
;
1234 return "Bad call to MD_ATOF()";
1236 t
= atof_ieee (input_line_pointer
, type
, words
);
1238 input_line_pointer
= t
;
1240 *sizeP
= prec
* sizeof (LITTLENUM_TYPE
);
1241 for (wordP
= words
; prec
--;)
1243 md_number_to_chars (litP
, (long) (*wordP
++), sizeof (LITTLENUM_TYPE
));
1244 litP
+= sizeof (LITTLENUM_TYPE
);
1246 return ""; /* Someone should teach Dean about null pointers */
1250 md_parse_option (argP
, cntP
, vecP
)
1259 int md_short_jump_size
;
1262 tc_aout_fix_to_chars ()
1264 printf ("call to tc_aout_fix_to_chars \n");
1269 md_create_short_jump (ptr
, from_addr
, to_addr
, frag
, to_symbol
)
1276 as_fatal ("failed sanity check.");
1280 md_create_long_jump (ptr
, from_addr
, to_addr
, frag
, to_symbol
)
1282 addressT from_addr
, to_addr
;
1286 as_fatal ("failed sanity check.");
1291 wordify_scb (buffer
, disp_size
, inst_size
)
1296 int rn
= buffer
[1] & 0x7;
1300 case 0x0e: /* BSR */
1334 *buffer
++ = 0x26; /* bne + 8 */
1340 *buffer
++ = 0x27; /* bne + 8 */
1345 *buffer
++ = 0xa8 | rn
; /* addq -1,rn */
1347 *buffer
++ = 0x04; /* cmp #0xff:8, rn */
1349 *buffer
++ = 0x70 | rn
;
1350 *buffer
++ = 0x36; /* bne ... */
1356 called after relaxing, change the frags so they know how big they are
1359 md_convert_frag (headers
, fragP
)
1360 object_headers
*headers
;
1366 char *buffer
= fragP
->fr_fix
+ fragP
->fr_literal
;
1368 switch (fragP
->fr_subtype
)
1370 case C (BRANCH
, BYTE_DISP
):
1375 case C (SCB_F
, BYTE_DISP
):
1376 case C (SCB_TST
, BYTE_DISP
):
1381 /* Branches to a known 16 bit displacement */
1383 /* Turn on the 16bit bit */
1384 case C (BRANCH
, WORD_DISP
):
1385 case C (SCB_F
, WORD_DISP
):
1386 case C (SCB_TST
, WORD_DISP
):
1387 wordify_scb (buffer
, &disp_size
, &inst_size
);
1390 case C (BRANCH
, UNDEF_WORD_DISP
):
1391 case C (SCB_F
, UNDEF_WORD_DISP
):
1392 case C (SCB_TST
, UNDEF_WORD_DISP
):
1393 /* This tried to be relaxed, but didn't manage it, it now needs a
1395 wordify_scb (buffer
, &disp_size
, &inst_size
);
1399 fragP
->fr_fix
+ inst_size
,
1407 fragP
->fr_fix
+= disp_size
+ inst_size
;
1416 /* Get the address of the end of the instruction */
1417 int next_inst
= fragP
->fr_fix
+ fragP
->fr_address
+ disp_size
+ inst_size
;
1418 int targ_addr
= (S_GET_VALUE (fragP
->fr_symbol
) +
1420 int disp
= targ_addr
- next_inst
;
1422 md_number_to_chars (buffer
+ inst_size
, disp
, disp_size
);
1423 fragP
->fr_fix
+= disp_size
+ inst_size
;
1430 md_section_align (seg
, size
)
1434 return ((size
+ (1 << section_alignment
[(int) seg
]) - 1)
1435 & (-1 << section_alignment
[(int) seg
]));
1440 md_apply_fix (fixP
, val
)
1444 char *buf
= fixP
->fx_where
+ fixP
->fx_frag
->fr_literal
;
1446 if (fixP
->fx_r_type
== 0)
1448 fixP
->fx_r_type
= fixP
->fx_size
== 4 ? R_H8500_IMM32
: R_H8500_IMM16
;
1451 switch (fixP
->fx_r_type
)
1455 case R_H8500_PCREL8
:
1460 case R_H8500_PCREL16
:
1461 *buf
++ = (val
>> 8);
1467 case R_H8500_HIGH16
:
1472 *buf
++ = (val
>> 16);
1473 *buf
++ = (val
>> 8);
1477 *buf
++ = (val
>> 24);
1478 *buf
++ = (val
>> 16);
1479 *buf
++ = (val
>> 8);
1489 DEFUN (md_operand
, (expressionP
), expressionS
* expressionP
)
1493 int md_long_jump_size
;
1496 called just before address relaxation, return the length
1497 by which a fragment must grow to reach it's destination
1500 md_estimate_size_before_relax (fragP
, segment_type
)
1501 register fragS
*fragP
;
1502 register segT segment_type
;
1504 int what
= GET_WHAT (fragP
->fr_subtype
);
1506 switch (fragP
->fr_subtype
)
1510 case C (BRANCH
, UNDEF_BYTE_DISP
):
1511 case C (SCB_F
, UNDEF_BYTE_DISP
):
1512 case C (SCB_TST
, UNDEF_BYTE_DISP
):
1513 /* used to be a branch to somewhere which was unknown */
1514 if (S_GET_SEGMENT (fragP
->fr_symbol
) == segment_type
)
1516 /* Got a symbol and it's defined in this segment, become byte
1517 sized - maybe it will fix up */
1518 fragP
->fr_subtype
= C (what
, BYTE_DISP
);
1519 fragP
->fr_var
= md_relax_table
[C (what
, BYTE_DISP
)].rlx_length
;
1523 /* Its got a segment, but its not ours, so it will always be long */
1524 fragP
->fr_subtype
= C (what
, UNDEF_WORD_DISP
);
1525 fragP
->fr_var
= md_relax_table
[C (what
, WORD_DISP
)].rlx_length
;
1526 return md_relax_table
[C (what
, WORD_DISP
)].rlx_length
;
1529 return fragP
->fr_var
;
1532 /* Put number into target byte order */
1535 md_number_to_chars (ptr
, use
, nbytes
)
1543 *ptr
++ = (use
>> 24) & 0xff;
1545 *ptr
++ = (use
>> 16) & 0xff;
1547 *ptr
++ = (use
>> 8) & 0xff;
1549 *ptr
++ = (use
>> 0) & 0xff;
1556 md_pcrel_from (fixP
)
1560 return fixP
->fx_size
+ fixP
->fx_where
+ fixP
->fx_frag
->fr_address
;
1564 tc_coff_symbol_emit_hook ()
1569 tc_coff_fix2rtype (fix_ptr
)
1572 if (fix_ptr
->fx_r_type
== RELOC_32
)
1574 /* cons likes to create reloc32's whatever the size of the reloc..
1576 switch (fix_ptr
->fx_size
)
1579 return R_H8500_IMM16
;
1582 return R_H8500_IMM8
;
1588 return fix_ptr
->fx_r_type
;
1592 tc_reloc_mangle (fix_ptr
, intr
, base
)
1594 struct internal_reloc
*intr
;
1598 symbolS
*symbol_ptr
;
1600 symbol_ptr
= fix_ptr
->fx_addsy
;
1602 /* If this relocation is attached to a symbol then it's ok
1604 if (fix_ptr
->fx_r_type
== RELOC_32
)
1606 /* cons likes to create reloc32's whatever the size of the reloc..
1608 switch (fix_ptr
->fx_size
)
1611 intr
->r_type
= R_IMM16
;
1614 intr
->r_type
= R_IMM8
;
1622 intr
->r_type
= fix_ptr
->fx_r_type
;
1625 intr
->r_vaddr
= fix_ptr
->fx_frag
->fr_address
+ fix_ptr
->fx_where
+ base
;
1626 intr
->r_offset
= fix_ptr
->fx_offset
;
1628 /* Turn the segment of the symbol into an offset. */
1633 dot
= segment_info
[S_GET_SEGMENT (symbol_ptr
)].dot
;
1636 /* intr->r_offset -=
1637 segment_info[S_GET_SEGMENT(symbol_ptr)].scnhdr.s_paddr;*/
1638 intr
->r_offset
+= S_GET_VALUE (symbol_ptr
);
1639 intr
->r_symndx
= dot
->sy_number
;
1643 intr
->r_symndx
= symbol_ptr
->sy_number
;
1649 intr
->r_symndx
= -1;
1660 /* Check for :s.w */
1661 if (isalpha (ptr
[1]) && ptr
[2] == '.')
1664 if (isalpha (ptr
[1]) && !isalpha (ptr
[2]))
1669 /* end of tc-h8500.c */