Commit | Line | Data |
---|---|---|
252b5132 | 1 | /* ns32k.c -- Assemble on the National Semiconductor 32k series |
310b5aa2 ILT |
2 | Copyright (C) 1987, 92, 93, 94, 95, 96, 97, 98, 1999 |
3 | Free Software Foundation, Inc. | |
252b5132 RH |
4 | |
5 | This file is part of GAS, the GNU Assembler. | |
6 | ||
7 | GAS is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 2, or (at your option) | |
10 | any later version. | |
11 | ||
12 | GAS is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with GAS; see the file COPYING. If not, write to the Free | |
19 | Software Foundation, 59 Temple Place - Suite 330, Boston, MA | |
20 | 02111-1307, USA. */ | |
21 | ||
22 | /*#define SHOW_NUM 1*//* uncomment for debugging */ | |
23 | ||
24 | #include <stdio.h> | |
25 | #include <ctype.h> | |
26 | ||
27 | #include "as.h" | |
28 | #include "opcode/ns32k.h" | |
29 | ||
30 | #include "obstack.h" | |
31 | ||
32 | /* Macros */ | |
33 | #define IIF_ENTRIES 13 /* number of entries in iif */ | |
34 | #define PRIVATE_SIZE 256 /* size of my garbage memory */ | |
35 | #define MAX_ARGS 4 | |
36 | #define DEFAULT -1 /* addr_mode returns this value when | |
37 | plain constant or label is | |
38 | encountered */ | |
39 | ||
40 | #define IIF(ptr,a1,c1,e1,g1,i1,k1,m1,o1,q1,s1,u1) \ | |
41 | iif.iifP[ptr].type= a1; \ | |
42 | iif.iifP[ptr].size= c1; \ | |
43 | iif.iifP[ptr].object= e1; \ | |
44 | iif.iifP[ptr].object_adjust= g1; \ | |
45 | iif.iifP[ptr].pcrel= i1; \ | |
46 | iif.iifP[ptr].pcrel_adjust= k1; \ | |
47 | iif.iifP[ptr].im_disp= m1; \ | |
48 | iif.iifP[ptr].relax_substate= o1; \ | |
49 | iif.iifP[ptr].bit_fixP= q1; \ | |
50 | iif.iifP[ptr].addr_mode= s1; \ | |
51 | iif.iifP[ptr].bsr= u1; | |
52 | ||
53 | #ifdef SEQUENT_COMPATABILITY | |
54 | #define LINE_COMMENT_CHARS "|" | |
55 | #define ABSOLUTE_PREFIX '@' | |
56 | #define IMMEDIATE_PREFIX '#' | |
57 | #endif | |
58 | ||
59 | #ifndef LINE_COMMENT_CHARS | |
60 | #define LINE_COMMENT_CHARS "#" | |
61 | #endif | |
62 | ||
63 | const char comment_chars[] = "#"; | |
64 | const char line_comment_chars[] = LINE_COMMENT_CHARS; | |
65 | const char line_separator_chars[] = ""; | |
66 | #if !defined(ABSOLUTE_PREFIX) && !defined(IMMEDIATE_PREFIX) | |
67 | #define ABSOLUTE_PREFIX '@' /* One or the other MUST be defined */ | |
68 | #endif | |
69 | ||
70 | struct addr_mode | |
71 | { | |
72 | char mode; /* addressing mode of operand (0-31) */ | |
73 | char scaled_mode; /* mode combined with scaled mode */ | |
74 | char scaled_reg; /* register used in scaled+1 (1-8) */ | |
75 | char float_flag; /* set if R0..R7 was F0..F7 ie a | |
76 | floating-point-register */ | |
77 | char am_size; /* estimated max size of general addr-mode | |
78 | parts */ | |
79 | char im_disp; /* if im_disp==1 we have a displacement */ | |
80 | char pcrel; /* 1 if pcrel, this is really redundant info */ | |
81 | char disp_suffix[2]; /* length of displacement(s), 0=undefined */ | |
82 | char *disp[2]; /* pointer(s) at displacement(s) | |
83 | or immediates(s) (ascii) */ | |
84 | char index_byte; /* index byte */ | |
85 | }; | |
86 | typedef struct addr_mode addr_modeS; | |
87 | ||
88 | ||
89 | char *freeptr, *freeptr_static; /* points at some number of free bytes */ | |
90 | struct hash_control *inst_hash_handle; | |
91 | ||
92 | struct ns32k_opcode *desc; /* pointer at description of instruction */ | |
93 | addr_modeS addr_modeP; | |
94 | const char EXP_CHARS[] = "eE"; | |
95 | const char FLT_CHARS[] = "fd"; /* we don't want to support lowercase, do we */ | |
96 | ||
97 | /* UPPERCASE denotes live names when an instruction is built, IIF is | |
98 | * used as an intermediate form to store the actual parts of the | |
99 | * instruction. A ns32k machine instruction can be divided into a | |
100 | * couple of sub PARTs. When an instruction is assembled the | |
101 | * appropriate PART get an assignment. When an IIF has been completed | |
102 | * it is converted to a FRAGment as specified in AS.H */ | |
103 | ||
104 | /* internal structs */ | |
105 | struct ns32k_option | |
106 | { | |
107 | char *pattern; | |
108 | unsigned long or; | |
109 | unsigned long and; | |
110 | }; | |
111 | ||
112 | typedef struct | |
113 | { | |
114 | int type; /* how to interpret object */ | |
115 | int size; /* Estimated max size of object */ | |
116 | unsigned long object; /* binary data */ | |
117 | int object_adjust; /* number added to object */ | |
118 | int pcrel; /* True if object is pcrel */ | |
119 | int pcrel_adjust; /* length in bytes from the | |
120 | instruction start to the | |
121 | displacement */ | |
122 | int im_disp; /* True if the object is a displacement */ | |
123 | relax_substateT relax_substate; /* Initial relaxsubstate */ | |
124 | bit_fixS *bit_fixP; /* Pointer at bit_fix struct */ | |
125 | int addr_mode; /* What addrmode do we associate with this | |
126 | iif-entry */ | |
127 | char bsr; /* Sequent hack */ | |
128 | } iif_entryT; /* Internal Instruction Format */ | |
129 | ||
130 | struct int_ins_form | |
131 | { | |
132 | int instr_size; /* Max size of instruction in bytes. */ | |
133 | iif_entryT iifP[IIF_ENTRIES + 1]; | |
134 | }; | |
135 | struct int_ins_form iif; | |
136 | expressionS exprP; | |
137 | char *input_line_pointer; | |
138 | /* description of the PARTs in IIF | |
139 | *object[n]: | |
140 | * 0 total length in bytes of entries in iif | |
141 | * 1 opcode | |
142 | * 2 index_byte_a | |
143 | * 3 index_byte_b | |
144 | * 4 disp_a_1 | |
145 | * 5 disp_a_2 | |
146 | * 6 disp_b_1 | |
147 | * 7 disp_b_2 | |
148 | * 8 imm_a | |
149 | * 9 imm_b | |
150 | * 10 implied1 | |
151 | * 11 implied2 | |
152 | * | |
153 | * For every entry there is a datalength in bytes. This is stored in size[n]. | |
154 | * 0, the objectlength is not explicitly given by the instruction | |
155 | * and the operand is undefined. This is a case for relaxation. | |
156 | * Reserve 4 bytes for the final object. | |
157 | * | |
158 | * 1, the entry contains one byte | |
159 | * 2, the entry contains two bytes | |
160 | * 3, the entry contains three bytes | |
161 | * 4, the entry contains four bytes | |
162 | * etc | |
163 | * | |
164 | * Furthermore, every entry has a data type identifier in type[n]. | |
165 | * | |
166 | * 0, the entry is void, ignore it. | |
167 | * 1, the entry is a binary number. | |
168 | * 2, the entry is a pointer at an expression. | |
169 | * Where expression may be as simple as a single '1', | |
170 | * and as complicated as foo-bar+12, | |
171 | * foo and bar may be undefined but suffixed by :{b|w|d} to | |
172 | * control the length of the object. | |
173 | * | |
174 | * 3, the entry is a pointer at a bignum struct | |
175 | * | |
176 | * | |
177 | * The low-order-byte coresponds to low physical memory. | |
178 | * Obviously a FRAGment must be created for each valid disp in PART whose | |
179 | * datalength is undefined (to bad) . | |
180 | * The case where just the expression is undefined is less severe and is | |
181 | * handled by fix. Here the number of bytes in the objectfile is known. | |
182 | * With this representation we simplify the assembly and separates the | |
183 | * machine dependent/independent parts in a more clean way (said OE) | |
184 | */ | |
185 | \f | |
186 | struct ns32k_option opt1[] = /* restore, exit */ | |
187 | { | |
188 | {"r0", 0x80, 0xff}, | |
189 | {"r1", 0x40, 0xff}, | |
190 | {"r2", 0x20, 0xff}, | |
191 | {"r3", 0x10, 0xff}, | |
192 | {"r4", 0x08, 0xff}, | |
193 | {"r5", 0x04, 0xff}, | |
194 | {"r6", 0x02, 0xff}, | |
195 | {"r7", 0x01, 0xff}, | |
196 | {0, 0x00, 0xff} | |
197 | }; | |
198 | struct ns32k_option opt2[] = /* save, enter */ | |
199 | { | |
200 | {"r0", 0x01, 0xff}, | |
201 | {"r1", 0x02, 0xff}, | |
202 | {"r2", 0x04, 0xff}, | |
203 | {"r3", 0x08, 0xff}, | |
204 | {"r4", 0x10, 0xff}, | |
205 | {"r5", 0x20, 0xff}, | |
206 | {"r6", 0x40, 0xff}, | |
207 | {"r7", 0x80, 0xff}, | |
208 | {0, 0x00, 0xff} | |
209 | }; | |
210 | struct ns32k_option opt3[] = /* setcfg */ | |
211 | { | |
212 | {"c", 0x8, 0xff}, | |
213 | {"m", 0x4, 0xff}, | |
214 | {"f", 0x2, 0xff}, | |
215 | {"i", 0x1, 0xff}, | |
216 | {0, 0x0, 0xff} | |
217 | }; | |
218 | struct ns32k_option opt4[] = /* cinv */ | |
219 | { | |
220 | {"a", 0x4, 0xff}, | |
221 | {"i", 0x2, 0xff}, | |
222 | {"d", 0x1, 0xff}, | |
223 | {0, 0x0, 0xff} | |
224 | }; | |
225 | struct ns32k_option opt5[] = /* string inst */ | |
226 | { | |
227 | {"b", 0x2, 0xff}, | |
228 | {"u", 0xc, 0xff}, | |
229 | {"w", 0x4, 0xff}, | |
230 | {0, 0x0, 0xff} | |
231 | }; | |
232 | struct ns32k_option opt6[] = /* plain reg ext,cvtp etc */ | |
233 | { | |
234 | {"r0", 0x00, 0xff}, | |
235 | {"r1", 0x01, 0xff}, | |
236 | {"r2", 0x02, 0xff}, | |
237 | {"r3", 0x03, 0xff}, | |
238 | {"r4", 0x04, 0xff}, | |
239 | {"r5", 0x05, 0xff}, | |
240 | {"r6", 0x06, 0xff}, | |
241 | {"r7", 0x07, 0xff}, | |
242 | {0, 0x00, 0xff} | |
243 | }; | |
244 | ||
245 | #if !defined(NS32032) && !defined(NS32532) | |
246 | #define NS32532 | |
247 | #endif | |
248 | ||
249 | struct ns32k_option cpureg_532[] = /* lpr spr */ | |
250 | { | |
251 | {"us", 0x0, 0xff}, | |
252 | {"dcr", 0x1, 0xff}, | |
253 | {"bpc", 0x2, 0xff}, | |
254 | {"dsr", 0x3, 0xff}, | |
255 | {"car", 0x4, 0xff}, | |
256 | {"fp", 0x8, 0xff}, | |
257 | {"sp", 0x9, 0xff}, | |
258 | {"sb", 0xa, 0xff}, | |
259 | {"usp", 0xb, 0xff}, | |
260 | {"cfg", 0xc, 0xff}, | |
261 | {"psr", 0xd, 0xff}, | |
262 | {"intbase", 0xe, 0xff}, | |
263 | {"mod", 0xf, 0xff}, | |
264 | {0, 0x00, 0xff} | |
265 | }; | |
266 | struct ns32k_option mmureg_532[] = /* lmr smr */ | |
267 | { | |
268 | {"mcr", 0x9, 0xff}, | |
269 | {"msr", 0xa, 0xff}, | |
270 | {"tear", 0xb, 0xff}, | |
271 | {"ptb0", 0xc, 0xff}, | |
272 | {"ptb1", 0xd, 0xff}, | |
273 | {"ivar0", 0xe, 0xff}, | |
274 | {"ivar1", 0xf, 0xff}, | |
275 | {0, 0x0, 0xff} | |
276 | }; | |
277 | ||
278 | struct ns32k_option cpureg_032[] = /* lpr spr */ | |
279 | { | |
280 | {"upsr", 0x0, 0xff}, | |
281 | {"fp", 0x8, 0xff}, | |
282 | {"sp", 0x9, 0xff}, | |
283 | {"sb", 0xa, 0xff}, | |
284 | {"psr", 0xd, 0xff}, | |
285 | {"intbase", 0xe, 0xff}, | |
286 | {"mod", 0xf, 0xff}, | |
287 | {0, 0x0, 0xff} | |
288 | }; | |
289 | struct ns32k_option mmureg_032[] = /* lmr smr */ | |
290 | { | |
291 | {"bpr0", 0x0, 0xff}, | |
292 | {"bpr1", 0x1, 0xff}, | |
293 | {"pf0", 0x4, 0xff}, | |
294 | {"pf1", 0x5, 0xff}, | |
295 | {"sc", 0x8, 0xff}, | |
296 | {"msr", 0xa, 0xff}, | |
297 | {"bcnt", 0xb, 0xff}, | |
298 | {"ptb0", 0xc, 0xff}, | |
299 | {"ptb1", 0xd, 0xff}, | |
300 | {"eia", 0xf, 0xff}, | |
301 | {0, 0x0, 0xff} | |
302 | }; | |
303 | ||
304 | #if defined(NS32532) | |
305 | struct ns32k_option *cpureg = cpureg_532; | |
306 | struct ns32k_option *mmureg = mmureg_532; | |
307 | #else | |
308 | struct ns32k_option *cpureg = cpureg_032; | |
309 | struct ns32k_option *mmureg = mmureg_032; | |
310 | #endif | |
311 | \f | |
312 | ||
313 | const pseudo_typeS md_pseudo_table[] = | |
314 | { /* so far empty */ | |
315 | {0, 0, 0} | |
316 | }; | |
317 | ||
318 | #define IND(x,y) (((x)<<2)+(y)) | |
319 | ||
320 | /* those are index's to relax groups in md_relax_table ie it must be | |
321 | multiplied by 4 to point at a group start. Viz IND(x,y) Se function | |
322 | relax_segment in write.c for more info */ | |
323 | ||
324 | #define BRANCH 1 | |
325 | #define PCREL 2 | |
326 | ||
327 | /* those are index's to entries in a relax group */ | |
328 | ||
329 | #define BYTE 0 | |
330 | #define WORD 1 | |
331 | #define DOUBLE 2 | |
332 | #define UNDEF 3 | |
333 | /* Those limits are calculated from the displacement start in memory. | |
334 | The ns32k uses the begining of the instruction as displacement | |
335 | base. This type of displacements could be handled here by moving | |
336 | the limit window up or down. I choose to use an internal | |
337 | displacement base-adjust as there are other routines that must | |
338 | consider this. Also, as we have two various offset-adjusts in the | |
339 | ns32k (acb versus br/brs/jsr/bcond), two set of limits would have | |
340 | had to be used. Now we dont have to think about that. */ | |
341 | ||
342 | ||
343 | const relax_typeS md_relax_table[] = | |
344 | { | |
345 | {1, 1, 0, 0}, | |
346 | {1, 1, 0, 0}, | |
347 | {1, 1, 0, 0}, | |
348 | {1, 1, 0, 0}, | |
349 | ||
350 | {(63), (-64), 1, IND (BRANCH, WORD)}, | |
351 | {(8192), (-8192), 2, IND (BRANCH, DOUBLE)}, | |
352 | {0, 0, 4, 0}, | |
353 | {1, 1, 0, 0} | |
354 | }; | |
355 | ||
356 | /* Array used to test if mode contains displacements. | |
357 | Value is true if mode contains displacement. */ | |
358 | ||
359 | char disp_test[] = | |
360 | {0, 0, 0, 0, 0, 0, 0, 0, | |
361 | 1, 1, 1, 1, 1, 1, 1, 1, | |
362 | 1, 1, 1, 0, 0, 1, 1, 0, | |
363 | 1, 1, 1, 1, 1, 1, 1, 1}; | |
364 | ||
365 | /* Array used to calculate max size of displacements */ | |
366 | ||
367 | char disp_size[] = | |
368 | {4, 1, 2, 0, 4}; | |
369 | \f | |
370 | static void evaluate_expr PARAMS ((expressionS * resultP, char *ptr)); | |
371 | static void md_number_to_disp PARAMS ((char *buf, long val, int n)); | |
372 | static void md_number_to_imm PARAMS ((char *buf, long val, int n)); | |
373 | ||
374 | /* Parses a general operand into an addressingmode struct | |
375 | ||
376 | in: pointer at operand in ascii form | |
377 | pointer at addr_mode struct for result | |
378 | the level of recursion. (always 0 or 1) | |
379 | ||
380 | out: data in addr_mode struct | |
381 | */ | |
382 | int | |
383 | addr_mode (operand, addr_modeP, recursive_level) | |
384 | char *operand; | |
385 | register addr_modeS *addr_modeP; | |
386 | int recursive_level; | |
387 | { | |
388 | register char *str; | |
389 | register int i; | |
390 | register int strl; | |
391 | register int mode; | |
392 | int j; | |
393 | mode = DEFAULT; /* default */ | |
394 | addr_modeP->scaled_mode = 0; /* why not */ | |
395 | addr_modeP->scaled_reg = 0; /* if 0, not scaled index */ | |
396 | addr_modeP->float_flag = 0; | |
397 | addr_modeP->am_size = 0; | |
398 | addr_modeP->im_disp = 0; | |
399 | addr_modeP->pcrel = 0; /* not set in this function */ | |
400 | addr_modeP->disp_suffix[0] = 0; | |
401 | addr_modeP->disp_suffix[1] = 0; | |
402 | addr_modeP->disp[0] = NULL; | |
403 | addr_modeP->disp[1] = NULL; | |
404 | str = operand; | |
405 | if (str[0] == 0) | |
406 | { | |
407 | return (0); | |
408 | } /* we don't want this */ | |
409 | strl = strlen (str); | |
410 | switch (str[0]) | |
411 | { | |
412 | /* the following three case statements controls the mode-chars | |
413 | this is the place to ed if you want to change them */ | |
414 | #ifdef ABSOLUTE_PREFIX | |
415 | case ABSOLUTE_PREFIX: | |
416 | if (str[strl - 1] == ']') | |
417 | break; | |
418 | addr_modeP->mode = 21; /* absolute */ | |
419 | addr_modeP->disp[0] = str + 1; | |
420 | return (-1); | |
421 | #endif | |
422 | #ifdef IMMEDIATE_PREFIX | |
423 | case IMMEDIATE_PREFIX: | |
424 | if (str[strl - 1] == ']') | |
425 | break; | |
426 | addr_modeP->mode = 20; /* immediate */ | |
427 | addr_modeP->disp[0] = str + 1; | |
428 | return (-1); | |
429 | #endif | |
430 | case '.': | |
431 | if (str[strl - 1] != ']') | |
432 | { | |
433 | switch (str[1]) | |
434 | { | |
435 | case '-': | |
436 | case '+': | |
437 | if (str[2] != '\000') | |
438 | { | |
439 | addr_modeP->mode = 27; /* pc-relativ */ | |
440 | addr_modeP->disp[0] = str + 2; | |
441 | return (-1); | |
442 | } | |
443 | default: | |
444 | as_warn (_("Invalid syntax in PC-relative addressing mode")); | |
445 | return (0); | |
446 | } | |
447 | } | |
448 | break; | |
449 | case 'e': | |
450 | if (str[strl - 1] != ']') | |
451 | { | |
452 | if ((!strncmp (str, "ext(", 4)) && strl > 7) | |
453 | { /* external */ | |
454 | addr_modeP->disp[0] = str + 4; | |
455 | i = 0; | |
456 | j = 2; | |
457 | do | |
458 | { /* disp[0]'s termination point */ | |
459 | j += 1; | |
460 | if (str[j] == '(') | |
461 | i++; | |
462 | if (str[j] == ')') | |
463 | i--; | |
464 | } | |
465 | while (j < strl && i != 0); | |
466 | if (i != 0 || !(str[j + 1] == '-' || str[j + 1] == '+')) | |
467 | { | |
468 | as_warn (_("Invalid syntax in External addressing mode")); | |
469 | return (0); | |
470 | } | |
471 | str[j] = '\000'; /* null terminate disp[0] */ | |
472 | addr_modeP->disp[1] = str + j + 2; | |
473 | addr_modeP->mode = 22; | |
474 | return (-1); | |
475 | } | |
476 | } | |
477 | break; | |
478 | default:; | |
479 | } | |
480 | strl = strlen (str); | |
481 | switch (strl) | |
482 | { | |
483 | case 2: | |
484 | switch (str[0]) | |
485 | { | |
486 | case 'f': | |
487 | addr_modeP->float_flag = 1; | |
488 | case 'r': | |
489 | if (str[1] >= '0' && str[1] < '8') | |
490 | { | |
491 | addr_modeP->mode = str[1] - '0'; | |
492 | return (-1); | |
493 | } | |
494 | } | |
495 | case 3: | |
496 | if (!strncmp (str, "tos", 3)) | |
497 | { | |
498 | addr_modeP->mode = 23; /* TopOfStack */ | |
499 | return (-1); | |
500 | } | |
501 | default:; | |
502 | } | |
503 | if (strl > 4) | |
504 | { | |
505 | if (str[strl - 1] == ')') | |
506 | { | |
507 | if (str[strl - 2] == ')') | |
508 | { | |
509 | if (!strncmp (&str[strl - 5], "(fp", 3)) | |
510 | { | |
511 | mode = 16; /* Memory Relative */ | |
512 | } | |
513 | if (!strncmp (&str[strl - 5], "(sp", 3)) | |
514 | { | |
515 | mode = 17; | |
516 | } | |
517 | if (!strncmp (&str[strl - 5], "(sb", 3)) | |
518 | { | |
519 | mode = 18; | |
520 | } | |
521 | if (mode != DEFAULT) | |
522 | { /* memory relative */ | |
523 | addr_modeP->mode = mode; | |
524 | j = strl - 5; /* temp for end of disp[0] */ | |
525 | i = 0; | |
526 | do | |
527 | { | |
528 | strl -= 1; | |
529 | if (str[strl] == ')') | |
530 | i++; | |
531 | if (str[strl] == '(') | |
532 | i--; | |
533 | } | |
534 | while (strl > -1 && i != 0); | |
535 | if (i != 0) | |
536 | { | |
537 | as_warn (_("Invalid syntax in Memory Relative addressing mode")); | |
538 | return (0); | |
539 | } | |
540 | addr_modeP->disp[1] = str; | |
541 | addr_modeP->disp[0] = str + strl + 1; | |
542 | str[j] = '\000'; /* null terminate disp[0] */ | |
543 | str[strl] = '\000'; /* null terminate disp[1] */ | |
544 | return (-1); | |
545 | } | |
546 | } | |
547 | switch (str[strl - 3]) | |
548 | { | |
549 | case 'r': | |
550 | case 'R': | |
551 | if (str[strl - 2] >= '0' | |
552 | && str[strl - 2] < '8' | |
553 | && str[strl - 4] == '(') | |
554 | { | |
555 | addr_modeP->mode = str[strl - 2] - '0' + 8; | |
556 | addr_modeP->disp[0] = str; | |
557 | str[strl - 4] = 0; | |
558 | return (-1); /* reg rel */ | |
559 | } | |
560 | default: | |
561 | if (!strncmp (&str[strl - 4], "(fp", 3)) | |
562 | { | |
563 | mode = 24; | |
564 | } | |
565 | if (!strncmp (&str[strl - 4], "(sp", 3)) | |
566 | { | |
567 | mode = 25; | |
568 | } | |
569 | if (!strncmp (&str[strl - 4], "(sb", 3)) | |
570 | { | |
571 | mode = 26; | |
572 | } | |
573 | if (!strncmp (&str[strl - 4], "(pc", 3)) | |
574 | { | |
575 | mode = 27; | |
576 | } | |
577 | if (mode != DEFAULT) | |
578 | { | |
579 | addr_modeP->mode = mode; | |
580 | addr_modeP->disp[0] = str; | |
581 | str[strl - 4] = '\0'; | |
582 | return (-1); /* memory space */ | |
583 | } | |
584 | } | |
585 | } | |
586 | /* no trailing ')' do we have a ']' ? */ | |
587 | if (str[strl - 1] == ']') | |
588 | { | |
589 | switch (str[strl - 2]) | |
590 | { | |
591 | case 'b': | |
592 | mode = 28; | |
593 | break; | |
594 | case 'w': | |
595 | mode = 29; | |
596 | break; | |
597 | case 'd': | |
598 | mode = 30; | |
599 | break; | |
600 | case 'q': | |
601 | mode = 31; | |
602 | break; | |
603 | default:; | |
604 | as_warn (_("Invalid scaled-indexed mode, use (b,w,d,q)")); | |
605 | if (str[strl - 3] != ':' || str[strl - 6] != '[' | |
606 | || str[strl - 5] == 'r' || str[strl - 4] < '0' | |
607 | || str[strl - 4] > '7') | |
608 | { | |
609 | as_warn (_("Syntax in scaled-indexed mode, use [Rn:m] where n=[0..7] m={b,w,d,q}")); | |
610 | } | |
611 | } /* scaled index */ | |
612 | { | |
613 | if (recursive_level > 0) | |
614 | { | |
615 | as_warn (_("Scaled-indexed addressing mode combined with scaled-index")); | |
616 | return (0); | |
617 | } | |
618 | addr_modeP->am_size += 1; /* scaled index byte */ | |
619 | j = str[strl - 4] - '0'; /* store temporary */ | |
620 | str[strl - 6] = '\000'; /* nullterminate for recursive call */ | |
621 | i = addr_mode (str, addr_modeP, 1); | |
622 | if (!i || addr_modeP->mode == 20) | |
623 | { | |
624 | as_warn (_("Invalid or illegal addressing mode combined with scaled-index")); | |
625 | return (0); | |
626 | } | |
627 | addr_modeP->scaled_mode = addr_modeP->mode; /* store the inferior | |
628 | mode */ | |
629 | addr_modeP->mode = mode; | |
630 | addr_modeP->scaled_reg = j + 1; | |
631 | return (-1); | |
632 | } | |
633 | } | |
634 | } | |
635 | addr_modeP->mode = DEFAULT; /* default to whatever */ | |
636 | addr_modeP->disp[0] = str; | |
637 | return (-1); | |
638 | } | |
639 | \f | |
640 | /* ptr points at string addr_modeP points at struct with result This | |
641 | routine calls addr_mode to determine the general addr.mode of the | |
642 | operand. When this is ready it parses the displacements for size | |
643 | specifying suffixes and determines size of immediate mode via | |
644 | ns32k-opcode. Also builds index bytes if needed. */ | |
645 | int | |
646 | get_addr_mode (ptr, addr_modeP) | |
647 | char *ptr; | |
648 | addr_modeS *addr_modeP; | |
649 | { | |
650 | int tmp; | |
651 | addr_mode (ptr, addr_modeP, 0); | |
652 | if (addr_modeP->mode == DEFAULT || addr_modeP->scaled_mode == -1) | |
653 | { | |
654 | /* resolve ambigious operands, this shouldn't be necessary if | |
655 | one uses standard NSC operand syntax. But the sequent | |
656 | compiler doesn't!!! This finds a proper addressinging mode | |
657 | if it is implicitly stated. See ns32k-opcode.h */ | |
658 | (void) evaluate_expr (&exprP, ptr); /* this call takes time Sigh! */ | |
659 | if (addr_modeP->mode == DEFAULT) | |
660 | { | |
661 | if (exprP.X_add_symbol || exprP.X_op_symbol) | |
662 | { | |
663 | addr_modeP->mode = desc->default_model; /* we have a label */ | |
664 | } | |
665 | else | |
666 | { | |
667 | addr_modeP->mode = desc->default_modec; /* we have a constant */ | |
668 | } | |
669 | } | |
670 | else | |
671 | { | |
672 | if (exprP.X_add_symbol || exprP.X_op_symbol) | |
673 | { | |
674 | addr_modeP->scaled_mode = desc->default_model; | |
675 | } | |
676 | else | |
677 | { | |
678 | addr_modeP->scaled_mode = desc->default_modec; | |
679 | } | |
680 | } | |
681 | /* must put this mess down in addr_mode to handle the scaled | |
682 | case better */ | |
683 | } | |
684 | /* It appears as the sequent compiler wants an absolute when we have | |
685 | a label without @. Constants becomes immediates besides the addr | |
686 | case. Think it does so with local labels too, not optimum, pcrel | |
687 | is better. When I have time I will make gas check this and | |
688 | select pcrel when possible Actually that is trivial. */ | |
689 | if (tmp = addr_modeP->scaled_reg) | |
690 | { /* build indexbyte */ | |
691 | tmp--; /* remember regnumber comes incremented for | |
692 | flagpurpose */ | |
693 | tmp |= addr_modeP->scaled_mode << 3; | |
694 | addr_modeP->index_byte = (char) tmp; | |
695 | addr_modeP->am_size += 1; | |
696 | } | |
697 | if (disp_test[addr_modeP->mode]) | |
698 | { /* there was a displacement, probe for length | |
699 | specifying suffix */ | |
700 | { | |
701 | register char c; | |
702 | register char suffix; | |
703 | register char suffix_sub; | |
704 | register int i; | |
705 | register char *toP; | |
706 | register char *fromP; | |
707 | ||
708 | addr_modeP->pcrel = 0; | |
709 | if (disp_test[addr_modeP->mode]) | |
710 | { /* there is a displacement */ | |
711 | if (addr_modeP->mode == 27 || addr_modeP->scaled_mode == 27) | |
712 | { /* do we have pcrel. mode */ | |
713 | addr_modeP->pcrel = 1; | |
714 | } | |
715 | addr_modeP->im_disp = 1; | |
716 | for (i = 0; i < 2; i++) | |
717 | { | |
718 | suffix_sub = suffix = 0; | |
719 | if (toP = addr_modeP->disp[i]) | |
720 | { /* suffix of expression, the largest size | |
721 | rules */ | |
722 | fromP = toP; | |
723 | while (c = *fromP++) | |
724 | { | |
725 | *toP++ = c; | |
726 | if (c == ':') | |
727 | { | |
728 | switch (*fromP) | |
729 | { | |
730 | case '\0': | |
731 | as_warn (_("Premature end of suffix -- Defaulting to d")); | |
732 | suffix = 4; | |
733 | continue; | |
734 | case 'b': | |
735 | suffix_sub = 1; | |
736 | break; | |
737 | case 'w': | |
738 | suffix_sub = 2; | |
739 | break; | |
740 | case 'd': | |
741 | suffix_sub = 4; | |
742 | break; | |
743 | default: | |
744 | as_warn (_("Bad suffix after ':' use {b|w|d} Defaulting to d")); | |
745 | suffix = 4; | |
746 | } | |
747 | fromP++; | |
748 | toP--; /* So we write over the ':' */ | |
749 | if (suffix < suffix_sub) | |
750 | suffix = suffix_sub; | |
751 | } | |
752 | } | |
753 | *toP = '\0';/* terminate properly */ | |
754 | addr_modeP->disp_suffix[i] = suffix; | |
755 | addr_modeP->am_size += suffix ? suffix : 4; | |
756 | } | |
757 | } | |
758 | } | |
759 | } | |
760 | } | |
761 | else | |
762 | { | |
763 | if (addr_modeP->mode == 20) | |
764 | { /* look in ns32k_opcode for size */ | |
765 | addr_modeP->disp_suffix[0] = addr_modeP->am_size = desc->im_size; | |
766 | addr_modeP->im_disp = 0; | |
767 | } | |
768 | } | |
769 | return addr_modeP->mode; | |
770 | } | |
771 | ||
772 | ||
773 | /* read an optionlist */ | |
774 | void | |
775 | optlist (str, optionP, default_map) | |
776 | char *str; /* the string to extract options from */ | |
777 | struct ns32k_option *optionP; /* how to search the string */ | |
778 | unsigned long *default_map; /* default pattern and output */ | |
779 | { | |
780 | register int i, j, k, strlen1, strlen2; | |
781 | register char *patternP, *strP; | |
782 | strlen1 = strlen (str); | |
783 | if (strlen1 < 1) | |
784 | { | |
785 | as_fatal (_("Very short instr to option, ie you can't do it on a NULLstr")); | |
786 | } | |
787 | for (i = 0; optionP[i].pattern != 0; i++) | |
788 | { | |
789 | strlen2 = strlen (optionP[i].pattern); | |
790 | for (j = 0; j < strlen1; j++) | |
791 | { | |
792 | patternP = optionP[i].pattern; | |
793 | strP = &str[j]; | |
794 | for (k = 0; k < strlen2; k++) | |
795 | { | |
796 | if (*(strP++) != *(patternP++)) | |
797 | break; | |
798 | } | |
799 | if (k == strlen2) | |
800 | { /* match */ | |
801 | *default_map |= optionP[i].or; | |
802 | *default_map &= optionP[i].and; | |
803 | } | |
804 | } | |
805 | } | |
806 | } | |
807 | ||
808 | /* search struct for symbols | |
809 | This function is used to get the short integer form of reg names in | |
810 | the instructions lmr, smr, lpr, spr return true if str is found in | |
811 | list */ | |
812 | ||
813 | int | |
814 | list_search (str, optionP, default_map) | |
815 | char *str; /* the string to match */ | |
816 | struct ns32k_option *optionP; /* list to search */ | |
817 | unsigned long *default_map; /* default pattern and output */ | |
818 | { | |
819 | register int i; | |
820 | for (i = 0; optionP[i].pattern != 0; i++) | |
821 | { | |
822 | if (!strncmp (optionP[i].pattern, str, 20)) | |
823 | { /* use strncmp to be safe */ | |
824 | *default_map |= optionP[i].or; | |
825 | *default_map &= optionP[i].and; | |
826 | return -1; | |
827 | } | |
828 | } | |
829 | as_warn (_("No such entry in list. (cpu/mmu register)")); | |
830 | return 0; | |
831 | } | |
832 | ||
833 | static void | |
834 | evaluate_expr (resultP, ptr) | |
835 | expressionS *resultP; | |
836 | char *ptr; | |
837 | { | |
838 | register char *tmp_line; | |
839 | ||
840 | tmp_line = input_line_pointer; | |
841 | input_line_pointer = ptr; | |
842 | expression (&exprP); | |
843 | input_line_pointer = tmp_line; | |
844 | } | |
845 | \f | |
846 | /* Convert operands to iif-format and adds bitfields to the opcode. | |
847 | Operands are parsed in such an order that the opcode is updated from | |
848 | its most significant bit, that is when the operand need to alter the | |
849 | opcode. | |
850 | Be carefull not to put to objects in the same iif-slot. | |
851 | */ | |
852 | ||
853 | void | |
854 | encode_operand (argc, argv, operandsP, suffixP, im_size, opcode_bit_ptr) | |
855 | int argc; | |
856 | char **argv; | |
857 | char *operandsP; | |
858 | char *suffixP; | |
859 | char im_size; | |
860 | char opcode_bit_ptr; | |
861 | { | |
862 | register int i, j; | |
863 | char d; | |
864 | int pcrel, tmp, b, loop, pcrel_adjust; | |
865 | for (loop = 0; loop < argc; loop++) | |
866 | { | |
867 | i = operandsP[loop << 1] - '1'; /* what operand are we supposed | |
868 | to work on */ | |
869 | if (i > 3) | |
870 | as_fatal (_("Internal consistency error. check ns32k-opcode.h")); | |
871 | pcrel = 0; | |
872 | pcrel_adjust = 0; | |
873 | tmp = 0; | |
874 | switch ((d = operandsP[(loop << 1) + 1])) | |
875 | { | |
876 | case 'f': /* operand of sfsr turns out to be a nasty | |
877 | specialcase */ | |
878 | opcode_bit_ptr -= 5; | |
879 | case 'Z': /* float not immediate */ | |
880 | case 'F': /* 32 bit float general form */ | |
881 | case 'L': /* 64 bit float */ | |
882 | case 'I': /* integer not immediate */ | |
883 | case 'B': /* byte */ | |
884 | case 'W': /* word */ | |
885 | case 'D': /* double-word */ | |
886 | case 'A': /* double-word gen-address-form ie no regs | |
887 | allowed */ | |
888 | get_addr_mode (argv[i], &addr_modeP); | |
889 | if((addr_modeP.mode == 20) && | |
890 | (d == 'I' || d == 'Z' || d == 'A')) { | |
891 | as_fatal(d == 'A'? _("Address of immediate operand"): | |
892 | _("Invalid immediate write operand.")); | |
893 | } | |
894 | ||
895 | if (opcode_bit_ptr == desc->opcode_size) | |
896 | b = 4; | |
897 | else | |
898 | b = 6; | |
899 | for (j = b; j < (b + 2); j++) | |
900 | { | |
901 | if (addr_modeP.disp[j - b]) | |
902 | { | |
903 | IIF (j, | |
904 | 2, | |
905 | addr_modeP.disp_suffix[j - b], | |
906 | (unsigned long) addr_modeP.disp[j - b], | |
907 | 0, | |
908 | addr_modeP.pcrel, | |
909 | iif.instr_size, | |
910 | addr_modeP.im_disp, | |
911 | IND (BRANCH, BYTE), | |
912 | NULL, | |
913 | (addr_modeP.scaled_reg ? addr_modeP.scaled_mode | |
914 | : addr_modeP.mode), | |
915 | 0); | |
916 | } | |
917 | } | |
918 | opcode_bit_ptr -= 5; | |
919 | iif.iifP[1].object |= ((long) addr_modeP.mode) << opcode_bit_ptr; | |
920 | if (addr_modeP.scaled_reg) | |
921 | { | |
922 | j = b / 2; | |
923 | IIF (j, 1, 1, (unsigned long) addr_modeP.index_byte, | |
924 | 0, 0, 0, 0, 0, NULL, -1, 0); | |
925 | } | |
926 | break; | |
927 | case 'b': /* multiple instruction disp */ | |
928 | freeptr++; /* OVE:this is an useful hack */ | |
929 | sprintf (freeptr, "((%s-1)*%d)\000", argv[i], desc->im_size); | |
930 | argv[i] = freeptr; | |
931 | pcrel -= 1; /* make pcrel 0 inspite of what case 'p': | |
932 | wants */ | |
933 | /* fall thru */ | |
934 | case 'p': /* displacement - pc relative addressing */ | |
935 | pcrel += 1; | |
936 | /* fall thru */ | |
937 | case 'd': /* displacement */ | |
938 | iif.instr_size += suffixP[i] ? suffixP[i] : 4; | |
939 | IIF (12, 2, suffixP[i], (unsigned long) argv[i], 0, | |
940 | pcrel, pcrel_adjust, 1, IND (BRANCH, BYTE), NULL, -1, 0); | |
941 | break; | |
942 | case 'H': /* sequent-hack: the linker wants a bit set | |
943 | when bsr */ | |
944 | pcrel = 1; | |
945 | iif.instr_size += suffixP[i] ? suffixP[i] : 4; | |
946 | IIF (12, 2, suffixP[i], (unsigned long) argv[i], 0, | |
947 | pcrel, pcrel_adjust, 1, IND (BRANCH, BYTE), NULL, -1, 1); | |
948 | break; | |
949 | case 'q': /* quick */ | |
950 | opcode_bit_ptr -= 4; | |
951 | IIF (11, 2, 42, (unsigned long) argv[i], 0, 0, 0, 0, 0, | |
952 | bit_fix_new (4, opcode_bit_ptr, -8, 7, 0, 1, 0), -1, 0); | |
953 | break; | |
954 | case 'r': /* register number (3 bits) */ | |
955 | list_search (argv[i], opt6, &tmp); | |
956 | opcode_bit_ptr -= 3; | |
957 | iif.iifP[1].object |= tmp << opcode_bit_ptr; | |
958 | break; | |
959 | case 'O': /* setcfg instruction optionslist */ | |
960 | optlist (argv[i], opt3, &tmp); | |
961 | opcode_bit_ptr -= 4; | |
962 | iif.iifP[1].object |= tmp << 15; | |
963 | break; | |
964 | case 'C': /* cinv instruction optionslist */ | |
965 | optlist (argv[i], opt4, &tmp); | |
966 | opcode_bit_ptr -= 4; | |
967 | iif.iifP[1].object |= tmp << 15; /* insert the regtype in opcode */ | |
968 | break; | |
969 | case 'S': /* stringinstruction optionslist */ | |
970 | optlist (argv[i], opt5, &tmp); | |
971 | opcode_bit_ptr -= 4; | |
972 | iif.iifP[1].object |= tmp << 15; | |
973 | break; | |
974 | case 'u': | |
975 | case 'U': /* registerlist */ | |
976 | IIF (10, 1, 1, 0, 0, 0, 0, 0, 0, NULL, -1, 0); | |
977 | switch (operandsP[(i << 1) + 1]) | |
978 | { | |
979 | case 'u': /* restore, exit */ | |
980 | optlist (argv[i], opt1, &iif.iifP[10].object); | |
981 | break; | |
982 | case 'U': /* save,enter */ | |
983 | optlist (argv[i], opt2, &iif.iifP[10].object); | |
984 | break; | |
985 | } | |
986 | iif.instr_size += 1; | |
987 | break; | |
988 | case 'M': /* mmu register */ | |
989 | list_search (argv[i], mmureg, &tmp); | |
990 | opcode_bit_ptr -= 4; | |
991 | iif.iifP[1].object |= tmp << opcode_bit_ptr; | |
992 | break; | |
993 | case 'P': /* cpu register */ | |
994 | list_search (argv[i], cpureg, &tmp); | |
995 | opcode_bit_ptr -= 4; | |
996 | iif.iifP[1].object |= tmp << opcode_bit_ptr; | |
997 | break; | |
998 | case 'g': /* inss exts */ | |
999 | iif.instr_size += 1; /* 1 byte is allocated after the opcode */ | |
1000 | IIF (10, 2, 1, | |
1001 | (unsigned long) argv[i], /* i always 2 here */ | |
1002 | 0, 0, 0, 0, 0, | |
1003 | bit_fix_new (3, 5, 0, 7, 0, 0, 0), /* a bit_fix is targeted to | |
1004 | the byte */ | |
1005 | -1, 0); | |
1006 | break; | |
1007 | case 'G': | |
1008 | IIF (11, 2, 42, | |
1009 | (unsigned long) argv[i], /* i always 3 here */ | |
1010 | 0, 0, 0, 0, 0, | |
1011 | bit_fix_new (5, 0, 1, 32, -1, 0, -1), -1, 0); | |
1012 | break; | |
1013 | case 'i': | |
1014 | iif.instr_size += 1; | |
1015 | b = 2 + i; /* put the extension byte after opcode */ | |
1016 | IIF (b, 2, 1, 0, 0, 0, 0, 0, 0, 0, -1, 0); | |
1017 | break; | |
1018 | default: | |
1019 | as_fatal (_("Bad opcode-table-option, check in file ns32k-opcode.h")); | |
1020 | } | |
1021 | } | |
1022 | } | |
1023 | \f | |
1024 | /* in: instruction line | |
1025 | out: internal structure of instruction | |
1026 | that has been prepared for direct conversion to fragment(s) and | |
1027 | fixes in a systematical fashion | |
1028 | Return-value = recursive_level | |
1029 | */ | |
1030 | /* build iif of one assembly text line */ | |
1031 | int | |
1032 | parse (line, recursive_level) | |
1033 | char *line; | |
1034 | int recursive_level; | |
1035 | { | |
1036 | register char *lineptr, c, suffix_separator; | |
1037 | register int i; | |
1038 | int argc, arg_type; | |
1039 | char sqr, sep; | |
1040 | char suffix[MAX_ARGS], *argv[MAX_ARGS]; /* no more than 4 operands */ | |
1041 | if (recursive_level <= 0) | |
1042 | { /* called from md_assemble */ | |
1043 | for (lineptr = line; (*lineptr) != '\0' && (*lineptr) != ' '; lineptr++); | |
1044 | c = *lineptr; | |
1045 | *lineptr = '\0'; | |
1046 | if (!(desc = (struct ns32k_opcode *) hash_find (inst_hash_handle, line))) | |
1047 | { | |
1048 | as_fatal (_("No such opcode")); | |
1049 | } | |
1050 | *lineptr = c; | |
1051 | } | |
1052 | else | |
1053 | { | |
1054 | lineptr = line; | |
1055 | } | |
1056 | argc = 0; | |
1057 | if (*desc->operands) | |
1058 | { | |
1059 | if (*lineptr++ != '\0') | |
1060 | { | |
1061 | sqr = '['; | |
1062 | sep = ','; | |
1063 | while (*lineptr != '\0') | |
1064 | { | |
1065 | if (desc->operands[argc << 1]) | |
1066 | { | |
1067 | suffix[argc] = 0; | |
1068 | arg_type = desc->operands[(argc << 1) + 1]; | |
1069 | switch (arg_type) | |
1070 | { | |
1071 | case 'd': | |
1072 | case 'b': | |
1073 | case 'p': | |
1074 | case 'H': /* the operand is supposed to be a | |
1075 | displacement */ | |
1076 | /* Hackwarning: do not forget to update the 4 | |
1077 | cases above when editing ns32k-opcode.h */ | |
1078 | suffix_separator = ':'; | |
1079 | break; | |
1080 | default: | |
1081 | suffix_separator = '\255'; /* if this char occurs we | |
1082 | loose */ | |
1083 | } | |
1084 | suffix[argc] = 0; /* 0 when no ':' is encountered */ | |
1085 | argv[argc] = freeptr; | |
1086 | *freeptr = '\0'; | |
1087 | while ((c = *lineptr) != '\0' && c != sep) | |
1088 | { | |
1089 | if (c == sqr) | |
1090 | { | |
1091 | if (sqr == '[') | |
1092 | { | |
1093 | sqr = ']'; | |
1094 | sep = '\0'; | |
1095 | } | |
1096 | else | |
1097 | { | |
1098 | sqr = '['; | |
1099 | sep = ','; | |
1100 | } | |
1101 | } | |
1102 | if (c == suffix_separator) | |
1103 | { /* ':' - label/suffix separator */ | |
1104 | switch (lineptr[1]) | |
1105 | { | |
1106 | case 'b': | |
1107 | suffix[argc] = 1; | |
1108 | break; | |
1109 | case 'w': | |
1110 | suffix[argc] = 2; | |
1111 | break; | |
1112 | case 'd': | |
1113 | suffix[argc] = 4; | |
1114 | break; | |
1115 | default: | |
1116 | as_warn (_("Bad suffix, defaulting to d")); | |
1117 | suffix[argc] = 4; | |
1118 | if (lineptr[1] == '\0' || lineptr[1] == sep) | |
1119 | { | |
1120 | lineptr += 1; | |
1121 | continue; | |
1122 | } | |
1123 | } | |
1124 | lineptr += 2; | |
1125 | continue; | |
1126 | } | |
1127 | *freeptr++ = c; | |
1128 | lineptr++; | |
1129 | } | |
1130 | *freeptr++ = '\0'; | |
1131 | argc += 1; | |
1132 | if (*lineptr == '\0') | |
1133 | continue; | |
1134 | lineptr += 1; | |
1135 | } | |
1136 | else | |
1137 | { | |
1138 | as_fatal (_("Too many operands passed to instruction")); | |
1139 | } | |
1140 | } | |
1141 | } | |
1142 | } | |
1143 | if (argc != strlen (desc->operands) / 2) | |
1144 | { | |
1145 | if (strlen (desc->default_args)) | |
1146 | { /* we can apply default, dont goof */ | |
1147 | if (parse (desc->default_args, 1) != 1) | |
1148 | { /* check error in default */ | |
1149 | as_fatal (_("Wrong numbers of operands in default, check ns32k-opcodes.h")); | |
1150 | } | |
1151 | } | |
1152 | else | |
1153 | { | |
1154 | as_fatal (_("Wrong number of operands")); | |
1155 | } | |
1156 | ||
1157 | } | |
1158 | for (i = 0; i < IIF_ENTRIES; i++) | |
1159 | { | |
1160 | iif.iifP[i].type = 0; /* mark all entries as void*/ | |
1161 | } | |
1162 | ||
1163 | /* build opcode iif-entry */ | |
1164 | iif.instr_size = desc->opcode_size / 8; | |
1165 | IIF (1, 1, iif.instr_size, desc->opcode_seed, 0, 0, 0, 0, 0, 0, -1, 0); | |
1166 | ||
1167 | /* this call encodes operands to iif format */ | |
1168 | if (argc) | |
1169 | { | |
1170 | encode_operand (argc, | |
1171 | argv, | |
1172 | &desc->operands[0], | |
1173 | &suffix[0], | |
1174 | desc->im_size, | |
1175 | desc->opcode_size); | |
1176 | } | |
1177 | return recursive_level; | |
1178 | } | |
1179 | \f | |
1180 | ||
1181 | /* Convert iif to fragments. From this point we start to dribble with | |
1182 | * functions in other files than this one.(Except hash.c) So, if it's | |
1183 | * possible to make an iif for an other CPU, you don't need to know | |
1184 | * what frags, relax, obstacks, etc is in order to port this | |
1185 | * assembler. You only need to know if it's possible to reduce your | |
1186 | * cpu-instruction to iif-format (takes some work) and adopt the other | |
1187 | * md_? parts according to given instructions Note that iif was | |
1188 | * invented for the clean ns32k`s architecure. | |
1189 | */ | |
1190 | ||
1191 | /* GAS for the ns32k has a problem. PC relative displacements are | |
1192 | * relative to the address of the opcode, not the address of the | |
1193 | * operand. We used to keep track of the offset between the operand | |
1194 | * and the opcode in pcrel_adjust for each frag and each fix. However, | |
1195 | * we get into trouble where there are two or more pc-relative | |
1196 | * operands and the size of the first one can't be determined. Then in | |
1197 | * the relax phase, the size of the first operand will change and | |
1198 | * pcrel_adjust will no longer be correct. The current solution is | |
1199 | * keep a pointer to the frag with the opcode in it and the offset in | |
1200 | * that frag for each frag and each fix. Then, when needed, we can | |
1201 | * always figure out how far it is between the opcode and the pcrel | |
1202 | * object. See also md_pcrel_adjust and md_fix_pcrel_adjust. For | |
1203 | * objects not part of an instruction, the pointer to the opcode frag | |
1204 | * is always zero. */ | |
1205 | ||
1206 | void | |
1207 | convert_iif () | |
1208 | { | |
1209 | int i; | |
1210 | bit_fixS *j; | |
1211 | fragS *inst_frag; | |
1212 | unsigned int inst_offset; | |
1213 | char *inst_opcode; | |
1214 | char *memP; | |
1215 | int l; | |
1216 | int k; | |
1217 | char type; | |
1218 | char size = 0; | |
1219 | int size_so_far; | |
1220 | ||
1221 | memP = frag_more (0); | |
1222 | inst_opcode = memP; | |
1223 | inst_offset = (memP - frag_now->fr_literal); | |
1224 | inst_frag = frag_now; | |
1225 | ||
1226 | for (i = 0; i < IIF_ENTRIES; i++) | |
1227 | { | |
1228 | if (type = iif.iifP[i].type) | |
1229 | { /* the object exist, so handle it */ | |
1230 | switch (size = iif.iifP[i].size) | |
1231 | { | |
1232 | case 42: | |
1233 | size = 0; /* it's a bitfix that operates on an existing | |
1234 | object*/ | |
1235 | if (iif.iifP[i].bit_fixP->fx_bit_base) | |
1236 | { /* expand fx_bit_base to point at opcode */ | |
1237 | iif.iifP[i].bit_fixP->fx_bit_base = (long) inst_opcode; | |
1238 | } | |
1239 | case 8: /* bignum or doublefloat */ | |
1240 | case 1: | |
1241 | case 2: | |
1242 | case 3: | |
1243 | case 4: /* the final size in objectmemory is known */ | |
1244 | memP = frag_more(size); | |
1245 | j = iif.iifP[i].bit_fixP; | |
1246 | switch (type) | |
1247 | { | |
1248 | case 1: /* the object is pure binary */ | |
1249 | if (j || iif.iifP[i].pcrel) | |
1250 | { | |
1251 | fix_new_ns32k (frag_now, | |
1252 | (long) (memP - frag_now->fr_literal), | |
1253 | size, | |
1254 | 0, | |
1255 | iif.iifP[i].object, | |
1256 | iif.iifP[i].pcrel, | |
1257 | iif.iifP[i].im_disp, | |
1258 | j, | |
1259 | iif.iifP[i].bsr, /* sequent hack */ | |
1260 | inst_frag, inst_offset); | |
1261 | } | |
1262 | else | |
1263 | { /* good, just put them bytes out */ | |
1264 | switch (iif.iifP[i].im_disp) | |
1265 | { | |
1266 | case 0: | |
1267 | md_number_to_chars (memP, iif.iifP[i].object, size); | |
1268 | break; | |
1269 | case 1: | |
1270 | md_number_to_disp (memP, iif.iifP[i].object, size); | |
1271 | break; | |
1272 | default: | |
1273 | as_fatal (_("iif convert internal pcrel/binary")); | |
1274 | } | |
1275 | } | |
1276 | break; | |
1277 | case 2: | |
1278 | /* the object is a pointer at an expression, so | |
1279 | unpack it, note that bignums may result from the | |
1280 | expression */ | |
1281 | evaluate_expr (&exprP, (char *) iif.iifP[i].object); | |
1282 | if (exprP.X_op == O_big || size == 8) | |
1283 | { | |
1284 | if ((k = exprP.X_add_number) > 0) | |
1285 | { | |
1286 | /* we have a bignum ie a quad. This can only | |
1287 | happens in a long suffixed instruction */ | |
1288 | if (k * 2 > size) | |
1289 | as_warn (_("Bignum too big for long")); | |
1290 | if (k == 3) | |
1291 | memP += 2; | |
1292 | for (l = 0; k > 0; k--, l += 2) | |
1293 | { | |
1294 | md_number_to_chars (memP + l, | |
1295 | generic_bignum[l >> 1], | |
1296 | sizeof (LITTLENUM_TYPE)); | |
1297 | } | |
1298 | } | |
1299 | else | |
1300 | { /* flonum */ | |
1301 | LITTLENUM_TYPE words[4]; | |
1302 | ||
1303 | switch (size) | |
1304 | { | |
1305 | case 4: | |
1306 | gen_to_words (words, 2, 8); | |
1307 | md_number_to_imm (memP, (long) words[0], | |
1308 | sizeof (LITTLENUM_TYPE)); | |
1309 | md_number_to_imm (memP + sizeof (LITTLENUM_TYPE), | |
1310 | (long) words[1], | |
1311 | sizeof (LITTLENUM_TYPE)); | |
1312 | break; | |
1313 | case 8: | |
1314 | gen_to_words (words, 4, 11); | |
1315 | md_number_to_imm (memP, (long) words[0], | |
1316 | sizeof (LITTLENUM_TYPE)); | |
1317 | md_number_to_imm (memP + sizeof (LITTLENUM_TYPE), | |
1318 | (long) words[1], | |
1319 | sizeof (LITTLENUM_TYPE)); | |
1320 | md_number_to_imm ((memP + 2 | |
1321 | * sizeof (LITTLENUM_TYPE)), | |
1322 | (long) words[2], | |
1323 | sizeof (LITTLENUM_TYPE)); | |
1324 | md_number_to_imm ((memP + 3 | |
1325 | * sizeof (LITTLENUM_TYPE)), | |
1326 | (long) words[3], | |
1327 | sizeof (LITTLENUM_TYPE)); | |
1328 | break; | |
1329 | } | |
1330 | } | |
1331 | break; | |
1332 | } | |
1333 | if (j || | |
1334 | exprP.X_add_symbol || | |
1335 | exprP.X_op_symbol || | |
1336 | iif.iifP[i].pcrel) | |
1337 | { | |
1338 | /* The expression was undefined due to an | |
1339 | undefined label. Create a fix so we can fix | |
1340 | the object later. */ | |
1341 | exprP.X_add_number += iif.iifP[i].object_adjust; | |
1342 | fix_new_ns32k_exp (frag_now, | |
1343 | (long) (memP - frag_now->fr_literal), | |
1344 | size, | |
1345 | &exprP, | |
1346 | iif.iifP[i].pcrel, | |
1347 | iif.iifP[i].im_disp, | |
1348 | j, | |
1349 | iif.iifP[i].bsr, | |
1350 | inst_frag, inst_offset); | |
1351 | } | |
1352 | else | |
1353 | { | |
1354 | /* good, just put them bytes out */ | |
1355 | switch (iif.iifP[i].im_disp) | |
1356 | { | |
1357 | case 0: | |
1358 | md_number_to_imm (memP, exprP.X_add_number, size); | |
1359 | break; | |
1360 | case 1: | |
1361 | md_number_to_disp (memP, exprP.X_add_number, size); | |
1362 | break; | |
1363 | default: | |
1364 | as_fatal (_("iif convert internal pcrel/pointer")); | |
1365 | } | |
1366 | } | |
1367 | break; | |
1368 | default: | |
1369 | as_fatal (_("Internal logic error in iif.iifP[n].type")); | |
1370 | } | |
1371 | break; | |
1372 | case 0: | |
1373 | /* To bad, the object may be undefined as far as its | |
1374 | final nsize in object memory is concerned. The size | |
1375 | of the object in objectmemory is not explicitly | |
1376 | given. If the object is defined its length can be | |
1377 | determined and a fix can replace the frag. */ | |
1378 | { | |
1379 | evaluate_expr (&exprP, (char *) iif.iifP[i].object); | |
1380 | if ((exprP.X_add_symbol || exprP.X_op_symbol) && | |
1381 | !iif.iifP[i].pcrel) | |
1382 | { | |
1383 | /* Size is unknown until link time so have to | |
1384 | allow 4 bytes. */ | |
1385 | size = 4; | |
1386 | memP = frag_more(size); | |
1387 | fix_new_ns32k_exp (frag_now, | |
1388 | (long) (memP - frag_now->fr_literal), | |
1389 | size, | |
1390 | &exprP, | |
1391 | 0, /* never iif.iifP[i].pcrel, */ | |
1392 | 1, /* always iif.iifP[i].im_disp */ | |
1393 | (bit_fixS *) 0, 0, | |
1394 | inst_frag, | |
1395 | inst_offset); | |
1396 | break; /* exit this absolute hack */ | |
1397 | } | |
1398 | ||
1399 | if (exprP.X_add_symbol || exprP.X_op_symbol) | |
1400 | { /* frag it */ | |
1401 | if (exprP.X_op_symbol) | |
1402 | { /* We cant relax this case */ | |
1403 | as_fatal (_("Can't relax difference")); | |
1404 | } | |
1405 | else | |
1406 | { | |
1407 | ||
1408 | /* Size is not important. This gets fixed by relax, | |
1409 | * but we assume 0 in what follows | |
1410 | */ | |
1411 | memP = frag_more(4); /* Max size */ | |
1412 | size = 0; | |
1413 | ||
1414 | { | |
1415 | fragS *old_frag = frag_now; | |
1416 | frag_variant (rs_machine_dependent, | |
1417 | 4, /* Max size */ | |
1418 | 0, /* size */ | |
1419 | IND (BRANCH, UNDEF), /* expecting the worst */ | |
1420 | exprP.X_add_symbol, | |
1421 | exprP.X_add_number, | |
1422 | inst_opcode); | |
1423 | frag_opcode_frag(old_frag) = inst_frag; | |
1424 | frag_opcode_offset(old_frag) = inst_offset; | |
1425 | frag_bsr(old_frag) = iif.iifP[i].bsr; | |
1426 | } | |
1427 | } | |
1428 | } | |
1429 | else | |
1430 | { | |
1431 | /* This duplicates code in md_number_to_disp */ | |
1432 | if (-64 <= exprP.X_add_number && exprP.X_add_number <= 63) | |
1433 | { | |
1434 | size = 1; | |
1435 | } | |
1436 | else | |
1437 | { | |
1438 | if (-8192 <= exprP.X_add_number | |
1439 | && exprP.X_add_number <= 8191) | |
1440 | { | |
1441 | size = 2; | |
1442 | } | |
1443 | else | |
1444 | { | |
1445 | if (-0x20000000<=exprP.X_add_number && | |
1446 | exprP.X_add_number<=0x1fffffff) | |
1447 | { | |
1448 | size = 4; | |
1449 | } | |
1450 | else | |
1451 | { | |
1452 | as_warn (_("Displacement to large for :d")); | |
1453 | size = 4; | |
1454 | } | |
1455 | } | |
1456 | } | |
1457 | memP = frag_more(size); | |
1458 | md_number_to_disp (memP, exprP.X_add_number, size); | |
1459 | } | |
1460 | } | |
1461 | break; | |
1462 | default: | |
1463 | as_fatal (_("Internal logic error in iif.iifP[].type")); | |
1464 | } | |
1465 | } | |
1466 | } | |
1467 | } | |
1468 | \f | |
1469 | #ifdef BFD_ASSEMBLER | |
1470 | /* This functionality should really be in the bfd library */ | |
1471 | static bfd_reloc_code_real_type | |
1472 | reloc (int size, int pcrel, int type) | |
1473 | { | |
1474 | int length, index; | |
1475 | bfd_reloc_code_real_type relocs[] = { | |
1476 | BFD_RELOC_NS32K_IMM_8, | |
1477 | BFD_RELOC_NS32K_IMM_16, | |
1478 | BFD_RELOC_NS32K_IMM_32, | |
1479 | BFD_RELOC_NS32K_IMM_8_PCREL, | |
1480 | BFD_RELOC_NS32K_IMM_16_PCREL, | |
1481 | BFD_RELOC_NS32K_IMM_32_PCREL, | |
1482 | ||
1483 | /* ns32k displacements */ | |
1484 | BFD_RELOC_NS32K_DISP_8, | |
1485 | BFD_RELOC_NS32K_DISP_16, | |
1486 | BFD_RELOC_NS32K_DISP_32, | |
1487 | BFD_RELOC_NS32K_DISP_8_PCREL, | |
1488 | BFD_RELOC_NS32K_DISP_16_PCREL, | |
1489 | BFD_RELOC_NS32K_DISP_32_PCREL, | |
1490 | ||
1491 | /* Normal 2's complement */ | |
1492 | BFD_RELOC_8, | |
1493 | BFD_RELOC_16, | |
1494 | BFD_RELOC_32, | |
1495 | BFD_RELOC_8_PCREL, | |
1496 | BFD_RELOC_16_PCREL, | |
1497 | BFD_RELOC_32_PCREL | |
1498 | }; | |
1499 | switch (size) | |
1500 | { | |
1501 | case 1: | |
1502 | length = 0; | |
1503 | break; | |
1504 | case 2: | |
1505 | length = 1; | |
1506 | break; | |
1507 | case 4: | |
1508 | length = 2; | |
1509 | break; | |
1510 | default: | |
1511 | length = -1; | |
1512 | break; | |
1513 | } | |
1514 | index = length + 3 * pcrel + 6 * type; | |
1515 | if (index >= 0 && index < sizeof(relocs)/sizeof(relocs[0])) | |
1516 | return relocs[index]; | |
1517 | if (pcrel) | |
1518 | as_bad (_("Can not do %d byte pc-relative relocation for storage type %d"), | |
1519 | size, type); | |
1520 | else | |
1521 | as_bad (_("Can not do %d byte relocation for storage type %d"), | |
1522 | size, type); | |
1523 | return BFD_RELOC_NONE; | |
1524 | ||
1525 | } | |
1526 | ||
1527 | #endif | |
1528 | ||
1529 | void | |
1530 | md_assemble (line) | |
1531 | char *line; | |
1532 | { | |
1533 | freeptr = freeptr_static; | |
1534 | parse (line, 0); /* explode line to more fix form in iif */ | |
1535 | convert_iif (); /* convert iif to frags, fix's etc */ | |
1536 | #ifdef SHOW_NUM | |
1537 | printf (" \t\t\t%s\n", line); | |
1538 | #endif | |
1539 | } | |
1540 | ||
1541 | ||
1542 | void | |
1543 | md_begin () | |
1544 | { | |
1545 | /* build a hashtable of the instructions */ | |
1546 | const struct ns32k_opcode *ptr; | |
1547 | const char *stat; | |
1548 | inst_hash_handle = hash_new (); | |
1549 | for (ptr = ns32k_opcodes; ptr < endop; ptr++) | |
1550 | { | |
1551 | if ((stat = hash_insert (inst_hash_handle, ptr->name, (char *) ptr))) | |
1552 | { | |
1553 | as_fatal (_("Can't hash %s: %s"), ptr->name, stat); /*fatal*/ | |
1554 | } | |
1555 | } | |
1556 | freeptr_static = (char *) malloc (PRIVATE_SIZE); /* some private space | |
1557 | please! */ | |
1558 | } | |
1559 | ||
1560 | /* Must be equal to MAX_PRECISON in atof-ieee.c */ | |
1561 | #define MAX_LITTLENUMS 6 | |
1562 | ||
1563 | /* Turn the string pointed to by litP into a floating point constant | |
1564 | of type type, and emit the appropriate bytes. The number of | |
1565 | LITTLENUMS emitted is stored in *sizeP . An error message is | |
1566 | returned, or NULL on OK. */ | |
1567 | char * | |
1568 | md_atof (type, litP, sizeP) | |
1569 | char type; | |
1570 | char *litP; | |
1571 | int *sizeP; | |
1572 | { | |
1573 | int prec; | |
1574 | LITTLENUM_TYPE words[MAX_LITTLENUMS]; | |
1575 | LITTLENUM_TYPE *wordP; | |
1576 | char *t; | |
1577 | ||
1578 | switch (type) | |
1579 | { | |
1580 | case 'f': | |
1581 | prec = 2; | |
1582 | break; | |
1583 | ||
1584 | case 'd': | |
1585 | prec = 4; | |
1586 | break; | |
1587 | default: | |
1588 | *sizeP = 0; | |
1589 | return _("Bad call to MD_ATOF()"); | |
1590 | } | |
1591 | t = atof_ieee (input_line_pointer, type, words); | |
1592 | if (t) | |
1593 | input_line_pointer = t; | |
1594 | ||
1595 | *sizeP = prec * sizeof (LITTLENUM_TYPE); | |
1596 | for (wordP = words + prec; prec--;) | |
1597 | { | |
1598 | md_number_to_chars (litP, (long) (*--wordP), sizeof (LITTLENUM_TYPE)); | |
1599 | litP += sizeof (LITTLENUM_TYPE); | |
1600 | } | |
1601 | return 0; | |
1602 | } | |
1603 | \f | |
1604 | /* Convert number to chars in correct order */ | |
1605 | ||
1606 | void | |
1607 | md_number_to_chars (buf, value, nbytes) | |
1608 | char *buf; | |
1609 | valueT value; | |
1610 | int nbytes; | |
1611 | { | |
1612 | number_to_chars_littleendian (buf, value, nbytes); | |
1613 | } | |
1614 | ||
1615 | ||
1616 | /* This is a variant of md_numbers_to_chars. The reason for its' | |
1617 | existence is the fact that ns32k uses Huffman coded | |
1618 | displacements. This implies that the bit order is reversed in | |
1619 | displacements and that they are prefixed with a size-tag. | |
1620 | ||
1621 | binary: msb -> lsb | |
1622 | 0xxxxxxx byte | |
1623 | 10xxxxxx xxxxxxxx word | |
1624 | 11xxxxxx xxxxxxxx xxxxxxxx xxxxxxxx double word | |
1625 | ||
1626 | This must be taken care of and we do it here! */ | |
1627 | static void | |
1628 | md_number_to_disp (buf, val, n) | |
1629 | char *buf; | |
1630 | long val; | |
1631 | char n; | |
1632 | { | |
1633 | switch (n) | |
1634 | { | |
1635 | case 1: | |
1636 | if (val < -64 || val > 63) | |
1637 | as_warn (_("Byte displacement out of range. line number not valid")); | |
1638 | val &= 0x7f; | |
1639 | #ifdef SHOW_NUM | |
1640 | printf ("%x ", val & 0xff); | |
1641 | #endif | |
1642 | *buf++ = val; | |
1643 | break; | |
1644 | case 2: | |
1645 | if (val < -8192 || val > 8191) | |
1646 | as_warn (_("Word displacement out of range. line number not valid")); | |
1647 | val &= 0x3fff; | |
1648 | val |= 0x8000; | |
1649 | #ifdef SHOW_NUM | |
1650 | printf ("%x ", val >> 8 & 0xff); | |
1651 | #endif | |
1652 | *buf++ = (val >> 8); | |
1653 | #ifdef SHOW_NUM | |
1654 | printf ("%x ", val & 0xff); | |
1655 | #endif | |
1656 | *buf++ = val; | |
1657 | break; | |
1658 | case 4: | |
1659 | if (val < -0x20000000 || val >= 0x20000000) | |
1660 | as_warn (_("Double word displacement out of range")); | |
1661 | val |= 0xc0000000; | |
1662 | #ifdef SHOW_NUM | |
1663 | printf ("%x ", val >> 24 & 0xff); | |
1664 | #endif | |
1665 | *buf++ = (val >> 24); | |
1666 | #ifdef SHOW_NUM | |
1667 | printf ("%x ", val >> 16 & 0xff); | |
1668 | #endif | |
1669 | *buf++ = (val >> 16); | |
1670 | #ifdef SHOW_NUM | |
1671 | printf ("%x ", val >> 8 & 0xff); | |
1672 | #endif | |
1673 | *buf++ = (val >> 8); | |
1674 | #ifdef SHOW_NUM | |
1675 | printf ("%x ", val & 0xff); | |
1676 | #endif | |
1677 | *buf++ = val; | |
1678 | break; | |
1679 | default: | |
1680 | as_fatal (_("Internal logic error. line %s, file \"%s\""), | |
1681 | __LINE__, __FILE__); | |
1682 | } | |
1683 | } | |
1684 | ||
1685 | static void | |
1686 | md_number_to_imm (buf, val, n) | |
1687 | char *buf; | |
1688 | long val; | |
1689 | char n; | |
1690 | { | |
1691 | switch (n) | |
1692 | { | |
1693 | case 1: | |
1694 | #ifdef SHOW_NUM | |
1695 | printf ("%x ", val & 0xff); | |
1696 | #endif | |
1697 | *buf++ = val; | |
1698 | break; | |
1699 | case 2: | |
1700 | #ifdef SHOW_NUM | |
1701 | printf ("%x ", val >> 8 & 0xff); | |
1702 | #endif | |
1703 | *buf++ = (val >> 8); | |
1704 | #ifdef SHOW_NUM | |
1705 | printf ("%x ", val & 0xff); | |
1706 | #endif | |
1707 | *buf++ = val; | |
1708 | break; | |
1709 | case 4: | |
1710 | #ifdef SHOW_NUM | |
1711 | printf ("%x ", val >> 24 & 0xff); | |
1712 | #endif | |
1713 | *buf++ = (val >> 24); | |
1714 | #ifdef SHOW_NUM | |
1715 | printf ("%x ", val >> 16 & 0xff); | |
1716 | #endif | |
1717 | *buf++ = (val >> 16); | |
1718 | #ifdef SHOW_NUM | |
1719 | printf ("%x ", val >> 8 & 0xff); | |
1720 | #endif | |
1721 | *buf++ = (val >> 8); | |
1722 | #ifdef SHOW_NUM | |
1723 | printf ("%x ", val & 0xff); | |
1724 | #endif | |
1725 | *buf++ = val; | |
1726 | break; | |
1727 | default: | |
1728 | as_fatal (_("Internal logic error. line %s, file \"%s\""), | |
1729 | __LINE__, __FILE__); | |
1730 | } | |
1731 | } | |
1732 | ||
1733 | ||
1734 | /* fast bitfiddling support */ | |
1735 | /* mask used to zero bitfield before oring in the true field */ | |
1736 | ||
1737 | static unsigned long l_mask[] = | |
1738 | { | |
1739 | 0xffffffff, 0xfffffffe, 0xfffffffc, 0xfffffff8, | |
1740 | 0xfffffff0, 0xffffffe0, 0xffffffc0, 0xffffff80, | |
1741 | 0xffffff00, 0xfffffe00, 0xfffffc00, 0xfffff800, | |
1742 | 0xfffff000, 0xffffe000, 0xffffc000, 0xffff8000, | |
1743 | 0xffff0000, 0xfffe0000, 0xfffc0000, 0xfff80000, | |
1744 | 0xfff00000, 0xffe00000, 0xffc00000, 0xff800000, | |
1745 | 0xff000000, 0xfe000000, 0xfc000000, 0xf8000000, | |
1746 | 0xf0000000, 0xe0000000, 0xc0000000, 0x80000000, | |
1747 | }; | |
1748 | static unsigned long r_mask[] = | |
1749 | { | |
1750 | 0x00000000, 0x00000001, 0x00000003, 0x00000007, | |
1751 | 0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f, | |
1752 | 0x000000ff, 0x000001ff, 0x000003ff, 0x000007ff, | |
1753 | 0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff, | |
1754 | 0x0000ffff, 0x0001ffff, 0x0003ffff, 0x0007ffff, | |
1755 | 0x000fffff, 0x001fffff, 0x003fffff, 0x007fffff, | |
1756 | 0x00ffffff, 0x01ffffff, 0x03ffffff, 0x07ffffff, | |
1757 | 0x0fffffff, 0x1fffffff, 0x3fffffff, 0x7fffffff, | |
1758 | }; | |
1759 | #define MASK_BITS 31 | |
1760 | /* Insert bitfield described by field_ptr and val at buf | |
1761 | This routine is written for modification of the first 4 bytes pointed | |
1762 | to by buf, to yield speed. | |
1763 | The ifdef stuff is for selection between a ns32k-dependent routine | |
1764 | and a general version. (My advice: use the general version!) | |
1765 | */ | |
1766 | ||
1767 | static void | |
1768 | md_number_to_field (buf, val, field_ptr) | |
1769 | register char *buf; | |
1770 | register long val; | |
1771 | register bit_fixS *field_ptr; | |
1772 | { | |
1773 | register unsigned long object; | |
1774 | register unsigned long mask; | |
1775 | /* define ENDIAN on a ns32k machine */ | |
1776 | #ifdef ENDIAN | |
1777 | register unsigned long *mem_ptr; | |
1778 | #else | |
1779 | register char *mem_ptr; | |
1780 | #endif | |
1781 | if (field_ptr->fx_bit_min <= val && val <= field_ptr->fx_bit_max) | |
1782 | { | |
1783 | #ifdef ENDIAN | |
1784 | if (field_ptr->fx_bit_base) | |
1785 | { /* override buf */ | |
1786 | mem_ptr = (unsigned long *) field_ptr->fx_bit_base; | |
1787 | } | |
1788 | else | |
1789 | { | |
1790 | mem_ptr = (unsigned long *) buf; | |
1791 | } | |
1792 | mem_ptr = ((unsigned long *) | |
1793 | ((char *) mem_ptr + field_ptr->fx_bit_base_adj)); | |
1794 | #else | |
1795 | if (field_ptr->fx_bit_base) | |
1796 | { /* override buf */ | |
1797 | mem_ptr = (char *) field_ptr->fx_bit_base; | |
1798 | } | |
1799 | else | |
1800 | { | |
1801 | mem_ptr = buf; | |
1802 | } | |
1803 | mem_ptr += field_ptr->fx_bit_base_adj; | |
1804 | #endif | |
1805 | #ifdef ENDIAN /* we have a nice ns32k machine with lowbyte | |
1806 | at low-physical mem */ | |
1807 | object = *mem_ptr; /* get some bytes */ | |
1808 | #else /* OVE Goof! the machine is a m68k or dito */ | |
1809 | /* That takes more byte fiddling */ | |
1810 | object = 0; | |
1811 | object |= mem_ptr[3] & 0xff; | |
1812 | object <<= 8; | |
1813 | object |= mem_ptr[2] & 0xff; | |
1814 | object <<= 8; | |
1815 | object |= mem_ptr[1] & 0xff; | |
1816 | object <<= 8; | |
1817 | object |= mem_ptr[0] & 0xff; | |
1818 | #endif | |
1819 | mask = 0; | |
1820 | mask |= (r_mask[field_ptr->fx_bit_offset]); | |
1821 | mask |= (l_mask[field_ptr->fx_bit_offset + field_ptr->fx_bit_size]); | |
1822 | object &= mask; | |
1823 | val += field_ptr->fx_bit_add; | |
1824 | object |= ((val << field_ptr->fx_bit_offset) & (mask ^ 0xffffffff)); | |
1825 | #ifdef ENDIAN | |
1826 | *mem_ptr = object; | |
1827 | #else | |
1828 | mem_ptr[0] = (char) object; | |
1829 | object >>= 8; | |
1830 | mem_ptr[1] = (char) object; | |
1831 | object >>= 8; | |
1832 | mem_ptr[2] = (char) object; | |
1833 | object >>= 8; | |
1834 | mem_ptr[3] = (char) object; | |
1835 | #endif | |
1836 | } | |
1837 | else | |
1838 | { | |
1839 | as_warn (_("Bit field out of range")); | |
1840 | } | |
1841 | } | |
1842 | ||
1843 | int md_pcrel_adjust (fragS *fragP) | |
1844 | { | |
1845 | fragS *opcode_frag; | |
1846 | addressT opcode_address; | |
1847 | unsigned int offset; | |
1848 | opcode_frag = frag_opcode_frag(fragP); | |
1849 | if (opcode_frag == 0) | |
1850 | return 0; | |
1851 | offset = frag_opcode_offset(fragP); | |
1852 | opcode_address = offset + opcode_frag->fr_address; | |
1853 | return fragP->fr_address + fragP->fr_fix - opcode_address; | |
1854 | } | |
1855 | ||
1856 | int md_fix_pcrel_adjust (fixS *fixP) | |
1857 | { | |
1858 | fragS *fragP = fixP->fx_frag; | |
1859 | fragS *opcode_frag; | |
1860 | addressT opcode_address; | |
1861 | unsigned int offset; | |
1862 | opcode_frag = fix_opcode_frag(fixP); | |
1863 | if (opcode_frag == 0) | |
1864 | return 0; | |
1865 | offset = fix_opcode_offset(fixP); | |
1866 | opcode_address = offset + opcode_frag->fr_address; | |
1867 | return fixP->fx_where + fixP->fx_frag->fr_address - opcode_address; | |
1868 | } | |
1869 | ||
1870 | /* Apply a fixS (fixup of an instruction or data that we didn't have | |
1871 | enough info to complete immediately) to the data in a frag. | |
1872 | ||
1873 | On the ns32k, everything is in a different format, so we have broken | |
1874 | out separate functions for each kind of thing we could be fixing. | |
1875 | They all get called from here. */ | |
1876 | ||
1877 | #ifdef BFD_ASSEMBLER | |
1878 | int | |
1879 | md_apply_fix (fixP, valp) | |
1880 | fixS *fixP; | |
1881 | valueT *valp; | |
1882 | #else | |
1883 | void | |
1884 | md_apply_fix (fixP, val) | |
1885 | fixS *fixP; | |
1886 | long val; | |
1887 | #endif | |
1888 | { | |
1889 | #ifdef BFD_ASSEMBLER | |
1890 | long val = *valp; | |
1891 | #endif | |
1892 | fragS *fragP = fixP->fx_frag; | |
1893 | ||
1894 | char *buf = fixP->fx_where + fixP->fx_frag->fr_literal; | |
1895 | ||
1896 | if (fix_bit_fixP(fixP)) | |
1897 | { /* Bitfields to fix, sigh */ | |
1898 | md_number_to_field (buf, val, fix_bit_fixP(fixP)); | |
1899 | } | |
1900 | else | |
1901 | switch (fix_im_disp(fixP)) | |
1902 | { | |
1903 | ||
1904 | case 0: /* Immediate field */ | |
1905 | md_number_to_imm (buf, val, fixP->fx_size); | |
1906 | break; | |
1907 | ||
1908 | case 1: /* Displacement field */ | |
1909 | /* Calculate offset */ | |
1910 | { | |
1911 | md_number_to_disp (buf, | |
1912 | (fixP->fx_pcrel ? val + md_fix_pcrel_adjust(fixP) | |
1913 | : val), fixP->fx_size); | |
1914 | } | |
1915 | break; | |
1916 | ||
1917 | case 2: /* Pointer in a data object */ | |
1918 | md_number_to_chars (buf, val, fixP->fx_size); | |
1919 | break; | |
1920 | } | |
1921 | #ifdef BSD_ASSEMBLER | |
1922 | return 1; | |
1923 | #endif | |
1924 | } | |
1925 | \f | |
1926 | /* Convert a relaxed displacement to ditto in final output */ | |
1927 | ||
1928 | #ifndef BFD_ASSEMBLER | |
1929 | void | |
1930 | md_convert_frag (headers, sec, fragP) | |
1931 | object_headers *headers; | |
1932 | segT sec; | |
1933 | register fragS *fragP; | |
1934 | #else | |
1935 | void | |
1936 | md_convert_frag (abfd, sec, fragP) | |
1937 | bfd *abfd; | |
1938 | segT sec; | |
1939 | register fragS *fragP; | |
1940 | #endif | |
1941 | { | |
1942 | long disp; | |
1943 | long ext = 0; | |
1944 | ||
1945 | /* Address in gas core of the place to store the displacement. */ | |
1946 | register char *buffer_address = fragP->fr_fix + fragP->fr_literal; | |
1947 | /* Address in object code of the displacement. */ | |
1948 | int object_address; | |
1949 | ||
1950 | fragS *opcode_frag; | |
1951 | ||
1952 | switch (fragP->fr_subtype) | |
1953 | { | |
1954 | case IND (BRANCH, BYTE): | |
1955 | ext = 1; | |
1956 | break; | |
1957 | case IND (BRANCH, WORD): | |
1958 | ext = 2; | |
1959 | break; | |
1960 | case IND (BRANCH, DOUBLE): | |
1961 | ext = 4; | |
1962 | break; | |
1963 | } | |
1964 | ||
1965 | if(ext == 0) | |
1966 | return; | |
1967 | ||
1968 | know (fragP->fr_symbol); | |
1969 | ||
1970 | object_address = fragP->fr_fix + fragP->fr_address; | |
1971 | /* The displacement of the address, from current location. */ | |
1972 | disp = (S_GET_VALUE (fragP->fr_symbol) + fragP->fr_offset) - object_address; | |
1973 | #ifdef BFD_ASSEMBLER | |
7dcc9865 | 1974 | disp += symbol_get_frag (fragP->fr_symbol)->fr_address; |
252b5132 RH |
1975 | #endif |
1976 | disp += md_pcrel_adjust(fragP); | |
1977 | ||
1978 | md_number_to_disp (buffer_address, (long) disp, (int) ext); | |
1979 | fragP->fr_fix += ext; | |
1980 | } | |
1981 | ||
1982 | /* This function returns the estimated size a variable object will occupy, | |
1983 | one can say that we tries to guess the size of the objects before we | |
1984 | actually know it */ | |
1985 | ||
1986 | int | |
1987 | md_estimate_size_before_relax (fragP, segment) | |
1988 | register fragS *fragP; | |
1989 | segT segment; | |
1990 | { | |
1991 | int old_fix; | |
1992 | old_fix = fragP->fr_fix; | |
1993 | switch (fragP->fr_subtype) | |
1994 | { | |
1995 | case IND (BRANCH, UNDEF): | |
1996 | if (S_GET_SEGMENT (fragP->fr_symbol) == segment) | |
1997 | { | |
1998 | /* the symbol has been assigned a value */ | |
1999 | fragP->fr_subtype = IND (BRANCH, BYTE); | |
2000 | } | |
2001 | else | |
2002 | { | |
2003 | /* we don't relax symbols defined in an other segment the | |
2004 | thing to do is to assume the object will occupy 4 bytes */ | |
2005 | fix_new_ns32k (fragP, | |
2006 | (int) (fragP->fr_fix), | |
2007 | 4, | |
2008 | fragP->fr_symbol, | |
2009 | fragP->fr_offset, | |
2010 | 1, | |
2011 | 1, | |
2012 | 0, | |
2013 | frag_bsr(fragP), /*sequent hack */ | |
2014 | frag_opcode_frag(fragP), | |
2015 | frag_opcode_offset(fragP)); | |
2016 | fragP->fr_fix += 4; | |
2017 | /* fragP->fr_opcode[1]=0xff; */ | |
2018 | frag_wane (fragP); | |
2019 | break; | |
2020 | } | |
2021 | case IND (BRANCH, BYTE): | |
2022 | fragP->fr_var += 1; | |
2023 | break; | |
2024 | default: | |
2025 | break; | |
2026 | } | |
2027 | return fragP->fr_var + fragP->fr_fix - old_fix; | |
2028 | } | |
2029 | ||
2030 | int md_short_jump_size = 3; | |
2031 | int md_long_jump_size = 5; | |
2032 | const int md_reloc_size = 8; /* Size of relocation record */ | |
2033 | ||
2034 | void | |
2035 | md_create_short_jump (ptr, from_addr, to_addr, frag, to_symbol) | |
2036 | char *ptr; | |
2037 | addressT from_addr, to_addr; | |
2038 | fragS *frag; | |
2039 | symbolS *to_symbol; | |
2040 | { | |
2041 | valueT offset; | |
2042 | ||
2043 | offset = to_addr - from_addr; | |
2044 | md_number_to_chars (ptr, (valueT) 0xEA, 1); | |
2045 | md_number_to_disp (ptr + 1, (valueT) offset, 2); | |
2046 | } | |
2047 | ||
2048 | void | |
2049 | md_create_long_jump (ptr, from_addr, to_addr, frag, to_symbol) | |
2050 | char *ptr; | |
2051 | addressT from_addr, to_addr; | |
2052 | fragS *frag; | |
2053 | symbolS *to_symbol; | |
2054 | { | |
2055 | valueT offset; | |
2056 | ||
2057 | offset = to_addr - from_addr; | |
2058 | md_number_to_chars (ptr, (valueT) 0xEA, 1); | |
2059 | md_number_to_disp (ptr + 1, (valueT) offset, 4); | |
2060 | } | |
2061 | \f | |
2062 | CONST char *md_shortopts = "m:"; | |
2063 | struct option md_longopts[] = { | |
2064 | {NULL, no_argument, NULL, 0} | |
2065 | }; | |
2066 | size_t md_longopts_size = sizeof(md_longopts); | |
2067 | ||
2068 | int | |
2069 | md_parse_option (c, arg) | |
2070 | int c; | |
2071 | char *arg; | |
2072 | { | |
2073 | switch (c) | |
2074 | { | |
2075 | case 'm': | |
2076 | if (!strcmp (arg, "32032")) | |
2077 | { | |
2078 | cpureg = cpureg_032; | |
2079 | mmureg = mmureg_032; | |
2080 | } | |
2081 | else if (!strcmp (arg, "32532")) | |
2082 | { | |
2083 | cpureg = cpureg_532; | |
2084 | mmureg = mmureg_532; | |
2085 | } | |
2086 | else | |
2087 | { | |
2088 | as_bad (_("invalid architecture option -m%s"), arg); | |
2089 | return 0; | |
2090 | } | |
2091 | break; | |
2092 | ||
2093 | default: | |
2094 | return 0; | |
2095 | } | |
2096 | ||
2097 | return 1; | |
2098 | } | |
2099 | ||
2100 | void | |
2101 | md_show_usage (stream) | |
2102 | FILE *stream; | |
2103 | { | |
2104 | fprintf(stream, _("\ | |
2105 | NS32K options:\n\ | |
2106 | -m32032 | -m32532 select variant of NS32K architecture\n")); | |
2107 | } | |
2108 | ||
2109 | \f | |
2110 | /* | |
2111 | * bit_fix_new() | |
2112 | * | |
2113 | * Create a bit_fixS in obstack 'notes'. | |
2114 | * This struct is used to profile the normal fix. If the bit_fixP is a | |
2115 | * valid pointer (not NULL) the bit_fix data will be used to format the fix. | |
2116 | */ | |
2117 | bit_fixS * | |
2118 | bit_fix_new (size, offset, min, max, add, base_type, base_adj) | |
2119 | char size; /* Length of bitfield */ | |
2120 | char offset; /* Bit offset to bitfield */ | |
2121 | long min; /* Signextended min for bitfield */ | |
2122 | long max; /* Signextended max for bitfield */ | |
2123 | long add; /* Add mask, used for huffman prefix */ | |
2124 | long base_type; /* 0 or 1, if 1 it's exploded to opcode ptr */ | |
2125 | long base_adj; | |
2126 | { | |
2127 | register bit_fixS *bit_fixP; | |
2128 | ||
2129 | bit_fixP = (bit_fixS *) obstack_alloc (¬es, sizeof (bit_fixS)); | |
2130 | ||
2131 | bit_fixP->fx_bit_size = size; | |
2132 | bit_fixP->fx_bit_offset = offset; | |
2133 | bit_fixP->fx_bit_base = base_type; | |
2134 | bit_fixP->fx_bit_base_adj = base_adj; | |
2135 | bit_fixP->fx_bit_max = max; | |
2136 | bit_fixP->fx_bit_min = min; | |
2137 | bit_fixP->fx_bit_add = add; | |
2138 | ||
2139 | return (bit_fixP); | |
2140 | } | |
2141 | ||
2142 | void | |
2143 | fix_new_ns32k (frag, where, size, add_symbol, offset, pcrel, | |
2144 | im_disp, bit_fixP, bsr, opcode_frag, opcode_offset) | |
2145 | fragS *frag; /* Which frag? */ | |
2146 | int where; /* Where in that frag? */ | |
2147 | int size; /* 1, 2 or 4 usually. */ | |
2148 | symbolS *add_symbol; /* X_add_symbol. */ | |
2149 | long offset; /* X_add_number. */ | |
2150 | int pcrel; /* TRUE if PC-relative relocation. */ | |
2151 | char im_disp; /* true if the value to write is a | |
2152 | displacement */ | |
2153 | bit_fixS *bit_fixP; /* pointer at struct of bit_fix's, ignored if | |
2154 | NULL */ | |
2155 | char bsr; /* sequent-linker-hack: 1 when relocobject is | |
2156 | a bsr */ | |
2157 | fragS *opcode_frag; | |
2158 | unsigned int opcode_offset; | |
2159 | ||
2160 | { | |
2161 | fixS *fixP = fix_new (frag, where, size, add_symbol, | |
2162 | offset, pcrel, | |
2163 | #ifdef BFD_ASSEMBLER | |
2164 | bit_fixP? NO_RELOC: reloc(size, pcrel, im_disp) | |
2165 | #else | |
2166 | NO_RELOC | |
2167 | #endif | |
2168 | ); | |
2169 | ||
2170 | fix_opcode_frag(fixP) = opcode_frag; | |
2171 | fix_opcode_offset(fixP) = opcode_offset; | |
2172 | fix_im_disp(fixP) = im_disp; | |
2173 | fix_bsr(fixP) = bsr; | |
2174 | fix_bit_fixP(fixP) = bit_fixP; | |
2175 | } /* fix_new_ns32k() */ | |
2176 | ||
2177 | void | |
2178 | fix_new_ns32k_exp (frag, where, size, exp, pcrel, | |
2179 | im_disp, bit_fixP, bsr, opcode_frag, opcode_offset) | |
2180 | fragS *frag; /* Which frag? */ | |
2181 | int where; /* Where in that frag? */ | |
2182 | int size; /* 1, 2 or 4 usually. */ | |
2183 | expressionS *exp; /* Expression. */ | |
2184 | int pcrel; /* TRUE if PC-relative relocation. */ | |
2185 | char im_disp; /* true if the value to write is a | |
2186 | displacement */ | |
2187 | bit_fixS *bit_fixP; /* pointer at struct of bit_fix's, ignored if | |
2188 | NULL */ | |
2189 | char bsr; /* sequent-linker-hack: 1 when relocobject is | |
2190 | a bsr */ | |
2191 | fragS *opcode_frag; | |
2192 | unsigned int opcode_offset; | |
2193 | { | |
2194 | fixS *fixP = fix_new_exp (frag, where, size, exp, pcrel, | |
2195 | #ifdef BFD_ASSEMBLER | |
2196 | bit_fixP? NO_RELOC: reloc(size, pcrel, im_disp) | |
2197 | #else | |
2198 | NO_RELOC | |
2199 | #endif | |
2200 | ); | |
2201 | ||
2202 | fix_opcode_frag(fixP) = opcode_frag; | |
2203 | fix_opcode_offset(fixP) = opcode_offset; | |
2204 | fix_im_disp(fixP) = im_disp; | |
2205 | fix_bsr(fixP) = bsr; | |
2206 | fix_bit_fixP(fixP) = bit_fixP; | |
2207 | } /* fix_new_ns32k() */ | |
2208 | ||
2209 | /* This is TC_CONS_FIX_NEW, called by emit_expr in read.c. */ | |
2210 | ||
2211 | void | |
2212 | cons_fix_new_ns32k (frag, where, size, exp) | |
2213 | fragS *frag; /* Which frag? */ | |
2214 | int where; /* Where in that frag? */ | |
2215 | int size; /* 1, 2 or 4 usually. */ | |
2216 | expressionS *exp; /* Expression. */ | |
2217 | { | |
2218 | fix_new_ns32k_exp (frag, where, size, exp, | |
2219 | 0, 2, 0, 0, 0, 0); | |
2220 | } | |
2221 | ||
2222 | /* We have no need to default values of symbols. */ | |
2223 | ||
2224 | symbolS * | |
2225 | md_undefined_symbol (name) | |
2226 | char *name; | |
2227 | { | |
2228 | return 0; | |
2229 | } | |
2230 | ||
2231 | /* Round up a section size to the appropriate boundary. */ | |
2232 | valueT | |
2233 | md_section_align (segment, size) | |
2234 | segT segment; | |
2235 | valueT size; | |
2236 | { | |
2237 | return size; /* Byte alignment is fine */ | |
2238 | } | |
2239 | ||
2240 | /* Exactly what point is a PC-relative offset relative TO? On the | |
2241 | ns32k, they're relative to the start of the instruction. */ | |
2242 | long | |
2243 | md_pcrel_from (fixP) | |
2244 | fixS *fixP; | |
2245 | { | |
2246 | long res; | |
2247 | res = fixP->fx_where + fixP->fx_frag->fr_address; | |
2248 | #ifdef SEQUENT_COMPATABILITY | |
2249 | if (frag_bsr(fixP->fx_frag)) | |
2250 | res += 0x12 /* FOO Kludge alert! */ | |
2251 | #endif | |
2252 | return res; | |
2253 | } | |
2254 | ||
2255 | #ifdef BFD_ASSEMBLER | |
2256 | ||
2257 | arelent * | |
2258 | tc_gen_reloc (section, fixp) | |
2259 | asection *section; | |
2260 | fixS *fixp; | |
2261 | { | |
2262 | arelent *rel; | |
2263 | bfd_reloc_code_real_type code; | |
2264 | ||
2265 | code = reloc(fixp->fx_size, fixp->fx_pcrel, fix_im_disp(fixp)); | |
2266 | ||
2267 | rel = (arelent *) xmalloc (sizeof (arelent)); | |
310b5aa2 ILT |
2268 | rel->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); |
2269 | *rel->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy); | |
252b5132 RH |
2270 | rel->address = fixp->fx_frag->fr_address + fixp->fx_where; |
2271 | if (fixp->fx_pcrel) | |
2272 | rel->addend = fixp->fx_addnumber; | |
2273 | else | |
2274 | rel->addend = 0; | |
2275 | ||
2276 | rel->howto = bfd_reloc_type_lookup (stdoutput, code); | |
2277 | if (!rel->howto) | |
2278 | { | |
2279 | const char *name; | |
2280 | ||
2281 | name = S_GET_NAME (fixp->fx_addsy); | |
2282 | if (name == NULL) | |
2283 | name = _("<unknown>"); | |
2284 | as_fatal (_("Cannot find relocation type for symbol %s, code %d"), | |
2285 | name, (int) code); | |
2286 | } | |
2287 | ||
2288 | return rel; | |
2289 | } | |
2290 | #else /* BFD_ASSEMBLER */ | |
2291 | ||
2292 | #ifdef OBJ_AOUT | |
2293 | void | |
2294 | cons_fix_new_ns32k (where, fixP, segment_address_in_file) | |
2295 | char *where; | |
2296 | struct fix *fixP; | |
2297 | relax_addressT segment_address_in_file; | |
2298 | { | |
2299 | /* | |
2300 | * In: length of relocation (or of address) in chars: 1, 2 or 4. | |
2301 | * Out: GNU LD relocation length code: 0, 1, or 2. | |
2302 | */ | |
2303 | ||
2304 | static unsigned char nbytes_r_length[] = {42, 0, 1, 42, 2}; | |
2305 | long r_symbolnum; | |
2306 | ||
2307 | know (fixP->fx_addsy != NULL); | |
2308 | ||
2309 | md_number_to_chars (where, | |
2310 | fixP->fx_frag->fr_address + fixP->fx_where - segment_address_in_file, | |
2311 | 4); | |
2312 | ||
2313 | r_symbolnum = (S_IS_DEFINED (fixP->fx_addsy) | |
2314 | ? S_GET_TYPE (fixP->fx_addsy) | |
2315 | : fixP->fx_addsy->sy_number); | |
2316 | ||
2317 | md_number_to_chars (where + 4, | |
2318 | ((long) (r_symbolnum) | |
2319 | | (long) (fixP->fx_pcrel << 24) | |
2320 | | (long) (nbytes_r_length[fixP->fx_size] << 25) | |
2321 | | (long) ((!S_IS_DEFINED (fixP->fx_addsy)) << 27) | |
2322 | | (long) (fix_bsr(fixP) << 28) | |
2323 | | (long) (fix_im_disp(fixP) << 29)), | |
2324 | 4); | |
2325 | } | |
2326 | ||
2327 | #endif /* OBJ_AOUT */ | |
2328 | #endif /* BFD_ASSMEBLER */ | |
2329 | ||
2330 | /* end of tc-ns32k.c */ |