1 /* tc-h8300.c -- Assemble code for the Hitachi H8/300
2 Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98, 2000
3 Free Software Foundation.
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
24 Written By Steve Chamberlain
33 #define h8_opcodes ops
34 #include "opcode/h8300.h"
37 const char comment_chars
[] =
39 const char line_separator_chars
[] =
41 const char line_comment_chars
[] = "#";
43 /* This table describes all the machine specific pseudo-ops the assembler
44 has to support. The fields are:
45 pseudo-op name without dot
46 function to call to execute this pseudo-op
47 Integer arg to pass to the function
54 #define PSIZE (Hmode ? L_32 : L_16)
56 #define DSYMMODE (Hmode ? L_24 : L_16)
57 int bsize
= L_8
; /* default branch displacement */
85 const pseudo_typeS md_pseudo_table
[] =
88 {"h8300h", h8300hmode
, 0},
89 {"h8300s", h8300smode
, 0},
90 {"sbranch", sbranch
, L_8
},
91 {"lbranch", sbranch
, L_16
},
97 {"form", listing_psize
, 0},
98 {"heading", listing_title
, 0},
99 {"import", s_ignore
, 0},
100 {"page", listing_eject
, 0},
101 {"program", s_ignore
, 0},
105 const int md_reloc_size
;
107 const char EXP_CHARS
[] = "eE";
109 /* Chars that mean this number is a floating point constant */
112 const char FLT_CHARS
[] = "rRsSfFdDxXpP";
114 static struct hash_control
*opcode_hash_control
; /* Opcode mnemonics */
117 This function is called once, at assembler startup time. This should
118 set up all the tables, etc that the MD part of the assembler needs
125 struct h8_opcode
*opcode
;
126 char prev_buffer
[100];
129 opcode_hash_control
= hash_new ();
132 for (opcode
= h8_opcodes
; opcode
->name
; opcode
++)
134 /* Strip off any . part when inserting the opcode and only enter
135 unique codes into the hash table
137 char *src
= opcode
->name
;
138 unsigned int len
= strlen (src
);
139 char *dst
= malloc (len
+ 1);
154 if (strcmp (buffer
, prev_buffer
))
156 hash_insert (opcode_hash_control
, buffer
, (char *) opcode
);
157 strcpy (prev_buffer
, buffer
);
163 /* Find the number of operands */
164 opcode
->noperands
= 0;
165 while (opcode
->args
.nib
[opcode
->noperands
] != E
)
167 /* Find the length of the opcode in bytes */
169 while (opcode
->data
.nib
[opcode
->length
* 2] != E
)
184 int opsize
; /* Set when a register size is seen */
196 WREG r0,r1,r2,r3,r4,r5,r6,r7,fp,sp
205 /* try and parse a reg name, returns number of chars consumed */
207 parse_reg (src
, mode
, reg
, direction
)
217 /* Cribbed from get_symbol_end(). */
218 if (!is_name_beginner (*src
) || *src
== '\001')
221 while (is_part_of_name (*end
) || *end
== '\001')
225 if (len
== 2 && src
[0] == 's' && src
[1] == 'p')
227 *mode
= PSIZE
| REG
| direction
;
231 if (len
== 3 && src
[0] == 'c' && src
[1] == 'c' && src
[2] == 'r')
237 if (len
== 3 && src
[0] == 'e' && src
[1] == 'x' && src
[2] == 'r')
243 if (len
== 2 && src
[0] == 'f' && src
[1] == 'p')
245 *mode
= PSIZE
| REG
| direction
;
249 if (len
== 3 && src
[0] == 'e' && src
[1] == 'r'
250 && src
[2] >= '0' && src
[2] <= '7')
252 *mode
= L_32
| REG
| direction
;
255 as_warn (_("Reg not valid for H8/300"));
258 if (len
== 2 && src
[0] == 'e' && src
[1] >= '0' && src
[1] <= '7')
260 *mode
= L_16
| REG
| direction
;
261 *reg
= src
[1] - '0' + 8;
263 as_warn (_("Reg not valid for H8/300"));
269 if (src
[1] >= '0' && src
[1] <= '7')
271 if (len
== 3 && src
[2] == 'l')
273 *mode
= L_8
| REG
| direction
;
274 *reg
= (src
[1] - '0') + 8;
277 if (len
== 3 && src
[2] == 'h')
279 *mode
= L_8
| REG
| direction
;
280 *reg
= (src
[1] - '0');
285 *mode
= L_16
| REG
| direction
;
286 *reg
= (src
[1] - '0');
300 char *save
= input_line_pointer
;
303 input_line_pointer
= s
;
305 if (op
->X_op
== O_absent
)
306 as_bad (_("missing operand"));
307 new = input_line_pointer
;
308 input_line_pointer
= save
;
313 skip_colonthing (ptr
, exp
, mode
)
315 expressionS
*exp ATTRIBUTE_UNUSED
;
325 /* ff fill any 8 bit quantity */
326 /* exp->X_add_number -= 0x100;*/
335 else if (*ptr
== '3')
339 else if (*ptr
== '1')
343 while (isdigit (*ptr
))
350 /* The many forms of operand:
353 @Rn Register indirect
354 @(exp[:16], Rn) Register indirect with displacement
358 @aa:16 absolute 16 bit
361 #xx[:size] immediate data
362 @(exp:[8], pc) pc rel
363 @@aa[:8] memory indirect
374 src
= skip_colonthing (src
, &op
->exp
, &mode
);
378 /* Choose a default mode */
379 if (op
->exp
.X_add_number
< -32768
380 || op
->exp
.X_add_number
> 32767)
387 else if (op
->exp
.X_add_symbol
388 || op
->exp
.X_op_symbol
)
400 get_operand (ptr
, op
, dst
, direction
)
403 unsigned int dst ATTRIBUTE_UNUSED
;
413 /* Gross. Gross. ldm and stm have a format not easily handled
414 by get_operand. We deal with it explicitly here. */
415 if (src
[0] == 'e' && src
[1] == 'r' && isdigit(src
[2])
416 && src
[3] == '-' && src
[4] == 'e' && src
[5] == 'r' && isdigit(src
[6]))
424 as_bad (_("Invalid register list for ldm/stm\n"));
427 as_bad (_("Invalid register list for ldm/stm\n"));
430 as_bad (_("Invalid register list for ldm/stm\n"));
434 as_bad (_("Invalid register list for ldm/stm\n"));
436 /* Even sicker. We encode two registers into op->reg. One
437 for the low register to save, the other for the high
438 register to save; we also set the high bit in op->reg
439 so we know this is "very special". */
440 op
->reg
= 0x80000000 | (high
<< 8) | low
;
446 len
= parse_reg (src
, &op
->mode
, &op
->reg
, direction
);
459 src
= parse_exp (src
, &op
->exp
);
461 src
= skip_colonthing (src
, &op
->exp
, &op
->mode
);
474 len
= parse_reg (src
, &mode
, &num
, direction
);
477 /* Oops, not a reg after all, must be ordinary exp */
479 /* must be a symbol */
480 op
->mode
= ABS
| PSIZE
| direction
;
481 *ptr
= skip_colonthing (parse_exp (src
, &op
->exp
),
482 &op
->exp
, &op
->mode
);
490 if ((mode
& SIZE
) != PSIZE
)
491 as_bad (_("Wrong size pointer register for architecture."));
502 /* Start off assuming a 16 bit offset */
505 src
= parse_exp (src
, &op
->exp
);
507 src
= colonmod24 (op
, src
);
512 op
->mode
|= ABS
| direction
;
519 as_bad (_("expected @(exp, reg16)"));
525 len
= parse_reg (src
, &mode
, &op
->reg
, direction
);
526 if (len
== 0 || !(mode
& REG
))
528 as_bad (_("expected @(exp, reg16)"));
531 op
->mode
|= DISP
| direction
;
534 src
= skip_colonthing (src
, &op
->exp
, &op
->mode
);
536 if (*src
!= ')' && '(')
538 as_bad (_("expected @(exp, reg16)"));
545 len
= parse_reg (src
, &mode
, &num
, direction
);
553 if ((mode
& SIZE
) != PSIZE
)
554 as_bad (_("Wrong size pointer register for architecture."));
560 if ((mode
& SIZE
) != PSIZE
)
561 as_bad (_("Wrong size pointer register for architecture."));
563 op
->mode
= direction
| IND
| PSIZE
;
571 /* must be a symbol */
573 op
->mode
= ABS
| direction
;
574 src
= parse_exp (src
, &op
->exp
);
576 *ptr
= colonmod24 (op
, src
);
587 src
= parse_exp (src
, &op
->exp
);
588 *ptr
= skip_colonthing (src
, &op
->exp
, &op
->mode
);
592 else if (strncmp (src
, "mach", 4) == 0
593 || strncmp (src
, "macl", 4) == 0)
595 op
->reg
= src
[3] == 'l';
602 src
= parse_exp (src
, &op
->exp
);
603 /* Trailing ':' size ? */
606 if (src
[1] == '1' && src
[2] == '6')
608 op
->mode
= PCREL
| L_16
;
611 else if (src
[1] == '8')
613 op
->mode
= PCREL
| L_8
;
618 as_bad (_("expect :8 or :16 here"));
623 op
->mode
= PCREL
| bsize
;
632 get_operands (noperands
, op_end
, operand
)
633 unsigned int noperands
;
635 struct h8_op
*operand
;
648 get_operand (&ptr
, operand
+ 0, 0, SRC
);
652 get_operand (&ptr
, operand
+ 1, 1, DST
);
662 get_operand (&ptr
, operand
+ 0, 0, SRC
);
665 get_operand (&ptr
, operand
+ 1, 1, DST
);
676 /* Passed a pointer to a list of opcodes which use different
677 addressing modes, return the opcode which matches the opcodes
682 get_specific (opcode
, operands
, size
)
683 struct h8_opcode
*opcode
;
684 struct h8_op
*operands
;
687 struct h8_opcode
*this_try
= opcode
;
690 unsigned int this_index
= opcode
->idx
;
692 /* There's only one ldm/stm and it's easier to just
693 get out quick for them. */
694 if (strcmp (opcode
->name
, "stm.l") == 0
695 || strcmp (opcode
->name
, "ldm.l") == 0)
698 while (this_index
== opcode
->idx
&& !found
)
703 if (this_try
->noperands
== 0)
707 this_size
= this_try
->how
& SN
;
708 if (this_size
!= size
&& (this_size
!= SB
|| size
!= SN
))
715 for (i
= 0; i
< this_try
->noperands
&& found
; i
++)
717 op_type op
= this_try
->args
.nib
[i
];
718 int x
= operands
[i
].mode
;
720 if ((op
& (DISP
| REG
)) == (DISP
| REG
)
721 && ((x
& (DISP
| REG
)) == (DISP
| REG
)))
723 dispreg
= operands
[i
].reg
;
731 x
= (x
& ~L_P
) | (Hmode
? L_32
: L_16
);
733 op
= (op
& ~L_P
) | (Hmode
? L_32
: L_16
);
737 /* The size of the reg is v important */
738 if ((op
& SIZE
) != (x
& SIZE
))
741 else if ((op
& ABSJMP
) && (x
& ABS
))
743 operands
[i
].mode
&= ~ABS
;
744 operands
[i
].mode
|= ABSJMP
;
745 /* But it may not be 24 bits long */
748 operands
[i
].mode
&= ~SIZE
;
749 operands
[i
].mode
|= L_16
;
752 else if ((op
& (KBIT
| DBIT
)) && (x
& IMM
))
754 /* This is ok if the immediate value is sensible */
758 /* The size of the displacement is important */
759 if ((op
& SIZE
) != (x
& SIZE
))
762 else if ((op
& (DISP
| IMM
| ABS
))
763 && (op
& (DISP
| IMM
| ABS
)) == (x
& (DISP
| IMM
| ABS
)))
765 /* Promote a L_24 to L_32 if it makes us match. */
766 if ((x
& L_24
) && (op
& L_32
))
771 /* Promote an L8 to L_16 if it makes us match. */
772 if (op
& ABS
&& op
& L_8
&& op
& DISP
)
777 else if ((x
& SIZE
) != 0
778 && ((op
& SIZE
) != (x
& SIZE
)))
781 else if ((op
& MACREG
) != (x
& MACREG
))
785 else if ((op
& MODE
) != (x
& MODE
))
799 check_operand (operand
, width
, string
)
800 struct h8_op
*operand
;
804 if (operand
->exp
.X_add_symbol
== 0
805 && operand
->exp
.X_op_symbol
== 0)
808 /* No symbol involved, let's look at offset, it's dangerous if any of
809 the high bits are not 0 or ff's, find out by oring or anding with
810 the width and seeing if the answer is 0 or all fs*/
812 if ((operand
->exp
.X_add_number
& ~width
) != 0 &&
813 (operand
->exp
.X_add_number
| width
) != (~0))
816 && (operand
->exp
.X_add_number
& 0xff00) == 0xff00)
818 /* Just ignore this one - which happens when trying to
819 fit a 16 bit address truncated into an 8 bit address
820 of something like bset. */
824 as_warn (_("operand %s0x%lx out of range."), string
,
825 (unsigned long) operand
->exp
.X_add_number
);
832 /* RELAXMODE has one of 3 values:
834 0 Output a "normal" reloc, no relaxing possible for this insn/reloc
836 1 Output a relaxable 24bit absolute mov.w address relocation
837 (may relax into a 16bit absolute address).
839 2 Output a relaxable 16/24 absolute mov.b address relocation
840 (may relax into an 8bit absolute address). */
843 do_a_fix_imm (offset
, operand
, relaxmode
)
845 struct h8_op
*operand
;
853 char *t
= operand
->mode
& IMM
? "#" : "@";
855 if (operand
->exp
.X_add_symbol
== 0)
857 char *bytes
= frag_now
->fr_literal
+ offset
;
858 switch (operand
->mode
& SIZE
)
861 check_operand (operand
, 0x3, t
);
862 bytes
[0] |= (operand
->exp
.X_add_number
) << 4;
865 check_operand (operand
, 0x7, t
);
866 bytes
[0] |= (operand
->exp
.X_add_number
) << 4;
869 check_operand (operand
, 0xff, t
);
870 bytes
[0] = operand
->exp
.X_add_number
;
873 check_operand (operand
, 0xffff, t
);
874 bytes
[0] = operand
->exp
.X_add_number
>> 8;
875 bytes
[1] = operand
->exp
.X_add_number
>> 0;
878 check_operand (operand
, 0xffffff, t
);
879 bytes
[0] = operand
->exp
.X_add_number
>> 16;
880 bytes
[1] = operand
->exp
.X_add_number
>> 8;
881 bytes
[2] = operand
->exp
.X_add_number
>> 0;
885 /* This should be done with bfd */
886 bytes
[0] = operand
->exp
.X_add_number
>> 24;
887 bytes
[1] = operand
->exp
.X_add_number
>> 16;
888 bytes
[2] = operand
->exp
.X_add_number
>> 8;
889 bytes
[3] = operand
->exp
.X_add_number
>> 0;
892 idx
= (relaxmode
== 2) ? R_MOV24B1
: R_MOVL1
;
893 fix_new_exp (frag_now
, offset
, 4, &operand
->exp
, 0, idx
);
901 switch (operand
->mode
& SIZE
)
907 where
= (operand
->mode
& SIZE
) == L_24
? -1 : 0;
910 else if (relaxmode
== 1)
916 as_bad(_("Can't work out size of operand.\n"));
924 operand
->exp
.X_add_number
=
925 ((operand
->exp
.X_add_number
& 0xffff) ^ 0x8000) - 0x8000;
931 operand
->exp
.X_add_number
=
932 ((operand
->exp
.X_add_number
& 0xff) ^ 0x80) - 0x80;
935 fix_new_exp (frag_now
,
945 /* Now we know what sort of opcodes it is, lets build the bytes -
948 build_bytes (this_try
, operand
)
949 struct h8_opcode
*this_try
;
950 struct h8_op
*operand
;
954 char *output
= frag_more (this_try
->length
);
955 op_type
*nibble_ptr
= this_try
->data
.nib
;
957 unsigned int nibble_count
= 0;
965 if (!(this_try
->inbase
|| Hmode
))
966 as_warn (_("Opcode `%s' with these operand types not available in H8/300 mode"),
969 while (*nibble_ptr
!= E
)
974 d
= (c
& (DST
| SRC_IN_DST
)) != 0;
983 if (c
& (REG
| IND
| INC
| DEC
))
985 nib
= operand
[d
].reg
;
987 else if ((c
& DISPREG
) == (DISPREG
))
994 absat
= nibble_count
/ 2;
997 else if (c
& (IMM
| PCREL
| ABS
| ABSJMP
| DISP
))
1000 immat
= nibble_count
/ 2;
1003 else if (c
& IGNORE
)
1009 switch (operand
[0].exp
.X_add_number
)
1018 as_bad (_("Need #1 or #2 here"));
1023 switch (operand
[0].exp
.X_add_number
)
1033 as_warn (_("#4 not valid on H8/300."));
1038 as_bad (_("Need #1 or #2 here"));
1041 /* stop it making a fix */
1042 operand
[0].mode
= 0;
1047 operand
[d
].mode
|= MEMRELAX
;
1057 nib
= 2 + operand
[d
].reg
;
1065 /* Disgusting. Why, oh why didn't someone ask us for advice
1066 on the assembler format. */
1067 if (strcmp (this_try
->name
, "stm.l") == 0
1068 || strcmp (this_try
->name
, "ldm.l") == 0)
1071 high
= (operand
[this_try
->name
[0] == 'l' ? 1 : 0].reg
>> 8) & 0xf;
1072 low
= operand
[this_try
->name
[0] == 'l' ? 1 : 0].reg
& 0xf;
1074 asnibbles
[2] = high
- low
;
1075 asnibbles
[7] = (this_try
->name
[0] == 'l') ? high
: low
;
1078 for (i
= 0; i
< this_try
->length
; i
++)
1080 output
[i
] = (asnibbles
[i
* 2] << 4) | asnibbles
[i
* 2 + 1];
1083 /* Note if this is a movb instruction -- there's a special relaxation
1084 which only applies to them. */
1085 if (strcmp (this_try
->name
, "mov.b") == 0)
1088 /* output any fixes */
1089 for (i
= 0; i
< 2; i
++)
1091 int x
= operand
[i
].mode
;
1093 if (x
& (IMM
| DISP
))
1095 do_a_fix_imm (output
- frag_now
->fr_literal
+ immat
,
1096 operand
+ i
, x
& MEMRELAX
!= 0);
1100 do_a_fix_imm (output
- frag_now
->fr_literal
+ absat
,
1101 operand
+ i
, x
& MEMRELAX
? movb
+ 1 : 0);
1105 int size16
= x
& L_16
;
1106 int where
= size16
? 2 : 1;
1107 int size
= size16
? 2 : 1;
1108 int type
= size16
? R_PCRWORD
: R_PCRBYTE
;
1110 check_operand (operand
+ i
, size16
? 0x7fff : 0x7f, "@");
1112 if (operand
[i
].exp
.X_add_number
& 1)
1114 as_warn (_("branch operand has odd offset (%lx)\n"),
1115 (unsigned long) operand
->exp
.X_add_number
);
1118 operand
[i
].exp
.X_add_number
-= 1;
1119 operand
[i
].exp
.X_add_number
=
1120 ((operand
[i
].exp
.X_add_number
& 0xff) ^ 0x80) - 0x80;
1122 fix_new_exp (frag_now
,
1123 output
- frag_now
->fr_literal
+ where
,
1129 else if (x
& MEMIND
)
1132 check_operand (operand
+ i
, 0xff, "@@");
1133 fix_new_exp (frag_now
,
1134 output
- frag_now
->fr_literal
+ 1,
1140 else if (x
& ABSJMP
)
1142 /* This jmp may be a jump or a branch */
1144 check_operand (operand
+ i
, Hmode
? 0xffffff : 0xffff, "@");
1145 if (operand
[i
].exp
.X_add_number
& 1)
1147 as_warn (_("branch operand has odd offset (%lx)\n"),
1148 (unsigned long) operand
->exp
.X_add_number
);
1151 operand
[i
].exp
.X_add_number
=
1152 ((operand
[i
].exp
.X_add_number
& 0xffff) ^ 0x8000) - 0x8000;
1153 fix_new_exp (frag_now
,
1154 output
- frag_now
->fr_literal
,
1165 try and give an intelligent error message for common and simple to
1170 clever_message (opcode
, operand
)
1171 struct h8_opcode
*opcode
;
1172 struct h8_op
*operand
;
1174 /* Find out if there was more than one possible opccode */
1176 if ((opcode
+ 1)->idx
!= opcode
->idx
)
1180 /* Only one opcode of this flavour, try and guess which operand
1182 for (argn
= 0; argn
< opcode
->noperands
; argn
++)
1184 switch (opcode
->args
.nib
[argn
])
1187 if (operand
[argn
].mode
!= RD16
)
1189 as_bad (_("destination operand must be 16 bit register"));
1197 if (operand
[argn
].mode
!= RS8
)
1199 as_bad (_("source operand must be 8 bit register"));
1205 if (operand
[argn
].mode
!= ABS16DST
)
1207 as_bad (_("destination operand must be 16bit absolute address"));
1212 if (operand
[argn
].mode
!= RD8
)
1214 as_bad (_("destination operand must be 8 bit register"));
1221 if (operand
[argn
].mode
!= ABS16SRC
)
1223 as_bad (_("source operand must be 16bit absolute address"));
1231 as_bad (_("invalid operands"));
1234 /* This is the guts of the machine-dependent assembler. STR points to a
1235 machine dependent instruction. This funciton is supposed to emit
1236 the frags/bytes it assembles to.
1247 struct h8_op operand
[2];
1248 struct h8_opcode
*opcode
;
1249 struct h8_opcode
*prev_opcode
;
1255 /* Drop leading whitespace */
1259 /* find the op code end */
1260 for (op_start
= op_end
= str
;
1261 *op_end
!= 0 && *op_end
!= ' ';
1275 if (op_end
== op_start
)
1277 as_bad (_("can't find opcode "));
1283 opcode
= (struct h8_opcode
*) hash_find (opcode_hash_control
,
1288 as_bad (_("unknown opcode"));
1292 /* We use to set input_line_pointer to the result of get_operands,
1293 but that is wrong. Our caller assumes we don't change it. */
1295 (void) get_operands (opcode
->noperands
, op_end
, operand
);
1297 prev_opcode
= opcode
;
1317 opcode
= get_specific (opcode
, operand
, size
);
1321 /* Couldn't find an opcode which matched the operands */
1322 char *where
= frag_more (2);
1326 clever_message (prev_opcode
, operand
);
1330 if (opcode
->size
&& dot
)
1332 if (opcode
->size
!= *dot
)
1334 as_warn (_("mismatch between opcode size and operand size"));
1338 build_bytes (opcode
, operand
);
1343 tc_crawl_symbol_chain (headers
)
1344 object_headers
* headers ATTRIBUTE_UNUSED
;
1346 printf (_("call to tc_crawl_symbol_chain \n"));
1350 md_undefined_symbol (name
)
1351 char *name ATTRIBUTE_UNUSED
;
1357 tc_headers_hook (headers
)
1358 object_headers
* headers ATTRIBUTE_UNUSED
;
1360 printf (_("call to tc_headers_hook \n"));
1363 /* Various routines to kill one day */
1364 /* Equal to MAX_PRECISION in atof-ieee.c */
1365 #define MAX_LITTLENUMS 6
1367 /* Turn a string in input_line_pointer into a floating point constant of type
1368 type, and store the appropriate bytes in *litP. The number of LITTLENUMS
1369 emitted is stored in *sizeP . An error message is returned, or NULL on OK.
1372 md_atof (type
, litP
, sizeP
)
1378 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
1379 LITTLENUM_TYPE
*wordP
;
1411 return _("Bad call to MD_ATOF()");
1413 t
= atof_ieee (input_line_pointer
, type
, words
);
1415 input_line_pointer
= t
;
1417 *sizeP
= prec
* sizeof (LITTLENUM_TYPE
);
1418 for (wordP
= words
; prec
--;)
1420 md_number_to_chars (litP
, (long) (*wordP
++), sizeof (LITTLENUM_TYPE
));
1421 litP
+= sizeof (LITTLENUM_TYPE
);
1426 CONST
char *md_shortopts
= "";
1427 struct option md_longopts
[] = {
1428 {NULL
, no_argument
, NULL
, 0}
1430 size_t md_longopts_size
= sizeof(md_longopts
);
1433 md_parse_option (c
, arg
)
1434 int c ATTRIBUTE_UNUSED
;
1435 char *arg ATTRIBUTE_UNUSED
;
1441 md_show_usage (stream
)
1442 FILE *stream ATTRIBUTE_UNUSED
;
1447 tc_aout_fix_to_chars ()
1449 printf (_("call to tc_aout_fix_to_chars \n"));
1454 md_convert_frag (headers
, seg
, fragP
)
1455 object_headers
*headers ATTRIBUTE_UNUSED
;
1456 segT seg ATTRIBUTE_UNUSED
;
1457 fragS
*fragP ATTRIBUTE_UNUSED
;
1459 printf (_("call to md_convert_frag \n"));
1464 md_section_align (seg
, size
)
1468 return ((size
+ (1 << section_alignment
[(int) seg
]) - 1) & (-1 << section_alignment
[(int) seg
]));
1473 md_apply_fix (fixP
, val
)
1477 char *buf
= fixP
->fx_where
+ fixP
->fx_frag
->fr_literal
;
1479 switch (fixP
->fx_size
)
1485 *buf
++ = (val
>> 8);
1489 *buf
++ = (val
>> 24);
1490 *buf
++ = (val
>> 16);
1491 *buf
++ = (val
>> 8);
1500 md_estimate_size_before_relax (fragP
, segment_type
)
1501 register fragS
*fragP ATTRIBUTE_UNUSED
;
1502 register segT segment_type ATTRIBUTE_UNUSED
;
1504 printf (_("call tomd_estimate_size_before_relax \n"));
1508 /* Put number into target byte order */
1511 md_number_to_chars (ptr
, use
, nbytes
)
1516 number_to_chars_bigendian (ptr
, use
, nbytes
);
1519 md_pcrel_from (fixP
)
1520 fixS
*fixP ATTRIBUTE_UNUSED
;
1527 tc_reloc_mangle (fix_ptr
, intr
, base
)
1529 struct internal_reloc
*intr
;
1533 symbolS
*symbol_ptr
;
1535 symbol_ptr
= fix_ptr
->fx_addsy
;
1537 /* If this relocation is attached to a symbol then it's ok
1539 if (fix_ptr
->fx_r_type
== TC_CONS_RELOC
)
1541 /* cons likes to create reloc32's whatever the size of the reloc..
1543 switch (fix_ptr
->fx_size
)
1546 intr
->r_type
= R_RELLONG
;
1549 intr
->r_type
= R_RELWORD
;
1552 intr
->r_type
= R_RELBYTE
;
1562 intr
->r_type
= fix_ptr
->fx_r_type
;
1565 intr
->r_vaddr
= fix_ptr
->fx_frag
->fr_address
+ fix_ptr
->fx_where
+ base
;
1566 intr
->r_offset
= fix_ptr
->fx_offset
;
1570 if (symbol_ptr
->sy_number
!= -1)
1571 intr
->r_symndx
= symbol_ptr
->sy_number
;
1576 /* This case arises when a reference is made to `.'. */
1577 segsym
= seg_info (S_GET_SEGMENT (symbol_ptr
))->dot
;
1579 intr
->r_symndx
= -1;
1582 intr
->r_symndx
= segsym
->sy_number
;
1583 intr
->r_offset
+= S_GET_VALUE (symbol_ptr
);
1588 intr
->r_symndx
= -1;
1593 /* end of tc-h8300.c */