Initial import from FreeBSD RELENG_4:
[dragonfly.git] / gnu / usr.bin / as / config / tc-m68k.c
1 /* tc-m68k.c  All the m68020 specific stuff in one convenient, huge,
2    slow to compile, easy to find file.
3
4    Copyright (C) 1987, 1991, 1992 Free Software Foundation, Inc.
5
6    This file is part of GAS, the GNU Assembler.
7
8    GAS is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 2, or (at your option)
11    any later version.
12
13    GAS is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with GAS; see the file COPYING.  If not, write to
20    the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
21
22 #include <ctype.h>
23
24 #include "as.h"
25
26 #include "obstack.h"
27
28 /* note that this file includes real declarations and thus can only be included by one source file per executable. */
29 #include "opcode/m68k.h"
30 #ifdef TE_SUN
31 /* This variable contains the value to write out at the beginning of
32    the a.out file.  The 2<<16 means that this is a 68020 file instead
33    of an old-style 68000 file */
34
35 long omagic = 2<<16|OMAGIC;     /* Magic byte for header file */
36 #else
37 long omagic = OMAGIC;
38 #endif
39
40 /* This array holds the chars that always start a comment.  If the
41    pre-processor is disabled, these aren't very useful */
42 const char comment_chars[] = "|";
43
44 /* This array holds the chars that only start a comment at the beginning of
45    a line.  If the line seems to have the form '# 123 filename'
46    .line and .file directives will appear in the pre-processed output */
47 /* Note that input_file.c hand checks for '#' at the beginning of the
48    first line of the input file.  This is because the compiler outputs
49    #NO_APP at the beginning of its output. */
50 /* Also note that comments like this one will always work. */
51 const char line_comment_chars[] = "#";
52
53 /* Chars that can be used to separate mant from exp in floating point nums */
54 const char EXP_CHARS[] = "eE";
55
56 /* Chars that mean this number is a floating point constant */
57 /* As in 0f12.456 */
58 /* or    0d1.2345e12 */
59
60 const char FLT_CHARS[] = "rRsSfFdDxXeEpP";
61
62 /* Also be aware that MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT may have to be
63    changed in read.c. Ideally it shouldn't have to know about it at all,
64    but nothing is ideal around here.
65    */
66
67 const int md_reloc_size = 8;            /* Size of relocation record */
68
69 /* Its an arbitrary name:  This means I don't approve of it */
70 /* See flames below */
71 static struct obstack robyn;
72
73 #define TAB(x,y)        (((x)<<2)+(y))
74 #define TABTYPE(xy)     ((xy) >> 2)
75 #define BYTE            0
76 #define SHORT           1
77 #define LONG            2
78 #define SZ_UNDEF        3
79
80 #define BRANCH          1
81 #define FBRANCH         2
82 #define PCREL           3
83 #define BCC68000        4
84 #define DBCC            5
85 #define PCLEA           6
86
87 /* Operands we can parse:  (And associated modes)
88
89    numb:        8 bit num
90    numw:        16 bit num
91    numl:        32 bit num
92    dreg:        data reg 0-7
93    reg: address or data register
94    areg:        address register
95    apc: address register, PC, ZPC or empty string
96    num: 16 or 32 bit num
97    num2:        like num
98    sz:  w or l          if omitted, l assumed
99    scale:       1 2 4 or 8      if omitted, 1 assumed
100
101    7.4 IMMED #num                               --> NUM
102    0.? DREG  dreg                               --> dreg
103    1.? AREG  areg                               --> areg
104    2.? AINDR areg@                              --> *(areg)
105    3.? AINC  areg@+                     --> *(areg++)
106    4.? ADEC  areg@-                     --> *(--areg)
107    5.? AOFF  apc@(numw)                 --> *(apc+numw) -- empty string and ZPC not allowed here
108    6.? AINDX apc@(num,reg:sz:scale)     --> *(apc+num+reg*scale)
109    6.? AINDX apc@(reg:sz:scale)         --> same, with num=0
110    6.? APODX apc@(num)@(num2,reg:sz:scale)      --> *(*(apc+num)+num2+reg*scale)
111    6.? APODX apc@(num)@(reg:sz:scale)   --> same, with num2=0
112    6.? AMIND apc@(num)@(num2)           --> *(*(apc+num)+num2) (previous mode without an index reg)
113    6.? APRDX apc@(num,reg:sz:scale)@(num2)      --> *(*(apc+num+reg*scale)+num2)
114    6.? APRDX apc@(reg:sz:scale)@(num2)  --> same, with num=0
115    7.0 ABSL  num:sz                     --> *(num)
116    num                          --> *(num) (sz L assumed)
117    *** MSCR  otherreg                   --> Magic
118    With -l option
119    5.? AOFF  apc@(num)                  --> *(apc+num) -- empty string and ZPC not allowed here still
120
121    examples:
122    #foo #0x35   #12
123    d2
124    a4
125    a3@
126    a5@+
127    a6@-
128    a2@(12)      pc@(14)
129    a1@(5,d2:w:1)        @(45,d6:l:4)
130    pc@(a2)              @(d4)
131    etc...
132
133
134    #name@(numw) -->turn into PC rel mode
135    apc@(num8,reg:sz:scale)              --> *(apc+num8+reg*scale)
136
137    */
138
139 enum operand_type {
140         IMMED = 1,
141         DREG,
142         AREG,
143         AINDR,
144         ADEC,
145         AINC,
146         AOFF,
147         AINDX,
148         APODX,
149         AMIND,
150         APRDX,
151         ABSL,
152         MSCR,
153         REGLST,
154 };
155
156
157 struct m68k_exp {
158         char    *e_beg;
159         char    *e_end;
160         expressionS e_exp;
161         short   e_siz;          /* 0 == default 1 == short/byte 2 == word 3 == long */
162 };
163
164 /* DATA and ADDR have to be contiguous, so that reg-DATA gives 0-7 == data reg,
165    8-15 == addr reg for operands that take both types */
166
167 enum _register {
168         DATA = 1,               /*   1- 8 == data registers 0-7 */
169         DATA0 = DATA,
170         DATA1,
171         DATA2,
172         DATA3,
173         DATA4,
174         DATA5,
175         DATA6,
176         DATA7,
177
178         ADDR,
179         ADDR0 = ADDR,
180         ADDR1,
181         ADDR2,
182         ADDR3,
183         ADDR4,
184         ADDR5,
185         ADDR6,
186         ADDR7,
187
188         /* Note that COPNUM == processor #1 -- COPNUM+7 == #8, which stores as 000 */
189         /* I think...  */
190
191         SP = ADDR7,
192
193         FPREG, /* Eight FP registers */
194         FP0 = FPREG,
195         FP1,
196         FP2,
197         FP3,
198         FP4,
199         FP5,
200         FP6,
201         FP7,
202         COPNUM = (FPREG+8),     /* Co-processor #1-#8 */
203         COP0 = COPNUM,
204         COP1,
205         COP2,
206         COP3,
207         COP4,
208         COP5,
209         COP6,
210         COP7,
211         PC,     /* Program counter */
212         ZPC, /* Hack for Program space, but 0 addressing */
213         SR,     /* Status Reg */
214         CCR, /* Condition code Reg */
215
216         /* These have to be in order for the movec instruction to work. */
217         USP,    /*  User Stack Pointer */
218         ISP,    /*  Interrupt stack pointer */
219         SFC,
220         DFC,
221         CACR,
222         VBR,
223         CAAR,
224         MSP,
225         ITT0,
226         ITT1,
227         DTT0,
228         DTT1,
229         MMUSR,
230         TC,
231         SRP,
232         URP,
233         /* end of movec ordering constraints */
234
235         FPI,
236         FPS,
237         FPC,
238
239         DRP,
240         CRP,
241         CAL,
242         VAL,
243         SCC,
244         AC,
245         BAD,
246         BAD0 = BAD,
247         BAD1,
248         BAD2,
249         BAD3,
250         BAD4,
251         BAD5,
252         BAD6,
253         BAD7,
254         BAC,
255         BAC0 = BAC,
256         BAC1,
257         BAC2,
258         BAC3,
259         BAC4,
260         BAC5,
261         BAC6,
262         BAC7,
263         PSR,
264         PCSR,
265
266         IC,     /* instruction cache token */
267         DC,     /* data cache token */
268         NC,     /* no cache token */
269         BC,     /* both caches token */
270
271 };
272
273 /* Internal form of an operand.  */
274 struct m68k_op {
275         char    *error;         /* Couldn't parse it */
276         enum operand_type mode; /* What mode this instruction is in.  */
277         enum _register reg;             /* Base register */
278         struct m68k_exp *con1;
279         int     ireg;           /* Index register */
280         int     isiz;           /* 0 == unspec  1 == byte(?)  2 == short  3 == long  */
281         int     imul;           /* Multipy ireg by this (1,2,4,or 8) */
282         struct  m68k_exp *con2;
283 };
284
285 /* internal form of a 68020 instruction */
286 struct m68k_it {
287         char    *error;
288         char    *args;          /* list of opcode info */
289         int     numargs;
290
291         int     numo;           /* Number of shorts in opcode */
292         short   opcode[11];
293
294         struct m68k_op operands[6];
295
296         int     nexp;           /* number of exprs in use */
297         struct m68k_exp exprs[4];
298
299         int     nfrag;          /* Number of frags we have to produce */
300         struct {
301                 int fragoff;    /* Where in the current opcode[] the frag ends */
302                 symbolS *fadd;
303                 long foff;
304                 int fragty;
305         } fragb[4];
306
307         int     nrel;           /* Num of reloc strucs in use */
308         struct  {
309                 int     n;
310                 symbolS *add,
311                         *sub,
312                         *got;
313                 long    off;
314                 char    wid;
315                 char    pcrel;
316                 enum    reloc_type rtype;
317         } reloc[5];             /* Five is enough??? */
318 };
319
320 #define cpu_of_arch(x)          ((x) & m68000up)
321 #define float_of_arch(x)        ((x) & mfloat)
322 #define mmu_of_arch(x)          ((x) & mmmu)
323
324 static struct m68k_it the_ins;          /* the instruction being assembled */
325
326 /* Macros for adding things to the m68k_it struct */
327
328 #define addword(w)      the_ins.opcode[the_ins.numo++]=(w)
329
330 /* Like addword, but goes BEFORE general operands */
331 #define insop(w)        { \
332         int z; \
333         for (z=the_ins.numo;z>opcode->m_codenum;--z) \
334             the_ins.opcode[z]=the_ins.opcode[z-1]; \
335         for (z=0;z<the_ins.nrel;z++) \
336             the_ins.reloc[z].n+=2; \
337         the_ins.opcode[opcode->m_codenum]=w; \
338         the_ins.numo++; \
339     }
340
341
342 #define add_exp(beg,end) (the_ins.exprs[the_ins.nexp].e_beg=beg, \
343                           the_ins.exprs[the_ins.nexp].e_end=end, \
344                           &the_ins.exprs[the_ins.nexp++] \
345                           )
346
347
348 /* The numo+1 kludge is so we can hit the low order byte of the prev word. Blecch*/
349 #define add_fix(width, exp, pc_rel, r_type) { \
350         the_ins.reloc[the_ins.nrel].n= ((width) == 'B') ? (the_ins.numo*2-1) : \
351             (((width) == 'b') ? ((the_ins.numo-1)*2) : (the_ins.numo*2)); \
352         the_ins.reloc[the_ins.nrel].add=adds((exp)); \
353         the_ins.reloc[the_ins.nrel].sub=subs((exp)); \
354         the_ins.reloc[the_ins.nrel].off=offs((exp)); \
355         the_ins.reloc[the_ins.nrel].got=gots((exp)); \
356         the_ins.reloc[the_ins.nrel].wid=width; \
357         the_ins.reloc[the_ins.nrel].pcrel=pc_rel; \
358         the_ins.reloc[the_ins.nrel++].rtype=r_type; \
359     }
360
361 #define add_frag(add,off,type)  {\
362         the_ins.fragb[the_ins.nfrag].fragoff=the_ins.numo;\
363         the_ins.fragb[the_ins.nfrag].fadd=add;\
364         the_ins.fragb[the_ins.nfrag].foff=off;\
365         the_ins.fragb[the_ins.nfrag++].fragty=type;\
366     }
367
368 #define isvar(exp)      ((exp) && (adds(exp) || subs(exp) || gots(exp)))
369
370 #define seg(exp)        ((exp)->e_exp.X_seg)
371 #define adds(exp)       ((exp)->e_exp.X_add_symbol)
372 #define subs(exp)       ((exp)->e_exp.X_subtract_symbol)
373 #define offs(exp)       ((exp)->e_exp.X_add_number)
374 #define gots(exp)       ((exp)->e_exp.X_got_symbol)
375
376
377 struct m68k_incant {
378         char *m_operands;
379         unsigned long m_opcode;
380         short m_opnum;
381         short m_codenum;
382         enum m68k_architecture m_arch;
383         struct m68k_incant *m_next;
384 };
385
386 #define getone(x)       ((((x)->m_opcode)>>16)&0xffff)
387 #define gettwo(x)       (((x)->m_opcode)&0xffff)
388
389
390 #if __STDC__ == 1
391
392 static char *crack_operand(char *str, struct m68k_op *opP);
393 static int get_num(struct m68k_exp *exp, int ok);
394 static int get_regs(int i, char *str, struct m68k_op *opP);
395 static int reverse_16_bits(int in);
396 static int reverse_8_bits(int in);
397 static int try_index(char **s, struct m68k_op *opP);
398 static void install_gen_operand(int mode, int val);
399 static void install_operand(int mode, int val);
400 static void s_bss(void);
401 static void s_data1(void);
402 static void s_data2(void);
403 static void s_even(void);
404 static void s_proc(void);
405
406 #else /* not __STDC__ */
407
408 static char *crack_operand();
409 static int get_num();
410 static int get_regs();
411 static int reverse_16_bits();
412 static int reverse_8_bits();
413 static int try_index();
414 static void install_gen_operand();
415 static void install_operand();
416 static void s_bss();
417 static void s_data1();
418 static void s_data2();
419 static void s_even();
420 static void s_proc();
421
422 #endif /* not __STDC__ */
423
424 static enum m68k_architecture current_architecture = 0;
425
426 /* BCC68000 is for patching in an extra jmp instruction for long offsets
427    on the 68000.  The 68000 doesn't support long branches with branchs */
428
429 /* This table desribes how you change sizes for the various types of variable
430    size expressions.  This version only supports two kinds. */
431
432 /* Note that calls to frag_var need to specify the maximum expansion needed */
433 /* This is currently 10 bytes for DBCC */
434
435 /* The fields are:
436    How far Forward this mode will reach:
437    How far Backward this mode will reach:
438    How many bytes this mode will add to the size of the frag
439    Which mode to go to if the offset won't fit in this one
440    */
441 const relax_typeS
442     md_relax_table[] = {
443             { 1,                1,              0,      0 },    /* First entries aren't used */
444             { 1,                1,              0,      0 },    /* For no good reason except */
445             { 1,                1,              0,      0 },    /* that the VAX doesn't either */
446             { 1,                1,              0,      0 },
447
448             { (127),    (-128),         0,      TAB(BRANCH,SHORT)},
449             { (32767),  (-32768),       2,      TAB(BRANCH,LONG) },
450             { 0,                0,              4,      0 },
451             { 1,                1,              0,      0 },
452
453             { 1,                1,              0,      0 },    /* FBRANCH doesn't come BYTE */
454             { (32767),  (-32768),       2,      TAB(FBRANCH,LONG)},
455             { 0,                0,              4,      0 },
456             { 1,                1,              0,      0 },
457
458             { 1,                1,              0,      0 },    /* PCREL doesn't come BYTE */
459             { (32767),  (-32768),       2,      TAB(PCREL,LONG)},
460             { 0,                0,              4,      0 },
461             { 1,                1,              0,      0 },
462
463             { (127),    (-128),         0,      TAB(BCC68000,SHORT)},
464             { (32767),  (-32768),       2,      TAB(BCC68000,LONG) },
465             { 0,                0,              6,      0 },    /* jmp long space */
466             { 1,                1,              0,      0 },
467
468             { 1,                1,              0,      0 },    /* DBCC doesn't come BYTE */
469             { (32767),  (-32768),       2,      TAB(DBCC,LONG) },
470             { 0,                0,              10,     0 },    /* bra/jmp long space */
471             { 1,                1,              0,      0 },
472
473             { 1,                1,              0,      0 },    /* PCLEA doesn't come BYTE */
474             { 32767,    -32768,         2,      TAB(PCLEA,LONG) },
475             { 0,                0,              6,      0 },
476             { 1,                1,              0,      0 },
477
478     };
479
480 /* These are the machine dependent pseudo-ops.  These are included so
481    the assembler can work on the output from the SUN C compiler, which
482    generates these.
483    */
484
485 /* This table describes all the machine specific pseudo-ops the assembler
486    has to support.  The fields are:
487    pseudo-op name without dot
488    function to call to execute this pseudo-op
489    Integer arg to pass to the function
490    */
491 const pseudo_typeS md_pseudo_table[] = {
492         { "data1",      s_data1,        0       },
493         { "data2",      s_data2,        0       },
494         { "bss",        s_bss,          0       },
495         { "even",       s_even,         0       },
496         { "skip",       s_space,        0       },
497         { "proc",       s_proc,         0       },
498         { 0,            0,              0       }
499 };
500
501
502 /* #define isbyte(x)    ((x) >= -128 && (x) <= 127) */
503 /* #define isword(x)    ((x) >= -32768 && (x) <= 32767) */
504
505 #define issbyte(x)      ((x) >= -128 && (x) <= 127)
506 #define isubyte(x)      ((x) >= 0 && (x) <= 255)
507 #define issword(x)      ((x) >= -32768 && (x) <= 32767)
508 #define isuword(x)      ((x) >= 0 && (x) <= 65535)
509
510 #define isbyte(x)       ((x) >= -128 && (x) <= 255)
511 #define isword(x)       ((x) >= -32768 && (x) <= 65535)
512 #define islong(x)       (1)
513
514 extern char *input_line_pointer;
515
516 enum {
517         FAIL = 0,
518         OK = 1,
519 };
520
521 /* JF these tables here are for speed at the expense of size */
522 /* You can replace them with the #if 0 versions if you really
523    need space and don't mind it running a bit slower */
524
525 static char mklower_table[256];
526 #define mklower(c) (mklower_table[(unsigned char)(c)])
527 static char notend_table[256];
528 static char alt_notend_table[256];
529 #define notend(s) (!(notend_table[(unsigned char)(*s)] || (*s == ':' &&\
530                                                             alt_notend_table[(unsigned char)(s[1])])))
531
532 #if 0
533 #define mklower(c)      (isupper(c) ? tolower(c) : c)
534 #endif
535
536 /* Handle the extra arg for fix_new when doing PIC */
537 #ifdef  PIC
538 #define FIX_NO_RELOC    NO_RELOC, NULL
539 #else
540 #define FIX_NO_RELOC    NO_RELOC
541 #endif  /* PIC */
542
543
544 /* JF modified this to handle cases where the first part of a symbol name
545    looks like a register */
546
547 /*
548  * m68k_reg_parse() := if it looks like a register, return it's token &
549  * advance the pointer.
550  */
551
552 enum _register m68k_reg_parse(ccp)
553 register char **ccp;
554 {
555 #ifndef MAX_REG_NAME_LEN
556 #define MAX_REG_NAME_LEN (6)
557 #endif /* MAX_REG_NAME_LEN */
558         register char c[MAX_REG_NAME_LEN];
559         char *p, *q;
560         register int n = 0,
561         ret = FAIL;
562
563         c[0] = mklower(ccp[0][0]);
564 #ifdef REGISTER_PREFIX
565         if (c[0] != REGISTER_PREFIX) {
566                 return(FAIL);
567         } /* need prefix */
568 #endif
569
570         for (p = c, q = ccp[0]; p < c + MAX_REG_NAME_LEN; ++p, ++q)
571             {
572                     if (*q == 0)
573                         {
574                                 *p = 0;
575                                 break;
576                         }
577                     else
578                         *p = mklower(*q);
579             } /* downcase */
580
581         switch (c[0]) {
582         case 'a':
583                 if (c[1] >= '0' && c[1] <= '7') {
584                         n=2;
585                         ret=ADDR+c[1]-'0';
586                 }
587 #ifndef NO_68851
588                 else if (c[1] == 'c') {
589                         n = 2;
590                         ret = AC;
591                 }
592 #endif
593                 break;
594 #ifndef NO_68851
595         case 'b':
596                 if (c[1] == 'a') {
597                         if (c[2] == 'd') {
598                                 if (c[3] >= '0' && c[3] <= '7') {
599                                         n = 4;
600                                         ret = BAD + c[3] - '0';
601                                 }
602                         } /* BAD */
603                         if (c[2] == 'c') {
604                                 if (c[3] >= '0' && c[3] <= '7') {
605                                         n = 4;
606                                         ret = BAC + c[3] - '0';
607                                 }
608                         } /* BAC */
609                 } else if (c[1] == 'c') {
610                         n = 2;
611                         ret = BC;
612                 } /* BC */
613                 break;
614 #endif
615         case 'c':
616 #ifndef NO_68851
617                 if (c[1] == 'a' && c[2] == 'l') {
618                         n = 3;
619                         ret = CAL;
620                 } else
621 #endif
622                     /* This supports both CCR and CC as the ccr reg. */
623                     if (c[1] == 'c' && c[2] == 'r') {
624                             n=3;
625                             ret = CCR;
626                     } else if (c[1] == 'c') {
627                             n=2;
628                             ret = CCR;
629                     } else if (c[1] == 'a' && (c[2] == 'a' || c[2] == 'c') && c[3] == 'r') {
630                             n=4;
631                             ret = c[2] == 'a' ? CAAR : CACR;
632                     }
633 #ifndef NO_68851
634                     else if (c[1] == 'r' && c[2] == 'p') {
635                             n = 3;
636                             ret = (CRP);
637                     }
638 #endif
639                 break;
640         case 'd':
641                 if (c[1] >= '0' && c[1] <= '7') {
642                         n = 2;
643                         ret = DATA + c[1] - '0';
644                 } else if (c[1] == 'f' && c[2] == 'c') {
645                         n = 3;
646                         ret = DFC;
647                 } else if (c[1] == 'c') {
648                         n = 2;
649                         ret = DC;
650                 } else if (c[1] == 't' && c[2] == 't') {
651                         if ('0' <= c[3] && c[3] <= '1') {
652                                 n = 4;
653                                 ret = DTT0 + (c[3] - '0');
654                         } /* DTT[01] */
655                 }
656 #ifndef NO_68851
657                 else if (c[1] == 'r' && c[2] == 'p') {
658                         n = 3;
659                         ret = (DRP);
660                 }
661 #endif
662                 break;
663         case 'f':
664                 if (c[1] == 'p') {
665                         if (c[2] >= '0' && c[2] <= '7') {
666                                 n=3;
667                                 ret = FPREG+c[2]-'0';
668                                 if (c[3] == ':')
669                                     ccp[0][3]=',';
670                         } else if (c[2] == 'i') {
671                                 n=3;
672                                 ret = FPI;
673                         } else if (c[2] == 's') {
674                                 n= (c[3] == 'r' ? 4 : 3);
675                                 ret = FPS;
676                         } else if (c[2] == 'c') {
677                                 n= (c[3] == 'r' ? 4 : 3);
678                                 ret = FPC;
679                         }
680                 }
681                 break;
682         case 'i':
683                 if (c[1] == 's' && c[2] == 'p') {
684                         n = 3;
685                         ret = ISP;
686                 } else if (c[1] == 'c') {
687                         n = 2;
688                         ret = IC;
689                 } else if (c[1] == 't' && c[2] == 't') {
690                         if ('0' <= c[3] && c[3] <= '1') {
691                                 n = 4;
692                                 ret = ITT0 + (c[3] - '0');
693                         } /* ITT[01] */
694                 }
695                 break;
696         case 'm':
697                 if (c[1] == 's' && c[2] == 'p') {
698                         n = 3;
699                         ret = MSP;
700                 } else if (c[1] == 'm' && c[2] == 'u' && c[3] == 's' && c[4] == 'r') {
701                         n = 5;
702                         ret = MMUSR;
703                 }
704                 break;
705         case 'n':
706                 if (c[1] == 'c') {
707                         n = 2;
708                         ret = NC;
709                 }
710                 break;
711         case 'p':
712                 if (c[1] == 'c') {
713 #ifndef NO_68851
714                         if (c[2] == 's' && c[3] == 'r') {
715                                 n=4;
716                                 ret = (PCSR);
717                         } else
718 #endif
719                             {
720                                     n=2;
721                                     ret = PC;
722                             }
723                 }
724 #ifndef NO_68851
725                 else if (c[1] == 's' && c[2] == 'r') {
726                         n = 3;
727                         ret = (PSR);
728                 }
729 #endif
730                 break;
731         case 's':
732 #ifndef NO_68851
733                 if (c[1] == 'c' && c[2] == 'c') {
734                         n = 3;
735                         ret = (SCC);
736                 } else
737 #endif
738                     if (c[1] == 'r') {
739                             if (c[2] == 'p') {
740                                     n = 3;
741                                     ret = SRP;
742                             } else {
743                                     n = 2;
744                                     ret = SR;
745                             } /* srp else sr */
746                     } else if (c[1] == 'p') {
747                             n = 2;
748                             ret = SP;
749                     } else if (c[1] == 'f' && c[2] == 'c') {
750                             n = 3;
751                             ret = SFC;
752                     }
753                 break;
754         case 't':
755                 if (c[1] == 'c') {
756                         n = 2;
757                         ret = TC;
758                 }
759                 break;
760         case 'u':
761                 if (c[1] == 's' && c[2] == 'p') {
762                         n=3;
763                         ret = USP;
764                 } else if (c[1] == 'r' && c[2] == 'p') {
765                         n = 3;
766                         ret = URP;
767                 }
768                 break;
769         case 'v':
770 #ifndef NO_68851
771                 if (c[1] == 'a' && c[2] == 'l') {
772                         n = 3;
773                         ret = (VAL);
774                 } else
775 #endif
776                     if (c[1] == 'b' && c[2] == 'r') {
777                             n=3;
778                             ret = VBR;
779                     }
780                 break;
781         case 'z':
782                 if (c[1] == 'p' && c[2] == 'c') {
783                         n=3;
784                         ret = ZPC;
785                 }
786                 break;
787         default:
788                 break;
789         }
790         if (n) {
791 #ifdef REGISTER_PREFIX
792                 n++;
793 #endif
794                 if (isalnum(ccp[0][n]) || ccp[0][n] == '_')
795                     ret=FAIL;
796                 else
797                     ccp[0]+=n;
798         } else
799             ret = FAIL;
800         return ret;
801 }
802
803 #define SKIP_WHITE()    { str++; if (*str == ' ') str++;}
804
805 /*
806  * m68k_ip_op := '#' + <anything>
807  *      | <register> + range_sep + get_regs
808  *      ;
809  *
810  * range_sep := '/' | '-' ;
811  *
812  * SKIP_WHITE := <empty> | ' ' ;
813  *
814  */
815
816 int
817     m68k_ip_op(str,opP)
818 char *str;
819 register struct m68k_op *opP;
820 {
821         char    *strend;
822         long    i;
823         char    *parse_index();
824
825         if (*str == ' ') {
826                 str++;
827         } /* Find the beginning of the string */
828
829         if (!*str) {
830                 opP->error="Missing operand";
831                 return FAIL;
832         } /* Out of gas */
833
834         for (strend = str; *strend; strend++) ;;
835
836         --strend;
837
838         if (*str == '#') {
839                 str++;
840                 opP->con1=add_exp(str,strend);
841                 opP->mode=IMMED;
842                 return OK;
843         } /* Guess what:  A constant.  Shar and enjoy */
844
845         i = m68k_reg_parse(&str);
846
847         /* is a register, is exactly a register, and is followed by '@' */
848
849         if ((i == FAIL || *str != '\0') && *str != '@') {
850                 char *stmp;
851
852                 if (i != FAIL && (*str == '/' || *str == '-')) {
853                         opP->mode=REGLST;
854                         return(get_regs(i,str,opP));
855                 }
856                 if ((stmp=strchr(str,'@')) != '\0') {
857                         opP->con1=add_exp(str,stmp-1);
858                         if (stmp == strend) {
859                                 opP->mode=AINDX;
860                                 return(OK);
861                         }
862
863                         if ((current_architecture & m68020up) == 0) {
864                                 return(FAIL);
865                         } /* if target is not a '20 or better */
866
867                         stmp++;
868                         if (*stmp++ != '(' || *strend-- != ')') {
869                                 opP->error="Malformed operand";
870                                 return(FAIL);
871                         }
872                         i=try_index(&stmp,opP);
873                         opP->con2=add_exp(stmp,strend);
874
875                         if (i == FAIL) {
876                                 opP->mode=AMIND;
877                         } else {
878                                 opP->mode=APODX;
879                         }
880                         return(OK);
881                 } /* if there's an '@' */
882                 opP->mode = ABSL;
883                 opP->con1 = add_exp(str,strend);
884                 return(OK);
885         } /* not a register, not exactly a register, or no '@' */
886
887         opP->reg=i;
888
889         if (*str == '\0') {
890                 if (i >= DATA+0 && i <= DATA+7)
891                     opP->mode=DREG;
892                 else if (i >= ADDR+0 && i <= ADDR+7)
893                     opP->mode=AREG;
894                 else
895                     opP->mode=MSCR;
896                 return OK;
897         }
898
899         if ((i<ADDR+0 || i>ADDR+7) && i != PC && i != ZPC && i != FAIL) {       /* Can't indirect off non address regs */
900                 opP->error="Invalid indirect register";
901                 return FAIL;
902         }
903         know(*str == '@');
904
905         str++;
906         switch (*str) {
907         case '\0':
908                 opP->mode=AINDR;
909                 return OK;
910         case '-':
911                 opP->mode=ADEC;
912                 return OK;
913         case '+':
914                 opP->mode=AINC;
915                 return OK;
916         case '(':
917                 str++;
918                 break;
919         default:
920                 opP->error="Junk after indirect";
921                 return FAIL;
922         }
923         /* Some kind of indexing involved.  Lets find out how bad it is */
924         i=try_index(&str,opP);
925         /* Didn't start with an index reg, maybe its offset or offset,reg */
926         if (i == FAIL) {
927                 char *beg_str;
928
929                 beg_str=str;
930                 for (i=1;i;) {
931                         switch (*str++) {
932                         case '\0':
933                                 opP->error="Missing )";
934                                 return FAIL;
935                         case ',': i=0; break;
936                         case '(': i++; break;
937                         case ')': --i; break;
938                         }
939                 }
940                 /* if (str[-3] == ':') {
941                    int siz;
942
943                    switch (str[-2]) {
944                    case 'b':
945                    case 'B':
946                    siz=1;
947                    break;
948                    case 'w':
949                    case 'W':
950                    siz=2;
951                    break;
952                    case 'l':
953                    case 'L':
954                    siz=3;
955                    break;
956                    default:
957                    opP->error="Specified size isn't :w or :l";
958                    return FAIL;
959                    }
960                    opP->con1=add_exp(beg_str,str-4);
961                    opP->con1->e_siz=siz;
962                    } else */
963                 opP->con1=add_exp(beg_str,str-2);
964                 /* Should be offset,reg */
965                 if (str[-1] == ',') {
966                         i=try_index(&str,opP);
967                         if (i == FAIL) {
968                                 opP->error="Malformed index reg";
969                                 return FAIL;
970                         }
971                 }
972         }
973         /* We've now got offset)   offset,reg)   or    reg) */
974
975         if (*str == '\0') {
976                 /* Th-the-thats all folks */
977                 if (opP->reg == FAIL) opP->mode = AINDX;        /* Other form of indirect */
978                 else if (opP->ireg == FAIL) opP->mode = AOFF;
979                 else opP->mode = AINDX;
980                 return(OK);
981         }
982         /* Next thing had better be another @ */
983         if (*str != '@' || str[1] != '(') {
984                 opP->error = "junk after indirect";
985                 return(FAIL);
986         }
987
988         if ((current_architecture & m68020up) == 0) {
989                 return(FAIL);
990         } /* if target is not a '20 or better */
991
992         str+=2;
993
994         if (opP->ireg != FAIL) {
995                 opP->mode = APRDX;
996
997                 i = try_index(&str, opP);
998                 if (i != FAIL) {
999                         opP->error = "Two index registers!  not allowed!";
1000                         return(FAIL);
1001                 }
1002         } else {
1003                 i = try_index(&str, opP);
1004         }
1005
1006         if (i == FAIL) {
1007                 char *beg_str;
1008
1009                 beg_str = str;
1010
1011                 for (i = 1; i; ) {
1012                         switch (*str++) {
1013                         case '\0':
1014                                 opP->error="Missing )";
1015                                 return(FAIL);
1016                         case ',': i=0; break;
1017                         case '(': i++; break;
1018                         case ')': --i; break;
1019                         }
1020                 }
1021
1022                 opP->con2=add_exp(beg_str,str-2);
1023
1024                 if (str[-1] == ',') {
1025                         if (opP->ireg != FAIL) {
1026                                 opP->error = "Can't have two index regs";
1027                                 return(FAIL);
1028                         }
1029
1030                         i = try_index(&str, opP);
1031
1032                         if (i == FAIL) {
1033                                 opP->error = "malformed index reg";
1034                                 return(FAIL);
1035                         }
1036
1037                         opP->mode = APODX;
1038                 } else if (opP->ireg != FAIL) {
1039                         opP->mode = APRDX;
1040                 } else {
1041                         opP->mode = AMIND;
1042                 }
1043         } else {
1044                 opP->mode = APODX;
1045         }
1046
1047         if (*str != '\0') {
1048                 opP->error="Junk after indirect";
1049                 return FAIL;
1050         }
1051         return(OK);
1052 } /* m68k_ip_op() */
1053
1054 /*
1055  *
1056  * try_index := data_or_address_register + ')' + SKIP_W
1057  *      | data_or_address_register + ':' + SKIP_W + size_spec + SKIP_W + multiplier + ')' + SKIP_W
1058  *
1059  * multiplier := <empty>
1060  *      | ':' + multiplier_number
1061  *      ;
1062  *
1063  * multiplier_number := '1' | '2' | '4' | '8' ;
1064  *
1065  * size_spec := 'l' | 'L' | 'w' | 'W' ;
1066  *
1067  * SKIP_W := <empty> | ' ' ;
1068  *
1069  */
1070
1071 static int try_index(s,opP)
1072 char **s;
1073 struct m68k_op *opP;
1074 {
1075         register int    i;
1076         char    *ss;
1077 #define SKIP_W()        { ss++; if (*ss == ' ') ss++;}
1078
1079         ss= *s;
1080         /* SKIP_W(); */
1081         i=m68k_reg_parse(&ss);
1082         if (!(i >= DATA+0 && i <= ADDR+7)) {    /* if i is not DATA or ADDR reg */
1083                 *s=ss;
1084                 return FAIL;
1085         }
1086         opP->ireg=i;
1087         /* SKIP_W(); */
1088         if (*ss == ')') {
1089                 opP->isiz=0;
1090                 opP->imul=1;
1091                 SKIP_W();
1092                 *s=ss;
1093                 return OK;
1094         }
1095         if (*ss != ':') {
1096                 opP->error="Missing : in index register";
1097                 *s=ss;
1098                 return FAIL;
1099         }
1100         SKIP_W();
1101         switch (*ss) {
1102         case 'w':
1103         case 'W':
1104                 opP->isiz=2;
1105                 break;
1106         case 'l':
1107         case 'L':
1108                 opP->isiz=3;
1109                 break;
1110         default:
1111                 opP->error="Index register size spec not :w or :l";
1112                 *s=ss;
1113                 return FAIL;
1114         }
1115         SKIP_W();
1116         if (*ss == ':') {
1117                 SKIP_W();
1118                 switch (*ss) {
1119                 case '1':
1120                 case '2':
1121                 case '4':
1122                 case '8':
1123                         opP->imul= *ss-'0';
1124                         break;
1125                 default:
1126                         opP->error="index multiplier not 1, 2, 4 or 8";
1127                         *s=ss;
1128                         return FAIL;
1129                 }
1130                 SKIP_W();
1131         } else opP->imul=1;
1132         if (*ss != ')') {
1133                 opP->error="Missing )";
1134                 *s=ss;
1135                 return FAIL;
1136         }
1137         SKIP_W();
1138         *s=ss;
1139         return OK;
1140 } /* try_index() */
1141
1142 #ifdef TEST1    /* TEST1 tests m68k_ip_op(), which parses operands */
1143 main()
1144 {
1145         char buf[128];
1146         struct m68k_op thark;
1147
1148         for (;;) {
1149                 if (!gets(buf))
1150                     break;
1151                 memset(&thark, '\0', sizeof(thark));
1152                 if (!m68k_ip_op(buf,&thark)) printf("FAIL:");
1153                 if (thark.error)
1154                     printf("op1 error %s in %s\n",thark.error,buf);
1155                 printf("mode %d, reg %d, ",thark.mode,thark.reg);
1156                 if (thark.b_const)
1157                     printf("Constant: '%.*s',",1+thark.e_const-thark.b_const,thark.b_const);
1158                 printf("ireg %d, isiz %d, imul %d ",thark.ireg,thark.isiz,thark.imul);
1159                 if (thark.b_iadd)
1160                     printf("Iadd: '%.*s'",1+thark.e_iadd-thark.b_iadd,thark.b_iadd);
1161                 printf("\n");
1162         }
1163         exit(0);
1164 }
1165
1166 #endif
1167
1168
1169 static struct hash_control*   op_hash = NULL;   /* handle of the OPCODE hash table
1170                                                    NULL means any use before m68k_ip_begin()
1171                                                    will crash */
1172
1173 \f
1174 /*
1175  *              m 6 8 k _ i p ( )
1176  *
1177  * This converts a string into a 68k instruction.
1178  * The string must be a bare single instruction in sun format
1179  * with RMS-style 68020 indirects
1180  *  (example:  )
1181  *
1182  * It provides some error messages: at most one fatal error message (which
1183  * stops the scan) and at most one warning message for each operand.
1184  * The 68k instruction is returned in exploded form, since we have no
1185  * knowledge of how you parse (or evaluate) your expressions.
1186  * We do however strip off and decode addressing modes and operation
1187  * mnemonic.
1188  *
1189  * This function's value is a string. If it is not "" then an internal
1190  * logic error was found: read this code to assign meaning to the string.
1191  * No argument string should generate such an error string:
1192  * it means a bug in our code, not in the user's text.
1193  *
1194  * You MUST have called m68k_ip_begin() once and m86_ip_end() never before using
1195  * this function.
1196  */
1197
1198 /* JF this function no longer returns a useful value.  Sorry */
1199 void m68k_ip (instring)
1200 char *instring;
1201 {
1202         register char *p;
1203         register struct m68k_op *opP;
1204         register struct m68k_incant *opcode;
1205         register char *s;
1206         register int tmpreg = 0,
1207         baseo = 0,
1208         outro = 0,
1209         nextword;
1210         int     siz1,
1211         siz2;
1212         char    c;
1213         int     losing;
1214         int     opsfound;
1215         int     reloc_type;
1216         char    *crack_operand();
1217         LITTLENUM_TYPE words[6];
1218         LITTLENUM_TYPE *wordp;
1219
1220         if (*instring == ' ')
1221             instring++;                 /* skip leading whitespace */
1222
1223         /* Scan up to end of operation-code, which MUST end in end-of-string
1224            or exactly 1 space. */
1225         for (p = instring; *p != '\0'; p++)
1226             if (*p == ' ')
1227                 break;
1228
1229
1230         if (p == instring) {
1231                 the_ins.error = "No operator";
1232                 the_ins.opcode[0] = NULL;
1233                 /* the_ins.numo=1; */
1234                 return;
1235         }
1236
1237         /* p now points to the end of the opcode name, probably whitespace.
1238            make sure the name is null terminated by clobbering the whitespace,
1239            look it up in the hash table, then fix it back. */
1240         c = *p;
1241         *p = '\0';
1242         opcode = (struct m68k_incant *)hash_find (op_hash, instring);
1243         *p = c;
1244
1245         if (opcode == NULL) {
1246                 the_ins.error = "Unknown operator";
1247                 the_ins.opcode[0] = NULL;
1248                 /* the_ins.numo=1; */
1249                 return;
1250         }
1251
1252         /* found a legitimate opcode, start matching operands */
1253         while (*p == ' ') ++p;
1254
1255         for (opP = &the_ins.operands[0]; *p; opP++) {
1256
1257                 p = crack_operand(p, opP);
1258
1259                 if (opP->error) {
1260                         the_ins.error=opP->error;
1261                         return;
1262                 }
1263         }
1264
1265         opsfound = opP - &the_ins.operands[0];
1266
1267         /* This ugly hack is to support the floating pt opcodes in their standard form */
1268         /* Essentially, we fake a first enty of type COP#1 */
1269         if (opcode->m_operands[0] == 'I') {
1270                 int     n;
1271
1272                 for (n=opsfound;n>0;--n)
1273                     the_ins.operands[n]=the_ins.operands[n-1];
1274
1275                 /* memcpy((char *)(&the_ins.operands[1]), (char *)(&the_ins.operands[0]), opsfound*sizeof(the_ins.operands[0])); */
1276                 memset((char *)(&the_ins.operands[0]), '\0', sizeof(the_ins.operands[0]));
1277                 the_ins.operands[0].mode=MSCR;
1278                 the_ins.operands[0].reg=COPNUM;         /* COP #1 */
1279                 opsfound++;
1280         }
1281
1282         /* We've got the operands.  Find an opcode that'll accept them */
1283         for (losing = 0; ; ) {
1284                 /* if we didn't get the right number of ops,
1285                    or we have no common model with this pattern
1286                    then reject this pattern. */
1287
1288                 if (opsfound != opcode->m_opnum
1289                     || ((opcode->m_arch & current_architecture) == 0)) {
1290
1291                         ++losing;
1292
1293                 } else {
1294                         for (s=opcode->m_operands, opP = &the_ins.operands[0]; *s && !losing; s += 2, opP++) {
1295                                 /* Warning: this switch is huge! */
1296                                 /* I've tried to organize the cases into  this order:
1297                                    non-alpha first, then alpha by letter.  lower-case goes directly
1298                                    before uppercase counterpart. */
1299                                 /* Code with multiple case ...: gets sorted by the lowest case ...
1300                                    it belongs to.  I hope this makes sense. */
1301                                 switch (*s) {
1302 #ifdef  PIC
1303                                 case ' ':
1304                                         /* this operand is just here to indicate a jump-table branch */
1305                                         if (!picmode)
1306                                                 losing++;
1307                                         break;
1308 #endif  /* PIC */
1309
1310                                 case '!':
1311                                         if (opP->mode == MSCR || opP->mode == IMMED
1312                                             || opP->mode == DREG || opP->mode == AREG
1313                                             || opP->mode == AINC || opP->mode == ADEC
1314                                             || opP->mode == REGLST)
1315                                             losing++;
1316                                         break;
1317
1318                                 case '#':
1319                                         if (opP->mode != IMMED)
1320                                             losing++;
1321                                         else {
1322                                                 long t;
1323
1324                                                 t=get_num(opP->con1,80);
1325                                                 if (s[1] == 'b' && !isbyte(t))
1326                                                     losing++;
1327                                                 else if (s[1] == 'w' && !isword(t))
1328                                                     losing++;
1329                                         }
1330                                         break;
1331
1332                                 case '^':
1333                                 case 'T':
1334                                         if (opP->mode != IMMED)
1335                                             losing++;
1336                                         break;
1337
1338                                 case '$':
1339                                         if (opP->mode == MSCR || opP->mode == AREG ||
1340                                            opP->mode == IMMED || opP->reg == PC || opP->reg == ZPC || opP->mode == REGLST)
1341                                             losing++;
1342                                         break;
1343
1344                                 case '%':
1345                                         if (opP->mode == MSCR || opP->reg == PC ||
1346                                            opP->reg == ZPC || opP->mode == REGLST)
1347                                             losing++;
1348                                         break;
1349
1350
1351                                 case '&':
1352                                         if (opP->mode == MSCR || opP->mode == DREG ||
1353                                            opP->mode == AREG || opP->mode == IMMED || opP->reg == PC || opP->reg == ZPC ||
1354                                            opP->mode == AINC || opP->mode == ADEC || opP->mode == REGLST)
1355                                             losing++;
1356                                         break;
1357
1358                                 case '*':
1359                                         if (opP->mode == MSCR || opP->mode == REGLST)
1360                                             losing++;
1361                                         break;
1362
1363                                 case '+':
1364                                         if (opP->mode != AINC)
1365                                             losing++;
1366                                         break;
1367
1368                                 case '-':
1369                                         if (opP->mode != ADEC)
1370                                             losing++;
1371                                         break;
1372
1373                                 case '/':
1374                                         if (opP->mode == MSCR || opP->mode == AREG ||
1375                                            opP->mode == AINC || opP->mode == ADEC || opP->mode == IMMED || opP->mode == REGLST)
1376                                             losing++;
1377                                         break;
1378
1379                                 case ';':
1380                                         if (opP->mode == MSCR || opP->mode == AREG || opP->mode == REGLST)
1381                                             losing++;
1382                                         break;
1383
1384                                 case '?':
1385                                         if (opP->mode == MSCR || opP->mode == AREG ||
1386                                            opP->mode == AINC || opP->mode == ADEC || opP->mode == IMMED || opP->reg == PC ||
1387                                            opP->reg == ZPC || opP->mode == REGLST)
1388                                             losing++;
1389                                         break;
1390
1391                                 case '@':
1392                                         if (opP->mode == MSCR || opP->mode == AREG ||
1393                                            opP->mode == IMMED || opP->mode == REGLST)
1394                                             losing++;
1395                                         break;
1396
1397                                 case '~':               /* For now! (JF FOO is this right?) */
1398                                         if (opP->mode == MSCR || opP->mode == DREG ||
1399                                            opP->mode == AREG || opP->mode == IMMED || opP->reg == PC || opP->reg == ZPC || opP->mode == REGLST)
1400                                             losing++;
1401                                         break;
1402
1403                                 case 'A':
1404                                         if (opP->mode != AREG)
1405                                             losing++;
1406                                         break;
1407                                 case 'a':
1408                                         if (opP->mode != AINDR) {
1409                                                 ++losing;
1410                                         } /* if not address register indirect */
1411                                         break;
1412                                 case 'B':       /* FOO */
1413                                         if (opP->mode != ABSL || (flagseen['S'] && instring[0] == 'j'
1414                                                                && instring[1] == 'b'
1415                                                                && instring[2] == 's'
1416                                                                && instring[3] == 'r'))
1417                                             losing++;
1418                                         break;
1419
1420                                 case 'C':
1421                                         if (opP->mode != MSCR || opP->reg != CCR)
1422                                             losing++;
1423                                         break;
1424
1425                                 case 'd':       /* FOO This mode is a KLUDGE!! */
1426                                         if (opP->mode != AOFF && (opP->mode != ABSL ||
1427                                                                opP->con1->e_beg[0] != '(' || opP->con1->e_end[0] != ')'))
1428                                             losing++;
1429                                         break;
1430
1431                                 case 'D':
1432                                         if (opP->mode != DREG)
1433                                             losing++;
1434                                         break;
1435
1436                                 case 'F':
1437                                         if (opP->mode != MSCR || opP->reg<(FPREG+0) || opP->reg>(FPREG+7))
1438                                             losing++;
1439                                         break;
1440
1441                                 case 'I':
1442                                         if (opP->mode != MSCR || opP->reg<COPNUM ||
1443                                            opP->reg >= COPNUM+7)
1444                                             losing++;
1445                                         break;
1446
1447                                 case 'J':
1448                                         if (opP->mode != MSCR
1449                                             || opP->reg < USP
1450                                             || opP->reg > URP
1451                                             || cpu_of_arch(current_architecture) < m68010 /* before 68010 had none */
1452                                             || (cpu_of_arch(current_architecture) < m68020
1453                                                 && opP->reg != SFC
1454                                                 && opP->reg != DFC
1455                                                 && opP->reg != USP
1456                                                 && opP->reg != VBR) /* 68010's had only these */
1457                                             || (cpu_of_arch(current_architecture) < m68040
1458                                                 && opP->reg != SFC
1459                                                 && opP->reg != DFC
1460                                                 && opP->reg != USP
1461                                                 && opP->reg != VBR
1462                                                 && opP->reg != CACR
1463                                                 && opP->reg != CAAR
1464                                                 && opP->reg != MSP
1465                                                 && opP->reg != ISP) /* 680[23]0's have only these */
1466                                             || (cpu_of_arch(current_architecture) == m68040 /* 68040 has all but this */
1467                                                 && opP->reg == CAAR)) {
1468                                                 losing++;
1469                                         } /* doesn't cut it */
1470                                         break;
1471
1472                                 case 'k':
1473                                         if (opP->mode != IMMED)
1474                                             losing++;
1475                                         break;
1476
1477                                 case 'l':
1478                                 case 'L':
1479                                         if (opP->mode == DREG || opP->mode == AREG || opP->mode == FPREG) {
1480                                                 if (s[1] == '8')
1481                                                     losing++;
1482                                                 else {
1483                                                         opP->mode=REGLST;
1484                                                         opP->reg=1<<(opP->reg-DATA);
1485                                                 }
1486                                         } else if (opP->mode != REGLST) {
1487                                                 losing++;
1488                                         } else if (s[1] == '8' && opP->reg&0x0FFffFF)
1489                                             losing++;
1490                                         else if (s[1] == '3' && opP->reg&0x7000000)
1491                                             losing++;
1492                                         break;
1493
1494                                 case 'M':
1495                                         if (opP->mode != IMMED)
1496                                             losing++;
1497                                         else {
1498                                                 long t;
1499
1500                                                 t=get_num(opP->con1,80);
1501                                                 if (!issbyte(t) || isvar(opP->con1))
1502                                                     losing++;
1503                                         }
1504                                         break;
1505
1506                                 case 'O':
1507                                         if (opP->mode != DREG && opP->mode != IMMED)
1508                                             losing++;
1509                                         break;
1510
1511                                 case 'Q':
1512                                         if (opP->mode != IMMED)
1513                                             losing++;
1514                                         else {
1515                                                 long t;
1516
1517                                                 t=get_num(opP->con1,80);
1518                                                 if (t<1 || t>8 || isvar(opP->con1))
1519                                                     losing++;
1520                                         }
1521                                         break;
1522
1523                                 case 'R':
1524                                         if (opP->mode != DREG && opP->mode != AREG)
1525                                             losing++;
1526                                         break;
1527
1528                                 case 's':
1529                                         if (opP->mode != MSCR || !(opP->reg == FPI || opP->reg == FPS || opP->reg == FPC))
1530                                             losing++;
1531                                         break;
1532
1533                                 case 'S':
1534                                         if (opP->mode != MSCR || opP->reg != SR)
1535                                             losing++;
1536                                         break;
1537
1538                                 case 'U':
1539                                         if (opP->mode != MSCR || opP->reg != USP)
1540                                             losing++;
1541                                         break;
1542
1543                                         /* JF these are out of order.  We could put them
1544                                            in order if we were willing to put up with
1545                                            bunches of #ifdef m68851s in the code */
1546 #ifndef NO_68851
1547                                         /* Memory addressing mode used by pflushr */
1548                                 case '|':
1549                                         if (opP->mode == MSCR || opP->mode == DREG ||
1550                                            opP->mode == AREG || opP->mode == REGLST)
1551                                             losing++;
1552                                         break;
1553
1554                                 case 'f':
1555                                         if (opP->mode != MSCR || (opP->reg != SFC && opP->reg != DFC))
1556                                             losing++;
1557                                         break;
1558
1559                                 case 'P':
1560                                         if (opP->mode != MSCR || (opP->reg != TC && opP->reg != CAL &&
1561                                                                   opP->reg != VAL && opP->reg != SCC && opP->reg != AC))
1562                                             losing++;
1563                                         break;
1564
1565                                 case 'V':
1566                                         if (opP->reg != VAL)
1567                                             losing++;
1568                                         break;
1569
1570                                 case 'W':
1571                                         if (opP->mode != MSCR || (opP->reg != DRP && opP->reg != SRP &&
1572                                                                   opP->reg != CRP))
1573                                             losing++;
1574                                         break;
1575
1576                                 case 'X':
1577                                         if (opP->mode != MSCR ||
1578                                             (!(opP->reg >= BAD && opP->reg <= BAD+7) &&
1579                                              !(opP->reg >= BAC && opP->reg <= BAC+7)))
1580                                             losing++;
1581                                         break;
1582
1583                                 case 'Y':
1584                                         if (opP->reg != PSR)
1585                                             losing++;
1586                                         break;
1587
1588                                 case 'Z':
1589                                         if (opP->reg != PCSR)
1590                                             losing++;
1591                                         break;
1592 #endif
1593                                 case 'c':
1594                                         if (opP->reg != NC
1595                                             && opP->reg != IC
1596                                             && opP->reg != DC
1597                                             && opP->reg != BC) {
1598                                                 losing++;
1599                                         } /* not a cache specifier. */
1600                                         break;
1601
1602                                 case '_':
1603                                         if (opP->mode != ABSL) {
1604                                                 ++losing;
1605                                         } /* not absolute */
1606                                         break;
1607
1608                                 default:
1609                                         as_fatal("Internal error:  Operand mode %c unknown in line %s of file \"%s\"",
1610                                                  *s, __LINE__, __FILE__);
1611                                 } /* switch on type of operand */
1612
1613                                 if (losing) break;
1614                         } /* for each operand */
1615                 } /* if immediately wrong */
1616
1617                 if (!losing) {
1618                         break;
1619                 } /* got it. */
1620
1621                 opcode = opcode->m_next;
1622
1623                 if (!opcode) {
1624                         the_ins.error = "instruction/operands mismatch";
1625                         return;
1626                 } /* Fell off the end */
1627
1628                 losing = 0;
1629         }
1630
1631         /* now assemble it */
1632
1633         the_ins.args=opcode->m_operands;
1634         the_ins.numargs=opcode->m_opnum;
1635         the_ins.numo=opcode->m_codenum;
1636         the_ins.opcode[0]=getone(opcode);
1637         the_ins.opcode[1]=gettwo(opcode);
1638
1639         for (s = the_ins.args, opP = &the_ins.operands[0]; *s; s += 2, opP++) {
1640                 /* This switch is a doozy.
1641                    Watch the first step; its a big one! */
1642                 switch (s[0]) {
1643
1644 #ifdef  PIC
1645                 case ' ':
1646                         /* this operand is just here to indicate a jump-table branch */
1647                         break;
1648 #endif  /* PIC */
1649
1650                 case '*':
1651                 case '~':
1652                 case '%':
1653                 case ';':
1654                 case '@':
1655                 case '!':
1656                 case '&':
1657                 case '$':
1658                 case '?':
1659                 case '/':
1660 #ifndef NO_68851
1661                 case '|':
1662 #endif
1663
1664 #ifdef  PIC
1665                         /* Use GLOB_DAT for operand references in PIC mode */
1666                         if (picmode)
1667                             reloc_type = RELOC_GLOB_DAT;
1668                         else
1669 #endif  /* PIC */
1670                         reloc_type = NO_RELOC;
1671
1672                         switch (opP->mode) {
1673                                 int literal;
1674
1675                         case IMMED:
1676                                 tmpreg=0x3c;    /* 7.4 */
1677                                 if (*opP->con1->e_beg == ':') {
1678                                         ++opP->con1->e_beg;
1679                                         literal = 1;
1680                                 } else
1681                                         literal = 0;
1682                                 if (strchr("bwl",s[1])) nextword=get_num(opP->con1,80);
1683                                 else nextword=nextword=get_num(opP->con1,0);
1684                                 if (isvar(opP->con1)) {
1685 #ifdef  PIC
1686                                     /* KLUDGE!!!  In PIC assembly, an immediate reference to
1687                                        __GLOBAL_OFFSET_TABLE_ is turned into a pc-relative
1688                                        reference to __GLOBAL_OFFSET_TABLE_ - 6,
1689                                        for the sake of Sun compatibility. */
1690                                     if (s[1] == 'l' && picmode && gots(opP->con1)) {
1691                                         offs(opP->con1) -= 6;
1692                                         add_fix(s[1], opP->con1, 1, NO_RELOC);
1693                                     } else
1694 #endif  /* PIC */
1695                                         add_fix(s[1],opP->con1,0,reloc_type);
1696                                 }
1697                                 switch (s[1]) {
1698                                 case 'b':
1699                                         if (!isbyte(nextword))
1700                                             opP->error="operand out of range";
1701                                         addword(nextword);
1702                                         baseo=0;
1703                                         break;
1704                                 case 'w':
1705                                         if (!isword(nextword))
1706                                             opP->error="operand out of range";
1707                                         addword(nextword);
1708                                         baseo=0;
1709                                         break;
1710                                 case 'l':
1711                                         addword(nextword>>16);
1712                                         addword(nextword);
1713                                         baseo=0;
1714                                         break;
1715
1716                                 case 'f':
1717                                         baseo=2;
1718                                         outro=8;
1719                                         break;
1720                                 case 'F':
1721                                         baseo=4;
1722                                         outro=11;
1723                                         break;
1724                                 case 'x':
1725                                         baseo=6;
1726                                         outro=15;
1727                                         break;
1728                                 case 'p':
1729                                         baseo=6;
1730                                         outro= -1;
1731                                         break;
1732                                 default:
1733                                         as_fatal("Internal error:  Can't decode %c%c in line %s of file \"%s\"",
1734                                                  *s, s[1], __LINE__, __FILE__);
1735                                 }
1736                                 if (!baseo)
1737                                     break;
1738
1739                                 if (literal) {
1740                                         if (seg(opP->con1) == SEG_BIG)
1741                                                 goto bignum;
1742                                         while (baseo -= 2) {
1743                                                 addword(0);
1744                                                 addword(0);
1745                                         }
1746                                         addword(nextword>>16);
1747                                         addword(nextword);
1748                                         break;
1749                                 }
1750
1751                                 /* We gotta put out some float */
1752                                 if (seg(opP->con1) != SEG_BIG) {
1753                                         int_to_gen(nextword);
1754                                         gen_to_words(words,baseo,(long int)outro);
1755                                         for (wordp=words;baseo--;wordp++)
1756                                             addword(*wordp);
1757                                         break;
1758                                 }               /* Its BIG */
1759                                 if (offs(opP->con1)>0) {
1760                                         as_warn("Bignum assumed to be binary bit-pattern");
1761                                 bignum:
1762                                         if (offs(opP->con1)>baseo) {
1763                                                 as_warn("Bignum too big for %c format; truncated",s[1]);
1764                                                 offs(opP->con1)=baseo;
1765                                         }
1766                                         baseo-=offs(opP->con1);
1767                                         for (wordp=generic_bignum+offs(opP->con1)-1;offs(opP->con1)--;--wordp)
1768                                             addword(*wordp);
1769                                         while (baseo--)
1770                                             addword(0);
1771                                         break;
1772                                 }
1773                                 gen_to_words(words,baseo,(long)outro);
1774                                 for (wordp=words;baseo--;wordp++)
1775                                     addword(*wordp);
1776                                 break;
1777                         case DREG:
1778                                 tmpreg=opP->reg-DATA; /* 0.dreg */
1779                                 break;
1780                         case AREG:
1781                                 tmpreg=0x08+opP->reg-ADDR; /* 1.areg */
1782                                 break;
1783                         case AINDR:
1784                                 tmpreg=0x10+opP->reg-ADDR; /* 2.areg */
1785                                 break;
1786                         case ADEC:
1787                                 tmpreg=0x20+opP->reg-ADDR; /* 4.areg */
1788                                 break;
1789                         case AINC:
1790                                 tmpreg=0x18+opP->reg-ADDR; /* 3.areg */
1791                                 break;
1792                         case AOFF:
1793
1794                                 nextword=get_num(opP->con1,80);
1795                                 /* Force into index mode.  Hope this works */
1796
1797                                 /* We do the first bit for 32-bit displacements,
1798                                    and the second bit for 16 bit ones.  It is
1799                                    possible that we should make the default be
1800                                    WORD instead of LONG, but I think that'd
1801                                    break GCC, so we put up with a little
1802                                    inefficiency for the sake of working output.
1803                                    */
1804
1805                                 if (   !issword(nextword)
1806                                    || (   isvar(opP->con1)
1807                                        && ((opP->con1->e_siz == 0
1808                                             && flagseen['l'] == 0)
1809                                            || opP->con1->e_siz == 3))) {
1810
1811                                         if (opP->reg == PC)
1812                                             tmpreg=0x3B;        /* 7.3 */
1813                                         else
1814                                             tmpreg=0x30+opP->reg-ADDR;  /* 6.areg */
1815                                         if (isvar(opP->con1)) {
1816                                                 if (opP->reg == PC && !subs(opP->con1)) {
1817                                                         add_frag(adds(opP->con1),
1818                                                                  offs(opP->con1),
1819                                                                  TAB(PCLEA,SZ_UNDEF));
1820                                                         break;
1821                                                 } else {
1822                                                         addword(0x0170);
1823                                                         add_fix('l',opP->con1,0,reloc_type);
1824                                                 }
1825                                         } else
1826                                             addword(0x0170);
1827                                         addword(nextword>>16);
1828                                 } else {
1829                                         if (opP->reg == PC)
1830                                             tmpreg=0x3A; /* 7.2 */
1831                                         else
1832                                             tmpreg=0x28+opP->reg-ADDR; /* 5.areg */
1833
1834                                         if (isvar(opP->con1)) {
1835                                                 if (opP->reg == PC) {
1836                                                         add_fix('w',opP->con1,1,NO_RELOC);
1837                                                 } else
1838                                                     add_fix('w',opP->con1,0,reloc_type);
1839                                         }
1840                                 }
1841                                 addword(nextword);
1842                                 break;
1843
1844                         case APODX:
1845                         case AMIND:
1846                         case APRDX:
1847                                 know(current_architecture & m68020up);
1848                                 /* intentional fall-through */
1849                         case AINDX:
1850                                 nextword=0;
1851                                 baseo=get_num(opP->con1,80);
1852                                 outro=get_num(opP->con2,80);
1853                                 /* Figure out the 'addressing mode' */
1854                                 /* Also turn on the BASE_DISABLE bit, if needed */
1855                                 if (opP->reg == PC || opP->reg == ZPC) {
1856                                         tmpreg=0x3b; /* 7.3 */
1857                                         if (opP->reg == ZPC)
1858                                             nextword|=0x80;
1859                                 } else if (opP->reg == FAIL) {
1860                                         nextword|=0x80;
1861                                         tmpreg=0x30;    /* 6.garbage */
1862                                 } else tmpreg=0x30+opP->reg-ADDR; /* 6.areg */
1863
1864                                 siz1= (opP->con1) ? opP->con1->e_siz : 0;
1865                                 siz2= (opP->con2) ? opP->con2->e_siz : 0;
1866
1867                                 /* Index register stuff */
1868                                 if (opP->ireg >= DATA+0 && opP->ireg <= ADDR+7) {
1869                                         nextword|=(opP->ireg-DATA)<<12;
1870
1871                                         if (opP->isiz == 0 || opP->isiz == 3)
1872                                             nextword|=0x800;
1873                                         switch (opP->imul) {
1874                                         case 1: break;
1875                                         case 2: nextword|=0x200; break;
1876                                         case 4: nextword|=0x400; break;
1877                                         case 8: nextword|=0x600; break;
1878                                         default: as_fatal("failed sanity check.");
1879                                         }
1880                                         /* IF its simple,
1881                                            GET US OUT OF HERE! */
1882
1883                                         /* Must be INDEX, with an index
1884                                            register.  Address register
1885                                            cannot be ZERO-PC, and either
1886                                            :b was forced, or we know
1887                                            it will fit */
1888                                         if (opP->mode == AINDX
1889                                             && opP->reg != FAIL
1890                                             && opP->reg != ZPC
1891                                             && (siz1 == 1
1892                                                || (   issbyte(baseo)
1893                                                    && !isvar(opP->con1)))) {
1894                                                 nextword +=baseo&0xff;
1895                                                 addword(nextword);
1896                                                 if (isvar(opP->con1))
1897                                                     add_fix('B',opP->con1,0,reloc_type);
1898                                                 break;
1899                                         }
1900                                 } else
1901                                     nextword|=0x40;     /* No index reg */
1902
1903                                 /* It aint simple */
1904                                 nextword|=0x100;
1905                                 /* If the guy specified a width, we assume that
1906                                    it is wide enough.  Maybe it isn't.  If so, we lose
1907                                    */
1908                                 switch (siz1) {
1909                                 case 0:
1910                                         if (isvar(opP->con1) || !issword(baseo)) {
1911                                                 siz1=3;
1912                                                 nextword|=0x30;
1913                                         } else if (baseo == 0)
1914                                             nextword|=0x10;
1915                                         else {
1916                                                 nextword|=0x20;
1917                                                 siz1=2;
1918                                         }
1919                                         break;
1920                                 case 1:
1921                                         as_warn("Byte dispacement won't work.  Defaulting to :w");
1922                                 case 2:
1923                                         nextword|=0x20;
1924                                         break;
1925                                 case 3:
1926                                         nextword|=0x30;
1927                                         break;
1928                                 }
1929
1930                                 /* Figure out innner displacement stuff */
1931                                 if (opP->mode != AINDX) {
1932                                         switch (siz2) {
1933                                         case 0:
1934                                                 if (isvar(opP->con2) || !issword(outro)) {
1935                                                         siz2=3;
1936                                                         nextword|=0x3;
1937                                                 } else if (outro == 0)
1938                                                     nextword|=0x1;
1939                                                 else {
1940                                                         nextword|=0x2;
1941                                                         siz2=2;
1942                                                 }
1943                                                 break;
1944                                         case 1:
1945                                                 as_warn("Byte dispacement won't work.  Defaulting to :w");
1946                                         case 2:
1947                                                 nextword|=0x2;
1948                                                 break;
1949                                         case 3:
1950                                                 nextword|=0x3;
1951                                                 break;
1952                                         }
1953                                         if (opP->mode == APODX) nextword|=0x04;
1954                                         else if (opP->mode == AMIND) nextword|=0x40;
1955                                 }
1956                                 addword(nextword);
1957
1958                                 if (isvar(opP->con1)) {
1959                                         if (opP->reg == PC || opP->reg == ZPC) {
1960                                                 add_fix(siz1 == 3 ? 'l' : 'w',opP->con1,1,NO_RELOC);
1961                                                 opP->con1->e_exp.X_add_number+=6;
1962                                         } else
1963                                             add_fix(siz1 == 3 ? 'l' : 'w',opP->con1,0,reloc_type);
1964                                 }
1965                                 if (siz1 == 3)
1966                                     addword(baseo>>16);
1967                                 if (siz1)
1968                                     addword(baseo);
1969
1970                                 if (isvar(opP->con2)) {
1971                                         if (opP->reg == PC || opP->reg == ZPC) {
1972                                                 add_fix(siz2 == 3 ? 'l' : 'w',opP->con2,1,NO_RELOC);
1973                                                 opP->con1->e_exp.X_add_number+=6;
1974                                         } else
1975                                             add_fix(siz2 == 3 ? 'l' : 'w',opP->con2,0,reloc_type);
1976                                 }
1977                                 if (siz2 == 3)
1978                                     addword(outro>>16);
1979                                 if (siz2)
1980                                     addword(outro);
1981
1982                                 break;
1983
1984                         case ABSL:
1985                                 nextword=get_num(opP->con1,80);
1986                                 switch (opP->con1->e_siz) {
1987                                 default:
1988                                         as_warn("Unknown size for absolute reference");
1989                                 case 0:
1990                                         if (!isvar(opP->con1) && issword(offs(opP->con1))) {
1991                                                 tmpreg=0x38; /* 7.0 */
1992                                                 addword(nextword);
1993                                                 break;
1994                                         }
1995                                         /* Don't generate pc relative code
1996                                            on 68010 and 68000 */
1997                                         if (isvar(opP->con1)
1998                                            && !subs(opP->con1)
1999                                            && seg(opP->con1) == SEG_TEXT
2000                                            && now_seg == SEG_TEXT
2001                                            && cpu_of_arch(current_architecture) >= m68020
2002                                            && !flagseen['S']
2003                                            && !strchr("~%&$?", s[0])) {
2004                                                 tmpreg=0x3A; /* 7.2 */
2005                                                 add_frag(adds(opP->con1),
2006                                                          offs(opP->con1),
2007                                                          TAB(PCREL,SZ_UNDEF));
2008                                                 break;
2009                                         }
2010                                 case 3:         /* Fall through into long */
2011                                         if (isvar(opP->con1))
2012                                             add_fix('l',opP->con1,0,NO_RELOC);
2013
2014                                         tmpreg=0x39;    /* 7.1 mode */
2015                                         addword(nextword>>16);
2016                                         addword(nextword);
2017                                         break;
2018
2019                                 case 2:         /* Word */
2020                                         if (isvar(opP->con1))
2021                                             add_fix('w',opP->con1,0,NO_RELOC);
2022
2023                                         tmpreg=0x38;    /* 7.0 mode */
2024                                         addword(nextword);
2025                                         break;
2026                                 }
2027                                 break;
2028                         case MSCR:
2029                         default:
2030                                 as_bad("unknown/incorrect operand");
2031                                 /* abort(); */
2032                         }
2033                         install_gen_operand(s[1],tmpreg);
2034                         break;
2035
2036                 case '#':
2037                 case '^':
2038                         switch (s[1]) { /* JF: I hate floating point! */
2039                         case 'j':
2040                                 tmpreg=70;
2041                                 break;
2042                         case '8':
2043                                 tmpreg=20;
2044                                 break;
2045                         case 'C':
2046                                 tmpreg=50;
2047                                 break;
2048                         case '3':
2049                         default:
2050                                 tmpreg=80;
2051                                 break;
2052                         }
2053                         tmpreg=get_num(opP->con1,tmpreg);
2054                         if (isvar(opP->con1))
2055                             add_fix(s[1],opP->con1,0,NO_RELOC);
2056                         switch (s[1]) {
2057                         case 'b':       /* Danger:  These do no check for
2058                                            certain types of overflow.
2059                                            user beware! */
2060                                 if (!isbyte(tmpreg))
2061                                     opP->error="out of range";
2062                                 insop(tmpreg);
2063                                 if (isvar(opP->con1))
2064                                     the_ins.reloc[the_ins.nrel-1].n=(opcode->m_codenum)*2;
2065                                 break;
2066                         case 'w':
2067                                 if (!isword(tmpreg))
2068                                     opP->error="out of range";
2069                                 insop(tmpreg);
2070                                 if (isvar(opP->con1))
2071                                     the_ins.reloc[the_ins.nrel-1].n=(opcode->m_codenum)*2;
2072                                 break;
2073                         case 'l':
2074                                 insop(tmpreg);          /* Because of the way insop works, we put these two out backwards */
2075                                 insop(tmpreg>>16);
2076                                 if (isvar(opP->con1))
2077                                     the_ins.reloc[the_ins.nrel-1].n=(opcode->m_codenum)*2;
2078                                 break;
2079                         case '3':
2080                                 tmpreg&=0xFF;
2081                         case '8':
2082                         case 'C':
2083                                 install_operand(s[1],tmpreg);
2084                                 break;
2085                         default:
2086                                 as_fatal("Internal error:  Unknown mode #%c in line %s of file \"%s\"", s[1], __LINE__, __FILE__);
2087                         }
2088                         break;
2089
2090                 case '+':
2091                 case '-':
2092                 case 'A':
2093                 case 'a':
2094                         install_operand(s[1], opP->reg - ADDR);
2095                         break;
2096
2097                 case 'B':
2098                         tmpreg = get_num(opP->con1, 80);
2099                         switch (s[1]) {
2100                         case 'B':
2101                                 /* Offset is relative to next word */
2102                                 opP->con1->e_exp.X_add_number -= 1;
2103                                 add_fix('B', opP->con1, 1,NO_RELOC);
2104                                 break;
2105                         case 'W':
2106                                 add_fix('w', opP->con1, 1,NO_RELOC);
2107                                 addword(0);
2108                                 break;
2109                         case 'L':
2110                         long_branch:
2111                                 if (cpu_of_arch(current_architecture) < m68020)         /* 68000 or 010 */
2112                                     as_warn("Can't use long branches on 68000/68010");
2113                                 the_ins.opcode[the_ins.numo-1]|=0xff;
2114                                 add_fix('l',opP->con1,1,NO_RELOC);
2115                                 addword(0);
2116                                 addword(0);
2117                                 break;
2118                         case 'g':
2119 #ifdef  PIC
2120                                 /* If we have the optional kludgey 2nd operand,
2121                                    make this go via the jump table. */
2122                                 if (picmode && s[2] == ' ') {
2123                                     the_ins.opcode[the_ins.numo-1] |= 0xFF;
2124                                     add_fix('l', opP->con1, 1, RELOC_JMP_TBL);
2125                                     addword(0);
2126                                     addword(0);
2127                                     break;
2128                                 }
2129 #endif  /* PIC */
2130                                 if (subs(opP->con1))     /* We can't relax it */
2131                                     goto long_branch;
2132
2133                                 /* This could either be a symbol, or an
2134                                    absolute address.  No matter, the
2135                                    frag hacking will finger it out.
2136                                    Not quite: it can't switch from
2137                                    BRANCH to BCC68000 for the case
2138                                    where opnd is absolute (it needs
2139                                    to use the 68000 hack since no
2140                                    conditional abs jumps).  */
2141                                 if (((cpu_of_arch(current_architecture) < m68020) || (0 == adds(opP->con1)))
2142                                     && (the_ins.opcode[0] >= 0x6200)
2143                                     && (the_ins.opcode[0] <= 0x6f00)) {
2144                                         add_frag(adds(opP->con1),offs(opP->con1),TAB(BCC68000,SZ_UNDEF));
2145                                 } else {
2146                                         add_frag(adds(opP->con1),offs(opP->con1),TAB(BRANCH,SZ_UNDEF));
2147                                 }
2148                                 break;
2149                         case 'w':
2150                                 if (isvar(opP->con1)) {
2151                                         /* check for DBcc instruction */
2152                                         if ((the_ins.opcode[0] & 0xf0f8) == 0x50c8) {
2153                                                 /* size varies if patch */
2154                                                 /* needed for long form */
2155                                                 add_frag(adds(opP->con1),offs(opP->con1),TAB(DBCC,SZ_UNDEF));
2156                                                 break;
2157                                         }
2158
2159                                         /* Don't ask! */
2160                                         opP->con1->e_exp.X_add_number+=2;
2161                                         add_fix('w',opP->con1,1,NO_RELOC);
2162                                 }
2163                                 addword(0);
2164                                 break;
2165                         case 'C':               /* Fixed size LONG coproc branches */
2166                                 the_ins.opcode[the_ins.numo-1]|=0x40;
2167                                 /* Offset the displacement to be relative to byte disp location */
2168                                 /* Coproc branches don't have a byte disp option, but they are
2169                                    compatible with the ordinary branches, which do... */
2170                                 opP->con1->e_exp.X_add_number+=4;
2171                                 add_fix('l',opP->con1,1,NO_RELOC);
2172                                 addword(0);
2173                                 addword(0);
2174                                 break;
2175                         case 'c':               /* Var size Coprocesssor branches */
2176                                 if (subs(opP->con1)) {
2177                                         add_fix('l',opP->con1,1,NO_RELOC);
2178                                         add_frag((symbolS *)0,(long)0,TAB(FBRANCH,LONG));
2179                                 } else if (adds(opP->con1)) {
2180                                         add_frag(adds(opP->con1),offs(opP->con1),TAB(FBRANCH,SZ_UNDEF));
2181                                 } else {
2182                                         /* add_frag((symbolS *)0,offs(opP->con1),TAB(FBRANCH,SHORT)); */
2183                                         the_ins.opcode[the_ins.numo-1]|=0x40;
2184                                         add_fix('l',opP->con1,1,NO_RELOC);
2185                                         addword(0);
2186                                         addword(4);
2187                                 }
2188                                 break;
2189                         default:
2190                                 as_fatal("Internal error:  operand type B%c unknown in line %s of file \"%s\"",
2191                                          s[1], __LINE__, __FILE__);
2192                         }
2193                         break;
2194
2195                 case 'C':               /* Ignore it */
2196                         break;
2197
2198                 case 'd':               /* JF this is a kludge */
2199                         if (opP->mode == AOFF) {
2200                                 install_operand('s',opP->reg-ADDR);
2201                         } else {
2202                                 char *tmpP;
2203
2204                                 tmpP=opP->con1->e_end-2;
2205                                 opP->con1->e_beg++;
2206                                 opP->con1->e_end-=4;    /* point to the , */
2207                                 baseo=m68k_reg_parse(&tmpP);
2208                                 if (baseo<ADDR+0 || baseo>ADDR+7) {
2209                                         as_bad("Unknown address reg, using A0");
2210                                         baseo=0;
2211                                 } else baseo-=ADDR;
2212                                 install_operand('s',baseo);
2213                         }
2214                         tmpreg=get_num(opP->con1,80);
2215                         if (!issword(tmpreg)) {
2216                                 as_warn("Expression out of range, using 0");
2217                                 tmpreg=0;
2218                         }
2219                         addword(tmpreg);
2220                         break;
2221
2222                 case 'D':
2223                         install_operand(s[1],opP->reg-DATA);
2224                         break;
2225
2226                 case 'F':
2227                         install_operand(s[1],opP->reg-FPREG);
2228                         break;
2229
2230                 case 'I':
2231                         tmpreg=1+opP->reg-COPNUM;
2232                         if (tmpreg == 8)
2233                             tmpreg=0;
2234                         install_operand(s[1],tmpreg);
2235                         break;
2236
2237                 case 'J':               /* JF foo */
2238                         switch (opP->reg) {
2239                         case SFC:   tmpreg=0x000; break;
2240                         case DFC:   tmpreg=0x001; break;
2241                         case CACR:  tmpreg=0x002; break;
2242                         case TC:    tmpreg=0x003; break;
2243                         case ITT0:  tmpreg=0x004; break;
2244                         case ITT1:  tmpreg=0x005; break;
2245                         case DTT0:  tmpreg=0x006; break;
2246                         case DTT1:  tmpreg=0x007; break;
2247
2248                         case USP:   tmpreg=0x800; break;
2249                         case VBR:   tmpreg=0x801; break;
2250                         case CAAR:  tmpreg=0x802; break;
2251                         case MSP:   tmpreg=0x803; break;
2252                         case ISP:   tmpreg=0x804; break;
2253                         case MMUSR: tmpreg=0x805; break;
2254                         case URP:   tmpreg=0x806; break;
2255                         case SRP:   tmpreg=0x807; break;
2256                         default:
2257                                 as_fatal("failed sanity check.");
2258                         }
2259                         install_operand(s[1],tmpreg);
2260                         break;
2261
2262                 case 'k':
2263                         tmpreg=get_num(opP->con1,55);
2264                         install_operand(s[1],tmpreg&0x7f);
2265                         break;
2266
2267                 case 'l':
2268                         tmpreg=opP->reg;
2269                         if (s[1] == 'w') {
2270                                 if (tmpreg&0x7FF0000)
2271                                     as_bad("Floating point register in register list");
2272                                 insop(reverse_16_bits(tmpreg));
2273                         } else {
2274                                 if (tmpreg&0x700FFFF)
2275                                     as_bad("Wrong register in floating-point reglist");
2276                                 install_operand(s[1],reverse_8_bits(tmpreg>>16));
2277                         }
2278                         break;
2279
2280                 case 'L':
2281                         tmpreg=opP->reg;
2282                         if (s[1] == 'w') {
2283                                 if (tmpreg&0x7FF0000)
2284                                     as_bad("Floating point register in register list");
2285                                 insop(tmpreg);
2286                         } else if (s[1] == '8') {
2287                                 if (tmpreg&0x0FFFFFF)
2288                                     as_bad("incorrect register in reglist");
2289                                 install_operand(s[1],tmpreg>>24);
2290                         } else {
2291                                 if (tmpreg&0x700FFFF)
2292                                     as_bad("wrong register in floating-point reglist");
2293                                 else
2294                                     install_operand(s[1],tmpreg>>16);
2295                         }
2296                         break;
2297
2298                 case 'M':
2299                         install_operand(s[1],get_num(opP->con1,60));
2300                         break;
2301
2302                 case 'O':
2303                         tmpreg= (opP->mode == DREG)
2304                             ? 0x20+opP->reg-DATA
2305                                 : (get_num(opP->con1,40)&0x1F);
2306                         install_operand(s[1],tmpreg);
2307                         break;
2308
2309                 case 'Q':
2310                         tmpreg=get_num(opP->con1,10);
2311                         if (tmpreg == 8)
2312                             tmpreg=0;
2313                         install_operand(s[1],tmpreg);
2314                         break;
2315
2316                 case 'R':
2317                         /* This depends on the fact that ADDR registers are
2318                            eight more than their corresponding DATA regs, so
2319                            the result will have the ADDR_REG bit set */
2320                         install_operand(s[1],opP->reg-DATA);
2321                         break;
2322
2323                 case 's':
2324                         if (opP->reg == FPI) tmpreg=0x1;
2325                         else if (opP->reg == FPS) tmpreg=0x2;
2326                         else if (opP->reg == FPC) tmpreg=0x4;
2327                         else as_fatal("failed sanity check.");
2328                         install_operand(s[1],tmpreg);
2329                         break;
2330
2331                 case 'S':       /* Ignore it */
2332                         break;
2333
2334                 case 'T':
2335                         install_operand(s[1],get_num(opP->con1,30));
2336                         break;
2337
2338                 case 'U':       /* Ignore it */
2339                         break;
2340
2341                 case 'c':
2342                         switch (opP->reg) {
2343                         case NC: tmpreg = 0; break;
2344                         case DC: tmpreg = 1; break;
2345                         case IC: tmpreg = 2; break;
2346                         case BC: tmpreg = 3; break;
2347                         default:
2348                                 as_fatal("failed sanity check");
2349                         } /* switch on cache token */
2350                         install_operand(s[1], tmpreg);
2351                         break;
2352 #ifndef NO_68851
2353                         /* JF: These are out of order, I fear. */
2354                 case 'f':
2355                         switch (opP->reg) {
2356                         case SFC:
2357                                 tmpreg=0;
2358                                 break;
2359                         case DFC:
2360                                 tmpreg=1;
2361                                 break;
2362                         default:
2363                                 as_fatal("failed sanity check.");
2364                         }
2365                         install_operand(s[1],tmpreg);
2366                         break;
2367
2368                 case 'P':
2369                         switch (opP->reg) {
2370                         case TC:
2371                                 tmpreg=0;
2372                                 break;
2373                         case CAL:
2374                                 tmpreg=4;
2375                                 break;
2376                         case VAL:
2377                                 tmpreg=5;
2378                                 break;
2379                         case SCC:
2380                                 tmpreg=6;
2381                                 break;
2382                         case AC:
2383                                 tmpreg=7;
2384                                 break;
2385                         default:
2386                                 as_fatal("failed sanity check.");
2387                         }
2388                         install_operand(s[1],tmpreg);
2389                         break;
2390
2391                 case 'V':
2392                         if (opP->reg == VAL)
2393                             break;
2394                         as_fatal("failed sanity check.");
2395
2396                 case 'W':
2397                         switch (opP->reg) {
2398
2399                         case DRP:
2400                                 tmpreg=1;
2401                                 break;
2402                         case SRP:
2403                                 tmpreg=2;
2404                                 break;
2405                         case CRP:
2406                                 tmpreg=3;
2407                                 break;
2408                         default:
2409                                 as_fatal("failed sanity check.");
2410                         }
2411                         install_operand(s[1],tmpreg);
2412                         break;
2413
2414                 case 'X':
2415                         switch (opP->reg) {
2416                         case BAD: case BAD+1: case BAD+2: case BAD+3:
2417                         case BAD+4: case BAD+5: case BAD+6: case BAD+7:
2418                                 tmpreg = (4 << 10) | ((opP->reg - BAD) << 2);
2419                                 break;
2420
2421                         case BAC: case BAC+1: case BAC+2: case BAC+3:
2422                         case BAC+4: case BAC+5: case BAC+6: case BAC+7:
2423                                 tmpreg = (5 << 10) | ((opP->reg - BAC) << 2);
2424                                 break;
2425
2426                         default:
2427                                 as_fatal("failed sanity check.");
2428                         }
2429                         install_operand(s[1], tmpreg);
2430                         break;
2431                 case 'Y':
2432                         know(opP->reg == PSR);
2433                         break;
2434                 case 'Z':
2435                         know(opP->reg == PCSR);
2436                         break;
2437 #endif /* m68851 */
2438                 case '_':
2439                         tmpreg=get_num(opP->con1,80);
2440                         install_operand(s[1], tmpreg);
2441                         break;
2442                 default:
2443                         as_fatal("Internal error:  Operand type %c unknown in line %s of file \"%s\"", s[0], __LINE__, __FILE__);
2444                 }
2445         }
2446         /* By the time whe get here (FINALLY) the_ins contains the complete
2447            instruction, ready to be emitted... */
2448 } /* m68k_ip() */
2449
2450 /*
2451  * get_regs := '/' + ?
2452  *      | '-' + <register>
2453  *      | '-' + <register> + ?
2454  *      | <empty>
2455  *      ;
2456  *
2457
2458  * The idea here must be to scan in a set of registers but I don't
2459  * understand it.  Looks awfully sloppy to me but I don't have any doc on
2460  * this format so...
2461
2462  *
2463  *
2464  */
2465
2466 static int get_regs(i,str,opP)
2467 int i;
2468 struct m68k_op *opP;
2469 char *str;
2470 {
2471         /*                           26, 25, 24, 23-16,  15-8, 0-7 */
2472         /* Low order 24 bits encoded fpc,fps,fpi,fp7-fp0,a7-a0,d7-d0 */
2473         unsigned long cur_regs = 0;
2474         int     reg1,
2475         reg2;
2476
2477 #define ADD_REG(x)      {     if (x == FPI) cur_regs|=(1<<24);\
2478 else if (x == FPS) cur_regs|=(1<<25);\
2479 else if (x == FPC) cur_regs|=(1<<26);\
2480 else cur_regs|=(1<<(x-1));  }
2481
2482         reg1=i;
2483         for (;;) {
2484                 if (*str == '/') {
2485                         ADD_REG(reg1);
2486                         str++;
2487                 } else if (*str == '-') {
2488                         str++;
2489                         reg2=m68k_reg_parse(&str);
2490                         if (reg2<DATA || reg2 >= FPREG+8 || reg1 == FPI || reg1 == FPS || reg1 == FPC) {
2491                                 opP->error="unknown register in register list";
2492                                 return FAIL;
2493                         }
2494                         while (reg1 <= reg2) {
2495                                 ADD_REG(reg1);
2496                                 reg1++;
2497                         }
2498                         if (*str == '\0')
2499                             break;
2500                 } else if (*str == '\0') {
2501                         ADD_REG(reg1);
2502                         break;
2503                 } else {
2504                         opP->error="unknow character in register list";
2505                         return FAIL;
2506                 }
2507                 /* DJA -- Bug Fix.  Did't handle d1-d2/a1 until the following instruction was added */
2508                 if (*str == '/')
2509                     str ++;
2510                 reg1=m68k_reg_parse(&str);
2511                 if ((reg1<DATA || reg1 >= FPREG+8) && !(reg1 == FPI || reg1 == FPS || reg1 == FPC)) {
2512                         opP->error="unknown register in register list";
2513                         return FAIL;
2514                 }
2515         }
2516         opP->reg=cur_regs;
2517         return OK;
2518 } /* get_regs() */
2519
2520 static int reverse_16_bits(in)
2521 int in;
2522 {
2523         int out=0;
2524         int n;
2525
2526         static int mask[16] = {
2527                 0x0001,0x0002,0x0004,0x0008,0x0010,0x0020,0x0040,0x0080,
2528                 0x0100,0x0200,0x0400,0x0800,0x1000,0x2000,0x4000,0x8000
2529             };
2530         for (n=0;n<16;n++) {
2531                 if (in&mask[n])
2532                     out|=mask[15-n];
2533         }
2534         return out;
2535 } /* reverse_16_bits() */
2536
2537 static int reverse_8_bits(in)
2538 int in;
2539 {
2540         int out=0;
2541         int n;
2542
2543         static int mask[8] = {
2544                 0x0001,0x0002,0x0004,0x0008,0x0010,0x0020,0x0040,0x0080,
2545         };
2546
2547         for (n=0;n<8;n++) {
2548                 if (in&mask[n])
2549                     out|=mask[7-n];
2550         }
2551         return out;
2552 } /* reverse_8_bits() */
2553
2554 static void install_operand(mode,val)
2555 int mode;
2556 int val;
2557 {
2558         switch (mode) {
2559         case 's':
2560                 the_ins.opcode[0]|=val & 0xFF;  /* JF FF is for M kludge */
2561                 break;
2562         case 'd':
2563                 the_ins.opcode[0]|=val<<9;
2564                 break;
2565         case '1':
2566                 the_ins.opcode[1]|=val<<12;
2567                 break;
2568         case '2':
2569                 the_ins.opcode[1]|=val<<6;
2570                 break;
2571         case '3':
2572                 the_ins.opcode[1]|=val;
2573                 break;
2574         case '4':
2575                 the_ins.opcode[2]|=val<<12;
2576                 break;
2577         case '5':
2578                 the_ins.opcode[2]|=val<<6;
2579                 break;
2580         case '6':
2581                 /* DANGER!  This is a hack to force cas2l and cas2w cmds
2582                    to be three words long! */
2583                 the_ins.numo++;
2584                 the_ins.opcode[2]|=val;
2585                 break;
2586         case '7':
2587                 the_ins.opcode[1]|=val<<7;
2588                 break;
2589         case '8':
2590                 the_ins.opcode[1]|=val<<10;
2591                 break;
2592 #ifndef NO_68851
2593         case '9':
2594                 the_ins.opcode[1]|=val<<5;
2595                 break;
2596 #endif
2597
2598         case 't':
2599                 the_ins.opcode[1]|=(val<<10)|(val<<7);
2600                 break;
2601         case 'D':
2602                 the_ins.opcode[1]|=(val<<12)|val;
2603                 break;
2604         case 'g':
2605                 the_ins.opcode[0]|=val=0xff;
2606                 break;
2607         case 'i':
2608                 the_ins.opcode[0]|=val<<9;
2609                 break;
2610         case 'C':
2611                 the_ins.opcode[1]|=val;
2612                 break;
2613         case 'j':
2614                 the_ins.opcode[1]|=val;
2615                 the_ins.numo++;         /* What a hack */
2616                 break;
2617         case 'k':
2618                 the_ins.opcode[1]|=val<<4;
2619                 break;
2620         case 'b':
2621         case 'w':
2622         case 'l':
2623                 break;
2624         case 'e':
2625                 the_ins.opcode[0] |= (val << 6);
2626                 break;
2627         case 'L':
2628                 the_ins.opcode[1] = (val >> 16);
2629                 the_ins.opcode[2] = val & 0xffff;
2630                 break;
2631         case 'c':
2632         default:
2633                 as_fatal("failed sanity check.");
2634         }
2635 } /* install_operand() */
2636
2637 static void install_gen_operand(mode,val)
2638 int mode;
2639 int val;
2640 {
2641         switch (mode) {
2642         case 's':
2643                 the_ins.opcode[0]|=val;
2644                 break;
2645         case 'd':
2646                 /* This is a kludge!!! */
2647                 the_ins.opcode[0]|=(val&0x07)<<9|(val&0x38)<<3;
2648                 break;
2649         case 'b':
2650         case 'w':
2651         case 'l':
2652         case 'f':
2653         case 'F':
2654         case 'x':
2655         case 'p':
2656                 the_ins.opcode[0]|=val;
2657                 break;
2658                 /* more stuff goes here */
2659         default:
2660                 as_fatal("failed sanity check.");
2661         }
2662 } /* install_gen_operand() */
2663
2664 /*
2665  * verify that we have some number of paren pairs, do m68k_ip_op(), and
2666  * then deal with the bitfield hack.
2667  */
2668
2669 static char *crack_operand(str,opP)
2670 register char *str;
2671 register struct m68k_op *opP;
2672 {
2673         register int parens;
2674         register int c;
2675         register char *beg_str;
2676
2677         if (!str) {
2678                 return str;
2679         }
2680         beg_str=str;
2681         for (parens=0;*str && (parens>0 || notend(str));str++) {
2682                 if (*str == '(') parens++;
2683                 else if (*str == ')') {
2684                         if (!parens) {          /* ERROR */
2685                                 opP->error="Extra )";
2686                                 return str;
2687                         }
2688                         --parens;
2689                 }
2690         }
2691         if (!*str && parens) {          /* ERROR */
2692                 opP->error="Missing )";
2693                 return str;
2694         }
2695         c= *str;
2696         *str='\0';
2697         if (m68k_ip_op(beg_str,opP) == FAIL) {
2698                 *str=c;
2699                 return str;
2700         }
2701         *str=c;
2702         if (c == '}')
2703             c= *++str;          /* JF bitfield hack */
2704         if (c) {
2705                 c= *++str;
2706                 if (!c)
2707                     as_bad("Missing operand");
2708         }
2709         return str;
2710 }
2711
2712 /* See the comment up above where the #define notend(... is */
2713 #if 0
2714 notend(s)
2715 char *s;
2716 {
2717         if (*s == ',') return 0;
2718         if (*s == '{' || *s == '}')
2719             return 0;
2720         if (*s != ':') return 1;
2721         /* This kludge here is for the division cmd, which is a kludge */
2722         if (index("aAdD#",s[1])) return 0;
2723         return 1;
2724 }
2725 #endif
2726
2727 /*
2728  * Generate a new fixup for one of the relocs in the_ins.
2729  */
2730 static void
2731     make_fix(m, where)
2732 int m;
2733 char *where;
2734 {
2735         int n;
2736
2737         switch (the_ins.reloc[m].wid) {
2738         case 'B':
2739         case 'b':
2740                 n=1;
2741                 break;
2742         case '3':
2743         case 'w':
2744                 n=2;
2745                 break;
2746         case 'l':
2747                 n=4;
2748                 break;
2749         default:
2750                 as_fatal("Don't know how to figure width of %c in md_assemble()",the_ins.reloc[m].wid);
2751         }
2752         fix_new(frag_now,
2753                 where - frag_now->fr_literal + the_ins.reloc[m].n,
2754                 n,
2755                 the_ins.reloc[m].add,
2756                 the_ins.reloc[m].sub,
2757                 the_ins.reloc[m].off,
2758                 the_ins.reloc[m].pcrel,
2759                 the_ins.reloc[m].rtype
2760 #ifdef  PIC
2761                 , the_ins.reloc[m].got
2762 #endif  /* PIC */
2763                 );
2764 #ifdef  PIC
2765         if (the_ins.reloc[m].rtype == RELOC_GLOB_DAT
2766             && the_ins.reloc[m].add != NULL)
2767                 the_ins.reloc[m].add->sy_forceout = 1;
2768 #endif  /* PIC */
2769 }
2770
2771 /* This is the guts of the machine-dependent assembler.  STR points to a
2772    machine dependent instruction.  This function is supposed to emit
2773    the frags/bytes it assembles to.
2774    */
2775 void
2776     md_assemble(str)
2777 char *str;
2778 {
2779         char *er;
2780         short   *fromP;
2781         char    *toP = NULL;
2782         int     m,n = 0;
2783         char    *to_beg_P;
2784         int     shorts_this_frag;
2785
2786
2787         if (current_architecture == 0) {
2788                 current_architecture = (m68020
2789 #ifndef NO_68881
2790                                         | m68881
2791 #endif
2792 #ifndef NO_68851
2793                                         | m68851
2794 #endif
2795                                         );
2796         } /* default current_architecture */
2797
2798         memset((char *)(&the_ins), '\0', sizeof(the_ins));      /* JF for paranoia sake */
2799         m68k_ip(str);
2800         er=the_ins.error;
2801         if (!er) {
2802                 for (n=the_ins.numargs;n;--n)
2803                     if (the_ins.operands[n].error) {
2804                             er=the_ins.operands[n].error;
2805                             break;
2806                     }
2807         }
2808         if (er) {
2809                 as_bad("\"%s\" -- Statement '%s' ignored",er,str);
2810                 return;
2811         }
2812
2813         if (the_ins.nfrag == 0) {       /* No frag hacking involved; just put it out */
2814                 toP=frag_more(2*the_ins.numo);
2815                 fromP= &the_ins.opcode[0];
2816                 for (m=the_ins.numo;m;--m) {
2817                         md_number_to_chars(toP,(long)(*fromP),2);
2818                         toP+=2;
2819                         fromP++;
2820                 }
2821                 /* put out symbol-dependent info */
2822                 for (m = 0; m < the_ins.nrel; m++) {
2823                         make_fix(m, toP-the_ins.numo*2);
2824                 }
2825                 return;
2826         }
2827
2828         /* There's some frag hacking */
2829         for (n=0,fromP= &the_ins.opcode[0];n<the_ins.nfrag;n++) {
2830                 int wid;
2831
2832                 if (n == 0) wid=2*the_ins.fragb[n].fragoff;
2833                 else wid=2*(the_ins.numo-the_ins.fragb[n-1].fragoff);
2834                 toP=frag_more(wid);
2835                 to_beg_P=toP;
2836                 shorts_this_frag=0;
2837                 for (m=wid/2;m;--m) {
2838                         md_number_to_chars(toP,(long)(*fromP),2);
2839                         toP+=2;
2840                         fromP++;
2841                         shorts_this_frag++;
2842                 }
2843                 for (m=0;m<the_ins.nrel;m++) {
2844                         if ((the_ins.reloc[m].n) >= 2*shorts_this_frag /* 2*the_ins.fragb[n].fragoff */) {
2845                                 the_ins.reloc[m].n-= 2*shorts_this_frag /* 2*the_ins.fragb[n].fragoff */;
2846                                 break;
2847                         }
2848                         if (the_ins.reloc[m].wid == 0)
2849                             continue;
2850                         make_fix(m, toP-the_ins.numo*2);
2851                         the_ins.reloc[m].wid=0;
2852                 }
2853                 /* know(the_ins.fragb[n].fadd); */
2854                 (void)frag_var(rs_machine_dependent,10,0,(relax_substateT)(the_ins.fragb[n].fragty),
2855                                the_ins.fragb[n].fadd,the_ins.fragb[n].foff,to_beg_P);
2856         }
2857         n=(the_ins.numo-the_ins.fragb[n-1].fragoff);
2858         shorts_this_frag=0;
2859         if (n) {
2860                 toP=frag_more(n*sizeof(short));
2861                 while (n--) {
2862                         md_number_to_chars(toP,(long)(*fromP),2);
2863                         toP+=2;
2864                         fromP++;
2865                         shorts_this_frag++;
2866                 }
2867         }
2868         for (m=0;m<the_ins.nrel;m++) {
2869                 if (the_ins.reloc[m].wid == 0)
2870                     continue;
2871                 make_fix(m, toP - /* the_ins.numo */ shorts_this_frag*2);
2872         }
2873 }
2874
2875 /* This function is called once, at assembler startup time.  This should
2876    set up all the tables, etc that the MD part of the assembler needs
2877    */
2878 void
2879     md_begin()
2880 {
2881         /*
2882          * md_begin -- set up hash tables with 68000 instructions.
2883          * similar to what the vax assembler does.  ---phr
2884          */
2885         /* RMS claims the thing to do is take the m68k-opcode.h table, and make
2886            a copy of it at runtime, adding in the information we want but isn't
2887            there.  I think it'd be better to have an awk script hack the table
2888            at compile time.  Or even just xstr the table and use it as-is.  But
2889            my lord ghod hath spoken, so we do it this way.  Excuse the ugly var
2890            names.  */
2891
2892         register const struct m68k_opcode *ins;
2893         register struct m68k_incant *hack,
2894         *slak;
2895         register char *retval = 0;              /* empty string, or error msg text */
2896         register unsigned int i;
2897         register char c;
2898
2899         if ((op_hash = hash_new()) == NULL)
2900             as_fatal("Virtual memory exhausted");
2901
2902         obstack_begin(&robyn,4000);
2903         for (ins = m68k_opcodes; ins < endop; ins++) {
2904                 hack=slak=(struct m68k_incant *)obstack_alloc(&robyn,sizeof(struct m68k_incant));
2905                 do {
2906                         /* we *could* ignore insns that don't match our
2907                            arch here but just leaving them out of the
2908                            hash. */
2909                         slak->m_operands=ins->args;
2910                         slak->m_opnum=strlen(slak->m_operands)/2;
2911                         slak->m_arch = ins->arch;
2912                         slak->m_opcode=ins->opcode;
2913                         /* This is kludgey */
2914                         slak->m_codenum=((ins->match)&0xffffL) ? 2 : 1;
2915                         if ((ins+1) != endop && !strcmp(ins->name,(ins+1)->name)) {
2916                                 slak->m_next=(struct m68k_incant *) obstack_alloc(&robyn,sizeof(struct m68k_incant));
2917                                 ins++;
2918                         } else
2919                             slak->m_next=0;
2920                         slak=slak->m_next;
2921                 } while (slak);
2922
2923                 retval = hash_insert (op_hash, ins->name,(char *)hack);
2924                 /* Didn't his mommy tell him about null pointers? */
2925                 if (retval && *retval)
2926                     as_fatal("Internal Error:  Can't hash %s: %s",ins->name,retval);
2927         }
2928
2929         for (i = 0; i < sizeof(mklower_table) ; i++)
2930             mklower_table[i] = (isupper(c = (char) i)) ? tolower(c) : c;
2931
2932         for (i = 0 ; i < sizeof(notend_table) ; i++) {
2933                 notend_table[i] = 0;
2934                 alt_notend_table[i] = 0;
2935         }
2936         notend_table[','] = 1;
2937         notend_table['{'] = 1;
2938         notend_table['}'] = 1;
2939         alt_notend_table['a'] = 1;
2940         alt_notend_table['A'] = 1;
2941         alt_notend_table['d'] = 1;
2942         alt_notend_table['D'] = 1;
2943         alt_notend_table['#'] = 1;
2944         alt_notend_table['f'] = 1;
2945         alt_notend_table['F'] = 1;
2946 #ifdef REGISTER_PREFIX
2947         alt_notend_table[REGISTER_PREFIX] = 1;
2948 #endif
2949 }
2950
2951 #if 0
2952 #define notend(s) ((*s == ',' || *s == '}' || *s == '{' \
2953                     || (*s == ':' && strchr("aAdD#", s[1]))) \
2954                    ? 0 : 1)
2955 #endif
2956
2957 /* This funciton is called once, before the assembler exits.  It is
2958    supposed to do any final cleanup for this part of the assembler.
2959    */
2960 void
2961     md_end()
2962 {
2963 }
2964
2965 /* Equal to MAX_PRECISION in atof-ieee.c */
2966 #define MAX_LITTLENUMS 6
2967
2968 /* Turn a string in input_line_pointer into a floating point constant of type
2969    type, and store the appropriate bytes in *litP.  The number of LITTLENUMS
2970    emitted is stored in *sizeP. An error message is returned, or NULL on OK.
2971    */
2972 char *
2973     md_atof(type,litP,sizeP)
2974 char type;
2975 char *litP;
2976 int *sizeP;
2977 {
2978         int     prec;
2979         LITTLENUM_TYPE words[MAX_LITTLENUMS];
2980         LITTLENUM_TYPE *wordP;
2981         char    *t;
2982         char    *atof_ieee();
2983
2984         switch (type) {
2985         case 'f':
2986         case 'F':
2987         case 's':
2988         case 'S':
2989                 prec = 2;
2990                 break;
2991
2992         case 'd':
2993         case 'D':
2994         case 'r':
2995         case 'R':
2996                 prec = 4;
2997                 break;
2998
2999         case 'x':
3000         case 'X':
3001                 prec = 6;
3002                 break;
3003
3004         case 'p':
3005         case 'P':
3006                 prec = 6;
3007                 break;
3008
3009         default:
3010                 *sizeP=0;
3011                 return "Bad call to MD_ATOF()";
3012         }
3013         t=atof_ieee(input_line_pointer,type,words);
3014         if (t)
3015             input_line_pointer=t;
3016
3017         *sizeP=prec * sizeof(LITTLENUM_TYPE);
3018         for (wordP=words;prec--;) {
3019                 md_number_to_chars(litP,(long)(*wordP++),sizeof(LITTLENUM_TYPE));
3020                 litP+=sizeof(LITTLENUM_TYPE);
3021         }
3022         return "";      /* Someone should teach Dean about null pointers */
3023 }
3024
3025 /* Turn an integer of n bytes (in val) into a stream of bytes appropriate
3026    for use in the a.out file, and stores them in the array pointed to by buf.
3027    This knows about the endian-ness of the target machine and does
3028    THE RIGHT THING, whatever it is.  Possible values for n are 1 (byte)
3029    2 (short) and 4 (long)  Floating numbers are put out as a series of
3030    LITTLENUMS (shorts, here at least)
3031    */
3032 void
3033     md_number_to_chars(buf, val, n)
3034 char    *buf;
3035 long    val;
3036 int n;
3037 {
3038         switch (n) {
3039         case 1:
3040                 *buf++=val;
3041                 break;
3042         case 2:
3043                 *buf++=(val>>8);
3044                 *buf++=val;
3045                 break;
3046         case 4:
3047                 *buf++=(val>>24);
3048                 *buf++=(val>>16);
3049                 *buf++=(val>>8);
3050                 *buf++=val;
3051                 break;
3052         default:
3053                 as_fatal("failed sanity check.");
3054         }
3055 }
3056
3057 void
3058     md_apply_fix(fixP, val)
3059 fixS *fixP;
3060 long val;
3061 {
3062         char *buf = fixP->fx_where + fixP->fx_frag->fr_literal;
3063
3064         switch (fixP->fx_size) {
3065         case 1:
3066                 *buf++ = val;
3067                 break;
3068         case 2:
3069                 *buf++ = (val >> 8);
3070                 *buf++ = val;
3071                 break;
3072         case 4:
3073                 *buf++ = (val >> 24);
3074                 *buf++ = (val >> 16);
3075                 *buf++ = (val >> 8);
3076                 *buf++ = val;
3077                 break;
3078         default:
3079                 BAD_CASE (fixP->fx_size);
3080         }
3081 }
3082
3083
3084 /* *fragP has been relaxed to its final size, and now needs to have
3085    the bytes inside it modified to conform to the new size  There is UGLY
3086    MAGIC here. ..
3087    */
3088 void
3089     md_convert_frag(headers, fragP)
3090 object_headers *headers;
3091 register fragS *fragP;
3092 {
3093         long disp;
3094         long ext = 0;
3095
3096         /* Address in object code of the displacement.  */
3097         register int object_address = fragP->fr_fix + fragP->fr_address;
3098
3099 #ifdef IBM_COMPILER_SUX
3100         /* This is wrong but it convinces the native rs6000 compiler to
3101            generate the code we want. */
3102         register char *buffer_address = fragP->fr_literal;
3103         buffer_address += fragP->fr_fix;
3104 #else /* IBM_COMPILER_SUX */
3105         /* Address in gas core of the place to store the displacement.  */
3106         register char *buffer_address = fragP->fr_fix + fragP->fr_literal;
3107 #endif /* IBM_COMPILER_SUX */
3108
3109         /* No longer true:   know(fragP->fr_symbol); */
3110
3111         /* The displacement of the address, from current location.  */
3112         disp = fragP->fr_symbol ? S_GET_VALUE(fragP->fr_symbol) : 0;
3113         disp = (disp + fragP->fr_offset) - object_address;
3114
3115         switch (fragP->fr_subtype) {
3116         case TAB(BCC68000,BYTE):
3117     case TAB(BRANCH,BYTE):
3118         know(issbyte(disp));
3119         if (disp == 0)
3120             as_bad("short branch with zero offset: use :w");
3121         fragP->fr_opcode[1]=disp;
3122         ext=0;
3123         break;
3124  case TAB(DBCC,SHORT):
3125      know(issword(disp));
3126         ext=2;
3127         break;
3128  case TAB(BCC68000,SHORT):
3129  case TAB(BRANCH,SHORT):
3130      know(issword(disp));
3131         fragP->fr_opcode[1]=0x00;
3132         ext=2;
3133         break;
3134  case TAB(BRANCH,LONG):
3135      if (cpu_of_arch(current_architecture) < m68020) {
3136              if (fragP->fr_opcode[0] == 0x61) {
3137                      fragP->fr_opcode[0]= 0x4E;
3138                      fragP->fr_opcode[1]= 0xB9; /* JBSR with ABSL LONG offset */
3139                      subseg_change(SEG_TEXT, 0);
3140
3141                      fix_new(fragP,
3142                              fragP->fr_fix,
3143                              4,
3144                              fragP->fr_symbol,
3145                              0,
3146                              fragP->fr_offset,
3147                              0,
3148                              FIX_NO_RELOC);
3149
3150                      fragP->fr_fix+=4;
3151                      ext=0;
3152              } else if (fragP->fr_opcode[0] == 0x60) {
3153                      fragP->fr_opcode[0]= 0x4E;
3154                      fragP->fr_opcode[1]= 0xF9;      /* JMP  with ABSL LONG offset */
3155                      subseg_change(SEG_TEXT, 0);
3156                      fix_new(fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0, fragP->fr_offset,0,
3157                              FIX_NO_RELOC);
3158                      fragP->fr_fix+=4;
3159                      ext=0;
3160              } else {
3161                      as_bad("Long branch offset not supported.");
3162              }
3163      } else {
3164              fragP->fr_opcode[1]=0xff;
3165              ext=4;
3166      }
3167         break;
3168  case TAB(BCC68000,LONG):
3169      /* only Bcc 68000 instructions can come here */
3170      /* change bcc into b!cc/jmp absl long */
3171      fragP->fr_opcode[0] ^= 0x01; /* invert bcc */
3172         fragP->fr_opcode[1] = 0x6;   /* branch offset = 6 */
3173
3174         /* JF: these used to be fr_opcode[2,3], but they may be in a
3175            different frag, in which case refering to them is a no-no.
3176            Only fr_opcode[0,1] are guaranteed to work. */
3177         *buffer_address++ = 0x4e;  /* put in jmp long (0x4ef9) */
3178         *buffer_address++ = 0xf9;
3179         fragP->fr_fix += 2;          /* account for jmp instruction */
3180         subseg_change(SEG_TEXT,0);
3181         fix_new(fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0,
3182                 fragP->fr_offset,0,
3183                 FIX_NO_RELOC);
3184         fragP->fr_fix += 4;
3185         ext=0;
3186         break;
3187  case TAB(DBCC,LONG):
3188      /* only DBcc 68000 instructions can come here */
3189      /* change dbcc into dbcc/jmp absl long */
3190      /* JF: these used to be fr_opcode[2-7], but that's wrong */
3191      *buffer_address++ = 0x00;  /* branch offset = 4 */
3192         *buffer_address++ = 0x04;
3193         *buffer_address++ = 0x60;  /* put in bra pc+6 */
3194         *buffer_address++ = 0x06;
3195         *buffer_address++ = 0x4e;  /* put in jmp long (0x4ef9) */
3196         *buffer_address++ = 0xf9;
3197
3198         fragP->fr_fix += 6;          /* account for bra/jmp instructions */
3199         subseg_change(SEG_TEXT,0);
3200         fix_new(fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0,
3201                 fragP->fr_offset,0,
3202                 FIX_NO_RELOC);
3203         fragP->fr_fix += 4;
3204         ext=0;
3205         break;
3206  case TAB(FBRANCH,SHORT):
3207      know((fragP->fr_opcode[1]&0x40) == 0);
3208         ext=2;
3209         break;
3210  case TAB(FBRANCH,LONG):
3211      fragP->fr_opcode[1]|=0x40; /* Turn on LONG bit */
3212         ext=4;
3213         break;
3214  case TAB(PCREL,SHORT):
3215      ext=2;
3216         break;
3217  case TAB(PCREL,LONG):
3218      /* The thing to do here is force it to ABSOLUTE LONG, since
3219         PCREL is really trying to shorten an ABSOLUTE address anyway */
3220      /* JF FOO This code has not been tested */
3221      subseg_change(SEG_TEXT,0);
3222         fix_new(fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0, fragP->fr_offset, 0, FIX_NO_RELOC);
3223         if ((fragP->fr_opcode[1] & 0x3F) != 0x3A)
3224             as_bad("Internal error (long PC-relative operand) for insn 0x%04lx at 0x%lx",
3225                    fragP->fr_opcode[0],fragP->fr_address);
3226         fragP->fr_opcode[1]&= ~0x3F;
3227         fragP->fr_opcode[1]|=0x39;      /* Mode 7.1 */
3228         fragP->fr_fix+=4;
3229         /* md_number_to_chars(buffer_address,
3230            (long)(fragP->fr_symbol->sy_value + fragP->fr_offset),
3231            4); */
3232         ext=0;
3233         break;
3234  case TAB(PCLEA,SHORT):
3235      subseg_change(SEG_TEXT,0);
3236         fix_new(fragP, (int) (fragP->fr_fix), 2, fragP->fr_symbol, (symbolS *) 0, fragP->fr_offset, 1, FIX_NO_RELOC);
3237         fragP->fr_opcode[1] &= ~0x3F;
3238         fragP->fr_opcode[1] |= 0x3A;
3239         ext=2;
3240         break;
3241  case TAB(PCLEA,LONG):
3242      subseg_change(SEG_TEXT,0);
3243         fix_new(fragP, (int) (fragP->fr_fix) + 2, 4, fragP->fr_symbol, (symbolS *) 0, fragP->fr_offset + 2, 1, FIX_NO_RELOC);
3244         *buffer_address++ = 0x01;
3245         *buffer_address++ = 0x70;
3246         fragP->fr_fix+=2;
3247         /* buffer_address+=2; */
3248         ext=4;
3249         break;
3250
3251 } /* switch on subtype */
3252
3253         if (ext) {
3254                 md_number_to_chars(buffer_address, (long) disp, (int) ext);
3255                 fragP->fr_fix += ext;
3256                 /*        H_SET_TEXT_SIZE(headers, H_GET_TEXT_SIZE(headers) + ext); */
3257         } /* if extending */
3258
3259         return;
3260 } /* md_convert_frag() */
3261
3262 /* Force truly undefined symbols to their maximum size, and generally set up
3263    the frag list to be relaxed
3264    */
3265 int md_estimate_size_before_relax(fragP, segment)
3266 register fragS *fragP;
3267 segT segment;
3268 {
3269         int     old_fix;
3270         register char *buffer_address = fragP->fr_fix + fragP->fr_literal;
3271
3272         old_fix = fragP->fr_fix;
3273
3274         /* handle SZ_UNDEF first, it can be changed to BYTE or SHORT */
3275         switch (fragP->fr_subtype) {
3276
3277         case TAB(BRANCH,SZ_UNDEF): {
3278                 if ((fragP->fr_symbol != NULL)  /* Not absolute */
3279                    && S_GET_SEGMENT(fragP->fr_symbol) == segment) {
3280                         fragP->fr_subtype = TAB(TABTYPE(fragP->fr_subtype), BYTE);
3281                         break;
3282                 } else if ((fragP->fr_symbol == 0) || (cpu_of_arch(current_architecture) < m68020)) {
3283                         /* On 68000, or for absolute value, switch to abs long */
3284                         /* FIXME, we should check abs val, pick short or long */
3285                         if (fragP->fr_opcode[0] == 0x61) {
3286                                 fragP->fr_opcode[0]= 0x4E;
3287                                 fragP->fr_opcode[1]= 0xB9;      /* JSR with ABSL LONG offset */
3288                                 subseg_change(SEG_TEXT, 0);
3289                                 fix_new(fragP, fragP->fr_fix, 4,
3290                                         fragP->fr_symbol, 0, fragP->fr_offset, 0, FIX_NO_RELOC);
3291                                 fragP->fr_fix+=4;
3292                                 frag_wane(fragP);
3293                         } else if (fragP->fr_opcode[0] == 0x60) {
3294                                 fragP->fr_opcode[0]= 0x4E;
3295                                 fragP->fr_opcode[1]= 0xF9;  /* JMP  with ABSL LONG offset */
3296                                 subseg_change(SEG_TEXT, 0);
3297                                 fix_new(fragP, fragP->fr_fix, 4,
3298                                         fragP->fr_symbol, 0, fragP->fr_offset, 0, FIX_NO_RELOC);
3299                                 fragP->fr_fix+=4;
3300                                 frag_wane(fragP);
3301                         } else {
3302                                 as_warn("Long branch offset to extern symbol not supported.");
3303                         }
3304                 } else if (flagseen['l']) { /* Symbol is still undefined.  Make it simple */
3305                         fix_new(fragP, (int) (fragP->fr_fix), 2, fragP->fr_symbol,
3306                                 (symbolS *) 0, fragP->fr_offset, 1, FIX_NO_RELOC);
3307                         fragP->fr_fix += 2;
3308                         fragP->fr_opcode[1] = 0x00;
3309                         frag_wane(fragP);
3310                 } else {
3311                         fix_new(fragP, (int) (fragP->fr_fix), 4, fragP->fr_symbol,
3312                                 (symbolS *) 0, fragP->fr_offset, 1,
3313 #ifdef  PIC
3314                                 /* With -k, make all external branches go via the jump table. */
3315                                 (picmode? RELOC_JMP_TBL: NO_RELOC), NULL
3316 #else
3317                                 NO_RELOC
3318 #endif
3319                                 );
3320                         fragP->fr_fix += 4;
3321                         fragP->fr_opcode[1] = 0xff;
3322                         frag_wane(fragP);
3323                         break;
3324                 }
3325
3326                 break;
3327         } /* case TAB(BRANCH,SZ_UNDEF) */
3328
3329         case TAB(FBRANCH,SZ_UNDEF): {
3330                 if (S_GET_SEGMENT(fragP->fr_symbol) == segment || flagseen['l']) {
3331                         fragP->fr_subtype = TAB(FBRANCH,SHORT);
3332                         fragP->fr_var += 2;
3333                 } else {
3334                         fragP->fr_subtype = TAB(FBRANCH,LONG);
3335                         fragP->fr_var += 4;
3336                 }
3337                 break;
3338         } /* TAB(FBRANCH,SZ_UNDEF) */
3339
3340         case TAB(PCREL,SZ_UNDEF): {
3341                 if (S_GET_SEGMENT(fragP->fr_symbol) == segment || flagseen['l']) {
3342                         fragP->fr_subtype = TAB(PCREL,SHORT);
3343                         fragP->fr_var += 2;
3344                 } else {
3345                         fragP->fr_subtype = TAB(PCREL,LONG);
3346                         fragP->fr_var += 4;
3347                 }
3348                 break;
3349         } /* TAB(PCREL,SZ_UNDEF) */
3350
3351         case TAB(BCC68000,SZ_UNDEF): {
3352                 if ((fragP->fr_symbol != NULL)
3353                    && S_GET_SEGMENT(fragP->fr_symbol) == segment) {
3354                         fragP->fr_subtype=TAB(BCC68000,BYTE);
3355                         break;
3356                 }
3357                 /* only Bcc 68000 instructions can come here */
3358                 /* change bcc into b!cc/jmp absl long */
3359                 fragP->fr_opcode[0] ^= 0x01; /* invert bcc */
3360                 if (flagseen['l']) {
3361                         fragP->fr_opcode[1] = 0x04;   /* branch offset = 6 */
3362                         /* JF: these were fr_opcode[2,3] */
3363                         buffer_address[0] = 0x4e;  /* put in jmp long (0x4ef9) */
3364                         buffer_address[1] = 0xf8;
3365                         fragP->fr_fix += 2;          /* account for jmp instruction */
3366                         subseg_change(SEG_TEXT,0);
3367                         fix_new(fragP, fragP->fr_fix, 2, fragP->fr_symbol, 0,
3368                                 fragP->fr_offset, 0, FIX_NO_RELOC);
3369                         fragP->fr_fix += 2;
3370                 } else {
3371                         fragP->fr_opcode[1] = 0x06;   /* branch offset = 6 */
3372                         /* JF: these were fr_opcode[2,3] */
3373                         buffer_address[2] = 0x4e;  /* put in jmp long (0x4ef9) */
3374                         buffer_address[3] = 0xf9;
3375                         fragP->fr_fix += 2;          /* account for jmp instruction */
3376                         subseg_change(SEG_TEXT,0);
3377                         fix_new(fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0,
3378                                 fragP->fr_offset, 0, FIX_NO_RELOC);
3379                         fragP->fr_fix += 4;
3380                 }
3381                 frag_wane(fragP);
3382                 break;
3383         } /* case TAB(BCC68000,SZ_UNDEF) */
3384
3385         case TAB(DBCC,SZ_UNDEF): {
3386                 if (fragP->fr_symbol != NULL && S_GET_SEGMENT(fragP->fr_symbol) == segment) {
3387                         fragP->fr_subtype=TAB(DBCC,SHORT);
3388                         fragP->fr_var+=2;
3389                         break;
3390                 }
3391                 /* only DBcc 68000 instructions can come here */
3392                 /* change dbcc into dbcc/jmp absl long */
3393                 /* JF: these used to be fr_opcode[2-4], which is wrong. */
3394                 buffer_address[0] = 0x00;  /* branch offset = 4 */
3395                 buffer_address[1] = 0x04;
3396                 buffer_address[2] = 0x60;  /* put in bra pc + ... */
3397
3398                 if (flagseen['l']) {
3399                         /* JF: these were fr_opcode[5-7] */
3400                         buffer_address[3] = 0x04; /* plus 4 */
3401                         buffer_address[4] = 0x4e;/* Put in Jump Word */
3402                         buffer_address[5] = 0xf8;
3403                         fragP->fr_fix += 6;       /* account for bra/jmp instruction */
3404                         subseg_change(SEG_TEXT,0);
3405                         fix_new(fragP, fragP->fr_fix, 2, fragP->fr_symbol, 0,
3406                                 fragP->fr_offset, 0, FIX_NO_RELOC);
3407                         fragP->fr_fix += 2;
3408                 } else {
3409                         /* JF: these were fr_opcode[5-7] */
3410                         buffer_address[3] = 0x06;  /* Plus 6 */
3411                         buffer_address[4] = 0x4e;  /* put in jmp long (0x4ef9) */
3412                         buffer_address[5] = 0xf9;
3413                         fragP->fr_fix += 6;       /* account for bra/jmp instruction */
3414                         subseg_change(SEG_TEXT,0);
3415                         fix_new(fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0,
3416                                 fragP->fr_offset, 0, FIX_NO_RELOC);
3417                         fragP->fr_fix += 4;
3418                 }
3419
3420                 frag_wane(fragP);
3421                 break;
3422         } /* case TAB(DBCC,SZ_UNDEF) */
3423
3424         case TAB(PCLEA,SZ_UNDEF): {
3425                 if ((S_GET_SEGMENT(fragP->fr_symbol)) == segment || flagseen['l']) {
3426                         fragP->fr_subtype=TAB(PCLEA,SHORT);
3427                         fragP->fr_var+=2;
3428                 } else {
3429                         fragP->fr_subtype=TAB(PCLEA,LONG);
3430                         fragP->fr_var+=6;
3431                 }
3432                 break;
3433         } /* TAB(PCLEA,SZ_UNDEF) */
3434
3435         default:
3436                 break;
3437
3438         } /* switch on subtype looking for SZ_UNDEF's. */
3439
3440         /* now that SZ_UNDEF are taken care of, check others */
3441         switch (fragP->fr_subtype) {
3442         case TAB(BCC68000,BYTE):
3443     case TAB(BRANCH,BYTE):
3444         /* We can't do a short jump to the next instruction,
3445            so we force word mode.  */
3446         if (fragP->fr_symbol && S_GET_VALUE(fragP->fr_symbol) == 0 &&
3447             fragP->fr_symbol->sy_frag == fragP->fr_next) {
3448                 fragP->fr_subtype=TAB(TABTYPE(fragP->fr_subtype),SHORT);
3449                 fragP->fr_var+=2;
3450         }
3451         break;
3452  default:
3453         break;
3454 }
3455         return fragP->fr_var + fragP->fr_fix - old_fix;
3456 }
3457
3458 #if defined(OBJ_AOUT) | defined(OBJ_BOUT)
3459 /* the bit-field entries in the relocation_info struct plays hell
3460    with the byte-order problems of cross-assembly.  So as a hack,
3461    I added this mach. dependent ri twiddler.  Ugly, but it gets
3462    you there. -KWK */
3463 /* on m68k: first 4 bytes are normal unsigned long, next three bytes
3464    are symbolnum, most sig. byte first.  Last byte is broken up with
3465    bit 7 as pcrel, bits 6 & 5 as length, bit 4 as pcrel, and the lower
3466    nibble as nuthin. (on Sun 3 at least) */
3467 /* Translate the internal relocation information into target-specific
3468    format. */
3469 #ifdef comment
3470 void
3471     md_ri_to_chars(the_bytes, ri)
3472 char *the_bytes;
3473 struct reloc_info_generic *ri;
3474 {
3475         /* this is easy */
3476         md_number_to_chars(the_bytes, ri->r_address, 4);
3477         /* now the fun stuff */
3478         the_bytes[4] = (ri->r_symbolnum >> 16) & 0x0ff;
3479         the_bytes[5] = (ri->r_symbolnum >> 8) & 0x0ff;
3480         the_bytes[6] = ri->r_symbolnum & 0x0ff;
3481         the_bytes[7] = (((ri->r_pcrel << 7)  & 0x80) | ((ri->r_length << 5) & 0x60) |
3482                         ((ri->r_extern << 4)  & 0x10));
3483 }
3484 #endif /* comment */
3485
3486 void tc_aout_fix_to_chars(where, fixP, segment_address_in_file)
3487 char *where;
3488 fixS *fixP;
3489 relax_addressT segment_address_in_file;
3490 {
3491         /*
3492          * In: length of relocation (or of address) in chars: 1, 2 or 4.
3493          * Out: GNU LD relocation length code: 0, 1, or 2.
3494          */
3495
3496         static unsigned char nbytes_r_length[] = { 42, 0, 1, 42, 2 };
3497         long r_symbolnum;
3498         int r_flags;
3499
3500         know(fixP->fx_addsy != NULL);
3501
3502         md_number_to_chars(where,
3503                            fixP->fx_frag->fr_address + fixP->fx_where - segment_address_in_file,
3504                            4);
3505
3506         r_symbolnum = (S_IS_DEFINED(fixP->fx_addsy)
3507                        ? S_GET_TYPE(fixP->fx_addsy)
3508                        : fixP->fx_addsy->sy_number);
3509         r_flags = (fixP->fx_pcrel? 0x80: 0)
3510             | ((nbytes_r_length[fixP->fx_size] & 3) << 5)
3511             | (!S_IS_DEFINED(fixP->fx_addsy)? 0x10: 0);
3512
3513 #ifdef  PIC
3514         switch (fixP->fx_r_type) {
3515         case NO_RELOC:
3516             break;
3517         case RELOC_32:
3518             if (picmode && S_IS_EXTERNAL(fixP->fx_addsy)) {
3519                 r_symbolnum = fixP->fx_addsy->sy_number;
3520                 r_flags |= 0x10;        /* set extern bit */
3521             }
3522             break;
3523         case RELOC_GLOB_DAT:
3524             r_flags |= 8;               /* set baserel bit */
3525             r_symbolnum = fixP->fx_addsy->sy_number;
3526             if (S_IS_EXTERNAL(fixP->fx_addsy))
3527                 r_flags |= 0x10;
3528             break;
3529         case RELOC_JMP_TBL:
3530             r_flags |= 4;               /* set jmptable bit */
3531             break;
3532         case RELOC_RELATIVE:
3533             /* should never happen */
3534             r_flags |= 2;               /* set relative bit */
3535             break;
3536         }
3537 #endif  /* PIC */
3538
3539         where[4] = (r_symbolnum >> 16) & 0x0ff;
3540         where[5] = (r_symbolnum >> 8) & 0x0ff;
3541         where[6] = r_symbolnum & 0x0ff;
3542         where[7] = r_flags;
3543
3544         return;
3545 } /* tc_aout_fix_to_chars() */
3546
3547 #endif /* OBJ_AOUT or OBJ_BOUT */
3548
3549 #ifndef WORKING_DOT_WORD
3550 const int md_short_jump_size = 4;
3551 const int md_long_jump_size = 6;
3552
3553 void
3554     md_create_short_jump(ptr,from_addr,to_addr,frag,to_symbol)
3555 char    *ptr;
3556 long    from_addr,
3557     to_addr;
3558 fragS   *frag;
3559 symbolS *to_symbol;
3560 {
3561         long offset;
3562
3563         offset = to_addr - (from_addr+2);
3564
3565         md_number_to_chars(ptr  ,(long)0x6000,2);
3566         md_number_to_chars(ptr+2,(long)offset,2);
3567 }
3568
3569 void
3570     md_create_long_jump(ptr,from_addr,to_addr,frag,to_symbol)
3571 char    *ptr;
3572 long    from_addr,
3573     to_addr;
3574 fragS   *frag;
3575 symbolS *to_symbol;
3576 {
3577         long offset;
3578
3579         if (cpu_of_arch(current_architecture) < m68020) {
3580                 offset=to_addr-S_GET_VALUE(to_symbol);
3581                 md_number_to_chars(ptr  ,(long)0x4EF9,2);
3582                 md_number_to_chars(ptr+2,(long)offset,4);
3583                 fix_new(frag,(ptr+2)-frag->fr_literal,4,to_symbol,(symbolS *)0,(long)0,0,
3584                         FIX_NO_RELOC);
3585         } else {
3586                 offset=to_addr - (from_addr+2);
3587                 md_number_to_chars(ptr  ,(long)0x60ff,2);
3588                 md_number_to_chars(ptr+2,(long)offset,4);
3589         }
3590 }
3591
3592 #endif
3593 /* Different values of OK tell what its OK to return.  Things that aren't OK are an error (what a shock, no?)
3594
3595    0:  Everything is OK
3596    10:  Absolute 1:8    only
3597    20:  Absolute 0:7    only
3598    30:  absolute 0:15   only
3599    40:  Absolute 0:31   only
3600    50:  absolute 0:127  only
3601    55:  absolute -64:63    only
3602    60:  absolute -128:127       only
3603    70:  absolute 0:4095 only
3604    80:  No bignums
3605
3606    */
3607
3608 static int get_num(exp,ok)
3609 struct m68k_exp *exp;
3610 int ok;
3611 {
3612 #ifdef TEST2
3613         long    l = 0;
3614
3615         if (!exp->e_beg)
3616             return 0;
3617         if (*exp->e_beg == '0') {
3618                 if (exp->e_beg[1] == 'x')
3619                     sscanf(exp->e_beg+2,"%x",&l);
3620                 else
3621                     sscanf(exp->e_beg+1,"%O",&l);
3622                 return l;
3623         }
3624         return atol(exp->e_beg);
3625 #else
3626         char    *save_in;
3627         char    c_save;
3628
3629         if (!exp) {
3630                 /* Can't do anything */
3631                 return 0;
3632         }
3633         if (!exp->e_beg || !exp->e_end) {
3634                 seg(exp)=SEG_ABSOLUTE;
3635                 adds(exp)=0;
3636                 subs(exp)=0;
3637                 offs(exp)= (ok == 10) ? 1 : 0;
3638                 as_warn("Null expression defaults to %ld",offs(exp));
3639                 return 0;
3640         }
3641
3642         exp->e_siz=0;
3643         if (/* ok != 80 && */exp->e_end[-1] == ':' && (exp->e_end-exp->e_beg) >= 2) {
3644                 switch (exp->e_end[0]) {
3645                 case 's':
3646                 case 'S':
3647                 case 'b':
3648                 case 'B':
3649                         exp->e_siz=1;
3650                         break;
3651                 case 'w':
3652                 case 'W':
3653                         exp->e_siz=2;
3654                         break;
3655                 case 'l':
3656                 case 'L':
3657                         exp->e_siz=3;
3658                         break;
3659                 default:
3660                         as_bad("Unknown size for expression \"%c\"",exp->e_end[0]);
3661                 }
3662                 exp->e_end-=2;
3663         }
3664         c_save=exp->e_end[1];
3665         exp->e_end[1]='\0';
3666         save_in=input_line_pointer;
3667         input_line_pointer=exp->e_beg;
3668         switch (expression(&(exp->e_exp))) {
3669         case SEG_PASS1:
3670                 seg(exp)=SEG_ABSOLUTE;
3671                 adds(exp)=0;
3672                 subs(exp)=0;
3673                 offs(exp)= (ok == 10) ? 1 : 0;
3674                 as_warn("Unknown expression: '%s' defaulting to %d",exp->e_beg,offs(exp));
3675                 break;
3676
3677         case SEG_ABSENT:
3678                 /* Do the same thing the VAX asm does */
3679                 seg(exp)=SEG_ABSOLUTE;
3680                 adds(exp)=0;
3681                 subs(exp)=0;
3682                 offs(exp)=0;
3683                 if (ok == 10) {
3684                         as_warn("expression out of range: defaulting to 1");
3685                         offs(exp)=1;
3686                 }
3687                 break;
3688         case SEG_ABSOLUTE:
3689                 switch (ok) {
3690                 case 10:
3691                         if (offs(exp)<1 || offs(exp)>8) {
3692                                 as_warn("expression out of range: defaulting to 1");
3693                                 offs(exp)=1;
3694                         }
3695                         break;
3696                 case 20:
3697                         if (offs(exp)<0 || offs(exp)>7)
3698                             goto outrange;
3699                         break;
3700                 case 30:
3701                         if (offs(exp)<0 || offs(exp)>15)
3702                             goto outrange;
3703                         break;
3704                 case 40:
3705                         if (offs(exp)<0 || offs(exp)>32)
3706                             goto outrange;
3707                         break;
3708                 case 50:
3709                         if (offs(exp)<0 || offs(exp)>127)
3710                             goto outrange;
3711                         break;
3712                 case 55:
3713                         if (offs(exp)<-64 || offs(exp)>63)
3714                             goto outrange;
3715                         break;
3716                 case 60:
3717                         if (offs(exp)<-128 || offs(exp)>127)
3718                             goto outrange;
3719                         break;
3720                 case 70:
3721                         if (offs(exp)<0 || offs(exp)>4095) {
3722                         outrange:
3723                                 as_warn("expression out of range: defaulting to 0");
3724                                 offs(exp)=0;
3725                         }
3726                         break;
3727                 default:
3728                         break;
3729                 }
3730                 break;
3731         case SEG_TEXT:
3732         case SEG_DATA:
3733         case SEG_BSS:
3734         case SEG_UNKNOWN:
3735         case SEG_DIFFERENCE:
3736                 if (ok >= 10 && ok <= 70) {
3737                         seg(exp)=SEG_ABSOLUTE;
3738                         adds(exp)=0;
3739                         subs(exp)=0;
3740                         offs(exp)= (ok == 10) ? 1 : 0;
3741                         as_warn("Can't deal with expression \"%s\": defaulting to %ld",exp->e_beg,offs(exp));
3742                 }
3743                 break;
3744         case SEG_BIG:
3745                 if (ok == 80 && offs(exp)<0) {  /* HACK! Turn it into a long */
3746                         LITTLENUM_TYPE words[6];
3747
3748                         gen_to_words(words,2,8L);/* These numbers are magic! */
3749                         seg(exp)=SEG_ABSOLUTE;
3750                         adds(exp)=0;
3751                         subs(exp)=0;
3752                         offs(exp)=words[1]|(words[0]<<16);
3753                 } else if (ok != 0) {
3754                         seg(exp)=SEG_ABSOLUTE;
3755                         adds(exp)=0;
3756                         subs(exp)=0;
3757                         offs(exp)= (ok == 10) ? 1 : 0;
3758                         as_warn("Can't deal with expression \"%s\": defaulting to %ld",exp->e_beg,offs(exp));
3759                 }
3760                 break;
3761         default:
3762                 as_fatal("failed sanity check.");
3763         }
3764         if (input_line_pointer != exp->e_end+1)
3765             as_bad("Ignoring junk after expression");
3766         exp->e_end[1]=c_save;
3767         input_line_pointer=save_in;
3768         if (exp->e_siz) {
3769                 switch (exp->e_siz) {
3770                 case 1:
3771                         if (!isbyte(offs(exp)))
3772                             as_warn("expression doesn't fit in BYTE");
3773                         break;
3774                 case 2:
3775                         if (!isword(offs(exp)))
3776                             as_warn("expression doesn't fit in WORD");
3777                         break;
3778                 }
3779         }
3780         return offs(exp);
3781 #endif
3782 } /* get_num() */
3783
3784 /* These are the back-ends for the various machine dependent pseudo-ops.  */
3785 void demand_empty_rest_of_line();       /* Hate those extra verbose names */
3786
3787 static void s_data1() {
3788         subseg_new(SEG_DATA,1);
3789         demand_empty_rest_of_line();
3790 } /* s_data1() */
3791
3792 static void s_data2() {
3793         subseg_new(SEG_DATA,2);
3794         demand_empty_rest_of_line();
3795 } /* s_data2() */
3796
3797 static void s_bss() {
3798         /* We don't support putting frags in the BSS segment, but we
3799            can put them into initialized data for now... */
3800         subseg_new(SEG_DATA,255);       /* FIXME-SOON */
3801         demand_empty_rest_of_line();
3802 } /* s_bss() */
3803
3804 static void s_even() {
3805         register int temp;
3806         register long temp_fill;
3807
3808         temp = 1;               /* JF should be 2? */
3809         temp_fill = get_absolute_expression ();
3810         if ( ! need_pass_2 ) /* Never make frag if expect extra pass. */
3811             frag_align (temp, (int)temp_fill);
3812         demand_empty_rest_of_line();
3813 } /* s_even() */
3814
3815 static void s_proc() {
3816         demand_empty_rest_of_line();
3817 } /* s_proc() */
3818
3819 /* s_space is defined in read.c .skip is simply an alias to it. */
3820
3821 /*
3822  * md_parse_option
3823  *      Invocation line includes a switch not recognized by the base assembler.
3824  *      See if it's a processor-specific option.  These are:
3825  *
3826  *      -[A]m[c]68000, -[A]m[c]68008, -[A]m[c]68010, -[A]m[c]68020, -[A]m[c]68030, -[A]m[c]68040
3827  *      -[A]m[c]68881, -[A]m[c]68882, -[A]m[c]68851
3828  *              Select the architecture.  Instructions or features not
3829  *              supported by the selected architecture cause fatal
3830  *              errors.  More than one may be specified.  The default is
3831  *              -m68020 -m68851 -m68881.  Note that -m68008 is a synonym
3832  *              for -m68000, and -m68882 is a synonym for -m68881.
3833  *
3834  * MAYBE_FLOAT_TOO is defined below so that specifying a processor type
3835  * (e.g. m68020) also requests that float instructions be included.  This
3836  * is the default setup, mostly to avoid hassling users.  A better
3837  * rearrangement of this structure would be to add an option to DENY
3838  * floating point opcodes, for people who want to really know there's none
3839  * of that funny floaty stuff going on.  FIXME-later.
3840  */
3841 #ifndef MAYBE_FLOAT_TOO
3842 #define MAYBE_FLOAT_TOO m68881
3843 #endif
3844
3845 int md_parse_option(argP,cntP,vecP)
3846 char **argP;
3847 int *cntP;
3848 char ***vecP;
3849 {
3850         switch (**argP) {
3851         case 'l':       /* -l means keep external to 2 bit offset
3852                            rather than 16 bit one */
3853                 break;
3854
3855         case 'S': /* -S means that jbsr's always turn into jsr's.  */
3856                 break;
3857
3858         case 'A':
3859                 (*argP)++;
3860                 /* intentional fall-through */
3861         case 'm':
3862                 (*argP)++;
3863
3864                 if (**argP == 'c') {
3865                         (*argP)++;
3866                 } /* allow an optional "c" */
3867
3868                 if (!strcmp(*argP, "68000")
3869                     || !strcmp(*argP, "68008")) {
3870                         current_architecture |= m68000;
3871                 } else if (!strcmp(*argP, "68010")) {
3872 #ifdef TE_SUN
3873                         omagic= 1<<16|OMAGIC;
3874 #endif
3875                         current_architecture |= m68010;
3876
3877                 } else if (!strcmp(*argP, "68020")) {
3878                         current_architecture |= m68020 | MAYBE_FLOAT_TOO;
3879
3880                 } else if (!strcmp(*argP, "68030")) {
3881                         current_architecture |= m68030 | MAYBE_FLOAT_TOO;
3882
3883                 } else if (!strcmp(*argP, "68040")) {
3884                         current_architecture |= m68040 | MAYBE_FLOAT_TOO;
3885
3886                 } else if (!strcmp(*argP, "68060")) {
3887                         current_architecture |= m68040 | MAYBE_FLOAT_TOO;
3888
3889 #ifndef NO_68881
3890                 } else if (!strcmp(*argP, "68881")) {
3891                         current_architecture |= m68881;
3892
3893                 } else if (!strcmp(*argP, "68882")) {
3894                         current_architecture |= m68882;
3895
3896 #endif /* NO_68881 */
3897 #ifndef NO_68851
3898                 } else if (!strcmp(*argP,"68851")) {
3899                         current_architecture |= m68851;
3900
3901 #endif /* NO_68851 */
3902                 } else {
3903                         as_warn("Unknown architecture, \"%s\". option ignored", *argP);
3904                 } /* switch on architecture */
3905
3906                 while (**argP) (*argP)++;
3907
3908                 break;
3909
3910         case 'p':
3911                 if (!strcmp(*argP,"pic")) {
3912                         (*argP) += 3;
3913                         break;          /* -pic, Position Independent Code */
3914                 } else {
3915                         return(0);
3916                 } /* pic or not */
3917
3918 #ifdef  PIC
3919         case 'k':
3920         case 'K':
3921                 /* Predefine GOT symbol */
3922                 GOT_symbol = symbol_find_or_make("__GLOBAL_OFFSET_TABLE_");
3923                 break;
3924 #endif  /* PIC */
3925
3926         default:
3927                 return 0;
3928         }
3929         return 1;
3930 }
3931
3932
3933 #ifdef TEST2
3934
3935 /* TEST2:  Test md_assemble() */
3936 /* Warning, this routine probably doesn't work anymore */
3937
3938 main()
3939 {
3940         struct m68k_it the_ins;
3941         char buf[120];
3942         char *cp;
3943         int     n;
3944
3945         m68k_ip_begin();
3946         for (;;) {
3947                 if (!gets(buf) || !*buf)
3948                     break;
3949                 if (buf[0] == '|' || buf[1] == '.')
3950                     continue;
3951                 for (cp=buf;*cp;cp++)
3952                     if (*cp == '\t')
3953                         *cp=' ';
3954                 if (is_label(buf))
3955                     continue;
3956                 memset(&the_ins, '\0', sizeof(the_ins));
3957                 m68k_ip(&the_ins,buf);
3958                 if (the_ins.error) {
3959                         printf("Error %s in %s\n",the_ins.error,buf);
3960                 } else {
3961                         printf("Opcode(%d.%s): ",the_ins.numo,the_ins.args);
3962                         for (n=0;n<the_ins.numo;n++)
3963                             printf(" 0x%x",the_ins.opcode[n]&0xffff);
3964                         printf("    ");
3965                         print_the_insn(&the_ins.opcode[0],stdout);
3966                         (void)putchar('\n');
3967                 }
3968                 for (n=0;n<strlen(the_ins.args)/2;n++) {
3969                         if (the_ins.operands[n].error) {
3970                                 printf("op%d Error %s in %s\n",n,the_ins.operands[n].error,buf);
3971                                 continue;
3972                         }
3973                         printf("mode %d, reg %d, ",the_ins.operands[n].mode,the_ins.operands[n].reg);
3974                         if (the_ins.operands[n].b_const)
3975                             printf("Constant: '%.*s', ",1+the_ins.operands[n].e_const-the_ins.operands[n].b_const,the_ins.operands[n].b_const);
3976                         printf("ireg %d, isiz %d, imul %d, ",the_ins.operands[n].ireg,the_ins.operands[n].isiz,the_ins.operands[n].imul);
3977                         if (the_ins.operands[n].b_iadd)
3978                             printf("Iadd: '%.*s',",1+the_ins.operands[n].e_iadd-the_ins.operands[n].b_iadd,the_ins.operands[n].b_iadd);
3979                         (void)putchar('\n');
3980                 }
3981         }
3982         m68k_ip_end();
3983         return 0;
3984 }
3985
3986 is_label(str)
3987 char *str;
3988 {
3989         while (*str == ' ')
3990             str++;
3991         while (*str && *str != ' ')
3992             str++;
3993         if (str[-1] == ':' || str[1] == '=')
3994             return 1;
3995         return 0;
3996 }
3997
3998 #endif
3999
4000 /* Possible states for relaxation:
4001
4002    0 0  branch offset   byte    (bra, etc)
4003    0 1                  word
4004    0 2                  long
4005
4006    1 0  indexed offsets byte    a0@(32,d4:w:1) etc
4007    1 1                  word
4008    1 2                  long
4009
4010    2 0  two-offset index word-word a0@(32,d4)@(45) etc
4011    2 1                  word-long
4012    2 2                  long-word
4013    2 3                  long-long
4014
4015    */
4016
4017
4018
4019 #ifdef DONTDEF
4020 abort()
4021 {
4022         printf("ABORT!\n");
4023         exit(12);
4024 }
4025
4026 print_frags()
4027 {
4028         fragS *fragP;
4029         extern fragS *text_frag_root;
4030
4031         for (fragP=text_frag_root;fragP;fragP=fragP->fr_next) {
4032                 printf("addr %lu  next 0x%x  fix %ld  var %ld  symbol 0x%x  offset %ld\n",
4033                        fragP->fr_address,fragP->fr_next,fragP->fr_fix,fragP->fr_var,fragP->fr_symbol,fragP->fr_offset);
4034                 printf("opcode 0x%x  type %d  subtype %d\n\n",fragP->fr_opcode,fragP->fr_type,fragP->fr_subtype);
4035         }
4036         fflush(stdout);
4037         return 0;
4038 }
4039 #endif
4040
4041
4042 /* We have no need to default values of symbols.  */
4043
4044 /* ARGSUSED */
4045 symbolS *
4046     md_undefined_symbol (name)
4047 char *name;
4048 {
4049         return 0;
4050 }
4051
4052 /* Parse an operand that is machine-specific.
4053    We just return without modifying the expression if we have nothing
4054    to do.  */
4055
4056 /* ARGSUSED */
4057 void
4058     md_operand (expressionP)
4059 expressionS *expressionP;
4060 {
4061 }
4062
4063 /* Round up a section size to the appropriate boundary.  */
4064 long
4065     md_section_align (segment, size)
4066 segT segment;
4067 long size;
4068 {
4069         return size;            /* Byte alignment is fine */
4070 }
4071
4072 /* Exactly what point is a PC-relative offset relative TO?
4073    On the 68k, they're relative to the address of the offset. */
4074 long
4075     md_pcrel_from (fixP)
4076 fixS *fixP;
4077 {
4078         return(fixP->fx_where + fixP->fx_frag->fr_address);
4079 }
4080
4081 /*
4082  * Local Variables:
4083  * comment-column: 0
4084  * fill-column: 131
4085  * End:
4086  */
4087
4088 /* end of tc-m68k.c */