1 /* tc-i860.c -- Assemble for the I860
2 Copyright (C) 1989, 92, 93, 94, 95, 98, 1999 Free Software Foundation, Inc.
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 along
17 with GAS; see the file COPYING. If not, write to the Free Software
18 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
22 #include "opcode/i860.h"
25 void md_number_to_chars ();
28 void md_convert_frag ();
29 int md_estimate_size_before_relax ();
30 void md_number_to_imm ();
31 void md_number_to_disp ();
32 void md_number_to_field ();
33 void md_ri_to_chars ();
34 static void i860_ip ();
35 /* void emit_machine_reloc(); */
37 const int md_reloc_size
= sizeof (struct relocation_info
);
39 /* void (*md_emit_relocations)() = emit_machine_reloc; */
41 /* handle of the OPCODE hash table */
42 static struct hash_control
*op_hash
= NULL
;
44 static void s_dual (), s_enddual ();
45 static void s_atmp ();
51 {"enddual", s_enddual
, 4},
56 /* This array holds the chars that always start a comment. If the
57 pre-processor is disabled, these aren't very useful */
58 const char comment_chars
[] = "!/"; /* JF removed '|' from comment_chars */
60 /* This array holds the chars that only start a comment at the beginning of
61 a line. If the line seems to have the form '# 123 filename'
62 .line and .file directives will appear in the pre-processed output */
63 /* Note that input_file.c hand checks for '#' at the beginning of the
64 first line of the input file. This is because the compiler outputs
65 #NO_APP at the beginning of its output. */
66 /* Also note that comments like this one will always work. */
67 const char line_comment_chars
[] = "#/";
69 const char line_separator_chars
[] = "";
71 /* Chars that can be used to separate mant from exp in floating point nums */
72 const char EXP_CHARS
[] = "eE";
74 /* Chars that mean this number is a floating point constant */
77 const char FLT_CHARS
[] = "rRsSfFdDxXpP";
79 /* Also be aware that MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT may have to be
80 changed in read.c . Ideally it shouldn't have to know about it at all,
81 but nothing is ideal around here.
83 int size_reloc_info
= sizeof (struct relocation_info
);
85 static unsigned char octal
[256];
86 #define isoctal(c) octal[c]
87 static unsigned char toHex
[256];
96 enum expand_type expand
;
97 enum highlow_type highlow
;
98 enum reloc_type reloc
;
103 static void print_insn (struct i860_it
*insn
);
104 static int getExpression (char *str
);
106 #else /* not __STDC__ */
108 static void print_insn ();
109 static int getExpression ();
111 #endif /* not __STDC__ */
113 static char *expr_end
;
114 static char last_expand
; /* error if expansion after branch */
118 DUAL_OFF
= 0, DUAL_ON
, DUAL_DDOT
, DUAL_ONDDOT
,
120 static enum dual dual_mode
= DUAL_OFF
; /* dual-instruction mode */
123 s_dual () /* floating point instructions have dual set */
129 s_enddual () /* floating point instructions have dual set */
131 dual_mode
= DUAL_OFF
;
134 static int atmp
= 31; /* temporary register for pseudo's */
140 if (strncmp (input_line_pointer
, "sp", 2) == 0)
142 input_line_pointer
+= 2;
145 else if (strncmp (input_line_pointer
, "fp", 2) == 0)
147 input_line_pointer
+= 2;
150 else if (strncmp (input_line_pointer
, "r", 1) == 0)
152 input_line_pointer
+= 1;
153 temp
= get_absolute_expression ();
154 if (temp
>= 0 && temp
<= 31)
157 as_bad (_("Unknown temporary pseudo register"));
161 as_bad (_("Unknown temporary pseudo register"));
163 demand_empty_rest_of_line ();
166 /* This function is called once, at assembler startup time. It should
167 set up all the tables, etc. that the MD part of the assembler will need. */
171 register char *retval
= NULL
;
173 register unsigned int i
= 0;
175 op_hash
= hash_new ();
177 while (i
< NUMOPCODES
)
179 const char *name
= i860_opcodes
[i
].name
;
180 retval
= hash_insert (op_hash
, name
, &i860_opcodes
[i
]);
183 fprintf (stderr
, _("internal error: can't hash `%s': %s\n"),
184 i860_opcodes
[i
].name
, retval
);
189 if (i860_opcodes
[i
].match
& i860_opcodes
[i
].lose
)
191 fprintf (stderr
, _("internal error: losing opcode: `%s' \"%s\"\n"),
192 i860_opcodes
[i
].name
, i860_opcodes
[i
].args
);
197 while (i
< NUMOPCODES
198 && !strcmp (i860_opcodes
[i
].name
, name
));
202 as_fatal (_("Broken assembler. No assembly attempted."));
204 for (i
= '0'; i
< '8'; ++i
)
206 for (i
= '0'; i
<= '9'; ++i
)
208 for (i
= 'a'; i
<= 'f'; ++i
)
209 toHex
[i
] = i
+ 10 - 'a';
210 for (i
= 'A'; i
<= 'F'; ++i
)
211 toHex
[i
] = i
+ 10 - 'A';
222 struct i860_it pseudo
[3];
227 /* check for expandable flag to produce pseudo-instructions */
228 if (the_insn
.expand
!= 0 && the_insn
.highlow
== NO_SPEC
)
230 for (i
= 0; i
< 3; i
++)
231 pseudo
[i
] = the_insn
;
233 switch (the_insn
.expand
)
241 if (the_insn
.exp
.X_add_symbol
== NULL
&&
242 the_insn
.exp
.X_op_symbol
== NULL
&&
243 (the_insn
.exp
.X_add_number
< (1 << 15) &&
244 the_insn
.exp
.X_add_number
>= -(1 << 15)))
246 /* or l%const,r0,ireg_dest */
247 pseudo
[0].opcode
= (the_insn
.opcode
& 0x001f0000) | 0xe4000000;
248 pseudo
[0].highlow
= PAIR
;
249 /* orh h%const,ireg_dest,ireg_dest */
250 pseudo
[1].opcode
= (the_insn
.opcode
& 0x03ffffff) | 0xec000000 |
251 ((the_insn
.opcode
& 0x001f0000) << 5);
252 pseudo
[1].highlow
= HIGH
;
257 if (the_insn
.exp
.X_add_symbol
== NULL
&&
258 the_insn
.exp
.X_op_symbol
== NULL
)
260 /* orh ha%addr_expr,r0,r31 */
261 pseudo
[0].opcode
= 0xec000000 | (atmp
<< 16);
262 pseudo
[0].highlow
= HIGHADJ
;
263 pseudo
[0].reloc
= LOW0
; /* must overwrite */
264 /* l%addr_expr(r31),ireg_dest */
265 pseudo
[1].opcode
= (the_insn
.opcode
& ~0x003e0000) | (atmp
<< 21);
266 pseudo
[1].highlow
= PAIR
;
270 case E_U32
: /* 2nd version emulates Intel as, not doc. */
271 if (the_insn
.exp
.X_add_symbol
== NULL
&&
272 the_insn
.exp
.X_op_symbol
== NULL
&&
273 (the_insn
.exp
.X_add_number
< (1 << 16) &&
274 the_insn
.exp
.X_add_number
>= 0))
276 /* $(opcode)h h%const,ireg_src2,ireg_dest
277 pseudo[0].opcode = (the_insn.opcode & 0xf3ffffff) | 0x0c000000; */
278 /* $(opcode)h h%const,ireg_src2,r31 */
279 pseudo
[0].opcode
= (the_insn
.opcode
& 0xf3e0ffff) | 0x0c000000 |
281 pseudo
[0].highlow
= HIGH
;
282 /* $(opcode) l%const,ireg_dest,ireg_dest
283 pseudo[1].opcode = (the_insn.opcode & 0xf01f0000) | 0x04000000 |
284 ((the_insn.opcode & 0x001f0000) << 5); */
285 /* $(opcode) l%const,r31,ireg_dest */
286 pseudo
[1].opcode
= (the_insn
.opcode
& 0xf01f0000) | 0x04000000 |
288 pseudo
[1].highlow
= PAIR
;
292 case E_AND
: /* 2nd version emulates Intel as, not doc. */
293 if (the_insn
.exp
.X_add_symbol
== NULL
&&
294 the_insn
.exp
.X_op_symbol
== NULL
&&
295 (the_insn
.exp
.X_add_number
< (1 << 16) &&
296 the_insn
.exp
.X_add_number
>= 0))
298 /* andnot h%const,ireg_src2,ireg_dest
299 pseudo[0].opcode = (the_insn.opcode & 0x03ffffff) | 0xd4000000; */
300 /* andnot h%const,ireg_src2,r31 */
301 pseudo
[0].opcode
= (the_insn
.opcode
& 0x03e0ffff) | 0xd4000000 |
303 pseudo
[0].highlow
= HIGH
;
304 pseudo
[0].exp
.X_add_number
= -1 - the_insn
.exp
.X_add_number
;
305 /* andnot l%const,ireg_dest,ireg_dest
306 pseudo[1].opcode = (the_insn.opcode & 0x001f0000) | 0xd4000000 |
307 ((the_insn.opcode & 0x001f0000) << 5); */
308 /* andnot l%const,r31,ireg_dest */
309 pseudo
[1].opcode
= (the_insn
.opcode
& 0x001f0000) | 0xd4000000 |
311 pseudo
[1].highlow
= PAIR
;
312 pseudo
[1].exp
.X_add_number
= -1 - the_insn
.exp
.X_add_number
;
317 if (the_insn
.exp
.X_add_symbol
== NULL
&&
318 the_insn
.exp
.X_op_symbol
== NULL
&&
319 (the_insn
.exp
.X_add_number
< (1 << 15) &&
320 the_insn
.exp
.X_add_number
>= -(1 << 15)))
322 /* orh h%const,r0,r31 */
323 pseudo
[0].opcode
= 0xec000000 | (atmp
<< 16);
324 pseudo
[0].highlow
= HIGH
;
325 /* or l%const,r31,r31 */
326 pseudo
[1].opcode
= 0xe4000000 | (atmp
<< 21) | (atmp
<< 16);
327 pseudo
[1].highlow
= PAIR
;
328 /* r31,ireg_src2,ireg_dest */
329 pseudo
[2].opcode
= (the_insn
.opcode
& ~0x0400ffff) | (atmp
<< 11);
330 pseudo
[2].reloc
= NO_RELOC
;
335 as_fatal (_("failed sanity check."));
338 the_insn
= pseudo
[0];
339 /* check for expanded opcode after branch or in dual */
340 if (no_opcodes
> 1 && last_expand
== 1)
341 as_warn (_("Expanded opcode after delayed branch: `%s'"), str
);
342 if (no_opcodes
> 1 && dual_mode
!= DUAL_OFF
)
343 as_warn (_("Expanded opcode in dual mode: `%s'"), str
);
348 { /* always produce at least one opcode */
350 /* put out the opcode */
351 md_number_to_chars (toP
, the_insn
.opcode
, 4);
353 /* check for expanded opcode after branch or in dual */
354 last_expand
= the_insn
.pcrel
;
356 /* put out the symbol-dependent stuff */
357 if (the_insn
.reloc
!= NO_RELOC
)
359 fix_new (frag_now
, /* which frag */
360 (toP
- frag_now
->fr_literal
), /* where */
364 /* merge bit fields into one argument */
365 (int) (((the_insn
.highlow
& 0x3) << 4) | (the_insn
.reloc
& 0xf)));
367 the_insn
= pseudo
[++i
];
369 while (--no_opcodes
> 0);
381 struct i860_opcode
*insn
;
383 unsigned long opcode
;
389 for (s
= str
; islower (*s
) || *s
== '.' || *s
== '3'; ++s
)
407 as_fatal (_("Unknown opcode: `%s'"), str
);
410 if (strncmp (str
, "d.", 2) == 0)
411 { /* check for d. opcode prefix */
412 if (dual_mode
== DUAL_ON
)
413 dual_mode
= DUAL_ONDDOT
;
415 dual_mode
= DUAL_DDOT
;
419 if ((insn
= (struct i860_opcode
*) hash_find (op_hash
, str
)) == NULL
)
421 if (dual_mode
== DUAL_DDOT
|| dual_mode
== DUAL_ONDDOT
)
423 as_bad (_("Unknown opcode: `%s'"), str
);
433 opcode
= insn
->match
;
434 memset (&the_insn
, '\0', sizeof (the_insn
));
435 the_insn
.reloc
= NO_RELOC
;
438 * Build the opcode, checking as we go to make
439 * sure that the operands match
441 for (args
= insn
->args
;; ++args
)
446 case '\0': /* end of args */
454 case '(': /* these must match exactly */
462 case '#': /* must be at least one digit */
473 case '1': /* next operand must be a register */
479 case 'f': /* frame pointer */
488 case 's': /* stack pointer */
497 case 'r': /* any register */
499 if (!isdigit (c
= *s
++))
505 if ((c
= 10 * (c
- '0') + (*s
++ - '0')) >= 32)
517 default: /* not this opcode */
521 * Got the register, now figure out where
522 * it goes in the opcode.
528 opcode
|= mask
<< 11;
532 opcode
|= mask
<< 21;
536 opcode
|= mask
<< 16;
542 case 'e': /* next operand is a floating point register */
545 if (*s
++ == 'f' && isdigit (*s
))
550 mask
= 10 * (mask
- '0') + (*s
++ - '0');
564 opcode
|= mask
<< 11;
568 opcode
|= mask
<< 21;
572 opcode
|= mask
<< 16;
573 if (dual_mode
!= DUAL_OFF
)
574 opcode
|= (1 << 9); /* dual mode instruction */
575 if (dual_mode
== DUAL_DDOT
)
576 dual_mode
= DUAL_OFF
;
577 if (dual_mode
== DUAL_ONDDOT
)
579 if ((opcode
& (1 << 10)) && (mask
== ((opcode
>> 11) & 0x1f)))
580 as_warn (_("Fsr1 equals fdest with Pipelining"));
586 case 'c': /* next operand must be a control register */
587 if (strncmp (s
, "fir", 3) == 0)
593 if (strncmp (s
, "psr", 3) == 0)
599 if (strncmp (s
, "dirbase", 7) == 0)
605 if (strncmp (s
, "db", 2) == 0)
611 if (strncmp (s
, "fsr", 3) == 0)
617 if (strncmp (s
, "epsr", 4) == 0)
625 case '5': /* 5 bit immediate in src1 */
626 memset (&the_insn
, '\0', sizeof (the_insn
));
627 if (!getExpression (s
))
630 if (the_insn
.exp
.X_add_number
& ~0x1f)
631 as_bad (_("5-bit immediate too large"));
632 opcode
|= (the_insn
.exp
.X_add_number
& 0x1f) << 11;
633 memset (&the_insn
, '\0', sizeof (the_insn
));
634 the_insn
.reloc
= NO_RELOC
;
639 case 'l': /* 26 bit immediate, relative branch */
640 the_insn
.reloc
= BRADDR
;
644 case 's': /* 16 bit immediate, split relative branch */
645 /* upper 5 bits of offset in dest field */
647 the_insn
.reloc
= SPLIT0
;
650 case 'S': /* 16 bit immediate, split (st), aligned */
651 if (opcode
& (1 << 28))
653 the_insn
.reloc
= SPLIT2
;
655 the_insn
.reloc
= SPLIT1
;
657 the_insn
.reloc
= SPLIT0
;
660 case 'I': /* 16 bit immediate, aligned */
661 if (opcode
& (1 << 28))
663 the_insn
.reloc
= LOW2
;
665 the_insn
.reloc
= LOW1
;
667 the_insn
.reloc
= LOW0
;
670 case 'i': /* 16 bit immediate */
671 the_insn
.reloc
= LOW0
;
678 if (strncmp (s
, "ha%", 3) == 0)
680 the_insn
.highlow
= HIGHADJ
;
683 else if (strncmp (s
, "h%", 2) == 0)
685 the_insn
.highlow
= HIGH
;
688 else if (strncmp (s
, "l%", 2) == 0)
690 the_insn
.highlow
= PAIR
;
693 the_insn
.expand
= insn
->expand
;
695 /* Note that if the getExpression() fails, we will still have
696 created U entries in the symbol table for the 'symbols'
697 in the input string. Try not to create U symbols for
700 if (!getExpression (s
))
708 as_fatal (_("failed sanity check."));
715 /* Args don't match. */
716 if (&insn
[1] - i860_opcodes
< NUMOPCODES
717 && !strcmp (insn
->name
, insn
[1].name
))
725 as_bad (_("Illegal operands"));
732 the_insn
.opcode
= opcode
;
742 save_in
= input_line_pointer
;
743 input_line_pointer
= str
;
744 seg
= expression (&the_insn
.exp
);
745 if (seg
!= absolute_section
746 && seg
!= undefined_section
747 && ! SEG_NORMAL (seg
))
749 the_insn
.error
= _("bad segment");
750 expr_end
= input_line_pointer
;
751 input_line_pointer
= save_in
;
754 expr_end
= input_line_pointer
;
755 input_line_pointer
= save_in
;
761 This is identical to the md_atof in m68k.c. I think this is right,
764 Turn a string in input_line_pointer into a floating point constant of type
765 type, and store the appropriate bytes in *litP. The number of LITTLENUMS
766 emitted is stored in *sizeP . An error message is returned, or NULL on OK.
769 /* Equal to MAX_PRECISION in atof-ieee.c */
770 #define MAX_LITTLENUMS 6
773 md_atof (type
, litP
, sizeP
)
779 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
780 LITTLENUM_TYPE
*wordP
;
813 return _("Bad call to MD_ATOF()");
815 t
= atof_ieee (input_line_pointer
, type
, words
);
817 input_line_pointer
= t
;
818 *sizeP
= prec
* sizeof (LITTLENUM_TYPE
);
819 for (wordP
= words
; prec
--;)
821 md_number_to_chars (litP
, (long) (*wordP
++), sizeof (LITTLENUM_TYPE
));
822 litP
+= sizeof (LITTLENUM_TYPE
);
828 * Write out big-endian.
831 md_number_to_chars (buf
, val
, n
)
836 number_to_chars_bigendian (buf
, val
, n
);
840 md_number_to_imm (buf
, val
, n
, fixP
)
846 enum reloc_type reloc
= fixP
->fx_r_type
& 0xf;
847 enum highlow_type highlow
= (fixP
->fx_r_type
>> 4) & 0x3;
850 assert (n
== 4); /* always on i860 */
855 case HIGHADJ
: /* adjusts the high-order 16-bits */
861 case HIGH
: /* selects the high-order 16-bits */
865 case PAIR
: /* selects the low-order 16-bits */
876 case BRADDR
: /* br,call,bc,bc.t,bnc,bnc.t w/26-bit immediate */
877 if (fixP
->fx_pcrel
!= 1)
878 as_bad (_("26-bit branch w/o pc relative set: 0x%08x"), val
);
879 val
>>= 2; /* align pcrel offset, see manual */
881 if (val
>= (1 << 25) || val
< -(1 << 25)) /* check for overflow */
882 as_bad (_("26-bit branch offset overflow: 0x%08x"), val
);
883 buf
[0] = (buf
[0] & 0xfc) | ((val
>> 24) & 0x3);
889 case SPLIT2
: /* 16 bit immediate, 4-byte aligned */
891 as_bad (_("16-bit immediate 4-byte alignment error: 0x%08x"), val
);
892 val
&= ~0x3; /* 4-byte align value */
894 case SPLIT1
: /* 16 bit immediate, 2-byte aligned */
896 as_bad (_("16-bit immediate 2-byte alignment error: 0x%08x"), val
);
897 val
&= ~0x1; /* 2-byte align value */
899 case SPLIT0
: /* st,bla,bte,btne w/16-bit immediate */
900 if (fixP
->fx_pcrel
== 1)
901 val
>>= 2; /* align pcrel offset, see manual */
902 /* check for bounds */
903 if (highlow
!= PAIR
&& (val
>= (1 << 16) || val
< -(1 << 15)))
904 as_bad (_("16-bit branch offset overflow: 0x%08x"), val
);
905 buf
[1] = (buf
[1] & ~0x1f) | ((val
>> 11) & 0x1f);
906 buf
[2] = (buf
[2] & ~0x7) | ((val
>> 8) & 0x7);
907 buf
[3] |= val
; /* perserve bottom opcode bits */
910 case LOW4
: /* fld,pfld,pst,flush 16-byte aligned */
912 as_bad (_("16-bit immediate 16-byte alignment error: 0x%08x"), val
);
913 val
&= ~0xf; /* 16-byte align value */
915 case LOW3
: /* fld,pfld,pst,flush 8-byte aligned */
917 as_bad (_("16-bit immediate 8-byte alignment error: 0x%08x"), val
);
918 val
&= ~0x7; /* 8-byte align value */
920 case LOW2
: /* 16 bit immediate, 4-byte aligned */
922 as_bad (_("16-bit immediate 4-byte alignment error: 0x%08x"), val
);
923 val
&= ~0x3; /* 4-byte align value */
925 case LOW1
: /* 16 bit immediate, 2-byte aligned */
927 as_bad (_("16-bit immediate 2-byte alignment error: 0x%08x"), val
);
928 val
&= ~0x1; /* 2-byte align value */
930 case LOW0
: /* 16 bit immediate, byte aligned */
931 /* check for bounds */
932 if (highlow
!= PAIR
&& (val
>= (1 << 16) || val
< -(1 << 15)))
933 as_bad (_("16-bit immediate overflow: 0x%08x"), val
);
935 buf
[3] |= val
; /* perserve bottom opcode bits */
940 as_bad (_("bad relocation type: 0x%02x"), reloc
);
945 /* should never be called for i860 */
947 md_number_to_disp (buf
, val
, n
)
951 as_fatal (_("md_number_to_disp\n"));
954 /* should never be called for i860 */
956 md_number_to_field (buf
, val
, fix
)
961 as_fatal (_("i860_number_to_field\n"));
964 /* the bit-field entries in the relocation_info struct plays hell
965 with the byte-order problems of cross-assembly. So as a hack,
966 I added this mach. dependent ri twiddler. Ugly, but it gets
968 /* on i860: first 4 bytes are normal unsigned long address, next three
969 bytes are index, most sig. byte first. Byte 7 is broken up with
970 bit 7 as pcrel, bit 6 as extern, and the lower six bits as
971 relocation type (highlow 5-4). Next 4 bytes are long addend. */
972 /* Thanx and a tip of the hat to Michael Bloom, mb@ttidca.tti.com */
974 md_ri_to_chars (ri_p
, ri
)
975 struct relocation_info
*ri_p
, ri
;
978 unsigned char the_bytes
[sizeof (*ri_p
)];
981 md_number_to_chars (the_bytes
, ri
.r_address
, sizeof (ri
.r_address
));
982 /* now the fun stuff */
983 the_bytes
[4] = (ri
.r_index
>> 16) & 0x0ff;
984 the_bytes
[5] = (ri
.r_index
>> 8) & 0x0ff;
985 the_bytes
[6] = ri
.r_index
& 0x0ff;
986 the_bytes
[7] = ((ri
.r_extern
<< 7) & 0x80) | (0 & 0x60) | (ri
.r_type
& 0x1F);
988 md_number_to_chars (&the_bytes
[8], ri
.r_addend
, sizeof (ri
.r_addend
));
989 /* now put it back where you found it, Junior... */
990 memcpy ((char *) ri_p
, the_bytes
, sizeof (*ri_p
));
994 /* should never be called for i860 */
996 md_convert_frag (headers
, seg
, fragP
)
997 object_headers
*headers
;
999 register fragS
*fragP
;
1001 as_fatal (_("i860_convert_frag\n"));
1004 /* should never be called for i860 */
1006 md_estimate_size_before_relax (fragP
, segtype
)
1007 register fragS
*fragP
;
1010 as_fatal (_("i860_estimate_size_before_relax\n"));
1013 /* for debugging only, must match enum reloc_type */
1014 static char *Reloc
[] =
1028 static char *Highlow
[] =
1037 struct i860_it
*insn
;
1041 fprintf (stderr
, "ERROR: %s\n");
1043 fprintf (stderr
, "opcode=0x%08x\t", insn
->opcode
);
1044 fprintf (stderr
, "expand=0x%08x\t", insn
->expand
);
1045 fprintf (stderr
, "reloc = %s\t", Reloc
[insn
->reloc
]);
1046 fprintf (stderr
, "highlow = %s\n", Highlow
[insn
->highlow
]);
1047 fprintf (stderr
, "exp = {\n");
1048 fprintf (stderr
, "\t\tX_add_symbol = %s\n",
1049 insn
->exp
.X_add_symbol
?
1050 (S_GET_NAME (insn
->exp
.X_add_symbol
) ?
1051 S_GET_NAME (insn
->exp
.X_add_symbol
) : "???") : "0");
1052 fprintf (stderr
, "\t\tX_op_symbol = %s\n",
1053 insn
->exp
.X_op_symbol
?
1054 (S_GET_NAME (insn
->exp
.X_op_symbol
) ?
1055 S_GET_NAME (insn
->exp
.X_op_symbol
) : "???") : "0");
1056 fprintf (stderr
, "\t\tX_add_number = %d\n",
1057 insn
->exp
.X_add_number
);
1058 fprintf (stderr
, "}\n");
1061 CONST
char *md_shortopts
= "";
1062 struct option md_longopts
[] = {
1063 {NULL
, no_argument
, NULL
, 0}
1065 size_t md_longopts_size
= sizeof(md_longopts
);
1068 md_parse_option (c
, arg
)
1076 md_show_usage (stream
)
1083 * I860 relocations are completely different, so it needs
1084 * this machine dependent routine to emit them.
1087 emit_machine_reloc (fixP
, segment_address_in_file
)
1088 register fixS
*fixP
;
1089 relax_addressT segment_address_in_file
;
1091 struct reloc_info_i860 ri
;
1092 register symbolS
*symbolP
;
1093 extern char *next_object_file_charP
;
1096 memset ((char *) &ri
, '\0', sizeof (ri
));
1097 for (; fixP
; fixP
= fixP
->fx_next
)
1100 if (fixP
->fx_r_type
& ~0x3f)
1102 as_fatal ("fixP->fx_r_type = %d\n", fixP
->fx_r_type
);
1104 ri
.r_pcrel
= fixP
->fx_pcrel
;
1105 ri
.r_type
= fixP
->fx_r_type
;
1107 if ((symbolP
= fixP
->fx_addsy
) != NULL
)
1109 ri
.r_address
= fixP
->fx_frag
->fr_address
+
1110 fixP
->fx_where
- segment_address_in_file
;
1111 if (!S_IS_DEFINED (symbolP
))
1114 ri
.r_symbolnum
= symbolP
->sy_number
;
1119 ri
.r_symbolnum
= S_GET_TYPE (symbolP
);
1121 if (symbolP
&& symbol_get_frag (symbolP
))
1123 ri
.r_addend
= symbol_get_frag (symbolP
)->fr_address
;
1125 ri
.r_type
= fixP
->fx_r_type
;
1128 /* preserve actual offset vs. pc + 4 */
1129 ri
.r_addend
-= (ri
.r_address
+ 4);
1133 ri
.r_addend
= fixP
->fx_addnumber
;
1136 md_ri_to_chars ((char *) &ri
, ri
);
1137 append (&next_object_file_charP
, (char *) &ri
, sizeof (ri
));
1142 #endif /* comment */
1146 /* on i860: first 4 bytes are normal unsigned long address, next three
1147 bytes are index, most sig. byte first. Byte 7 is broken up with
1148 bit 7 as pcrel, bit 6 as extern, and the lower six bits as
1149 relocation type (highlow 5-4). Next 4 bytes are long addend. */
1152 tc_aout_fix_to_chars (where
, fixP
, segment_address_in_file
)
1155 relax_addressT segment_address_in_file
;
1162 know (fixP
->fx_addsy
);
1163 know (!(fixP
->fx_r_type
& ~0x3f));
1165 if (!S_IS_DEFINED (fixP
->fx_addsy
))
1168 r_index
= fixP
->fx_addsy
->sy_number
;
1173 r_index
= S_GET_TYPE (fixP
->fx_addsy
);
1176 md_number_to_chars (where
,
1177 r_address
= fixP
->fx_frag
->fr_address
+ fixP
->fx_where
- segment_address_in_file
,
1180 where
[4] = (r_index
>> 16) & 0x0ff;
1181 where
[5] = (r_index
>> 8) & 0x0ff;
1182 where
[6] = r_index
& 0x0ff;
1183 where
[7] = (((fixP
->fx_pcrel
<< 7) & 0x80)
1184 | ((r_extern
<< 6) & 0x40)
1185 | (fixP
->fx_r_type
& 0x3F));
1187 if (symbol_get_frag (fixP
->fx_addsy
))
1189 r_addend
= symbol_get_frag (fixP
->fx_addsy
)->fr_address
;
1194 /* preserve actual offset vs. pc + 4 */
1195 r_addend
-= (r_address
+ 4);
1199 r_addend
= fixP
->fx_addnumber
;
1202 md_number_to_chars (&where
[8], r_addend
, 4);
1205 #endif /* OBJ_AOUT */
1207 /* We have no need to default values of symbols. */
1211 md_undefined_symbol (name
)
1217 /* Round up a section size to the appropriate boundary. */
1219 md_section_align (segment
, size
)
1223 return size
; /* Byte alignment is fine */
1226 /* Exactly what point is a PC-relative offset relative TO?
1227 On the i860, they're relative to the address of the offset, plus
1228 its size. (??? Is this right? FIXME-SOON!) */
1230 md_pcrel_from (fixP
)
1233 return fixP
->fx_size
+ fixP
->fx_where
+ fixP
->fx_frag
->fr_address
;
1237 md_apply_fix (fixP
, val
)
1241 char *place
= fixP
->fx_where
+ fixP
->fx_frag
->fr_literal
;
1243 /* looks to me like i860 never has bit fixes. Let's see. xoxorich. */
1244 know (fixP
->fx_bit_fixP
== NULL
);
1245 if (!fixP
->fx_bit_fixP
)
1247 fixP
->fx_addnumber
= val
;
1248 md_number_to_imm (place
, val
, fixP
->fx_size
, fixP
);
1252 md_number_to_field (place
, val
, fixP
->fx_bit_fixP
);
1263 /* end of tc-i860.c */