* as.c: change -l to -a[lsn], to avoid conflict with 68000
[deliverable/binutils-gdb.git] / gas / config / tc-h8300.c
1 /* tc-h8300.c -- Assemble code for the Hitachi h8/300
2 Copyright (C) 1991 Free Software Foundation.
3
4 This file is part of GAS, the GNU Assembler.
5
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)
9 any later version.
10
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.
15
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. */
19
20
21 /*
22 Written By Steve Chamberlain
23 sac@cygnus.com
24 */
25
26 #include <stdio.h>
27 #include "as.h"
28 #include "bfd.h"
29 #include "opcode/h8300.h"
30 #include <ctype.h>
31 #include "listing.h"
32
33 char comment_chars[] = { ';',0 };
34 char line_separator_chars[] = { '$' ,0};
35
36 /* This table describes all the machine specific pseudo-ops the assembler
37 has to support. The fields are:
38 pseudo-op name without dot
39 function to call to execute this pseudo-op
40 Integer arg to pass to the function
41 */
42
43 void cons();
44
45 const pseudo_typeS md_pseudo_table[] = {
46 { "int", cons, 2 },
47 { 0,0,0 }
48 };
49
50 int md_reloc_size ;
51
52 const char EXP_CHARS[] = "eE";
53
54 /* Chars that mean this number is a floating point constant */
55 /* As in 0f12.456 */
56 /* or 0d1.2345e12 */
57 char FLT_CHARS[] = "rRsSfFdDxXpP";
58
59
60 const relax_typeS md_relax_table[1];
61
62
63 static struct hash_control *opcode_hash_control; /* Opcode mnemonics */
64
65
66 /*
67 This function is called once, at assembler startup time. This should
68 set up all the tables, etc that the MD part of the assembler needs
69 */
70
71 /* encode the size and number into the number field
72 xxnnnn
73 00 8 bit
74 01 16 bit
75 10 ccr
76 nnnnreg number
77 */
78 #define WORD_REG 0x10
79 #define BYTE_REG 0x00
80 #define CCR_REG 0x20
81 struct reg_entry
82 {
83 char *name;
84 char number;
85 };
86
87 struct reg_entry reg_list[] = {
88 "r0",WORD_REG +0,
89 "r1",WORD_REG +1,
90 "r2",WORD_REG +2,
91 "r3",WORD_REG +3,
92 "r4",WORD_REG +4,
93 "r5",WORD_REG +5,
94 "r6",WORD_REG +6,
95 "r7",WORD_REG +7,
96 "fp",WORD_REG +6,
97 "sp",WORD_REG +7,
98 "r0h",BYTE_REG + 0,
99 "r0l",BYTE_REG + 1,
100 "r1h",BYTE_REG + 2,
101 "r1l",BYTE_REG + 3,
102 "r2h",BYTE_REG + 4,
103 "r2l",BYTE_REG + 5,
104 "r3h",BYTE_REG + 6,
105 "r3l",BYTE_REG + 7,
106 "r4h",BYTE_REG + 8,
107 "r4l",BYTE_REG + 9,
108 "r5h",BYTE_REG + 10,
109 "r5l",BYTE_REG + 11,
110 "r6h",BYTE_REG + 12,
111 "r6l",BYTE_REG + 13,
112 "r7h",BYTE_REG + 14,
113 "r7l",BYTE_REG + 15,
114 "ccr",CCR_REG,
115 0,0
116 }
117 ;
118
119
120
121
122
123 void md_begin ()
124 {
125 struct h8_opcode *opcode;
126 const struct reg_entry *reg;
127 char prev_buffer[100];
128 int idx = 0;
129
130 opcode_hash_control = hash_new();
131 prev_buffer[0] = 0;
132
133 for (opcode = h8_opcodes; opcode->name; opcode++)
134 {
135 /* Strip off any . part when inserting the opcode and only enter
136 unique codes into the hash table
137 */
138 char *src= opcode->name;
139 unsigned int len = strlen(src);
140 char *dst = malloc(len+1);
141 char *buffer = dst;
142 opcode->size = 0;
143 while (*src) {
144 if (*src == '.') {
145 *dst++ = 0;
146 src++;
147 opcode->size = *src;
148 break;
149 }
150 *dst++ = *src++;
151 }
152 if (strcmp(buffer, prev_buffer))
153 {
154 hash_insert(opcode_hash_control, buffer, (char *)opcode);
155 strcpy(prev_buffer, buffer);
156 idx++;
157 }
158 opcode->idx = idx;
159
160
161 /* Find the number of operands */
162 opcode->noperands = 0;
163 while (opcode->args.nib[opcode->noperands] != E)
164 opcode->noperands ++;
165 /* Find the length of the opcode in bytes */
166 opcode->length =0;
167 while (opcode->data.nib[opcode->length*2] != E)
168 opcode->length++;
169 }
170
171 }
172
173
174 struct h8_exp {
175 char *e_beg;
176 char *e_end;
177 expressionS e_exp;
178 };
179 struct h8_op
180 {
181 unsigned int dispreg;
182 op_type mode;
183 unsigned reg;
184 expressionS exp;
185 };
186
187
188
189 /*
190 parse operands
191 WREG r0,r1,r2,r3,r4,r5,r6,r7,fp,sp
192 r0l,r0h,..r7l,r7h
193 @WREG
194 @WREG+
195 @-WREG
196 #const
197
198 */
199
200 op_type r8_sord[] = {RS8, RD8};
201 op_type r16_sord[] = {RS16, RD16};
202 op_type rind_sord[] = {RSIND, RDIND};
203 op_type abs_sord[2] = {ABS16SRC, ABS16DST};
204 op_type disp_sord[] = {DISPSRC, DISPDST};
205
206 /* try and parse a reg name, returns number of chars consumed */
207 int
208 DEFUN(parse_reg,(src, mode, reg, dst),
209 char *src AND
210 op_type *mode AND
211 unsigned int *reg AND
212 int dst)
213 {
214 if (src[0] == 's' && src[1] == 'p')
215 {
216 *mode = r16_sord[dst];
217 *reg = 7;
218 return 2;
219 }
220 if (src[0] == 'c' && src[1] == 'c' && src[2] == 'r')
221 {
222 *mode = CCR;
223 *reg = 0;
224 return 3;
225 }
226 if (src[0] == 'f' && src[1] == 'p')
227 {
228 *mode = r16_sord[dst];
229 *reg = 6;
230 return 2;
231 }
232 if (src[0] == 'r')
233 {
234 if (src[1] >= '0' && src[1] <= '7')
235 {
236 if(src[2] == 'l')
237 {
238 *mode = r8_sord[dst];
239 *reg = (src[1] - '0') + 8;
240 return 3;
241 }
242 if(src[2] == 'h')
243 {
244 *mode = r8_sord[dst];
245 *reg = (src[1] - '0') ;
246 return 3;
247 }
248 *mode = r16_sord[dst];
249 *reg = (src[1] - '0');
250 return 2;
251 }
252 }
253 return 0;
254 }
255
256 char *
257 DEFUN(parse_exp,(s, op),
258 char *s AND
259 expressionS *op)
260 {
261 char *save = input_line_pointer;
262 char *new;
263 segT seg;
264 input_line_pointer = s;
265 seg = expr(0,op);
266 new = input_line_pointer;
267 input_line_pointer = save;
268 if (SEG_NORMAL(seg))
269 return new;
270 switch (seg) {
271 case SEG_ABSOLUTE:
272 case SEG_UNKNOWN:
273 case SEG_DIFFERENCE:
274 case SEG_BIG:
275 case SEG_REGISTER:
276 return new;
277 case SEG_ABSENT:
278 as_bad("Missing operand");
279 return new;
280 default:
281 as_bad("Don't understand operand of type %s", segment_name (seg));
282 return new;
283 }
284 }
285
286 static char *
287 DEFUN(skip_colonthing,(ptr),
288 char *ptr)
289 {
290 if (*ptr == ':') {
291 ptr++;
292 while (isdigit(*ptr))
293 ptr++;
294
295 }
296 return ptr;
297 }
298
299 /* The many forms of operand:
300
301 Rn Register direct
302 @Rn Register indirect
303 @(exp[:16], Rn) Register indirect with displacement
304 @Rn+
305 @-Rn
306 @aa:8 absolute 8 bit
307 @aa:16 absolute 16 bit
308 @aa absolute 16 bit
309
310 #xx[:size] immediate data
311 @(exp:[8], pc) pc rel
312 @@aa[:8] memory indirect
313
314 */
315
316 static void
317 DEFUN(get_operand,(ptr, op, dst),
318 char **ptr AND
319 struct h8_op *op AND
320 unsigned int dst)
321 {
322 char *src = *ptr;
323 op_type mode;
324 unsigned int num;
325 unsigned int len;
326 unsigned int size;
327 op->mode = E;
328
329 len = parse_reg(src, &op->mode, &op->reg, dst);
330 if (len) {
331 *ptr = src + len;
332 return ;
333 }
334
335 if (*src == '@')
336 {
337 src++;
338 if (*src == '@')
339 {
340 src++;
341 src = parse_exp(src,&op->exp);
342 src = skip_colonthing(src);
343
344 *ptr = src;
345
346 op->mode = MEMIND;
347 return;
348
349 }
350
351
352 if (*src == '-')
353 {
354 src++;
355 len = parse_reg(src, &mode, &num, dst);
356 if (len == 0 || mode != r16_sord[dst])
357 {
358 as_bad("@- needs word register");
359 }
360 op->mode = RDDEC;
361 op->reg = num;
362 *ptr = src + len;
363 return;
364 }
365 if (*src == '(' && ')')
366 {
367 /* Disp */
368 src++;
369 src = parse_exp(src, &op->exp);
370
371 if (*src == ')')
372 {
373 src++;
374 op->mode = abs_sord[dst];
375 *ptr = src;
376 return;
377 }
378 src = skip_colonthing(src);
379
380 if (*src != ',')
381 {
382 as_bad("expected @(exp, reg16)");
383 }
384 src++;
385 len = parse_reg(src, &mode, &op->reg, dst);
386 if (len == 0 || mode != r16_sord[dst])
387 {
388 as_bad("expected @(exp, reg16)");
389 }
390 op->mode = disp_sord[dst];
391 src += len;
392 src = skip_colonthing(src);
393
394 if (*src != ')' && '(')
395 {
396 as_bad("expected @(exp, reg16)");
397
398 }
399 *ptr = src +1;
400
401 return;
402 }
403 len = parse_reg(src, &mode, &num, dst);
404
405 if(len) {
406 src += len;
407 if (*src == '+')
408 {
409 src++;
410 if (mode != RS16)
411 {
412 as_bad("@Rn+ needs src word register");
413 }
414 op->mode = RSINC;
415 op->reg = num;
416 *ptr = src;
417 return;
418 }
419 if (mode != r16_sord[dst])
420 {
421 as_bad("@Rn needs word register");
422 }
423 op->mode =rind_sord[dst];
424 op->reg = num;
425 *ptr = src;
426 return;
427 }
428 else
429 {
430 /* must be a symbol */
431 op->mode = abs_sord[dst];
432 *ptr = skip_colonthing(parse_exp(src, &op->exp));
433
434 return;
435 }
436 }
437
438
439 if (*src == '#') {
440 src++;
441 op->mode = IMM16;
442 src = parse_exp(src, &op->exp);
443 *ptr= skip_colonthing(src);
444
445 return;
446 }
447 else {
448 *ptr = parse_exp(src, &op->exp);
449 op->mode = DISP8;
450 }
451 }
452
453
454 static
455 char *
456 DEFUN(get_operands,(noperands,op_end, operand),
457 unsigned int noperands AND
458 char *op_end AND
459 struct h8_op *operand)
460 {
461 char *ptr = op_end;
462 switch (noperands)
463 {
464 case 0:
465 operand[0].mode = 0;
466 operand[1].mode = 0;
467 break;
468
469 case 1:
470 ptr++;
471 get_operand(& ptr, operand +0,0);
472 operand[1].mode =0;
473 break;
474
475 case 2:
476 ptr++;
477 get_operand(& ptr, operand +0,0);
478 if (*ptr == ',') ptr++;
479 get_operand(& ptr, operand +1, 1);
480 break;
481
482 default:
483 abort();
484 }
485
486
487 return ptr;
488 }
489
490 /* Passed a pointer to a list of opcodes which use different
491 addressing modes, return the opcode which matches the opcodes
492 provided
493 */
494 static
495 struct h8_opcode *
496 DEFUN(get_specific,(opcode, operands),
497 struct h8_opcode *opcode AND
498 struct h8_op *operands)
499
500 {
501 struct h8_opcode *this_try = opcode ;
502 int found = 0;
503 unsigned int noperands = opcode->noperands;
504
505 unsigned int dispreg;
506 unsigned int this_index = opcode->idx;
507 while (this_index == opcode->idx && !found)
508 {
509 unsigned int i;
510
511 this_try = opcode ++;
512 for (i = 0; i < noperands; i++)
513 {
514 op_type op = (this_try->args.nib[i]) & ~(B30|B31);
515 switch (op)
516 {
517 case Hex0:
518 case Hex1:
519 case Hex2:
520 case Hex3:
521 case Hex4:
522 case Hex5:
523 case Hex6:
524 case Hex7:
525 case Hex8:
526 case Hex9:
527 case HexA:
528 case HexB:
529 case HexC:
530 case HexD:
531 case HexE:
532 case HexF:
533 break;
534 case DISPSRC:
535 case DISPDST:
536 operands[0].dispreg = operands[i].reg;
537 case RD8:
538 case RS8:
539 case RDIND:
540 case RSIND:
541 case RD16:
542 case RS16:
543 case CCR:
544 case RSINC:
545 case RDDEC:
546 if (operands[i].mode != op) goto fail;
547 break;
548 case KBIT:
549 case IMM16:
550 case IMM3:
551 case IMM8:
552 if (operands[i].mode != IMM16) goto fail;
553 break;
554 case MEMIND:
555 if (operands[i].mode != MEMIND) goto fail;
556 break;
557 case ABS16SRC:
558 case ABS8SRC:
559 case ABS16OR8SRC:
560 case ABS16ORREL8SRC:
561
562 if (operands[i].mode != ABS16SRC) goto fail;
563 break;
564 case ABS16OR8DST:
565 case ABS16DST:
566 case ABS8DST:
567 if (operands[i].mode != ABS16DST) goto fail;
568 break;
569 }
570 }
571 found =1;
572 fail: ;
573 }
574 if (found)
575 return this_try;
576 else
577 return 0;
578 }
579
580 static void
581 DEFUN(check_operand,(operand, width, string),
582 struct h8_op *operand AND
583 unsigned int width AND
584 char *string)
585 {
586 if (operand->exp.X_add_symbol == 0
587 && operand->exp.X_subtract_symbol == 0)
588 {
589
590 /* No symbol involved, let's look at offset, it's dangerous if any of
591 the high bits are not 0 or ff's, find out by oring or anding with
592 the width and seeing if the answer is 0 or all fs*/
593 if ((operand->exp.X_add_number | width) != ~0 &&
594 (operand->exp.X_add_number & ~width)!= 0)
595 {
596 as_warn("operand %s0x%x out of range.", string, operand->exp.X_add_number);
597 }
598 }
599
600 }
601
602 /* Now we know what sort of opcodes it is, lets build the bytes -
603 */
604 static void
605 DEFUN (build_bytes,(this_try, operand),
606 struct h8_opcode *this_try AND
607 struct h8_op *operand)
608
609 {
610 unsigned int i;
611
612 char *output = frag_more(this_try->length);
613 char *output_ptr = output;
614 op_type *nibble_ptr = this_try->data.nib;
615 char part;
616 op_type c;
617 char high;
618 int nib;
619 top: ;
620 while (*nibble_ptr != E)
621 {
622 int nibble;
623 for (nibble = 0; nibble <2; nibble++)
624 {
625 c = *nibble_ptr & ~(B30|B31);
626 switch (c)
627 {
628 default:
629 abort();
630 case KBIT:
631 switch (operand[0].exp.X_add_number)
632 {
633 case 1:
634 nib = 0;
635 break;
636 case 2:
637 nib = 8;
638 break;
639 default:
640 as_bad("Need #1 or #2 here");
641 break;
642 }
643 /* stop it making a fix */
644 operand[0].mode = 0;
645 break;
646 case 0:
647 case 1:
648 case 2: case 3: case 4: case 5: case 6:
649 case 7: case 8: case 9: case 10: case 11:
650 case 12: case 13: case 14: case 15:
651 nib = c;
652 break;
653 case DISPREG:
654 nib = operand[0].dispreg;
655 break;
656 case IMM8:
657 operand[0].mode = IMM8;
658 nib = 0;
659 break;
660
661 case DISPDST:
662 nib = 0;
663 break;
664 case IMM3:
665 if (operand[0].exp.X_add_symbol == 0) {
666 operand[0].mode = 0; /* stop it making a fix */
667 nib = (operand[0].exp.X_add_number);
668 }
669 else as_bad("can't have symbol for bit number");
670 if (nib < 0 || nib > 7)
671 {
672 as_bad("Bit number out of range %d", nib);
673 }
674
675 break;
676
677 case ABS16DST:
678 nib = 0;
679 break;
680 case ABS8DST:
681 operand[1].mode = ABS8DST;
682 nib = 0;
683 break;
684 case ABS8SRC:
685 operand[0].mode = ABS8SRC;
686 nib = 0;
687 break;
688 case ABS16OR8DST:
689 operand[1].mode = c;
690
691 nib = 0;
692
693 break;
694
695 case ABS16ORREL8SRC:
696 operand[0].mode = c;
697 nib=0;
698 break;
699
700 case ABS16OR8SRC:
701 operand[0].mode = ABS16OR8SRC;
702 nib = 0;
703 break;
704 case DISPSRC:
705 operand[0].mode = ABS16SRC;
706 nib = 0;
707 break;
708
709 case DISP8:
710 operand[0].mode = DISP8;
711 nib = 0;
712 break;
713
714 case ABS16SRC:
715 case IMM16:
716 case IGNORE:
717 case MEMIND:
718
719 nib=0;
720 break;
721 case RS8:
722 case RS16:
723 case RSIND:
724 case RSINC:
725 nib = operand[0].reg;
726 break;
727
728 case RD8:
729 case RD16:
730 case RDDEC:
731 case RDIND:
732 nib = operand[1].reg;
733 break;
734
735 case E:
736 abort();
737 break;
738 }
739 if (*nibble_ptr & B31) {
740 nib |=0x8;
741 }
742
743 if (nibble == 0) {
744 *output_ptr = nib << 4;
745 }
746 else {
747 *output_ptr |= nib;
748 output_ptr++;
749 }
750 nibble_ptr++;
751 }
752
753 }
754
755 /* output any fixes */
756 for (i = 0; i < 2; i++)
757 {
758 switch (operand[i].mode) {
759 case 0:
760 break;
761
762 case DISP8:
763 check_operand(operand+i, 0x7f,"@");
764
765 fix_new(frag_now,
766 output - frag_now->fr_literal + 1,
767 1,
768 operand[i].exp.X_add_symbol,
769 operand[i].exp.X_subtract_symbol,
770 operand[i].exp.X_add_number -1,
771 1,
772 R_PCRBYTE);
773 break;
774 case IMM8:
775 check_operand(operand+i, 0xff,"#");
776 /* If there is nothing else going on we can safely
777 reloc in place */
778 if (operand[i].exp.X_add_symbol == 0)
779 {
780 output[1] = operand[i].exp.X_add_number;
781 }
782 else
783 {
784 fix_new(frag_now,
785 output - frag_now->fr_literal + 1,
786 1,
787 operand[i].exp.X_add_symbol,
788 operand[i].exp.X_subtract_symbol,
789 operand[i].exp.X_add_number,
790 0,
791 R_RELBYTE);
792 }
793
794 break;
795 case MEMIND:
796 check_operand(operand+i, 0xff,"@@");
797 fix_new(frag_now,
798 output - frag_now->fr_literal + 1,
799 1,
800 operand[i].exp.X_add_symbol,
801 operand[i].exp.X_subtract_symbol,
802 operand[i].exp.X_add_number,
803 0,
804 R_RELBYTE);
805 break;
806 case ABS8DST:
807 case ABS8SRC:
808 check_operand(operand+i, 0xff,"@");
809 fix_new(frag_now,
810 output - frag_now->fr_literal + 1,
811 1,
812 operand[i].exp.X_add_symbol,
813 operand[i].exp.X_subtract_symbol,
814 operand[i].exp.X_add_number,
815 0,
816 R_RELBYTE);
817 break;
818
819 case ABS16OR8SRC:
820 case ABS16OR8DST:
821 check_operand(operand+i, 0xffff,"@");
822
823 fix_new(frag_now,
824 output - frag_now->fr_literal + 2,
825 2,
826 operand[i].exp.X_add_symbol,
827 operand[i].exp.X_subtract_symbol,
828 operand[i].exp.X_add_number,
829 0,
830 R_MOVB1);
831 break;
832
833 case ABS16ORREL8SRC:
834 check_operand(operand+i, 0xffff,"@");
835
836 fix_new(frag_now,
837 output - frag_now->fr_literal + 2,
838 2,
839 operand[i].exp.X_add_symbol,
840 operand[i].exp.X_subtract_symbol,
841 operand[i].exp.X_add_number,
842 0,
843 R_JMP1);
844 break;
845
846
847 case ABS16SRC:
848 case ABS16DST:
849 case IMM16:
850 case DISPSRC:
851 case DISPDST:
852 check_operand(operand+i, 0xffff,"@");
853 if (operand[i].exp.X_add_symbol == 0)
854 {
855 /* This should be done with bfd */
856 output[3] = operand[i].exp.X_add_number & 0xff;
857 output[2] = operand[i].exp.X_add_number >> 8;
858
859 }
860 else
861 {
862
863 fix_new(frag_now,
864 output - frag_now->fr_literal + 2,
865 2,
866 operand[i].exp.X_add_symbol,
867 operand[i].exp.X_subtract_symbol,
868 operand[i].exp.X_add_number,
869 0,
870 R_RELWORD);
871 }
872
873 break;
874 case RS8:
875 case RD8:
876 case RS16:
877 case RD16:
878 case RDDEC:
879 case KBIT:
880 case RSINC:
881 case RDIND:
882 case RSIND:
883 case CCR:
884
885 break;
886 default:
887 abort();
888 }
889 }
890
891 }
892 /* This is the guts of the machine-dependent assembler. STR points to a
893 machine dependent instruction. This funciton is supposed to emit
894 the frags/bytes it assembles to.
895 */
896
897
898 void
899 DEFUN(md_assemble,(str),
900 char *str)
901 {
902 char *op_start;
903 char *op_end;
904 unsigned int i;
905 struct h8_op operand[2];
906 struct h8_opcode * opcode;
907 char *dot = 0;
908 char c;
909 /* Drop leading whitespace */
910 while (*str == ' ')
911 str++;
912
913 /* find the op code end */
914 for (op_start = op_end = str;
915 *op_end != 0 && *op_end != ' ';
916 op_end ++)
917 {
918 if (*op_end == '.') {
919 dot = op_end+1;
920 *op_end = 0;
921 op_end+=2;
922 break;
923 }
924 }
925
926 ;
927
928 if (op_end == op_start)
929 {
930 as_bad("can't find opcode ");
931 }
932 c = *op_end;
933
934 *op_end = 0;
935
936 opcode = (struct h8_opcode *) hash_find(opcode_hash_control,
937 op_start);
938
939 if (opcode == NULL)
940 {
941 as_bad("unknown opcode");
942 return;
943 }
944
945
946 input_line_pointer = get_operands(opcode->noperands, op_end,
947 operand);
948 *op_end = c;
949 opcode = get_specific(opcode, operand);
950
951 if (opcode == 0)
952 {
953 /* Allocate 2 bytes for the insn anyway */
954 char *where =frag_more(2);
955 where[0] = 0xde;
956 where[1] = 0xad;
957
958
959 as_bad("illegal operands for opcode");
960 return;
961 }
962 if (opcode->size && dot)
963 {
964 if (opcode->size != *dot)
965 {
966 as_warn("mismatch between opcode size and operand size");
967 }
968 }
969
970 build_bytes(opcode, operand);
971
972 }
973
974 void
975 DEFUN(tc_crawl_symbol_chain, (headers),
976 object_headers *headers)
977 {
978 printf("call to tc_crawl_symbol_chain \n");
979 }
980
981 symbolS *DEFUN(md_undefined_symbol,(name),
982 char *name)
983 {
984 return 0;
985 }
986
987 void
988 DEFUN(tc_headers_hook,(headers),
989 object_headers *headers)
990 {
991 printf("call to tc_headers_hook \n");
992 }
993 void
994 DEFUN_VOID(md_end)
995 {
996 }
997
998 /* Various routines to kill one day */
999 /* Equal to MAX_PRECISION in atof-ieee.c */
1000 #define MAX_LITTLENUMS 6
1001
1002 /* Turn a string in input_line_pointer into a floating point constant of type
1003 type, and store the appropriate bytes in *litP. The number of LITTLENUMS
1004 emitted is stored in *sizeP . An error message is returned, or NULL on OK.
1005 */
1006 char *
1007 md_atof(type,litP,sizeP)
1008 char type;
1009 char *litP;
1010 int *sizeP;
1011 {
1012 int prec;
1013 LITTLENUM_TYPE words[MAX_LITTLENUMS];
1014 LITTLENUM_TYPE *wordP;
1015 char *t;
1016 char *atof_ieee();
1017
1018 switch(type) {
1019 case 'f':
1020 case 'F':
1021 case 's':
1022 case 'S':
1023 prec = 2;
1024 break;
1025
1026 case 'd':
1027 case 'D':
1028 case 'r':
1029 case 'R':
1030 prec = 4;
1031 break;
1032
1033 case 'x':
1034 case 'X':
1035 prec = 6;
1036 break;
1037
1038 case 'p':
1039 case 'P':
1040 prec = 6;
1041 break;
1042
1043 default:
1044 *sizeP=0;
1045 return "Bad call to MD_ATOF()";
1046 }
1047 t=atof_ieee(input_line_pointer,type,words);
1048 if(t)
1049 input_line_pointer=t;
1050
1051 *sizeP=prec * sizeof(LITTLENUM_TYPE);
1052 for(wordP=words;prec--;) {
1053 md_number_to_chars(litP,(long)(*wordP++),sizeof(LITTLENUM_TYPE));
1054 litP+=sizeof(LITTLENUM_TYPE);
1055 }
1056 return ""; /* Someone should teach Dean about null pointers */
1057 }
1058
1059 int
1060 md_parse_option(argP, cntP, vecP)
1061 char **argP;
1062 int *cntP;
1063 char ***vecP;
1064
1065 {
1066 return 0;
1067
1068 }
1069
1070 int md_short_jump_size;
1071
1072 void tc_aout_fix_to_chars () { printf("call to tc_aout_fix_to_chars \n");
1073 abort(); }
1074 void md_create_short_jump(ptr, from_addr, to_addr, frag, to_symbol)
1075 char *ptr;
1076 long from_addr;
1077 long to_addr;
1078 fragS *frag;
1079 symbolS *to_symbol;
1080 {
1081 as_fatal("failed sanity check.");
1082 }
1083
1084 void
1085 md_create_long_jump(ptr,from_addr,to_addr,frag,to_symbol)
1086 char *ptr;
1087 long from_addr, to_addr;
1088 fragS *frag;
1089 symbolS *to_symbol;
1090 {
1091 as_fatal("failed sanity check.");
1092 }
1093
1094 void
1095 md_convert_frag(headers, fragP)
1096 object_headers *headers;
1097 fragS * fragP;
1098
1099 { printf("call to md_convert_frag \n"); abort(); }
1100
1101 long
1102 DEFUN(md_section_align,(seg, size),
1103 segT seg AND
1104 long size)
1105 {
1106 return((size + (1 << section_alignment[(int) seg]) - 1) & (-1 << section_alignment[(int) seg]));
1107
1108 }
1109
1110 void
1111 md_apply_fix(fixP, val)
1112 fixS *fixP;
1113 long val;
1114 {
1115 char *buf = fixP->fx_where + fixP->fx_frag->fr_literal;
1116
1117 switch(fixP->fx_size) {
1118 case 1:
1119 *buf++=val;
1120 break;
1121 case 2:
1122 *buf++=(val>>8);
1123 *buf++=val;
1124 break;
1125 case 4:
1126 *buf++=(val>>24);
1127 *buf++=(val>>16);
1128 *buf++=(val>>8);
1129 *buf++=val;
1130 break;
1131 default:
1132 abort();
1133
1134 }
1135 }
1136
1137 void DEFUN(md_operand, (expressionP),expressionS *expressionP)
1138 { }
1139
1140 int md_long_jump_size;
1141 int
1142 md_estimate_size_before_relax(fragP, segment_type)
1143 register fragS *fragP;
1144 register segT segment_type;
1145 {
1146 printf("call tomd_estimate_size_before_relax \n"); abort(); }
1147 /* Put number into target byte order */
1148
1149 void DEFUN(md_number_to_chars,(ptr, use, nbytes),
1150 char *ptr AND
1151 long use AND
1152 int nbytes)
1153 {
1154 switch (nbytes) {
1155 case 4: *ptr++ = (use >> 24) & 0xff;
1156 case 3: *ptr++ = (use >> 16) & 0xff;
1157 case 2: *ptr++ = (use >> 8) & 0xff;
1158 case 1: *ptr++ = (use >> 0) & 0xff;
1159 break;
1160 default:
1161 abort();
1162 }
1163 }
1164 long md_pcrel_from(fixP)
1165 fixS *fixP; { abort(); }
1166
1167 void tc_coff_symbol_emit_hook() { }
1168
1169
1170 void tc_reloc_mangle(fix_ptr, intr, base)
1171 fixS *fix_ptr;
1172 struct internal_reloc *intr;
1173 bfd_vma base;
1174
1175 {
1176 symbolS *symbol_ptr;
1177
1178 symbol_ptr = fix_ptr->fx_addsy;
1179
1180 /* If this relocation is attached to a symbol then it's ok
1181 to output it */
1182 if (fix_ptr->fx_r_type == RELOC_32) {
1183 /* cons likes to create reloc32's whatever the size of the reloc..
1184 */
1185 switch (fix_ptr->fx_size)
1186 {
1187
1188 case 2:
1189 intr->r_type = R_RELWORD;
1190 break;
1191 case 1:
1192 intr->r_type = R_RELBYTE;
1193 break;
1194 default:
1195 abort();
1196
1197 }
1198
1199 }
1200 else {
1201 intr->r_type = fix_ptr->fx_r_type;
1202 }
1203
1204 intr->r_vaddr = fix_ptr->fx_frag->fr_address + fix_ptr->fx_where +base;
1205 intr->r_offset = fix_ptr->fx_offset;
1206
1207 if (symbol_ptr)
1208 intr->r_symndx = symbol_ptr->sy_number;
1209 else
1210 intr->r_symndx = -1;
1211
1212
1213 }
This page took 0.053518 seconds and 5 git commands to generate.