]>
Commit | Line | Data |
---|---|---|
a39116f1 | 1 | /* tc-h8300.c -- Assemble code for the Hitachi H8/300 |
7c2d4011 | 2 | Copyright (C) 1991, 1992 Free Software Foundation. |
025b0302 | 3 | |
a39116f1 | 4 | This file is part of GAS, the GNU Assembler. |
025b0302 | 5 | |
a39116f1 RP |
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. | |
025b0302 | 10 | |
a39116f1 RP |
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. | |
025b0302 | 15 | |
a39116f1 RP |
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. */ | |
f5e8a8f9 SC |
19 | |
20 | ||
025b0302 | 21 | /* |
cd8761e1 | 22 | Written By Steve Chamberlain |
5d9f0ecf | 23 | [email protected] |
a39116f1 | 24 | */ |
cd8761e1 SC |
25 | |
26 | #include <stdio.h> | |
27 | #include "as.h" | |
28 | #include "bfd.h" | |
025b0302 ME |
29 | #define DEFINE_TABLE |
30 | #define h8_opcodes ops | |
5d9f0ecf | 31 | #include "opcode/h8300.h" |
cd8761e1 SC |
32 | #include <ctype.h> |
33 | ||
025b0302 ME |
34 | const char comment_chars[] = |
35 | {';', 0}; | |
36 | const char line_separator_chars[] = | |
37 | {'$', 0}; | |
38 | const char line_comment_chars[] = "#"; | |
cd8761e1 SC |
39 | |
40 | /* This table describes all the machine specific pseudo-ops the assembler | |
41 | has to support. The fields are: | |
5d9f0ecf SC |
42 | pseudo-op name without dot |
43 | function to call to execute this pseudo-op | |
44 | Integer arg to pass to the function | |
a39116f1 | 45 | */ |
17b81479 | 46 | |
025b0302 ME |
47 | void cons (); |
48 | ||
49 | int Hmode; | |
50 | #define PSIZE (Hmode ? L_32 : L_16) | |
51 | #define DMODE (L_16) | |
52 | #define DSYMMODE (Hmode ? L_24 : L_16) | |
53 | int bsize = L_8; /* default branch displacement */ | |
54 | ||
55 | ||
56 | void | |
57 | h8300hmode () | |
58 | { | |
59 | Hmode = 1; | |
60 | } | |
61 | ||
62 | ||
63 | void | |
64 | sbranch (size) | |
65 | int size; | |
66 | { | |
67 | bsize = size; | |
68 | } | |
5d9f0ecf | 69 | |
025b0302 | 70 | const pseudo_typeS md_pseudo_table[] = |
7c2d4011 | 71 | { |
025b0302 ME |
72 | |
73 | {"h8300h", h8300hmode, 0}, | |
74 | {"sbranch", sbranch, L_8}, | |
75 | {"lbranch", sbranch, L_16}, | |
76 | ||
77 | {"int", cons, 2}, | |
78 | {"data.b", cons, 1}, | |
79 | {"data.w", cons, 2}, | |
80 | {"data.l", cons, 4}, | |
81 | {"form", listing_psize, 0}, | |
82 | {"heading", listing_title, 0}, | |
83 | {"import", s_ignore, 0}, | |
84 | {"page", listing_eject, 0}, | |
85 | {"program", s_ignore, 0}, | |
86 | {0, 0, 0} | |
cd8761e1 SC |
87 | }; |
88 | ||
025b0302 | 89 | const int md_reloc_size; |
a39116f1 | 90 | |
cd8761e1 SC |
91 | const char EXP_CHARS[] = "eE"; |
92 | ||
93 | /* Chars that mean this number is a floating point constant */ | |
94 | /* As in 0f12.456 */ | |
95 | /* or 0d1.2345e12 */ | |
025b0302 | 96 | const char FLT_CHARS[] = "rRsSfFdDxXpP"; |
cd8761e1 SC |
97 | |
98 | ||
99 | const relax_typeS md_relax_table[1]; | |
100 | ||
101 | ||
102 | static struct hash_control *opcode_hash_control; /* Opcode mnemonics */ | |
cd8761e1 | 103 | |
cd8761e1 | 104 | /* |
a39116f1 RP |
105 | This function is called once, at assembler startup time. This should |
106 | set up all the tables, etc that the MD part of the assembler needs | |
107 | */ | |
5d9f0ecf SC |
108 | |
109 | ||
025b0302 ME |
110 | void |
111 | md_begin () | |
112 | { | |
113 | struct h8_opcode *opcode; | |
114 | const struct reg_entry *reg; | |
115 | char prev_buffer[100]; | |
116 | int idx = 0; | |
5d9f0ecf | 117 | |
025b0302 ME |
118 | opcode_hash_control = hash_new (); |
119 | prev_buffer[0] = 0; | |
cd8761e1 | 120 | |
025b0302 ME |
121 | for (opcode = h8_opcodes; opcode->name; opcode++) |
122 | { | |
123 | /* Strip off any . part when inserting the opcode and only enter | |
124 | unique codes into the hash table | |
125 | */ | |
126 | char *src = opcode->name; | |
127 | unsigned int len = strlen (src); | |
128 | char *dst = malloc (len + 1); | |
129 | char *buffer = dst; | |
130 | ||
131 | opcode->size = 0; | |
132 | while (*src) | |
133 | { | |
134 | if (*src == '.') | |
a39116f1 | 135 | { |
025b0302 ME |
136 | src++; |
137 | opcode->size = *src; | |
138 | break; | |
a39116f1 | 139 | } |
025b0302 ME |
140 | *dst++ = *src++; |
141 | } | |
142 | *dst++ = 0; | |
143 | if (strcmp (buffer, prev_buffer)) | |
144 | { | |
145 | hash_insert (opcode_hash_control, buffer, (char *) opcode); | |
146 | strcpy (prev_buffer, buffer); | |
147 | idx++; | |
148 | } | |
149 | opcode->idx = idx; | |
150 | ||
151 | ||
152 | /* Find the number of operands */ | |
153 | opcode->noperands = 0; | |
154 | while (opcode->args.nib[opcode->noperands] != E) | |
155 | opcode->noperands++; | |
156 | /* Find the length of the opcode in bytes */ | |
157 | opcode->length = 0; | |
158 | while (opcode->data.nib[opcode->length * 2] != E) | |
159 | opcode->length++; | |
160 | } | |
161 | ||
cd8761e1 SC |
162 | } |
163 | ||
164 | ||
025b0302 | 165 | struct h8_exp |
cd8761e1 | 166 | { |
025b0302 ME |
167 | char *e_beg; |
168 | char *e_end; | |
169 | expressionS e_exp; | |
cd8761e1 | 170 | }; |
025b0302 ME |
171 | int dispreg; |
172 | int opsize; /* Set when a register size is seen */ | |
cd8761e1 SC |
173 | |
174 | ||
025b0302 ME |
175 | struct h8_op |
176 | { | |
177 | op_type mode; | |
178 | unsigned reg; | |
179 | expressionS exp; | |
180 | }; | |
cd8761e1 SC |
181 | |
182 | /* | |
025b0302 | 183 | parse operands |
a39116f1 RP |
184 | WREG r0,r1,r2,r3,r4,r5,r6,r7,fp,sp |
185 | r0l,r0h,..r7l,r7h | |
186 | @WREG | |
187 | @WREG+ | |
188 | @-WREG | |
189 | #const | |
cd8761e1 | 190 | |
025b0302 | 191 | */ |
5d9f0ecf | 192 | |
cd8761e1 | 193 | /* try and parse a reg name, returns number of chars consumed */ |
025b0302 ME |
194 | int |
195 | parse_reg (src, mode, reg, direction) | |
196 | char *src; | |
197 | op_type *mode; | |
198 | unsigned int *reg; | |
199 | int direction; | |
200 | ||
cd8761e1 | 201 | { |
025b0302 ME |
202 | if (src[0] == 's' && src[1] == 'p') |
203 | { | |
204 | *mode = PSIZE | REG | direction; | |
205 | *reg = 7; | |
206 | return 2; | |
207 | } | |
208 | if (src[0] == 'c' && src[1] == 'c' && src[2] == 'r') | |
209 | { | |
210 | *mode = CCR; | |
211 | *reg = 0; | |
212 | return 3; | |
213 | } | |
214 | if (src[0] == 'f' && src[1] == 'p') | |
215 | { | |
216 | *mode = PSIZE | REG | direction; | |
217 | *reg = 6; | |
218 | return 2; | |
219 | } | |
220 | if (src[0] == 'e' | |
221 | && src[1] == 'r' | |
222 | && src[2] >= '0' && src[2] <= '7') | |
223 | { | |
224 | *mode = L_32 | REG | direction; | |
225 | *reg = src[2] - '0'; | |
226 | if (!Hmode) | |
227 | as_warn ("Reg only legal for H8/300-H"); | |
228 | ||
229 | return 3; | |
230 | } | |
231 | if (src[0] == 'e' | |
232 | && src[1] >= '0' && src[1] <= '7') | |
233 | { | |
234 | *mode = L_16 | REG | direction; | |
235 | *reg = src[1] - '0' + 8; | |
236 | if (!Hmode) | |
237 | as_warn ("Reg only legal for H8/300-H"); | |
238 | return 2; | |
239 | } | |
240 | ||
241 | if (src[0] == 'r') | |
242 | { | |
243 | if (src[1] >= '0' && src[1] <= '7') | |
244 | { | |
245 | if (src[2] == 'l') | |
a39116f1 | 246 | { |
025b0302 ME |
247 | *mode = L_8 | REG | direction; |
248 | *reg = (src[1] - '0') + 8; | |
249 | return 3; | |
a39116f1 | 250 | } |
025b0302 | 251 | if (src[2] == 'h') |
a39116f1 | 252 | { |
025b0302 ME |
253 | *mode = L_8 | REG | direction; |
254 | *reg = (src[1] - '0'); | |
255 | return 3; | |
a39116f1 | 256 | } |
025b0302 ME |
257 | *mode = L_16 | REG | direction; |
258 | *reg = (src[1] - '0'); | |
259 | return 2; | |
260 | } | |
261 | } | |
262 | return 0; | |
cd8761e1 SC |
263 | } |
264 | ||
265 | char * | |
025b0302 ME |
266 | DEFUN (parse_exp, (s, op), |
267 | char *s AND | |
268 | expressionS * op) | |
cd8761e1 | 269 | { |
025b0302 ME |
270 | char *save = input_line_pointer; |
271 | char *new; | |
025b0302 ME |
272 | |
273 | input_line_pointer = s; | |
5ac34ac3 ILT |
274 | if (expression (op) == O_absent) |
275 | as_bad ("missing operand"); | |
025b0302 ME |
276 | new = input_line_pointer; |
277 | input_line_pointer = save; | |
5ac34ac3 | 278 | return new; |
5d9f0ecf SC |
279 | } |
280 | ||
281 | static char * | |
025b0302 ME |
282 | skip_colonthing (ptr, exp, mode) |
283 | char *ptr; | |
284 | expressionS *exp; | |
285 | int *mode; | |
5d9f0ecf | 286 | { |
025b0302 ME |
287 | if (*ptr == ':') |
288 | { | |
289 | ptr++; | |
290 | if (*ptr == '8') | |
291 | { | |
292 | ptr++; | |
293 | /* ff fill any 8 bit quantity */ | |
294 | exp->X_add_number |= 0xff00; | |
5d9f0ecf | 295 | } |
025b0302 ME |
296 | else |
297 | { | |
298 | *mode &= ~SIZE; | |
299 | if (*ptr == '2') | |
300 | { | |
301 | *mode |= L_24; | |
302 | } | |
303 | else if (*ptr == '1') | |
304 | { | |
305 | *mode |= L_16; | |
306 | } | |
307 | while (isdigit (*ptr)) | |
308 | ptr++; | |
309 | } | |
310 | } | |
311 | return ptr; | |
cd8761e1 SC |
312 | } |
313 | ||
5d9f0ecf | 314 | /* The many forms of operand: |
025b0302 | 315 | |
a39116f1 RP |
316 | Rn Register direct |
317 | @Rn Register indirect | |
318 | @(exp[:16], Rn) Register indirect with displacement | |
319 | @Rn+ | |
320 | @-Rn | |
321 | @aa:8 absolute 8 bit | |
322 | @aa:16 absolute 16 bit | |
323 | @aa absolute 16 bit | |
025b0302 | 324 | |
a39116f1 RP |
325 | #xx[:size] immediate data |
326 | @(exp:[8], pc) pc rel | |
327 | @@aa[:8] memory indirect | |
025b0302 | 328 | |
a39116f1 | 329 | */ |
cd8761e1 | 330 | |
025b0302 ME |
331 | char * |
332 | colonmod24 (op, src) | |
333 | struct h8_op *op; | |
334 | char *src; | |
335 | ||
336 | { | |
337 | int mode = 0; | |
338 | src = skip_colonthing (src, &op->exp, &mode); | |
339 | ||
340 | if (!mode) | |
341 | { | |
342 | /* Choose a default mode */ | |
343 | if (op->exp.X_add_number < -32768 | |
344 | || op->exp.X_add_number > 32767) | |
345 | { | |
346 | if (Hmode) | |
347 | mode = L_24; | |
348 | else | |
349 | mode = L_16; | |
350 | } | |
351 | else if (op->exp.X_add_symbol | |
5ac34ac3 | 352 | || op->exp.X_op_symbol) |
025b0302 ME |
353 | mode = DSYMMODE; |
354 | else | |
355 | mode = DMODE; | |
356 | } | |
357 | op->mode |= mode; | |
358 | return src; | |
359 | ||
360 | } | |
361 | ||
362 | ||
363 | static void | |
364 | get_operand (ptr, op, dst, direction) | |
365 | char **ptr; | |
366 | struct h8_op *op; | |
367 | unsigned int dst; | |
368 | ||
cd8761e1 | 369 | { |
7c2d4011 SC |
370 | char *src = *ptr; |
371 | op_type mode; | |
025b0302 ME |
372 | unsigned int num; |
373 | unsigned int len; | |
7c2d4011 | 374 | unsigned int size; |
025b0302 | 375 | |
7c2d4011 | 376 | op->mode = E; |
025b0302 ME |
377 | |
378 | len = parse_reg (src, &op->mode, &op->reg, direction); | |
379 | if (len) | |
7c2d4011 | 380 | { |
7c2d4011 SC |
381 | *ptr = src + len; |
382 | return; | |
383 | } | |
025b0302 ME |
384 | |
385 | if (*src == '@') | |
7c2d4011 | 386 | { |
7c2d4011 | 387 | src++; |
025b0302 ME |
388 | if (*src == '@') |
389 | { | |
390 | src++; | |
391 | src = parse_exp (src, &op->exp); | |
392 | ||
393 | src = skip_colonthing (src, &op->exp, &op->mode); | |
394 | ||
395 | *ptr = src; | |
396 | ||
397 | op->mode = MEMIND; | |
398 | return; | |
399 | ||
400 | } | |
401 | ||
402 | ||
403 | if (*src == '-') | |
7c2d4011 SC |
404 | { |
405 | src++; | |
025b0302 ME |
406 | len = parse_reg (src, &mode, &num, direction); |
407 | if (len == 0) | |
408 | { | |
409 | /* Oops, not a reg after all, must be ordinary exp */ | |
410 | src--; | |
411 | /* must be a symbol */ | |
412 | op->mode = ABS | PSIZE | direction; | |
413 | *ptr = skip_colonthing (parse_exp (src, &op->exp), | |
414 | &op->exp, &op->mode); | |
415 | ||
416 | return; | |
417 | ||
418 | ||
419 | } | |
420 | ||
421 | ||
422 | if ((mode & SIZE) != PSIZE) | |
423 | as_bad ("Wrong size pointer register for architecture."); | |
424 | op->mode = RDDEC; | |
425 | op->reg = num; | |
426 | *ptr = src + len; | |
427 | return; | |
428 | } | |
429 | if (*src == '(' ) | |
430 | { | |
431 | /* Disp */ | |
432 | src++; | |
433 | ||
434 | /* Start off assuming a 16 bit offset */ | |
435 | ||
436 | ||
437 | src = parse_exp (src, &op->exp); | |
438 | ||
439 | src = colonmod24 (op, src); | |
440 | ||
441 | if (*src == ')') | |
442 | { | |
443 | src++; | |
444 | op->mode = DISP | direction; | |
445 | *ptr = src; | |
446 | return; | |
447 | } | |
448 | ||
449 | if (*src != ',') | |
450 | { | |
451 | as_bad ("expected @(exp, reg16)"); | |
452 | return; | |
453 | ||
454 | } | |
455 | src++; | |
456 | ||
457 | len = parse_reg (src, &mode, &op->reg, direction); | |
458 | if (len == 0 || !(mode & REG)) | |
459 | { | |
460 | as_bad ("expected @(exp, reg16)"); | |
461 | return; | |
462 | } | |
463 | op->mode |= DISP | direction; | |
464 | dispreg = op->reg; | |
465 | src += len; | |
466 | src = skip_colonthing (src, &op->exp, &op->mode); | |
467 | ||
468 | if (*src != ')' && '(') | |
469 | { | |
470 | as_bad ("expected @(exp, reg16)"); | |
471 | return; | |
472 | } | |
473 | *ptr = src + 1; | |
474 | ||
475 | return; | |
476 | } | |
477 | len = parse_reg (src, &mode, &num, direction); | |
478 | ||
479 | if (len) | |
480 | { | |
481 | src += len; | |
482 | if (*src == '+') | |
483 | { | |
484 | src++; | |
485 | if ((mode & SIZE) != PSIZE) | |
486 | as_bad ("Wrong size pointer register for architecture."); | |
487 | op->mode = RSINC; | |
488 | op->reg = num; | |
489 | *ptr = src; | |
490 | return; | |
491 | } | |
492 | if ((mode & SIZE) != PSIZE) | |
493 | as_bad ("Wrong size pointer register for architecture."); | |
494 | ||
495 | op->mode = direction | IND | PSIZE; | |
7c2d4011 SC |
496 | op->reg = num; |
497 | *ptr = src; | |
025b0302 | 498 | |
7c2d4011 SC |
499 | return; |
500 | } | |
025b0302 | 501 | else |
7c2d4011 | 502 | { |
025b0302 ME |
503 | /* must be a symbol */ |
504 | ||
505 | op->mode = ABS | direction; | |
506 | src = parse_exp (src, &op->exp); | |
507 | ||
508 | *ptr = colonmod24 (op, src); | |
509 | ||
7c2d4011 | 510 | return; |
7c2d4011 | 511 | } |
7c2d4011 | 512 | } |
025b0302 ME |
513 | |
514 | ||
515 | if (*src == '#') | |
516 | { | |
7c2d4011 | 517 | src++; |
025b0302 ME |
518 | op->mode = IMM; |
519 | src = parse_exp (src, &op->exp); | |
520 | *ptr = skip_colonthing (src, &op->exp, &op->mode); | |
521 | ||
7c2d4011 SC |
522 | return; |
523 | } | |
025b0302 ME |
524 | else |
525 | { | |
526 | src = parse_exp (src, &op->exp); | |
527 | /* Trailing ':' size ? */ | |
528 | if (*src == ':') | |
529 | { | |
530 | if (src[1] == '1' && src[2] == '6') | |
531 | { | |
532 | op->mode = PCREL | L_16; | |
533 | src += 3; | |
534 | } | |
535 | else if (src[1] == '8') | |
536 | { | |
537 | op->mode = PCREL | L_8; | |
538 | src += 2; | |
539 | } | |
540 | else | |
541 | { | |
542 | as_bad ("expect :8 or :16 here"); | |
543 | } | |
544 | } | |
545 | else | |
546 | { | |
547 | op->mode = PCREL | bsize; | |
548 | } | |
549 | *ptr = src; | |
7c2d4011 | 550 | } |
5d9f0ecf SC |
551 | } |
552 | ||
553 | ||
554 | static | |
025b0302 ME |
555 | char * |
556 | DEFUN (get_operands, (noperands, op_end, operand), | |
557 | unsigned int noperands AND | |
558 | char *op_end AND | |
559 | struct h8_op *operand) | |
5d9f0ecf | 560 | { |
025b0302 ME |
561 | char *ptr = op_end; |
562 | ||
563 | switch (noperands) | |
564 | { | |
565 | case 0: | |
566 | operand[0].mode = 0; | |
567 | operand[1].mode = 0; | |
568 | break; | |
569 | ||
570 | case 1: | |
571 | ptr++; | |
572 | get_operand (&ptr, operand + 0, 0, SRC); | |
573 | if (*ptr == ',') | |
574 | { | |
575 | ptr++; | |
576 | get_operand (&ptr, operand + 1, 1, DST); | |
577 | } | |
578 | else | |
579 | { | |
580 | operand[1].mode = 0; | |
581 | } | |
582 | ||
583 | break; | |
584 | case 2: | |
585 | ptr++; | |
586 | get_operand (&ptr, operand + 0, 0, SRC); | |
587 | if (*ptr == ',') | |
588 | ptr++; | |
589 | get_operand (&ptr, operand + 1, 1, DST); | |
590 | break; | |
591 | ||
592 | default: | |
593 | abort (); | |
594 | } | |
595 | ||
596 | ||
597 | return ptr; | |
cd8761e1 SC |
598 | } |
599 | ||
5d9f0ecf SC |
600 | /* Passed a pointer to a list of opcodes which use different |
601 | addressing modes, return the opcode which matches the opcodes | |
602 | provided | |
a39116f1 | 603 | */ |
5d9f0ecf | 604 | static |
025b0302 ME |
605 | struct h8_opcode * |
606 | get_specific (opcode, operands) | |
607 | struct h8_opcode *opcode; | |
608 | struct h8_op *operands; | |
5d9f0ecf | 609 | { |
025b0302 ME |
610 | struct h8_opcode *this_try = opcode; |
611 | int found = 0; | |
612 | ||
613 | unsigned int this_index = opcode->idx; | |
614 | ||
615 | while (this_index == opcode->idx && !found) | |
616 | { | |
617 | unsigned int i; | |
618 | found = 1; | |
619 | ||
620 | this_try = opcode++; | |
621 | for (i = 0; i < this_try->noperands && found; i++) | |
622 | { | |
623 | op_type op = this_try->args.nib[i]; | |
624 | int x = operands[i].mode; | |
625 | ||
626 | if ((op & (DISP | REG)) == (DISP | REG) | |
627 | && ((x & DISP | REG) == (DISP | REG))) | |
a39116f1 | 628 | { |
025b0302 | 629 | dispreg = operands[i].reg; |
a39116f1 | 630 | } |
025b0302 ME |
631 | else if (op & REG) |
632 | { | |
633 | if (!(x & REG)) | |
634 | found = 0; | |
635 | ||
636 | if (x & L_P) | |
637 | { | |
638 | x = (x & ~L_P) | (Hmode ? L_32 : L_16); | |
639 | } | |
640 | if (op & L_P) | |
641 | { | |
642 | op = (op & ~L_P) | (Hmode ? L_32 : L_16); | |
643 | } | |
644 | ||
645 | opsize = op & SIZE; | |
646 | ||
647 | /* The size of the reg is v important */ | |
648 | if ((op & SIZE) != (x & SIZE)) | |
649 | found = 0; | |
650 | } | |
651 | else if ((op & ABSJMP) && (x & ABS)) | |
652 | { | |
653 | operands[i].mode &= ~ABS; | |
654 | operands[i].mode |= ABSJMP; | |
655 | /* But it may not be 24 bits long */ | |
656 | if (!Hmode) | |
657 | { | |
658 | operands[i].mode &= ~SIZE; | |
659 | operands[i].mode |= L_16; | |
660 | } | |
661 | ||
662 | ||
663 | } | |
664 | else if ((op & (KBIT | DBIT)) && (x & IMM)) | |
665 | { | |
666 | /* This is ok if the immediate value is sensible */ | |
667 | ||
668 | } | |
669 | else if (op & PCREL) | |
670 | { | |
671 | ||
672 | /* The size of the displacement is important */ | |
673 | if ((op & SIZE) != (x & SIZE)) | |
674 | found = 0; | |
675 | ||
676 | } | |
677 | else if ((op & (DISP | IMM | ABS)) | |
678 | && (op & (DISP | IMM | ABS)) == (x & (DISP | IMM | ABS))) | |
679 | { | |
680 | /* Got a diplacement,will fit if no size or same size as try */ | |
681 | if ((x & SIZE) != 0 | |
682 | && ((op & SIZE) != (x & SIZE))) | |
683 | found = 0; | |
684 | } | |
685 | else if ((op & ABSMOV) && (x & ABS)) | |
686 | { | |
687 | /* Ok */ | |
688 | } | |
689 | else if ((op & MODE) != (x & MODE)) | |
690 | { | |
691 | found = 0; | |
692 | } | |
693 | ||
694 | } | |
695 | } | |
696 | if (found) | |
697 | return this_try; | |
698 | else | |
699 | return 0; | |
5d9f0ecf SC |
700 | } |
701 | ||
702 | static void | |
025b0302 ME |
703 | DEFUN (check_operand, (operand, width, string), |
704 | struct h8_op *operand AND | |
705 | unsigned int width AND | |
706 | char *string) | |
5d9f0ecf | 707 | { |
025b0302 | 708 | if (operand->exp.X_add_symbol == 0 |
5ac34ac3 | 709 | && operand->exp.X_op_symbol == 0) |
7c2d4011 | 710 | { |
025b0302 ME |
711 | |
712 | /* No symbol involved, let's look at offset, it's dangerous if any of | |
713 | the high bits are not 0 or ff's, find out by oring or anding with | |
714 | the width and seeing if the answer is 0 or all fs*/ | |
715 | if ((operand->exp.X_add_number & ~width) != 0 && | |
716 | (operand->exp.X_add_number | width) != (~0)) | |
717 | { | |
718 | as_warn ("operand %s0x%x out of range.", string, operand->exp.X_add_number); | |
719 | } | |
7c2d4011 | 720 | } |
025b0302 ME |
721 | |
722 | } | |
723 | ||
724 | static void | |
725 | do_a_fix_imm (offset, operand, relaxing) | |
726 | int offset; | |
727 | struct h8_op *operand; | |
728 | int relaxing; | |
729 | { | |
730 | int idx; | |
731 | int size; | |
732 | int where; | |
733 | ||
734 | ||
735 | char *t = operand->mode & IMM ? "#" : "@"; | |
736 | ||
737 | if (operand->exp.X_add_symbol == 0) | |
738 | { | |
739 | char *bytes = frag_now->fr_literal + offset; | |
740 | switch (operand->mode & SIZE) | |
741 | { | |
742 | case L_3: | |
743 | check_operand (operand, 0x7, t); | |
744 | bytes[0] |= (operand->exp.X_add_number) << 4; | |
745 | break; | |
746 | case L_8: | |
747 | check_operand (operand, 0xff, t); | |
748 | bytes[0] = operand->exp.X_add_number; | |
749 | break; | |
750 | case L_16: | |
751 | check_operand (operand, 0xffff, t); | |
752 | bytes[0] = operand->exp.X_add_number >> 8; | |
753 | bytes[1] = operand->exp.X_add_number >> 0; | |
754 | break; | |
755 | case L_24: | |
756 | check_operand (operand, 0xffffff, t); | |
757 | bytes[0] = operand->exp.X_add_number >> 16; | |
758 | bytes[1] = operand->exp.X_add_number >> 8; | |
759 | bytes[2] = operand->exp.X_add_number >> 0; | |
760 | break; | |
761 | ||
762 | case L_32: | |
763 | /* This should be done with bfd */ | |
764 | bytes[0] = operand->exp.X_add_number >> 24; | |
765 | bytes[1] = operand->exp.X_add_number >> 16; | |
766 | bytes[2] = operand->exp.X_add_number >> 8; | |
767 | bytes[3] = operand->exp.X_add_number >> 0; | |
768 | break; | |
769 | } | |
770 | ||
771 | } | |
772 | else | |
773 | { | |
774 | switch (operand->mode & SIZE) | |
775 | { | |
776 | default: | |
777 | abort (); | |
778 | case L_24: | |
779 | size = 4; | |
780 | where = -1; | |
781 | idx = relaxing ? R_MOVLB1 : R_RELLONG; | |
782 | break; | |
783 | ||
784 | case L_32: | |
785 | size = 4; | |
786 | where = 0; | |
787 | idx = R_RELLONG; | |
788 | break; | |
789 | case L_16: | |
790 | size = 2; | |
791 | where = 0; | |
792 | idx = relaxing ? R_MOVB1 : R_RELWORD; | |
793 | break; | |
794 | case L_8: | |
795 | size = 1; | |
796 | where = 0; | |
797 | idx = R_RELBYTE; | |
798 | } | |
799 | ||
800 | ||
5ac34ac3 ILT |
801 | operand->exp.X_add_number = (short) operand->exp.X_add_number; |
802 | fix_new_exp (frag_now, | |
803 | offset + where, | |
804 | size, | |
805 | &operand->exp, | |
806 | 0, | |
807 | idx); | |
025b0302 ME |
808 | } |
809 | ||
5d9f0ecf SC |
810 | } |
811 | ||
812 | /* Now we know what sort of opcodes it is, lets build the bytes - | |
a39116f1 | 813 | */ |
025b0302 ME |
814 | static void |
815 | build_bytes (this_try, operand) | |
816 | struct h8_opcode *this_try; | |
817 | struct h8_op *operand; | |
5d9f0ecf | 818 | { |
025b0302 ME |
819 | unsigned int i; |
820 | ||
821 | char *output = frag_more (this_try->length); | |
822 | char *output_ptr = output; | |
823 | op_type *nibble_ptr = this_try->data.nib; | |
824 | char part; | |
825 | op_type c; | |
826 | char high; | |
827 | unsigned int nibble_count = 0; | |
828 | ||
829 | int immat; | |
830 | int nib; | |
831 | char asnibbles[30]; | |
832 | char *p = asnibbles; | |
833 | ||
834 | if (!(this_try->inbase || Hmode)) | |
835 | { | |
836 | as_warn ("Opcode `%s' only available on H8/300-H", this_try->name); | |
837 | } | |
838 | ||
839 | while (*nibble_ptr != E) | |
840 | { | |
841 | int d; | |
842 | c = *nibble_ptr++; | |
843 | ||
844 | d = (c & DST) != 0; | |
845 | ||
846 | if (c < 16) | |
847 | { | |
848 | nib = c; | |
849 | } | |
850 | else | |
851 | { | |
852 | ||
853 | if (c & (REG | IND | INC | DEC)) | |
a39116f1 | 854 | { |
025b0302 | 855 | nib = operand[d].reg; |
a39116f1 | 856 | } |
025b0302 | 857 | else if ((c & DISPREG) == (DISPREG)) |
a39116f1 | 858 | { |
025b0302 | 859 | nib = dispreg; |
a39116f1 | 860 | } |
5d9f0ecf | 861 | |
025b0302 ME |
862 | else if (c & ABSMOV) |
863 | { | |
864 | operand[d].mode &= ~ABS; | |
865 | operand[d].mode |= ABSMOV; | |
866 | immat = nibble_count / 2; | |
867 | nib = 0; | |
868 | } | |
869 | else if (c & (IMM | PCREL | ABS | ABSJMP | DISP )) | |
870 | { | |
871 | operand[d].mode = c; | |
872 | immat = nibble_count / 2; | |
873 | nib = 0; | |
874 | } | |
875 | else if (c & IGNORE) | |
876 | { | |
877 | nib = 0; | |
878 | } | |
879 | else if (c & DBIT) | |
880 | { | |
881 | switch (operand[0].exp.X_add_number) | |
882 | { | |
883 | case 1: | |
884 | nib = c; | |
885 | break; | |
886 | case 2: | |
887 | nib = 0x8 | c; | |
888 | break; | |
889 | default: | |
890 | as_bad ("Need #1 or #2 here"); | |
891 | } | |
892 | } | |
893 | else if (c & KBIT) | |
894 | { | |
895 | switch (operand[0].exp.X_add_number) | |
896 | { | |
897 | case 1: | |
898 | nib = 0; | |
899 | break; | |
900 | case 2: | |
901 | nib = 8; | |
902 | break; | |
903 | case 4: | |
904 | if (!Hmode) | |
905 | as_warn ("#4 only valid in h8/300 mode."); | |
906 | nib = 9; | |
907 | break; | |
908 | ||
909 | default: | |
910 | as_bad ("Need #1 or #2 here"); | |
911 | break; | |
912 | } | |
913 | /* stop it making a fix */ | |
914 | operand[0].mode = 0; | |
915 | } | |
916 | ||
917 | if (c & B31) | |
918 | { | |
919 | nib |= 0x8; | |
920 | } | |
921 | } | |
922 | nibble_count++; | |
923 | ||
924 | *p++ = nib; | |
925 | } | |
926 | ||
927 | for (i = 0; i < this_try->length; i++) | |
928 | { | |
929 | output[i] = (asnibbles[i * 2] << 4) | asnibbles[i * 2 + 1]; | |
930 | } | |
931 | ||
932 | /* output any fixes */ | |
933 | for (i = 0; i < 2; i++) | |
7c2d4011 | 934 | { |
025b0302 ME |
935 | int x = operand[i].mode; |
936 | ||
937 | if (x & (IMM | ABS | DISP)) | |
7c2d4011 | 938 | { |
025b0302 | 939 | do_a_fix_imm (output - frag_now->fr_literal + immat, operand + i,0); |
7c2d4011 | 940 | } |
025b0302 | 941 | else if (x & PCREL) |
7c2d4011 | 942 | { |
025b0302 ME |
943 | int size16 = x & L_16; |
944 | int where = size16 ? 2 : 1; | |
945 | int size = size16 ? 2 : 1; | |
946 | int type = size16 ? R_PCRWORD : R_PCRBYTE; | |
947 | ||
948 | check_operand (operand + i, size16 ? 0x7fff : 0x7f, "@"); | |
949 | ||
950 | if (operand[i].exp.X_add_number & 1) | |
951 | { | |
952 | as_warn ("branch operand has odd offset (%x)\n", | |
953 | operand->exp.X_add_number); | |
954 | } | |
955 | ||
c2ac84cb | 956 | operand[i].exp.X_add_number = |
5ac34ac3 ILT |
957 | (char) (operand[i].exp.X_add_number - 1); |
958 | fix_new_exp (frag_now, | |
959 | output - frag_now->fr_literal + where, | |
960 | size, | |
961 | &operand[i].exp, | |
962 | 1, | |
963 | type); | |
7c2d4011 | 964 | } |
025b0302 | 965 | else if (x & MEMIND) |
7c2d4011 | 966 | { |
025b0302 ME |
967 | |
968 | check_operand (operand + i, 0xff, "@@"); | |
5ac34ac3 ILT |
969 | fix_new_exp (frag_now, |
970 | output - frag_now->fr_literal + 1, | |
971 | 1, | |
972 | &operand[i].exp, | |
973 | 0, | |
974 | R_RELBYTE); | |
7c2d4011 | 975 | } |
025b0302 ME |
976 | |
977 | else if (x & ABSMOV) | |
7c2d4011 | 978 | { |
025b0302 ME |
979 | /* This mov is either absolute long or thru a memory loc */ |
980 | do_a_fix_imm (output - frag_now->fr_literal + immat, operand + i,1); | |
7c2d4011 | 981 | } |
025b0302 ME |
982 | |
983 | else if (x & ABSJMP) | |
7c2d4011 | 984 | { |
025b0302 ME |
985 | /* This jmp may be a jump or a branch */ |
986 | ||
987 | check_operand (operand + i, Hmode ? 0xfffff : 0xffff, "@"); | |
988 | if (operand[i].exp.X_add_number & 1) | |
989 | { | |
990 | as_warn ("branch operand has odd offset (%x)\n", | |
991 | operand->exp.X_add_number); | |
992 | } | |
c2ac84cb | 993 | operand[i].exp.X_add_number = (short) operand[i].exp.X_add_number; |
5ac34ac3 ILT |
994 | fix_new_exp (frag_now, |
995 | output - frag_now->fr_literal, | |
996 | 4, | |
997 | &operand[i].exp, | |
998 | 0, | |
999 | R_JMPL1); | |
7c2d4011 | 1000 | } |
7c2d4011 | 1001 | } |
025b0302 ME |
1002 | |
1003 | } | |
1004 | ||
1005 | /* | |
1006 | try and give an intelligent error message for common and simple to | |
1007 | detect errors | |
1008 | */ | |
1009 | ||
1010 | static void | |
1011 | DEFUN (clever_message, (opcode, operand), | |
1012 | struct h8_opcode *opcode AND | |
1013 | struct h8_op *operand) | |
1014 | { | |
1015 | struct h8_opcode *scan = opcode; | |
1016 | ||
1017 | /* Find out if there was more than one possible opccode */ | |
1018 | ||
1019 | if ((opcode + 1)->idx != opcode->idx) | |
1020 | { | |
1021 | unsigned int argn; | |
1022 | ||
1023 | /* Only one opcode of this flavour, try and guess which operand | |
1024 | didn't match */ | |
1025 | for (argn = 0; argn < opcode->noperands; argn++) | |
1026 | { | |
1027 | switch (opcode->args.nib[argn]) | |
1028 | { | |
1029 | case RD16: | |
1030 | if (operand[argn].mode != RD16) | |
1031 | { | |
1032 | as_bad ("destination operand must be 16 bit register"); | |
1033 | return; | |
1034 | ||
1035 | } | |
1036 | break; | |
1037 | ||
1038 | case RS8: | |
1039 | ||
1040 | if (operand[argn].mode != RS8) | |
1041 | { | |
1042 | as_bad ("source operand must be 8 bit register"); | |
1043 | return; | |
1044 | } | |
1045 | break; | |
1046 | ||
1047 | case ABS16DST: | |
1048 | if (operand[argn].mode != ABS16DST) | |
1049 | { | |
1050 | as_bad ("destination operand must be 16bit absolute address"); | |
1051 | return; | |
1052 | } | |
1053 | break; | |
1054 | case RD8: | |
1055 | if (operand[argn].mode != RD8) | |
1056 | { | |
1057 | as_bad ("destination operand must be 8 bit register"); | |
1058 | return; | |
1059 | } | |
1060 | break; | |
1061 | ||
1062 | ||
1063 | case ABS16SRC: | |
1064 | if (operand[argn].mode != ABS16SRC) | |
1065 | { | |
1066 | as_bad ("source operand must be 16bit absolute address"); | |
1067 | return; | |
1068 | } | |
1069 | break; | |
1070 | ||
1071 | } | |
1072 | } | |
1073 | } | |
1074 | as_bad ("invalid operands"); | |
5d9f0ecf | 1075 | } |
a39116f1 | 1076 | |
cd8761e1 SC |
1077 | /* This is the guts of the machine-dependent assembler. STR points to a |
1078 | machine dependent instruction. This funciton is supposed to emit | |
1079 | the frags/bytes it assembles to. | |
a39116f1 RP |
1080 | */ |
1081 | ||
1082 | ||
cd8761e1 | 1083 | |
025b0302 ME |
1084 | void |
1085 | DEFUN (md_assemble, (str), | |
1086 | char *str) | |
cd8761e1 | 1087 | { |
025b0302 ME |
1088 | char *op_start; |
1089 | char *op_end; | |
1090 | unsigned int i; | |
1091 | struct h8_op operand[2]; | |
1092 | struct h8_opcode *opcode; | |
1093 | struct h8_opcode *prev_opcode; | |
1094 | ||
1095 | char *dot = 0; | |
1096 | char c; | |
1097 | ||
1098 | /* Drop leading whitespace */ | |
1099 | while (*str == ' ') | |
1100 | str++; | |
1101 | ||
1102 | /* find the op code end */ | |
1103 | for (op_start = op_end = str; | |
1104 | *op_end != 0 && *op_end != ' '; | |
1105 | op_end++) | |
1106 | { | |
1107 | if (*op_end == '.') | |
1108 | { | |
1109 | dot = op_end + 1; | |
1110 | *op_end = 0; | |
1111 | op_end += 2; | |
1112 | break; | |
1113 | } | |
1114 | } | |
1115 | ||
1116 | ; | |
1117 | ||
1118 | if (op_end == op_start) | |
1119 | { | |
1120 | as_bad ("can't find opcode "); | |
1121 | } | |
1122 | c = *op_end; | |
1123 | ||
1124 | *op_end = 0; | |
1125 | ||
1126 | opcode = (struct h8_opcode *) hash_find (opcode_hash_control, | |
1127 | op_start); | |
1128 | ||
1129 | if (opcode == NULL) | |
1130 | { | |
1131 | as_bad ("unknown opcode"); | |
1132 | return; | |
1133 | } | |
1134 | ||
1135 | ||
1136 | input_line_pointer = get_operands (opcode->noperands, op_end, | |
1137 | operand); | |
1138 | *op_end = c; | |
1139 | prev_opcode = opcode; | |
1140 | ||
1141 | opcode = get_specific (opcode, operand); | |
1142 | ||
1143 | if (opcode == 0) | |
1144 | { | |
1145 | /* Couldn't find an opcode which matched the operands */ | |
1146 | char *where = frag_more (2); | |
1147 | ||
1148 | where[0] = 0x0; | |
1149 | where[1] = 0x0; | |
1150 | clever_message (prev_opcode, operand); | |
1151 | ||
1152 | return; | |
1153 | } | |
1154 | if (opcode->size && dot) | |
1155 | { | |
1156 | if (opcode->size != *dot) | |
1157 | { | |
1158 | as_warn ("mismatch between opcode size and operand size"); | |
1159 | } | |
1160 | } | |
1161 | ||
1162 | build_bytes (opcode, operand); | |
1163 | ||
cd8761e1 SC |
1164 | } |
1165 | ||
025b0302 ME |
1166 | void |
1167 | DEFUN (tc_crawl_symbol_chain, (headers), | |
1168 | object_headers * headers) | |
cd8761e1 | 1169 | { |
025b0302 | 1170 | printf ("call to tc_crawl_symbol_chain \n"); |
cd8761e1 SC |
1171 | } |
1172 | ||
025b0302 ME |
1173 | symbolS * |
1174 | DEFUN (md_undefined_symbol, (name), | |
1175 | char *name) | |
cd8761e1 | 1176 | { |
025b0302 | 1177 | return 0; |
cd8761e1 SC |
1178 | } |
1179 | ||
025b0302 ME |
1180 | void |
1181 | DEFUN (tc_headers_hook, (headers), | |
1182 | object_headers * headers) | |
cd8761e1 | 1183 | { |
025b0302 | 1184 | printf ("call to tc_headers_hook \n"); |
cd8761e1 | 1185 | } |
025b0302 | 1186 | |
cd8761e1 | 1187 | void |
025b0302 | 1188 | DEFUN_VOID (md_end) |
cd8761e1 SC |
1189 | { |
1190 | } | |
1191 | ||
1192 | /* Various routines to kill one day */ | |
05b4b0e7 SC |
1193 | /* Equal to MAX_PRECISION in atof-ieee.c */ |
1194 | #define MAX_LITTLENUMS 6 | |
1195 | ||
1196 | /* Turn a string in input_line_pointer into a floating point constant of type | |
1197 | type, and store the appropriate bytes in *litP. The number of LITTLENUMS | |
1198 | emitted is stored in *sizeP . An error message is returned, or NULL on OK. | |
a39116f1 | 1199 | */ |
05b4b0e7 | 1200 | char * |
025b0302 ME |
1201 | md_atof (type, litP, sizeP) |
1202 | char type; | |
1203 | char *litP; | |
1204 | int *sizeP; | |
05b4b0e7 | 1205 | { |
025b0302 ME |
1206 | int prec; |
1207 | LITTLENUM_TYPE words[MAX_LITTLENUMS]; | |
1208 | LITTLENUM_TYPE *wordP; | |
1209 | char *t; | |
1210 | char *atof_ieee (); | |
1211 | ||
1212 | switch (type) | |
1213 | { | |
1214 | case 'f': | |
1215 | case 'F': | |
1216 | case 's': | |
1217 | case 'S': | |
1218 | prec = 2; | |
1219 | break; | |
1220 | ||
1221 | case 'd': | |
1222 | case 'D': | |
1223 | case 'r': | |
1224 | case 'R': | |
1225 | prec = 4; | |
1226 | break; | |
1227 | ||
1228 | case 'x': | |
1229 | case 'X': | |
1230 | prec = 6; | |
1231 | break; | |
1232 | ||
1233 | case 'p': | |
1234 | case 'P': | |
1235 | prec = 6; | |
1236 | break; | |
1237 | ||
1238 | default: | |
1239 | *sizeP = 0; | |
1240 | return "Bad call to MD_ATOF()"; | |
1241 | } | |
1242 | t = atof_ieee (input_line_pointer, type, words); | |
1243 | if (t) | |
1244 | input_line_pointer = t; | |
1245 | ||
1246 | *sizeP = prec * sizeof (LITTLENUM_TYPE); | |
1247 | for (wordP = words; prec--;) | |
1248 | { | |
1249 | md_number_to_chars (litP, (long) (*wordP++), sizeof (LITTLENUM_TYPE)); | |
1250 | litP += sizeof (LITTLENUM_TYPE); | |
1251 | } | |
1252 | return ""; | |
05b4b0e7 SC |
1253 | } |
1254 | ||
1255 | int | |
025b0302 ME |
1256 | md_parse_option (argP, cntP, vecP) |
1257 | char **argP; | |
1258 | int *cntP; | |
1259 | char ***vecP; | |
05b4b0e7 | 1260 | |
a39116f1 | 1261 | { |
025b0302 ME |
1262 | return 0; |
1263 | ||
a39116f1 | 1264 | } |
cd8761e1 SC |
1265 | |
1266 | int md_short_jump_size; | |
1267 | ||
025b0302 ME |
1268 | void |
1269 | tc_aout_fix_to_chars () | |
1270 | { | |
1271 | printf ("call to tc_aout_fix_to_chars \n"); | |
1272 | abort (); | |
1273 | } | |
1274 | ||
1275 | void | |
1276 | md_create_short_jump (ptr, from_addr, to_addr, frag, to_symbol) | |
1277 | char *ptr; | |
1278 | addressT from_addr; | |
1279 | addressT to_addr; | |
1280 | fragS *frag; | |
1281 | symbolS *to_symbol; | |
05b4b0e7 | 1282 | { |
025b0302 | 1283 | as_fatal ("failed sanity check."); |
a39116f1 | 1284 | } |
05b4b0e7 SC |
1285 | |
1286 | void | |
025b0302 ME |
1287 | md_create_long_jump (ptr, from_addr, to_addr, frag, to_symbol) |
1288 | char *ptr; | |
1289 | addressT from_addr, to_addr; | |
1290 | fragS *frag; | |
1291 | symbolS *to_symbol; | |
05b4b0e7 | 1292 | { |
025b0302 | 1293 | as_fatal ("failed sanity check."); |
05b4b0e7 SC |
1294 | } |
1295 | ||
1296 | void | |
025b0302 ME |
1297 | md_convert_frag (headers, fragP) |
1298 | object_headers *headers; | |
1299 | fragS *fragP; | |
05b4b0e7 | 1300 | |
025b0302 ME |
1301 | { |
1302 | printf ("call to md_convert_frag \n"); | |
1303 | abort (); | |
1304 | } | |
cd8761e1 | 1305 | |
1728686e SC |
1306 | valueT md_section_align (seg, size) |
1307 | segT seg; | |
1308 | valueT size; | |
cd8761e1 | 1309 | { |
025b0302 ME |
1310 | return ((size + (1 << section_alignment[(int) seg]) - 1) & (-1 << section_alignment[(int) seg])); |
1311 | ||
cd8761e1 SC |
1312 | } |
1313 | ||
05b4b0e7 | 1314 | void |
025b0302 ME |
1315 | md_apply_fix (fixP, val) |
1316 | fixS *fixP; | |
1317 | long val; | |
05b4b0e7 | 1318 | { |
025b0302 ME |
1319 | char *buf = fixP->fx_where + fixP->fx_frag->fr_literal; |
1320 | ||
1321 | switch (fixP->fx_size) | |
1322 | { | |
1323 | case 1: | |
1324 | *buf++ = val; | |
1325 | break; | |
1326 | case 2: | |
1327 | *buf++ = (val >> 8); | |
1328 | *buf++ = val; | |
1329 | break; | |
1330 | case 4: | |
1331 | *buf++ = (val >> 24); | |
1332 | *buf++ = (val >> 16); | |
1333 | *buf++ = (val >> 8); | |
1334 | *buf++ = val; | |
1335 | break; | |
1336 | default: | |
1337 | abort (); | |
1338 | ||
1339 | } | |
05b4b0e7 | 1340 | } |
cd8761e1 | 1341 | |
025b0302 ME |
1342 | void |
1343 | DEFUN (md_operand, (expressionP), expressionS * expressionP) | |
1344 | { | |
1345 | } | |
cd8761e1 | 1346 | |
025b0302 | 1347 | int md_long_jump_size; |
05b4b0e7 | 1348 | int |
025b0302 ME |
1349 | md_estimate_size_before_relax (fragP, segment_type) |
1350 | register fragS *fragP; | |
1351 | register segT segment_type; | |
1352 | { | |
1353 | printf ("call tomd_estimate_size_before_relax \n"); | |
1354 | abort (); | |
1355 | } | |
1356 | ||
cd8761e1 | 1357 | /* Put number into target byte order */ |
05b4b0e7 | 1358 | |
025b0302 ME |
1359 | void |
1360 | DEFUN (md_number_to_chars, (ptr, use, nbytes), | |
1361 | char *ptr AND | |
1362 | valueT use AND | |
1363 | int nbytes) | |
cd8761e1 | 1364 | { |
025b0302 ME |
1365 | switch (nbytes) |
1366 | { | |
1367 | case 4: | |
1368 | *ptr++ = (use >> 24) & 0xff; | |
1369 | case 3: | |
1370 | *ptr++ = (use >> 16) & 0xff; | |
1371 | case 2: | |
1372 | *ptr++ = (use >> 8) & 0xff; | |
1373 | case 1: | |
1374 | *ptr++ = (use >> 0) & 0xff; | |
1375 | break; | |
1376 | default: | |
1377 | abort (); | |
1378 | } | |
1379 | } | |
1380 | long | |
1381 | md_pcrel_from (fixP) | |
1382 | fixS *fixP; | |
1383 | { | |
1384 | abort (); | |
cd8761e1 | 1385 | } |
cd8761e1 | 1386 | |
025b0302 ME |
1387 | void |
1388 | tc_coff_symbol_emit_hook () | |
1389 | { | |
1390 | } | |
5d9f0ecf SC |
1391 | |
1392 | ||
025b0302 ME |
1393 | void |
1394 | tc_reloc_mangle (fix_ptr, intr, base) | |
1395 | fixS *fix_ptr; | |
1396 | struct internal_reloc *intr; | |
1397 | bfd_vma base; | |
5d9f0ecf SC |
1398 | |
1399 | { | |
025b0302 ME |
1400 | symbolS *symbol_ptr; |
1401 | ||
1402 | symbol_ptr = fix_ptr->fx_addsy; | |
1403 | ||
1404 | /* If this relocation is attached to a symbol then it's ok | |
1405 | to output it */ | |
1406 | if (fix_ptr->fx_r_type == RELOC_32) | |
1407 | { | |
1408 | /* cons likes to create reloc32's whatever the size of the reloc.. | |
1409 | */ | |
1410 | switch (fix_ptr->fx_size) | |
1411 | { | |
1412 | ||
1413 | case 2: | |
1414 | intr->r_type = R_RELWORD; | |
1415 | break; | |
1416 | case 1: | |
1417 | intr->r_type = R_RELBYTE; | |
1418 | break; | |
1419 | default: | |
1420 | abort (); | |
1421 | ||
a39116f1 | 1422 | } |
025b0302 ME |
1423 | |
1424 | } | |
1425 | else | |
1426 | { | |
1427 | intr->r_type = fix_ptr->fx_r_type; | |
1428 | } | |
1429 | ||
1430 | intr->r_vaddr = fix_ptr->fx_frag->fr_address + fix_ptr->fx_where + base; | |
1431 | intr->r_offset = fix_ptr->fx_offset; | |
1432 | ||
1433 | if (symbol_ptr) | |
1434 | intr->r_symndx = symbol_ptr->sy_number; | |
1435 | else | |
1436 | intr->r_symndx = -1; | |
1437 | ||
1438 | ||
1439 | } | |
1440 | ||
1441 | tc_coff_sizemachdep () | |
1442 | { | |
1443 | abort (); | |
5d9f0ecf | 1444 | } |
8b228fe9 RP |
1445 | |
1446 | /* end of tc-h8300.c */ |