1 /* tc-h8300.c -- Assemble code for the Hitachi H8/300
2 Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 1998 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
23 Written By Steve Chamberlain
32 #define h8_opcodes ops
33 #include "opcode/h8300.h"
36 const char comment_chars
[] =
38 const char line_separator_chars
[] =
40 const char line_comment_chars
[] = "#";
42 /* This table describes all the machine specific pseudo-ops the assembler
43 has to support. The fields are:
44 pseudo-op name without dot
45 function to call to execute this pseudo-op
46 Integer arg to pass to the function
53 #define PSIZE (Hmode ? L_32 : L_16)
55 #define DSYMMODE (Hmode ? L_24 : L_16)
56 int bsize
= L_8
; /* default branch displacement */
84 const pseudo_typeS md_pseudo_table
[] =
87 {"h8300h", h8300hmode
, 0},
88 {"h8300s", h8300smode
, 0},
89 {"sbranch", sbranch
, L_8
},
90 {"lbranch", sbranch
, L_16
},
96 {"form", listing_psize
, 0},
97 {"heading", listing_title
, 0},
98 {"import", s_ignore
, 0},
99 {"page", listing_eject
, 0},
100 {"program", s_ignore
, 0},
104 const int md_reloc_size
;
106 const char EXP_CHARS
[] = "eE";
108 /* Chars that mean this number is a floating point constant */
111 const char FLT_CHARS
[] = "rRsSfFdDxXpP";
113 static struct hash_control
*opcode_hash_control
; /* Opcode mnemonics */
116 This function is called once, at assembler startup time. This should
117 set up all the tables, etc that the MD part of the assembler needs
124 struct h8_opcode
*opcode
;
125 char prev_buffer
[100];
128 opcode_hash_control
= hash_new ();
131 for (opcode
= h8_opcodes
; opcode
->name
; opcode
++)
133 /* Strip off any . part when inserting the opcode and only enter
134 unique codes into the hash table
136 char *src
= opcode
->name
;
137 unsigned int len
= strlen (src
);
138 char *dst
= malloc (len
+ 1);
153 if (strcmp (buffer
, prev_buffer
))
155 hash_insert (opcode_hash_control
, buffer
, (char *) opcode
);
156 strcpy (prev_buffer
, buffer
);
162 /* Find the number of operands */
163 opcode
->noperands
= 0;
164 while (opcode
->args
.nib
[opcode
->noperands
] != E
)
166 /* Find the length of the opcode in bytes */
168 while (opcode
->data
.nib
[opcode
->length
* 2] != E
)
183 int opsize
; /* Set when a register size is seen */
195 WREG r0,r1,r2,r3,r4,r5,r6,r7,fp,sp
204 /* try and parse a reg name, returns number of chars consumed */
206 parse_reg (src
, mode
, reg
, direction
)
216 /* Cribbed from get_symbol_end(). */
217 if (!is_name_beginner (*src
) || *src
== '\001')
220 while (is_part_of_name (*end
) || *end
== '\001')
224 if (len
== 2 && src
[0] == 's' && src
[1] == 'p')
226 *mode
= PSIZE
| REG
| direction
;
230 if (len
== 3 && src
[0] == 'c' && src
[1] == 'c' && src
[2] == 'r')
236 if (len
== 3 && src
[0] == 'e' && src
[1] == 'x' && src
[2] == 'r')
242 if (len
== 2 && src
[0] == 'f' && src
[1] == 'p')
244 *mode
= PSIZE
| REG
| direction
;
248 if (len
== 3 && src
[0] == 'e' && src
[1] == 'r'
249 && src
[2] >= '0' && src
[2] <= '7')
251 *mode
= L_32
| REG
| direction
;
254 as_warn (_("Reg not valid for H8/300"));
257 if (len
== 2 && src
[0] == 'e' && src
[1] >= '0' && src
[1] <= '7')
259 *mode
= L_16
| REG
| direction
;
260 *reg
= src
[1] - '0' + 8;
262 as_warn (_("Reg not valid for H8/300"));
268 if (src
[1] >= '0' && src
[1] <= '7')
270 if (len
== 3 && src
[2] == 'l')
272 *mode
= L_8
| REG
| direction
;
273 *reg
= (src
[1] - '0') + 8;
276 if (len
== 3 && src
[2] == 'h')
278 *mode
= L_8
| REG
| direction
;
279 *reg
= (src
[1] - '0');
284 *mode
= L_16
| REG
| direction
;
285 *reg
= (src
[1] - '0');
299 char *save
= input_line_pointer
;
302 input_line_pointer
= s
;
304 if (op
->X_op
== O_absent
)
305 as_bad (_("missing operand"));
306 new = input_line_pointer
;
307 input_line_pointer
= save
;
312 skip_colonthing (ptr
, exp
, mode
)
324 /* ff fill any 8 bit quantity */
325 /* exp->X_add_number -= 0x100;*/
334 else if (*ptr
== '3')
338 else if (*ptr
== '1')
342 while (isdigit (*ptr
))
349 /* The many forms of operand:
352 @Rn Register indirect
353 @(exp[:16], Rn) Register indirect with displacement
357 @aa:16 absolute 16 bit
360 #xx[:size] immediate data
361 @(exp:[8], pc) pc rel
362 @@aa[:8] memory indirect
373 src
= skip_colonthing (src
, &op
->exp
, &mode
);
377 /* Choose a default mode */
378 if (op
->exp
.X_add_number
< -32768
379 || op
->exp
.X_add_number
> 32767)
386 else if (op
->exp
.X_add_symbol
387 || op
->exp
.X_op_symbol
)
399 get_operand (ptr
, op
, dst
, direction
)
412 /* Gross. Gross. ldm and stm have a format not easily handled
413 by get_operand. We deal with it explicitly here. */
414 if (src
[0] == 'e' && src
[1] == 'r' && isdigit(src
[2])
415 && src
[3] == '-' && src
[4] == 'e' && src
[5] == 'r' && isdigit(src
[6]))
423 as_bad (_("Invalid register list for ldm/stm\n"));
426 as_bad (_("Invalid register list for ldm/stm\n"));
429 as_bad (_("Invalid register list for ldm/stm\n"));
433 as_bad (_("Invalid register list for ldm/stm\n"));
435 /* Even sicker. We encode two registers into op->reg. One
436 for the low register to save, the other for the high
437 register to save; we also set the high bit in op->reg
438 so we know this is "very special". */
439 op
->reg
= 0x80000000 | (high
<< 8) | low
;
445 len
= parse_reg (src
, &op
->mode
, &op
->reg
, direction
);
458 src
= parse_exp (src
, &op
->exp
);
460 src
= skip_colonthing (src
, &op
->exp
, &op
->mode
);
473 len
= parse_reg (src
, &mode
, &num
, direction
);
476 /* Oops, not a reg after all, must be ordinary exp */
478 /* must be a symbol */
479 op
->mode
= ABS
| PSIZE
| direction
;
480 *ptr
= skip_colonthing (parse_exp (src
, &op
->exp
),
481 &op
->exp
, &op
->mode
);
489 if ((mode
& SIZE
) != PSIZE
)
490 as_bad (_("Wrong size pointer register for architecture."));
501 /* Start off assuming a 16 bit offset */
504 src
= parse_exp (src
, &op
->exp
);
506 src
= colonmod24 (op
, src
);
511 op
->mode
|= ABS
| direction
;
518 as_bad (_("expected @(exp, reg16)"));
524 len
= parse_reg (src
, &mode
, &op
->reg
, direction
);
525 if (len
== 0 || !(mode
& REG
))
527 as_bad (_("expected @(exp, reg16)"));
530 op
->mode
|= DISP
| direction
;
533 src
= skip_colonthing (src
, &op
->exp
, &op
->mode
);
535 if (*src
!= ')' && '(')
537 as_bad (_("expected @(exp, reg16)"));
544 len
= parse_reg (src
, &mode
, &num
, direction
);
552 if ((mode
& SIZE
) != PSIZE
)
553 as_bad (_("Wrong size pointer register for architecture."));
559 if ((mode
& SIZE
) != PSIZE
)
560 as_bad (_("Wrong size pointer register for architecture."));
562 op
->mode
= direction
| IND
| PSIZE
;
570 /* must be a symbol */
572 op
->mode
= ABS
| direction
;
573 src
= parse_exp (src
, &op
->exp
);
575 *ptr
= colonmod24 (op
, src
);
586 src
= parse_exp (src
, &op
->exp
);
587 *ptr
= skip_colonthing (src
, &op
->exp
, &op
->mode
);
591 else if (strncmp (src
, "mach", 4) == 0
592 || strncmp (src
, "macl", 4) == 0)
594 op
->reg
= src
[3] == 'l';
601 src
= parse_exp (src
, &op
->exp
);
602 /* Trailing ':' size ? */
605 if (src
[1] == '1' && src
[2] == '6')
607 op
->mode
= PCREL
| L_16
;
610 else if (src
[1] == '8')
612 op
->mode
= PCREL
| L_8
;
617 as_bad (_("expect :8 or :16 here"));
622 op
->mode
= PCREL
| bsize
;
631 get_operands (noperands
, op_end
, operand
)
632 unsigned int noperands
;
634 struct h8_op
*operand
;
647 get_operand (&ptr
, operand
+ 0, 0, SRC
);
651 get_operand (&ptr
, operand
+ 1, 1, DST
);
661 get_operand (&ptr
, operand
+ 0, 0, SRC
);
664 get_operand (&ptr
, operand
+ 1, 1, DST
);
675 /* Passed a pointer to a list of opcodes which use different
676 addressing modes, return the opcode which matches the opcodes
681 get_specific (opcode
, operands
, size
)
682 struct h8_opcode
*opcode
;
683 struct h8_op
*operands
;
686 struct h8_opcode
*this_try
= opcode
;
689 unsigned int this_index
= opcode
->idx
;
691 /* There's only one ldm/stm and it's easier to just
692 get out quick for them. */
693 if (strcmp (opcode
->name
, "stm.l") == 0
694 || strcmp (opcode
->name
, "ldm.l") == 0)
697 while (this_index
== opcode
->idx
&& !found
)
702 if (this_try
->noperands
== 0)
706 this_size
= this_try
->how
& SN
;
707 if (this_size
!= size
&& (this_size
!= SB
|| size
!= SN
))
714 for (i
= 0; i
< this_try
->noperands
&& found
; i
++)
716 op_type op
= this_try
->args
.nib
[i
];
717 int x
= operands
[i
].mode
;
719 if ((op
& (DISP
| REG
)) == (DISP
| REG
)
720 && ((x
& (DISP
| REG
)) == (DISP
| REG
)))
722 dispreg
= operands
[i
].reg
;
730 x
= (x
& ~L_P
) | (Hmode
? L_32
: L_16
);
732 op
= (op
& ~L_P
) | (Hmode
? L_32
: L_16
);
736 /* The size of the reg is v important */
737 if ((op
& SIZE
) != (x
& SIZE
))
740 else if ((op
& ABSJMP
) && (x
& ABS
))
742 operands
[i
].mode
&= ~ABS
;
743 operands
[i
].mode
|= ABSJMP
;
744 /* But it may not be 24 bits long */
747 operands
[i
].mode
&= ~SIZE
;
748 operands
[i
].mode
|= L_16
;
751 else if ((op
& (KBIT
| DBIT
)) && (x
& IMM
))
753 /* This is ok if the immediate value is sensible */
757 /* The size of the displacement is important */
758 if ((op
& SIZE
) != (x
& SIZE
))
761 else if ((op
& (DISP
| IMM
| ABS
))
762 && (op
& (DISP
| IMM
| ABS
)) == (x
& (DISP
| IMM
| ABS
)))
764 /* Promote a L_24 to L_32 if it makes us match. */
765 if ((x
& L_24
) && (op
& L_32
))
770 /* Promote an L8 to L_16 if it makes us match. */
771 if (op
& ABS
&& op
& L_8
&& op
& DISP
)
776 else if ((x
& SIZE
) != 0
777 && ((op
& SIZE
) != (x
& SIZE
)))
780 else if ((op
& MACREG
) != (x
& MACREG
))
784 else if ((op
& MODE
) != (x
& MODE
))
798 check_operand (operand
, width
, string
)
799 struct h8_op
*operand
;
803 if (operand
->exp
.X_add_symbol
== 0
804 && operand
->exp
.X_op_symbol
== 0)
807 /* No symbol involved, let's look at offset, it's dangerous if any of
808 the high bits are not 0 or ff's, find out by oring or anding with
809 the width and seeing if the answer is 0 or all fs*/
811 if ((operand
->exp
.X_add_number
& ~width
) != 0 &&
812 (operand
->exp
.X_add_number
| width
) != (~0))
815 && (operand
->exp
.X_add_number
& 0xff00) == 0xff00)
817 /* Just ignore this one - which happens when trying to
818 fit a 16 bit address truncated into an 8 bit address
819 of something like bset. */
823 as_warn (_("operand %s0x%lx out of range."), string
,
824 (unsigned long) operand
->exp
.X_add_number
);
831 /* RELAXMODE has one of 3 values:
833 0 Output a "normal" reloc, no relaxing possible for this insn/reloc
835 1 Output a relaxable 24bit absolute mov.w address relocation
836 (may relax into a 16bit absolute address).
838 2 Output a relaxable 16/24 absolute mov.b address relocation
839 (may relax into an 8bit absolute address). */
842 do_a_fix_imm (offset
, operand
, relaxmode
)
844 struct h8_op
*operand
;
852 char *t
= operand
->mode
& IMM
? "#" : "@";
854 if (operand
->exp
.X_add_symbol
== 0)
856 char *bytes
= frag_now
->fr_literal
+ offset
;
857 switch (operand
->mode
& SIZE
)
860 check_operand (operand
, 0x3, t
);
861 bytes
[0] |= (operand
->exp
.X_add_number
) << 4;
864 check_operand (operand
, 0x7, t
);
865 bytes
[0] |= (operand
->exp
.X_add_number
) << 4;
868 check_operand (operand
, 0xff, t
);
869 bytes
[0] = operand
->exp
.X_add_number
;
872 check_operand (operand
, 0xffff, t
);
873 bytes
[0] = operand
->exp
.X_add_number
>> 8;
874 bytes
[1] = operand
->exp
.X_add_number
>> 0;
877 check_operand (operand
, 0xffffff, t
);
878 bytes
[0] = operand
->exp
.X_add_number
>> 16;
879 bytes
[1] = operand
->exp
.X_add_number
>> 8;
880 bytes
[2] = operand
->exp
.X_add_number
>> 0;
884 /* This should be done with bfd */
885 bytes
[0] = operand
->exp
.X_add_number
>> 24;
886 bytes
[1] = operand
->exp
.X_add_number
>> 16;
887 bytes
[2] = operand
->exp
.X_add_number
>> 8;
888 bytes
[3] = operand
->exp
.X_add_number
>> 0;
895 switch (operand
->mode
& SIZE
)
901 where
= (operand
->mode
& SIZE
) == L_24
? -1 : 0;
904 else if (relaxmode
== 1)
910 as_bad(_("Can't work out size of operand.\n"));
918 operand
->exp
.X_add_number
= (short)operand
->exp
.X_add_number
;
924 /* This used to use a cast to char, but that fails if char is an
925 unsigned type. We can't use `signed char', as that isn't valid
927 if (operand
->exp
.X_add_number
& 0x80)
928 operand
->exp
.X_add_number
|= ((offsetT
) -1 << 8);
930 operand
->exp
.X_add_number
&= 0xff;
933 fix_new_exp (frag_now
,
943 /* Now we know what sort of opcodes it is, lets build the bytes -
946 build_bytes (this_try
, operand
)
947 struct h8_opcode
*this_try
;
948 struct h8_op
*operand
;
952 char *output
= frag_more (this_try
->length
);
953 op_type
*nibble_ptr
= this_try
->data
.nib
;
955 unsigned int nibble_count
= 0;
963 if (!(this_try
->inbase
|| Hmode
))
964 as_warn (_("Opcode `%s' with these operand types not available in H8/300 mode"),
967 while (*nibble_ptr
!= E
)
972 d
= (c
& (DST
| SRC_IN_DST
)) != 0;
981 if (c
& (REG
| IND
| INC
| DEC
))
983 nib
= operand
[d
].reg
;
985 else if ((c
& DISPREG
) == (DISPREG
))
992 absat
= nibble_count
/ 2;
995 else if (c
& (IMM
| PCREL
| ABS
| ABSJMP
| DISP
))
998 immat
= nibble_count
/ 2;
1001 else if (c
& IGNORE
)
1007 switch (operand
[0].exp
.X_add_number
)
1016 as_bad (_("Need #1 or #2 here"));
1021 switch (operand
[0].exp
.X_add_number
)
1031 as_warn (_("#4 not valid on H8/300."));
1036 as_bad (_("Need #1 or #2 here"));
1039 /* stop it making a fix */
1040 operand
[0].mode
= 0;
1045 operand
[d
].mode
|= MEMRELAX
;
1055 nib
= 2 + operand
[d
].reg
;
1063 /* Disgusting. Why, oh why didn't someone ask us for advice
1064 on the assembler format. */
1065 if (strcmp (this_try
->name
, "stm.l") == 0
1066 || strcmp (this_try
->name
, "ldm.l") == 0)
1069 high
= (operand
[this_try
->name
[0] == 'l' ? 1 : 0].reg
>> 8) & 0xf;
1070 low
= operand
[this_try
->name
[0] == 'l' ? 1 : 0].reg
& 0xf;
1072 asnibbles
[2] = high
- low
;
1073 asnibbles
[7] = (this_try
->name
[0] == 'l') ? high
: low
;
1076 for (i
= 0; i
< this_try
->length
; i
++)
1078 output
[i
] = (asnibbles
[i
* 2] << 4) | asnibbles
[i
* 2 + 1];
1081 /* Note if this is a movb instruction -- there's a special relaxation
1082 which only applies to them. */
1083 if (strcmp (this_try
->name
, "mov.b") == 0)
1086 /* output any fixes */
1087 for (i
= 0; i
< 2; i
++)
1089 int x
= operand
[i
].mode
;
1091 if (x
& (IMM
| DISP
))
1093 do_a_fix_imm (output
- frag_now
->fr_literal
+ immat
,
1094 operand
+ i
, x
& MEMRELAX
!= 0);
1098 do_a_fix_imm (output
- frag_now
->fr_literal
+ absat
,
1099 operand
+ i
, x
& MEMRELAX
? movb
+ 1 : 0);
1103 int size16
= x
& L_16
;
1104 int where
= size16
? 2 : 1;
1105 int size
= size16
? 2 : 1;
1106 int type
= size16
? R_PCRWORD
: R_PCRBYTE
;
1108 check_operand (operand
+ i
, size16
? 0x7fff : 0x7f, "@");
1110 if (operand
[i
].exp
.X_add_number
& 1)
1112 as_warn (_("branch operand has odd offset (%lx)\n"),
1113 (unsigned long) operand
->exp
.X_add_number
);
1116 operand
[i
].exp
.X_add_number
-= 1;
1117 /* This used to use a cast to char, but that fails if char is an
1118 unsigned type. We can't use `signed char', as that isn't valid
1120 if (operand
[i
].exp
.X_add_number
& 0x80)
1121 operand
[i
].exp
.X_add_number
|= ((offsetT
) -1 << 8);
1123 operand
[i
].exp
.X_add_number
&= 0xff;
1125 fix_new_exp (frag_now
,
1126 output
- frag_now
->fr_literal
+ where
,
1132 else if (x
& MEMIND
)
1135 check_operand (operand
+ i
, 0xff, "@@");
1136 fix_new_exp (frag_now
,
1137 output
- frag_now
->fr_literal
+ 1,
1143 else if (x
& ABSJMP
)
1145 /* This jmp may be a jump or a branch */
1147 check_operand (operand
+ i
, Hmode
? 0xffffff : 0xffff, "@");
1148 if (operand
[i
].exp
.X_add_number
& 1)
1150 as_warn (_("branch operand has odd offset (%lx)\n"),
1151 (unsigned long) operand
->exp
.X_add_number
);
1154 operand
[i
].exp
.X_add_number
= (short) operand
[i
].exp
.X_add_number
;
1155 fix_new_exp (frag_now
,
1156 output
- frag_now
->fr_literal
,
1167 try and give an intelligent error message for common and simple to
1172 clever_message (opcode
, operand
)
1173 struct h8_opcode
*opcode
;
1174 struct h8_op
*operand
;
1176 /* Find out if there was more than one possible opccode */
1178 if ((opcode
+ 1)->idx
!= opcode
->idx
)
1182 /* Only one opcode of this flavour, try and guess which operand
1184 for (argn
= 0; argn
< opcode
->noperands
; argn
++)
1186 switch (opcode
->args
.nib
[argn
])
1189 if (operand
[argn
].mode
!= RD16
)
1191 as_bad (_("destination operand must be 16 bit register"));
1199 if (operand
[argn
].mode
!= RS8
)
1201 as_bad (_("source operand must be 8 bit register"));
1207 if (operand
[argn
].mode
!= ABS16DST
)
1209 as_bad (_("destination operand must be 16bit absolute address"));
1214 if (operand
[argn
].mode
!= RD8
)
1216 as_bad (_("destination operand must be 8 bit register"));
1223 if (operand
[argn
].mode
!= ABS16SRC
)
1225 as_bad (_("source operand must be 16bit absolute address"));
1233 as_bad (_("invalid operands"));
1236 /* This is the guts of the machine-dependent assembler. STR points to a
1237 machine dependent instruction. This funciton is supposed to emit
1238 the frags/bytes it assembles to.
1249 struct h8_op operand
[2];
1250 struct h8_opcode
*opcode
;
1251 struct h8_opcode
*prev_opcode
;
1257 /* Drop leading whitespace */
1261 /* find the op code end */
1262 for (op_start
= op_end
= str
;
1263 *op_end
!= 0 && *op_end
!= ' ';
1277 if (op_end
== op_start
)
1279 as_bad (_("can't find opcode "));
1285 opcode
= (struct h8_opcode
*) hash_find (opcode_hash_control
,
1290 as_bad (_("unknown opcode"));
1294 /* We use to set input_line_pointer to the result of get_operands,
1295 but that is wrong. Our caller assumes we don't change it. */
1297 (void) get_operands (opcode
->noperands
, op_end
, operand
);
1299 prev_opcode
= opcode
;
1319 opcode
= get_specific (opcode
, operand
, size
);
1323 /* Couldn't find an opcode which matched the operands */
1324 char *where
= frag_more (2);
1328 clever_message (prev_opcode
, operand
);
1332 if (opcode
->size
&& dot
)
1334 if (opcode
->size
!= *dot
)
1336 as_warn (_("mismatch between opcode size and operand size"));
1340 build_bytes (opcode
, operand
);
1345 tc_crawl_symbol_chain (headers
)
1346 object_headers
* headers
;
1348 printf (_("call to tc_crawl_symbol_chain \n"));
1352 md_undefined_symbol (name
)
1359 tc_headers_hook (headers
)
1360 object_headers
* headers
;
1362 printf (_("call to tc_headers_hook \n"));
1365 /* Various routines to kill one day */
1366 /* Equal to MAX_PRECISION in atof-ieee.c */
1367 #define MAX_LITTLENUMS 6
1369 /* Turn a string in input_line_pointer into a floating point constant of type
1370 type, and store the appropriate bytes in *litP. The number of LITTLENUMS
1371 emitted is stored in *sizeP . An error message is returned, or NULL on OK.
1374 md_atof (type
, litP
, sizeP
)
1380 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
1381 LITTLENUM_TYPE
*wordP
;
1413 return _("Bad call to MD_ATOF()");
1415 t
= atof_ieee (input_line_pointer
, type
, words
);
1417 input_line_pointer
= t
;
1419 *sizeP
= prec
* sizeof (LITTLENUM_TYPE
);
1420 for (wordP
= words
; prec
--;)
1422 md_number_to_chars (litP
, (long) (*wordP
++), sizeof (LITTLENUM_TYPE
));
1423 litP
+= sizeof (LITTLENUM_TYPE
);
1428 CONST
char *md_shortopts
= "";
1429 struct option md_longopts
[] = {
1430 {NULL
, no_argument
, NULL
, 0}
1432 size_t md_longopts_size
= sizeof(md_longopts
);
1435 md_parse_option (c
, arg
)
1443 md_show_usage (stream
)
1449 tc_aout_fix_to_chars ()
1451 printf (_("call to tc_aout_fix_to_chars \n"));
1456 md_convert_frag (headers
, seg
, fragP
)
1457 object_headers
*headers
;
1461 printf (_("call to md_convert_frag \n"));
1466 md_section_align (seg
, size
)
1470 return ((size
+ (1 << section_alignment
[(int) seg
]) - 1) & (-1 << section_alignment
[(int) seg
]));
1475 md_apply_fix (fixP
, val
)
1479 char *buf
= fixP
->fx_where
+ fixP
->fx_frag
->fr_literal
;
1481 switch (fixP
->fx_size
)
1487 *buf
++ = (val
>> 8);
1491 *buf
++ = (val
>> 24);
1492 *buf
++ = (val
>> 16);
1493 *buf
++ = (val
>> 8);
1502 md_estimate_size_before_relax (fragP
, segment_type
)
1503 register fragS
*fragP
;
1504 register segT segment_type
;
1506 printf (_("call tomd_estimate_size_before_relax \n"));
1510 /* Put number into target byte order */
1513 md_number_to_chars (ptr
, use
, nbytes
)
1518 number_to_chars_bigendian (ptr
, use
, nbytes
);
1521 md_pcrel_from (fixP
)
1529 tc_reloc_mangle (fix_ptr
, intr
, base
)
1531 struct internal_reloc
*intr
;
1535 symbolS
*symbol_ptr
;
1537 symbol_ptr
= fix_ptr
->fx_addsy
;
1539 /* If this relocation is attached to a symbol then it's ok
1541 if (fix_ptr
->fx_r_type
== TC_CONS_RELOC
)
1543 /* cons likes to create reloc32's whatever the size of the reloc..
1545 switch (fix_ptr
->fx_size
)
1548 intr
->r_type
= R_RELLONG
;
1551 intr
->r_type
= R_RELWORD
;
1554 intr
->r_type
= R_RELBYTE
;
1564 intr
->r_type
= fix_ptr
->fx_r_type
;
1567 intr
->r_vaddr
= fix_ptr
->fx_frag
->fr_address
+ fix_ptr
->fx_where
+ base
;
1568 intr
->r_offset
= fix_ptr
->fx_offset
;
1572 if (symbol_ptr
->sy_number
!= -1)
1573 intr
->r_symndx
= symbol_ptr
->sy_number
;
1578 /* This case arises when a reference is made to `.'. */
1579 segsym
= seg_info (S_GET_SEGMENT (symbol_ptr
))->dot
;
1581 intr
->r_symndx
= -1;
1584 intr
->r_symndx
= segsym
->sy_number
;
1585 intr
->r_offset
+= S_GET_VALUE (symbol_ptr
);
1590 intr
->r_symndx
= -1;
1595 /* end of tc-h8300.c */