Lots of changes for:
[deliverable/binutils-gdb.git] / gas / config / tc-tahoe.c
1 /* tc-tahoe.c
2 Not part of GAS yet. */
3
4 #include "as.h"
5 #include "obstack.h"
6
7 /* this bit glommed from tahoe-inst.h */
8
9 typedef unsigned char byte;
10 typedef byte tahoe_opcodeT;
11
12 /*
13 * This is part of tahoe-ins-parse.c & friends.
14 * We want to parse a tahoe instruction text into a tree defined here.
15 */
16
17 #define TIT_MAX_OPERANDS (4) /* maximum number of operands in one
18 single tahoe instruction */
19
20 struct top /* tahoe instruction operand */
21 {
22 int top_ndx; /* -1, or index register. eg 7=[R7] */
23 int top_reg; /* -1, or register number. eg 7 = R7 or (R7) */
24 byte top_mode; /* Addressing mode byte. This byte, defines
25 which of the 11 modes opcode is. */
26
27 char top_access; /* Access type wanted for this opperand
28 'b'branch ' 'no-instruction 'amrvw' */
29 char top_width; /* Operand width expected, one of "bwlq?-:!" */
30
31 char *top_error; /* Say if operand is inappropriate */
32
33 segT seg_of_operand; /* segment as returned by expression()*/
34
35 expressionS exp_of_operand; /* The expression as parsed by expression()*/
36
37 byte top_dispsize; /* Number of bytes in the displacement if we
38 can figure it out */
39 };
40
41 /* The addressing modes for an operand. These numbers are the acutal values
42 for certain modes, so be carefull if you screw with them. */
43 #define TAHOE_DIRECT_REG (0x50)
44 #define TAHOE_REG_DEFERRED (0x60)
45
46 #define TAHOE_REG_DISP (0xE0)
47 #define TAHOE_REG_DISP_DEFERRED (0xF0)
48
49 #define TAHOE_IMMEDIATE (0x8F)
50 #define TAHOE_IMMEDIATE_BYTE (0x88)
51 #define TAHOE_IMMEDIATE_WORD (0x89)
52 #define TAHOE_IMMEDIATE_LONGWORD (0x8F)
53 #define TAHOE_ABSOLUTE_ADDR (0x9F)
54
55 #define TAHOE_DISPLACED_RELATIVE (0xEF)
56 #define TAHOE_DISP_REL_DEFERRED (0xFF)
57
58 #define TAHOE_AUTO_DEC (0x7E)
59 #define TAHOE_AUTO_INC (0x8E)
60 #define TAHOE_AUTO_INC_DEFERRED (0x9E)
61 /* INDEXED_REG is decided by the existance or lack of a [reg] */
62
63 /* These are encoded into top_width when top_access=='b'
64 and it's a psuedo op.*/
65 #define TAHOE_WIDTH_ALWAYS_JUMP '-'
66 #define TAHOE_WIDTH_CONDITIONAL_JUMP '?'
67 #define TAHOE_WIDTH_BIG_REV_JUMP '!'
68 #define TAHOE_WIDTH_BIG_NON_REV_JUMP ':'
69
70 /* The hex code for certain tahoe commands and modes.
71 This is just for readability. */
72 #define TAHOE_JMP (0x71)
73 #define TAHOE_PC_REL_LONG (0xEF)
74 #define TAHOE_BRB (0x11)
75 #define TAHOE_BRW (0x13)
76 /* These, when 'ored' with, or added to, a register number,
77 set up the number for the displacement mode. */
78 #define TAHOE_PC_OR_BYTE (0xA0)
79 #define TAHOE_PC_OR_WORD (0xC0)
80 #define TAHOE_PC_OR_LONG (0xE0)
81
82 struct tit /* get it out of the sewer, it stands for
83 tahoe instruction tree (Geeze!) */
84 {
85 tahoe_opcodeT tit_opcode; /* The opcode. */
86 byte tit_operands; /* How many operands are here. */
87 struct top tit_operand[TIT_MAX_OPERANDS]; /* Operands */
88 char *tit_error; /* "" or fatal error text */
89 };
90
91 /* end: tahoe-inst.h */
92
93 /* tahoe.c - tahoe-specific -
94 Not part of gas yet.
95 */
96
97 #include "opcode/tahoe.h"
98
99 /* This is the number to put at the beginning of the a.out file */
100 long omagic = OMAGIC;
101
102 /* These chars start a comment anywhere in a source file (except inside
103 another comment or a quoted string. */
104 const char comment_chars[] = "#;";
105
106 /* These chars only start a comment at the beginning of a line. */
107 const char line_comment_chars[] = "#";
108
109 /* Chars that can be used to separate mant from exp in floating point nums */
110 const char EXP_CHARS[] = "eE";
111
112 /* Chars that mean this number is a floating point constant
113 as in 0f123.456
114 or 0d1.234E-12 (see exp chars above)
115 Note: The Tahoe port doesn't support floating point constants. This is
116 consistant with 'as' If it's needed, I can always add it later. */
117 const char FLT_CHARS[] = "df";
118
119 /* Also be aware that MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT may have to be
120 changed in read.c . Ideally it shouldn't have to know about it at all,
121 but nothing is ideal around here.
122 (The tahoe has plenty of room, so the change currently isn't needed.)
123 */
124
125 static struct tit t; /* A tahoe instruction after decoding. */
126
127 void float_cons ();
128 /* A table of pseudo ops (sans .), the function called, and an integer op
129 that the function is called with. */
130
131 const pseudo_typeS md_pseudo_table[] =
132 {
133 {"dfloat", float_cons, 'd'},
134 {"ffloat", float_cons, 'f'},
135 {0}
136 };
137 \f
138 /*
139 * For Tahoe, relative addresses of "just the right length" are pretty easy.
140 * The branch displacement is always the last operand, even in
141 * synthetic instructions.
142 * For Tahoe, we encode the relax_substateTs (in e.g. fr_substate) as:
143 *
144 * 4 3 2 1 0 bit number
145 * ---/ /--+-------+-------+-------+-------+-------+
146 * | what state ? | how long ? |
147 * ---/ /--+-------+-------+-------+-------+-------+
148 *
149 * The "how long" bits are 00=byte, 01=word, 10=long.
150 * This is a Un*x convention.
151 * Not all lengths are legit for a given value of (what state).
152 * The four states are listed below.
153 * The "how long" refers merely to the displacement length.
154 * The address usually has some constant bytes in it as well.
155 *
156
157 States for Tahoe address relaxing.
158 1. TAHOE_WIDTH_ALWAYS_JUMP (-)
159 Format: "b-"
160 Tahoe opcodes are: (Hex)
161 jr 11
162 jbr 11
163 Simple branch.
164 Always, 1 byte opcode, then displacement/absolute.
165 If word or longword, change opcode to brw or jmp.
166
167
168 2. TAHOE_WIDTH_CONDITIONAL_JUMP (?)
169 J<cond> where <cond> is a simple flag test.
170 Format: "b?"
171 Tahoe opcodes are: (Hex)
172 jneq/jnequ 21
173 jeql/jeqlu 31
174 jgtr 41
175 jleq 51
176 jgeq 81
177 jlss 91
178 jgtru a1
179 jlequ b1
180 jvc c1
181 jvs d1
182 jlssu/jcs e1
183 jgequ/jcc f1
184 Always, you complement 4th bit to reverse the condition.
185 Always, 1-byte opcode, then 1-byte displacement.
186
187 3. TAHOE_WIDTH_BIG_REV_JUMP (!)
188 Jbc/Jbs where cond tests a memory bit.
189 Format: "rlvlb!"
190 Tahoe opcodes are: (Hex)
191 jbs 0e
192 jbc 1e
193 Always, you complement 4th bit to reverse the condition.
194 Always, 1-byte opcde, longword, longword-address, 1-word-displacement
195
196 4. TAHOE_WIDTH_BIG_NON_REV_JUMP (:)
197 JaoblXX/Jbssi
198 Format: "rlmlb:"
199 Tahoe opcodes are: (Hex)
200 aojlss 2f
201 jaoblss 2f
202 aojleq 3f
203 jaobleq 3f
204 jbssi 5f
205 Always, we cannot reverse the sense of the branch; we have a word
206 displacement.
207
208 We need to modify the opcode is for class 1, 2 and 3 instructions.
209 After relax() we may complement the 4th bit of 2 or 3 to reverse sense of
210 branch.
211
212 We sometimes store context in the operand literal. This way we can figure out
213 after relax() what the original addressing mode was. (Was is pc_rel, or
214 pc_rel_disp? That sort of thing.) */
215 \f
216 /* These displacements are relative to the START address of the
217 displacement which is at the start of the displacement, not the end of
218 the instruction. The hardware pc_rel is at the end of the instructions.
219 That's why all the displacements have the length of the displacement added
220 to them. (WF + length(word))
221
222 The first letter is Byte, Word.
223 2nd letter is Forward, Backward. */
224 #define BF (1+ 127)
225 #define BB (1+-128)
226 #define WF (2+ 32767)
227 #define WB (2+-32768)
228 /* Dont need LF, LB because they always reach. [They are coded as 0.] */
229
230 #define C(a,b) ENCODE_RELAX(a,b)
231 /* This macro has no side-effects. */
232 #define ENCODE_RELAX(what,length) (((what) << 2) + (length))
233 #define RELAX_STATE(what) ((what) >> 2)
234 #define RELAX_LENGTH(length) ((length) && 3)
235
236 #define STATE_ALWAYS_BRANCH (1)
237 #define STATE_CONDITIONAL_BRANCH (2)
238 #define STATE_BIG_REV_BRANCH (3)
239 #define STATE_BIG_NON_REV_BRANCH (4)
240 #define STATE_PC_RELATIVE (5)
241
242 #define STATE_BYTE (0)
243 #define STATE_WORD (1)
244 #define STATE_LONG (2)
245 #define STATE_UNDF (3) /* Symbol undefined in pass1 */
246
247 /* This is the table used by gas to figure out relaxing modes. The fields are
248 forward_branch reach, backward_branch reach, number of bytes it would take,
249 where the next biggest branch is. */
250 const relax_typeS
251 md_relax_table[] =
252 {
253 {
254 1, 1, 0, 0
255 }, /* error sentinel 0,0 */
256 {
257 1, 1, 0, 0
258 }, /* unused 0,1 */
259 {
260 1, 1, 0, 0
261 }, /* unused 0,2 */
262 {
263 1, 1, 0, 0
264 }, /* unused 0,3 */
265 /* Unconditional branch cases "jrb"
266 The relax part is the actual displacement */
267 {
268 BF, BB, 1, C (1, 1)
269 }, /* brb B`foo 1,0 */
270 {
271 WF, WB, 2, C (1, 2)
272 }, /* brw W`foo 1,1 */
273 {
274 0, 0, 5, 0
275 }, /* Jmp L`foo 1,2 */
276 {
277 1, 1, 0, 0
278 }, /* unused 1,3 */
279 /* Reversible Conditional Branch. If the branch won't reach, reverse
280 it, and jump over a brw or a jmp that will reach. The relax part is the
281 actual address. */
282 {
283 BF, BB, 1, C (2, 1)
284 }, /* b<cond> B`foo 2,0 */
285 {
286 WF + 2, WB + 2, 4, C (2, 2)
287 }, /* brev over, brw W`foo, over: 2,1 */
288 {
289 0, 0, 7, 0
290 }, /* brev over, jmp L`foo, over: 2,2 */
291 {
292 1, 1, 0, 0
293 }, /* unused 2,3 */
294 /* Another type of reversable branch. But this only has a word
295 displacement. */
296 {
297 1, 1, 0, 0
298 }, /* unused 3,0 */
299 {
300 WF, WB, 2, C (3, 2)
301 }, /* jbX W`foo 3,1 */
302 {
303 0, 0, 8, 0
304 }, /* jrevX over, jmp L`foo, over: 3,2 */
305 {
306 1, 1, 0, 0
307 }, /* unused 3,3 */
308 /* These are the non reversable branches, all of which have a word
309 displacement. If I can't reach, branch over a byte branch, to a
310 jump that will reach. The jumped branch jumps over the reaching
311 branch, to continue with the flow of the program. It's like playing
312 leap frog. */
313 {
314 1, 1, 0, 0
315 }, /* unused 4,0 */
316 {
317 WF, WB, 2, C (4, 2)
318 }, /* aobl_ W`foo 4,1 */
319 {
320 0, 0, 10, 0
321 }, /*aobl_ W`hop,br over,hop: jmp L^foo,over 4,2*/
322 {
323 1, 1, 0, 0
324 }, /* unused 4,3 */
325 /* Normal displacement mode, no jumping or anything like that.
326 The relax points to one byte before the address, thats why all
327 the numbers are up by one. */
328 {
329 BF + 1, BB + 1, 2, C (5, 1)
330 }, /* B^"foo" 5,0 */
331 {
332 WF + 1, WB + 1, 3, C (5, 2)
333 }, /* W^"foo" 5,1 */
334 {
335 0, 0, 5, 0
336 }, /* L^"foo" 5,2 */
337 {
338 1, 1, 0, 0
339 }, /* unused 5,3 */
340 };
341
342 #undef C
343 #undef BF
344 #undef BB
345 #undef WF
346 #undef WB
347 /* End relax stuff */
348 \f
349 /* Handle of the OPCODE hash table. NULL means any use before
350 md_begin() will crash. */
351 static struct hash_control *op_hash;
352
353 /* Init function. Build the hash table. */
354 void
355 md_begin ()
356 {
357 struct tot *tP;
358 char *errorval = 0;
359 int synthetic_too = 1; /* If 0, just use real opcodes. */
360
361 if ((op_hash = hash_new ()))
362 {
363 for (tP = totstrs; *tP->name && !*errorval; tP++)
364 {
365 errorval = hash_insert (op_hash, tP->name, &tP->detail);
366 }
367 if (synthetic_too)
368 {
369 for (tP = synthetic_totstrs; *tP->name && !*errorval; tP++)
370 {
371 errorval = hash_insert (op_hash, tP->name, &tP->detail);
372 }
373 }
374 }
375 else
376 {
377 errorval = "Virtual memory exceeded";
378 }
379 if (errorval)
380 as_fatal (errorval);
381 }
382
383 void
384 md_end ()
385 {
386 } /* md_end */
387 \f
388 int
389 md_parse_option (argP, cntP, vecP)
390 char **argP;
391 int *cntP;
392 char ***vecP;
393 {
394 char *temp_name; /* name for -t or -d options */
395 char opt;
396
397 switch (**argP)
398 {
399 case 'a':
400 as_warn ("The -a option doesn't exits. (Dispite what the man page says!");
401
402 case 'J':
403 as_warn ("JUMPIFY (-J) not implemented, use psuedo ops instead.");
404 break;
405
406 case 'S':
407 as_warn ("SYMBOL TABLE not implemented");
408 break; /* SYMBOL TABLE not implemented */
409
410 case 'T':
411 as_warn ("TOKEN TRACE not implemented");
412 break; /* TOKEN TRACE not implemented */
413
414 case 'd':
415 case 't':
416 opt = **argP;
417 if (**argP)
418 { /* Rest of argument is filename. */
419 temp_name = *argP;
420 while (**argP)
421 (*argP)++;
422 }
423 else if (*cntP)
424 {
425 while (**argP)
426 (*argP)++;
427 --(*cntP);
428 temp_name = *++(*vecP);
429 **vecP = NULL; /* Remember this is not a file-name. */
430 }
431 else
432 {
433 as_warn ("I expected a filename after -%c.", opt);
434 temp_name = "{absent}";
435 }
436
437 if (opt == 'd')
438 as_warn ("Displacement length %s ignored!", temp_name);
439 else
440 as_warn ("I don't need or use temp. file \"%s\".", temp_name);
441 break;
442
443 case 'V':
444 as_warn ("I don't use an interpass file! -V ignored");
445 break;
446
447 default:
448 return 0;
449
450 }
451 return 1;
452 }
453 \f
454 /* The functions in this section take numbers in the machine format, and
455 munges them into Tahoe byte order.
456 They exist primarily for cross assembly purpose. */
457 void /* Knows about order of bytes in address. */
458 md_number_to_chars (con, value, nbytes)
459 char con[]; /* Return 'nbytes' of chars here. */
460 valueT value; /* The value of the bits. */
461 int nbytes; /* Number of bytes in the output. */
462 {
463 number_to_chars_bigendian (con, value, nbytes);
464 }
465
466 #ifdef comment
467 void /* Knows about order of bytes in address. */
468 md_number_to_imm (con, value, nbytes)
469 char con[]; /* Return 'nbytes' of chars here. */
470 long int value; /* The value of the bits. */
471 int nbytes; /* Number of bytes in the output. */
472 {
473 md_number_to_chars (con, value, nbytes);
474 }
475
476 #endif /* comment */
477
478 void
479 tc_apply_fix (fixP, val)
480 fixS *fixP;
481 long val;
482 {
483 /* char *place = fixP->fx_where + fixP->fx_frag->fr_literal; */
484 /* should never be called */
485 know (0);
486 return;
487 } /* tc_apply_fix() */
488
489 void /* Knows about order of bytes in address. */
490 md_number_to_disp (con, value, nbytes)
491 char con[]; /* Return 'nbytes' of chars here. */
492 long int value; /* The value of the bits. */
493 int nbytes; /* Number of bytes in the output. */
494 {
495 md_number_to_chars (con, value, nbytes);
496 }
497
498 void /* Knows about order of bytes in address. */
499 md_number_to_field (con, value, nbytes)
500 char con[]; /* Return 'nbytes' of chars here. */
501 long int value; /* The value of the bits. */
502 int nbytes; /* Number of bytes in the output. */
503 {
504 md_number_to_chars (con, value, nbytes);
505 }
506
507 /* Put the bits in an order that a tahoe will understand, despite the ordering
508 of the native machine.
509 On Tahoe: first 4 bytes are normal unsigned big endian long,
510 next three bytes are symbolnum, in kind of 3 byte big endian (least sig. byte last).
511 The last byte is broken up with bit 7 as pcrel,
512 bits 6 & 5 as length,
513 bit 4 as extern and the last nibble as 'undefined'. */
514
515 #if comment
516 void
517 md_ri_to_chars (ri_p, ri)
518 struct relocation_info *ri_p, ri;
519 {
520 byte the_bytes[sizeof (struct relocation_info)];
521 /* The reason I can't just encode these directly into ri_p is that
522 ri_p may point to ri. */
523
524 /* This is easy */
525 md_number_to_chars (the_bytes, ri.r_address, sizeof (ri.r_address));
526
527 /* now the fun stuff */
528 the_bytes[4] = (ri.r_symbolnum >> 16) & 0x0ff;
529 the_bytes[5] = (ri.r_symbolnum >> 8) & 0x0ff;
530 the_bytes[6] = ri.r_symbolnum & 0x0ff;
531 the_bytes[7] = (((ri.r_extern << 4) & 0x10) | ((ri.r_length << 5) & 0x60) |
532 ((ri.r_pcrel << 7) & 0x80)) & 0xf0;
533
534 bcopy (the_bytes, (char *) ri_p, sizeof (struct relocation_info));
535 }
536
537 #endif /* comment */
538
539 /* Put the bits in an order that a tahoe will understand, despite the ordering
540 of the native machine.
541 On Tahoe: first 4 bytes are normal unsigned big endian long,
542 next three bytes are symbolnum, in kind of 3 byte big endian (least sig. byte last).
543 The last byte is broken up with bit 7 as pcrel,
544 bits 6 & 5 as length,
545 bit 4 as extern and the last nibble as 'undefined'. */
546
547 void
548 tc_aout_fix_to_chars (where, fixP, segment_address_in_file)
549 char *where;
550 fixS *fixP;
551 relax_addressT segment_address_in_file;
552 {
553 long r_symbolnum;
554
555 know (fixP->fx_addsy != NULL);
556
557 md_number_to_chars (where,
558 fixP->fx_frag->fr_address + fixP->fx_where - segment_address_in_file,
559 4);
560
561 r_symbolnum = (S_IS_DEFINED (fixP->fx_addsy)
562 ? S_GET_TYPE (fixP->fx_addsy)
563 : fixP->fx_addsy->sy_number);
564
565 where[4] = (r_symbolnum >> 16) & 0x0ff;
566 where[5] = (r_symbolnum >> 8) & 0x0ff;
567 where[6] = r_symbolnum & 0x0ff;
568 where[7] = (((is_pcrel (fixP) << 7) & 0x80)
569 | ((((fixP->fx_type == FX_8 || fixP->fx_type == FX_PCREL8
570 ? 0
571 : (fixP->fx_type == FX_16 || fixP->fx_type == FX_PCREL16
572 ? 1
573 : (fixP->fx_type == FX_32 || fixP->fx_type == FX_PCREL32
574 ? 2
575 : 42)))) << 5) & 0x60)
576 | ((!S_IS_DEFINED (fixP->fx_addsy) << 4) & 0x10));
577
578 return;
579 } /* tc_aout_fix_to_chars() */
580
581 /* Relocate byte stuff */
582 \f
583 /* This is for broken word. */
584 const int md_short_jump_size = 3;
585
586 void
587 md_create_short_jump (ptr, from_addr, to_addr, frag, to_symbol)
588 char *ptr;
589 addressT from_addr, to_addr;
590 fragS *frag;
591 symbolS *to_symbol;
592 {
593 valueT offset;
594
595 offset = to_addr - (from_addr + 1);
596 *ptr++ = TAHOE_BRW;
597 md_number_to_chars (ptr, offset, 2);
598 }
599
600 const int md_long_jump_size = 6;
601 const int md_reloc_size = 8; /* Size of relocation record */
602
603 void
604 md_create_long_jump (ptr, from_addr, to_addr, frag, to_symbol)
605 char *ptr;
606 addressT from_addr, to_addr;
607 fragS *frag;
608 symbolS *to_symbol;
609 {
610 valueT offset;
611
612 offset = to_addr - (from_addr + 4);
613 *ptr++ = TAHOE_JMP;
614 *ptr++ = TAHOE_PC_REL_LONG;
615 md_number_to_chars (ptr, offset, 4);
616 }
617 \f
618 /*
619 * md_estimate_size_before_relax()
620 *
621 * Called just before relax().
622 * Any symbol that is now undefined will not become defined, so we assumed
623 * that it will be resolved by the linker.
624 * Return the correct fr_subtype in the frag, for relax()
625 * Return the initial "guess for fr_var" to caller. (How big I think this
626 * will be.)
627 * The guess for fr_var is ACTUALLY the growth beyond fr_fix.
628 * Whatever we do to grow fr_fix or fr_var contributes to our returned value.
629 * Although it may not be explicit in the frag, pretend fr_var starts with a
630 * 0 value.
631 */
632 int
633 md_estimate_size_before_relax (fragP, segment_type)
634 register fragS *fragP;
635 segT segment_type; /* N_DATA or N_TEXT. */
636 {
637 register char *p;
638 register int old_fr_fix;
639 /* int pc_rel; FIXME: remove this */
640
641 old_fr_fix = fragP->fr_fix;
642 switch (fragP->fr_subtype)
643 {
644 case ENCODE_RELAX (STATE_PC_RELATIVE, STATE_UNDF):
645 if (S_GET_SEGMENT (fragP->fr_symbol) == segment_type)
646 {
647 /* The symbol was in the same segment as the opcode, and it's
648 a real pc_rel case so it's a relaxable case. */
649 fragP->fr_subtype = ENCODE_RELAX (STATE_PC_RELATIVE, STATE_BYTE);
650 }
651 else
652 {
653 /* This case is still undefined, so asume it's a long word for the
654 linker to fix. */
655 p = fragP->fr_literal + old_fr_fix;
656 *p |= TAHOE_PC_OR_LONG;
657 /* We now know how big it will be, one long word. */
658 fragP->fr_fix += 1 + 4;
659 fix_new (fragP, old_fr_fix + 1, fragP->fr_symbol,
660 fragP->fr_offset, FX_PCREL32, NULL);
661 frag_wane (fragP);
662 }
663 break;
664
665 case ENCODE_RELAX (STATE_CONDITIONAL_BRANCH, STATE_UNDF):
666 if (S_GET_SEGMENT (fragP->fr_symbol) == segment_type)
667 {
668 fragP->fr_subtype = ENCODE_RELAX (STATE_CONDITIONAL_BRANCH, STATE_BYTE);
669 }
670 else
671 {
672 p = fragP->fr_literal + old_fr_fix;
673 *fragP->fr_opcode ^= 0x10; /* Reverse sense of branch. */
674 *p++ = 6;
675 *p++ = TAHOE_JMP;
676 *p++ = TAHOE_PC_REL_LONG;
677 fragP->fr_fix += 1 + 1 + 1 + 4;
678 fix_new (fragP, old_fr_fix + 3, fragP->fr_symbol,
679 fragP->fr_offset, FX_PCREL32, NULL);
680 frag_wane (fragP);
681 }
682 break;
683
684 case ENCODE_RELAX (STATE_BIG_REV_BRANCH, STATE_UNDF):
685 if (S_GET_SEGMENT (fragP->fr_symbol) == segment_type)
686 {
687 fragP->fr_subtype =
688 ENCODE_RELAX (STATE_BIG_REV_BRANCH, STATE_WORD);
689 }
690 else
691 {
692 p = fragP->fr_literal + old_fr_fix;
693 *fragP->fr_opcode ^= 0x10; /* Reverse sense of branch. */
694 *p++ = 0;
695 *p++ = 6;
696 *p++ = TAHOE_JMP;
697 *p++ = TAHOE_PC_REL_LONG;
698 fragP->fr_fix += 2 + 2 + 4;
699 fix_new (fragP, old_fr_fix + 4, fragP->fr_symbol,
700 fragP->fr_offset, FX_PCREL32, NULL);
701 frag_wane (fragP);
702 }
703 break;
704
705 case ENCODE_RELAX (STATE_BIG_NON_REV_BRANCH, STATE_UNDF):
706 if (S_GET_SEGMENT (fragP->fr_symbol) == segment_type)
707 {
708 fragP->fr_subtype = ENCODE_RELAX (STATE_BIG_NON_REV_BRANCH, STATE_WORD);
709 }
710 else
711 {
712 p = fragP->fr_literal + old_fr_fix;
713 *p++ = 2;
714 *p++ = 0;
715 *p++ = TAHOE_BRB;
716 *p++ = 6;
717 *p++ = TAHOE_JMP;
718 *p++ = TAHOE_PC_REL_LONG;
719 fragP->fr_fix += 2 + 2 + 2 + 4;
720 fix_new (fragP, old_fr_fix + 6, fragP->fr_symbol,
721 fragP->fr_offset, FX_PCREL32, NULL);
722 frag_wane (fragP);
723 }
724 break;
725
726 case ENCODE_RELAX (STATE_ALWAYS_BRANCH, STATE_UNDF):
727 if (S_GET_SEGMENT (fragP->fr_symbol) == segment_type)
728 {
729 fragP->fr_subtype = ENCODE_RELAX (STATE_ALWAYS_BRANCH, STATE_BYTE);
730 }
731 else
732 {
733 p = fragP->fr_literal + old_fr_fix;
734 *fragP->fr_opcode = TAHOE_JMP;
735 *p++ = TAHOE_PC_REL_LONG;
736 fragP->fr_fix += 1 + 4;
737 fix_new (fragP, old_fr_fix + 1, fragP->fr_symbol,
738 fragP->fr_offset, FX_PCREL32, NULL);
739 frag_wane (fragP);
740 }
741 break;
742
743 default:
744 break;
745 }
746 return (fragP->fr_var + fragP->fr_fix - old_fr_fix);
747 } /* md_estimate_size_before_relax() */
748 \f
749 /*
750 * md_convert_frag();
751 *
752 * Called after relax() is finished.
753 * In: Address of frag.
754 * fr_type == rs_machine_dependent.
755 * fr_subtype is what the address relaxed to.
756 *
757 * Out: Any fixSs and constants are set up.
758 * Caller will turn frag into a ".space 0".
759 */
760 void
761 md_convert_frag (headers, fragP)
762 object_headers *headers;
763 register fragS *fragP;
764 {
765 register char *addressP; /* -> _var to change. */
766 register char *opcodeP; /* -> opcode char(s) to change. */
767 register short int length_code; /* 2=long 1=word 0=byte */
768 register short int extension = 0; /* Size of relaxed address.
769 Added to fr_fix: incl. ALL var chars. */
770 register symbolS *symbolP;
771 register long int where;
772 register long int address_of_var;
773 /* Where, in file space, is _var of *fragP? */
774 register long int target_address;
775 /* Where, in file space, does addr point? */
776
777 know (fragP->fr_type == rs_machine_dependent);
778 length_code = RELAX_LENGTH (fragP->fr_subtype);
779 know (length_code >= 0 && length_code < 3);
780 where = fragP->fr_fix;
781 addressP = fragP->fr_literal + where;
782 opcodeP = fragP->fr_opcode;
783 symbolP = fragP->fr_symbol;
784 know (symbolP);
785 target_address = S_GET_VALUE (symbolP) + fragP->fr_offset;
786 address_of_var = fragP->fr_address + where;
787 switch (fragP->fr_subtype)
788 {
789 case ENCODE_RELAX (STATE_PC_RELATIVE, STATE_BYTE):
790 /* *addressP holds the registers number, plus 0x10, if it's deferred
791 mode. To set up the right mode, just OR the size of this displacement */
792 /* Byte displacement. */
793 *addressP++ |= TAHOE_PC_OR_BYTE;
794 *addressP = target_address - (address_of_var + 2);
795 extension = 2;
796 break;
797
798 case ENCODE_RELAX (STATE_PC_RELATIVE, STATE_WORD):
799 /* Word displacement. */
800 *addressP++ |= TAHOE_PC_OR_WORD;
801 md_number_to_chars (addressP, target_address - (address_of_var + 3), 2);
802 extension = 3;
803 break;
804
805 case ENCODE_RELAX (STATE_PC_RELATIVE, STATE_LONG):
806 /* Long word displacement. */
807 *addressP++ |= TAHOE_PC_OR_LONG;
808 md_number_to_chars (addressP, target_address - (address_of_var + 5), 4);
809 extension = 5;
810 break;
811
812 case ENCODE_RELAX (STATE_CONDITIONAL_BRANCH, STATE_BYTE):
813 *addressP = target_address - (address_of_var + 1);
814 extension = 1;
815 break;
816
817 case ENCODE_RELAX (STATE_CONDITIONAL_BRANCH, STATE_WORD):
818 *opcodeP ^= 0x10; /* Reverse sense of test. */
819 *addressP++ = 3; /* Jump over word branch */
820 *addressP++ = TAHOE_BRW;
821 md_number_to_chars (addressP, target_address - (address_of_var + 4), 2);
822 extension = 4;
823 break;
824
825 case ENCODE_RELAX (STATE_CONDITIONAL_BRANCH, STATE_LONG):
826 *opcodeP ^= 0x10; /* Reverse sense of test. */
827 *addressP++ = 6;
828 *addressP++ = TAHOE_JMP;
829 *addressP++ = TAHOE_PC_REL_LONG;
830 md_number_to_chars (addressP, target_address, 4);
831 extension = 7;
832 break;
833
834 case ENCODE_RELAX (STATE_ALWAYS_BRANCH, STATE_BYTE):
835 *addressP = target_address - (address_of_var + 1);
836 extension = 1;
837 break;
838
839 case ENCODE_RELAX (STATE_ALWAYS_BRANCH, STATE_WORD):
840 *opcodeP = TAHOE_BRW;
841 md_number_to_chars (addressP, target_address - (address_of_var + 2), 2);
842 extension = 2;
843 break;
844
845 case ENCODE_RELAX (STATE_ALWAYS_BRANCH, STATE_LONG):
846 *opcodeP = TAHOE_JMP;
847 *addressP++ = TAHOE_PC_REL_LONG;
848 md_number_to_chars (addressP, target_address - (address_of_var + 5), 4);
849 extension = 5;
850 break;
851
852 case ENCODE_RELAX (STATE_BIG_REV_BRANCH, STATE_WORD):
853 md_number_to_chars (addressP, target_address - (address_of_var + 2), 2);
854 extension = 2;
855 break;
856
857 case ENCODE_RELAX (STATE_BIG_REV_BRANCH, STATE_LONG):
858 *opcodeP ^= 0x10;
859 *addressP++ = 0;
860 *addressP++ = 6;
861 *addressP++ = TAHOE_JMP;
862 *addressP++ = TAHOE_PC_REL_LONG;
863 md_number_to_chars (addressP, target_address, 4);
864 extension = 8;
865 break;
866
867 case ENCODE_RELAX (STATE_BIG_NON_REV_BRANCH, STATE_WORD):
868 md_number_to_chars (addressP, target_address - (address_of_var + 2), 2);
869 extension = 2;
870 break;
871
872 case ENCODE_RELAX (STATE_BIG_NON_REV_BRANCH, STATE_LONG):
873 *addressP++ = 0;
874 *addressP++ = 2;
875 *addressP++ = TAHOE_BRB;
876 *addressP++ = 6;
877 *addressP++ = TAHOE_JMP;
878 *addressP++ = TAHOE_PC_REL_LONG;
879 md_number_to_chars (addressP, target_address, 4);
880 extension = 10;
881 break;
882
883 default:
884 BAD_CASE (fragP->fr_subtype);
885 break;
886 }
887 fragP->fr_fix += extension;
888 } /* md_convert_frag */
889 \f
890
891 /* This is the stuff for md_assemble. */
892 #define FP_REG 13
893 #define SP_REG 14
894 #define PC_REG 15
895 #define BIGGESTREG PC_REG
896
897 /*
898 * Parse the string pointed to by START
899 * If it represents a valid register, point START to the character after
900 * the last valid register char, and return the register number (0-15).
901 * If invalid, leave START alone, return -1.
902 * The format has to be exact. I don't do things like eat leading zeros
903 * or the like.
904 * Note: This doesn't check for the next character in the string making
905 * this invalid. Ex: R123 would return 12, it's the callers job to check
906 * what start is point to apon return.
907 *
908 * Valid registers are R1-R15, %1-%15, FP (13), SP (14), PC (15)
909 * Case doesn't matter.
910 */
911 int
912 tahoe_reg_parse (start)
913 char **start; /* A pointer to the string to parse. */
914 {
915 register char *regpoint = *start;
916 register int regnum = -1;
917
918 switch (*regpoint++)
919 {
920 case '%': /* Registers can start with a %,
921 R or r, and then a number. */
922 case 'R':
923 case 'r':
924 if (isdigit (*regpoint))
925 {
926 /* Got the first digit. */
927 regnum = *regpoint++ - '0';
928 if ((regnum == 1) && isdigit (*regpoint))
929 {
930 /* Its a two digit number. */
931 regnum = 10 + (*regpoint++ - '0');
932 if (regnum > BIGGESTREG)
933 { /* Number too big? */
934 regnum = -1;
935 }
936 }
937 }
938 break;
939 case 'F': /* Is it the FP */
940 case 'f':
941 switch (*regpoint++)
942 {
943 case 'p':
944 case 'P':
945 regnum = FP_REG;
946 }
947 break;
948 case 's': /* How about the SP */
949 case 'S':
950 switch (*regpoint++)
951 {
952 case 'p':
953 case 'P':
954 regnum = SP_REG;
955 }
956 break;
957 case 'p': /* OR the PC even */
958 case 'P':
959 switch (*regpoint++)
960 {
961 case 'c':
962 case 'C':
963 regnum = PC_REG;
964 }
965 break;
966 }
967
968 if (regnum != -1)
969 { /* No error, so move string pointer */
970 *start = regpoint;
971 }
972 return regnum; /* Return results */
973 } /* tahoe_reg_parse */
974 \f
975 /*
976 * This chops up an operand and figures out its modes and stuff.
977 * It's a little touchy about extra characters.
978 * Optex to start with one extra character so it can be overwritten for
979 * the backward part of the parsing.
980 * You can't put a bunch of extra characters in side to
981 * make the command look cute. ie: * foo ( r1 ) [ r0 ]
982 * If you like doing a lot of typing, try COBOL!
983 * Actually, this parser is a little weak all around. It's designed to be
984 * used with compliers, so I emphisise correct decoding of valid code quickly
985 * rather that catching every possable error.
986 * Note: This uses the expression function, so save input_line_pointer before
987 * calling.
988 *
989 * Sperry defines the semantics of address modes (and values)
990 * by a two-letter code, explained here.
991 *
992 * letter 1: access type
993 *
994 * a address calculation - no data access, registers forbidden
995 * b branch displacement
996 * m read - let go of bus - write back "modify"
997 * r read
998 * w write
999 * v bit field address: like 'a' but registers are OK
1000 *
1001 * letter 2: data type (i.e. width, alignment)
1002 *
1003 * b byte
1004 * w word
1005 * l longword
1006 * q quadword (Even regs < 14 allowed) (if 12, you get a warning)
1007 * - unconditional synthetic jbr operand
1008 * ? simple synthetic reversable branch operand
1009 * ! complex synthetic reversable branch operand
1010 * : complex synthetic non-reversable branch operand
1011 *
1012 * The '-?!:' letter 2's are not for external consumption. They are used
1013 * by GAS for psuedo ops relaxing code.
1014 *
1015 * After parsing topP has:
1016 *
1017 * top_ndx: -1, or the index register. eg 7=[R7]
1018 * top_reg: -1, or register number. eg 7 = R7 or (R7)
1019 * top_mode: The addressing mode byte. This byte, defines which of
1020 * the 11 modes opcode is.
1021 * top_access: Access type wanted for this opperand 'b'branch ' '
1022 * no-instruction 'amrvw'
1023 * top_width: Operand width expected, one of "bwlq?-:!"
1024 * exp_of_operand: The expression as parsed by expression()
1025 * top_dispsize: Number of bytes in the displacement if we can figure it
1026 * out and it's relavent.
1027 *
1028 * Need syntax checks built.
1029 */
1030
1031 void
1032 tip_op (optex, topP)
1033 char *optex; /* The users text input, with one leading character */
1034 struct top *topP; /* The tahoe instruction with some fields already set:
1035 in: access, width
1036 out: ndx, reg, mode, error, dispsize */
1037
1038 {
1039 int mode = 0; /* This operand's mode. */
1040 char segfault = *optex; /* To keep the back parsing from freaking. */
1041 char *point = optex + 1; /* Parsing from front to back. */
1042 char *end; /* Parsing from back to front. */
1043 int reg = -1; /* major register, -1 means absent */
1044 int imreg = -1; /* Major register in immediate mode */
1045 int ndx = -1; /* index register number, -1 means absent */
1046 char dec_inc = ' '; /* Is the SP auto-incremented '+' or
1047 auto-decremented '-' or neither ' '. */
1048 int immediate = 0; /* 1 if '$' immediate mode */
1049 int call_width = 0; /* If the caller casts the displacement */
1050 int abs_width = 0; /* The width of the absolute displacment */
1051 int com_width = 0; /* Displacement width required by branch */
1052 int deferred = 0; /* 1 if '*' deferral is used */
1053 byte disp_size = 0; /* How big is this operand. 0 == don't know */
1054 char *op_bad = ""; /* Bad operand error */
1055
1056 char *tp, *temp, c; /* Temporary holders */
1057
1058 char access = topP->top_access; /* Save on a deref. */
1059 char width = topP->top_width;
1060
1061 int really_none = 0; /* Empty expressions evaluate to 0
1062 but I need to know if it's there or not */
1063 expressionS *expP; /* -> expression values for this operand */
1064
1065 /* Does this command restrict the displacement size. */
1066 if (access == 'b')
1067 com_width = (width == 'b' ? 1 :
1068 (width == 'w' ? 2 :
1069 (width == 'l' ? 4 : 0)));
1070
1071 *optex = '\0'; /* This is kind of a back stop for all
1072 the searches to fail on if needed.*/
1073 if (*point == '*')
1074 { /* A dereference? */
1075 deferred = 1;
1076 point++;
1077 }
1078
1079 /* Force words into a certain mode */
1080 /* Bitch, Bitch, Bitch! */
1081 /*
1082 * Using the ^ operator is ambigous. If I have an absolute label
1083 * called 'w' set to, say 2, and I have the expression 'w^1', do I get
1084 * 1, forced to be in word displacement mode, or do I get the value of
1085 * 'w' or'ed with 1 (3 in this case).
1086 * The default is 'w' as an offset, so that's what I use.
1087 * Stick with `, it does the same, and isn't ambig.
1088 */
1089
1090 if (*point != '\0' && ((point[1] == '^') || (point[1] == '`')))
1091 switch (*point)
1092 {
1093 case 'b':
1094 case 'B':
1095 case 'w':
1096 case 'W':
1097 case 'l':
1098 case 'L':
1099 if (com_width)
1100 as_warn ("Casting a branch displacement is bad form, and is ignored.");
1101 else
1102 {
1103 c = (isupper (*point) ? tolower (*point) : *point);
1104 call_width = ((c == 'b') ? 1 :
1105 ((c == 'w') ? 2 : 4));
1106 }
1107 point += 2;
1108 break;
1109 }
1110
1111 /* Setting immediate mode */
1112 if (*point == '$')
1113 {
1114 immediate = 1;
1115 point++;
1116 }
1117
1118 /*
1119 * I've pulled off all the easy stuff off the front, move to the end and
1120 * yank.
1121 */
1122
1123 for (end = point; *end != '\0'; end++) /* Move to the end. */
1124 ;
1125
1126 if (end != point) /* Null string? */
1127 end--;
1128
1129 if (end > point && *end == ' ' && end[-1] != '\'')
1130 end--; /* Hop white space */
1131
1132 /* Is this an index reg. */
1133 if ((*end == ']') && (end[-1] != '\''))
1134 {
1135 temp = end;
1136
1137 /* Find opening brace. */
1138 for (--end; (*end != '[' && end != point); end--)
1139 ;
1140
1141 /* If I found the opening brace, get the index register number. */
1142 if (*end == '[')
1143 {
1144 tp = end + 1; /* tp should point to the start of a reg. */
1145 ndx = tahoe_reg_parse (&tp);
1146 if (tp != temp)
1147 { /* Reg. parse error. */
1148 ndx = -1;
1149 }
1150 else
1151 {
1152 end--; /* Found it, move past brace. */
1153 }
1154 if (ndx == -1)
1155 {
1156 op_bad = "Couldn't parse the [index] in this operand.";
1157 end = point; /* Force all the rest of the tests to fail. */
1158 }
1159 }
1160 else
1161 {
1162 op_bad = "Couldn't find the opening '[' for the index of this operand.";
1163 end = point; /* Force all the rest of the tests to fail. */
1164 }
1165 }
1166
1167 /* Post increment? */
1168 if (*end == '+')
1169 {
1170 dec_inc = '+';
1171 /* was: *end--; */
1172 end--;
1173 }
1174
1175 /* register in parens? */
1176 if ((*end == ')') && (end[-1] != '\''))
1177 {
1178 temp = end;
1179
1180 /* Find opening paren. */
1181 for (--end; (*end != '(' && end != point); end--)
1182 ;
1183
1184 /* If I found the opening paren, get the register number. */
1185 if (*end == '(')
1186 {
1187 tp = end + 1;
1188 reg = tahoe_reg_parse (&tp);
1189 if (tp != temp)
1190 {
1191 /* Not a register, but could be part of the expression. */
1192 reg = -1;
1193 end = temp; /* Rest the pointer back */
1194 }
1195 else
1196 {
1197 end--; /* Found the reg. move before opening paren. */
1198 }
1199 }
1200 else
1201 {
1202 op_bad = "Couldn't find the opening '(' for the deref of this operand.";
1203 end = point; /* Force all the rest of the tests to fail. */
1204 }
1205 }
1206
1207 /* Pre decrement? */
1208 if (*end == '-')
1209 {
1210 if (dec_inc != ' ')
1211 {
1212 op_bad = "Operand can't be both pre-inc and post-dec.";
1213 end = point;
1214 }
1215 else
1216 {
1217 dec_inc = '-';
1218 /* was: *end--; */
1219 end--;
1220 }
1221 }
1222
1223 /*
1224 * Everything between point and end is the 'expression', unless it's
1225 * a register name.
1226 */
1227
1228 c = end[1];
1229 end[1] = '\0';
1230
1231 tp = point;
1232 imreg = tahoe_reg_parse (&point); /* Get the immediate register
1233 if it is there.*/
1234 if (*point != '\0')
1235 {
1236 /* If there is junk after point, then the it's not immediate reg. */
1237 point = tp;
1238 imreg = -1;
1239 }
1240
1241 if (imreg != -1 && reg != -1)
1242 op_bad = "I parsed 2 registers in this operand.";
1243
1244 /*
1245 * Evaluate whats left of the expression to see if it's valid.
1246 * Note again: This assumes that the calling expression has saved
1247 * input_line_pointer. (Nag, nag, nag!)
1248 */
1249
1250 if (*op_bad == '\0')
1251 {
1252 /* statement has no syntax goofs yet: lets sniff the expression */
1253 input_line_pointer = point;
1254 expP = &(topP->exp_of_operand);
1255 topP->seg_of_operand = expression (expP);
1256 switch (expP->X_op)
1257 {
1258 case O_absent:
1259 /* No expression. For BSD4.2 compatibility, missing expression is
1260 absolute 0 */
1261 expP->X_op = O_constant;
1262 expP->X_add_number = 0;
1263 really_none = 1;
1264 case O_constant:
1265 /* for SEG_ABSOLUTE, we shouldnt need to set X_op_symbol,
1266 X_add_symbol to any particular value. */
1267 /* But, we will program defensively. Since this situation occurs
1268 rarely so it costs us little to do so. */
1269 expP->X_add_symbol = NULL;
1270 expP->X_op_symbol = NULL;
1271 /* How many bytes are needed to express this abs value? */
1272 abs_width =
1273 ((((expP->X_add_number & 0xFFFFFF80) == 0) ||
1274 ((expP->X_add_number & 0xFFFFFF80) == 0xFFFFFF80)) ? 1 :
1275 (((expP->X_add_number & 0xFFFF8000) == 0) ||
1276 ((expP->X_add_number & 0xFFFF8000) == 0xFFFF8000)) ? 2 : 4);
1277
1278 case O_symbol:
1279 break;
1280
1281 default:
1282 /*
1283 * Major bug. We can't handle the case of a operator
1284 * expression in a synthetic opcode variable-length
1285 * instruction. We don't have a frag type that is smart
1286 * enough to relax a operator, and so we just force all
1287 * operators to behave like SEG_PASS1s. Clearly, if there is
1288 * a demand we can invent a new or modified frag type and
1289 * then coding up a frag for this case will be easy.
1290 */
1291 need_pass_2 = 1;
1292 op_bad = "Can't relocate expression error.";
1293 break;
1294
1295 case O_big:
1296 /* This is an error. Tahoe doesn't allow any expressions
1297 bigger that a 32 bit long word. Any bigger has to be referenced
1298 by address. */
1299 op_bad = "Expression is too large for a 32 bits.";
1300 break;
1301 }
1302 if (*input_line_pointer != '\0')
1303 {
1304 op_bad = "Junk at end of expression.";
1305 }
1306 }
1307
1308 end[1] = c;
1309
1310 /* I'm done, so restore optex */
1311 *optex = segfault;
1312
1313
1314 /*
1315 * At this point in the game, we (in theory) have all the components of
1316 * the operand at least parsed. Now it's time to check for syntax/semantic
1317 * errors, and build the mode.
1318 * This is what I have:
1319 * deferred = 1 if '*'
1320 * call_width = 0,1,2,4
1321 * abs_width = 0,1,2,4
1322 * com_width = 0,1,2,4
1323 * immediate = 1 if '$'
1324 * ndx = -1 or reg num
1325 * dec_inc = '-' or '+' or ' '
1326 * reg = -1 or reg num
1327 * imreg = -1 or reg num
1328 * topP->exp_of_operand
1329 * really_none
1330 */
1331 /* Is there a displacement size? */
1332 disp_size = (call_width ? call_width :
1333 (com_width ? com_width :
1334 abs_width ? abs_width : 0));
1335
1336 if (*op_bad == '\0')
1337 {
1338 if (imreg != -1)
1339 {
1340 /* Rn */
1341 mode = TAHOE_DIRECT_REG;
1342 if (deferred || immediate || (dec_inc != ' ') ||
1343 (reg != -1) || !really_none)
1344 op_bad = "Syntax error in direct register mode.";
1345 else if (ndx != -1)
1346 op_bad = "You can't index a register in direct register mode.";
1347 else if (imreg == SP_REG && access == 'r')
1348 op_bad =
1349 "SP can't be the source operand with direct register addressing.";
1350 else if (access == 'a')
1351 op_bad = "Can't take the address of a register.";
1352 else if (access == 'b')
1353 op_bad = "Direct Register can't be used in a branch.";
1354 else if (width == 'q' && ((imreg % 2) || (imreg > 13)))
1355 op_bad = "For quad access, the register must be even and < 14.";
1356 else if (call_width)
1357 op_bad = "You can't cast a direct register.";
1358
1359 if (*op_bad == '\0')
1360 {
1361 /* No errors, check for warnings */
1362 if (width == 'q' && imreg == 12)
1363 as_warn ("Using reg 14 for quadwords can tromp the FP register.");
1364
1365 reg = imreg;
1366 }
1367
1368 /* We know: imm = -1 */
1369 }
1370 else if (dec_inc == '-')
1371 {
1372 /* -(SP) */
1373 mode = TAHOE_AUTO_DEC;
1374 if (deferred || immediate || !really_none)
1375 op_bad = "Syntax error in auto-dec mode.";
1376 else if (ndx != -1)
1377 op_bad = "You can't have an index auto dec mode.";
1378 else if (access == 'r')
1379 op_bad = "Auto dec mode cant be used for reading.";
1380 else if (reg != SP_REG)
1381 op_bad = "Auto dec only works of the SP register.";
1382 else if (access == 'b')
1383 op_bad = "Auto dec can't be used in a branch.";
1384 else if (width == 'q')
1385 op_bad = "Auto dec won't work with quadwords.";
1386
1387 /* We know: imm = -1, dec_inc != '-' */
1388 }
1389 else if (dec_inc == '+')
1390 {
1391 if (immediate || !really_none)
1392 op_bad = "Syntax error in one of the auto-inc modes.";
1393 else if (deferred)
1394 {
1395 /* *(SP)+ */
1396 mode = TAHOE_AUTO_INC_DEFERRED;
1397 if (reg != SP_REG)
1398 op_bad = "Auto inc deferred only works of the SP register.";
1399 else if (ndx != -1)
1400 op_bad = "You can't have an index auto inc deferred mode.";
1401 else if (access == 'b')
1402 op_bad = "Auto inc can't be used in a branch.";
1403 }
1404 else
1405 {
1406 /* (SP)+ */
1407 mode = TAHOE_AUTO_INC;
1408 if (access == 'm' || access == 'w')
1409 op_bad = "You can't write to an auto inc register.";
1410 else if (reg != SP_REG)
1411 op_bad = "Auto inc only works of the SP register.";
1412 else if (access == 'b')
1413 op_bad = "Auto inc can't be used in a branch.";
1414 else if (width == 'q')
1415 op_bad = "Auto inc won't work with quadwords.";
1416 else if (ndx != -1)
1417 op_bad = "You can't have an index in auto inc mode.";
1418 }
1419
1420 /* We know: imm = -1, dec_inc == ' ' */
1421 }
1422 else if (reg != -1)
1423 {
1424 if ((ndx != -1) && (reg == SP_REG))
1425 op_bad = "You can't index the sp register.";
1426 if (deferred)
1427 {
1428 /* *<disp>(Rn) */
1429 mode = TAHOE_REG_DISP_DEFERRED;
1430 if (immediate)
1431 op_bad = "Syntax error in register displaced mode.";
1432 }
1433 else if (really_none)
1434 {
1435 /* (Rn) */
1436 mode = TAHOE_REG_DEFERRED;
1437 /* if reg = SP then cant be indexed */
1438 }
1439 else
1440 {
1441 /* <disp>(Rn) */
1442 mode = TAHOE_REG_DISP;
1443 }
1444
1445 /* We know: imm = -1, dec_inc == ' ', Reg = -1 */
1446 }
1447 else
1448 {
1449 if (really_none)
1450 op_bad = "An offest is needed for this operand.";
1451 if (deferred && immediate)
1452 {
1453 /* *$<ADDR> */
1454 mode = TAHOE_ABSOLUTE_ADDR;
1455 disp_size = 4;
1456 }
1457 else if (immediate)
1458 {
1459 /* $<disp> */
1460 mode = TAHOE_IMMEDIATE;
1461 if (ndx != -1)
1462 op_bad = "You can't index a register in immediate mode.";
1463 if (access == 'a')
1464 op_bad = "Immediate access can't be used as an address.";
1465 /* ponder the wisdom of a cast because it doesn't do any good. */
1466 }
1467 else if (deferred)
1468 {
1469 /* *<disp> */
1470 mode = TAHOE_DISP_REL_DEFERRED;
1471 }
1472 else
1473 {
1474 /* <disp> */
1475 mode = TAHOE_DISPLACED_RELATIVE;
1476 }
1477 }
1478 }
1479
1480 /*
1481 * At this point, all the errors we can do have be checked for.
1482 * We can build the 'top'. */
1483
1484 topP->top_ndx = ndx;
1485 topP->top_reg = reg;
1486 topP->top_mode = mode;
1487 topP->top_error = op_bad;
1488 topP->top_dispsize = disp_size;
1489 } /* tip_op */
1490 \f
1491 /*
1492 * t i p ( )
1493 *
1494 * This converts a string into a tahoe instruction.
1495 * The string must be a bare single instruction in tahoe (with BSD4 frobs)
1496 * format.
1497 * It provides at most one fatal error message (which stops the scan)
1498 * some warning messages as it finds them.
1499 * The tahoe instruction is returned in exploded form.
1500 *
1501 * The exploded instruction is returned to a struct tit of your choice.
1502 * #include "tahoe-inst.h" to know what a struct tit is.
1503 *
1504 */
1505
1506 static void
1507 tip (titP, instring)
1508 struct tit *titP; /* We build an exploded instruction here. */
1509 char *instring; /* Text of a vax instruction: we modify. */
1510 {
1511 register struct tot_wot *twP = NULL; /* How to bit-encode this opcode. */
1512 register char *p; /* 1/skip whitespace.2/scan vot_how */
1513 register char *q; /* */
1514 register unsigned char count; /* counts number of operands seen */
1515 register struct top *operandp;/* scan operands in struct tit */
1516 register char *alloperr = ""; /* error over all operands */
1517 register char c; /* Remember char, (we clobber it
1518 with '\0' temporarily). */
1519 char *save_input_line_pointer;
1520
1521 if (*instring == ' ')
1522 ++instring; /* Skip leading whitespace. */
1523 for (p = instring; *p && *p != ' '; p++)
1524 ; /* MUST end in end-of-string or
1525 exactly 1 space. */
1526 /* Scanned up to end of operation-code. */
1527 /* Operation-code is ended with whitespace. */
1528 if (p == instring)
1529 {
1530 titP->tit_error = "No operator";
1531 count = 0;
1532 titP->tit_opcode = 0;
1533 }
1534 else
1535 {
1536 c = *p;
1537 *p = '\0';
1538 /*
1539 * Here with instring pointing to what better be an op-name, and p
1540 * pointing to character just past that.
1541 * We trust instring points to an op-name, with no whitespace.
1542 */
1543 twP = (struct tot_wot *) hash_find (op_hash, instring);
1544 *p = c; /* Restore char after op-code. */
1545 if (twP == 0)
1546 {
1547 titP->tit_error = "Unknown operator";
1548 count = 0;
1549 titP->tit_opcode = 0;
1550 }
1551 else
1552 {
1553 /*
1554 * We found a match! So lets pick up as many operands as the
1555 * instruction wants, and even gripe if there are too many.
1556 * We expect comma to seperate each operand.
1557 * We let instring track the text, while p tracks a part of the
1558 * struct tot.
1559 */
1560
1561 count = 0; /* no operands seen yet */
1562 instring = p + (*p != '\0'); /* point past the operation code */
1563 /* tip_op() screws with the input_line_pointer, so save it before
1564 I jump in */
1565 save_input_line_pointer = input_line_pointer;
1566 for (p = twP->args, operandp = titP->tit_operand;
1567 !*alloperr && *p;
1568 operandp++, p += 2)
1569 {
1570 /*
1571 * Here to parse one operand. Leave instring pointing just
1572 * past any one ',' that marks the end of this operand.
1573 */
1574 if (!p[1])
1575 as_fatal ("Compiler bug: ODD number of bytes in arg structure %s.",
1576 twP->args);
1577 else if (*instring)
1578 {
1579 for (q = instring; (*q != ',' && *q != '\0'); q++)
1580 {
1581 if (*q == '\'' && q[1] != '\0') /* Jump quoted characters */
1582 q++;
1583 }
1584 c = *q;
1585 /*
1586 * Q points to ',' or '\0' that ends argument. C is that
1587 * character.
1588 */
1589 *q = '\0';
1590 operandp->top_access = p[0];
1591 operandp->top_width = p[1];
1592 tip_op (instring - 1, operandp);
1593 *q = c; /* Restore input text. */
1594 if (*(operandp->top_error))
1595 {
1596 alloperr = operandp->top_error;
1597 }
1598 instring = q + (c ? 1 : 0); /* next operand (if any) */
1599 count++; /* won another argument, may have an operr */
1600 }
1601 else
1602 alloperr = "Not enough operands";
1603 }
1604 /* Restore the pointer. */
1605 input_line_pointer = save_input_line_pointer;
1606
1607 if (!*alloperr)
1608 {
1609 if (*instring == ' ')
1610 instring++; /* Skip whitespace. */
1611 if (*instring)
1612 alloperr = "Too many operands";
1613 }
1614 titP->tit_error = alloperr;
1615 }
1616 }
1617
1618 titP->tit_opcode = twP->code; /* The op-code. */
1619 titP->tit_operands = count;
1620 } /* tip */
1621 \f
1622 /* md_assemble() emit frags for 1 instruction */
1623 void
1624 md_assemble (instruction_string)
1625 char *instruction_string; /* A string: assemble 1 instruction. */
1626 {
1627 char *p;
1628 register struct top *operandP;/* An operand. Scans all operands. */
1629 /* char c_save; fixme: remove this line *//* What used to live after an expression. */
1630 /* struct frag *fragP; fixme: remove this line *//* Fragment of code we just made. */
1631 /* register struct top *end_operandP; fixme: remove this line *//* -> slot just after last operand
1632 Limit of the for (each operand). */
1633 register expressionS *expP; /* -> expression values for this operand */
1634
1635 /* These refer to an instruction operand expression. */
1636 segT to_seg; /* Target segment of the address. */
1637
1638 register valueT this_add_number;
1639 register struct symbol *this_add_symbol; /* +ve (minuend) symbol. */
1640
1641 /* tahoe_opcodeT opcode_as_number; fixme: remove this line *//* The opcode as a number. */
1642 char *opcodeP; /* Where it is in a frag. */
1643 /* char *opmodeP; fixme: remove this line *//* Where opcode type is, in a frag. */
1644
1645 int dispsize; /* From top_dispsize: tahoe_operand_width
1646 (in bytes) */
1647 int is_undefined; /* 1 if operand expression's
1648 segment not known yet. */
1649 int pc_rel; /* Is this operand pc relative? */
1650
1651 /* Decode the operand. */
1652 tip (&t, instruction_string);
1653
1654 /*
1655 * Check to see if this operand decode properly.
1656 * Notice that we haven't made any frags yet.
1657 * If it goofed, then this instruction will wedge in any pass,
1658 * and we can safely flush it, without causing interpass symbol phase
1659 * errors. That is, without changing label values in different passes.
1660 */
1661 if (*t.tit_error)
1662 {
1663 as_warn ("Ignoring statement due to \"%s\"", t.tit_error);
1664 }
1665 else
1666 {
1667 /* We saw no errors in any operands - try to make frag(s) */
1668 /* Emit op-code. */
1669 /* Remember where it is, in case we want to modify the op-code later. */
1670 opcodeP = frag_more (1);
1671 *opcodeP = t.tit_opcode;
1672 /* Now do each operand. */
1673 for (operandP = t.tit_operand;
1674 operandP < t.tit_operand + t.tit_operands;
1675 operandP++)
1676 { /* for each operand */
1677 expP = &(operandP->exp_of_operand);
1678 if (operandP->top_ndx >= 0)
1679 {
1680 /* Indexed addressing byte
1681 Legality of indexed mode already checked: it is OK */
1682 FRAG_APPEND_1_CHAR (0x40 + operandP->top_ndx);
1683 } /* if(top_ndx>=0) */
1684
1685 /* Here to make main operand frag(s). */
1686 this_add_number = expP->X_add_number;
1687 this_add_symbol = expP->X_add_symbol;
1688 to_seg = operandP->seg_of_operand;
1689 know (to_seg == SEG_UNKNOWN || \
1690 to_seg == SEG_ABSOLUTE || \
1691 to_seg == SEG_DATA || \
1692 to_seg == SEG_TEXT || \
1693 to_seg == SEG_BSS);
1694 is_undefined = (to_seg == SEG_UNKNOWN);
1695 /* Do we know how big this opperand is? */
1696 dispsize = operandP->top_dispsize;
1697 pc_rel = 0;
1698 /* Deal with the branch possabilities. (Note, this doesn't include
1699 jumps.)*/
1700 if (operandP->top_access == 'b')
1701 {
1702 /* Branches must be expressions. A psuedo branch can also jump to
1703 an absolute address. */
1704 if (to_seg == now_seg || is_undefined)
1705 {
1706 /* If is_undefined, then it might BECOME now_seg by relax time. */
1707 if (dispsize)
1708 {
1709 /* I know how big the branch is supposed to be (it's a normal
1710 branch), so I set up the frag, and let GAS do the rest. */
1711 p = frag_more (dispsize);
1712 fix_new (frag_now, p - frag_now->fr_literal,
1713 this_add_symbol, this_add_number,
1714 size_to_fx (dispsize, 1),
1715 NULL);
1716 }
1717 else
1718 {
1719 /* (to_seg==now_seg || to_seg == SEG_UNKNOWN) && dispsize==0 */
1720 /* If we don't know how big it is, then its a synthetic branch,
1721 so we set up a simple relax state. */
1722 switch (operandP->top_width)
1723 {
1724 case TAHOE_WIDTH_CONDITIONAL_JUMP:
1725 /* Simple (conditional) jump. I may have to reverse the
1726 condition of opcodeP, and then jump to my destination.
1727 I set 1 byte aside for the branch off set, and could need 6
1728 more bytes for the pc_rel jump */
1729 frag_var (rs_machine_dependent, 7, 1,
1730 ENCODE_RELAX (STATE_CONDITIONAL_BRANCH,
1731 is_undefined ? STATE_UNDF : STATE_BYTE),
1732 this_add_symbol, this_add_number, opcodeP);
1733 break;
1734 case TAHOE_WIDTH_ALWAYS_JUMP:
1735 /* Simple (unconditional) jump. I may have to convert this to
1736 a word branch, or an absolute jump. */
1737 frag_var (rs_machine_dependent, 5, 1,
1738 ENCODE_RELAX (STATE_ALWAYS_BRANCH,
1739 is_undefined ? STATE_UNDF : STATE_BYTE),
1740 this_add_symbol, this_add_number, opcodeP);
1741 break;
1742 /* The smallest size for the next 2 cases is word. */
1743 case TAHOE_WIDTH_BIG_REV_JUMP:
1744 frag_var (rs_machine_dependent, 8, 2,
1745 ENCODE_RELAX (STATE_BIG_REV_BRANCH,
1746 is_undefined ? STATE_UNDF : STATE_WORD),
1747 this_add_symbol, this_add_number,
1748 opcodeP);
1749 break;
1750 case TAHOE_WIDTH_BIG_NON_REV_JUMP:
1751 frag_var (rs_machine_dependent, 10, 2,
1752 ENCODE_RELAX (STATE_BIG_NON_REV_BRANCH,
1753 is_undefined ? STATE_UNDF : STATE_WORD),
1754 this_add_symbol, this_add_number,
1755 opcodeP);
1756 break;
1757 default:
1758 as_fatal ("Compliler bug: Got a case (%d) I wasn't expecting.",
1759 operandP->top_width);
1760 }
1761 }
1762 }
1763 else
1764 {
1765 /* to_seg != now_seg && to_seg != seg_unknown (still in branch)
1766 In other words, I'm jumping out of my segment so extend the
1767 branches to jumps, and let GAS fix them. */
1768
1769 /* These are "branches" what will always be branches around a jump
1770 to the correct addresss in real life.
1771 If to_seg is SEG_ABSOLUTE, just encode the branch in,
1772 else let GAS fix the address. */
1773
1774 switch (operandP->top_width)
1775 {
1776 /* The theory:
1777 For SEG_ABSOLUTE, then mode is ABSOLUTE_ADDR, jump
1778 to that addresss (not pc_rel).
1779 For other segs, address is a long word PC rel jump. */
1780 case TAHOE_WIDTH_CONDITIONAL_JUMP:
1781 /* b<cond> */
1782 /* To reverse the condition in a TAHOE branch,
1783 complement bit 4 */
1784 *opcodeP ^= 0x10;
1785 p = frag_more (7);
1786 *p++ = 6;
1787 *p++ = TAHOE_JMP;
1788 *p++ = (operandP->top_mode ==
1789 TAHOE_ABSOLUTE_ADDR ? TAHOE_ABSOLUTE_ADDR :
1790 TAHOE_PC_REL_LONG);
1791 fix_new (frag_now, p - frag_now->fr_literal,
1792 this_add_symbol, this_add_number,
1793 (to_seg != SEG_ABSOLUTE) ? FX_PCREL32 : FX_32, NULL);
1794 /*
1795 * Now (eg) BLEQ 1f
1796 * JMP foo
1797 * 1:
1798 */
1799 break;
1800 case TAHOE_WIDTH_ALWAYS_JUMP:
1801 /* br, just turn it into a jump */
1802 *opcodeP = TAHOE_JMP;
1803 p = frag_more (5);
1804 *p++ = (operandP->top_mode ==
1805 TAHOE_ABSOLUTE_ADDR ? TAHOE_ABSOLUTE_ADDR :
1806 TAHOE_PC_REL_LONG);
1807 fix_new (frag_now, p - frag_now->fr_literal,
1808 this_add_symbol, this_add_number,
1809 (to_seg != SEG_ABSOLUTE) ? FX_PCREL32 : FX_32, NULL);
1810 /* Now (eg) JMP foo */
1811 break;
1812 case TAHOE_WIDTH_BIG_REV_JUMP:
1813 p = frag_more (8);
1814 *opcodeP ^= 0x10;
1815 *p++ = 0;
1816 *p++ = 6;
1817 *p++ = TAHOE_JMP;
1818 *p++ = (operandP->top_mode ==
1819 TAHOE_ABSOLUTE_ADDR ? TAHOE_ABSOLUTE_ADDR :
1820 TAHOE_PC_REL_LONG);
1821 fix_new (frag_now, p - frag_now->fr_literal,
1822 this_add_symbol, this_add_number,
1823 (to_seg != SEG_ABSOLUTE) ? FX_PCREL32 : FX_32, NULL);
1824 /*
1825 * Now (eg) ACBx 1f
1826 * JMP foo
1827 * 1:
1828 */
1829 break;
1830 case TAHOE_WIDTH_BIG_NON_REV_JUMP:
1831 p = frag_more (10);
1832 *p++ = 0;
1833 *p++ = 2;
1834 *p++ = TAHOE_BRB;
1835 *p++ = 6;
1836 *p++ = TAHOE_JMP;
1837 *p++ = (operandP->top_mode ==
1838 TAHOE_ABSOLUTE_ADDR ? TAHOE_ABSOLUTE_ADDR :
1839 TAHOE_PC_REL_LONG);
1840 fix_new (frag_now, p - frag_now->fr_literal,
1841 this_add_symbol, this_add_number,
1842 (to_seg != SEG_ABSOLUTE) ? FX_PCREL32 : FX_32, NULL);
1843 /*
1844 * Now (eg) xOBxxx 1f
1845 * BRB 2f
1846 * 1: JMP @#foo
1847 * 2:
1848 */
1849 break;
1850 case 'b':
1851 case 'w':
1852 as_warn ("Real branch displacements must be expressions.");
1853 break;
1854 default:
1855 as_fatal ("Complier error: I got an unknown synthetic branch :%c",
1856 operandP->top_width);
1857 break;
1858 }
1859 }
1860 }
1861 else
1862 {
1863 /* It ain't a branch operand. */
1864 switch (operandP->top_mode)
1865 {
1866 /* Auto-foo access, only works for one reg (SP)
1867 so the only thing needed is the mode. */
1868 case TAHOE_AUTO_DEC:
1869 case TAHOE_AUTO_INC:
1870 case TAHOE_AUTO_INC_DEFERRED:
1871 FRAG_APPEND_1_CHAR (operandP->top_mode);
1872 break;
1873
1874 /* Numbered Register only access. Only thing needed is the
1875 mode + Register number */
1876 case TAHOE_DIRECT_REG:
1877 case TAHOE_REG_DEFERRED:
1878 FRAG_APPEND_1_CHAR (operandP->top_mode + operandP->top_reg);
1879 break;
1880
1881 /* An absolute address. It's size is always 5 bytes.
1882 (mode_type + 4 byte address). */
1883 case TAHOE_ABSOLUTE_ADDR:
1884 know ((this_add_symbol == NULL));
1885 p = frag_more (5);
1886 *p = TAHOE_ABSOLUTE_ADDR;
1887 md_number_to_chars (p + 1, this_add_number, 4);
1888 break;
1889
1890 /* Immediate data. If the size isn't known, then it's an address
1891 + and offset, which is 4 bytes big. */
1892 case TAHOE_IMMEDIATE:
1893 if (this_add_symbol != NULL)
1894 {
1895 p = frag_more (5);
1896 *p++ = TAHOE_IMMEDIATE_LONGWORD;
1897 fix_new (frag_now, p - frag_now->fr_literal,
1898 this_add_symbol, this_add_number,
1899 FX_32, NULL);
1900 }
1901 else
1902 {
1903 /* It's a integer, and I know it's size. */
1904 if ((unsigned) this_add_number < 0x40)
1905 {
1906 /* Will it fit in a literal? */
1907 FRAG_APPEND_1_CHAR ((byte) this_add_number);
1908 }
1909 else
1910 {
1911 p = frag_more (dispsize + 1);
1912 switch (dispsize)
1913 {
1914 case 1:
1915 *p++ = TAHOE_IMMEDIATE_BYTE;
1916 *p = (byte) this_add_number;
1917 break;
1918 case 2:
1919 *p++ = TAHOE_IMMEDIATE_WORD;
1920 md_number_to_chars (p, this_add_number, 2);
1921 break;
1922 case 4:
1923 *p++ = TAHOE_IMMEDIATE_LONGWORD;
1924 md_number_to_chars (p, this_add_number, 4);
1925 break;
1926 }
1927 }
1928 }
1929 break;
1930
1931 /* Distance from the PC. If the size isn't known, we have to relax
1932 into it. The difference between this and disp(sp) is that
1933 this offset is pc_rel, and disp(sp) isn't.
1934 Note the drop through code. */
1935
1936 case TAHOE_DISPLACED_RELATIVE:
1937 case TAHOE_DISP_REL_DEFERRED:
1938 operandP->top_reg = PC_REG;
1939 pc_rel = 1;
1940
1941 /* Register, plus a displacement mode. Save the register number,
1942 and weather its deffered or not, and relax the size if it isn't
1943 known. */
1944 case TAHOE_REG_DISP:
1945 case TAHOE_REG_DISP_DEFERRED:
1946 if (operandP->top_mode == TAHOE_DISP_REL_DEFERRED ||
1947 operandP->top_mode == TAHOE_REG_DISP_DEFERRED)
1948 operandP->top_reg += 0x10; /* deffered mode is always 0x10 higher
1949 than it's non-deffered sibling. */
1950
1951 /* Is this a value out of this segment?
1952 The first part of this conditional is a cludge to make gas
1953 produce the same output as 'as' when there is a lable, in
1954 the current segment, displaceing a register. It's strange,
1955 and no one in their right mind would do it, but it's easy
1956 to cludge. */
1957 if ((dispsize == 0 && !pc_rel) ||
1958 (to_seg != now_seg && !is_undefined && to_seg != SEG_ABSOLUTE))
1959 dispsize = 4;
1960
1961 if (dispsize == 0)
1962 {
1963 /*
1964 * We have a SEG_UNKNOWN symbol, or the size isn't cast.
1965 * It might turn out to be in the same segment as
1966 * the instruction, permitting relaxation.
1967 */
1968 p = frag_var (rs_machine_dependent, 5, 2,
1969 ENCODE_RELAX (STATE_PC_RELATIVE,
1970 is_undefined ? STATE_UNDF : STATE_BYTE),
1971 this_add_symbol, this_add_number, 0);
1972 *p = operandP->top_reg;
1973 }
1974 else
1975 {
1976 /* Either this is an abs, or a cast. */
1977 p = frag_more (dispsize + 1);
1978 switch (dispsize)
1979 {
1980 case 1:
1981 *p = TAHOE_PC_OR_BYTE + operandP->top_reg;
1982 break;
1983 case 2:
1984 *p = TAHOE_PC_OR_WORD + operandP->top_reg;
1985 break;
1986 case 4:
1987 *p = TAHOE_PC_OR_LONG + operandP->top_reg;
1988 break;
1989 };
1990 fix_new (frag_now, p + 1 - frag_now->fr_literal,
1991 this_add_symbol, this_add_number,
1992 size_to_fx (dispsize, pc_rel), NULL);
1993 }
1994 break;
1995 default:
1996 as_fatal ("Barf, bad mode %x\n", operandP->top_mode);
1997 }
1998 }
1999 } /* for(operandP) */
2000 } /* if(!need_pass_2 && !goofed) */
2001 } /* tahoe_assemble() */
2002
2003
2004 /* We have no need to default values of symbols. */
2005
2006 /* ARGSUSED */
2007 symbolS *
2008 md_undefined_symbol (name)
2009 char *name;
2010 {
2011 return 0;
2012 } /* md_undefined_symbol() */
2013
2014 /* Parse an operand that is machine-specific.
2015 We just return without modifying the expression if we have nothing
2016 to do. */
2017
2018 /* ARGSUSED */
2019 void
2020 md_operand (expressionP)
2021 expressionS *expressionP;
2022 {
2023 } /* md_operand() */
2024
2025 /* Round up a section size to the appropriate boundary. */
2026 valueT
2027 md_section_align (segment, size)
2028 segT segment;
2029 valueT size;
2030 {
2031 return ((size + 7) & ~7); /* Round all sects to multiple of 8 */
2032 } /* md_section_align() */
2033
2034 /* Exactly what point is a PC-relative offset relative TO?
2035 On the sparc, they're relative to the address of the offset, plus
2036 its size. This gets us to the following instruction.
2037 (??? Is this right? FIXME-SOON) */
2038 long
2039 md_pcrel_from (fixP)
2040 fixS *fixP;
2041 {
2042 return (((fixP->fx_type == FX_8
2043 || fixP->fx_type == FX_PCREL8)
2044 ? 1
2045 : ((fixP->fx_type == FX_16
2046 || fixP->fx_type == FX_PCREL16)
2047 ? 2
2048 : ((fixP->fx_type == FX_32
2049 || fixP->fx_type == FX_PCREL32)
2050 ? 4
2051 : 0))) + fixP->fx_where + fixP->fx_frag->fr_address);
2052 } /* md_pcrel_from() */
2053
2054 int
2055 tc_is_pcrel (fixP)
2056 fixS *fixP;
2057 {
2058 /* should never be called */
2059 know (0);
2060 return (0);
2061 } /* tc_is_pcrel() */
2062
2063 /* end of tc-tahoe.c */
This page took 0.106128 seconds and 5 git commands to generate.