From 542e1629fdd4df8920511c4eb2df15bb83feb13b Mon Sep 17 00:00:00 2001 From: "K. Richard Pixley" Date: Mon, 17 Feb 1992 15:54:49 +0000 Subject: [PATCH] fighting bitrot in a major way --- gas/.Sanitize | 9 +- gas/ChangeLog | 1325 +-------- gas/Makefile.in | 227 +- gas/NOTES | 9 +- gas/bignum-copy.c | 15 +- gas/bit_fix.h | 50 + gas/config/.Sanitize | 9 +- gas/config/ho-ansi.h | 1 - gas/config/ho-generic.h | 2 + gas/config/ho-sunos.h | 3 - gas/config/ho-sysv.h | 2 - gas/config/obj-coffbfd.c | 10 +- gas/config/tc-a29k.c | 27 +- gas/config/tc-a29k.h | 12 +- gas/config/tc-i386.c | 219 +- gas/config/tc-i386.h | 78 +- gas/config/tc-i860.c | 10 +- gas/config/tc-i960.c | 10 +- gas/config/tc-m68kmote.c | 6909 +++++++++++++++++++++++----------------------- gas/config/tc-m68kmote.h | 2 +- gas/config/tc-ns32k.c | 2488 ++++++++--------- gas/config/tc-sparc.c | 4 +- gas/obstack.c | 370 +++ gas/obstack.h | 444 +++ gas/read.c | 251 +- gas/strerror.c | 61 + gas/write.c | 31 +- 27 files changed, 5970 insertions(+), 6608 deletions(-) create mode 100644 gas/bit_fix.h create mode 100644 gas/obstack.c create mode 100644 gas/obstack.h create mode 100644 gas/strerror.c diff --git a/gas/.Sanitize b/gas/.Sanitize index 26df215..bc93a48 100644 --- a/gas/.Sanitize +++ b/gas/.Sanitize @@ -37,6 +37,10 @@ README README-quirks README-vms-dbg README.coff +obstack.h +obstack.c +bit_fix.h +strerror.c README.rich a.out.gnu.h app.c @@ -101,7 +105,10 @@ echo Done in `pwd`. # # # $Log$ -# Revision 1.8 1992/02/14 00:21:34 pesch +# Revision 1.9 1992/02/17 15:52:52 rich +# fighting bitrot in a major way +# +# Revision 1.8 1992/02/14 00:21:34 pesch # It's OK to keep the doc subdirectory, really. # # Revision 1.7 1992/02/13 10:13:19 rich diff --git a/gas/ChangeLog b/gas/ChangeLog index 9e83613..f7dd25d 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,1326 +1,9 @@ -Fri Jan 24 16:48:32 1992 Steve Chamberlain (sac at rtl.cygnus.com) +Mon Feb 17 07:51:06 1992 K. Richard Pixley (rich at cygnus.com) - * listing.c, config/obj-aout.c: added intermixed - source/assembler file listings to files with stabs in them. + * nearly everything. flush ChangeLog, package as gas-1.92.1. + ChangeLog's prior to this are sketchy at best. I have logs. + They just aren't ChangeLogs. -Thu Jan 23 17:30:08 1992 Steve Chamberlain (sac at rtl.cygnus.com) - - * symbols.c(colon): if a symbol is being multiply defined as exactly - the same value, then don't cause a fatal error. This fixes - P00000616 - where a def _foo= . followed by foo: is seen. - -Wed Jan 8 11:26:40 1992 Steve Chamberlain (sac at rtl.cygnus.com) - - * config/obj-coffbfd.c: lint - * config/tc-h8300.c, config/tc-h8300.h: Too Many bug fixes - * config/tc-m68k.h, config/tc-sparc.h: Override default - listing options to give better effect. - - Added support for listings - * Makefile.in: include listing.[co] - * as.c: parse -l - * as.h: include listing.h, include listing hook into frag - * frags.c (frag_new): hook for creating line number info - * messages.c (as_warn, as_bad): remember message for listing - * read.c: add new pseudos to the table - * write.c: (relax_segment): need to cope with branches with 0 - offsets, so create M68K_AIM_KLUDGE- this came to light because - listings make lots of zero length frags. - * listing.c, listing.h: new files - -Mon Jan 6 06:13:23 1992 John Gilmore (gnu at cygnus.com) - - * config/tc-m68k.c (md_parse_option): Default to allowing - floating point opcodes with processors that support them. - -Sat Jan 4 16:34:16 1992 John Gilmore (gnu at cygnus.com) - - * as.h: Move redefine of xfree. - * config/ho-generic.h: Declare free(), since it's used without - ()s in obstack_begin. - * read.c: Use xmalloc, not malloc. - * expr.c, input-scrub.c, write.c: Avoid "know" macros - that cover more than one line, since this causes char strings - with embedded newlines. - -Wed Dec 11 18:13:07 1991 Steve Chamberlain (sac at rtl.cygnus.com) - * configure.in: handle rename of obj-coffbfd - * config/obj-coffbfd.c: lint, don't fixup relocs if H8300, use - tc_reloc_mangle to prepare relocation if one available - * config/tc-h8300.h: added tc_reloc_mangle routine - -Tue Dec 10 04:07:28 1991 K. Richard Pixley (rich at rtl.cygnus.com) - - * input-file.c: don't close a NULL file pointer. - - * Makefile.in: infodir belongs in datadir. - -Sat Dec 7 17:13:42 1991 K. Richard Pixley (rich at rtl.cygnus.com) - - * Makefile.in: fix fake-as target to also create as.new. - -Fri Dec 6 23:16:43 1991 K. Richard Pixley (rich at rtl.cygnus.com) - - * Makefile.in: install using INSTALL_DATA and INSTALL_PROGRAM. - correct include directory locations. added standards.text - support. - - * configure.in: mark this directory as target dependent. - -Thu Dec 5 22:46:23 1991 K. Richard Pixley (rich at rtl.cygnus.com) - - * Makefile.in: idestdir and ddestdir go away. Added - copyrights and shift gpl to v2. Added ChangeLog if it - didn't exist. docdir and mandir now keyed off datadir by - default. - -Wed Dec 4 10:28:48 1991 Steve Chamberlain (sac at cygnus.com) - - * config/obj-coff-bfd.c (crawl_symbol_chain): only move a - symbol to the end of a file if it really is external. - - -Sat Nov 30 23:03:59 1991 Steve Chamberlain (sac at rtl.cygnus.com) - - * as.h: reloc.h->aout/reloc.h. - * a.out.gnu.h: reloc.h->aout/reloc.h - -Thu Nov 28 13:21:41 1991 Steve Chamberlain (sac at rtl.cygnus.com) - - * config/obj-coff-bfd: made multiple sections with subsections - work. - * config/tc-h8300.c: made $ statement sep, and int alloc 2 bytes. - - -Mon Nov 25 17:26:22 1991 Steve Chamberlain (sac at cygnus.com) - - * as.c: (perform_an_assembly_pass): moved declaration of i to - avoid a syntax error. Now always create the three default - sections when in MANY_SEGMENTS mode. - * as.h: New improved way of specifying MANY_SEGMENTS - * configure.in: hds object format is now coff-bfd - * subsegs.h: add line numbers and section stuff to the - segment_info structure. (But go back later and fix.. this is - COFF specific) - - -Thu Oct 24 17:25:59 1991 Steve Chamberlain (steve at rtl.cygnus.com) - - * config/obj-coff.c (obj_coff_dim): Allows newline to end a - .dim statement. - -Mon Oct 21 09:25:33 1991 Steve Chamberlain (steve at rtl.cygnus.com) - - * configure.in: added ebmon entry. - * output-file.c (output_file_create, output_file_close) added - stuff to use bfd. - * write.c: more bfd support - * config/obj-coff.c config/obj-coff.h use bfd for swapping - header info. - * tc-a29k: added the reloc types we support now - - -Mon Oct 14 11:44:03 1991 Roland H. Pesch (pesch at cygnus.com) - - * doc/Makefile (as.ms): one more sed workaround for texi2roff - (as.mm, as.me): new targets - -Fri Oct 11 18:18:37 1991 Roland H. Pesch (pesch at cygnus.com) - - * doc/Makefile: new targets as.info, as.ms - doc/as.texinfo: minor changes for texi2roff-2 - Makefile.in: revise 'doc' target. - -Fri Jan 4 12:48:22 EST 1991 Jay Fenlason (hack@ai.mit.edu) - - * messages.c Moved as_perror from input-scrub.c Modified the - error messages to look better. - - * output-file.c Don't call as_fatal, just call exit() - - expr.c Slightly improve checking for foo-foo case in - clean_up_expression(). Detect foo: bar: ... foo-bar... - -Tue Dec 4 16:29:20 EST 1990 Jay Fenlason (hack@ai.mit.edu) - - * m68k.c Fixed an obscure bug involving AOFF mode with a - large constant displacement (Was forgetting to output the - extension word.) - - make-gas.com Added a three line patch from Eric Youngdale that - makes it possible to submit make-gas.com to a batch queue. - -Wed Nov 21 15:07:51 EST 1990 Jay Fenlason (hack@ai.mit.edu) - - * vms.c (VMS_TBT_Routine_END) Add a four line patch from - Eric Youngdale. - -Tue Nov 13 14:02:15 EST 1990 Jay Fenlason (hack@ai.mti.edu) - - * vms-dbg.c (VMS_DBG_record()) Another one character patch from - Eric Youngdale. - -Mon Oct 29 15:49:21 EST 1990 Jay Fenlason (hack@ai.mit.edu) - - * read.c Replace some as_warn calls with as_bad. - -Fri Oct 26 15:21:15 EDT 1990 Jay Fenlason (hack@ai.mit.edu) - - * i386.c, i860.c, ns32k.c Add const changes. - -Mon Oct 22 14:04:26 EDT 1990 Jay Fenlason (hack@ai.mit.edu) - - * sparc.c Add const changes. - - * make-gas.com define const= for VMS, since many older versions of - GCC don't work correctly with const under VMS. - -Thu Oct 18 12:44:11 EDT 1990 Jay Fenlason (hack@ai.mit.edu) - - * i860.c i860-opcode.h Added patches from rgb@mcc.com - - * read.c, symbols.c, vms.c, + new_file vms-dbg-module.c - Added Eric Youngdale's VMS debugging - patches, so debugging GCC output now works. - - * hash.c (hash_grow) Remember to blank out the wall entry in the new - hash table. This is important on systems where malloc() returns - non-zero storage. . . - -Tue Oct 16 10:11:35 EDT 1990 Jay Fenlason (hack@ai.mit.edu) - - * output-file.c (output_file_create) if output filename is given as - '-', write to stdout. - - * m68k.c Finally get the PCREL code to work right. Add relaxation of - PCREL stuff This small fix from Ken Woodland - (kenny%datacube.uucp@uunet.uu.net). - - * m68k.c Added some const declarations to constants. (md_relax_table, - md_pseudo_table, etc. . .) - -Thu Oct 11 11:15:10 EDT 1990 Jay Fenlason (hack@ai.mit.edu) - - * Makefile, read.c, write.c Include the i860 port. - (New files i860.c i860-opcode.h i860.h) - - * m68k.c Fix some addressing modes, (AOFF, AINDEX, etc) to work in - PC relative mode. - - * (all over) Raeburn's const hacking. This reduces the data-space size by - declaring many tables, etc, as 'const'. - -Mon Oct 22 22:48:22 1990 John Gilmore (gnu at cygint) - - Make gas work if you turn on the know() checks. - - * app.c: Only pass a single space through: the one after - the opcode. All other whitespace is removed, to match the - expectations of the parser in read.c. - - * as.h: Remove obsolete comments. Remove JF's NDEBUG so - that know() can really work if you turn it on. Make - SEG_MAXIMUM_ORDINAL == SEG_REGISTER. - - * expr.c (operand): Change BITS_PER_INT to 8*sizeof(int). - - * input-scrub.c: strlen("\0") doesn't return 1... - (as_where): Add space after line number in errors, like gcc. - - * m68k.c (s_bss): Fake .bss into data section 255. - We can't cope with a real "BSS section" yet, but we can at - least do the right thing less efficiently (with lots of - zeroes). - - * read.c: Turn lots of as_warn()'s into as_bad()'s. - - * read.h (SKIP_WHITESPACE): Replace last instance of ASSERT() - with know(). - - * sparc.c (s_seg): We can't put frags into the BSS segment - yet, so just fake bss seg as 255th data segment. - - * vax.c: Remove \'s from continued macro *parameters*. These - must have been added after the last time someone turned on - know() checking... - - * write.c (relax_segment): Refine what we know() about the - symbols referenced during relaxation. - - * Makefile (OTHER_ALIGN): Remove, handled in tables now. - Flip options a bit. These options really ought to go - elsewhere. - -Sun Oct 21 03:57:21 1990 John Gilmore (gnu at cygint) - - Sun-3 fixes. - - * expr.c, write.c: Missing semicolon after know(). - - * write.c (fixup_segment): Allow pc-relative accesses to undefined - external symbols. Previously this would turn off pc-rel calc - of displacement, while leaving pc-rel opcode alone, botching. - - * m68k.c (m68k_ip): Allow pc-relative effective addresses - for source operands. "pea" instructions are a good example - where we can shorten from abs long to pc+16bit. - (md_convert_frag): Fix "JBSR" comments to refer to "JSR", the - actual instruction. Insert comments about bug in 68000 bcc - and dbcc long code (that doesn't get exercised much). Add - comments about long pcrel displacements for -pic. Remove - "this code has not been tested" comment. - (md_estimate_size_before_relax): Now that fixup_segment - doesn't shortcircuit pc-relative fixups for undefined symbols, - only output them if -pic; else turn them absolute, which is - slightly faster. More JBSR->JSR comments. - (md_parse_options): Parse -pic. - -Fri Oct 19 14:35:20 1990 John Gilmore (gnu at cygint) - - * Make sparc assembler more compatible with Sun assembler. - sparc.c: reformat pseudo-op table to match main table. - (md_assemble): Add SPECIAL_CASE_FDIV to assemble FDIV* - instructions as fdiv followed by fmovs to get around chip bug. - (s_common, s_seg): Accept "bss" section name. - (md_assemble): Handle "set" instructions with absolute - operands, that only take one instruction rather than two. - sparc-opcode.h (fdiv*): Mark instructions "S"pecial. - subsegs.c (subseg_change): Move tail pointer too. - symbols.c (colon): Allow new definitions to override .comm symbols, - as in VMS. Sun CC depends on this. - write.c (new_fix): Always take r_type argument, not just on sparc. - Chain fixP's in order, using tail pointer, so relocation - records come out in forward order like Sun as. Remove SPARC - ifdefs. - write.h: Add seg_fix_tailP, data_fix_tailP, text_fix_tailP. - - * am29k.c: Use s_align_bytes rather than a local copy. - - * read.c (s_align): Rather than ifdef it, make two functions, - s_align_bytes and s_align_ptwo. Individual pseudo-op tables - can call whichever one they like. - - * write.c (append): Move from append.c to here. - append.c: Remove file. - - * Makefile (MDSRC, mdsrc): Easy way to edit all md.c's. - Fix options. Add option for -DDEBUG for know() and assert(). - Remove append.c, am29k.h. Don't build special read-sparc.o. - Remove sparc.h. "make clean" removes am29k .o's. Add - dependencies on reloc.h. - -Thu Oct 18 17:56:34 1990 John Gilmore (gnu at cygint) - - * Generalize sparc extensions to relocation info. Gas now - keeps relocation information internally in a different format - than how it is stored in the resulting .o. md_ri_to_bytes() - converts to external format. md_reloc_size says how large - each relocation record is in external format. - sparc.h: Remove this file. Rename to reloc.h. Rename struct - to reloc_info_generic. - reloc.h: Add relocation types for AMD 29000. - read.c, write.c: Always call fix_new with reloc-type argument. - write.c (emit_relocations): Make md_ri_to_bytes write directly - to output area rather than overwriting its argument then - bcopying it. - md.h: Declare md_reloc_size and md_ri_to_bytes. - i386.c, am29k.c, vax.c, ms32k.c, m68k.c, sparc.c: include reloc.h. - (md_reloc_size): Specify correct value. - (md_ri_to_bytes): Convert format from internal to external. - - write.c (write_object_file): Call md_section_align() which - rounds section sizes up if desired. - sparc.c (md_section_align): Round to 8 byte boundary. - i386.c, am29k.c, vax.c, ns32k.c, m68k.c (md_section_align): Nop. - -Mon Oct 15 22:06:11 1990 John Gilmore (gnu at cygint) - - Changes in support of the AMD 29000 version of gas. - - * am29k-opcode.h: Add dummy entry to end so we can examine - item N+1 without exceeding table. - - * am29k.h: New include file, derived from sparc.h. Kludged - together, still needs major work to get relocation working. - - * am29k.c: New file, derived from sparc.c. - Put 29k-specific ASM29K pseudo-ops into table. - Change comment_chars to ASM29K. - Change s_seg to s_use. - Change s_sparc_align to s_29k_align, default operand to 4. - (define_some_regs): Define special register names. - (md_begin): Preprocess opcode table to mash together all - the variants of single opcodes. This simplifies later handling. - Call define_some_regs to preset special reg names. - (parse_operand): Add, parses out an operand from a stmt. - (machine_ip): Simplify, since 29K is simpler asm language. - Handle the various keyletters in the opcode table. - - - Handle include files in the assembler, with a .include - pseudo-op. - * as.h (input_scrub_include_file): declare. - * as.c (perform_an_assembly_pass): Avoid buffer hacking. - Start us off in text segment. - * read.c (read_a_source_file): Take a name as argument, - internalize all buffer handling. Don't start a new text - subsegment on each entry. Actually use the start and end - pointers returned by input_scrub_next_buffer. - (s_include): Call input_scrub_include_file for .include. - * input-scrub.c: Fix comments. - (struct input_save): Add, for saving state at .include. - (input_scrub_push, input_scrub_pop): Add, push & pop state. - (input_scrub_begin): Initialize next_saved_file. - (input_scrub_end): Free buffer. - (input_scrub_include_file): Add, to include a file. - (input_scrub_close): Add, to close a file. - (input_scrub_next_buffer): Set buffer-start address for - caller. If we hit EOF and were included, pop to previous file. - * input-file.c: Remove old includes. Remove old file-descriptor - hacking code, that was commented out. - (struct saved_file): Add, for saving state at .include. - (input_file_push, input_file_pop): Add, push & pop state. - (input_file_open): Don't buffer all files in one place. - (input_file_close): Add, close input file. - * input-file.h: Declare new functions. - * app.c: (struct app_save): Add, for saving state at .include. - (app_push, app_pop): Add, push and pop state. - (do_scrub_next_char): Move its static state variables out so - they can be saved and restored. - - - * app.c: Allow overriding of character meanings by machine - dependent strings. Avoid wiring character constants into app.c. - (do_scrub_begin): New meanings override old ones, not "OR" them. - Only handle /* comments if / is not already in use. - (do_scrub_next_char): Reorganize mass of nested if's - into a switch for speed. Don't assume ';' is line terminator. - Reorganize switch on characters, into a switch on their (machine- - dependent) lexer table meanings. - - - Encapsulate knowledge of segment types in fewer places. - This allows us to add the "SEG_REGISTER" type, as well as - providing flexibility for eventual COFF/ELF support. - * struc-symbol.h (symbol_to_segment, symbol_to_segment_type, - set_symbol_segment, set_symbol_segment_keep_ext, - segment_name): Define macros to encapsulate this info. - * as.h: Remove externs for seg_name, seg_N_TYPE, N_TYPE_seg. - * symbols.c (symbol_new): Change 'type' arg to 'seg'. - * expr.c, i386.c, m68k.c, ns32k.c, read.c, symbols.c, vax.c, - write.c: Use macros. - * i386.c, m68k.c, ns32k.c, vax.c, write.c: Change 2nd arg type of - md_estimate_size_before_relax. - * expr.c, read.c: Change 'type' arg to symbol_new. - * read.c, symbols.c, vax.c, write.c: Move md.h to end of includes. - - - Allow expressions to evaluate to registers. - * as.h: Add SEG_REGISTER. - * struc-symbol.h: Add fake N_REGISTER type. - * subseg.c: Add types to tables. - * expr.c (operand): Symbols of SEG_REGISTER type are - immediately evaluated like those of SEG_ABSOLUTE. - (clean_up_expression): Clean up SEG_REGISTER exprs. - - - Allow machine descriptions to cleanly extend the set of - possible operands. - * expr.c (operand): Call md_operand before rejecting an - operand as unacceptable. - * md.h: declare. - * i386.c, ns32k.c, m68k.c, sparc.c, vax.c: Define null function. - * am29k.c (md_operand): Use this for %% and & prefix operators. - - - Allow machine descriptions to cleanly permit symbols to be - predefined upon first usage. - * symbols.c (symbol_find_or_make): Call md_undefined_symbol - before making an undefined symbol. - * md.h: declare. - * i386.c, ns32k.c, m68k.c, sparc.c, vax.c: Define null function. - * am29k.c (md_undefined_symbol): use this for the local and - global register names; since there are hundreds of them, it - only defines them upon their first use. - * expr.c (operand): Call symbol_find_or_make rather than - roll our own undefined symbols. - - - Miscellaneous changes: - - * as.h (know): Make this useful if DEBUG defined. - - * write.h: Support SPARC-like relocation throughout all - versions. - - * read.c (read_a_source_file): Report the name of invalid - pseudo-ops. Don't double-report junk characters. Close the - input file, which gas never used to do. - (ignore_rest_of_line): Report junk chars in ascii if - printable. - (s_ignore): Ignore entire statement; used for 'listing - control' statements from ASM29K, e.g. .eject. - - * read.c (s_lsym): Handle register equates too. - - * read.c: Add most ASM29K pseudo-ops to the master table. - Not all are implemented yet. - - * cond.c: New file, for functions implementing conditional - assembly pseudo-ops: .ifdef, .ifndef, .else, .endif, .ifseq, - .ifsne, .end. So far, they are just stubbed out. - - * read.c (pobegin): Allow the machine dependent pseudo-op - table to override the generic one. Remove #ifdef SPARC - on .word, since it can now be overridden. - - * expr.c (operand): Support radix-2 constants. Kill off - support for octals with digits '8' and '9'. Initial steps - toward more general support for local-labels. - - * symbols.h (symbol_table_lookup): Remove macro, change all - occurrences (in read.c, expr.c, symbols.c) to symbol_find. - - * read.h (is_end_of_line): Define for external use. - - * i386.c (alloca): Use builtin_alloca or include or extern. - - * Makefile: Add ALL and all: entries. Add asm29k entries. - Add cond.c and cond.o. Remove special handling for messages.o. - Add lint entry. - -Thu Sep 27 13:43:49 EDT 1990 Jay Fenlason (hack@ai.mit.edu) - - * m68k.c (get_num) Fix so that 1:w is treated properly. - - * Makefile Replace references to a.out.h with a.out.gnu.h - -Tue Sep 25 15:50:36 EDT 1990 Jay Fenlason (hack@ai.mit.edu) - - * sparc.c (md_number_to_imm) Fix so that RELOC_32 locations contain - zero, so that it will work with some sparc loaders which don't assume - that the locations in question do. A xix line patch from Michael Bloom - (usc!srhqla!quad1!psivax!ttidca!mb@zaphod.mps.ohio-state.edu) - -Mon Sep 24 11:43:15 EDT 1990 Jay Fenlason (hack@ai.mit.edu) - - * as.c #include if _POSIX_SOURCE defined. This because - uses pid_t that's defined in it. - - * m68k.c reverse the sense of -l option, and allow :w and :l to - override the default size of AOFF indexes. - - Also, allow -l to shorten branches to unknown labels from LONG to WORD. - -Thu Sep 13 17:05:09 EDT 1990 Jay Fenlason (hack@ai.mit.edu) - - * vax.c (md_parse_option) Don't print a warning msg if given -J - -Wed Sep 5 14:26:14 EDT 1990 Jay Fenlason - - * expr.c (operand) Don't get garbaged high-order bits when given a - lot of leading zeroes. - -Tue Sep 4 11:40:21 EDT 1990 Jay Fenlason - - * read.c (pseudo_set) Compain if we're setting the symbol to the - difference of two symbols which are in different frags. (We can't - find out how far apart they are.) - -Wed Aug 15 12:18:58 EDT 1990 Jay Fenlason - - * m68k.c (m68k_ip_op) Dyke out the code that deals with parsing - :[wl] at the end of expressions since it is handled in get_num() - and this was putting the result in the wrong place anyway. - Corrected a couple of other references to ->isiz instead of con?->e_siz - -Mon Aug 13 15:53:46 EDT 1990 Jay Fenlason - - * read.c Handle .align specially on the sparc, or any other machine - where OTHER_ALIGN is defined. Added option and comments about it - to Makefile. -v -Fri Aug 10 12:24:33 EDT 1990 Jay Fenlason - - * m68k.c (get_num) Handle SEG_PASS1 expressions. - -Mon Aug 6 16:32:29 EDT 1990 Jay Fenlason - - * write.c (fixup_segment) Added two patches for the NS32k - and SEQUENT A six line patch from Ian Dall - (asgard!aegir!hugin!augean!sibyl!ian@munnari.oz.au) - -Wed Aug 1 13:30:48 EDT 1990 Jay Fenlason (hack@ai.mit.edu) - - * m68k.c Include REGISTER_PREFIX ifdefs. - - * write.c Include LOCAL_LABEL() and DOT_LABEL_PREFIX feature. - - * vax.c (md_parse_option) Accept -H option. - - * vms.c New version of case hasher, etc. These from Eric Youngdale - - -Fri Jul 20 13:39:02 EDT 1990 Jay Fenlason (hack@ai.mit.edu) - - * README Added README.APOLLO and README.COFF stuff - -Wed Jul 18 16:29:22 EDT 1990 Jay Fenlason (hack@ai.mit.edu) - - * Makefile Added option for SEQUENT_COMPATABILITY - - * ns32k.c Add configurable syntax feature from - ian@sibyl.eleceng.ua.oz@augean.ua.oz.au - and SEQUENT_COMPATABILITY - - * ns32k-opcode.h Add configurable syntax feature. - -Mon Jul 16 11:44:14 EDT 1990 Jay Fenlason (hack@ai.mit.edu) - - * write.c (relax_segment) On ns32k, add fragP->fr_pcrel_adjust to - aim. - (fixup_segment) On ns32k, don't subtract size from - add_number on pcrel external symbols. - - * ns32k.c (md_relax_table) Use correct max displacements. - This is a six-line patch from ian@sibyl.eleceng.ua.oz.au - - * ns32k.c (md_atof, convert_iif) Emit floating point numbers in - the correct byte order. A seven line patch from - ian@sibyl.eleceng.ua.oz.au - - * ns32k.c (all over) Some lint fixes. - -Mon Jul 9 13:17:00 EDT 1990 Jay Fenlason (hack@ai.mit.edu) - - * app.c (do_scrub_next_char) If a comment is #{whitespace} - don't treat the next line as comment also. - - * m68k.c (...) Accept apc@(num:[wl]), etc. - - * i386.c (md_assemble) Get bitfields correct when doing cross - assembly to 386. A two line patch from Michael Bloom. - (usc!srhqla!quad1!ttidca!mb@zaphod.mps.ohio-state.edu). - - * README.APOLLO a new file with vasta@apollo's name, address - and phone # in it. - - * make-gas.com Deleted references to gdb source files. - -Fri Jul 6 14:34:27 EDT 1990 Jay Fenlason (hack@ai.mit.edu) - - * i386.c Ignore the .optim directive - - * input-file.c Change from _IOLBF to _IOFBF in setbuffer emulation - for SYSV. - -Mon Jun 18 15:36:49 EDT 1990 Jay Fenlason (hack@ai.mit.edu) - - * sparc.c #ifdef DONTDEF s_sparc_align, since it isn't called from - anywhere. - -Fri Jun 15 15:53:30 EDT 1990 Jay Fenlason (hack@ai.mit.edu) - - * vax.c (md_parse_option) make the code agree with the documentation - on the behaviour of the -d option. - -Thu Jun 7 14:23:54 EDT 1990 Jay Fenlason (hack@ai.mit.edu) - - * atof-ieee.c (gen_to_words) Assemble 0r-0 correctly. - - * Makefile Remove last references to gdb*.c files. - - * version.c New version 1.36 - -Tue May 22 13:22:26 EDT 1990 Jay Fenlason (hack@ai.mit.edu) - - * Makefile Mention a work-around for a possible problem with HPUX7.0 - -Mon May 21 14:06:04 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * sparc.c (sparc_ip): Change error message from "not in hash table" - to "unknown opcode". - -Wed May 16 15:33:14 EDT 1990 hack@wookumz - - * i386.c (i386_operand) Print error msg if given an operand like - 4(mumble) which we can't parse. - - * m68k.c (md_assemble) Add '3' to the list of operand-places that - can be found in 'symbol-dependent info'. Also change - 'confusing width' diagnostic to something more meaningful. - -Fri May 11 12:09:21 EDT 1990 hack@wookumz - - app.c (do_scrub_next_char) Don't flush the line after a line - consisting of a single '/' A one-line patch from Mike Kupfer - (kupfer@orc.olivetti.com) - - * i386.c (md_assemble) Call frag_wane() before calling frag_new() - A one line patch from Steve Bleazard (steve@robobar.co.uk - -Tue May 8 12:56:25 EDT 1990 hack@wookumz - - * atof-generic.c (atof-generic) Modified the Infinity detection code - to accept 0rinfinity and 0r-infinity as well as 0rinf and 0r-inf - -Thu Apr 26 15:17:31 EDT 1990 hack@wookumz - - * atof-ieee.c Change value of NaNs to 0x7fff ffff (float) and - 0x7fff ffff ffff ffff (double) If you want some other value for - NaN, use .long and spell it out yourself. - - atof-generic.c (atof_generic) Cleaned up code that detects NaN - and Inf. - - vax.c (md_assemble) print a useful error message if expression() - returns SEG_PASS1 or SEG_DIFFERENCE and we can't deal with those. - -Thu Apr 19 10:30:47 EDT 1990 hack@wookumz - - * input-scrub.c (AFTER_STRING) Make AFTER_STRING contain a null - so that the strstr() call when looking for "#NO_APP" after a "#APP" - will work. A two character patch from Bruce Robertson - (bruce@heather.pooh.com) - - * Makefile, i386.c Use atof-ieee.c instead of atof-i386.c - -Mon Apr 16 16:20:55 EDT 1990 hack@wookumz - - * m68k.c (md_relax_table) Many of the offsets were off by two. - Fixed some generic spacing problems thoughout the file. - -Thu Apr 12 12:22:35 EDT 1990 hack@wookumz - - * sparc.c (md_ri_to_chars) Handle little-endian cross assembly. - - * write.c (relax_segment) Compare addresses correctly to avoid - accidentally relaxing a branch that we don't have to. - These small changes from John Gilmore (gnu@toad.com) - -Fri Apr 6 12:52:15 EDT 1990 hack@wookumz - - * Makefile, expr.c symbols.c Correctly document the SUN_ASM_SYNTAX - option, and make it work. - -Tue Mar 20 12:46:59 EST 1990 - - * as.c (main) Only trap SIGHUP, SIGINT, SIGPIPE, and SIGTERM, - and only if they aren't being ignored. A three line patch - from Paul Eggert (eggert@twinsun.com) - - * write.c (relax_segment) Correct typo 'growth - ' should have been - growth = - - * atof-vax.c (next_bits, flonum_gen2vax) Clean up by sharing some - variables. While we're at it, fix next_bits so that it - doesn't use littlenums that don't exist. . . - -Tue Mar 13 16:23:21 EST 1990 hack@wookumz - - * Rename atof-m68k.c atof-ieee.c - - * Delete atof-ns32k.c - - * m68k.c sparc.c ns32k.c atof-ieee.c Call atof-ieee instead of - atof-m68k or atof-ns32k - - * Makefile Compile with atof-ieee.c instead of atof-ns32k.c or - atof-m68k.c - -Mon Mar 12 14:06:55 EST 1990 hack@wookumz - - * as.c If the signal handler gets called twice, exit immediatly. - - * ns32k.c Call gen_to_words with a pointer of the proper type, and - call md_number_to_chars to put the results in the proper byte-order. - Whoever wrote this code was *sloppy*! - - * Makefile ns32k.o depends on ns32k.c - - * vax.c (md_parse_option) If VMS, accept -+ and -h options. - - * vms.c (VMS_Case_Hack_Symbol) Replace #if NO_CASE_HACKING - with references to the -h option. These small VMS patches - from Angel Li (angel@flipper.miami.edu). - -Thu Mar 8 19:18:59 EST 1990 hack@wookumz - * vms.c Some trivial patches from Eric Youngdale - (YOUNGDALE@v6550c.nrl.navy.mil) - -Wed Mar 7 17:12:09 EST 1990 hack@wookumz - * make-gas.com (Define error as as_fatal when compiling vax.c and vms.c - A two line patch from Eric Youngdale - (YOUNGDALE@v6550c.nrl.navy.mil) - -Tue Mar 6 16:01:09 EST 1990 hack@wookumz - - * Makefile Include ns32k options in makefile. A small patch from - David Taylor (taylor@think.com). - - * as.c read.c write.c Makefile #ifdef DONTDEF out all the gdb - symbol stuff, since it isn't used anymore and it doesn't work. - -Mon Mar 5 14:51:04 EST 1990 hack@wookumz - - * i386.c (md_assemble) Replace memchr() with index(). - - * as.c Trap signals 1 through NSIG, print an error msg, and don't - produce an object file. - - * m68k.c Added a hack so that fsincosx fpx,fpy:fpz works. - - * messages.c New function: as_bad This is like as_warn, except - -W doesn't disable it, and calling it inhibits production of an - object file and causes a non-zero exit code. - -Tue Feb 13 14:25:53 EST 1990 hack@wookumz - * Makefile Include G0 and LOADLIBES for Sequent Symmetry. - Based on a small patch from Johan Widen (jw@sics.se) - -Thu Feb 1 14:08:58 EST 1990 hack@wookumz - * m68k.c Replace 'abort' with 'abort()' which will work. - -Wed Jan 24 17:15:08 EST 1990 hack@ai.mit.edu - - * read.c (ignore_rest_of_line) Have it print the first junk char - in both decimal and %c form. - - (read_a_source_file) On bad pseudo-op, print out the unknown - pseudo-op's name. - -Tue Jan 23 13:12:48 EST 1990 hack@ai.mit.edu - - * read.c (pseudo_set) If the symbol is external, have it remain - external. - - * i386-opcode.h Allow jc as a synonym for jb and jnc as a syn for jnb. - - -Wed Jan 3 09:35:31 EST 1990 hack@ai.mit.edu - - * ns32k.c [cpureg_032] Change register id of psr from 0x0b to 0x0d - * ns32k-opcode.h Change shift-counts for lsh and lshd - to one byte instead of 2 and 4. - A Trivial patch from John F. Peters (think!ames!practic.com!jfp@eddie) - -Tue Dec 5 16:37:44 EST 1989 hack@ai.mit.edu - - * ns32k.c (md_create_{long,short}_jump) Six line patch from - John F Peters (think!ames!vine!practice.com!jfp) to use the - correct addressing mode and byte-order for broken-word stuff. - - * write.c (write_object_file) One line patch to call fix_new_ns32k - with the correct # of args. - -Fri Dec 1 16:44:21 EST 1989 hack@ai.mit.edu - - * atof-generic.c, flonum-mult.c A real fix for the trailing-zeroes - problem from Georg Feil (ghfeil@white.toronto.edu) (two line change) - -Mon Nov 27 15:30:46 EST 1989 hack@ai.mit.edu - - * i386-opcode.h Fixed opcode-table entry for ljmp. A one char - patch from eliot@mgm.mit.edu - -Mon Nov 20 12:41:28 EST 1989 hack@ai.mit.edu - - * expr.c Replace the generic_buffer hack with a more portable one */ - - * atof-generic.c (atof_generic) Ignore trailing zeroes after a decimal - point. For some reason trailing zeroes (but not trailing nonzeroes) were - causing loss of precision. I don't know why. . . - - * vms.c Change copyright notice. Install changes from Kenneth Adelman - (adelman@tgv.com) for c++? (A dozen lines or so) - -Mon Nov 13 11:48:44 EST 1989 hack@ai.mit.edu - - * Makefile Add BINDIR and use it to control where the executable is - installed. - - * i386.c Use __builtin_alloca if possible (trivial patch from - Marco S. Hyman pacbell!dumbcat!marc) - -Mon Nov 6 18:24:47 EST 1989 hack@ai.mit.edu - - * version.c New version: 1.35 will be distributed with the - 1.36 gcc release. - -Mon Oct 30 10:38:11 EST 1989 hack@ai.mit.edu - - * atof-m68k.c (atof_m68k) Don't put the bits[] array on the stack, - since it may be pointed to after atof-m68k exits. - -Tue Oct 24 11:15:57 EDT 1989 hack@ai.mit.edu - - * atof-m68k.c Added #define for bcopy on USG systems. - #ifdef TEST the print_gen() function. - - * a.out.h if USE_HP_INC_HDR then use ../binutils/hp-include/a.out.h - -Fri Oct 13 14:36:48 EDT 1989 hack@ai.mit.edu - - * vax.c (all) Ran vax through indent -gnu to make it readable. - - vax.c (vip_op) Correctly assemble code like jmp $*0x11223344 - by setting vip_nbytes to 4 when using an immediate address. - I hope this works! - - m68k.c (s_proc (new)) Added s_proc no-op pseudo-op. - - Makefile Added instructions for compiling on Sequent Symmetry - and HP 9000/300. - - a.out.h Modified to compile on Sequent and HP above. (HP port - based on a msg from asjl@comp.vuw.ac.nz (real name unknown)). - -Tue Oct 10 14:39:44 EDT 1989 hack@ai.mit.edu - * vax.c (vip_op) Fixed a typo in an error msg and cleaned - up some spacing stuff. - -Wed Sep 27 19:07:12 EDT 1989 hack@ai.mit.edu - - * app.c (do_scrub_next_char) Fixed parsing of - # "file" garbage - text so that it'll work again? (8 line patch from Mike Hibler - (mike@cs.utah.edu)) - -Mon Sep 18 16:26:01 EDT 1989 hack@ai.mit.edu - - * app.c (do_scrub_next_char): Modify parsing of /* ... */ to work - on the text /* ****/ - - * sparc.c (sparc_ip): Don't abort on insns that use the Alternate - Spaces. Try to assemble them correctly. - -Thu Sep 14 11:42:44 EDT 1989 hack@ai.mit.edu - - * sparc.c (md_number_to_imm) Dozen line patch from jkp@sauna.hut.fi - (Jyrki Kuoppala) so that gas output will work with shared libraries. - - * ns32k.c Include instead of if USG defined. - - (md_end) free(freeptr_static) instead of free(freeptr) . - - * atof-ns32k.c Include as.h so that sysV stuff (bzero) will be - defined if needed. These ns32k changes from - nixbur!mollers.pad@seismo.css.gov (Josef Moellers) - -Fri Sep 1 11:39:52 EDT 1989 hack@ai.mit.edu - - * atof-m68k.c (gen_to_words) Get the sign right on negative - floating-point numbers. - -Wed Aug 30 13:59:57 EDT 1989 hack@ai.mit.edu - - * Makefile Remove the rest of the $< entries that kill sun make - -Fri Aug 25 15:00:30 EDT 1989 Nobody You Know (hack@ai.mit.edu) - - * atof-m68k.c (gen_to_words) deal with denormalized floating-point - numbers. - -Tue Aug 22 02:03:05 1989 Roland McGrath (roland at hobbes.ai.mit.edu) - - * Makefile (gas-dist.tar): Put ChangeLog in the tar file. - - * version.c: Added comment telling Jay Fenl--I mean people--not to put - changes in version.c, but to use ChangeLog instead. - - * version.c (version_string): Put "GNU" in all-caps. - - * version.c: Moved all comments about changes to ChangeLog (this file). - Many anonymous entries have been attributed to Jay Fenlason (hack). - -Thu Aug 17 15:53:57 1989 Jay Fenlason (hack at apple-gunkies.ai.mit.edu) - - * Makefile: Removed $< references that seem - to choke some versions of make. - - * frags.c (frag_grow): Fixed to deal with requests for very - large frags (larger than frags.chunk_size). - - * app.c (do_scrub_next_char): Have it ignore any characters - after the filename in a # line "filename". - - * sparc.c (s_common): On an error, don't print out - input_line_pointer past the end of the line where the error is. - - * atof-generic.c (atof_generic): Accept any case for - inf and nan. - - * m68k.c (m68_ip): Don't use PC-relative mode for alterable - addressing modes. - -Tue Aug 15 04:58:36 1989 Roland McGrath (roland at apple-gunkies.ai.mit.edu) - - * sparc.c (md_begin): Rewrote this function to perform consistency - checks with the new opcode table. - -Fri Aug 11 16:01:16 1989 Roland McGrath (roland at apple-gunkies.ai.mit.edu) - - * sparc-opcode.h (struct sparc_opcode): Replaced `mask' field with - `lose'; removed `last' field. Updated all opcodes accordingly. - Fixed several opcodes that generated the wrong instructions. - sparc.c (md_begin, sparc_ip): Changed to use new struct sparc_opcode. - -Thu Aug 3 14:44:24 1989 Jay Fenlason (hack at apple-gunkies.ai.mit.edu) - - * Makefile (a32k): Use read- and write-ns32k.o - * ns32k.c (encode_operand): Make sure pcrel_adjust starts out zeroed. - * read.c (cons): Call fix_new_ns32k() if NS32K is defined. - * write.c (write_object_file): Ditto. - These so that .word sym-sym (etc) will produce values with - the proper byte-order. - -Wed Aug 2 12:55:?? 1989 Jay Fenlason (hack at apple-gunkies.ai.mit.edu) - - * sparc.c (comment_chars[]): Removed '|' because it was causing - problems. Probably not the best fix, since I suspect other - assemblers (68020) may get | in .stabs also, and the 68020 needs - the '|' comment character. - -Mon Jul 31 09:22:28 1989 Roland McGrath (roland at apple-gunkies.ai.mit.edu) - - * sparc.c (sparc_ip): Allow the characters [0123] in opcodes. - -Tue Jul 25 16:32:12 1989 Jay Fenlason (hack) - - * atof-generic.c (atof_generic): Tried to keep - size_of_digits_in_littlenum from going negative. - - * sparc-opcode.h: Added duplicate [i+1] entries to go with - the [1+i] entries already there. A kludgy fix, but it works. - -Mon Jul 24 17:20:03 1989 Jay Fenlason (hack) - - * write.c (relax_segment): Modified rs_org code so it won't - occasionally dump core. - - * write.c (pseudo_set): Modified SEG_DIFFERENCE to (perhaps) - allow one to set a symbol to the difference of two other symbols. - - * ns32k.c (convert_iif): Moved size_so_far+=size and size=0 inside - the check for a valid type. - - * sparc-opcode.h: Modified the entries for std "q,[1+i]", "D,[1+i]", - and "Q,[1+i]". - -(In version 1.34) Jay Fenlason (hack) - - * Makefile: Reorganized, added stuff to make asparc. - - * sparc.c, sparc-opcode.h, sparc.h: Sparc port. - - * write.c: Set the size of text and bss segments to a multiple of eight - bytes. - - * m68k.c: Moved .single pseudo-op to machine independent part. - - * atof-generic.c: Fixed type in #ifdef __GNUC__. - - * sparc-opcode.h: Handle "mov REG, %y". - - * make-gas.com: Know that error.c no longer exists. - - * sparc.c: Handle [expr+reg]. - Don't call getExpression when looking for an immediate and getting - something that starts with % and isn't %hi or %lo. - - * Teach the 68k about long conditional branches. - -(In version 1.33) Jay Fenlason (hack) - - * Use __builtin_alloca if available. - - * README: Added more instructions for reporting bugs. - - * ns32k-opcode.h: Changed the acbb, acbw, and acbd insns. - - * vax.c: Replaced instances of LENGTH[STRING] with STRING[LENGTH]. - - * ns32k.c (encode_operand): Increased max size of bit field for exts - and inss instructions from 31 to 32 bits. - - * flonum-mult.c (flonum_multip): Fixed typo. - - * m68kc.: Allow #32 to be the same as #0 for bit-field ops. - - * make-gas.com, version.c, hex-value.c, flonum-const.c: VMS fixes. - - * ns32k.c, ns32k-opcode.h: More fixes from taylor@think.com. - Mostly typos in comments, etc. - - * ns32k-opcode.h: Fixed size of immediate operands to andw and andd - instructions. - -(In version 1.32) Jay Fenlason (hack) - - * read.c (s_set): Fixed misnamed variable. - - * as.c: Don't hang if given an invalid option. - - * m68k.c: Fixed bug in creating absolute long addresses for branches. - - * ns3k*: Some small ns32k patches. - - * m68k.c: Recognize 0rnan, 0rinf, 0r-inf. - - * app.c: Don't dump core on unterminated strings. - - * symbols.c: Give reasonable error messages. - - * ns32k*: Allow -m32032 and -m32532 options. - - * atof-*.c: Added support for NaN, Inf, and -Inf in atof_generic and - the various descriptions. - - * m68k.c (add_fix): Replace occurrences of "width==" with - "(width)==". This correct a precedence problem. - - * write.c, struc-symbol.h, m68k-opcode.h, m-hpux.h, Makefile: Changes - for HP-UX from Chris Hanson (cph@kleph.ai.mit.edu). - - * m68k-opcode.h: Reorder movem insns so gdb will see the ones using the - register list syntax first. - - * symbols.c (colon): Give more useful error messages when something was - defined as a .comm and is now trying to be defined locally. - Also, redefining a symbol is a fatal, not a warning. - - * m68k.c: Fixed a bug in using bignums as literal bit patterns for - floating-point numbers. - -(In version 1.31) Jay Fenlason (hack) - - * i386*: More patches. - - * Moved machine-dependent option parsing into the machine-dependent - source files. - -(In version 1.30) Jay Fenlason (hack) - - * i386*: New new version. - - * atof-m68k.c: Changed to be smaller, with somewhat better modularity. - Also fixed an obscure bug wherein next_bits would return random bits. - - * m68k.c: Be more careful about creating PC-relative addressing modes - on the 68000 and 68010. - - * frags.c (frag_new): Zero out the new frag. - - * Don't choke on "foo= bar" or on formfeeds. - - * read.c: Allow Sun-syntax local labels #ifdef SUN_ASM_SYNTAX. - * m-sun3.h: Defined SUN_ASM_SYNTAX. - -(In version 1.29) Jay Fenlason (hack) - - * i386.c: Newer version that fixes a bug wherein a jump instruction - would be split between two frags. - - * i386*: New version. - - * m68k.c: #ifdef M_SUN and -m68010, produce Sun-2 executables. - -(In version 1.28) Jay Fenlason (hack) - - * m68k.c: Added .single pseudo-op. - - * Made ". = X" and ".set .,X" equivalent to ".org X". - The pseudo-symbol "." has the value of the location the assembler is - currently assembling to. - -(In version 1.27) Jay Fenlason (hack) - - * Merged ns32k and i386 support. - -(In version 1.26) Jay Fenlason (hack) - - * Added partial ns32k support. - - * Added RMS's evil .word misfeature. Invented the -k (kludge) option - to warn that this misfeature was used. - - * Modified some files to get rid of warnings from GCC. - - * Added fix so that / can also be a comment character by itself. - -(In version 1.25) Jay Fenlason (hack) - - * Installed patches for VMS. - - * as.h (SIZEOF_STRUCT_FRAG): Added space before backslash-newline. - - * messages.c: Fixed typo. - - * app.c: Handle : correctly. - - * error.c: Removed; no longer used. - - * m68k-opcode.h: Added fnop. - Fixed to correctly handle fmovem with a register list and - non-predecriment addressing mode. - - * m68k-opcode.h: Fixed to know about long form of FBcc insns. - - * write.c: Warn if a fixup ended up being wider than its field width. - -(In version 1.24) Jay Fenlason (hack) - - * Accept and ignore -mc68010 and -m68010 switches. - - * Correctly assemble long subroutine calls on the 68000 without using a - 68020-specific instruction. - - * When calling with no filenames, read stdin. - -(In version 1.23) Jay Fenlason (hack) - - * app.c: Rewritten. - - * xmalloc.c, xrealloc.c: Replaced to work with GCC. - -(In version 1.22) Jay Fenlason (hack) - - * write.c: Fixed a VMS bug. - - * m68k.c: Fixed a bug having to do with turning absolute into - PC-relative. - - * atof-m68k.c (atof_m68k, gen_to_words): Try to avoid a problem with - running off the end of the LITTLENUMS. - - * vax.c: Fixed so parenthesized expressions work. - - * atof-generic.c: Added a cast that fixes problems with some C - compilers. - -(In version 1.21) - - * Changes for VMS support and correct bitfield order for - cross-assembly. - -(In version 1.20) - - * m68k*: Fixed "fmovel #N, fpcr". Added fpcr and fpsr to the list of - registers. - -(In version 1.19) - - * m68k.c? (md_convert_frag): Don't put the fixups for absolute long to - PC-relative in the data segment. - - * atof-generic.c: #include #ifdef sparc. - -(In version 1.18) - - * Re-fixed _vfprintf stuff (?). - - * Made "movem REG, ADDR" work. - - * Improved preprocessing, without temporary files. - -(In version 1.17) - - * Don't produce an undefined empty symbol for ".globl foo," (a line - ending with a comma). - - * Fixed a bug wherein ".long X" became ".long 0" on the Sparc. - - * Fixed a bug which caused many "#APP" "#NO_APP" pairs to dump core. - - * Fixed calls to _doprnt to call _vfprintf #ifndef NO_VARARGS. - -(In version 1.16) - - * Merged HP-UX changes from Chris Hanson (cph@zurich.ai.mit.edu). - - * flonum-multip.c: Renamed to flonum-mult.c. - - * m-hpux.h: Created. - - * m68k.c (bcopy): Fixed. - -(In version 1.15) - - * struct-symbol.h: Renamed to struc-symbol.h. - -(In version 1.14) - - * vax.c: Added a quick fix for the offset of fixed-width branches not - fitting in the field given. - - * gdb-lines.c, read.c: Added support for .gdline and .gdbline - pseudo-ops. - -(In version 1.13) - - * read.c, atof-generic.c: Fixed bugs in reading in floating-point - numbers. - - * m68k-opcode.h: Made "fmovep a0@, fp0" work. - -(In version 1.12) - - * write.c: Fixed an obscure bug in relaction that would occasionally - cause the assembler to stop relaxing when it really had at least one - more pass to do. - -(In version 1.11) - - * m68k*: Allow register lists in fmovem. - - * Added more floating-point exponents. - - * Print an error message on exponent overflow. - -(In version 1.10) - - * Fixed floating point bugs that made it generate incorrect numbers for - values over 10^16 or so. - -(In version 1.09) - - * Fixed bug wherein you couldn't forward reference local label 0. - -(In version 1.08) - - * m68k.c, m68k-opcode.h: Added support for fmovem with register lists. - - * Fixed an obscure bug having to do with generating PC-relative - addressing mode for things in the middle of the instruction instead of - at the end. - -Wed Mar 1 15:29:24 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * *.*: Modified copyright notices to reflect new General Public - License. - - * Makefile: Added copyright notice. - -Fri Feb 17 09:42:01 1989 Jay Fenlason (hack at spiff) - - * Patched frags.c so that new frags start out bzero()ed. - -Thu Jan 26 14:23:44 1989 Jay Fenlason (hack at apple-gunkies.ai.mit.edu) - - * Added patches from pace to files as.h i386.c i386-opcode.h - imull foo,%eax no longer gets assembled into the 32-64 bit - multiply, which clobbers %edx behind gcc's back - - jcxz/jecxz were backwards - - There was a bug when using %ebp as a base register with no - displacement - - Instructions like andb $0xffffff, %al used to put out too many - immediate bytes - - The splitting jump instructions across frags could happen when - obstack_room()==6 too. Local Variables: mode: indented-text diff --git a/gas/Makefile.in b/gas/Makefile.in index 2759503..a732558 100644 --- a/gas/Makefile.in +++ b/gas/Makefile.in @@ -17,8 +17,6 @@ #along with GNU GAS; see the file COPYING. If not, write to #the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -# $Id$ - # The targets for external use include: # all, doc, proto, install, uninstall, includes, TAGS, # clean, cleanconfig, realclean, stage1, stage2, stage3, stage4. @@ -59,57 +57,6 @@ BISON = bison MAKEINFO = makeinfo RANLIB = ranlib -# Version of ar to use when compiling gnulib. -OLDAR = ar - -# Additional system libraries to link with. -CLIB= - -# Specify the rule for actually making gnulib. -GNULIB = gnulib.portable - -# Specify the rule for actually making gnulib2. -GNULIB2 = gnulib2.portable - -# List of extra C and assembler files to add to gnulib. -# Assembler files should have names ending in `.asm'. -LIBFUNCS_EXTRA = - -# Program to convert libraries. -LIBCONVERT = - -# Control whether header files are installed. -INSTALL_HEADERS=install-headers - -# Change this to empty to prevent installing limits.h -LIMITS_H = limits.h - -# Directory to link to, when using the target `maketest'. -DIR = ../gcc - -# For better debugging under COFF, define SEPARATE_AUX_OUTPUT in config.h -# and define the following variable as `aux-output2.c' in make-... -AUX_OUTPUT2 = - -# Flags to use when cross-building GCC. -# Prefix to apply to names of object files when using them -# to run on the machine we are compiling on. -HOST_PREFIX= -# Prefix to apply to names of object files when compiling them -# to run on the machine we are compiling on. -# The default for this variable is chosen to keep these rules -# out of the way of the other rules for compiling the same source files. -HOST_PREFIX_1=loser- -HOST_CC=$(CC) -HOST_CFLAGS=$(ALL_CFLAGS) -HOST_LDFLAGS=$(LDFLAGS) -HOST_CPPFLAGS=$(CPPFLAGS) - -# Choose the real default target. -ALL=as.new - -# End of variables for you to override. - # Lists of files for various purposes. REAL_SOURCES = \ @@ -128,8 +75,10 @@ REAL_SOURCES = \ $(srcdir)/input-file.c \ $(srcdir)/input-scrub.c \ $(srcdir)/messages.c \ + $(srcdir)/obstack.c \ $(srcdir)/output-file.c \ $(srcdir)/read.c \ + $(srcdir)/strerror.c \ $(srcdir)/strstr.c \ $(srcdir)/subsegs.c \ $(srcdir)/symbols.c \ @@ -155,8 +104,10 @@ REAL_HEADERS = \ $(srcdir)/frags.h \ $(srcdir)/hash.h \ $(srcdir)/input-file.h \ + $(srcdir)/listing.h \ $(srcdir)/tc.h \ $(srcdir)/obj.h \ + $(srcdir)/obstack.h \ $(srcdir)/read.h \ $(srcdir)/struc-symbol.h \ $(srcdir)/subsegs.h \ @@ -194,8 +145,10 @@ OBJS = \ input-file.o \ input-scrub.o \ messages.o \ + obstack.o \ output-file.o \ read.o \ + strerror.o \ strstr.o \ subsegs.o \ symbols.o \ @@ -207,41 +160,19 @@ OBJS = \ #### host, target, and site specific Makefile frags come in here. -# Definition of `all' is here so that new rules inserted by sed -# do not specify the default target. -# The real definition is under `all.internal'. - -all: $(ALL) +all: as.new info: install-info: -fake-as: force - - rm -f ./as.new - cp /bin/as ./fake-as - cp ./fake-as ./as.new - # Now figure out from those variables how to compile and link. # This is the variable actually used when we compile. ALL_CFLAGS = -g $(INTERNAL_CFLAGS) $(CFLAGS) $(HDEFINES) $(TDEFINES) -# Even if ALLOCA is set, don't use it if compiling with GCC. -USE_ALLOCA= `if [ x"${CC}" = x"${OLDCC}" ] ; then echo ${ALLOCA}; else true; fi` -USE_HOST_ALLOCA= `if [ x"${CC}" = x"${OLDCC}" ] ; then echo ${HOST_PREFIX}${ALLOCA}; else true; fi` - -# Likewise, for use in the tools that must run on this machine -# even if we are cross-building GCC. -# We don't use USE_ALLOCA because backquote expansion doesn't work in deps. -HOST_LIBDEPS= $(HOST_PREFIX)$(OBSTACK) $(HOST_PREFIX)$(ALLOCA) $(HOST_PREFIX)$(MALLOC) - # How to link with both our special library facilities # and the system's installed libraries. -LIBS = $(LOCAL_LOADLIBES) $(CLIB) $(unsubdir)/../libiberty$(subdir)/libiberty.a - -# Likewise, for use in the tools that must run on this machine -# even if we are cross-building GCC. -HOST_LIBS = $(HOST_PREFIX)$(OBSTACK) $(USE_HOST_ALLOCA) $(HOST_PREFIX)$(MALLOC) $(CLIB) +LIBS = $(LOCAL_LOADLIBES) $(CLIB) # ../libiberty/libiberty.a # Specify the directories to be searched for header files. # Both . and srcdir are used, in that order, @@ -257,36 +188,18 @@ SUBDIR_INCLUDES = -I.. -I$(srcdir) -I$(srcdir)/config # This tells GNU make version 3 not to export all the variables # defined in this file into the environment. .NOEXPORT: - + # Files to be copied away after each stage in building. -STAGE_GCC=gcc STAGESTUFF = *.o as.new -# The files that "belong" in CONFIG_H are deliberately omitted -# because having them there would not be useful in actual practice. -# All they would do is cause complete recompilation every time -# one of the machine description files is edited. -# That may or may not be what one wants to do. -# If it is, rm *.o is an easy way to do it. -# CONFIG_H = config.h tm.h -CONFIG_H = - as.new: $(OBJS) $(LIBDEPS) -mv -f as.new as.old $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o as.new $(OBJS) $(LIBS) $(LOADLIBES) -objdump: - -all.internal: native -# This is what is made with the host's compiler if making a cross assembler. -native: config.status as - config.status: @echo You must configure gas. Look at the INSTALL file for details. @false -compilations: ${OBJS} - # Compiling object files from source files. app.o : app.c as.h host.h targ-env.h obj-format.h \ @@ -380,26 +293,6 @@ targ-cpu.o : targ-cpu.c targ-env.h obj-format.h \ write.h flonum.h bignum.h expr.h frags.h hash.h read.h \ symbols.h tc.h obj.h $(TARG_CPU_DEPENDENTS) - -# Compile the libraries to be used by gen*. -# If we are not cross-building, gen* use the same .o's that cc1 will use, -# and HOST_PREFIX_1 is `foobar', just to ensure these rules don't conflict -# with the rules for rtl.o, alloca.o, etc. -$(HOST_PREFIX_1)alloca.o: alloca.c - rm -f $(HOST_PREFIX)alloca.c - cp $(srcdir)/alloca.c $(HOST_PREFIX)alloca.c - $(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(HOST_PREFIX)alloca.c - -$(HOST_PREFIX_1)obstack.o: obstack.c - rm -f $(HOST_PREFIX)obstack.c - cp $(srcdir)/obstack.c $(HOST_PREFIX)obstack.c - $(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(HOST_PREFIX)obstack.c - -$(HOST_PREFIX_1)malloc.o: malloc.c - rm -f $(HOST_PREFIX)malloc.c - cp $(srcdir)/malloc.c $(HOST_PREFIX)malloc.c - $(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(HOST_PREFIX)malloc.c - # Remake the info files. doc: $(srcdir)/as.info @@ -407,37 +300,26 @@ doc: $(srcdir)/as.info $(srcdir)/as.info: $(srcdir)/doc/as.texinfo (cd doc; make as.info; mv as.info $srcdir) - -# Deletion of files made during compilation. -# There are three levels of this: `clean', `cleanconfig' and `realclean'. -# `clean' deletes what you want to delete ordinarily to save space. -# This is most, but not all, of the files made by compilation. -# `cleanconfig' also deletes everything depending -# on the choice of config files. -# `realclean' also deletes everything that could be regenerated automatically. - clean: - -rm -f $(STAGESTUFF) $(HOST_PREFIX_1)alloca.c $(HOST_PREFIX_1)malloc.c $(HOST_PREFIX_1)obstack.c core + -rm -f $(STAGESTUFF) core # Like clean but also delete the links made to configure gas. -cleanconfig: clean - -rm -f config.status Makefile host.h targ-env.h - -rm -f targ-cpu.h targ-cpu.c - -rm -f obj-format.h obj-format.c - -rm -f atof-targ.c - -# Get rid of every file that's generated from some other file (except INSTALL). -realclean: cleanconfig - -rm -f gas.aux gas.cps gas.fns gas.info gas.kys gas.pgs gas.tps gas.vrs - -rm -f TAGS - -rm -f gas.info* gas.?? gas.??s gas.log gas.toc gas.*aux - -rm -f *.dvi - +distclean: clean + -rm -f config.status Makefile host.h targ-env.h targ-cpu.h \ + targ-cpu.c obj-format.h obj-format.c atof-targ.c \ + gas.aux gas.cps gas.fns gas.info gas.kys gas.pgs + gas.tps gas.vrs TAGS gas.info* gas.?? gas.??s gas.log \ + gas.toc gas.*aux *.dvi + # Entry points `install', `includes' and `uninstall'. # Copy the files into directories where they will be run. -install: $(ALL) - $(INSTALL_PROGRAM) $(ALL) $(bindir)/as +install: + if [ "$(host_alias)" = "$(target_alias)" ] ; then \ + $(INSTALL_PROGRAM) as.new $(bindir)/as ; \ + else \ + $(INSTALL_PROGRAM) as.new $(bindir)/as-$(target_alias) ; \ + fi # Create the installation directory. install-dir: @@ -446,50 +328,33 @@ install-dir: -mkdir $(libdir)/gcc/$(target) -mkdir $(libdir)/gcc/$(target)/$(version) -# Install the compiler executables built during cross compilation. -install-cross: native install-dir - -if [ -f cc1 ] ; then $(INSTALL_PROGRAM) cc1 $(libsubdir)/cc1; else true; fi - -if [ -f cc1plus ] ; then $(INSTALL_PROGRAM) cc1plus $(libsubdir)/cc1plus; else true; fi - $(INSTALL_PROGRAM) cpp $(libsubdir)/cpp - ./gcc -dumpspecs > $(libsubdir)/specs - $(INSTALL_PROGRAM) gcc $(bindir)/gcc - -# Install the man pages. -install-man: install-dir $(srcdir)/gcc.1 protoize.1 unprotoize.1 - $(INSTALL_FILE) $(srcdir)/gcc.1 $(mandir)/gcc.$(manext) - chmod a-x $(mandir)/gcc.$(manext) - $(INSTALL_FILE) $(srcdir)/protoize.1 $(mandir)/protoize.$(manext) - chmod a-x $(mandir)/protoize.$(manext) - $(INSTALL_FILE) $(srcdir)/unprotoize.1 $(mandir)/unprotoize.$(manext) - chmod a-x $(mandir)/unprotoize.$(manext) - # Cancel installation by deleting the installed files. uninstall: -rm -rf $(libsubdir) -rm -rf $(bindir)/as -rm -rf $(mandir)/gas.$(manext) - + # These exist for maintenance purposes. tags TAGS: force etags $(REAL_SOURCES) $(REAL_HEADERS) $(srcdir)/README $(srcdir)/Makefile $(srcdir)/config/*.[hc] -bootstrap: $(ALL) force +bootstrap: as.new force $(MAKE) stage1 - $(MAKE) CC="$(CC)" CFLAGS="-O -Bstage1/ $(CFLAGS)" libdir=$(libdir) ALLOCA= $(ALL) + $(MAKE) CC="$(CC)" CFLAGS="-O -Bstage1/ $(CFLAGS)" libdir=$(libdir) ALLOCA= as.new $(MAKE) stage2 - $(MAKE) CC="$(CC)" CFLAGS="-O -Bstage2/ $(CFLAGS)" libdir=$(libdir) ALLOCA= $(ALL) + $(MAKE) CC="$(CC)" CFLAGS="-O -Bstage2/ $(CFLAGS)" libdir=$(libdir) ALLOCA= as.new $(MAKE) comparison against=stage2 bootstrap2: force - $(MAKE) CC="$(CC)" CFLAGS="-O -Bstage1/ $(CFLAGS)" libdir=$(libdir) ALLOCA= $(ALL) + $(MAKE) CC="$(CC)" CFLAGS="-O -Bstage1/ $(CFLAGS)" libdir=$(libdir) ALLOCA= as.new $(MAKE) stage2 - $(MAKE) CC="$(CC)" CFLAGS="-O -Bstage2/ $(CFLAGS)" libdir=$(libdir) ALLOCA= $(ALL) + $(MAKE) CC="$(CC)" CFLAGS="-O -Bstage2/ $(CFLAGS)" libdir=$(libdir) ALLOCA= as.new $(MAKE) comparison against=stage2 bootstrap3: force - $(MAKE) CC="$(CC)" CFLAGS="-O -Bstage2/ $(CFLAGS)" libdir=$(libdir) ALLOCA= $(ALL) + $(MAKE) CC="$(CC)" CFLAGS="-O -Bstage2/ $(CFLAGS)" libdir=$(libdir) ALLOCA= as.new $(MAKE) comparison against=stage2 # Copy the object files from a particular stage into a subdirectory. @@ -525,40 +390,8 @@ de-stage3: force - (cd stage3 ; rm as ; mv -f * ..) - rmdir stage3 -# Copy just the executable files from a particular stage into a subdirectory, -# and delete the object files. Use this if you're just verifying a version -# that is pretty sure to work, and you are short of disk space. -risky-stage1: force - -mkdir stage1 - -mv cc1 cpp cccp gcc stage1 - -rm -f stage1/gnulib - -cp gnulib stage1 && $(RANLIB) stage1/gnulib - -make clean - -risky-stage2: force - -mkdir stage2 - -mv cc1 cpp cccp gcc stage2 - -rm -f stage2/gnulib - -cp gnulib stage2 && $(RANLIB) stage2/gnulib - -make clean - -risky-stage3: force - -mkdir stage3 - -mv cc1 cpp cccp gcc stage3 - -rm -f stage3/gnulib - -cp gnulib stage3 && $(RANLIB) stage3/gnulib - -make clean - -risky-stage4: force - -mkdir stage4 - -mv cc1 cpp cccp gcc stage4 - -rm -f stage4/gnulib - -cp gnulib stage4 && $(RANLIB) stage4/gnulib - -make clean - #In GNU Make, ignore whether `stage*' exists. .PHONY: stage1 stage2 stage3 stage4 clean realclean TAGS bootstrap -.PHONY: risky-stage1 risky-stage2 risky-stage3 risky-stage4 force: diff --git a/gas/NOTES b/gas/NOTES index 0669aa7..e2f4d8a 100644 --- a/gas/NOTES +++ b/gas/NOTES @@ -1,19 +1,20 @@ to do: +remove DONTDEF + fucked up on a.out.gnu.h, etc. -fucked up on foo-opcode.h. remove the ifdef's from fx_callj tests? what are callj tests? -search for (), build prototypes. space tighten sparc alignment. -convert md_ri_to_chars to not pass structs. convert md_ri_to_chars to emit fixP's. fix number_to_chars, & family to have no side effects. -prototype. md_ => tp_ use CROSS_ASSEMBLE multiple segments. share b.out with a.out. +regress: + ++-inf stack: diff --git a/gas/bignum-copy.c b/gas/bignum-copy.c index 1134636..8e8ad9b 100644 --- a/gas/bignum-copy.c +++ b/gas/bignum-copy.c @@ -19,11 +19,6 @@ #include "as.h" -#ifdef USG -#define bzero(s,n) memset(s,0,n) -#define bcopy(from,to,n) memcpy(to,from,n) -#endif - /* * bignum_copy () * @@ -31,7 +26,7 @@ * If the output is shorter than the input, copy lower-order littlenums. * Return 0 or the number of significant littlenums dropped. * Assumes littlenum arrays are densely packed: no unused chars between - * the littlenums. Uses bcopy() to move littlenums, and wants to + * the littlenums. Uses memcpy() to move littlenums, and wants to * know length (in chars) of the input bignum. */ @@ -49,7 +44,7 @@ register int out_length; /* in sizeof(littlenum)s */ LITTLENUM_TYPE *p; /* -> most significant (non-zero) input littlenum. */ - bcopy((char *) in, (char *) out, + memcpy((void *) out, (void *) in, out_length << LITTLENUM_SHIFT); for (p = in + in_length - 1; p >= in; --p) { if (* p) break; @@ -60,12 +55,12 @@ register int out_length; /* in sizeof(littlenum)s */ significant_littlenums_dropped = 0; } } else { - bcopy((char *) in, (char *) out, + memcpy((char *) out, (char *) in, in_length << LITTLENUM_SHIFT); if (out_length > in_length) { - bzero((char *) (out + out_length), - (out_length - in_length) << LITTLENUM_SHIFT); + memset((char *) (out + out_length), + '\0', (out_length - in_length) << LITTLENUM_SHIFT); } significant_littlenums_dropped = 0; diff --git a/gas/bit_fix.h b/gas/bit_fix.h new file mode 100644 index 0000000..7936927 --- /dev/null +++ b/gas/bit_fix.h @@ -0,0 +1,50 @@ +/* write.h + + Copyright (C) 1987, 1992 Free Software Foundation, Inc. + + This file is part of GAS, the GNU Assembler. + + GAS is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + GAS is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GAS; see the file COPYING. If not, write to + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/* The bit_fix was implemented to support machines that need variables + to be inserted in bitfields other than 1, 2 and 4 bytes. + Furthermore it gives us a possibillity to mask in bits in the symbol + when it's fixed in the objectcode and check the symbols limits. + + The or-mask is used to set the huffman bits in displacements for the + ns32k port. + The acbi, addqi, movqi, cmpqi instruction requires an assembler that + can handle bitfields. Ie handle an expression, evaluate it and insert + the result in an some bitfield. ( ex: 5 bits in a short field of a opcode) + */ + +#ifndef __bit_fix_h__ +#define __bit_fix_h__ + +struct bit_fix { + int fx_bit_size; /* Length of bitfield */ + int fx_bit_offset; /* Bit offset to bitfield */ + long fx_bit_base; /* Where do we apply the bitfix. + If this is zero, default is assumed. */ + long fx_bit_base_adj; /* Adjustment of base */ + long fx_bit_max; /* Signextended max for bitfield */ + long fx_bit_min; /* Signextended min for bitfield */ + long fx_bit_add; /* Or mask, used for huffman prefix */ +}; +typedef struct bit_fix bit_fixS; + +#endif /* __bit_fix_h__ */ + + /* end of bit_fix.h */ diff --git a/gas/config/.Sanitize b/gas/config/.Sanitize index d831b5d..b3f5e27 100644 --- a/gas/config/.Sanitize +++ b/gas/config/.Sanitize @@ -32,9 +32,7 @@ atof-ieee.c atof-vax.c coff.gnu.h cplus-dem.c -ho-a29k.h ho-ansi.h -ho-cygnus.h ho-decstation.h ho-generic.h ho-hpux.h @@ -46,8 +44,6 @@ ho-sun4.h ho-sunos.h ho-sysv.h ho-vax.h -mh-a29k -mh-cygnus mh-i386 mt-ebmon29k mt-h8300 @@ -128,7 +124,10 @@ echo Done in `pwd`. # # # $Log$ -# Revision 1.14 1992/02/13 10:13:24 rich +# Revision 1.15 1992/02/17 15:53:46 rich +# fighting bitrot in a major way +# +# Revision 1.14 1992/02/13 10:13:24 rich # clean up Sanitize for gas # # Revision 1.13 1992/02/11 00:51:52 sac diff --git a/gas/config/ho-ansi.h b/gas/config/ho-ansi.h index 095c24b..2af0341 100644 --- a/gas/config/ho-ansi.h +++ b/gas/config/ho-ansi.h @@ -25,6 +25,5 @@ #define sys_nerr _sys_nerr #define sys_errlist _sys_errlist -#define bzero(b,l) (memset((b),0,(l))) /* end of ho-ansi.h */ diff --git a/gas/config/ho-generic.h b/gas/config/ho-generic.h index 04db63e..493cfc6 100644 --- a/gas/config/ho-generic.h +++ b/gas/config/ho-generic.h @@ -23,6 +23,8 @@ #define M_GENERIC 1 +#define HAVE_STRERROR + extern int free(); /* end of ho-generic.h */ diff --git a/gas/config/ho-sunos.h b/gas/config/ho-sunos.h index 52951a6..1193b1b 100644 --- a/gas/config/ho-sunos.h +++ b/gas/config/ho-sunos.h @@ -43,9 +43,6 @@ extern char *strchr(); extern char *strrchr(); extern int _filbuf(); extern int _flsbuf(); -extern int bcopy(); -extern int bzero(); -extern int bzero(); extern int fclose(); extern int fgetc(); extern int fprintf(); diff --git a/gas/config/ho-sysv.h b/gas/config/ho-sysv.h index bc9b267..443fe3b 100644 --- a/gas/config/ho-sysv.h +++ b/gas/config/ho-sysv.h @@ -19,8 +19,6 @@ #define HO_USG -#define bcopy(from,to,n) memcpy((to),(from),(n)) -#define bzero(s,n) memset((s),0,(n)) #define setbuffer(stream, buf, size) setvbuf((stream), (buf), _IOLBF, (size)) extern int free(); diff --git a/gas/config/obj-coffbfd.c b/gas/config/obj-coffbfd.c index dd4c527..4d10635 100644 --- a/gas/config/obj-coffbfd.c +++ b/gas/config/obj-coffbfd.c @@ -597,7 +597,7 @@ symbolS *symbolP; /* Additional information */ symbolP->sy_symbol.ost_flags = 0; /* Auxiliary entries */ - bzero((char*)&symbolP->sy_symbol.ost_auxent[0], AUXESZ); + memset((char*) &symbolP->sy_symbol.ost_auxent[0], '\0', AUXESZ); #ifdef STRIP_UNDERSCORE /* Remove leading underscore at the beginning of the symbol. @@ -749,7 +749,7 @@ static void SKIP_WHITESPACES(); def_symbol_in_progress = (symbolS *) obstack_alloc(¬es, sizeof(*def_symbol_in_progress)); - bzero(def_symbol_in_progress, sizeof(*def_symbol_in_progress)); + memset(def_symbol_in_progress, '\0', sizeof(*def_symbol_in_progress)); symbol_name = input_line_pointer; name_end = get_symbol_end(); @@ -1269,8 +1269,8 @@ static unsigned int DEFUN_VOID(yank_symbols) } /* make it at least 1 */ /* Clobber possible stale .dim information. */ - bzero(symbolP->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_ary.x_dimen, - sizeof(symbolP->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_ary.x_dimen)); + memset(symbolP->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_ary.x_dimen, + '\0', sizeof(symbolP->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_ary.x_dimen)); } /* The C_FCN doesn't need any additional information. I don't even know if this is needed for sdb. But the @@ -1947,7 +1947,7 @@ static void S_SET_OFFSET(symbolP, symbolP->sy_name_offset); S_SET_ZEROES(symbolP, 0); } else { - bzero(symbolP->sy_symbol.ost_entry.n_name, SYMNMLEN); + memset(symbolP->sy_symbol.ost_entry.n_name, '\0', SYMNMLEN); strncpy(symbolP->sy_symbol.ost_entry.n_name, temp, SYMNMLEN); } where = symbol_to_chars(abfd, where, symbolP); diff --git a/gas/config/tc-a29k.c b/gas/config/tc-a29k.c index 5fe4909..fbdadb5 100644 --- a/gas/config/tc-a29k.c +++ b/gas/config/tc-a29k.c @@ -437,7 +437,7 @@ char *str; } argsStart = s; opcode = insn->opcode; - bzero(&the_insn, sizeof(the_insn)); + memset(&the_insn, '\0', sizeof(the_insn)); the_insn.reloc = NO_RELOC; /* @@ -900,20 +900,21 @@ register fragS *fragP; /* should never be called for 29k */ void md_create_long_jump(ptr, from_addr, to_addr, frag, to_symbol) char *ptr; -long from_addr, - to_addr; +long from_addr; +long to_addr; fragS *frag; symbolS *to_symbol; { as_fatal("sparc_create_long_jump\n"); } -/* should never be called for sparc */ +/* should never be called for a29k */ int md_estimate_size_before_relax(fragP, segtype) register fragS *fragP; segT segtype; { as_fatal("sparc_estimate_size_before_relax\n"); + return(0); } #if 0 @@ -986,24 +987,22 @@ char *where; fixS *fixP; relax_addressT segment_address_in_file; { - long r_index; + long r_symbolnum; know(fixP->fx_r_type < NO_RELOC); know(fixP->fx_addsy != NULL); - r_index = (S_IS_DEFINED(fixP->fx_addsy) - ? S_GET_TYPE(fixP->fx_addsy) - : fixP->fx_addsy->sy_number); - - /* this is easy */ md_number_to_chars(where, fixP->fx_frag->fr_address + fixP->fx_where - segment_address_in_file, 4); - /* now the fun stuff */ - where[4] = (r_index >> 16) & 0x0ff; - where[5] = (r_index >> 8) & 0x0ff; - where[6] = r_index & 0x0ff; + r_symbolnum = (S_IS_DEFINED(fixP->fx_addsy) + ? S_GET_TYPE(fixP->fx_addsy) + : fixP->fx_addsy->sy_number); + + where[4] = (r_symbolnum >> 16) & 0x0ff; + where[5] = (r_symbolnum >> 8) & 0x0ff; + where[6] = r_symbolnum & 0x0ff; where[7] = (((!S_IS_DEFINED(fixP->fx_addsy)) << 7) & 0x80) | (0 & 0x60) | (fixP->fx_r_type & 0x1F); /* Also easy */ md_number_to_chars(&where[8], fixP->fx_addnumber, 4); diff --git a/gas/config/tc-a29k.h b/gas/config/tc-a29k.h index 254ebe1..d176262 100644 --- a/gas/config/tc-a29k.h +++ b/gas/config/tc-a29k.h @@ -19,15 +19,17 @@ #define TC_A29K -#define tc_headers_hook(a) ; /* not used */ -#define tc_headers_hook(a) ; /* not used */ -#define tc_crawl_symbol_chain(a) ; /* not used */ -#define tc_coff_symbol_emit_hook(a) ; /* not used */ - +#define tc_aout_pre_write_hook(x) {;} /* not used */ +#define tc_coff_symbol_emit_hook(a) {;} /* not used */ +#define tc_crawl_symbol_chain(a) {;} /* not used */ +#define tc_headers_hook(a) {;} /* not used */ +#define tc_headers_hook(a) {;} /* not used */ + #define AOUT_MACHTYPE 101 #define TC_COFF_FIX2RTYPE(fix_ptr) tc_coff_fix2rtype(fix_ptr) #define BFD_ARCH bfd_arch_a29k #define COFF_MAGIC SIPFBOMAGIC + /* Should the reloc be output ? on the 29k, this is true only if there is a symbol attatched. on the h8, this is allways true, since no fixup is done diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index 42398ae..92b4b4a 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -34,46 +34,47 @@ typedef struct { /* TM holds the template for the insn were currently assembling. */ - template tm; + template tm; /* SUFFIX holds the opcode suffix (e.g. 'l' for 'movl') if given. */ - char suffix; + char suffix; /* Operands are coded with OPERANDS, TYPES, DISPS, IMMS, and REGS. */ /* OPERANDS gives the number of given operands. */ - unsigned int operands; + unsigned int operands; /* REG_OPERANDS, DISP_OPERANDS, MEM_OPERANDS, IMM_OPERANDS give the number of given register, displacement, memory operands and immediate operands. */ - unsigned int reg_operands, disp_operands, mem_operands, imm_operands; + unsigned int reg_operands, disp_operands, mem_operands, imm_operands; /* TYPES [i] is the type (see above #defines) which tells us how to search through DISPS [i] & IMMS [i] & REGS [i] for the required operand. */ - unsigned int types [MAX_OPERANDS]; + unsigned int types[MAX_OPERANDS]; /* Displacements (if given) for each operand. */ - expressionS * disps [MAX_OPERANDS]; + expressionS *disps[MAX_OPERANDS]; /* Immediate operands (if given) for each operand. */ - expressionS * imms [MAX_OPERANDS]; + expressionS *imms[MAX_OPERANDS]; /* Register operands (if given) for each operand. */ - reg_entry * regs [MAX_OPERANDS]; + reg_entry *regs[MAX_OPERANDS]; /* BASE_REG, INDEX_REG, and LOG2_SCALE_FACTOR are used to encode the base index byte below. */ - reg_entry * base_reg; - reg_entry * index_reg; - unsigned int log2_scale_factor; + reg_entry *base_reg; + reg_entry *index_reg; + unsigned int log2_scale_factor; /* SEG gives the seg_entry of this insn. It is equal to zero unless an explicit segment override is given. */ - seg_entry * seg; /* segment for memory operands (if given) */ + const seg_entry *seg; /* segment for memory operands (if given) */ /* PREFIX holds all the given prefix opcodes (usually null). PREFIXES is the size of PREFIX. */ - char prefix [MAX_PREFIXES]; - unsigned int prefixes; + /* richfix: really unsigned? */ + unsigned char prefix[MAX_PREFIXES]; + unsigned int prefixes; /* RM and IB are the modrm byte and the base index byte where the addressing modes of this insn are encoded. */ @@ -203,14 +204,28 @@ const relax_typeS md_relax_table[] = { #if __STDC__ == 1 static char *output_invalid(int c); +static int fits_in_signed_byte(long num); +static int fits_in_signed_word(long num); +static int fits_in_unsigned_byte(long num); +static int fits_in_unsigned_word(long num); static int i386_operand(char *operand_string); +static int smallest_imm_type(long num); static reg_entry *parse_register(char *reg_string); +static unsigned long mode_from_disp_size(unsigned long t); +static unsigned long opcode_suffix_to_type(unsigned long s); #else /* not __STDC__ */ static char *output_invalid(); +static int fits_in_signed_byte(); +static int fits_in_signed_word(); +static int fits_in_unsigned_byte(); +static int fits_in_unsigned_word(); static int i386_operand(); +static int smallest_imm_type(); static reg_entry *parse_register(); +static unsigned long mode_from_disp_size(); +static unsigned long opcode_suffix_to_type(); #endif /* not __STDC__ */ @@ -317,11 +332,11 @@ void md_begin () { register unsigned int c; - bzero (opcode_chars, sizeof(opcode_chars)); - bzero (operand_chars, sizeof(operand_chars)); - bzero (space_chars, sizeof(space_chars)); - bzero (identifier_chars, sizeof(identifier_chars)); - bzero (digit_chars, sizeof(digit_chars)); + memset(opcode_chars, '\0', sizeof(opcode_chars)); + memset(operand_chars, '\0', sizeof(operand_chars)); + memset(space_chars, '\0', sizeof(space_chars)); + memset(identifier_chars, '\0', sizeof(identifier_chars)); + memset(digit_chars, '\0', sizeof(digit_chars)); for (c = 0; c < 256; c++) { if (islower(c) || isdigit(c)) { @@ -473,15 +488,15 @@ void md_assemble (line) char *line; { /* Holds temlate once we've found it. */ - register template * t; + register template *t; /* Possible templates for current insn */ templates *current_templates = (templates *) 0; /* Initialize globals. */ - bzero (&i, sizeof(i)); - bzero (disp_expressions, sizeof(disp_expressions)); - bzero (im_expressions, sizeof(im_expressions)); + memset(&i, '\0', sizeof(i)); + memset(disp_expressions, '\0', sizeof(disp_expressions)); + memset(im_expressions, '\0', sizeof(im_expressions)); save_stack_p = save_stack; /* reset stack pointer */ /* Fist parse an opcode & call i386_operand for the operands. @@ -638,12 +653,12 @@ char *line; /* now *l must be either ',' or END_OF_INSN */ if (*l == ',') { - if (*++l == END_OF_INSN) { /* just skip it, if it's \n complain */ + if (*++l == END_OF_INSN) { /* just skip it, if it's \n complain */ goto expecting_operand_after_comma; } expecting_operand = 1; } - } while (*l != END_OF_INSN); /* until we get end of insn */ + } while (*l != END_OF_INSN); /* until we get end of insn */ } } @@ -676,7 +691,7 @@ char *line; ( ((t0 & t1 & (Reg)) == 0 && (m0 & m1 & (Reg)) == 0) || \ ((t0 & t1) & (m0 & m1) & (Reg)) \ ) : 1) - { + { register unsigned int overlap0, overlap1; expressionS * exp; unsigned int overlap2; @@ -746,7 +761,7 @@ char *line; } /* Copy the template we found (we may change it!). */ - bcopy (t, &i.tm, sizeof (template)); + memcpy(&i.tm, t, sizeof(template)); t = &i.tm; /* alter new copy of template */ /* If there's no opcode suffix we try to invent one based on register @@ -917,7 +932,7 @@ char *line; if (i.base_reg == esp && ! i.index_reg) { /* (%esp) becomes two byte modrm with no index register. */ i.rm.regmem = ESCAPE_TO_TWO_BYTE_ADDRESSING; - i.rm.mode = MODE_FROM_DISP_SIZE (i.types[o]); + i.rm.mode = mode_from_disp_size(i.types[o]); i.bi.base = ESP_REG_NUM; i.bi.index = NO_INDEX_REGISTER; i.bi.scale = 0; /* Must be zero! */ @@ -929,7 +944,7 @@ char *line; /* fake_zero_displacement code does not set this. */ i.types[o] |= Disp8; } - i.rm.mode = MODE_FROM_DISP_SIZE (i.types[o]); + i.rm.mode = mode_from_disp_size(i.types[o]); i.rm.regmem = EBP_REG_NUM; } else if (! i.base_reg && (i.types[o] & BaseIndex)) { /* There are three cases here. @@ -961,7 +976,7 @@ char *line; } else { /* It's not a special case; rev'em up. */ i.rm.regmem = i.base_reg->reg_num; - i.rm.mode = MODE_FROM_DISP_SIZE (i.types[o]); + i.rm.mode = mode_from_disp_size(i.types[o]); if (i.index_reg) { i.rm.regmem = ESCAPE_TO_TWO_BYTE_ADDRESSING; i.bi.base = i.base_reg->reg_num; @@ -970,7 +985,7 @@ char *line; if (i.base_reg == ebp && i.disp_operands == 0) { /* pace */ fake_zero_displacement = 1; i.types[o] |= Disp8; - i.rm.mode = MODE_FROM_DISP_SIZE (i.types[o]); + i.rm.mode = mode_from_disp_size(i.types[o]); } } } @@ -987,15 +1002,15 @@ char *line; /* Select the correct segment for the memory operand. */ if (i.seg) { - const unsigned int seg_index; - const seg_entry * default_seg; + unsigned int seg_index; + const seg_entry *default_seg; if (i.rm.regmem == ESCAPE_TO_TWO_BYTE_ADDRESSING) { seg_index = (i.rm.mode<<3) | i.bi.base; - default_seg = two_byte_segment_defaults [seg_index]; + default_seg = two_byte_segment_defaults[seg_index]; } else { seg_index = (i.rm.mode<<3) | i.rm.regmem; - default_seg = one_byte_segment_defaults [seg_index]; + default_seg = one_byte_segment_defaults[seg_index]; } /* If the specified segment is not the default, use an opcode prefix to select it */ @@ -1054,12 +1069,12 @@ char *line; switch (i.disps[0]->X_seg) { case SEG_ABSOLUTE: - if (FITS_IN_SIGNED_BYTE (n)) { + if (fits_in_signed_byte(n)) { p = frag_more (2); p[0] = t->base_opcode; p[1] = n; #if 0 /* leave out 16 bit jumps - pace */ - } else if (FITS_IN_SIGNED_WORD (n)) { + } else if (fits_in_signed_word(n)) { p = frag_more (4); p[0] = WORD_PREFIX_OPCODE; p[1] = t->base_opcode; @@ -1106,7 +1121,7 @@ char *line; int size = (t->opcode_modifier & JumpByte) ? 1 : 4; int n = i.disps[0]->X_add_number; - if (FITS_IN_UNSIGNED_BYTE(t->base_opcode)) { + if (fits_in_unsigned_byte(t->base_opcode)) { FRAG_APPEND_1_CHAR (t->base_opcode); } else { p = frag_more (2); /* opcode can be at most two bytes */ @@ -1119,7 +1134,7 @@ char *line; switch (i.disps[0]->X_seg) { case SEG_ABSOLUTE: md_number_to_chars (p, n, size); - if (size == 1 && ! FITS_IN_SIGNED_BYTE (n)) { + if (size == 1 && ! fits_in_signed_byte(n)) { as_bad("loop/jecx only takes byte displacement; %d shortened to %d", n, *p); } @@ -1145,7 +1160,7 @@ char *line; md_number_to_chars (p + 5, i.imms[0]->X_add_number, 2); } else { /* Output normal instructions here. */ - register char *q; + unsigned char *q; /* First the prefix bytes. */ for (q = i.prefix; q < i.prefix + i.prefixes; q++) { @@ -1154,9 +1169,9 @@ char *line; } /* Now the opcode; be careful about word order here! */ - if (FITS_IN_UNSIGNED_BYTE(t->base_opcode)) { + if (fits_in_unsigned_byte(t->base_opcode)) { FRAG_APPEND_1_CHAR (t->base_opcode); - } else if (FITS_IN_UNSIGNED_WORD(t->base_opcode)) { + } else if (fits_in_unsigned_word(t->base_opcode)) { p = frag_more (2); /* put out high byte first: can't use md_number_to_chars! */ *p++ = (t->base_opcode >> 8) & 0xff; @@ -1271,8 +1286,8 @@ char *operand_string; char * end_of_operand_string = operand_string + strlen(operand_string); /* Start and end of displacement string expression (if found). */ - char * displacement_string_start = 0; - char * displacement_string_end; + char *displacement_string_start = NULL; + char *displacement_string_end = NULL; /* We check for an absolute prefix (differentiating, for example, 'jmp pc_relative_label' from 'jmp *absolute_label'. */ @@ -1283,8 +1298,8 @@ char *operand_string; /* Check if operand is a register. */ if (*op_string == REGISTER_PREFIX) { - register reg_entry * r; - if (! (r = parse_register (op_string))) { + register reg_entry *r; + if (!(r = parse_register (op_string))) { as_bad("bad register name ('%s')", op_string); return 0; } @@ -1323,19 +1338,22 @@ char *operand_string; i.regs[this_operand] = r; i.reg_operands++; } else if (*op_string == IMMEDIATE_PREFIX) { /* ... or an immediate */ - char * save_input_line_pointer; - register expressionS *exp; - segT exp_seg; + char *save_input_line_pointer; + segT exp_seg = SEG_GOOF; + expressionS *exp; + if (i.imm_operands == MAX_IMMEDIATE_OPERANDS) { as_bad("only 1 or 2 immediate operands are allowed"); return 0; } + exp = &im_expressions[i.imm_operands++]; - i.imms [this_operand] = exp; + i.imms[this_operand] = exp; save_input_line_pointer = input_line_pointer; input_line_pointer = ++op_string; /* must advance op_string! */ - exp_seg = expression (exp); + exp_seg = expression(exp); input_line_pointer = save_input_line_pointer; + switch (exp_seg) { case SEG_ABSENT: /* missing or bad expr becomes absolute 0 */ as_bad("missing or invalid immediate expression '%s' taken as 0", @@ -1347,7 +1365,7 @@ char *operand_string; i.types[this_operand] |= Imm; break; case SEG_ABSOLUTE: - i.types[this_operand] |= SMALLEST_IMM_TYPE (exp->X_add_number); + i.types[this_operand] |= smallest_imm_type(exp->X_add_number); break; case SEG_TEXT: case SEG_DATA: case SEG_BSS: case SEG_UNKNOWN: i.types[this_operand] |= Imm32; /* this is an address ==> 32bit */ @@ -1511,16 +1529,16 @@ char *operand_string; assuming displacement_string_start and displacement_string_end are meaningful. */ if (displacement_string_start) { - register expressionS * exp; - segT exp_seg; - char * save_input_line_pointer; + register expressionS *exp; + segT exp_seg = SEG_GOOF; + char *save_input_line_pointer; exp = &disp_expressions[i.disp_operands]; i.disps [this_operand] = exp; i.disp_operands++; save_input_line_pointer = input_line_pointer; input_line_pointer = displacement_string_start; END_STRING_AND_SAVE (displacement_string_end); - exp_seg = expression (exp); + exp_seg = expression(exp); if(*input_line_pointer) as_bad("Ignoring junk '%s' after expression",input_line_pointer); RESTORE_END_STRING (displacement_string_end); @@ -1641,10 +1659,11 @@ void object_headers *headers; register fragS * fragP; { - register unsigned char * opcode; - unsigned char * where_to_put_displacement; - unsigned int target_address, opcode_address; - unsigned int extension; + register unsigned char *opcode; + unsigned char *where_to_put_displacement = NULL; + unsigned int target_address; + unsigned int opcode_address; + unsigned int extension = 0; int displacement_from_opcode_start; opcode = (unsigned char *) fragP -> fr_opcode; @@ -1860,26 +1879,24 @@ relax_addressT segment_address_in_file; */ static unsigned char nbytes_r_length [] = { 42, 0, 1, 42, 2 }; - long r_index; + long r_symbolnum; know(fixP->fx_addsy != NULL); - r_index = (S_IS_DEFINED(fixP->fx_addsy) - ? S_GET_TYPE(fixP->fx_addsy) - : fixP->fx_addsy->sy_number); - - /* this is easy */ md_number_to_chars(where, fixP->fx_frag->fr_address + fixP->fx_where - segment_address_in_file, 4); - /* now the fun stuff */ - where[4] = r_index & 0x0ff; - where[5] = (r_index >> 8) & 0x0ff; - where[6] = (r_index >> 16) & 0x0ff; + r_symbolnum = (S_IS_DEFINED(fixP->fx_addsy) + ? S_GET_TYPE(fixP->fx_addsy) + : fixP->fx_addsy->sy_number); + + where[6] = (r_symbolnum >> 16) & 0x0ff; + where[5] = (r_symbolnum >> 8) & 0x0ff; + where[4] = r_symbolnum & 0x0ff; where[7] = ((((!S_IS_DEFINED(fixP->fx_addsy)) << 3) & 0x08) | ((nbytes_r_length[fixP->fx_size] << 1) & 0x06) - | ((fixP->fx_pcrel << 0) & 0x01) & 0x0f); + | (((fixP->fx_pcrel << 0) & 0x01) & 0x0f)); return; } /* tc_aout_fix_to_chars() */ @@ -2006,6 +2023,66 @@ fixS *fixP; return fixP->fx_size + fixP->fx_where + fixP->fx_frag->fr_address; } + /* these were macros, but I don't trust macros that eval their + arguments more than once. Besides, gcc can static inline them. + xoxorich. */ + +static unsigned long mode_from_disp_size(t) +unsigned long t; +{ + return((t & (Disp8)) + ? 1 + : ((t & (Disp32)) ? 2 : 0)); +} /* mode_from_disp_size() */ + +/* convert opcode suffix ('b' 'w' 'l' typically) into type specifyer */ + +static unsigned long opcode_suffix_to_type(s) +unsigned long s; +{ + return(s == BYTE_OPCODE_SUFFIX + ? Byte : (s == WORD_OPCODE_SUFFIX + ? Word : DWord)); +} /* opcode_suffix_to_type() */ + +static int fits_in_signed_byte(num) +long num; +{ + return((num >= -128) && (num <= 127)); +} /* fits_in_signed_byte() */ + +static int fits_in_unsigned_byte(num) +long num; +{ + return((num & 0xff) == num); +} /* fits_in_unsigned_byte() */ + +static int fits_in_unsigned_word(num) +long num; +{ + return((num & 0xffff) == num); +} /* fits_in_unsigned_word() */ + +static int fits_in_signed_word(num) +long num; +{ + return((-32768 <= num) && (num <= 32767)); +} /* fits_in_signed_word() */ + +static int smallest_imm_type(num) +long num; +{ + return((num == 1) + ? (Imm1|Imm8|Imm8S|Imm16|Imm32) + : (fits_in_signed_byte(num) + ? (Imm8S|Imm8|Imm16|Imm32) + : (fits_in_unsigned_byte(num) + ? (Imm8|Imm16|Imm32) + : ((fits_in_signed_word(num) || fits_in_unsigned_word(num)) + ? (Imm16|Imm32) + : (Imm32))))); +} /* smallest_imm_type() */ + /* * Local Variables: * comment-column: 0 diff --git a/gas/config/tc-i386.h b/gas/config/tc-i386.h index b68f956..6e89dfc 100644 --- a/gas/config/tc-i386.h +++ b/gas/config/tc-i386.h @@ -1,5 +1,5 @@ -/* i386.h -- Header file for i386.c - Copyright (C) 1989, Free Software Foundation. +/* tc-i386.h -- Header file for tc-i386.c + Copyright (C) 1989, 1992 Free Software Foundation. This file is part of GAS, the GNU Assembler. @@ -22,16 +22,19 @@ #define AOUT_MACHTYPE 100 #define REVERSE_SORT_RELOCS -#define tc_crawl_symbol_chain(a) ; /* not used */ -#define tc_headers_hook(a) ; /* not used */ - +#define NO_LISTING + +#define tc_aout_pre_write_hook(x) {;} /* not used */ +#define tc_crawl_symbol_chain(a) {;} /* not used */ +#define tc_headers_hook(a) {;} /* not used */ + #define MAX_OPERANDS 3 /* max operands per insn */ #define MAX_PREFIXES 4 /* max prefixes per opcode */ #define MAX_IMMEDIATE_OPERANDS 2 /* max immediates per insn */ #define MAX_MEMORY_OPERANDS 2 /* max memory ref per insn * lcall uses 2 */ - /* we define the syntax here (modulo base,index,scale syntax) */ +/* we define the syntax here (modulo base,index,scale syntax) */ #define REGISTER_PREFIX '%' #define IMMEDIATE_PREFIX '$' #define ABSOLUTE_PREFIX '*' @@ -39,18 +42,18 @@ #define TWO_BYTE_OPCODE_ESCAPE 0x0f - /* register numbers */ +/* register numbers */ #define EBP_REG_NUM 5 #define ESP_REG_NUM 4 - /* modrm_byte.regmem for twobyte escape */ +/* modrm_byte.regmem for twobyte escape */ #define ESCAPE_TO_TWO_BYTE_ADDRESSING ESP_REG_NUM - /* index_base_byte.index for no index register addressing */ +/* index_base_byte.index for no index register addressing */ #define NO_INDEX_REGISTER ESP_REG_NUM - /* index_base_byte.base for no base register addressing */ +/* index_base_byte.base for no base register addressing */ #define NO_BASE_REGISTER EBP_REG_NUM - /* these are the att as opcode suffixes, making movl --> mov, for example */ + /* these are the att as opcode suffixes, making movl --> mov, for example */ #define DWORD_OPCODE_SUFFIX 'l' #define WORD_OPCODE_SUFFIX 'w' #define BYTE_OPCODE_SUFFIX 'b' @@ -115,53 +118,32 @@ #define Abs32 0x20000000 #define Abs (Abs8|Abs16|Abs32) -#define MODE_FROM_DISP_SIZE(t) \ - ((t&(Disp8)) ? 1 : \ - ((t&(Disp32)) ? 2 : 0)) - #define Byte (Reg8|Imm8|Imm8S) #define Word (Reg16|Imm16) #define DWord (Reg32|Imm32) -/* convert opcode suffix ('b' 'w' 'l' typically) into type specifyer */ -#define OPCODE_SUFFIX_TO_TYPE(s) \ - (s == BYTE_OPCODE_SUFFIX ? Byte : \ - (s == WORD_OPCODE_SUFFIX ? Word : DWord)) - -#define FITS_IN_SIGNED_BYTE(num) ((num) >= -128 && (num) <= 127) -#define FITS_IN_UNSIGNED_BYTE(num) ((num) >= 0 && (num) <= 255) -#define FITS_IN_UNSIGNED_WORD(num) ((num) >= 0 && (num) <= 65535) -#define FITS_IN_SIGNED_WORD(num) ((num) >= -32768 && (num) <= 32767) - #define SMALLEST_DISP_TYPE(num) \ - FITS_IN_SIGNED_BYTE(num) ? (Disp8|Disp32|Abs8|Abs32) : (Disp32|Abs32) - -#define SMALLEST_IMM_TYPE(num) \ - (num == 1) ? (Imm1|Imm8|Imm8S|Imm16|Imm32): \ - FITS_IN_SIGNED_BYTE(num) ? (Imm8S|Imm8|Imm16|Imm32) : \ - FITS_IN_UNSIGNED_BYTE(num) ? (Imm8|Imm16|Imm32): \ - (FITS_IN_SIGNED_WORD(num)||FITS_IN_UNSIGNED_WORD(num)) ? (Imm16|Imm32) : \ - (Imm32) + fits_in_signed_byte(num) ? (Disp8|Disp32|Abs8|Abs32) : (Disp32|Abs32) typedef struct { /* instruction name sans width suffix ("mov" for movl insns) */ - char *name; + char *name; /* how many operands */ - unsigned int operands; + unsigned int operands; /* base_opcode is the fundamental opcode byte with a optional prefix(es). */ - unsigned int base_opcode; + unsigned int base_opcode; /* extension_opcode is the 3 bit extension for group insns. If this template has no extension opcode (the usual case) use None */ - unsigned char extension_opcode; -#define None 0xff /* If no extension_opcode is possible. */ + unsigned char extension_opcode; +#define None 0xff /* If no extension_opcode is possible. */ /* the bits in opcode_modifier are used to generate the final opcode from the base_opcode. These bits also are used to detect alternate forms of the same instruction */ - unsigned int opcode_modifier; + unsigned int opcode_modifier; /* opcode_modifier bits: */ #define W 0x1 /* set if operands are words or dwords */ @@ -211,26 +193,26 @@ typedef struct { END. */ typedef struct { - template *start; - template *end; + template *start; + template *end; } templates; /* these are for register name --> number & type hash lookup */ typedef struct { - char * reg_name; - unsigned int reg_type; - unsigned int reg_num; + char *reg_name; + unsigned int reg_type; + unsigned int reg_num; } reg_entry; typedef struct { - char * seg_name; - unsigned int seg_prefix; + char *seg_name; + unsigned int seg_prefix; } seg_entry; /* these are for prefix name --> prefix code hash lookup */ typedef struct { - char * prefix_name; - unsigned char prefix_code; + char *prefix_name; + unsigned char prefix_code; } prefix_entry; /* 386 operand encoding bytes: see 386 book for details of this. */ diff --git a/gas/config/tc-i860.c b/gas/config/tc-i860.c index ced89f2..abd53c8 100644 --- a/gas/config/tc-i860.c +++ b/gas/config/tc-i860.c @@ -464,7 +464,7 @@ char *str; argsStart = s; for (;;) { opcode = insn->match; - bzero(&the_insn, sizeof(the_insn)); + memset(&the_insn, '\0', sizeof(the_insn)); the_insn.reloc = NO_RELOC; /* @@ -630,13 +630,13 @@ char *str; break; case '5': /* 5 bit immediate in src1 */ - bzero(&the_insn, sizeof(the_insn)); + memset(&the_insn, '\0', sizeof(the_insn)); if ( !getExpression(s)) { s = expr_end; if (the_insn.exp.X_add_number & ~0x1f) as_bad("5-bit immediate too large"); opcode |= (the_insn.exp.X_add_number & 0x1f) << 11; - bzero(&the_insn, sizeof(the_insn)); + memset(&the_insn, '\0', sizeof(the_insn)); the_insn.reloc = NO_RELOC; continue; } @@ -1019,7 +1019,7 @@ struct relocation_info *ri_p, ri; /* Also easy */ md_number_to_chars(&the_bytes[8], ri.r_addend, sizeof(ri.r_addend)); /* now put it back where you found it, Junior... */ - bcopy (the_bytes, (char *)ri_p, sizeof(*ri_p)); + memcpy((char *) ri_p, the_bytes, sizeof(*ri_p)); #endif } @@ -1122,7 +1122,7 @@ relax_addressT segment_address_in_file; extern char *next_object_file_charP; long add_number; - bzero((char *) &ri, sizeof(ri)); + memset((char *) &ri, '\0', sizeof(ri)); for (; fixP; fixP = fixP->fx_next) { if (fixP->fx_r_type & ~0x3f) { diff --git a/gas/config/tc-i960.c b/gas/config/tc-i960.c index c2baa08..262ed8b 100644 --- a/gas/config/tc-i960.c +++ b/gas/config/tc-i960.c @@ -1,5 +1,5 @@ -/* i960.c - All the i80960-specific stuff - Copyright (C) 1989, 1990, 1991 Free Software Foundation, Inc. +/* tc-i960.c - All the i80960-specific stuff + Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc. This file is part of GAS. @@ -496,7 +496,7 @@ char *textP; /* Source text of instruction */ /* Parse instruction into opcode and operands */ - bzero(args, sizeof(args)); + memset(args, '\0', sizeof(args)); n_ops = i_scan(textP, args); if (n_ops == -1){ return; /* Error message already issued */ @@ -1471,7 +1471,7 @@ struct i960_opcode *oP; /* Pointer to description of instruction */ expressionS expr; /* Parsed expression */ fixS *fixP; /*->description of deferred address fixup */ - bzero(&instr, sizeof(memS)); + memset(&instr, '\0', sizeof(memS)); instr.opcode = oP->opcode; /* Process operands. */ @@ -2551,7 +2551,7 @@ relax_addressT segment_address_in_file; symbolS *symbolP; /* JF this is for paranoia */ - bzero((char *)&ri, sizeof(ri)); + memset((char *)&ri, '\0', sizeof(ri)); know((symbolP = fixP->fx_addsy) != 0); diff --git a/gas/config/tc-m68kmote.c b/gas/config/tc-m68kmote.c index 8bf73ef..206312a 100644 --- a/gas/config/tc-m68kmote.c +++ b/gas/config/tc-m68kmote.c @@ -141,182 +141,182 @@ static struct obstack robyn; */ enum operand_type { - IMMED = 1, - DREG, - AREG, - AINDR, - ADEC, - AINC, - AOFF, - AINDX, - APODX, - AMIND, - APRDX, - ABSL, - MSCR, - REGLST, + IMMED = 1, + DREG, + AREG, + AINDR, + ADEC, + AINC, + AOFF, + AINDX, + APODX, + AMIND, + APRDX, + ABSL, + MSCR, + REGLST, }; struct m68k_exp { - char *e_beg; - char *e_end; - expressionS e_exp; - short e_siz; /* 0== default 1==short/byte 2==word 3==long */ + char *e_beg; + char *e_end; + expressionS e_exp; + short e_siz; /* 0== default 1==short/byte 2==word 3==long */ }; /* DATA and ADDR have to be contiguous, so that reg-DATA gives 0-7==data reg, 8-15==addr reg for operands that take both types */ enum _register { - DATA = 1, /* 1- 8 == data registers 0-7 */ - DATA0 = DATA, - DATA1, - DATA2, - DATA3, - DATA4, - DATA5, - DATA6, - DATA7, - - ADDR, - ADDR0 = ADDR, - ADDR1, - ADDR2, - ADDR3, - ADDR4, - ADDR5, - ADDR6, - ADDR7, - - /* Note that COPNUM==processor #1 -- COPNUM+7==#8, which stores as 000 */ - /* I think. . . */ - - SP = ADDR7, - - FPREG, /* Eight FP registers */ - FP0 = FPREG, - FP1, - FP2, - FP3, - FP4, - FP5, - FP6, - FP7, - COPNUM = (FPREG+8), /* Co-processor #1-#8 */ - COP0 = COPNUM, - COP1, - COP2, - COP3, - COP4, - COP5, - COP6, - COP7, - PC, /* Program counter */ - ZPC, /* Hack for Program space, but 0 addressing */ - SR, /* Status Reg */ - CCR, /* Condition code Reg */ - - /* These have to be in order for the movec instruction to work. */ - USP, /* User Stack Pointer */ - ISP, /* Interrupt stack pointer */ - SFC, - DFC, - CACR, - VBR, - CAAR, - MSP, - ITT0, - ITT1, - DTT0, - DTT1, - MMUSR, - TC, - SRP, - URP, - /* end of movec ordering constraints */ - - FPI, - FPS, - FPC, - - DRP, - CRP, - CAL, - VAL, - SCC, - AC, - BAD, - BAD0 = BAD, - BAD1, - BAD2, - BAD3, - BAD4, - BAD5, - BAD6, - BAD7, - BAC, - BAC0 = BAC, - BAC1, - BAC2, - BAC3, - BAC4, - BAC5, - BAC6, - BAC7, - PSR, - PCSR, - - IC, /* instruction cache token */ - DC, /* data cache token */ - NC, /* no cache token */ - BC, /* both caches token */ - + DATA = 1, /* 1- 8 == data registers 0-7 */ + DATA0 = DATA, + DATA1, + DATA2, + DATA3, + DATA4, + DATA5, + DATA6, + DATA7, + + ADDR, + ADDR0 = ADDR, + ADDR1, + ADDR2, + ADDR3, + ADDR4, + ADDR5, + ADDR6, + ADDR7, + + /* Note that COPNUM==processor #1 -- COPNUM+7==#8, which stores as 000 */ + /* I think. . . */ + + SP = ADDR7, + + FPREG, /* Eight FP registers */ + FP0 = FPREG, + FP1, + FP2, + FP3, + FP4, + FP5, + FP6, + FP7, + COPNUM = (FPREG+8), /* Co-processor #1-#8 */ + COP0 = COPNUM, + COP1, + COP2, + COP3, + COP4, + COP5, + COP6, + COP7, + PC, /* Program counter */ + ZPC, /* Hack for Program space, but 0 addressing */ + SR, /* Status Reg */ + CCR, /* Condition code Reg */ + + /* These have to be in order for the movec instruction to work. */ + USP, /* User Stack Pointer */ + ISP, /* Interrupt stack pointer */ + SFC, + DFC, + CACR, + VBR, + CAAR, + MSP, + ITT0, + ITT1, + DTT0, + DTT1, + MMUSR, + TC, + SRP, + URP, + /* end of movec ordering constraints */ + + FPI, + FPS, + FPC, + + DRP, + CRP, + CAL, + VAL, + SCC, + AC, + BAD, + BAD0 = BAD, + BAD1, + BAD2, + BAD3, + BAD4, + BAD5, + BAD6, + BAD7, + BAC, + BAC0 = BAC, + BAC1, + BAC2, + BAC3, + BAC4, + BAC5, + BAC6, + BAC7, + PSR, + PCSR, + + IC, /* instruction cache token */ + DC, /* data cache token */ + NC, /* no cache token */ + BC, /* both caches token */ + }; /* Internal form of an operand. */ struct m68k_op { - char *error; /* Couldn't parse it */ - enum operand_type mode; /* What mode this instruction is in. */ - enum _register reg; /* Base register */ - struct m68k_exp *con1; - int ireg; /* Index register */ - int isiz; /* 0==unspec 1==byte(?) 2==short 3==long */ - int imul; /* Multipy ireg by this (1,2,4,or 8) */ - struct m68k_exp *con2; + char *error; /* Couldn't parse it */ + enum operand_type mode; /* What mode this instruction is in. */ + enum _register reg; /* Base register */ + struct m68k_exp *con1; + int ireg; /* Index register */ + int isiz; /* 0==unspec 1==byte(?) 2==short 3==long */ + int imul; /* Multipy ireg by this (1,2,4,or 8) */ + struct m68k_exp *con2; }; /* internal form of a 68020 instruction */ struct m68k_it { - char *error; - char *args; /* list of opcode info */ - int numargs; - - int numo; /* Number of shorts in opcode */ - short opcode[11]; - - struct m68k_op operands[6]; - - int nexp; /* number of exprs in use */ - struct m68k_exp exprs[4]; - - int nfrag; /* Number of frags we have to produce */ - struct { - int fragoff; /* Where in the current opcode[] the frag ends */ - symbolS *fadd; - long foff; - int fragty; - } fragb[4]; - - int nrel; /* Num of reloc strucs in use */ - struct { - int n; - symbolS *add, - *sub; - long off; - char wid; - char pcrel; - } reloc[5]; /* Five is enough??? */ + char *error; + char *args; /* list of opcode info */ + int numargs; + + int numo; /* Number of shorts in opcode */ + short opcode[11]; + + struct m68k_op operands[6]; + + int nexp; /* number of exprs in use */ + struct m68k_exp exprs[4]; + + int nfrag; /* Number of frags we have to produce */ + struct { + int fragoff; /* Where in the current opcode[] the frag ends */ + symbolS *fadd; + long foff; + int fragty; + } fragb[4]; + + int nrel; /* Num of reloc strucs in use */ + struct { + int n; + symbolS *add, + *sub; + long off; + char wid; + char pcrel; + } reloc[5]; /* Five is enough??? */ }; #define cpu_of_arch(x) ((x) & m68000up) @@ -337,7 +337,7 @@ static struct m68k_it the_ins; /* the instruction being assembled */ the_ins.reloc[z].n+=2;\ the_ins.opcode[opcode->m_codenum]=w;\ the_ins.numo++;\ - } + } #define add_exp(beg,end) (\ @@ -356,14 +356,14 @@ static struct m68k_it the_ins; /* the instruction being assembled */ the_ins.reloc[the_ins.nrel].off=offs((exp));\ the_ins.reloc[the_ins.nrel].wid=width;\ the_ins.reloc[the_ins.nrel++].pcrel=pc_rel;\ - } + } #define add_frag(add,off,type) {\ the_ins.fragb[the_ins.nfrag].fragoff=the_ins.numo;\ the_ins.fragb[the_ins.nfrag].fadd=add;\ the_ins.fragb[the_ins.nfrag].foff=off;\ the_ins.fragb[the_ins.nfrag++].fragty=type;\ - } + } #define isvar(exp) ((exp) && (adds(exp) || subs(exp))) @@ -374,12 +374,12 @@ static struct m68k_it the_ins; /* the instruction being assembled */ struct m68k_incant { - char *m_operands; - unsigned long m_opcode; - short m_opnum; - short m_codenum; - enum m68k_architecture m_arch; - struct m68k_incant *m_next; + char *m_operands; + unsigned long m_opcode; + short m_opnum; + short m_codenum; + enum m68k_architecture m_arch; + struct m68k_incant *m_next; }; #define getone(x) ((((x)->m_opcode)>>16)&0xffff) @@ -439,42 +439,42 @@ static enum m68k_architecture current_architecture = 0; */ const relax_typeS md_relax_table[] = { - { 1, 1, 0, 0 }, /* First entries aren't used */ -{ 1, 1, 0, 0 }, /* For no good reason except */ -{ 1, 1, 0, 0 }, /* that the VAX doesn't either */ -{ 1, 1, 0, 0 }, - -{ (127), (-128), 0, TAB(BRANCH,SHORT)}, -{ (32767), (-32768), 2, TAB(BRANCH,LONG) }, -{ 0, 0, 4, 0 }, -{ 1, 1, 0, 0 }, - -{ 1, 1, 0, 0 }, /* FBRANCH doesn't come BYTE */ -{ (32767), (-32768), 2, TAB(FBRANCH,LONG)}, -{ 0, 0, 4, 0 }, -{ 1, 1, 0, 0 }, - -{ 1, 1, 0, 0 }, /* PCREL doesn't come BYTE */ -{ (32767), (-32768), 2, TAB(PCREL,LONG)}, -{ 0, 0, 4, 0 }, -{ 1, 1, 0, 0 }, - -{ (127), (-128), 0, TAB(BCC68000,SHORT)}, -{ (32767), (-32768), 2, TAB(BCC68000,LONG) }, -{ 0, 0, 6, 0 }, /* jmp long space */ -{ 1, 1, 0, 0 }, - -{ 1, 1, 0, 0 }, /* DBCC doesn't come BYTE */ -{ (32767), (-32768), 2, TAB(DBCC,LONG) }, -{ 0, 0, 10, 0 }, /* bra/jmp long space */ -{ 1, 1, 0, 0 }, - -{ 1, 1, 0, 0 }, /* PCLEA doesn't come BYTE */ -{ 32767, -32768, 2, TAB(PCLEA,LONG) }, -{ 0, 0, 6, 0 }, -{ 1, 1, 0, 0 }, - -}; + { 1, 1, 0, 0 }, /* First entries aren't used */ + { 1, 1, 0, 0 }, /* For no good reason except */ + { 1, 1, 0, 0 }, /* that the VAX doesn't either */ + { 1, 1, 0, 0 }, + + { (127), (-128), 0, TAB(BRANCH,SHORT)}, + { (32767), (-32768), 2, TAB(BRANCH,LONG) }, + { 0, 0, 4, 0 }, + { 1, 1, 0, 0 }, + + { 1, 1, 0, 0 }, /* FBRANCH doesn't come BYTE */ + { (32767), (-32768), 2, TAB(FBRANCH,LONG)}, + { 0, 0, 4, 0 }, + { 1, 1, 0, 0 }, + + { 1, 1, 0, 0 }, /* PCREL doesn't come BYTE */ + { (32767), (-32768), 2, TAB(PCREL,LONG)}, + { 0, 0, 4, 0 }, + { 1, 1, 0, 0 }, + + { (127), (-128), 0, TAB(BCC68000,SHORT)}, + { (32767), (-32768), 2, TAB(BCC68000,LONG) }, + { 0, 0, 6, 0 }, /* jmp long space */ + { 1, 1, 0, 0 }, + + { 1, 1, 0, 0 }, /* DBCC doesn't come BYTE */ + { (32767), (-32768), 2, TAB(DBCC,LONG) }, + { 0, 0, 10, 0 }, /* bra/jmp long space */ + { 1, 1, 0, 0 }, + + { 1, 1, 0, 0 }, /* PCLEA doesn't come BYTE */ + { 32767, -32768, 2, TAB(PCLEA,LONG) }, + { 0, 0, 6, 0 }, + { 1, 1, 0, 0 }, + + }; /* These are the machine dependent pseudo-ops. These are included so the assembler can work on the output from the SUN C compiler, which @@ -498,40 +498,40 @@ void s_ds(); void s_dcb(); void s_dc(); const pseudo_typeS md_pseudo_table[] = { -{ "xdef", s_globl, 0 }, -{ "sect", s_sect, 0 }, -{ "dc", s_dc, 2 }, -{ "dc.d", float_cons, 'd' }, -{ "dc.s", float_cons, 'f' }, -{ "dc.l", s_dc, 4 }, -{ "dc.w", s_dc, 2 }, -{ "dc.b", s_dc, 1 }, -{ "comline", s_ds, 1 }, -{ "ds.b", s_ds, 1 }, -{ "ds.w", s_ds, 2 }, -{ "ds", s_ds, 2 }, -{ "ds.l", s_ds, 4 }, -{ "ds.d", s_ds, 8 }, -{ "ds.s", s_ds, 4 }, -{ "dcb", s_dcb, 2 }, -{ "dcb.b", s_dcb, 1 }, -{ "dcb.w", s_dcb, 2 }, -{ "dcb.l", s_dcb, 4 }, -{ "xcom", s_comm, 0 }, -{ "align", s_align_bytes, 0 }, -{ "chip", s_chip, 0 }, -{ 0, 0, 0 } + { "xdef", s_globl, 0 }, + { "sect", s_sect, 0 }, + { "dc", s_dc, 2 }, + { "dc.d", float_cons, 'd' }, + { "dc.s", float_cons, 'f' }, + { "dc.l", s_dc, 4 }, + { "dc.w", s_dc, 2 }, + { "dc.b", s_dc, 1 }, + { "comline", s_ds, 1 }, + { "ds.b", s_ds, 1 }, + { "ds.w", s_ds, 2 }, + { "ds", s_ds, 2 }, + { "ds.l", s_ds, 4 }, + { "ds.d", s_ds, 8 }, + { "ds.s", s_ds, 4 }, + { "dcb", s_dcb, 2 }, + { "dcb.b", s_dcb, 1 }, + { "dcb.w", s_dcb, 2 }, + { "dcb.l", s_dcb, 4 }, + { "xcom", s_comm, 0 }, + { "align", s_align_bytes, 0 }, + { "chip", s_chip, 0 }, + { 0, 0, 0 } }; #else const pseudo_typeS md_pseudo_table[] = { -{ "data1", s_data1, 0 }, -{ "data2", s_data2, 0 }, -{ "bss", s_bss, 0 }, -{ "even", s_even, 0 }, -{ "skip", s_space, 0 }, -{ "proc", s_proc, 0 }, -{ 0, 0, 0 } + { "data1", s_data1, 0 }, + { "data2", s_data2, 0 }, + { "bss", s_bss, 0 }, + { "even", s_even, 0 }, + { "skip", s_space, 0 }, + { "proc", s_proc, 0 }, + { 0, 0, 0 } } @@ -546,16 +546,16 @@ const pseudo_typeS md_pseudo_table[] = { #define isubyte(x) ((x)>=0 && (x)<=255) #define issword(x) ((x)>=-32768 && (x)<=32767) #define isuword(x) ((x)>=0 && (x)<=65535) - + #define isbyte(x) ((x)>=-128 && (x)<=255) #define isword(x) ((x)>=-32768 && (x)<=65535) #define islong(x) (1) - - extern char *input_line_pointer; + +extern char *input_line_pointer; enum { - FAIL = 0, - OK = 1, + FAIL = 0, + OK = 1, }; /* JF these tables here are for speed at the expense of size */ @@ -564,7 +564,7 @@ enum { static char mklower_table[256]; #define mklower(c) (mklower_table[(unsigned char)(c)]) - static char notend_table[256]; +static char notend_table[256]; static char alt_notend_table[256]; #define notend(s) ( !(notend_table[(unsigned char)(*s)] || (*s==':' &&\ alt_notend_table[(unsigned char)(s[1])]))) @@ -572,7 +572,7 @@ static char alt_notend_table[256]; #if 0 #define mklower(c) (isupper(c) ? tolower(c) : c) #endif - + #define ISSPACE(x) ((x) == ' ' || (x) == '\t') #ifdef MRI #define MULTIPLIER '*' @@ -581,270 +581,270 @@ static char alt_notend_table[256]; #define MULTIPLIER ':' #define SIZER ':' #endif - - - /* JF modified this to handle cases where the first part of a symbol name - looks like a register */ - - /* - * m68k_reg_parse() := if it looks like a register, return it's token & - * advance the pointer. - */ - - enum _register m68k_reg_parse(ccp) + + +/* JF modified this to handle cases where the first part of a symbol name + looks like a register */ + +/* + * m68k_reg_parse() := if it looks like a register, return it's token & + * advance the pointer. + */ + +enum _register m68k_reg_parse(ccp) register char **ccp; { #ifndef MAX_REG_NAME_LEN #define MAX_REG_NAME_LEN (6) #endif /* MAX_REG_NAME_LEN */ - register char c[MAX_REG_NAME_LEN]; - char *p, *q; - register int n = 0, - ret = FAIL; - - c[0] = mklower(ccp[0][0]); + register char c[MAX_REG_NAME_LEN]; + char *p, *q; + register int n = 0, + ret = FAIL; + + c[0] = mklower(ccp[0][0]); #ifdef REGISTER_PREFIX - if (c[0] != REGISTER_PREFIX) { - return(FAIL); - } /* need prefix */ + if (c[0] != REGISTER_PREFIX) { + return(FAIL); + } /* need prefix */ #endif - - for (p = c, q = ccp[0]; p < c + MAX_REG_NAME_LEN; ++p, ++q) - { - if (*q == 0) - { - *p = 0; - break; - } - else - *p = mklower(*q); - } /* downcase */ - - switch(c[0]) { - case 'a': - if(c[1]>='0' && c[1]<='7') { - n=2; - ret=ADDR+c[1]-'0'; - } + + for (p = c, q = ccp[0]; p < c + MAX_REG_NAME_LEN; ++p, ++q) + { + if (*q == 0) + { + *p = 0; + break; + } + else + *p = mklower(*q); + } /* downcase */ + + switch(c[0]) { + case 'a': + if(c[1]>='0' && c[1]<='7') { + n=2; + ret=ADDR+c[1]-'0'; + } #ifndef NO_68851 - else if (c[1] == 'c') { - n = 2; - ret = AC; - } + else if (c[1] == 'c') { + n = 2; + ret = AC; + } #endif - break; + break; #ifndef NO_68851 - case 'b': - if (c[1] == 'a') { - if (c[2] == 'd') { - if (c[3] >= '0' && c[3] <= '7') { - n = 4; - ret = BAD + c[3] - '0'; - } - } /* BAD */ - if (c[2] == 'c') { - if (c[3] >= '0' && c[3] <= '7') { - n = 4; - ret = BAC + c[3] - '0'; - } - } /* BAC */ - } else if (c[1] == 'c') { - n = 2; - ret = BC; - } /* BC */ - break; + case 'b': + if (c[1] == 'a') { + if (c[2] == 'd') { + if (c[3] >= '0' && c[3] <= '7') { + n = 4; + ret = BAD + c[3] - '0'; + } + } /* BAD */ + if (c[2] == 'c') { + if (c[3] >= '0' && c[3] <= '7') { + n = 4; + ret = BAC + c[3] - '0'; + } + } /* BAC */ + } else if (c[1] == 'c') { + n = 2; + ret = BC; + } /* BC */ + break; #endif - case 'c': + case 'c': #ifndef NO_68851 - if (c[1] == 'a' && c[2] == 'l') { - n = 3; - ret = CAL; - } else + if (c[1] == 'a' && c[2] == 'l') { + n = 3; + ret = CAL; + } else #endif - /* This supports both CCR and CC as the ccr reg. */ - if(c[1]=='c' && c[2]=='r') { - n=3; - ret = CCR; - } else if(c[1]=='c') { - n=2; - ret = CCR; - } else if(c[1]=='a' && (c[2]=='a' || c[2]=='c') && c[3]=='r') { - n=4; - ret = c[2]=='a' ? CAAR : CACR; - } + /* This supports both CCR and CC as the ccr reg. */ + if(c[1]=='c' && c[2]=='r') { + n=3; + ret = CCR; + } else if(c[1]=='c') { + n=2; + ret = CCR; + } else if(c[1]=='a' && (c[2]=='a' || c[2]=='c') && c[3]=='r') { + n=4; + ret = c[2]=='a' ? CAAR : CACR; + } #ifndef NO_68851 - else if (c[1] == 'r' && c[2] == 'p') { - n = 3; - ret = (CRP); - } + else if (c[1] == 'r' && c[2] == 'p') { + n = 3; + ret = (CRP); + } #endif - break; - case 'd': - if (c[1] >= '0' && c[1] <= '7') { - n = 2; - ret = DATA + c[1] - '0'; - } else if (c[1] == 'f' && c[2] == 'c') { - n = 3; - ret = DFC; - } else if (c[1] == 'c') { - n = 2; - ret = DC; - } else if (c[1] == 't' && c[2] == 't') { - if ('0' <= c[3] && c[3] <= '1') { - n = 4; - ret = DTT0 + (c[3] - '0'); - } /* DTT[01] */ - } + break; + case 'd': + if (c[1] >= '0' && c[1] <= '7') { + n = 2; + ret = DATA + c[1] - '0'; + } else if (c[1] == 'f' && c[2] == 'c') { + n = 3; + ret = DFC; + } else if (c[1] == 'c') { + n = 2; + ret = DC; + } else if (c[1] == 't' && c[2] == 't') { + if ('0' <= c[3] && c[3] <= '1') { + n = 4; + ret = DTT0 + (c[3] - '0'); + } /* DTT[01] */ + } #ifndef NO_68851 - else if (c[1] == 'r' && c[2] == 'p') { - n = 3; - ret = (DRP); - } + else if (c[1] == 'r' && c[2] == 'p') { + n = 3; + ret = (DRP); + } #endif - break; - case 'f': - if(c[1]=='p') { - if(c[2]>='0' && c[2]<='7') { - n=3; - ret = FPREG+c[2]-'0'; - if(c[3]==':') - ccp[0][3]=','; - } else if(c[2]=='i') { - n=3; - ret = FPI; - } else if(c[2]=='s') { - n= (c[3] == 'r' ? 4 : 3); - ret = FPS; - } else if(c[2]=='c') { - n= (c[3] == 'r' ? 4 : 3); - ret = FPC; - } else if (!isalpha(c[2]) && !isdigit(c[2])) { - n = 2; - ret = ADDR + 6; - } - - - } - break; - case 'i': - if (c[1] == 's' && c[2] == 'p') { - n = 3; - ret = ISP; - } else if (c[1] == 'c') { - n = 2; - ret = IC; - } else if (c[1] == 't' && c[2] == 't') { - if ('0' <= c[3] && c[3] <= '1') { - n = 4; - ret = ITT0 + (c[3] - '0'); - } /* ITT[01] */ - } - break; - case 'm': - if (c[1] == 's' && c[2] == 'p') { - n = 3; - ret = MSP; - } else if (c[1] == 'm' && c[2] == 'u' && c[3] == 's' && c[4] == 'r') { - n = 5; - ret = MMUSR; - } - break; - case 'n': - if (c[1] == 'c') { - n = 2; - ret = NC; - } - break; - case 'p': - if(c[1]=='c') { + break; + case 'f': + if(c[1]=='p') { + if(c[2]>='0' && c[2]<='7') { + n=3; + ret = FPREG+c[2]-'0'; + if(c[3]==':') + ccp[0][3]=','; + } else if(c[2]=='i') { + n=3; + ret = FPI; + } else if(c[2]=='s') { + n= (c[3] == 'r' ? 4 : 3); + ret = FPS; + } else if(c[2]=='c') { + n= (c[3] == 'r' ? 4 : 3); + ret = FPC; + } else if (!isalpha(c[2]) && !isdigit(c[2])) { + n = 2; + ret = ADDR + 6; + } + + + } + break; + case 'i': + if (c[1] == 's' && c[2] == 'p') { + n = 3; + ret = ISP; + } else if (c[1] == 'c') { + n = 2; + ret = IC; + } else if (c[1] == 't' && c[2] == 't') { + if ('0' <= c[3] && c[3] <= '1') { + n = 4; + ret = ITT0 + (c[3] - '0'); + } /* ITT[01] */ + } + break; + case 'm': + if (c[1] == 's' && c[2] == 'p') { + n = 3; + ret = MSP; + } else if (c[1] == 'm' && c[2] == 'u' && c[3] == 's' && c[4] == 'r') { + n = 5; + ret = MMUSR; + } + break; + case 'n': + if (c[1] == 'c') { + n = 2; + ret = NC; + } + break; + case 'p': + if(c[1]=='c') { #ifndef NO_68851 - if(c[2] == 's' && c[3]=='r') { - n=4; - ret = (PCSR); - } else + if(c[2] == 's' && c[3]=='r') { + n=4; + ret = (PCSR); + } else #endif - { - n=2; - ret = PC; - } - } + { + n=2; + ret = PC; + } + } #ifndef NO_68851 - else if (c[1] == 's' && c[2] == 'r') { - n = 3; - ret = (PSR); - } + else if (c[1] == 's' && c[2] == 'r') { + n = 3; + ret = (PSR); + } #endif - break; - case 's': + break; + case 's': #ifndef NO_68851 - if (c[1] == 'c' && c[2] == 'c') { - n = 3; - ret = (SCC); - } else + if (c[1] == 'c' && c[2] == 'c') { + n = 3; + ret = (SCC); + } else #endif - if (c[1] == 'r') { - if (c[2] == 'p') { - n = 3; - ret = SRP; - } else { - n = 2; - ret = SR; - } /* srp else sr */ - } else if (c[1] == 'p') { - n = 2; - ret = SP; - } else if (c[1] == 'f' && c[2] == 'c') { - n = 3; - ret = SFC; - } - break; - case 't': - if (c[1] == 'c') { - n = 2; - ret = TC; - } - break; - case 'u': - if (c[1] == 's' && c[2] == 'p') { - n=3; - ret = USP; - } else if (c[1] == 'r' && c[2] == 'p') { - n = 3; - ret = URP; - } - break; - case 'v': + if (c[1] == 'r') { + if (c[2] == 'p') { + n = 3; + ret = SRP; + } else { + n = 2; + ret = SR; + } /* srp else sr */ + } else if (c[1] == 'p') { + n = 2; + ret = SP; + } else if (c[1] == 'f' && c[2] == 'c') { + n = 3; + ret = SFC; + } + break; + case 't': + if (c[1] == 'c') { + n = 2; + ret = TC; + } + break; + case 'u': + if (c[1] == 's' && c[2] == 'p') { + n=3; + ret = USP; + } else if (c[1] == 'r' && c[2] == 'p') { + n = 3; + ret = URP; + } + break; + case 'v': #ifndef NO_68851 - if (c[1] == 'a' && c[2] == 'l') { - n = 3; - ret = (VAL); - } else + if (c[1] == 'a' && c[2] == 'l') { + n = 3; + ret = (VAL); + } else #endif - if(c[1]=='b' && c[2]=='r') { - n=3; - ret = VBR; - } - break; - case 'z': - if(c[1]=='p' && c[2]=='c') { - n=3; - ret = ZPC; + if(c[1]=='b' && c[2]=='r') { + n=3; + ret = VBR; + } + break; + case 'z': + if(c[1]=='p' && c[2]=='c') { + n=3; + ret = ZPC; + } + break; + default: + break; } - break; - default: - break; - } - if(n) { + if(n) { #ifdef REGISTER_PREFIX - n++; + n++; #endif - if(isalnum(ccp[0][n]) || ccp[0][n]=='_') - ret=FAIL; - else - ccp[0]+=n; - } else - ret = FAIL; - return ret; + if(isalnum(ccp[0][n]) || ccp[0][n]=='_') + ret=FAIL; + else + ccp[0]+=n; + } else + ret = FAIL; + return ret; } #define SKIP_WHITE() { str++; if(ISSPACE(*str)) str++;} @@ -858,258 +858,258 @@ int char *str; register struct m68k_op *opP; { - char *strend; - long i; - char *parse_index(); - - /* Skip leading blank */ - if(ISSPACE(*str)) - str++; - if(!*str) { - opP->error="Missing operand"; - return FAIL; - } - /* *strend = last character of string */ - for(strend=str;*strend;strend++) - ; - --strend; - - /* Logic of the parsing switch(*str): - case opP->mode = - ---- ----------- - #anything IMMED 1 - REG AREG or DREG or MSCR 3 or 2 or 13 - REG- or REG/ REGLST 14 - (REG) AINDR 4 - (REG)+ AINC 6 - (REG,INDX) AINDX 8 - (EXPR,REG) AOFF 7 - (EXPR,REG,INDX) AINDX 8 - -(REG) ADEC 5 - EXP2(REG) AOFF 7 - EXP2(REG,INDX) AINDX 8 - EXP2 ABSL 12 - - REG means truth(m68k_reg_parse(&str)) - INDX means truth(try_index(&str,opP)) - EXPR means not REG - EXP2 means not REG and not '(' and not '-(' - */ - - if(*str=='#') { - /* "#" Immediate mode */ - str++; - opP->con1=add_exp(str,strend); - opP->mode=IMMED; - return OK; - } - - i=m68k_reg_parse(&str); - if (i!=FAIL) { - if(*str=='\0') { - /* "Rn" Register Direct mode */ - opP->reg=i; - if(i>=DATA+0 && i<=DATA+7) - opP->mode=DREG; - else if(i>=ADDR+0 && i<=ADDR+7) - opP->mode=AREG; - else - opP->mode=MSCR; - return OK; - } - else if(*str=='/' || *str=='-') { - /* "Rm-Rn/Ro-Rp" Register list for MOVEM instruction */ - opP->mode=REGLST; - return get_regs(i,str,opP); + char *strend; + long i; + char *parse_index(); + + /* Skip leading blank */ + if(ISSPACE(*str)) + str++; + if(!*str) { + opP->error="Missing operand"; + return FAIL; } - else { - opP->error="Junk after register name"; - return FAIL; + /* *strend = last character of string */ + for(strend=str;*strend;strend++) + ; + --strend; + + /* Logic of the parsing switch(*str): + case opP->mode = + ---- ----------- + #anything IMMED 1 + REG AREG or DREG or MSCR 3 or 2 or 13 + REG- or REG/ REGLST 14 + (REG) AINDR 4 + (REG)+ AINC 6 + (REG,INDX) AINDX 8 + (EXPR,REG) AOFF 7 + (EXPR,REG,INDX) AINDX 8 + -(REG) ADEC 5 + EXP2(REG) AOFF 7 + EXP2(REG,INDX) AINDX 8 + EXP2 ABSL 12 + + REG means truth(m68k_reg_parse(&str)) + INDX means truth(try_index(&str,opP)) + EXPR means not REG + EXP2 means not REG and not '(' and not '-(' + */ + + if(*str=='#') { + /* "#" Immediate mode */ + str++; + opP->con1=add_exp(str,strend); + opP->mode=IMMED; + return OK; } - } - - if(*str=='(') { - str++; + i=m68k_reg_parse(&str); - if((iADDR+7) && i!=PC && i!=ZPC && i!=FAIL) { - /* Can't indirect off non address regs */ - opP->error="Invalid indirect register"; - return FAIL; - } - if(i!=FAIL) { - opP->reg=i; - if(*str==')') { - str++; + if (i!=FAIL) { if(*str=='\0') { - /* "(An)" Address Register Indirect mode */ - opP->mode=AINDR; - return OK; - } - if(*str=='+') { - if(str[1]=='\0') { - /* "(An)+" Register Indirect w Postincrement */ - opP->mode=AINC; + /* "Rn" Register Direct mode */ + opP->reg=i; + if(i>=DATA+0 && i<=DATA+7) + opP->mode=DREG; + else if(i>=ADDR+0 && i<=ADDR+7) + opP->mode=AREG; + else + opP->mode=MSCR; return OK; - } } - opP->error="Junk after indirect"; - return FAIL; - } - if(*str==',') { - str++; - i=try_index(&str,opP); - if(i==FAIL) return FAIL; - /* "(An,Rn)" Register Indirect with Index mode*/ - opP->mode=AINDX; - return OK; - } - else { - opP->error="Bad indirect syntax"; - return FAIL; - } + else if(*str=='/' || *str=='-') { + /* "Rm-Rn/Ro-Rp" Register list for MOVEM instruction */ + opP->mode=REGLST; + return get_regs(i,str,opP); + } + else { + opP->error="Junk after register name"; + return FAIL; + } } - else { - /* "(EXPR,..." , a displacement */ - char *stmp; - char *index(); - - if(stmp=index(str,',')) { - opP->con1=add_exp(str,stmp-1); - str=stmp; - SKIP_WHITE(); + + if(*str=='(') { + str++; i=m68k_reg_parse(&str); - if((iADDR+7) && i!=PC && i!=ZPC) { - /* Can't indirect off non address regs */ - opP->error="Invalid indirect register"; - return FAIL; + if((iADDR+7) && i!=PC && i!=ZPC && i!=FAIL) { + /* Can't indirect off non address regs */ + opP->error="Invalid indirect register"; + return FAIL; } if(i!=FAIL) { - opP->reg=i; - if(*str==')') { - /* "(d,An)" Register Indirect w Displacement */ - opP->mode=AOFF; - return OK; - } - if(*str==',') { - str++; - i=try_index(&str,opP); - if(i==FAIL) return FAIL; - /* "(d,An,Rn)" Register Indirect with Index */ - opP->mode=AINDX; - return OK; - } - else { - opP->error="Bad indirect syntax"; - return FAIL; - } + opP->reg=i; + if(*str==')') { + str++; + if(*str=='\0') { + /* "(An)" Address Register Indirect mode */ + opP->mode=AINDR; + return OK; + } + if(*str=='+') { + if(str[1]=='\0') { + /* "(An)+" Register Indirect w Postincrement */ + opP->mode=AINC; + return OK; + } + } + opP->error="Junk after indirect"; + return FAIL; + } + if(*str==',') { + str++; + i=try_index(&str,opP); + if(i==FAIL) return FAIL; + /* "(An,Rn)" Register Indirect with Index mode*/ + opP->mode=AINDX; + return OK; + } + else { + opP->error="Bad indirect syntax"; + return FAIL; + } } else { - opP->error="Invalid register"; - return FAIL; + /* "(EXPR,..." , a displacement */ + char *stmp; + char *index(); + + if(stmp=index(str,',')) { + opP->con1=add_exp(str,stmp-1); + str=stmp; + SKIP_WHITE(); + i=m68k_reg_parse(&str); + if((iADDR+7) && i!=PC && i!=ZPC) { + /* Can't indirect off non address regs */ + opP->error="Invalid indirect register"; + return FAIL; + } + if(i!=FAIL) { + opP->reg=i; + if(*str==')') { + /* "(d,An)" Register Indirect w Displacement */ + opP->mode=AOFF; + return OK; + } + if(*str==',') { + str++; + i=try_index(&str,opP); + if(i==FAIL) return FAIL; + /* "(d,An,Rn)" Register Indirect with Index */ + opP->mode=AINDX; + return OK; + } + else { + opP->error="Bad indirect syntax"; + return FAIL; + } + } + else { + opP->error="Invalid register"; + return FAIL; + } + } + else { + opP->error="Missing register for indirect"; + return FAIL; + } } - } - else { - opP->error="Missing register for indirect"; - return FAIL; - } } - } - - if(*str=='-') { - if(str[1]=='(') { - str = str+2; - i=m68k_reg_parse(&str); - if((iADDR+7) && i!=PC && i!=ZPC && i!=FAIL) { - /* Can't indirect off non address regs */ - opP->error="Invalid indirect register"; - return FAIL; - } - if(i!=FAIL) { - opP->reg=i; - if(*str==')') { - str++; - if(*str=='\0') { - /* "-(An)" Register Indirect with Predecrement */ - opP->mode=ADEC; - return OK; - } - opP->error="Junk after indirect"; - return FAIL; + + if(*str=='-') { + if(str[1]=='(') { + str = str+2; + i=m68k_reg_parse(&str); + if((iADDR+7) && i!=PC && i!=ZPC && i!=FAIL) { + /* Can't indirect off non address regs */ + opP->error="Invalid indirect register"; + return FAIL; + } + if(i!=FAIL) { + opP->reg=i; + if(*str==')') { + str++; + if(*str=='\0') { + /* "-(An)" Register Indirect with Predecrement */ + opP->mode=ADEC; + return OK; + } + opP->error="Junk after indirect"; + return FAIL; + } + opP->error="Bad indirect syntax"; + return FAIL; + } + opP->error="Invalid register"; + return FAIL; } - opP->error="Bad indirect syntax"; - return FAIL; - } - opP->error="Invalid register"; - return FAIL; - } - /* if '-' but not "-(', do nothing */ - } - - /* whether *str=='-' or not */ -{ - /* "EXP2" or "EXP2(REG..." */ - char *stmp; - char *index(); - if(stmp=index(str,'(')) { - opP->con1=add_exp(str,stmp-1); - str=stmp+1; - i=m68k_reg_parse(&str); - if((iADDR+7) && i!=PC && i!=ZPC) { - /* Can't indirect off non address regs */ - opP->error="Invalid indirect register"; - return FAIL; - } - if(i!=FAIL) { - opP->reg=i; - if(*str==')') { - /* "d(An)" Register Indirect w Displacement */ - opP->mode=AOFF; - return OK; - } - if(*str==',') { - str++; - i=try_index(&str,opP); - if(i==FAIL) return FAIL; - /* "d(An,Rn)" Register Indirect with Index */ - opP->mode=AINDX; - return OK; - } - else { - opP->error="Bad indirect syntax"; - return FAIL; - } - } - else { - opP->error="Invalid register"; - return FAIL; + /* if '-' but not "-(', do nothing */ } - } - else { - /* "EXP2" Absolute */ - opP->mode=ABSL; - if(strend[-1]=='.') { /* mode ==foo.[wl] */ - switch(*strend) { - case 'w': - case 'W': - opP->isiz=2; - break; - case 'l': - case 'L': - opP->isiz=3; - break; - default: - opP->error="Size spec not .W or .L"; - return FAIL; - } - strend-=2; - } - else opP->isiz=0; - - opP->con1=add_exp(str,strend); - return OK; - } -} + /* whether *str=='-' or not */ + { + /* "EXP2" or "EXP2(REG..." */ + char *stmp; + char *index(); + if(stmp=index(str,'(')) { + opP->con1=add_exp(str,stmp-1); + str=stmp+1; + i=m68k_reg_parse(&str); + if((iADDR+7) && i!=PC && i!=ZPC) { + /* Can't indirect off non address regs */ + opP->error="Invalid indirect register"; + return FAIL; + } + if(i!=FAIL) { + opP->reg=i; + if(*str==')') { + /* "d(An)" Register Indirect w Displacement */ + opP->mode=AOFF; + return OK; + } + if(*str==',') { + str++; + i=try_index(&str,opP); + if(i==FAIL) return FAIL; + /* "d(An,Rn)" Register Indirect with Index */ + opP->mode=AINDX; + return OK; + } + else { + opP->error="Bad indirect syntax"; + return FAIL; + } + } + else { + opP->error="Invalid register"; + return FAIL; + } + } + else { + /* "EXP2" Absolute */ + opP->mode=ABSL; + if(strend[-1]=='.') { /* mode ==foo.[wl] */ + switch(*strend) { + case 'w': + case 'W': + opP->isiz=2; + break; + case 'l': + case 'L': + opP->isiz=3; + break; + default: + opP->error="Size spec not .W or .L"; + return FAIL; + } + strend-=2; + } + else opP->isiz=0; + + + opP->con1=add_exp(str,strend); + return OK; + } + } } /* end of m68k_ip_op () */ #else @@ -1129,237 +1129,237 @@ int char *str; register struct m68k_op *opP; { - char *strend; - long i; - char *parse_index(); - - if (ISSPACE(*str)) { - str++; - } /* Find the beginning of the string */ - - if(!*str) { - opP->error="Missing operand"; - return FAIL; - } /* Out of gas */ - - for(strend = str; *strend; strend++) ;; - - --strend; - - if(*str=='#') { - str++; - opP->con1=add_exp(str,strend); - opP->mode=IMMED; - return OK; - } /* Guess what: A constant. Shar and enjoy */ - - i = m68k_reg_parse(&str); - - /* is a register, is exactly a register, and is followed by '@' */ - - if((i==FAIL || *str!='\0') && *str!='@') { - char *stmp; - - if(i!=FAIL && (*str=='/' || *str=='-')) { - opP->mode=REGLST; - return(get_regs(i,str,opP)); - } - if ((stmp=strchr(str,'@')) != '\0') { - opP->con1=add_exp(str,stmp-1); - if(stmp==strend) { - opP->mode=AINDX; - return(OK); - } - - if ((current_architecture & m68020up) == 0) { - return(FAIL); - } /* if target is not a '20 or better */ - - stmp++; - if(*stmp++!='(' || *strend--!=')') { - opP->error="Malformed operand"; - return(FAIL); - } - i=try_index(&stmp,opP); - opP->con2=add_exp(stmp,strend); - - if (i == FAIL) { - opP->mode=AMIND; - } else { - opP->mode=APODX; - } - return(OK); - } /* if there's an '@' */ - opP->mode = ABSL; - opP->con1 = add_exp(str,strend); - return(OK); - } /* not a register, not exactly a register, or no '@' */ - - opP->reg=i; - - if (*str=='\0') { - if(i>=DATA+0 && i<=DATA+7) - opP->mode=DREG; - else if(i>=ADDR+0 && i<=ADDR+7) - opP->mode=AREG; - else - opP->mode=MSCR; - return OK; - } - - if((iADDR+7) && i!=PC && i!=ZPC && i!=FAIL) { /* Can't indirect off non address regs */ - opP->error="Invalid indirect register"; - return FAIL; - } - know(*str == '@'); - - str++; - switch(*str) { - case '\0': - opP->mode=AINDR; - return OK; - case '-': - opP->mode=ADEC; - return OK; - case '+': - opP->mode=AINC; - return OK; - case '(': - str++; - break; - default: - opP->error="Junk after indirect"; - return FAIL; - } - /* Some kind of indexing involved. Lets find out how bad it is */ - i=try_index(&str,opP); - /* Didn't start with an index reg, maybe its offset or offset,reg */ - if(i==FAIL) { - char *beg_str; + char *strend; + long i; + char *parse_index(); - beg_str=str; - for(i=1;i;) { - switch(*str++) { - case '\0': - opP->error="Missing )"; + if (ISSPACE(*str)) { + str++; + } /* Find the beginning of the string */ + + if(!*str) { + opP->error="Missing operand"; return FAIL; - case ',': i=0; break; - case '(': i++; break; - case ')': --i; break; - } + } /* Out of gas */ + + for(strend = str; *strend; strend++) ;; + + --strend; + + if(*str=='#') { + str++; + opP->con1=add_exp(str,strend); + opP->mode=IMMED; + return OK; + } /* Guess what: A constant. Shar and enjoy */ + + i = m68k_reg_parse(&str); + + /* is a register, is exactly a register, and is followed by '@' */ + + if((i==FAIL || *str!='\0') && *str!='@') { + char *stmp; + + if(i!=FAIL && (*str=='/' || *str=='-')) { + opP->mode=REGLST; + return(get_regs(i,str,opP)); + } + if ((stmp=strchr(str,'@')) != '\0') { + opP->con1=add_exp(str,stmp-1); + if(stmp==strend) { + opP->mode=AINDX; + return(OK); + } + + if ((current_architecture & m68020up) == 0) { + return(FAIL); + } /* if target is not a '20 or better */ + + stmp++; + if(*stmp++!='(' || *strend--!=')') { + opP->error="Malformed operand"; + return(FAIL); + } + i=try_index(&stmp,opP); + opP->con2=add_exp(stmp,strend); + + if (i == FAIL) { + opP->mode=AMIND; + } else { + opP->mode=APODX; + } + return(OK); + } /* if there's an '@' */ + opP->mode = ABSL; + opP->con1 = add_exp(str,strend); + return(OK); + } /* not a register, not exactly a register, or no '@' */ + + opP->reg=i; + + if (*str=='\0') { + if(i>=DATA+0 && i<=DATA+7) + opP->mode=DREG; + else if(i>=ADDR+0 && i<=ADDR+7) + opP->mode=AREG; + else + opP->mode=MSCR; + return OK; } - /* if(str[-3]==':') { - int siz; - - switch(str[-2]) { - case 'b': - case 'B': - siz=1; - break; - case 'w': - case 'W': - siz=2; - break; - case 'l': - case 'L': - siz=3; - break; - default: - opP->error="Specified size isn't :w or :l"; - return FAIL; - } - opP->con1=add_exp(beg_str,str-4); - opP->con1->e_siz=siz; - } else */ - opP->con1=add_exp(beg_str,str-2); - /* Should be offset,reg */ - if(str[-1]==',') { - i=try_index(&str,opP); - if(i==FAIL) { - opP->error="Malformed index reg"; + + if((iADDR+7) && i!=PC && i!=ZPC && i!=FAIL) { /* Can't indirect off non address regs */ + opP->error="Invalid indirect register"; return FAIL; - } } - } - /* We've now got offset) offset,reg) or reg) */ - - if (*str == '\0') { - /* Th-the-thats all folks */ - if (opP->reg == FAIL) opP->mode = AINDX; /* Other form of indirect */ - else if(opP->ireg == FAIL) opP->mode = AOFF; - else opP->mode = AINDX; - return(OK); - } - /* Next thing had better be another @ */ - if(*str!='@' || str[1]!='(') { - opP->error = "junk after indirect"; - return(FAIL); - } - - if ((current_architecture & m68020up) == 0) { - return(FAIL); - } /* if target is not a '20 or better */ - - str+=2; - - if(opP->ireg != FAIL) { - opP->mode = APRDX; - - i = try_index(&str, opP); - if (i != FAIL) { - opP->error = "Two index registers! not allowed!"; - return(FAIL); + know(*str == '@'); + + str++; + switch(*str) { + case '\0': + opP->mode=AINDR; + return OK; + case '-': + opP->mode=ADEC; + return OK; + case '+': + opP->mode=AINC; + return OK; + case '(': + str++; + break; + default: + opP->error="Junk after indirect"; + return FAIL; } - } else { - i = try_index(&str, opP); - } - - if (i == FAIL) { - char *beg_str; - - beg_str = str; - - for (i = 1; i; ) { - switch(*str++) { - case '\0': - opP->error="Missing )"; - return(FAIL); - case ',': i=0; break; - case '(': i++; break; - case ')': --i; break; - } + /* Some kind of indexing involved. Lets find out how bad it is */ + i=try_index(&str,opP); + /* Didn't start with an index reg, maybe its offset or offset,reg */ + if(i==FAIL) { + char *beg_str; + + beg_str=str; + for(i=1;i;) { + switch(*str++) { + case '\0': + opP->error="Missing )"; + return FAIL; + case ',': i=0; break; + case '(': i++; break; + case ')': --i; break; + } + } + /* if(str[-3]==':') { + int siz; + + switch(str[-2]) { + case 'b': + case 'B': + siz=1; + break; + case 'w': + case 'W': + siz=2; + break; + case 'l': + case 'L': + siz=3; + break; + default: + opP->error="Specified size isn't :w or :l"; + return FAIL; + } + opP->con1=add_exp(beg_str,str-4); + opP->con1->e_siz=siz; + } else */ + opP->con1=add_exp(beg_str,str-2); + /* Should be offset,reg */ + if(str[-1]==',') { + i=try_index(&str,opP); + if(i==FAIL) { + opP->error="Malformed index reg"; + return FAIL; + } + } } + /* We've now got offset) offset,reg) or reg) */ - opP->con2=add_exp(beg_str,str-2); - - if (str[-1] == ',') { - if (opP->ireg != FAIL) { - opP->error = "Can't have two index regs"; + if (*str == '\0') { + /* Th-the-thats all folks */ + if (opP->reg == FAIL) opP->mode = AINDX; /* Other form of indirect */ + else if(opP->ireg == FAIL) opP->mode = AOFF; + else opP->mode = AINDX; + return(OK); + } + /* Next thing had better be another @ */ + if(*str!='@' || str[1]!='(') { + opP->error = "junk after indirect"; return(FAIL); - } - - i = try_index(&str, opP); - - if (i == FAIL) { - opP->error = "malformed index reg"; + } + + if ((current_architecture & m68020up) == 0) { return(FAIL); - } - - opP->mode = APODX; - } else if (opP->ireg != FAIL) { - opP->mode = APRDX; + } /* if target is not a '20 or better */ + + str+=2; + + if(opP->ireg != FAIL) { + opP->mode = APRDX; + + i = try_index(&str, opP); + if (i != FAIL) { + opP->error = "Two index registers! not allowed!"; + return(FAIL); + } + } else { + i = try_index(&str, opP); + } + + if (i == FAIL) { + char *beg_str; + + beg_str = str; + + for (i = 1; i; ) { + switch(*str++) { + case '\0': + opP->error="Missing )"; + return(FAIL); + case ',': i=0; break; + case '(': i++; break; + case ')': --i; break; + } + } + + opP->con2=add_exp(beg_str,str-2); + + if (str[-1] == ',') { + if (opP->ireg != FAIL) { + opP->error = "Can't have two index regs"; + return(FAIL); + } + + i = try_index(&str, opP); + + if (i == FAIL) { + opP->error = "malformed index reg"; + return(FAIL); + } + + opP->mode = APODX; + } else if (opP->ireg != FAIL) { + opP->mode = APRDX; + } else { + opP->mode = AMIND; + } } else { - opP->mode = AMIND; + opP->mode = APODX; + } + + if(*str!='\0') { + opP->error="Junk after indirect"; + return FAIL; } - } else { - opP->mode = APODX; - } - - if(*str!='\0') { - opP->error="Junk after indirect"; - return FAIL; - } - return(OK); + return(OK); } /* m68k_ip_op() */ #endif /* @@ -1380,100 +1380,100 @@ register struct m68k_op *opP; */ static int try_index(s,opP) - char **s; - struct m68k_op *opP; +char **s; +struct m68k_op *opP; { - register int i; - char *ss; + register int i; + char *ss; #define SKIP_W() { ss++; if (ISSPACE(*ss)) ss++;} - - ss= *s; - /* SKIP_W(); */ - i=m68k_reg_parse(&ss); - if(!(i>=DATA+0 && i<=ADDR+7)) { /* if i is not DATA or ADDR reg */ - *s=ss; - return FAIL; - } - opP->ireg=i; - /* SKIP_W(); */ - if(*ss==')') { - opP->isiz=0; - opP->imul=1; - SKIP_W(); - *s=ss; - return OK; - } - if(*ss!=SIZER) - { - opP->error="Missing : in index register"; - *s=ss; - return FAIL; - } - SKIP_W(); - switch(*ss) { - case 'w': - case 'W': - opP->isiz=2; - break; - case 'l': - case 'L': - opP->isiz=3; - break; - default: - opP->error="Index register size spec not :w or :l"; - *s=ss; - return FAIL; - } - SKIP_W(); - if(*ss==MULTIPLIER) - { + + ss= *s; + /* SKIP_W(); */ + i=m68k_reg_parse(&ss); + if(!(i>=DATA+0 && i<=ADDR+7)) { /* if i is not DATA or ADDR reg */ + *s=ss; + return FAIL; + } + opP->ireg=i; + /* SKIP_W(); */ + if(*ss==')') { + opP->isiz=0; + opP->imul=1; + SKIP_W(); + *s=ss; + return OK; + } + if(*ss!=SIZER) + { + opP->error="Missing : in index register"; + *s=ss; + return FAIL; + } SKIP_W(); switch(*ss) { - case '1': - case '2': - case '4': - case '8': - opP->imul= *ss-'0'; - break; + case 'w': + case 'W': + opP->isiz=2; + break; + case 'l': + case 'L': + opP->isiz=3; + break; default: - opP->error="index multiplier not 1, 2, 4 or 8"; - *s=ss; - return FAIL; + opP->error="Index register size spec not :w or :l"; + *s=ss; + return FAIL; + } + SKIP_W(); + if(*ss==MULTIPLIER) + { + SKIP_W(); + switch(*ss) { + case '1': + case '2': + case '4': + case '8': + opP->imul= *ss-'0'; + break; + default: + opP->error="index multiplier not 1, 2, 4 or 8"; + *s=ss; + return FAIL; + } + SKIP_W(); + } else opP->imul=1; + if(*ss!=')') { + opP->error="Missing )"; + *s=ss; + return FAIL; } SKIP_W(); - } else opP->imul=1; - if(*ss!=')') { - opP->error="Missing )"; *s=ss; - return FAIL; - } - SKIP_W(); - *s=ss; - return OK; + return OK; } /* try_index() */ #ifdef TEST1 /* TEST1 tests m68k_ip_op(), which parses operands */ main() { - char buf[128]; - struct m68k_op thark; - - for(;;) { - if(!gets(buf)) - break; - bzero(&thark,sizeof(thark)); - if(!m68k_ip_op(buf,&thark)) printf("FAIL:"); - if(thark.error) - printf("op1 error %s in %s\n",thark.error,buf); - printf("mode %d, reg %d, ",thark.mode,thark.reg); - if(thark.b_const) - printf("Constant: '%.*s',",1+thark.e_const-thark.b_const,thark.b_const); - printf("ireg %d, isiz %d, imul %d ",thark.ireg,thark.isiz,thark.imul); - if(thark.b_iadd) - printf("Iadd: '%.*s'",1+thark.e_iadd-thark.b_iadd,thark.b_iadd); - printf("\n"); - } - exit(0); + char buf[128]; + struct m68k_op thark; + + for(;;) { + if(!gets(buf)) + break; + memset(&thark, '\0', sizeof(thark)); + if(!m68k_ip_op(buf,&thark)) printf("FAIL:"); + if(thark.error) + printf("op1 error %s in %s\n",thark.error,buf); + printf("mode %d, reg %d, ",thark.mode,thark.reg); + if(thark.b_const) + printf("Constant: '%.*s',",1+thark.e_const-thark.b_const,thark.b_const); + printf("ireg %d, isiz %d, imul %d ",thark.ireg,thark.isiz,thark.imul); + if(thark.b_iadd) + printf("Iadd: '%.*s'",1+thark.e_iadd-thark.b_iadd,thark.b_iadd); + printf("\n"); + } + exit(0); } #endif @@ -1510,1233 +1510,1233 @@ static struct hash_control* op_hash = NULL; /* handle of the OPCODE hash table /* JF this function no longer returns a useful value. Sorry */ void m68k_ip (instring) - char *instring; +char *instring; { - register char *p; - register struct m68k_op *opP; - register struct m68k_incant *opcode, prev_opcode; - register char *s; - register int tmpreg = 0, - baseo = 0, - outro = 0, - nextword; - int siz1, - siz2; - char c; - int losing; - int opsfound; - char *crack_operand(); - - LITTLENUM_TYPE words[6]; - LITTLENUM_TYPE *wordp; - - if (ISSPACE(*instring)) - instring++; /* skip leading whitespace */ - - /* Scan up to end of operation-code, which MUST end in end-of-string - or exactly 1 space. */ - for (p = instring; *p != '\0'; p++) - if (ISSPACE(*p)) - break; - - - if (p == instring) { - the_ins.error = "No operator"; - the_ins.opcode[0] = NULL; - /* the_ins.numo=1; */ - return; - } - - /* p now points to the end of the opcode name, probably whitespace. - make sure the name is null terminated by clobbering the whitespace, - look it up in the hash table, then fix it back. */ - c = *p; - *p = '\0'; + register char *p; + register struct m68k_op *opP; + register struct m68k_incant *opcode, prev_opcode; + register char *s; + register int tmpreg = 0, + baseo = 0, + outro = 0, + nextword; + int siz1, + siz2; + char c; + int losing; + int opsfound; + char *crack_operand(); + + LITTLENUM_TYPE words[6]; + LITTLENUM_TYPE *wordp; + + if (ISSPACE(*instring)) + instring++; /* skip leading whitespace */ + + /* Scan up to end of operation-code, which MUST end in end-of-string + or exactly 1 space. */ + for (p = instring; *p != '\0'; p++) + if (ISSPACE(*p)) + break; + + + if (p == instring) { + the_ins.error = "No operator"; + the_ins.opcode[0] = NULL; + /* the_ins.numo=1; */ + return; + } + + /* p now points to the end of the opcode name, probably whitespace. + make sure the name is null terminated by clobbering the whitespace, + look it up in the hash table, then fix it back. */ + c = *p; + *p = '\0'; #ifdef MRI - /* Copy from input line to our private buffer, and drop any dots */ -{ - char our_copy[100]; - char *dst = our_copy; - char *src = instring; - while (*src) - { - if (*src != '.') - *dst++ = *src; - src++; - } - *dst = 0; - - - opcode = (struct m68k_incant *)hash_find (op_hash, our_copy); - - /* If no match, try again with a w suffix */ - if (!opcode) - { - *dst++ = 'w'; - *dst = 0; - opcode = (struct m68k_incant *)hash_find (op_hash, our_copy); - } - - - -} - + /* Copy from input line to our private buffer, and drop any dots */ + { + char our_copy[100]; + char *dst = our_copy; + char *src = instring; + while (*src) + { + if (*src != '.') + *dst++ = *src; + src++; + } + *dst = 0; + + + opcode = (struct m68k_incant *)hash_find (op_hash, our_copy); + + /* If no match, try again with a w suffix */ + if (!opcode) + { + *dst++ = 'w'; + *dst = 0; + opcode = (struct m68k_incant *)hash_find (op_hash, our_copy); + } + + + + } + #else -opcode = (struct m68k_incant *)hash_find (op_hash, instring); + opcode = (struct m68k_incant *)hash_find (op_hash, instring); #endif -*p = c; - -if (opcode == NULL) { - the_ins.error = "Unknown opcode"; - the_ins.opcode[0] = NULL; - /* the_ins.numo=1; */ - return; -} - -/* found a legitimate opcode, start matching operands */ -while (ISSPACE(*p)) ++p; - - for(opP = &the_ins.operands[0]; *p; opP++) { + *p = c; + + if (opcode == NULL) { + the_ins.error = "Unknown opcode"; + the_ins.opcode[0] = NULL; + /* the_ins.numo=1; */ + return; + } - p = crack_operand(p, opP); + /* found a legitimate opcode, start matching operands */ + while (ISSPACE(*p)) ++p; - if (opP->error) { - the_ins.error=opP->error; - return; + for(opP = &the_ins.operands[0]; *p; opP++) { + + p = crack_operand(p, opP); + + if (opP->error) { + the_ins.error=opP->error; + return; + } } - } - - opsfound = opP - &the_ins.operands[0]; - - /* This ugly hack is to support the floating pt opcodes in their standard form */ - /* Essentially, we fake a first enty of type COP#1 */ - if (opcode->m_operands[0]=='I') { - int n; - for(n=opsfound;n>0;--n) - the_ins.operands[n]=the_ins.operands[n-1]; - - /* bcopy((char *)(&the_ins.operands[0]),(char *)(&the_ins.operands[1]),opsfound*sizeof(the_ins.operands[0])); */ - bzero((char *)(&the_ins.operands[0]),sizeof(the_ins.operands[0])); - the_ins.operands[0].mode=MSCR; - the_ins.operands[0].reg=COPNUM; /* COP #1 */ - opsfound++; - } - - /* We've got the operands. Find an opcode that'll accept them */ - for (losing = 0; ; ) { - /* if we didn't get the right number of ops, - or we have no common model with this pattern - then reject this pattern. */ - - if (opsfound != opcode->m_opnum - || ((opcode->m_arch & current_architecture) == 0)) { - - ++losing; - - } else { - for (s=opcode->m_operands, opP = &the_ins.operands[0]; *s && !losing; s += 2, opP++) { - /* Warning: this switch is huge! */ - /* I've tried to organize the cases into this order: - non-alpha first, then alpha by letter. lower-case goes directly - before uppercase counterpart. */ - /* Code with multiple case ...: gets sorted by the lowest case ... - it belongs to. I hope this makes sense. */ - switch(*s) { - case '!': - if (opP->mode == MSCR || opP->mode == IMMED - || opP->mode == DREG || opP->mode == AREG - || opP->mode == AINC || opP->mode == ADEC - || opP->mode == REGLST) - losing++; - break; - - case '#': - if(opP->mode!=IMMED) - losing++; - else { - long t; + opsfound = opP - &the_ins.operands[0]; + + /* This ugly hack is to support the floating pt opcodes in their standard form */ + /* Essentially, we fake a first enty of type COP#1 */ + if (opcode->m_operands[0]=='I') { + int n; + + for(n=opsfound;n>0;--n) + the_ins.operands[n]=the_ins.operands[n-1]; + + /* memcpy((char *)(&the_ins.operands[1]), (char *)(&the_ins.operands[0]), opsfound*sizeof(the_ins.operands[0])); */ + memset((char *)(&the_ins.operands[0]), '\0', sizeof(the_ins.operands[0])); + the_ins.operands[0].mode=MSCR; + the_ins.operands[0].reg=COPNUM; /* COP #1 */ + opsfound++; + } + + /* We've got the operands. Find an opcode that'll accept them */ + for (losing = 0; ; ) { + /* if we didn't get the right number of ops, + or we have no common model with this pattern + then reject this pattern. */ + + if (opsfound != opcode->m_opnum + || ((opcode->m_arch & current_architecture) == 0)) { - t=get_num(opP->con1,80); - if(s[1]=='b' && !isbyte(t)) - losing++; - else if(s[1]=='w' && !isword(t)) - losing++; - } - break; - - case '^': - case 'T': - if(opP->mode!=IMMED) - losing++; - break; - - case '$': - if(opP->mode==MSCR || opP->mode==AREG || - opP->mode==IMMED || opP->reg==PC || opP->reg==ZPC || opP->mode==REGLST) - losing++; - break; - + ++losing; + + } else { + for (s=opcode->m_operands, opP = &the_ins.operands[0]; *s && !losing; s += 2, opP++) { + /* Warning: this switch is huge! */ + /* I've tried to organize the cases into this order: + non-alpha first, then alpha by letter. lower-case goes directly + before uppercase counterpart. */ + /* Code with multiple case ...: gets sorted by the lowest case ... + it belongs to. I hope this makes sense. */ + switch(*s) { + case '!': + if (opP->mode == MSCR || opP->mode == IMMED + || opP->mode == DREG || opP->mode == AREG + || opP->mode == AINC || opP->mode == ADEC + || opP->mode == REGLST) + losing++; + break; + + case '#': + if(opP->mode!=IMMED) + losing++; + else { + long t; + + t=get_num(opP->con1,80); + if(s[1]=='b' && !isbyte(t)) + losing++; + else if(s[1]=='w' && !isword(t)) + losing++; + } + break; + + case '^': + case 'T': + if(opP->mode!=IMMED) + losing++; + break; + + case '$': + if(opP->mode==MSCR || opP->mode==AREG || + opP->mode==IMMED || opP->reg==PC || opP->reg==ZPC || opP->mode==REGLST) + losing++; + break; + + case '%': + if(opP->mode==MSCR || opP->reg==PC || + opP->reg==ZPC || opP->mode==REGLST) + losing++; + break; + + + case '&': + if(opP->mode==MSCR || opP->mode==DREG || + opP->mode==AREG || opP->mode==IMMED || opP->reg==PC || opP->reg==ZPC || + opP->mode==AINC || opP->mode==ADEC || opP->mode==REGLST) + losing++; + break; + + case '*': + if(opP->mode==MSCR || opP->mode==REGLST) + losing++; + break; + + case '+': + if(opP->mode!=AINC) + losing++; + break; + + case '-': + if(opP->mode!=ADEC) + losing++; + break; + + case '/': + if(opP->mode==MSCR || opP->mode==AREG || + opP->mode==AINC || opP->mode==ADEC || opP->mode==IMMED || opP->mode==REGLST) + losing++; + break; + + case ';': + if(opP->mode==MSCR || opP->mode==AREG || opP->mode==REGLST) + losing++; + break; + + case '?': + if(opP->mode==MSCR || opP->mode==AREG || + opP->mode==AINC || opP->mode==ADEC || opP->mode==IMMED || opP->reg==PC || + opP->reg==ZPC || opP->mode==REGLST) + losing++; + break; + + case '@': + if(opP->mode==MSCR || opP->mode==AREG || + opP->mode==IMMED || opP->mode==REGLST) + losing++; + break; + + case '~': /* For now! (JF FOO is this right?) */ + if(opP->mode==MSCR || opP->mode==DREG || + opP->mode==AREG || opP->mode==IMMED || opP->reg==PC || opP->reg==ZPC || opP->mode==REGLST) + losing++; + break; + + case 'A': + if(opP->mode!=AREG) + losing++; + break; + case 'a': + if (opP->mode != AINDR) { + ++losing; + } /* if not address register indirect */ + break; + case 'B': /* FOO */ + if(opP->mode!=ABSL || (flagseen['S'] && instring[0] == 'j' + && instring[1] == 'b' + && instring[2] == 's' + && instring[3] == 'r')) + losing++; + break; + + case 'C': + if(opP->mode!=MSCR || opP->reg!=CCR) + losing++; + break; + + case 'd': /* FOO This mode is a KLUDGE!! */ + if(opP->mode!=AOFF && (opP->mode!=ABSL || + opP->con1->e_beg[0]!='(' || opP->con1->e_end[0]!=')')) + losing++; + break; + + case 'D': + if(opP->mode!=DREG) + losing++; + break; + + case 'F': + if(opP->mode!=MSCR || opP->reg<(FPREG+0) || opP->reg>(FPREG+7)) + losing++; + break; + + case 'I': + if(opP->mode!=MSCR || opP->regreg>=COPNUM+7) + losing++; + break; + + case 'J': + if (opP->mode != MSCR + || opP->reg < USP + || opP->reg > URP + || cpu_of_arch(current_architecture) < m68010 /* before 68010 had none */ + || (cpu_of_arch(current_architecture) < m68020 + && opP->reg != SFC + && opP->reg != DFC + && opP->reg != USP + && opP->reg != VBR) /* 68010's had only these */ + || (cpu_of_arch(current_architecture) < m68040 + && opP->reg != SFC + && opP->reg != DFC + && opP->reg != USP + && opP->reg != VBR + && opP->reg != CACR + && opP->reg != CAAR + && opP->reg != MSP + && opP->reg != ISP) /* 680[23]0's have only these */ + || (cpu_of_arch(current_architecture) == m68040 /* 68040 has all but this */ + && opP->reg == CAAR)) { + losing++; + } /* doesn't cut it */ + break; + + case 'k': + if(opP->mode!=IMMED) + losing++; + break; + + case 'l': + case 'L': + if(opP->mode==DREG || opP->mode==AREG || opP->mode==FPREG) { + if(s[1]=='8') + losing++; + else { + opP->mode=REGLST; + opP->reg=1<<(opP->reg-DATA); + } + } else if(opP->mode!=REGLST) { + losing++; + } else if(s[1]=='8' && opP->reg&0x0FFffFF) + losing++; + else if(s[1]=='3' && opP->reg&0x7000000) + losing++; + break; + + case 'M': + if(opP->mode!=IMMED) + losing++; + else { + long t; + + t=get_num(opP->con1,80); + if(!issbyte(t) || isvar(opP->con1)) + losing++; + } + break; + + case 'O': + if(opP->mode!=DREG && opP->mode!=IMMED) + losing++; + break; + + case 'Q': + if(opP->mode!=IMMED) + losing++; + else { + long t; + + t=get_num(opP->con1,80); + if(t<1 || t>8 || isvar(opP->con1)) + losing++; + } + break; + + case 'R': + if(opP->mode!=DREG && opP->mode!=AREG) + losing++; + break; + + case 's': + if(opP->mode!=MSCR || !(opP->reg==FPI || opP->reg==FPS || opP->reg==FPC)) + losing++; + break; + + case 'S': + if(opP->mode!=MSCR || opP->reg!=SR) + losing++; + break; + + case 'U': + if(opP->mode!=MSCR || opP->reg!=USP) + losing++; + break; + + /* JF these are out of order. We could put them + in order if we were willing to put up with + bunches of #ifdef m68851s in the code */ +#ifndef NO_68851 + /* Memory addressing mode used by pflushr */ + case '|': + if(opP->mode==MSCR || opP->mode==DREG || + opP->mode==AREG || opP->mode==REGLST) + losing++; + break; + + case 'f': + if (opP->mode != MSCR || (opP->reg != SFC && opP->reg != DFC)) + losing++; + break; + + case 'P': + if (opP->mode != MSCR || (opP->reg != TC && opP->reg != CAL && + opP->reg != VAL && opP->reg != SCC && opP->reg != AC)) + losing++; + break; + + case 'V': + if (opP->reg != VAL) + losing++; + break; + + case 'W': + if (opP->mode != MSCR || (opP->reg != DRP && opP->reg != SRP && + opP->reg != CRP)) + losing++; + break; + + case 'X': + if (opP->mode != MSCR || + (!(opP->reg >= BAD && opP->reg <= BAD+7) && + !(opP->reg >= BAC && opP->reg <= BAC+7))) + losing++; + break; + + case 'Y': + if (opP->reg != PSR) + losing++; + break; + + case 'Z': + if (opP->reg != PCSR) + losing++; + break; +#endif + case 'c': + if (opP->reg != NC + && opP->reg != IC + && opP->reg != DC + && opP->reg != BC) { + losing++; + } /* not a cache specifier. */ + break; + + case '_': + if (opP->mode != ABSL) { + ++losing; + } /* not absolute */ + break; + + default: + as_fatal("Internal error: Operand mode %c unknown in line %s of file \"%s\"", + *s, __LINE__, __FILE__); + } /* switch on type of operand */ + + if (losing) break; + } /* for each operand */ + } /* if immediately wrong */ + + if (!losing) { + break; + } /* got it. */ + + + if (!opcode->m_next) + { + if ((opcode->m_arch & current_architecture) == 0) + { + the_ins.error = "Opcode not available on architecture specified"; + addword(0); + + } + else + { + the_ins.error = "instruction/operands mismatch"; + } + + return; + } /* Fell off the end */ + opcode = opcode->m_next; + losing = 0; + } + + /* now assemble it */ + + the_ins.args=opcode->m_operands; + the_ins.numargs=opcode->m_opnum; + the_ins.numo=opcode->m_codenum; + the_ins.opcode[0]=getone(opcode); + the_ins.opcode[1]=gettwo(opcode); + + for (s = the_ins.args, opP = &the_ins.operands[0]; *s; s += 2, opP++) { + /* This switch is a doozy. + Watch the first step; its a big one! */ + switch(s[0]) { + + case '*': + case '~': case '%': - if(opP->mode==MSCR || opP->reg==PC || - opP->reg==ZPC || opP->mode==REGLST) - losing++; - break; - - + case ';': + case '@': + case '!': case '&': - if(opP->mode==MSCR || opP->mode==DREG || - opP->mode==AREG || opP->mode==IMMED || opP->reg==PC || opP->reg==ZPC || - opP->mode==AINC || opP->mode==ADEC || opP->mode==REGLST) - losing++; - break; - - case '*': - if(opP->mode==MSCR || opP->mode==REGLST) - losing++; - break; - + case '$': + case '?': + case '/': +#ifndef NO_68851 + case '|': +#endif + switch(opP->mode) { + case IMMED: + tmpreg=0x3c; /* 7.4 */ + if (strchr("bwl",s[1])) nextword=get_num(opP->con1,80); + else nextword=nextword=get_num(opP->con1,0); + if(isvar(opP->con1)) + add_fix(s[1],opP->con1,0); + switch(s[1]) { + case 'b': + if(!isbyte(nextword)) + opP->error="operand out of range"; + addword(nextword); + baseo=0; + break; + case 'w': + if(!isword(nextword)) + opP->error="operand out of range"; + addword(nextword); + baseo=0; + break; + case 'l': + addword(nextword>>16); + addword(nextword); + baseo=0; + break; + + case 'f': + baseo=2; + outro=8; + break; + case 'F': + baseo=4; + outro=11; + break; + case 'x': + baseo=6; + outro=15; + break; + case 'p': + baseo=6; + outro= -1; + break; + default: + as_fatal("Internal error: Can't decode %c%c in line %s of file \"%s\"", + *s, s[1], __LINE__, __FILE__); + } + if(!baseo) + break; + + /* We gotta put out some float */ + if(seg(opP->con1)!=SEG_BIG) { + int_to_gen(nextword); + gen_to_words(words,baseo,(long int)outro); + for(wordp=words;baseo--;wordp++) + addword(*wordp); + break; + } /* Its BIG */ + if(offs(opP->con1)>0) { + as_warn("Bignum assumed to be binary bit-pattern"); + if(offs(opP->con1)>baseo) { + as_warn("Bignum too big for %c format; truncated",s[1]); + offs(opP->con1)=baseo; + } + baseo-=offs(opP->con1); + for(wordp=generic_bignum+offs(opP->con1)-1;offs(opP->con1)--;--wordp) + addword(*wordp); + while(baseo--) + addword(0); + break; + } + gen_to_words(words,baseo,(long)outro); + for (wordp=words;baseo--;wordp++) + addword(*wordp); + break; + case DREG: + tmpreg=opP->reg-DATA; /* 0.dreg */ + break; + case AREG: + tmpreg=0x08+opP->reg-ADDR; /* 1.areg */ + break; + case AINDR: + tmpreg=0x10+opP->reg-ADDR; /* 2.areg */ + break; + case ADEC: + tmpreg=0x20+opP->reg-ADDR; /* 4.areg */ + break; + case AINC: + tmpreg=0x18+opP->reg-ADDR; /* 3.areg */ + break; + case AOFF: + + nextword=get_num(opP->con1,80); + /* Force into index mode. Hope this works */ + + /* We do the first bit for 32-bit displacements, + and the second bit for 16 bit ones. It is + possible that we should make the default be + WORD instead of LONG, but I think that'd + break GCC, so we put up with a little + inefficiency for the sake of working output. + */ + + if( !issword(nextword) + || ( isvar(opP->con1) + && ( ( opP->con1->e_siz==0 + && flagseen['l']==0) + || opP->con1->e_siz==3))) { + + if(opP->reg==PC) + tmpreg=0x3B; /* 7.3 */ + else + tmpreg=0x30+opP->reg-ADDR; /* 6.areg */ + if(isvar(opP->con1)) { + if(opP->reg==PC) { + add_frag(adds(opP->con1), + offs(opP->con1), + TAB(PCLEA,SZ_UNDEF)); + break; + } else { + addword(0x0170); + add_fix('l',opP->con1,1); + } + } else + addword(0x0170); + addword(nextword>>16); + } else { + if(opP->reg==PC) + tmpreg=0x3A; /* 7.2 */ + else + tmpreg=0x28+opP->reg-ADDR; /* 5.areg */ + + if(isvar(opP->con1)) { + if(opP->reg==PC) { + add_fix('w',opP->con1,1); + } else + add_fix('w',opP->con1,0); + } + } + addword(nextword); + break; + + case APODX: + case AMIND: + case APRDX: + know(current_architecture & m68020up); + /* intentional fall-through */ + case AINDX: + nextword=0; + baseo=get_num(opP->con1,80); + outro=get_num(opP->con2,80); + /* Figure out the 'addressing mode' */ + /* Also turn on the BASE_DISABLE bit, if needed */ + if(opP->reg==PC || opP->reg==ZPC) { + tmpreg=0x3b; /* 7.3 */ + if(opP->reg==ZPC) + nextword|=0x80; + } else if(opP->reg==FAIL) { + nextword|=0x80; + tmpreg=0x30; /* 6.garbage */ + } else tmpreg=0x30+opP->reg-ADDR; /* 6.areg */ + + siz1= (opP->con1) ? opP->con1->e_siz : 0; + siz2= (opP->con2) ? opP->con2->e_siz : 0; + + /* Index register stuff */ + if(opP->ireg>=DATA+0 && opP->ireg<=ADDR+7) { + nextword|=(opP->ireg-DATA)<<12; + + if(opP->isiz==0 || opP->isiz==3) + nextword|=0x800; + switch(opP->imul) { + case 1: break; + case 2: nextword|=0x200; break; + case 4: nextword|=0x400; break; + case 8: nextword|=0x600; break; + default: as_fatal("failed sanity check."); + } + /* IF its simple, + GET US OUT OF HERE! */ + + /* Must be INDEX, with an index + register. Address register + cannot be ZERO-PC, and either + :b was forced, or we know + it will fit */ + if( opP->mode==AINDX + && opP->reg!=FAIL + && opP->reg!=ZPC + && ( siz1==1 + || ( issbyte(baseo) + && !isvar(opP->con1)))) { + nextword +=baseo&0xff; + addword(nextword); + if(isvar(opP->con1)) + add_fix('B',opP->con1,0); + break; + } + } else + nextword|=0x40; /* No index reg */ + + /* It aint simple */ + nextword|=0x100; + /* If the guy specified a width, we assume that + it is wide enough. Maybe it isn't. If so, we lose + */ + switch(siz1) { + case 0: + if(isvar(opP->con1) || !issword(baseo)) { + siz1=3; + nextword|=0x30; + } else if(baseo==0) + nextword|=0x10; + else { + nextword|=0x20; + siz1=2; + } + break; + case 1: + as_warn("Byte dispacement won't work. Defaulting to :w"); + case 2: + nextword|=0x20; + break; + case 3: + nextword|=0x30; + break; + } + + /* Figure out innner displacement stuff */ + if(opP->mode!=AINDX) { + switch(siz2) { + case 0: + if(isvar(opP->con2) || !issword(outro)) { + siz2=3; + nextword|=0x3; + } else if(outro==0) + nextword|=0x1; + else { + nextword|=0x2; + siz2=2; + } + break; + case 1: + as_warn("Byte dispacement won't work. Defaulting to :w"); + case 2: + nextword|=0x2; + break; + case 3: + nextword|=0x3; + break; + } + if(opP->mode==APODX) nextword|=0x04; + else if(opP->mode==AMIND) nextword|=0x40; + } + addword(nextword); + + if(isvar(opP->con1)) { + if(opP->reg==PC || opP->reg==ZPC) { + add_fix(siz1==3 ? 'l' : 'w',opP->con1,1); + opP->con1->e_exp.X_add_number+=6; + } else + add_fix(siz1==3 ? 'l' : 'w',opP->con1,0); + } + if(siz1==3) + addword(baseo>>16); + if(siz1) + addword(baseo); + + if(isvar(opP->con2)) { + if(opP->reg==PC || opP->reg==ZPC) { + add_fix(siz2==3 ? 'l' : 'w',opP->con2,1); + opP->con1->e_exp.X_add_number+=6; + } else + add_fix(siz2==3 ? 'l' : 'w',opP->con2,0); + } + if(siz2==3) + addword(outro>>16); + if(siz2) + addword(outro); + + break; + + case ABSL: + nextword=get_num(opP->con1,80); + switch(opP->con1->e_siz) { + default: + as_warn("Unknown size for absolute reference"); + case 0: + if(!isvar(opP->con1) && issword(offs(opP->con1))) { + tmpreg=0x38; /* 7.0 */ + addword(nextword); + break; + } + /* Don't generate pc relative code + on 68010 and 68000 */ + if(isvar(opP->con1) + && !subs(opP->con1) + && seg(opP->con1) == SEG_TEXT + && now_seg == SEG_TEXT + && cpu_of_arch(current_architecture) < m68020 + && !flagseen['S'] + && !strchr("~%&$?", s[0])) { + tmpreg=0x3A; /* 7.2 */ + add_frag(adds(opP->con1), + offs(opP->con1), + TAB(PCREL,SZ_UNDEF)); + break; + } + case 3: /* Fall through into long */ + if(isvar(opP->con1)) + add_fix('l',opP->con1,0); + + tmpreg=0x39; /* 7.1 mode */ + addword(nextword>>16); + addword(nextword); + break; + + case 2: /* Word */ + if(isvar(opP->con1)) + add_fix('w',opP->con1,0); + + tmpreg=0x38; /* 7.0 mode */ + addword(nextword); + break; + } + break; + case MSCR: + default: + as_bad("unknown/incorrect operand"); + /* abort(); */ + } + install_gen_operand(s[1],tmpreg); + break; + + case '#': + case '^': + switch(s[1]) { /* JF: I hate floating point! */ + case 'j': + tmpreg=70; + break; + case '8': + tmpreg=20; + break; + case 'C': + tmpreg=50; + break; + case '3': + default: + tmpreg=80; + break; + } + tmpreg=get_num(opP->con1,tmpreg); + if(isvar(opP->con1)) + add_fix(s[1],opP->con1,0); + switch(s[1]) { + case 'b': /* Danger: These do no check for + certain types of overflow. + user beware! */ + if(!isbyte(tmpreg)) + opP->error="out of range"; + insop(tmpreg); + if(isvar(opP->con1)) + the_ins.reloc[the_ins.nrel-1].n=(opcode->m_codenum)*2; + break; + case 'w': + if(!isword(tmpreg)) + opP->error="out of range"; + insop(tmpreg); + if(isvar(opP->con1)) + the_ins.reloc[the_ins.nrel-1].n=(opcode->m_codenum)*2; + break; + case 'l': + insop(tmpreg); /* Because of the way insop works, we put these two out backwards */ + insop(tmpreg>>16); + if(isvar(opP->con1)) + the_ins.reloc[the_ins.nrel-1].n=(opcode->m_codenum)*2; + break; + case '3': + tmpreg&=0xFF; + case '8': + case 'C': + install_operand(s[1],tmpreg); + break; + default: + as_fatal("Internal error: Unknown mode #%c in line %s of file \"%s\"", s[1], __LINE__, __FILE__); + } + break; + case '+': - if(opP->mode!=AINC) - losing++; - break; - case '-': - if(opP->mode!=ADEC) - losing++; - break; - - case '/': - if(opP->mode==MSCR || opP->mode==AREG || - opP->mode==AINC || opP->mode==ADEC || opP->mode==IMMED || opP->mode==REGLST) - losing++; - break; - - case ';': - if(opP->mode==MSCR || opP->mode==AREG || opP->mode==REGLST) - losing++; - break; - - case '?': - if(opP->mode==MSCR || opP->mode==AREG || - opP->mode==AINC || opP->mode==ADEC || opP->mode==IMMED || opP->reg==PC || - opP->reg==ZPC || opP->mode==REGLST) - losing++; - break; - - case '@': - if(opP->mode==MSCR || opP->mode==AREG || - opP->mode==IMMED || opP->mode==REGLST) - losing++; - break; - - case '~': /* For now! (JF FOO is this right?) */ - if(opP->mode==MSCR || opP->mode==DREG || - opP->mode==AREG || opP->mode==IMMED || opP->reg==PC || opP->reg==ZPC || opP->mode==REGLST) - losing++; - break; - case 'A': - if(opP->mode!=AREG) - losing++; - break; case 'a': - if (opP->mode != AINDR) { - ++losing; - } /* if not address register indirect */ - break; - case 'B': /* FOO */ - if(opP->mode!=ABSL || (flagseen['S'] && instring[0] == 'j' - && instring[1] == 'b' - && instring[2] == 's' - && instring[3] == 'r')) - losing++; - break; - - case 'C': - if(opP->mode!=MSCR || opP->reg!=CCR) - losing++; - break; - - case 'd': /* FOO This mode is a KLUDGE!! */ - if(opP->mode!=AOFF && (opP->mode!=ABSL || - opP->con1->e_beg[0]!='(' || opP->con1->e_end[0]!=')')) - losing++; - break; - - case 'D': - if(opP->mode!=DREG) - losing++; - break; - - case 'F': - if(opP->mode!=MSCR || opP->reg<(FPREG+0) || opP->reg>(FPREG+7)) - losing++; - break; - - case 'I': - if(opP->mode!=MSCR || opP->regreg>=COPNUM+7) - losing++; - break; - - case 'J': - if (opP->mode != MSCR - || opP->reg < USP - || opP->reg > URP - || cpu_of_arch(current_architecture) < m68010 /* before 68010 had none */ - || (cpu_of_arch(current_architecture) < m68020 - && opP->reg != SFC - && opP->reg != DFC - && opP->reg != USP - && opP->reg != VBR) /* 68010's had only these */ - || (cpu_of_arch(current_architecture) < m68040 - && opP->reg != SFC - && opP->reg != DFC - && opP->reg != USP - && opP->reg != VBR - && opP->reg != CACR - && opP->reg != CAAR - && opP->reg != MSP - && opP->reg != ISP) /* 680[23]0's have only these */ - || (cpu_of_arch(current_architecture) == m68040 /* 68040 has all but this */ - && opP->reg == CAAR)) { - losing++; - } /* doesn't cut it */ - break; - + install_operand(s[1],opP->reg-ADDR); + break; + + case 'B': + tmpreg=get_num(opP->con1,80); + switch(s[1]) { + case 'B': + /* Needs no offsetting */ + add_fix('B',opP->con1,1); + break; + case 'W': + /* Offset the displacement to be relative to byte disp location */ + opP->con1->e_exp.X_add_number+=2; + add_fix('w',opP->con1,1); + addword(0); + break; + case 'L': + long_branch: + if (cpu_of_arch(current_architecture) < m68020) /* 68000 or 010 */ + as_warn("Can't use long branches on 68000/68010"); + the_ins.opcode[the_ins.numo-1]|=0xff; + /* Offset the displacement to be relative to byte disp location */ + opP->con1->e_exp.X_add_number+=4; + add_fix('l',opP->con1,1); + addword(0); + addword(0); + break; + case 'g': + if(subs(opP->con1)) /* We can't relax it */ + goto long_branch; + + /* This could either be a symbol, or an + absolute address. No matter, the + frag hacking will finger it out. + Not quite: it can't switch from + BRANCH to BCC68000 for the case + where opnd is absolute (it needs + to use the 68000 hack since no + conditional abs jumps). */ + if (((cpu_of_arch(current_architecture) < m68020) || (0==adds(opP->con1))) + && (the_ins.opcode[0] >= 0x6200) + && (the_ins.opcode[0] <= 0x6f00)) { + add_frag(adds(opP->con1),offs(opP->con1),TAB(BCC68000,SZ_UNDEF)); + } else { + add_frag(adds(opP->con1),offs(opP->con1),TAB(BRANCH,SZ_UNDEF)); + } + break; + case 'w': + if(isvar(opP->con1)) { + /* check for DBcc instruction */ + if ((the_ins.opcode[0] & 0xf0f8) ==0x50c8) { + /* size varies if patch */ + /* needed for long form */ + add_frag(adds(opP->con1),offs(opP->con1),TAB(DBCC,SZ_UNDEF)); + break; + } + + /* Don't ask! */ + opP->con1->e_exp.X_add_number+=2; + add_fix('w',opP->con1,1); + } + addword(0); + break; + case 'C': /* Fixed size LONG coproc branches */ + the_ins.opcode[the_ins.numo-1]|=0x40; + /* Offset the displacement to be relative to byte disp location */ + /* Coproc branches don't have a byte disp option, but they are + compatible with the ordinary branches, which do... */ + opP->con1->e_exp.X_add_number+=4; + add_fix('l',opP->con1,1); + addword(0); + addword(0); + break; + case 'c': /* Var size Coprocesssor branches */ + if(subs(opP->con1)) { + add_fix('l',opP->con1,1); + add_frag((symbolS *)0,(long)0,TAB(FBRANCH,LONG)); + } else if(adds(opP->con1)) { + add_frag(adds(opP->con1),offs(opP->con1),TAB(FBRANCH,SZ_UNDEF)); + } else { + /* add_frag((symbolS *)0,offs(opP->con1),TAB(FBRANCH,SHORT)); */ + the_ins.opcode[the_ins.numo-1]|=0x40; + add_fix('l',opP->con1,1); + addword(0); + addword(4); + } + break; + default: + as_fatal("Internal error: operand type B%c unknown in line %s of file \"%s\"", + s[1], __LINE__, __FILE__); + } + break; + + case 'C': /* Ignore it */ + break; + + case 'd': /* JF this is a kludge */ + if(opP->mode==AOFF) { + install_operand('s',opP->reg-ADDR); + } else { + char *tmpP; + + tmpP=opP->con1->e_end-2; + opP->con1->e_beg++; + opP->con1->e_end-=4; /* point to the , */ + baseo=m68k_reg_parse(&tmpP); + if(baseoADDR+7) { + as_bad("Unknown address reg, using A0"); + baseo=0; + } else baseo-=ADDR; + install_operand('s',baseo); + } + tmpreg=get_num(opP->con1,80); + if(!issword(tmpreg)) { + as_warn("Expression out of range, using 0"); + tmpreg=0; + } + addword(tmpreg); + break; + + case 'D': + install_operand(s[1],opP->reg-DATA); + break; + + case 'F': + install_operand(s[1],opP->reg-FPREG); + break; + + case 'I': + tmpreg=1+opP->reg-COPNUM; + if(tmpreg==8) + tmpreg=0; + install_operand(s[1],tmpreg); + break; + + case 'J': /* JF foo */ + switch(opP->reg) { + case SFC: tmpreg=0x000; break; + case DFC: tmpreg=0x001; break; + case CACR: tmpreg=0x002; break; + case TC: tmpreg=0x003; break; + case ITT0: tmpreg=0x004; break; + case ITT1: tmpreg=0x005; break; + case DTT0: tmpreg=0x006; break; + case DTT1: tmpreg=0x007; break; + + case USP: tmpreg=0x800; break; + case VBR: tmpreg=0x801; break; + case CAAR: tmpreg=0x802; break; + case MSP: tmpreg=0x803; break; + case ISP: tmpreg=0x804; break; + case MMUSR: tmpreg=0x805; break; + case URP: tmpreg=0x806; break; + case SRP: tmpreg=0x807; break; + default: + as_fatal("failed sanity check."); + } + install_operand(s[1],tmpreg); + break; + case 'k': - if(opP->mode!=IMMED) - losing++; - break; - + tmpreg=get_num(opP->con1,55); + install_operand(s[1],tmpreg&0x7f); + break; + case 'l': + tmpreg=opP->reg; + if(s[1]=='w') { + if(tmpreg&0x7FF0000) + as_bad("Floating point register in register list"); + insop(reverse_16_bits(tmpreg)); + } else { + if(tmpreg&0x700FFFF) + as_bad("Wrong register in floating-point reglist"); + install_operand(s[1],reverse_8_bits(tmpreg>>16)); + } + break; + case 'L': - if(opP->mode==DREG || opP->mode==AREG || opP->mode==FPREG) { - if(s[1]=='8') - losing++; - else { - opP->mode=REGLST; - opP->reg=1<<(opP->reg-DATA); + tmpreg=opP->reg; + if(s[1]=='w') { + if(tmpreg&0x7FF0000) + as_bad("Floating point register in register list"); + insop(tmpreg); + } else if(s[1]=='8') { + if(tmpreg&0x0FFFFFF) + as_bad("incorrect register in reglist"); + install_operand(s[1],tmpreg>>24); + } else { + if(tmpreg&0x700FFFF) + as_bad("wrong register in floating-point reglist"); + else + install_operand(s[1],tmpreg>>16); } - } else if(opP->mode!=REGLST) { - losing++; - } else if(s[1]=='8' && opP->reg&0x0FFffFF) - losing++; - else if(s[1]=='3' && opP->reg&0x7000000) - losing++; - break; - + break; + case 'M': - if(opP->mode!=IMMED) - losing++; - else { - long t; + install_operand(s[1],get_num(opP->con1,60)); + break; - t=get_num(opP->con1,80); - if(!issbyte(t) || isvar(opP->con1)) - losing++; - } - break; - case 'O': - if(opP->mode!=DREG && opP->mode!=IMMED) - losing++; - break; - + tmpreg= (opP->mode==DREG) + ? 0x20+opP->reg-DATA + : (get_num(opP->con1,40)&0x1F); + install_operand(s[1],tmpreg); + break; + case 'Q': - if(opP->mode!=IMMED) - losing++; - else { - long t; + tmpreg=get_num(opP->con1,10); + if(tmpreg==8) + tmpreg=0; + install_operand(s[1],tmpreg); + break; - t=get_num(opP->con1,80); - if(t<1 || t>8 || isvar(opP->con1)) - losing++; - } - break; - case 'R': - if(opP->mode!=DREG && opP->mode!=AREG) - losing++; - break; - + /* This depends on the fact that ADDR registers are + eight more than their corresponding DATA regs, so + the result will have the ADDR_REG bit set */ + install_operand(s[1],opP->reg-DATA); + break; + case 's': - if(opP->mode!=MSCR || !(opP->reg==FPI || opP->reg==FPS || opP->reg==FPC)) - losing++; - break; - - case 'S': - if(opP->mode!=MSCR || opP->reg!=SR) - losing++; - break; - - case 'U': - if(opP->mode!=MSCR || opP->reg!=USP) - losing++; - break; - - /* JF these are out of order. We could put them - in order if we were willing to put up with - bunches of #ifdef m68851s in the code */ -#ifndef NO_68851 - /* Memory addressing mode used by pflushr */ - case '|': - if(opP->mode==MSCR || opP->mode==DREG || - opP->mode==AREG || opP->mode==REGLST) - losing++; - break; - - case 'f': - if (opP->mode != MSCR || (opP->reg != SFC && opP->reg != DFC)) - losing++; - break; - - case 'P': - if (opP->mode != MSCR || (opP->reg != TC && opP->reg != CAL && - opP->reg != VAL && opP->reg != SCC && opP->reg != AC)) - losing++; - break; - - case 'V': - if (opP->reg != VAL) - losing++; - break; - - case 'W': - if (opP->mode != MSCR || (opP->reg != DRP && opP->reg != SRP && - opP->reg != CRP)) - losing++; - break; - - case 'X': - if (opP->mode != MSCR || - (!(opP->reg >= BAD && opP->reg <= BAD+7) && - !(opP->reg >= BAC && opP->reg <= BAC+7))) - losing++; - break; - - case 'Y': - if (opP->reg != PSR) - losing++; - break; - - case 'Z': - if (opP->reg != PCSR) - losing++; - break; -#endif + if(opP->reg==FPI) tmpreg=0x1; + else if(opP->reg==FPS) tmpreg=0x2; + else if(opP->reg==FPC) tmpreg=0x4; + else as_fatal("failed sanity check."); + install_operand(s[1],tmpreg); + break; + + case 'S': /* Ignore it */ + break; + + case 'T': + install_operand(s[1],get_num(opP->con1,30)); + break; + + case 'U': /* Ignore it */ + break; + case 'c': - if (opP->reg != NC - && opP->reg != IC - && opP->reg != DC - && opP->reg != BC) { - losing++; - } /* not a cache specifier. */ - break; - - case '_': - if (opP->mode != ABSL) { - ++losing; - } /* not absolute */ - break; - - default: - as_fatal("Internal error: Operand mode %c unknown in line %s of file \"%s\"", - *s, __LINE__, __FILE__); - } /* switch on type of operand */ - - if (losing) break; - } /* for each operand */ - } /* if immediately wrong */ - - if (!losing) { - break; - } /* got it. */ - - - if (!opcode->m_next) - { - if ((opcode->m_arch & current_architecture) == 0) - { - the_ins.error = "Opcode not available on architecture specified"; - addword(0); - - } - else - { - the_ins.error = "instruction/operands mismatch"; - } - - return; - } /* Fell off the end */ - opcode = opcode->m_next; - losing = 0; - } - - /* now assemble it */ - - the_ins.args=opcode->m_operands; - the_ins.numargs=opcode->m_opnum; - the_ins.numo=opcode->m_codenum; - the_ins.opcode[0]=getone(opcode); - the_ins.opcode[1]=gettwo(opcode); - - for (s = the_ins.args, opP = &the_ins.operands[0]; *s; s += 2, opP++) { - /* This switch is a doozy. - Watch the first step; its a big one! */ - switch(s[0]) { - - case '*': - case '~': - case '%': - case ';': - case '@': - case '!': - case '&': - case '$': - case '?': - case '/': + switch (opP->reg) { + case NC: tmpreg = 0; break; + case DC: tmpreg = 1; break; + case IC: tmpreg = 2; break; + case BC: tmpreg = 3; break; + default: + as_fatal("failed sanity check"); + } /* switch on cache token */ + install_operand(s[1], tmpreg); + break; #ifndef NO_68851 - case '|': -#endif - switch(opP->mode) { - case IMMED: - tmpreg=0x3c; /* 7.4 */ - if (strchr("bwl",s[1])) nextword=get_num(opP->con1,80); - else nextword=nextword=get_num(opP->con1,0); - if(isvar(opP->con1)) - add_fix(s[1],opP->con1,0); - switch(s[1]) { - case 'b': - if(!isbyte(nextword)) - opP->error="operand out of range"; - addword(nextword); - baseo=0; - break; - case 'w': - if(!isword(nextword)) - opP->error="operand out of range"; - addword(nextword); - baseo=0; - break; - case 'l': - addword(nextword>>16); - addword(nextword); - baseo=0; - break; - + /* JF: These are out of order, I fear. */ case 'f': - baseo=2; - outro=8; - break; - case 'F': - baseo=4; - outro=11; - break; - case 'x': - baseo=6; - outro=15; - break; - case 'p': - baseo=6; - outro= -1; - break; - default: - as_fatal("Internal error: Can't decode %c%c in line %s of file \"%s\"", - *s, s[1], __LINE__, __FILE__); - } - if(!baseo) - break; - - /* We gotta put out some float */ - if(seg(opP->con1)!=SEG_BIG) { - int_to_gen(nextword); - gen_to_words(words,baseo,(long int)outro); - for(wordp=words;baseo--;wordp++) - addword(*wordp); - break; - } /* Its BIG */ - if(offs(opP->con1)>0) { - as_warn("Bignum assumed to be binary bit-pattern"); - if(offs(opP->con1)>baseo) { - as_warn("Bignum too big for %c format; truncated",s[1]); - offs(opP->con1)=baseo; - } - baseo-=offs(opP->con1); - for(wordp=generic_bignum+offs(opP->con1)-1;offs(opP->con1)--;--wordp) - addword(*wordp); - while(baseo--) - addword(0); - break; - } - gen_to_words(words,baseo,(long)outro); - for (wordp=words;baseo--;wordp++) - addword(*wordp); - break; - case DREG: - tmpreg=opP->reg-DATA; /* 0.dreg */ - break; - case AREG: - tmpreg=0x08+opP->reg-ADDR; /* 1.areg */ - break; - case AINDR: - tmpreg=0x10+opP->reg-ADDR; /* 2.areg */ - break; - case ADEC: - tmpreg=0x20+opP->reg-ADDR; /* 4.areg */ - break; - case AINC: - tmpreg=0x18+opP->reg-ADDR; /* 3.areg */ - break; - case AOFF: - - nextword=get_num(opP->con1,80); - /* Force into index mode. Hope this works */ - - /* We do the first bit for 32-bit displacements, - and the second bit for 16 bit ones. It is - possible that we should make the default be - WORD instead of LONG, but I think that'd - break GCC, so we put up with a little - inefficiency for the sake of working output. - */ - - if( !issword(nextword) - || ( isvar(opP->con1) - && ( ( opP->con1->e_siz==0 - && flagseen['l']==0) - || opP->con1->e_siz==3))) { - - if(opP->reg==PC) - tmpreg=0x3B; /* 7.3 */ - else - tmpreg=0x30+opP->reg-ADDR; /* 6.areg */ - if(isvar(opP->con1)) { - if(opP->reg==PC) { - add_frag(adds(opP->con1), - offs(opP->con1), - TAB(PCLEA,SZ_UNDEF)); - break; - } else { - addword(0x0170); - add_fix('l',opP->con1,1); + switch (opP->reg) { + case SFC: + tmpreg=0; + break; + case DFC: + tmpreg=1; + break; + default: + as_fatal("failed sanity check."); } - } else - addword(0x0170); - addword(nextword>>16); - } else { - if(opP->reg==PC) - tmpreg=0x3A; /* 7.2 */ - else - tmpreg=0x28+opP->reg-ADDR; /* 5.areg */ - - if(isvar(opP->con1)) { - if(opP->reg==PC) { - add_fix('w',opP->con1,1); - } else - add_fix('w',opP->con1,0); - } - } - addword(nextword); - break; - - case APODX: - case AMIND: - case APRDX: - know(current_architecture & m68020up); - /* intentional fall-through */ - case AINDX: - nextword=0; - baseo=get_num(opP->con1,80); - outro=get_num(opP->con2,80); - /* Figure out the 'addressing mode' */ - /* Also turn on the BASE_DISABLE bit, if needed */ - if(opP->reg==PC || opP->reg==ZPC) { - tmpreg=0x3b; /* 7.3 */ - if(opP->reg==ZPC) - nextword|=0x80; - } else if(opP->reg==FAIL) { - nextword|=0x80; - tmpreg=0x30; /* 6.garbage */ - } else tmpreg=0x30+opP->reg-ADDR; /* 6.areg */ - - siz1= (opP->con1) ? opP->con1->e_siz : 0; - siz2= (opP->con2) ? opP->con2->e_siz : 0; - - /* Index register stuff */ - if(opP->ireg>=DATA+0 && opP->ireg<=ADDR+7) { - nextword|=(opP->ireg-DATA)<<12; - - if(opP->isiz==0 || opP->isiz==3) - nextword|=0x800; - switch(opP->imul) { - case 1: break; - case 2: nextword|=0x200; break; - case 4: nextword|=0x400; break; - case 8: nextword|=0x600; break; - default: as_fatal("failed sanity check."); - } - /* IF its simple, - GET US OUT OF HERE! */ - - /* Must be INDEX, with an index - register. Address register - cannot be ZERO-PC, and either - :b was forced, or we know - it will fit */ - if( opP->mode==AINDX - && opP->reg!=FAIL - && opP->reg!=ZPC - && ( siz1==1 - || ( issbyte(baseo) - && !isvar(opP->con1)))) { - nextword +=baseo&0xff; - addword(nextword); - if(isvar(opP->con1)) - add_fix('B',opP->con1,0); + install_operand(s[1],tmpreg); break; - } - } else - nextword|=0x40; /* No index reg */ - - /* It aint simple */ - nextword|=0x100; - /* If the guy specified a width, we assume that - it is wide enough. Maybe it isn't. If so, we lose - */ - switch(siz1) { - case 0: - if(isvar(opP->con1) || !issword(baseo)) { - siz1=3; - nextword|=0x30; - } else if(baseo==0) - nextword|=0x10; - else { - nextword|=0x20; - siz1=2; - } - break; - case 1: - as_warn("Byte dispacement won't work. Defaulting to :w"); - case 2: - nextword|=0x20; - break; - case 3: - nextword|=0x30; - break; - } - - /* Figure out innner displacement stuff */ - if(opP->mode!=AINDX) { - switch(siz2) { - case 0: - if(isvar(opP->con2) || !issword(outro)) { - siz2=3; - nextword|=0x3; - } else if(outro==0) - nextword|=0x1; - else { - nextword|=0x2; - siz2=2; + + case 'P': + switch(opP->reg) { + case TC: + tmpreg=0; + break; + case CAL: + tmpreg=4; + break; + case VAL: + tmpreg=5; + break; + case SCC: + tmpreg=6; + break; + case AC: + tmpreg=7; + break; + default: + as_fatal("failed sanity check."); } + install_operand(s[1],tmpreg); break; - case 1: - as_warn("Byte dispacement won't work. Defaulting to :w"); - case 2: - nextword|=0x2; + + case 'V': + if (opP->reg == VAL) + break; + as_fatal("failed sanity check."); + + case 'W': + switch(opP->reg) { + + case DRP: + tmpreg=1; + break; + case SRP: + tmpreg=2; + break; + case CRP: + tmpreg=3; + break; + default: + as_fatal("failed sanity check."); + } + install_operand(s[1],tmpreg); break; - case 3: - nextword|=0x3; + + case 'X': + switch (opP->reg) { + case BAD: case BAD+1: case BAD+2: case BAD+3: + case BAD+4: case BAD+5: case BAD+6: case BAD+7: + tmpreg = (4 << 10) | ((opP->reg - BAD) << 2); + break; + + case BAC: case BAC+1: case BAC+2: case BAC+3: + case BAC+4: case BAC+5: case BAC+6: case BAC+7: + tmpreg = (5 << 10) | ((opP->reg - BAC) << 2); + break; + + default: + as_fatal("failed sanity check."); + } + install_operand(s[1], tmpreg); break; - } - if(opP->mode==APODX) nextword|=0x04; - else if(opP->mode==AMIND) nextword|=0x40; - } - addword(nextword); - - if(isvar(opP->con1)) { - if(opP->reg==PC || opP->reg==ZPC) { - add_fix(siz1==3 ? 'l' : 'w',opP->con1,1); - opP->con1->e_exp.X_add_number+=6; - } else - add_fix(siz1==3 ? 'l' : 'w',opP->con1,0); - } - if(siz1==3) - addword(baseo>>16); - if(siz1) - addword(baseo); - - if(isvar(opP->con2)) { - if(opP->reg==PC || opP->reg==ZPC) { - add_fix(siz2==3 ? 'l' : 'w',opP->con2,1); - opP->con1->e_exp.X_add_number+=6; - } else - add_fix(siz2==3 ? 'l' : 'w',opP->con2,0); - } - if(siz2==3) - addword(outro>>16); - if(siz2) - addword(outro); - - break; - - case ABSL: - nextword=get_num(opP->con1,80); - switch(opP->con1->e_siz) { - default: - as_warn("Unknown size for absolute reference"); - case 0: - if(!isvar(opP->con1) && issword(offs(opP->con1))) { - tmpreg=0x38; /* 7.0 */ - addword(nextword); + case 'Y': + know(opP->reg == PSR); break; - } - /* Don't generate pc relative code - on 68010 and 68000 */ - if(isvar(opP->con1) - && !subs(opP->con1) - && seg(opP->con1) == SEG_TEXT - && now_seg == SEG_TEXT - && cpu_of_arch(current_architecture) < m68020 - && !flagseen['S'] - && !strchr("~%&$?", s[0])) { - tmpreg=0x3A; /* 7.2 */ - add_frag(adds(opP->con1), - offs(opP->con1), - TAB(PCREL,SZ_UNDEF)); + case 'Z': + know(opP->reg == PCSR); break; - } - case 3: /* Fall through into long */ - if(isvar(opP->con1)) - add_fix('l',opP->con1,0); - - tmpreg=0x39; /* 7.1 mode */ - addword(nextword>>16); - addword(nextword); - break; - - case 2: /* Word */ - if(isvar(opP->con1)) - add_fix('w',opP->con1,0); - - tmpreg=0x38; /* 7.0 mode */ - addword(nextword); - break; - } - break; - case MSCR: - default: - as_bad("unknown/incorrect operand"); - /* abort(); */ - } - install_gen_operand(s[1],tmpreg); - break; - - case '#': - case '^': - switch(s[1]) { /* JF: I hate floating point! */ - case 'j': - tmpreg=70; - break; - case '8': - tmpreg=20; - break; - case 'C': - tmpreg=50; - break; - case '3': - default: - tmpreg=80; - break; - } - tmpreg=get_num(opP->con1,tmpreg); - if(isvar(opP->con1)) - add_fix(s[1],opP->con1,0); - switch(s[1]) { - case 'b': /* Danger: These do no check for - certain types of overflow. - user beware! */ - if(!isbyte(tmpreg)) - opP->error="out of range"; - insop(tmpreg); - if(isvar(opP->con1)) - the_ins.reloc[the_ins.nrel-1].n=(opcode->m_codenum)*2; - break; - case 'w': - if(!isword(tmpreg)) - opP->error="out of range"; - insop(tmpreg); - if(isvar(opP->con1)) - the_ins.reloc[the_ins.nrel-1].n=(opcode->m_codenum)*2; - break; - case 'l': - insop(tmpreg); /* Because of the way insop works, we put these two out backwards */ - insop(tmpreg>>16); - if(isvar(opP->con1)) - the_ins.reloc[the_ins.nrel-1].n=(opcode->m_codenum)*2; - break; - case '3': - tmpreg&=0xFF; - case '8': - case 'C': - install_operand(s[1],tmpreg); - break; - default: - as_fatal("Internal error: Unknown mode #%c in line %s of file \"%s\"", s[1], __LINE__, __FILE__); - } - break; - - case '+': - case '-': - case 'A': - case 'a': - install_operand(s[1],opP->reg-ADDR); - break; - - case 'B': - tmpreg=get_num(opP->con1,80); - switch(s[1]) { - case 'B': - /* Needs no offsetting */ - add_fix('B',opP->con1,1); - break; - case 'W': - /* Offset the displacement to be relative to byte disp location */ - opP->con1->e_exp.X_add_number+=2; - add_fix('w',opP->con1,1); - addword(0); - break; - case 'L': - long_branch: - if (cpu_of_arch(current_architecture) < m68020) /* 68000 or 010 */ - as_warn("Can't use long branches on 68000/68010"); - the_ins.opcode[the_ins.numo-1]|=0xff; - /* Offset the displacement to be relative to byte disp location */ - opP->con1->e_exp.X_add_number+=4; - add_fix('l',opP->con1,1); - addword(0); - addword(0); - break; - case 'g': - if(subs(opP->con1)) /* We can't relax it */ - goto long_branch; - - /* This could either be a symbol, or an - absolute address. No matter, the - frag hacking will finger it out. - Not quite: it can't switch from - BRANCH to BCC68000 for the case - where opnd is absolute (it needs - to use the 68000 hack since no - conditional abs jumps). */ - if (((cpu_of_arch(current_architecture) < m68020) || (0==adds(opP->con1))) - && (the_ins.opcode[0] >= 0x6200) - && (the_ins.opcode[0] <= 0x6f00)) { - add_frag(adds(opP->con1),offs(opP->con1),TAB(BCC68000,SZ_UNDEF)); - } else { - add_frag(adds(opP->con1),offs(opP->con1),TAB(BRANCH,SZ_UNDEF)); - } - break; - case 'w': - if(isvar(opP->con1)) { - /* check for DBcc instruction */ - if ((the_ins.opcode[0] & 0xf0f8) ==0x50c8) { - /* size varies if patch */ - /* needed for long form */ - add_frag(adds(opP->con1),offs(opP->con1),TAB(DBCC,SZ_UNDEF)); +#endif /* m68851 */ + case '_': + tmpreg=get_num(opP->con1,80); + install_operand(s[1], tmpreg); break; - } - - /* Don't ask! */ - opP->con1->e_exp.X_add_number+=2; - add_fix('w',opP->con1,1); - } - addword(0); - break; - case 'C': /* Fixed size LONG coproc branches */ - the_ins.opcode[the_ins.numo-1]|=0x40; - /* Offset the displacement to be relative to byte disp location */ - /* Coproc branches don't have a byte disp option, but they are - compatible with the ordinary branches, which do... */ - opP->con1->e_exp.X_add_number+=4; - add_fix('l',opP->con1,1); - addword(0); - addword(0); - break; - case 'c': /* Var size Coprocesssor branches */ - if(subs(opP->con1)) { - add_fix('l',opP->con1,1); - add_frag((symbolS *)0,(long)0,TAB(FBRANCH,LONG)); - } else if(adds(opP->con1)) { - add_frag(adds(opP->con1),offs(opP->con1),TAB(FBRANCH,SZ_UNDEF)); - } else { - /* add_frag((symbolS *)0,offs(opP->con1),TAB(FBRANCH,SHORT)); */ - the_ins.opcode[the_ins.numo-1]|=0x40; - add_fix('l',opP->con1,1); - addword(0); - addword(4); + default: + as_fatal("Internal error: Operand type %c unknown in line %s of file \"%s\"", s[0], __LINE__, __FILE__); } - break; - default: - as_fatal("Internal error: operand type B%c unknown in line %s of file \"%s\"", - s[1], __LINE__, __FILE__); - } - break; - - case 'C': /* Ignore it */ - break; - - case 'd': /* JF this is a kludge */ - if(opP->mode==AOFF) { - install_operand('s',opP->reg-ADDR); - } else { - char *tmpP; - - tmpP=opP->con1->e_end-2; - opP->con1->e_beg++; - opP->con1->e_end-=4; /* point to the , */ - baseo=m68k_reg_parse(&tmpP); - if(baseoADDR+7) { - as_bad("Unknown address reg, using A0"); - baseo=0; - } else baseo-=ADDR; - install_operand('s',baseo); - } - tmpreg=get_num(opP->con1,80); - if(!issword(tmpreg)) { - as_warn("Expression out of range, using 0"); - tmpreg=0; - } - addword(tmpreg); - break; - - case 'D': - install_operand(s[1],opP->reg-DATA); - break; - - case 'F': - install_operand(s[1],opP->reg-FPREG); - break; - - case 'I': - tmpreg=1+opP->reg-COPNUM; - if(tmpreg==8) - tmpreg=0; - install_operand(s[1],tmpreg); - break; - - case 'J': /* JF foo */ - switch(opP->reg) { - case SFC: tmpreg=0x000; break; - case DFC: tmpreg=0x001; break; - case CACR: tmpreg=0x002; break; - case TC: tmpreg=0x003; break; - case ITT0: tmpreg=0x004; break; - case ITT1: tmpreg=0x005; break; - case DTT0: tmpreg=0x006; break; - case DTT1: tmpreg=0x007; break; - - case USP: tmpreg=0x800; break; - case VBR: tmpreg=0x801; break; - case CAAR: tmpreg=0x802; break; - case MSP: tmpreg=0x803; break; - case ISP: tmpreg=0x804; break; - case MMUSR: tmpreg=0x805; break; - case URP: tmpreg=0x806; break; - case SRP: tmpreg=0x807; break; - default: - as_fatal("failed sanity check."); - } - install_operand(s[1],tmpreg); - break; - - case 'k': - tmpreg=get_num(opP->con1,55); - install_operand(s[1],tmpreg&0x7f); - break; - - case 'l': - tmpreg=opP->reg; - if(s[1]=='w') { - if(tmpreg&0x7FF0000) - as_bad("Floating point register in register list"); - insop(reverse_16_bits(tmpreg)); - } else { - if(tmpreg&0x700FFFF) - as_bad("Wrong register in floating-point reglist"); - install_operand(s[1],reverse_8_bits(tmpreg>>16)); - } - break; - - case 'L': - tmpreg=opP->reg; - if(s[1]=='w') { - if(tmpreg&0x7FF0000) - as_bad("Floating point register in register list"); - insop(tmpreg); - } else if(s[1]=='8') { - if(tmpreg&0x0FFFFFF) - as_bad("incorrect register in reglist"); - install_operand(s[1],tmpreg>>24); - } else { - if(tmpreg&0x700FFFF) - as_bad("wrong register in floating-point reglist"); - else - install_operand(s[1],tmpreg>>16); - } - break; - - case 'M': - install_operand(s[1],get_num(opP->con1,60)); - break; - - case 'O': - tmpreg= (opP->mode==DREG) - ? 0x20+opP->reg-DATA - : (get_num(opP->con1,40)&0x1F); - install_operand(s[1],tmpreg); - break; - - case 'Q': - tmpreg=get_num(opP->con1,10); - if(tmpreg==8) - tmpreg=0; - install_operand(s[1],tmpreg); - break; - - case 'R': - /* This depends on the fact that ADDR registers are - eight more than their corresponding DATA regs, so - the result will have the ADDR_REG bit set */ - install_operand(s[1],opP->reg-DATA); - break; - - case 's': - if(opP->reg==FPI) tmpreg=0x1; - else if(opP->reg==FPS) tmpreg=0x2; - else if(opP->reg==FPC) tmpreg=0x4; - else as_fatal("failed sanity check."); - install_operand(s[1],tmpreg); - break; - - case 'S': /* Ignore it */ - break; - - case 'T': - install_operand(s[1],get_num(opP->con1,30)); - break; - - case 'U': /* Ignore it */ - break; - - case 'c': - switch (opP->reg) { - case NC: tmpreg = 0; break; - case DC: tmpreg = 1; break; - case IC: tmpreg = 2; break; - case BC: tmpreg = 3; break; - default: - as_fatal("failed sanity check"); - } /* switch on cache token */ - install_operand(s[1], tmpreg); - break; -#ifndef NO_68851 - /* JF: These are out of order, I fear. */ - case 'f': - switch (opP->reg) { - case SFC: - tmpreg=0; - break; - case DFC: - tmpreg=1; - break; - default: - as_fatal("failed sanity check."); - } - install_operand(s[1],tmpreg); - break; - - case 'P': - switch(opP->reg) { - case TC: - tmpreg=0; - break; - case CAL: - tmpreg=4; - break; - case VAL: - tmpreg=5; - break; - case SCC: - tmpreg=6; - break; - case AC: - tmpreg=7; - break; - default: - as_fatal("failed sanity check."); - } - install_operand(s[1],tmpreg); - break; - - case 'V': - if (opP->reg == VAL) - break; - as_fatal("failed sanity check."); - - case 'W': - switch(opP->reg) { - - case DRP: - tmpreg=1; - break; - case SRP: - tmpreg=2; - break; - case CRP: - tmpreg=3; - break; - default: - as_fatal("failed sanity check."); - } - install_operand(s[1],tmpreg); - break; - - case 'X': - switch (opP->reg) { - case BAD: case BAD+1: case BAD+2: case BAD+3: - case BAD+4: case BAD+5: case BAD+6: case BAD+7: - tmpreg = (4 << 10) | ((opP->reg - BAD) << 2); - break; - - case BAC: case BAC+1: case BAC+2: case BAC+3: - case BAC+4: case BAC+5: case BAC+6: case BAC+7: - tmpreg = (5 << 10) | ((opP->reg - BAC) << 2); - break; - - default: - as_fatal("failed sanity check."); - } - install_operand(s[1], tmpreg); - break; - case 'Y': - know(opP->reg == PSR); - break; - case 'Z': - know(opP->reg == PCSR); - break; -#endif /* m68851 */ - case '_': - tmpreg=get_num(opP->con1,80); - install_operand(s[1], tmpreg); - break; - default: - as_fatal("Internal error: Operand type %c unknown in line %s of file \"%s\"", s[0], __LINE__, __FILE__); } - } - /* By the time whe get here (FINALLY) the_ins contains the complete - instruction, ready to be emitted. . . */ + /* By the time whe get here (FINALLY) the_ins contains the complete + instruction, ready to be emitted. . . */ } /* m68k_ip() */ /* @@ -2756,201 +2756,201 @@ while (ISSPACE(*p)) ++p; */ static int get_regs(i,str,opP) - int i; - struct m68k_op *opP; - char *str; +int i; +struct m68k_op *opP; +char *str; { - /* 26, 25, 24, 23-16, 15-8, 0-7 */ - /* Low order 24 bits encoded fpc,fps,fpi,fp7-fp0,a7-a0,d7-d0 */ - unsigned long cur_regs = 0; - int reg1, - reg2; - + /* 26, 25, 24, 23-16, 15-8, 0-7 */ + /* Low order 24 bits encoded fpc,fps,fpi,fp7-fp0,a7-a0,d7-d0 */ + unsigned long cur_regs = 0; + int reg1, + reg2; + #define ADD_REG(x) { if(x==FPI) cur_regs|=(1<<24);\ else if(x==FPS) cur_regs|=(1<<25);\ else if(x==FPC) cur_regs|=(1<<26);\ else cur_regs|=(1<<(x-1)); } - - reg1=i; - for(;;) { - if(*str=='/') { - ADD_REG(reg1); - str++; - } else if(*str=='-') { - str++; - reg2=m68k_reg_parse(&str); - if(reg2=FPREG+8 || reg1==FPI || reg1==FPS || reg1==FPC) { - opP->error="unknown register in register list"; - return FAIL; - } - while(reg1<=reg2) { - ADD_REG(reg1); - reg1++; - } - if(*str=='\0') - break; - } else if(*str=='\0') { - ADD_REG(reg1); - break; - } else { - opP->error="unknow character in register list"; - return FAIL; - } - /* DJA -- Bug Fix. Did't handle d1-d2/a1 until the following instruction was added */ - if (*str=='/') - str ++; - reg1=m68k_reg_parse(&str); - if((reg1=FPREG+8) && !(reg1==FPI || reg1==FPS || reg1==FPC)) { - opP->error="unknown register in register list"; - return FAIL; + + reg1=i; + for(;;) { + if(*str=='/') { + ADD_REG(reg1); + str++; + } else if(*str=='-') { + str++; + reg2=m68k_reg_parse(&str); + if(reg2=FPREG+8 || reg1==FPI || reg1==FPS || reg1==FPC) { + opP->error="unknown register in register list"; + return FAIL; + } + while(reg1<=reg2) { + ADD_REG(reg1); + reg1++; + } + if(*str=='\0') + break; + } else if(*str=='\0') { + ADD_REG(reg1); + break; + } else { + opP->error="unknow character in register list"; + return FAIL; + } + /* DJA -- Bug Fix. Did't handle d1-d2/a1 until the following instruction was added */ + if (*str=='/') + str ++; + reg1=m68k_reg_parse(&str); + if((reg1=FPREG+8) && !(reg1==FPI || reg1==FPS || reg1==FPC)) { + opP->error="unknown register in register list"; + return FAIL; + } } - } - opP->reg=cur_regs; - return OK; + opP->reg=cur_regs; + return OK; } /* get_regs() */ static int reverse_16_bits(in) - int in; +int in; { - int out=0; - int n; - - static int mask[16] = { - 0x0001,0x0002,0x0004,0x0008,0x0010,0x0020,0x0040,0x0080, - 0x0100,0x0200,0x0400,0x0800,0x1000,0x2000,0x4000,0x8000 - }; - for(n=0;n<16;n++) { - if(in&mask[n]) - out|=mask[15-n]; - } - return out; + int out=0; + int n; + + static int mask[16] = { + 0x0001,0x0002,0x0004,0x0008,0x0010,0x0020,0x0040,0x0080, + 0x0100,0x0200,0x0400,0x0800,0x1000,0x2000,0x4000,0x8000 + }; + for(n=0;n<16;n++) { + if(in&mask[n]) + out|=mask[15-n]; + } + return out; } /* reverse_16_bits() */ static int reverse_8_bits(in) - int in; +int in; { - int out=0; - int n; - - static int mask[8] = { - 0x0001,0x0002,0x0004,0x0008,0x0010,0x0020,0x0040,0x0080, - }; - - for(n=0;n<8;n++) { - if(in&mask[n]) - out|=mask[7-n]; - } - return out; + int out=0; + int n; + + static int mask[8] = { + 0x0001,0x0002,0x0004,0x0008,0x0010,0x0020,0x0040,0x0080, + }; + + for(n=0;n<8;n++) { + if(in&mask[n]) + out|=mask[7-n]; + } + return out; } /* reverse_8_bits() */ static void install_operand(mode,val) - int mode; - int val; +int mode; +int val; { - switch(mode) { - case 's': - the_ins.opcode[0]|=val & 0xFF; /* JF FF is for M kludge */ - break; - case 'd': - the_ins.opcode[0]|=val<<9; - break; - case '1': - the_ins.opcode[1]|=val<<12; - break; - case '2': - the_ins.opcode[1]|=val<<6; - break; - case '3': - the_ins.opcode[1]|=val; - break; - case '4': - the_ins.opcode[2]|=val<<12; - break; - case '5': - the_ins.opcode[2]|=val<<6; - break; - case '6': - /* DANGER! This is a hack to force cas2l and cas2w cmds - to be three words long! */ - the_ins.numo++; - the_ins.opcode[2]|=val; - break; - case '7': - the_ins.opcode[1]|=val<<7; - break; - case '8': - the_ins.opcode[1]|=val<<10; - break; + switch(mode) { + case 's': + the_ins.opcode[0]|=val & 0xFF; /* JF FF is for M kludge */ + break; + case 'd': + the_ins.opcode[0]|=val<<9; + break; + case '1': + the_ins.opcode[1]|=val<<12; + break; + case '2': + the_ins.opcode[1]|=val<<6; + break; + case '3': + the_ins.opcode[1]|=val; + break; + case '4': + the_ins.opcode[2]|=val<<12; + break; + case '5': + the_ins.opcode[2]|=val<<6; + break; + case '6': + /* DANGER! This is a hack to force cas2l and cas2w cmds + to be three words long! */ + the_ins.numo++; + the_ins.opcode[2]|=val; + break; + case '7': + the_ins.opcode[1]|=val<<7; + break; + case '8': + the_ins.opcode[1]|=val<<10; + break; #ifndef NO_68851 - case '9': - the_ins.opcode[1]|=val<<5; - break; + case '9': + the_ins.opcode[1]|=val<<5; + break; #endif - - case 't': - the_ins.opcode[1]|=(val<<10)|(val<<7); - break; - case 'D': - the_ins.opcode[1]|=(val<<12)|val; - break; - case 'g': - the_ins.opcode[0]|=val=0xff; - break; - case 'i': - the_ins.opcode[0]|=val<<9; - break; - case 'C': - the_ins.opcode[1]|=val; - break; - case 'j': - the_ins.opcode[1]|=val; - the_ins.numo++; /* What a hack */ - break; - case 'k': - the_ins.opcode[1]|=val<<4; - break; - case 'b': - case 'w': - case 'l': - break; - case 'e': - the_ins.opcode[0] |= (val << 6); - break; - case 'L': - the_ins.opcode[1] = (val >> 16); - the_ins.opcode[2] = val & 0xffff; - break; - case 'c': - default: - as_fatal("failed sanity check."); - } + + case 't': + the_ins.opcode[1]|=(val<<10)|(val<<7); + break; + case 'D': + the_ins.opcode[1]|=(val<<12)|val; + break; + case 'g': + the_ins.opcode[0]|=val=0xff; + break; + case 'i': + the_ins.opcode[0]|=val<<9; + break; + case 'C': + the_ins.opcode[1]|=val; + break; + case 'j': + the_ins.opcode[1]|=val; + the_ins.numo++; /* What a hack */ + break; + case 'k': + the_ins.opcode[1]|=val<<4; + break; + case 'b': + case 'w': + case 'l': + break; + case 'e': + the_ins.opcode[0] |= (val << 6); + break; + case 'L': + the_ins.opcode[1] = (val >> 16); + the_ins.opcode[2] = val & 0xffff; + break; + case 'c': + default: + as_fatal("failed sanity check."); + } } /* install_operand() */ static void install_gen_operand(mode,val) - int mode; - int val; +int mode; +int val; { - switch(mode) { - case 's': - the_ins.opcode[0]|=val; - break; - case 'd': - /* This is a kludge!!! */ - the_ins.opcode[0]|=(val&0x07)<<9|(val&0x38)<<3; - break; - case 'b': - case 'w': - case 'l': - case 'f': - case 'F': - case 'x': - case 'p': - the_ins.opcode[0]|=val; - break; - /* more stuff goes here */ - default: - as_fatal("failed sanity check."); - } + switch(mode) { + case 's': + the_ins.opcode[0]|=val; + break; + case 'd': + /* This is a kludge!!! */ + the_ins.opcode[0]|=(val&0x07)<<9|(val&0x38)<<3; + break; + case 'b': + case 'w': + case 'l': + case 'f': + case 'F': + case 'x': + case 'p': + the_ins.opcode[0]|=val; + break; + /* more stuff goes here */ + default: + as_fatal("failed sanity check."); + } } /* install_gen_operand() */ /* @@ -2959,109 +2959,109 @@ static void install_gen_operand(mode,val) */ static char *crack_operand(str,opP) - register char *str; - register struct m68k_op *opP; +register char *str; +register struct m68k_op *opP; { - register int parens; - register int c; - register char *beg_str; - - if(!str) { - return str; - } - beg_str=str; - for(parens=0;*str && (parens>0 || notend(str));str++) { - if(*str=='(') parens++; - else if(*str==')') { - if(!parens) { /* ERROR */ - opP->error="Extra )"; + register int parens; + register int c; + register char *beg_str; + + if(!str) { + return str; + } + beg_str=str; + for(parens=0;*str && (parens>0 || notend(str));str++) { + if(*str=='(') parens++; + else if(*str==')') { + if(!parens) { /* ERROR */ + opP->error="Extra )"; + return str; + } + --parens; + } + } + if(!*str && parens) { /* ERROR */ + opP->error="Missing )"; + return str; + } + c= *str; + *str='\0'; + if(m68k_ip_op(beg_str,opP)==FAIL) { + *str=c; return str; - } - --parens; } - } - if(!*str && parens) { /* ERROR */ - opP->error="Missing )"; - return str; - } - c= *str; - *str='\0'; - if(m68k_ip_op(beg_str,opP)==FAIL) { *str=c; + + if(c=='}') + c= *++str; /* JF bitfield hack */ + + if(c) { + c= *++str; + if(!c) + as_bad("Missing operand"); + } return str; - } - *str=c; - - if(c=='}') - c= *++str; /* JF bitfield hack */ - - if(c) { - c= *++str; - if(!c) - as_bad("Missing operand"); - } - return str; } /* See the comment up above where the #define notend(... is */ #if 0 notend(s) - char *s; +char *s; { - if(*s==',') return 0; - if(*s=='{' || *s=='}') - return 0; - if(*s!=':') return 1; - /* This kludge here is for the division cmd, which is a kludge */ - if(index("aAdD#",s[1])) return 0; - return 1; + if(*s==',') return 0; + if(*s=='{' || *s=='}') + return 0; + if(*s!=':') return 1; + /* This kludge here is for the division cmd, which is a kludge */ + if(index("aAdD#",s[1])) return 0; + return 1; } #endif int done_pseudo(str) - char *str; +char *str; { - extern struct hash_control * po_hash; - char *ptr = str; - char *null_ptr; - pseudo_typeS * pop; - - char c; - - is_end_of_line[0] = 1; - /* Skip over name of pseudo, change to lower case */ - while (isalpha(*ptr) || *ptr == '.') - { - if (isupper(*ptr)) { - *ptr = tolower(*ptr); - } - ptr++; - } - null_ptr = ptr; - c = *null_ptr; - *null_ptr = 0; - - - pop = (pseudo_typeS *)hash_find(po_hash, str); - - *null_ptr = c; - if (pop != (pseudo_typeS *)NULL) - { - input_line_pointer = null_ptr+1; - SKIP_WHITESPACE(); - /* Now we point to first non-blank char after pseudo op */ - (*pop->poc_handler)(pop->poc_val); - input_line_pointer--; + extern struct hash_control * po_hash; + char *ptr = str; + char *null_ptr; + pseudo_typeS * pop; - return 1; + char c; + + is_end_of_line[0] = 1; + /* Skip over name of pseudo, change to lower case */ + while (isalpha(*ptr) || *ptr == '.') + { + if (isupper(*ptr)) { + *ptr = tolower(*ptr); + } + ptr++; + } + null_ptr = ptr; + c = *null_ptr; + *null_ptr = 0; + + + pop = (pseudo_typeS *)hash_find(po_hash, str); + + *null_ptr = c; + if (pop != (pseudo_typeS *)NULL) + { + input_line_pointer = null_ptr+1; + SKIP_WHITESPACE(); + /* Now we point to first non-blank char after pseudo op */ + (*pop->poc_handler)(pop->poc_val); + input_line_pointer--; + + return 1; + + } + /* Just put back the char where the null was put and return as if nothing had happened */ + + *null_ptr = c; + return 0; - } - /* Just put back the char where the null was put and return as if nothing had happened */ - - *null_ptr = c; - return 0; - } @@ -3073,154 +3073,154 @@ void md_assemble(str) char *str; { - char *er; - short *fromP; - char *toP = NULL; - int m,n = 0; - char *to_beg_P; - int shorts_this_frag; - - /* if (done_pseudo(str)) return ;*/ - - - - if (current_architecture == 0) { - current_architecture = (m68020 + char *er; + short *fromP; + char *toP = NULL; + int m,n = 0; + char *to_beg_P; + int shorts_this_frag; + + /* if (done_pseudo(str)) return ;*/ + + + + if (current_architecture == 0) { + current_architecture = (m68020 #ifndef NO_68881 - | m68881 + | m68881 #endif #ifndef NO_68851 - | m68851 + | m68851 #endif - ); - } /* default current_architecture */ - - bzero((char *)(&the_ins),sizeof(the_ins)); /* JF for paranoia sake */ - - m68k_ip(str); - er=the_ins.error; - if(!er) { - for(n=the_ins.numargs;n;--n) - if(the_ins.operands[n].error) { - er=the_ins.operands[n].error; - break; - } - } - if(er) { - as_bad("\"%s\" -- Statement '%s' ignored",er,str); - return; - } - - if(the_ins.nfrag==0) { /* No frag hacking involved; just put it out */ - toP=frag_more(2*the_ins.numo); - fromP= &the_ins.opcode[0]; - for(m=the_ins.numo;m;--m) { - md_number_to_chars(toP,(long)(*fromP),2); - toP+=2; - fromP++; + ); + } /* default current_architecture */ + + memset((char *)(&the_ins), '\0', sizeof(the_ins)); /* JF for paranoia sake */ + + m68k_ip(str); + er=the_ins.error; + if(!er) { + for(n=the_ins.numargs;n;--n) + if(the_ins.operands[n].error) { + er=the_ins.operands[n].error; + break; + } } - /* put out symbol-dependent info */ - for(m=0;mfr_literal)-the_ins.numo*2+the_ins.reloc[m].n, - n, - the_ins.reloc[m].add, - the_ins.reloc[m].sub, - the_ins.reloc[m].off, - the_ins.reloc[m].pcrel, - NO_RELOC); + if(er) { + as_bad("\"%s\" -- Statement '%s' ignored",er,str); + return; } - return; - } - - /* There's some frag hacking */ - for(n=0,fromP= &the_ins.opcode[0];nfr_literal)-the_ins.numo*2+the_ins.reloc[m].n, + n, + the_ins.reloc[m].add, + the_ins.reloc[m].sub, + the_ins.reloc[m].off, + the_ins.reloc[m].pcrel, + NO_RELOC); + } + return; + } + + /* There's some frag hacking */ + for(n=0,fromP= &the_ins.opcode[0];n= 2*shorts_this_frag /* 2*the_ins.fragb[n].fragoff */) { + the_ins.reloc[m].n-= 2*shorts_this_frag /* 2*the_ins.fragb[n].fragoff */; + break; + } + wid=the_ins.reloc[m].wid; + if(wid==0) + continue; + the_ins.reloc[m].wid=0; + wid = (wid=='b') ? 1 : (wid=='w') ? 2 : (wid=='l') ? 4 : 4000; + + fix_new(frag_now, + (toP-frag_now->fr_literal)-the_ins.numo*2+the_ins.reloc[m].n, + wid, + the_ins.reloc[m].add, + the_ins.reloc[m].sub, + the_ins.reloc[m].off, + the_ins.reloc[m].pcrel, + NO_RELOC); + } + /* know(the_ins.fragb[n].fadd); */ + (void)frag_var(rs_machine_dependent,10,0,(relax_substateT)(the_ins.fragb[n].fragty), + the_ins.fragb[n].fadd,the_ins.fragb[n].foff,to_beg_P); + } + n=(the_ins.numo-the_ins.fragb[n-1].fragoff); shorts_this_frag=0; - for(m=wid/2;m;--m) { - md_number_to_chars(toP,(long)(*fromP),2); - toP+=2; - fromP++; - shorts_this_frag++; + if(n) { + toP=frag_more(n*sizeof(short)); + while(n--) { + md_number_to_chars(toP,(long)(*fromP),2); + toP+=2; + fromP++; + shorts_this_frag++; + } } for(m=0;m= 2*shorts_this_frag /* 2*the_ins.fragb[n].fragoff */) { - the_ins.reloc[m].n-= 2*shorts_this_frag /* 2*the_ins.fragb[n].fragoff */; - break; - } - wid=the_ins.reloc[m].wid; - if(wid==0) - continue; - the_ins.reloc[m].wid=0; - wid = (wid=='b') ? 1 : (wid=='w') ? 2 : (wid=='l') ? 4 : 4000; - - fix_new(frag_now, - (toP-frag_now->fr_literal)-the_ins.numo*2+the_ins.reloc[m].n, - wid, - the_ins.reloc[m].add, - the_ins.reloc[m].sub, - the_ins.reloc[m].off, - the_ins.reloc[m].pcrel, - NO_RELOC); - } - /* know(the_ins.fragb[n].fadd); */ - (void)frag_var(rs_machine_dependent,10,0,(relax_substateT)(the_ins.fragb[n].fragty), - the_ins.fragb[n].fadd,the_ins.fragb[n].foff,to_beg_P); - } - n=(the_ins.numo-the_ins.fragb[n-1].fragoff); - shorts_this_frag=0; - if(n) { - toP=frag_more(n*sizeof(short)); - while(n--) { - md_number_to_chars(toP,(long)(*fromP),2); - toP+=2; - fromP++; - shorts_this_frag++; + int wid; + + wid=the_ins.reloc[m].wid; + if(wid==0) + continue; + the_ins.reloc[m].wid=0; + wid = (wid=='b') ? 1 : (wid=='w') ? 2 : (wid=='l') ? 4 : 4000; + + fix_new(frag_now, + (the_ins.reloc[m].n + toP-frag_now->fr_literal)- /* the_ins.numo */ shorts_this_frag*2, + wid, + the_ins.reloc[m].add, + the_ins.reloc[m].sub, + the_ins.reloc[m].off, + the_ins.reloc[m].pcrel, + NO_RELOC); } - } - for(m=0;mfr_literal)- /* the_ins.numo */ shorts_this_frag*2, - wid, - the_ins.reloc[m].add, - the_ins.reloc[m].sub, - the_ins.reloc[m].off, - the_ins.reloc[m].pcrel, - NO_RELOC); - } } /* This function is called once, at assembler startup time. This should @@ -3229,77 +3229,77 @@ char *str; void md_begin() { - /* - * md_begin -- set up hash tables with 68000 instructions. - * similar to what the vax assembler does. ---phr - */ - /* RMS claims the thing to do is take the m68k-opcode.h table, and make - a copy of it at runtime, adding in the information we want but isn't - there. I think it'd be better to have an awk script hack the table - at compile time. Or even just xstr the table and use it as-is. But - my lord ghod hath spoken, so we do it this way. Excuse the ugly var - names. */ - - register const struct m68k_opcode *ins; - register struct m68k_incant *hack, - *slak; - register char *retval = 0; /* empty string, or error msg text */ - register unsigned int i; - register char c; - - if ((op_hash = hash_new()) == NULL) - as_fatal("Virtual memory exhausted"); - - obstack_begin(&robyn,4000); - for (ins = m68k_opcodes; ins < endop; ins++) { - hack=slak=(struct m68k_incant *)obstack_alloc(&robyn,sizeof(struct m68k_incant)); - do { - /* we *could* ignore insns that don't match our - arch here but just leaving them out of the - hash. */ - slak->m_operands=ins->args; - slak->m_opnum=strlen(slak->m_operands)/2; - slak->m_arch = ins->arch; - slak->m_opcode=ins->opcode; - /* This is kludgey */ - slak->m_codenum=((ins->match)&0xffffL) ? 2 : 1; - if((ins+1)!=endop && !strcmp(ins->name,(ins+1)->name)) { - slak->m_next=(struct m68k_incant *) obstack_alloc(&robyn,sizeof(struct m68k_incant)); - ins++; - } else - slak->m_next=0; - slak=slak->m_next; - } while(slak); - - retval = hash_insert (op_hash, ins->name,(char *)hack); - /* Didn't his mommy tell him about null pointers? */ - if(retval && *retval) - as_fatal("Internal Error: Can't hash %s: %s",ins->name,retval); - } - - for (i = 0; i < sizeof(mklower_table) ; i++) - mklower_table[i] = (isupper(c = (char) i)) ? tolower(c) : c; - - for (i = 0 ; i < sizeof(notend_table) ; i++) { - notend_table[i] = 0; - alt_notend_table[i] = 0; - } - notend_table[','] = 1; - notend_table['{'] = 1; - notend_table['}'] = 1; - alt_notend_table['a'] = 1; - alt_notend_table['A'] = 1; - alt_notend_table['d'] = 1; - alt_notend_table['D'] = 1; - alt_notend_table['#'] = 1; - alt_notend_table['f'] = 1; - alt_notend_table['F'] = 1; - + /* + * md_begin -- set up hash tables with 68000 instructions. + * similar to what the vax assembler does. ---phr + */ + /* RMS claims the thing to do is take the m68k-opcode.h table, and make + a copy of it at runtime, adding in the information we want but isn't + there. I think it'd be better to have an awk script hack the table + at compile time. Or even just xstr the table and use it as-is. But + my lord ghod hath spoken, so we do it this way. Excuse the ugly var + names. */ + + register const struct m68k_opcode *ins; + register struct m68k_incant *hack, + *slak; + register char *retval = 0; /* empty string, or error msg text */ + register unsigned int i; + register char c; + + if ((op_hash = hash_new()) == NULL) + as_fatal("Virtual memory exhausted"); + + obstack_begin(&robyn,4000); + for (ins = m68k_opcodes; ins < endop; ins++) { + hack=slak=(struct m68k_incant *)obstack_alloc(&robyn,sizeof(struct m68k_incant)); + do { + /* we *could* ignore insns that don't match our + arch here but just leaving them out of the + hash. */ + slak->m_operands=ins->args; + slak->m_opnum=strlen(slak->m_operands)/2; + slak->m_arch = ins->arch; + slak->m_opcode=ins->opcode; + /* This is kludgey */ + slak->m_codenum=((ins->match)&0xffffL) ? 2 : 1; + if((ins+1)!=endop && !strcmp(ins->name,(ins+1)->name)) { + slak->m_next=(struct m68k_incant *) obstack_alloc(&robyn,sizeof(struct m68k_incant)); + ins++; + } else + slak->m_next=0; + slak=slak->m_next; + } while(slak); + + retval = hash_insert (op_hash, ins->name,(char *)hack); + /* Didn't his mommy tell him about null pointers? */ + if(retval && *retval) + as_fatal("Internal Error: Can't hash %s: %s",ins->name,retval); + } + + for (i = 0; i < sizeof(mklower_table) ; i++) + mklower_table[i] = (isupper(c = (char) i)) ? tolower(c) : c; + + for (i = 0 ; i < sizeof(notend_table) ; i++) { + notend_table[i] = 0; + alt_notend_table[i] = 0; + } + notend_table[','] = 1; + notend_table['{'] = 1; + notend_table['}'] = 1; + alt_notend_table['a'] = 1; + alt_notend_table['A'] = 1; + alt_notend_table['d'] = 1; + alt_notend_table['D'] = 1; + alt_notend_table['#'] = 1; + alt_notend_table['f'] = 1; + alt_notend_table['F'] = 1; + #ifdef REGISTER_PREFIX - alt_notend_table[REGISTER_PREFIX] = 1; + alt_notend_table[REGISTER_PREFIX] = 1; #endif - - + + } #if 0 @@ -3329,51 +3329,51 @@ char type; char *litP; int *sizeP; { - int prec; - LITTLENUM_TYPE words[MAX_LITTLENUMS]; - LITTLENUM_TYPE *wordP; - char *t; - char *atof_ieee(); - - switch(type) { - case 'f': - case 'F': - case 's': - case 'S': - prec = 2; - break; - - case 'd': - case 'D': - case 'r': - case 'R': - prec = 4; - break; - - case 'x': - case 'X': - prec = 6; - break; + int prec; + LITTLENUM_TYPE words[MAX_LITTLENUMS]; + LITTLENUM_TYPE *wordP; + char *t; + char *atof_ieee(); - case 'p': - case 'P': - prec = 6; - break; + switch(type) { + case 'f': + case 'F': + case 's': + case 'S': + prec = 2; + break; + + case 'd': + case 'D': + case 'r': + case 'R': + prec = 4; + break; + + case 'x': + case 'X': + prec = 6; + break; + + case 'p': + case 'P': + prec = 6; + break; + + default: + *sizeP=0; + return "Bad call to MD_ATOF()"; + } + t=atof_ieee(input_line_pointer,type,words); + if(t) + input_line_pointer=t; - default: - *sizeP=0; - return "Bad call to MD_ATOF()"; - } - t=atof_ieee(input_line_pointer,type,words); - if(t) - input_line_pointer=t; - - *sizeP=prec * sizeof(LITTLENUM_TYPE); - for(wordP=words;prec--;) { - md_number_to_chars(litP,(long)(*wordP++),sizeof(LITTLENUM_TYPE)); - litP+=sizeof(LITTLENUM_TYPE); - } - return ""; /* Someone should teach Dean about null pointers */ + *sizeP=prec * sizeof(LITTLENUM_TYPE); + for(wordP=words;prec--;) { + md_number_to_chars(litP,(long)(*wordP++),sizeof(LITTLENUM_TYPE)); + litP+=sizeof(LITTLENUM_TYPE); + } + return ""; /* Someone should teach Dean about null pointers */ } /* Turn an integer of n bytes (in val) into a stream of bytes appropriate @@ -3389,23 +3389,23 @@ char *buf; long val; int n; { - switch(n) { - case 1: - *buf++=val; - break; - case 2: - *buf++=(val>>8); - *buf++=val; - break; - case 4: - *buf++=(val>>24); - *buf++=(val>>16); - *buf++=(val>>8); - *buf++=val; - break; - default: - as_fatal("failed sanity check."); - } + switch(n) { + case 1: + *buf++=val; + break; + case 2: + *buf++=(val>>8); + *buf++=val; + break; + case 4: + *buf++=(val>>24); + *buf++=(val>>16); + *buf++=(val>>8); + *buf++=val; + break; + default: + as_fatal("failed sanity check."); + } } void @@ -3413,25 +3413,25 @@ void fixS *fixP; long val; { - char *buf = fixP->fx_where + fixP->fx_frag->fr_literal; - - switch(fixP->fx_size) { - case 1: - *buf++=val; - break; - case 2: - *buf++=(val>>8); - *buf++=val; - break; - case 4: - *buf++=(val>>24); - *buf++=(val>>16); - *buf++=(val>>8); - *buf++=val; - break; - default: - BAD_CASE (fixP->fx_size); - } + char *buf = fixP->fx_where + fixP->fx_frag->fr_literal; + + switch(fixP->fx_size) { + case 1: + *buf++=val; + break; + case 2: + *buf++=(val>>8); + *buf++=val; + break; + case 4: + *buf++=(val>>24); + *buf++=(val>>16); + *buf++=(val>>8); + *buf++=val; + break; + default: + BAD_CASE (fixP->fx_size); + } } @@ -3444,30 +3444,30 @@ void object_headers *headers; register fragS *fragP; { - long disp; - long ext = 0; - - /* Address in object code of the displacement. */ - register int object_address = fragP -> fr_fix + fragP -> fr_address; - + long disp; + long ext = 0; + + /* Address in object code of the displacement. */ + register int object_address = fragP -> fr_fix + fragP -> fr_address; + #ifdef IBM_COMPILER_SUX - /* This is wrong but it convinces the native rs6000 compiler to - generate the code we want. */ - register char *buffer_address = fragP -> fr_literal; - buffer_address += fragP -> fr_fix; + /* This is wrong but it convinces the native rs6000 compiler to + generate the code we want. */ + register char *buffer_address = fragP -> fr_literal; + buffer_address += fragP -> fr_fix; #else /* IBM_COMPILER_SUX */ - /* Address in gas core of the place to store the displacement. */ - register char *buffer_address = fragP->fr_fix + fragP->fr_literal; + /* Address in gas core of the place to store the displacement. */ + register char *buffer_address = fragP->fr_fix + fragP->fr_literal; #endif /* IBM_COMPILER_SUX */ - - /* No longer true: know(fragP->fr_symbol); */ - - /* The displacement of the address, from current location. */ - disp = fragP->fr_symbol ? S_GET_VALUE(fragP->fr_symbol) : 0; - disp = (disp + fragP->fr_offset) - object_address; - - switch(fragP->fr_subtype) { - case TAB(BCC68000,BYTE): + + /* No longer true: know(fragP->fr_symbol); */ + + /* The displacement of the address, from current location. */ + disp = fragP->fr_symbol ? S_GET_VALUE(fragP->fr_symbol) : 0; + disp = (disp + fragP->fr_offset) - object_address; + + switch(fragP->fr_subtype) { + case TAB(BCC68000,BYTE): case TAB(BRANCH,BYTE): know(issbyte(disp)); if(disp==0) @@ -3475,54 +3475,54 @@ register fragS *fragP; fragP->fr_opcode[1]=disp; ext=0; break; - case TAB(DBCC,SHORT): - know(issword(disp)); + case TAB(DBCC,SHORT): + know(issword(disp)); ext=2; break; - case TAB(BCC68000,SHORT): - case TAB(BRANCH,SHORT): - know(issword(disp)); + case TAB(BCC68000,SHORT): + case TAB(BRANCH,SHORT): + know(issword(disp)); fragP->fr_opcode[1]=0x00; ext=2; break; - case TAB(BRANCH,LONG): - if (cpu_of_arch(current_architecture) < m68020) { - if (fragP->fr_opcode[0]==0x61) { - fragP->fr_opcode[0]= 0x4E; - fragP->fr_opcode[1]= 0xB9; /* JBSR with ABSL LONG offset */ - subseg_change(SEG_TEXT, 0); - - fix_new(fragP, - fragP->fr_fix, - 4, - fragP->fr_symbol, - 0, - fragP->fr_offset, - 0, - NO_RELOC); - - fragP->fr_fix+=4; - ext=0; - } else if (fragP->fr_opcode[0]==0x60) { - fragP->fr_opcode[0]= 0x4E; - fragP->fr_opcode[1]= 0xF9; /* JMP with ABSL LONG offset */ - subseg_change(SEG_TEXT, 0); - fix_new(fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0, fragP->fr_offset,0, - NO_RELOC); - fragP->fr_fix+=4; - ext=0; - } else { - as_bad("Long branch offset not supported."); - } - } else { - fragP->fr_opcode[1]=0xff; - ext=4; - } + case TAB(BRANCH,LONG): + if (cpu_of_arch(current_architecture) < m68020) { + if (fragP->fr_opcode[0]==0x61) { + fragP->fr_opcode[0]= 0x4E; + fragP->fr_opcode[1]= 0xB9; /* JBSR with ABSL LONG offset */ + subseg_change(SEG_TEXT, 0); + + fix_new(fragP, + fragP->fr_fix, + 4, + fragP->fr_symbol, + 0, + fragP->fr_offset, + 0, + NO_RELOC); + + fragP->fr_fix+=4; + ext=0; + } else if (fragP->fr_opcode[0]==0x60) { + fragP->fr_opcode[0]= 0x4E; + fragP->fr_opcode[1]= 0xF9; /* JMP with ABSL LONG offset */ + subseg_change(SEG_TEXT, 0); + fix_new(fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0, fragP->fr_offset,0, + NO_RELOC); + fragP->fr_fix+=4; + ext=0; + } else { + as_bad("Long branch offset not supported."); + } + } else { + fragP->fr_opcode[1]=0xff; + ext=4; + } break; - case TAB(BCC68000,LONG): - /* only Bcc 68000 instructions can come here */ - /* change bcc into b!cc/jmp absl long */ - fragP->fr_opcode[0] ^= 0x01; /* invert bcc */ + case TAB(BCC68000,LONG): + /* only Bcc 68000 instructions can come here */ + /* change bcc into b!cc/jmp absl long */ + fragP->fr_opcode[0] ^= 0x01; /* invert bcc */ fragP->fr_opcode[1] = 0x6; /* branch offset = 6 */ /* JF: these used to be fr_opcode[2,3], but they may be in a @@ -3538,11 +3538,11 @@ register fragS *fragP; fragP->fr_fix += 4; ext=0; break; - case TAB(DBCC,LONG): - /* only DBcc 68000 instructions can come here */ - /* change dbcc into dbcc/jmp absl long */ - /* JF: these used to be fr_opcode[2-7], but that's wrong */ - *buffer_address++ = 0x00; /* branch offset = 4 */ + case TAB(DBCC,LONG): + /* only DBcc 68000 instructions can come here */ + /* change dbcc into dbcc/jmp absl long */ + /* JF: these used to be fr_opcode[2-7], but that's wrong */ + *buffer_address++ = 0x00; /* branch offset = 4 */ *buffer_address++ = 0x04; *buffer_address++ = 0x60; /* put in bra pc+6 */ *buffer_address++ = 0x06; @@ -3557,22 +3557,22 @@ register fragS *fragP; fragP->fr_fix += 4; ext=0; break; - case TAB(FBRANCH,SHORT): - know((fragP->fr_opcode[1]&0x40)==0); + case TAB(FBRANCH,SHORT): + know((fragP->fr_opcode[1]&0x40)==0); ext=2; break; - case TAB(FBRANCH,LONG): - fragP->fr_opcode[1]|=0x40; /* Turn on LONG bit */ + case TAB(FBRANCH,LONG): + fragP->fr_opcode[1]|=0x40; /* Turn on LONG bit */ ext=4; break; - case TAB(PCREL,SHORT): - ext=2; + case TAB(PCREL,SHORT): + ext=2; break; - case TAB(PCREL,LONG): - /* The thing to do here is force it to ABSOLUTE LONG, since - PCREL is really trying to shorten an ABSOLUTE address anyway */ - /* JF FOO This code has not been tested */ - subseg_change(SEG_TEXT,0); + case TAB(PCREL,LONG): + /* The thing to do here is force it to ABSOLUTE LONG, since + PCREL is really trying to shorten an ABSOLUTE address anyway */ + /* JF FOO This code has not been tested */ + subseg_change(SEG_TEXT,0); fix_new(fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0, fragP->fr_offset, 0, NO_RELOC); if((fragP->fr_opcode[1] & 0x3F) != 0x3A) as_bad("Internal error (long PC-relative operand) for insn 0x%04lx at 0x%lx", @@ -3585,217 +3585,217 @@ register fragS *fragP; 4); */ ext=0; break; - case TAB(PCLEA,SHORT): - subseg_change(SEG_TEXT,0); + case TAB(PCLEA,SHORT): + subseg_change(SEG_TEXT,0); fix_new(fragP,(int)(fragP->fr_fix),2,fragP->fr_symbol,(symbolS *)0,fragP->fr_offset,1, NO_RELOC); fragP->fr_opcode[1] &= ~0x3F; fragP->fr_opcode[1] |= 0x3A; ext=2; break; - case TAB(PCLEA,LONG): - subseg_change(SEG_TEXT,0); + case TAB(PCLEA,LONG): + subseg_change(SEG_TEXT,0); fix_new(fragP,(int)(fragP->fr_fix)+2,4,fragP->fr_symbol,(symbolS *)0,fragP->fr_offset+2,1, NO_RELOC); *buffer_address++ = 0x01; *buffer_address++ = 0x70; fragP->fr_fix+=2; - /* buffer_address+=2; */ - ext=4; - break; - - } /* switch on subtype */ - - if (ext) { - md_number_to_chars(buffer_address, (long) disp, (int) ext); - fragP->fr_fix += ext; - /* H_SET_TEXT_SIZE(headers, H_GET_TEXT_SIZE(headers) + ext); */ - } /* if extending */ - - return; -} /* md_convert_frag() */ - -/* Force truly undefined symbols to their maximum size, and generally set up - the frag list to be relaxed - */ -int md_estimate_size_before_relax(fragP, segment) - register fragS *fragP; - segT segment; -{ - int old_fix; - register char *buffer_address = fragP->fr_fix + fragP->fr_literal; - - old_fix = fragP->fr_fix; - - /* handle SZ_UNDEF first, it can be changed to BYTE or SHORT */ - switch(fragP->fr_subtype) { - - case TAB(BRANCH,SZ_UNDEF): { - if((fragP->fr_symbol != NULL) /* Not absolute */ - && S_GET_SEGMENT(fragP->fr_symbol) == segment) { - fragP->fr_subtype=TAB(TABTYPE(fragP->fr_subtype),BYTE); - break; - } else if((fragP->fr_symbol == 0) || (cpu_of_arch(current_architecture) < m68020)) { - /* On 68000, or for absolute value, switch to abs long */ - /* FIXME, we should check abs val, pick short or long */ - if(fragP->fr_opcode[0]==0x61) { - fragP->fr_opcode[0]= 0x4E; - fragP->fr_opcode[1]= 0xB9; /* JBSR with ABSL LONG offset */ - subseg_change(SEG_TEXT, 0); - fix_new(fragP, fragP->fr_fix, 4, - fragP->fr_symbol, 0, fragP->fr_offset, 0, NO_RELOC); - fragP->fr_fix+=4; - frag_wane(fragP); - } else if(fragP->fr_opcode[0]==0x60) { - fragP->fr_opcode[0]= 0x4E; - fragP->fr_opcode[1]= 0xF9; /* JMP with ABSL LONG offset */ - subseg_change(SEG_TEXT, 0); - fix_new(fragP, fragP->fr_fix, 4, - fragP->fr_symbol, 0, fragP->fr_offset, 0, NO_RELOC); - fragP->fr_fix+=4; - frag_wane(fragP); - } else { - as_warn("Long branch offset to extern symbol not supported."); - } - } else { /* Symbol is still undefined. Make it simple */ - fix_new(fragP, (int)(fragP->fr_fix), 4, fragP->fr_symbol, - (symbolS *)0, fragP->fr_offset+4, 1, NO_RELOC); - fragP->fr_fix+=4; - fragP->fr_opcode[1]=0xff; - frag_wane(fragP); - break; - } - - break; - } /* case TAB(BRANCH,SZ_UNDEF) */ - - case TAB(FBRANCH,SZ_UNDEF): { - if(S_GET_SEGMENT(fragP->fr_symbol) == segment || flagseen['l']) { - fragP->fr_subtype = TAB(FBRANCH,SHORT); - fragP->fr_var += 2; - } else { - fragP->fr_subtype = TAB(FBRANCH,LONG); - fragP->fr_var += 4; - } - break; - } /* TAB(FBRANCH,SZ_UNDEF) */ - - case TAB(PCREL,SZ_UNDEF): { - if(S_GET_SEGMENT(fragP->fr_symbol) == segment || flagseen['l']) { - fragP->fr_subtype = TAB(PCREL,SHORT); - fragP->fr_var += 2; - } else { - fragP->fr_subtype = TAB(PCREL,LONG); - fragP->fr_var += 4; - } - break; - } /* TAB(PCREL,SZ_UNDEF) */ - - case TAB(BCC68000,SZ_UNDEF): { - if((fragP->fr_symbol != NULL) - && S_GET_SEGMENT(fragP->fr_symbol) == segment) { - fragP->fr_subtype=TAB(BCC68000,BYTE); - break; - } - /* only Bcc 68000 instructions can come here */ - /* change bcc into b!cc/jmp absl long */ - fragP->fr_opcode[0] ^= 0x01; /* invert bcc */ - if(flagseen['l']) { - fragP->fr_opcode[1] = 0x04; /* branch offset = 6 */ - /* JF: these were fr_opcode[2,3] */ - buffer_address[0] = 0x4e; /* put in jmp long (0x4ef9) */ - buffer_address[1] = 0xf8; - fragP->fr_fix += 2; /* account for jmp instruction */ - subseg_change(SEG_TEXT,0); - fix_new(fragP, fragP->fr_fix, 2, fragP->fr_symbol, 0, - fragP->fr_offset, 0, NO_RELOC); - fragP->fr_fix += 2; - } else { - fragP->fr_opcode[1] = 0x06; /* branch offset = 6 */ - /* JF: these were fr_opcode[2,3] */ - buffer_address[2] = 0x4e; /* put in jmp long (0x4ef9) */ - buffer_address[3] = 0xf9; - fragP->fr_fix += 2; /* account for jmp instruction */ - subseg_change(SEG_TEXT,0); - fix_new(fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0, - fragP->fr_offset, 0, NO_RELOC); - fragP->fr_fix += 4; - } - frag_wane(fragP); + /* buffer_address+=2; */ + ext=4; break; - } /* case TAB(BCC68000,SZ_UNDEF) */ - case TAB(DBCC,SZ_UNDEF): { - if (fragP->fr_symbol != NULL && S_GET_SEGMENT(fragP->fr_symbol) == segment) { - fragP->fr_subtype=TAB(DBCC,SHORT); - fragP->fr_var+=2; - break; - } - /* only DBcc 68000 instructions can come here */ - /* change dbcc into dbcc/jmp absl long */ - /* JF: these used to be fr_opcode[2-4], which is wrong. */ - buffer_address[0] = 0x00; /* branch offset = 4 */ - buffer_address[1] = 0x04; - buffer_address[2] = 0x60; /* put in bra pc + ... */ - - if(flagseen['l']) { - /* JF: these were fr_opcode[5-7] */ - buffer_address[3] = 0x04; /* plus 4 */ - buffer_address[4] = 0x4e;/* Put in Jump Word */ - buffer_address[5] = 0xf8; - fragP->fr_fix += 6; /* account for bra/jmp instruction */ - subseg_change(SEG_TEXT,0); - fix_new(fragP, fragP->fr_fix, 2, fragP->fr_symbol, 0, - fragP->fr_offset, 0, NO_RELOC); - fragP->fr_fix += 2; - } else { - /* JF: these were fr_opcode[5-7] */ - buffer_address[3] = 0x06; /* Plus 6 */ - buffer_address[4] = 0x4e; /* put in jmp long (0x4ef9) */ - buffer_address[5] = 0xf9; - fragP->fr_fix += 6; /* account for bra/jmp instruction */ - subseg_change(SEG_TEXT,0); - fix_new(fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0, - fragP->fr_offset, 0, NO_RELOC); - fragP->fr_fix += 4; - } +} /* switch on subtype */ - frag_wane(fragP); - break; - } /* case TAB(DBCC,SZ_UNDEF) */ + if (ext) { + md_number_to_chars(buffer_address, (long) disp, (int) ext); + fragP->fr_fix += ext; + /* H_SET_TEXT_SIZE(headers, H_GET_TEXT_SIZE(headers) + ext); */ + } /* if extending */ - case TAB(PCLEA,SZ_UNDEF): { - if ((S_GET_SEGMENT(fragP->fr_symbol))==segment || flagseen['l']) { - fragP->fr_subtype=TAB(PCLEA,SHORT); - fragP->fr_var+=2; - } else { - fragP->fr_subtype=TAB(PCLEA,LONG); - fragP->fr_var+=6; - } - break; - } /* TAB(PCLEA,SZ_UNDEF) */ + return; +} /* md_convert_frag() */ + +/* Force truly undefined symbols to their maximum size, and generally set up + the frag list to be relaxed + */ +int md_estimate_size_before_relax(fragP, segment) +register fragS *fragP; +segT segment; +{ + int old_fix; + register char *buffer_address = fragP->fr_fix + fragP->fr_literal; - default: - break; + old_fix = fragP->fr_fix; + + /* handle SZ_UNDEF first, it can be changed to BYTE or SHORT */ + switch(fragP->fr_subtype) { + + case TAB(BRANCH,SZ_UNDEF): { + if((fragP->fr_symbol != NULL) /* Not absolute */ + && S_GET_SEGMENT(fragP->fr_symbol) == segment) { + fragP->fr_subtype=TAB(TABTYPE(fragP->fr_subtype),BYTE); + break; + } else if((fragP->fr_symbol == 0) || (cpu_of_arch(current_architecture) < m68020)) { + /* On 68000, or for absolute value, switch to abs long */ + /* FIXME, we should check abs val, pick short or long */ + if(fragP->fr_opcode[0]==0x61) { + fragP->fr_opcode[0]= 0x4E; + fragP->fr_opcode[1]= 0xB9; /* JBSR with ABSL LONG offset */ + subseg_change(SEG_TEXT, 0); + fix_new(fragP, fragP->fr_fix, 4, + fragP->fr_symbol, 0, fragP->fr_offset, 0, NO_RELOC); + fragP->fr_fix+=4; + frag_wane(fragP); + } else if(fragP->fr_opcode[0]==0x60) { + fragP->fr_opcode[0]= 0x4E; + fragP->fr_opcode[1]= 0xF9; /* JMP with ABSL LONG offset */ + subseg_change(SEG_TEXT, 0); + fix_new(fragP, fragP->fr_fix, 4, + fragP->fr_symbol, 0, fragP->fr_offset, 0, NO_RELOC); + fragP->fr_fix+=4; + frag_wane(fragP); + } else { + as_warn("Long branch offset to extern symbol not supported."); + } + } else { /* Symbol is still undefined. Make it simple */ + fix_new(fragP, (int)(fragP->fr_fix), 4, fragP->fr_symbol, + (symbolS *)0, fragP->fr_offset+4, 1, NO_RELOC); + fragP->fr_fix+=4; + fragP->fr_opcode[1]=0xff; + frag_wane(fragP); + break; + } + + break; + } /* case TAB(BRANCH,SZ_UNDEF) */ + + case TAB(FBRANCH,SZ_UNDEF): { + if(S_GET_SEGMENT(fragP->fr_symbol) == segment || flagseen['l']) { + fragP->fr_subtype = TAB(FBRANCH,SHORT); + fragP->fr_var += 2; + } else { + fragP->fr_subtype = TAB(FBRANCH,LONG); + fragP->fr_var += 4; + } + break; + } /* TAB(FBRANCH,SZ_UNDEF) */ + + case TAB(PCREL,SZ_UNDEF): { + if(S_GET_SEGMENT(fragP->fr_symbol) == segment || flagseen['l']) { + fragP->fr_subtype = TAB(PCREL,SHORT); + fragP->fr_var += 2; + } else { + fragP->fr_subtype = TAB(PCREL,LONG); + fragP->fr_var += 4; + } + break; + } /* TAB(PCREL,SZ_UNDEF) */ + + case TAB(BCC68000,SZ_UNDEF): { + if((fragP->fr_symbol != NULL) + && S_GET_SEGMENT(fragP->fr_symbol) == segment) { + fragP->fr_subtype=TAB(BCC68000,BYTE); + break; + } + /* only Bcc 68000 instructions can come here */ + /* change bcc into b!cc/jmp absl long */ + fragP->fr_opcode[0] ^= 0x01; /* invert bcc */ + if(flagseen['l']) { + fragP->fr_opcode[1] = 0x04; /* branch offset = 6 */ + /* JF: these were fr_opcode[2,3] */ + buffer_address[0] = 0x4e; /* put in jmp long (0x4ef9) */ + buffer_address[1] = 0xf8; + fragP->fr_fix += 2; /* account for jmp instruction */ + subseg_change(SEG_TEXT,0); + fix_new(fragP, fragP->fr_fix, 2, fragP->fr_symbol, 0, + fragP->fr_offset, 0, NO_RELOC); + fragP->fr_fix += 2; + } else { + fragP->fr_opcode[1] = 0x06; /* branch offset = 6 */ + /* JF: these were fr_opcode[2,3] */ + buffer_address[2] = 0x4e; /* put in jmp long (0x4ef9) */ + buffer_address[3] = 0xf9; + fragP->fr_fix += 2; /* account for jmp instruction */ + subseg_change(SEG_TEXT,0); + fix_new(fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0, + fragP->fr_offset, 0, NO_RELOC); + fragP->fr_fix += 4; + } + frag_wane(fragP); + break; + } /* case TAB(BCC68000,SZ_UNDEF) */ + + case TAB(DBCC,SZ_UNDEF): { + if (fragP->fr_symbol != NULL && S_GET_SEGMENT(fragP->fr_symbol) == segment) { + fragP->fr_subtype=TAB(DBCC,SHORT); + fragP->fr_var+=2; + break; + } + /* only DBcc 68000 instructions can come here */ + /* change dbcc into dbcc/jmp absl long */ + /* JF: these used to be fr_opcode[2-4], which is wrong. */ + buffer_address[0] = 0x00; /* branch offset = 4 */ + buffer_address[1] = 0x04; + buffer_address[2] = 0x60; /* put in bra pc + ... */ + + if(flagseen['l']) { + /* JF: these were fr_opcode[5-7] */ + buffer_address[3] = 0x04; /* plus 4 */ + buffer_address[4] = 0x4e;/* Put in Jump Word */ + buffer_address[5] = 0xf8; + fragP->fr_fix += 6; /* account for bra/jmp instruction */ + subseg_change(SEG_TEXT,0); + fix_new(fragP, fragP->fr_fix, 2, fragP->fr_symbol, 0, + fragP->fr_offset, 0, NO_RELOC); + fragP->fr_fix += 2; + } else { + /* JF: these were fr_opcode[5-7] */ + buffer_address[3] = 0x06; /* Plus 6 */ + buffer_address[4] = 0x4e; /* put in jmp long (0x4ef9) */ + buffer_address[5] = 0xf9; + fragP->fr_fix += 6; /* account for bra/jmp instruction */ + subseg_change(SEG_TEXT,0); + fix_new(fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0, + fragP->fr_offset, 0, NO_RELOC); + fragP->fr_fix += 4; + } + + frag_wane(fragP); + break; + } /* case TAB(DBCC,SZ_UNDEF) */ + + case TAB(PCLEA,SZ_UNDEF): { + if ((S_GET_SEGMENT(fragP->fr_symbol))==segment || flagseen['l']) { + fragP->fr_subtype=TAB(PCLEA,SHORT); + fragP->fr_var+=2; + } else { + fragP->fr_subtype=TAB(PCLEA,LONG); + fragP->fr_var+=6; + } + break; + } /* TAB(PCLEA,SZ_UNDEF) */ + + default: + break; + + } /* switch on subtype looking for SZ_UNDEF's. */ - } /* switch on subtype looking for SZ_UNDEF's. */ - - /* now that SZ_UNDEF are taken care of, check others */ - switch(fragP->fr_subtype) { - case TAB(BCC68000,BYTE): + /* now that SZ_UNDEF are taken care of, check others */ + switch(fragP->fr_subtype) { + case TAB(BCC68000,BYTE): case TAB(BRANCH,BYTE): /* We can't do a short jump to the next instruction, so we force word mode. */ if (fragP->fr_symbol && S_GET_VALUE(fragP->fr_symbol)==0 && fragP->fr_symbol->sy_frag==fragP->fr_next) { - fragP->fr_subtype=TAB(TABTYPE(fragP->fr_subtype),SHORT); - fragP->fr_var+=2; + fragP->fr_subtype=TAB(TABTYPE(fragP->fr_subtype),SHORT); + fragP->fr_var+=2; } break; - default: + default: break; - } - return fragP->fr_var + fragP->fr_fix - old_fix; +} + return fragP->fr_var + fragP->fr_fix - old_fix; } #if defined(OBJ_AOUT) | defined(OBJ_BOUT) @@ -3815,53 +3815,53 @@ void char *the_bytes; struct reloc_info_generic *ri; { - /* this is easy */ - md_number_to_chars(the_bytes, ri->r_address, 4); - /* now the fun stuff */ - the_bytes[4] = (ri->r_symbolnum >> 16) & 0x0ff; - the_bytes[5] = (ri->r_symbolnum >> 8) & 0x0ff; - the_bytes[6] = ri->r_symbolnum & 0x0ff; - the_bytes[7] = (((ri->r_pcrel << 7) & 0x80) | ((ri->r_length << 5) & 0x60) | - ((ri->r_extern << 4) & 0x10)); + /* this is easy */ + md_number_to_chars(the_bytes, ri->r_address, 4); + /* now the fun stuff */ + the_bytes[4] = (ri->r_symbolnum >> 16) & 0x0ff; + the_bytes[5] = (ri->r_symbolnum >> 8) & 0x0ff; + the_bytes[6] = ri->r_symbolnum & 0x0ff; + the_bytes[7] = (((ri->r_pcrel << 7) & 0x80) | ((ri->r_length << 5) & 0x60) | + ((ri->r_extern << 4) & 0x10)); } #endif /* comment */ void tc_aout_fix_to_chars(where, fixP, segment_address_in_file) - char *where; - fixS *fixP; - relax_addressT segment_address_in_file; +char *where; +fixS *fixP; +relax_addressT segment_address_in_file; { - /* - * In: length of relocation (or of address) in chars: 1, 2 or 4. - * Out: GNU LD relocation length code: 0, 1, or 2. - */ - - static unsigned char nbytes_r_length [] = { 42, 0, 1, 42, 2 }; - - long r_extern; - long r_symbolnum; - - /* this is easy */ - md_number_to_chars(where, - fixP->fx_frag->fr_address + fixP->fx_where - segment_address_in_file, - 4); - - /* now the fun stuff */ - if (S_GET_TYPE(fixP->fx_addsy) == N_UNDF) { - r_extern = 1; - r_symbolnum = fixP->fx_addsy->sy_number; - } else { - r_extern = 0; - r_symbolnum = S_GET_TYPE(fixP->fx_addsy); - } - - where[4] = (r_symbolnum >> 16) & 0x0ff; - where[5] = (r_symbolnum >> 8) & 0x0ff; - where[6] = r_symbolnum & 0x0ff; - where[7] = (((fixP->fx_pcrel << 7) & 0x80) | ((nbytes_r_length[fixP->fx_size] << 5) & 0x60) | - ((r_extern << 4) & 0x10)); - - return; + /* + * In: length of relocation (or of address) in chars: 1, 2 or 4. + * Out: GNU LD relocation length code: 0, 1, or 2. + */ + + static unsigned char nbytes_r_length [] = { 42, 0, 1, 42, 2 }; + + long r_extern; + long r_symbolnum; + + /* this is easy */ + md_number_to_chars(where, + fixP->fx_frag->fr_address + fixP->fx_where - segment_address_in_file, + 4); + + /* now the fun stuff */ + if (S_GET_TYPE(fixP->fx_addsy) == N_UNDF) { + r_extern = 1; + r_symbolnum = fixP->fx_addsy->sy_number; + } else { + r_extern = 0; + r_symbolnum = S_GET_TYPE(fixP->fx_addsy); + } + + where[4] = (r_symbolnum >> 16) & 0x0ff; + where[5] = (r_symbolnum >> 8) & 0x0ff; + where[6] = r_symbolnum & 0x0ff; + where[7] = (((fixP->fx_pcrel << 7) & 0x80) | ((nbytes_r_length[fixP->fx_size] << 5) & 0x60) | + ((r_extern << 4) & 0x10)); + + return; } /* tc_aout_fix_to_chars() */ #endif /* OBJ_AOUT or OBJ_BOUT */ @@ -3878,12 +3878,12 @@ long from_addr, fragS *frag; symbolS *to_symbol; { - long offset; - - offset = to_addr - (from_addr+2); - - md_number_to_chars(ptr ,(long)0x6000,2); - md_number_to_chars(ptr+2,(long)offset,2); + long offset; + + offset = to_addr - (from_addr+2); + + md_number_to_chars(ptr ,(long)0x6000,2); + md_number_to_chars(ptr+2,(long)offset,2); } void @@ -3894,19 +3894,19 @@ long from_addr, fragS *frag; symbolS *to_symbol; { - long offset; - - if (cpu_of_arch(current_architecture) < m68020) { - offset=to_addr-S_GET_VALUE(to_symbol); - md_number_to_chars(ptr ,(long)0x4EF9,2); - md_number_to_chars(ptr+2,(long)offset,4); - fix_new(frag,(ptr+2)-frag->fr_literal,4,to_symbol,(symbolS *)0,(long)0,0, - NO_RELOC); - } else { - offset=to_addr - (from_addr+2); - md_number_to_chars(ptr ,(long)0x60ff,2); - md_number_to_chars(ptr+2,(long)offset,4); - } + long offset; + + if (cpu_of_arch(current_architecture) < m68020) { + offset=to_addr-S_GET_VALUE(to_symbol); + md_number_to_chars(ptr ,(long)0x4EF9,2); + md_number_to_chars(ptr+2,(long)offset,4); + fix_new(frag,(ptr+2)-frag->fr_literal,4,to_symbol,(symbolS *)0,(long)0,0, + NO_RELOC); + } else { + offset=to_addr - (from_addr+2); + md_number_to_chars(ptr ,(long)0x60ff,2); + md_number_to_chars(ptr+2,(long)offset,4); + } } #endif @@ -3926,178 +3926,178 @@ symbolS *to_symbol; */ static int get_num(exp,ok) - struct m68k_exp *exp; - int ok; +struct m68k_exp *exp; +int ok; { #ifdef TEST2 - long l = 0; - - if(!exp->e_beg) - return 0; - if(*exp->e_beg=='0') { - if(exp->e_beg[1]=='x') - sscanf(exp->e_beg+2,"%x",&l); - else - sscanf(exp->e_beg+1,"%O",&l); - return l; - } - return atol(exp->e_beg); + long l = 0; + + if(!exp->e_beg) + return 0; + if(*exp->e_beg=='0') { + if(exp->e_beg[1]=='x') + sscanf(exp->e_beg+2,"%x",&l); + else + sscanf(exp->e_beg+1,"%O",&l); + return l; + } + return atol(exp->e_beg); #else - char *save_in; - char c_save; - - if(!exp) { - /* Can't do anything */ - return 0; - } - if(!exp->e_beg || !exp->e_end) { - seg(exp)=SEG_ABSOLUTE; - adds(exp)=0; - subs(exp)=0; - offs(exp)= (ok==10) ? 1 : 0; - as_warn("Null expression defaults to %ld",offs(exp)); - return 0; - } - - exp->e_siz=0; - if(/* ok!=80 && */exp->e_end[-1]==SIZER && (exp->e_end-exp->e_beg)>=2) { - switch(exp->e_end[0]) { - case 's': - case 'S': - case 'b': - case 'B': - exp->e_siz=1; - break; - case 'w': - case 'W': - exp->e_siz=2; - break; - case 'l': - case 'L': - exp->e_siz=3; - break; - default: - as_bad("Unknown size for expression \"%c\"",exp->e_end[0]); + char *save_in; + char c_save; + + if(!exp) { + /* Can't do anything */ + return 0; + } + if(!exp->e_beg || !exp->e_end) { + seg(exp)=SEG_ABSOLUTE; + adds(exp)=0; + subs(exp)=0; + offs(exp)= (ok==10) ? 1 : 0; + as_warn("Null expression defaults to %ld",offs(exp)); + return 0; } - exp->e_end-=2; - } - c_save=exp->e_end[1]; - exp->e_end[1]='\0'; - save_in=input_line_pointer; - input_line_pointer=exp->e_beg; - switch(expression(&(exp->e_exp))) { - case SEG_PASS1: - seg(exp)=SEG_ABSOLUTE; - adds(exp)=0; - subs(exp)=0; - offs(exp)= (ok==10) ? 1 : 0; - as_warn("Unknown expression: '%s' defaulting to %d",exp->e_beg,offs(exp)); - break; - case SEG_ABSENT: - /* Do the same thing the VAX asm does */ - seg(exp)=SEG_ABSOLUTE; - adds(exp)=0; - subs(exp)=0; - offs(exp)=0; - if(ok==10) { - as_warn("expression out of range: defaulting to 1"); - offs(exp)=1; + exp->e_siz=0; + if(/* ok!=80 && */exp->e_end[-1]==SIZER && (exp->e_end-exp->e_beg)>=2) { + switch(exp->e_end[0]) { + case 's': + case 'S': + case 'b': + case 'B': + exp->e_siz=1; + break; + case 'w': + case 'W': + exp->e_siz=2; + break; + case 'l': + case 'L': + exp->e_siz=3; + break; + default: + as_bad("Unknown size for expression \"%c\"",exp->e_end[0]); + } + exp->e_end-=2; } - break; - case SEG_ABSOLUTE: - switch(ok) { - case 10: - if(offs(exp)<1 || offs(exp)>8) { - as_warn("expression out of range: defaulting to 1"); - offs(exp)=1; - } - break; - case 20: - if(offs(exp)<0 || offs(exp)>7) - goto outrange; - break; - case 30: - if(offs(exp)<0 || offs(exp)>15) - goto outrange; - break; - case 40: - if(offs(exp)<0 || offs(exp)>32) - goto outrange; - break; - case 50: - if(offs(exp)<0 || offs(exp)>127) - goto outrange; - break; - case 55: - if(offs(exp)<-64 || offs(exp)>63) - goto outrange; - break; - case 60: - if(offs(exp)<-128 || offs(exp)>127) - goto outrange; - break; - case 70: - if(offs(exp)<0 || offs(exp)>4095) { - outrange: - as_warn("expression out of range: defaulting to 0"); + c_save=exp->e_end[1]; + exp->e_end[1]='\0'; + save_in=input_line_pointer; + input_line_pointer=exp->e_beg; + switch(expression(&(exp->e_exp))) { + case SEG_PASS1: + seg(exp)=SEG_ABSOLUTE; + adds(exp)=0; + subs(exp)=0; + offs(exp)= (ok==10) ? 1 : 0; + as_warn("Unknown expression: '%s' defaulting to %d",exp->e_beg,offs(exp)); + break; + + case SEG_ABSENT: + /* Do the same thing the VAX asm does */ + seg(exp)=SEG_ABSOLUTE; + adds(exp)=0; + subs(exp)=0; offs(exp)=0; - } - break; + if(ok==10) { + as_warn("expression out of range: defaulting to 1"); + offs(exp)=1; + } + break; + case SEG_ABSOLUTE: + switch(ok) { + case 10: + if(offs(exp)<1 || offs(exp)>8) { + as_warn("expression out of range: defaulting to 1"); + offs(exp)=1; + } + break; + case 20: + if(offs(exp)<0 || offs(exp)>7) + goto outrange; + break; + case 30: + if(offs(exp)<0 || offs(exp)>15) + goto outrange; + break; + case 40: + if(offs(exp)<0 || offs(exp)>32) + goto outrange; + break; + case 50: + if(offs(exp)<0 || offs(exp)>127) + goto outrange; + break; + case 55: + if(offs(exp)<-64 || offs(exp)>63) + goto outrange; + break; + case 60: + if(offs(exp)<-128 || offs(exp)>127) + goto outrange; + break; + case 70: + if(offs(exp)<0 || offs(exp)>4095) { + outrange: + as_warn("expression out of range: defaulting to 0"); + offs(exp)=0; + } + break; + default: + break; + } + break; + case SEG_TEXT: + case SEG_DATA: + case SEG_BSS: + case SEG_UNKNOWN: + case SEG_DIFFERENCE: + if(ok>=10 && ok<=70) { + seg(exp)=SEG_ABSOLUTE; + adds(exp)=0; + subs(exp)=0; + offs(exp)= (ok==10) ? 1 : 0; + as_warn("Can't deal with expression \"%s\": defaulting to %ld",exp->e_beg,offs(exp)); + } + break; + case SEG_BIG: + if(ok==80 && offs(exp)<0) { /* HACK! Turn it into a long */ + LITTLENUM_TYPE words[6]; + + gen_to_words(words,2,8L);/* These numbers are magic! */ + seg(exp)=SEG_ABSOLUTE; + adds(exp)=0; + subs(exp)=0; + offs(exp)=words[1]|(words[0]<<16); + } else if(ok!=0) { + seg(exp)=SEG_ABSOLUTE; + adds(exp)=0; + subs(exp)=0; + offs(exp)= (ok==10) ? 1 : 0; + as_warn("Can't deal with expression \"%s\": defaulting to %ld",exp->e_beg,offs(exp)); + } + break; default: - break; - } - break; - case SEG_TEXT: - case SEG_DATA: - case SEG_BSS: - case SEG_UNKNOWN: - case SEG_DIFFERENCE: - if(ok>=10 && ok<=70) { - seg(exp)=SEG_ABSOLUTE; - adds(exp)=0; - subs(exp)=0; - offs(exp)= (ok==10) ? 1 : 0; - as_warn("Can't deal with expression \"%s\": defaulting to %ld",exp->e_beg,offs(exp)); - } - break; - case SEG_BIG: - if(ok==80 && offs(exp)<0) { /* HACK! Turn it into a long */ - LITTLENUM_TYPE words[6]; - - gen_to_words(words,2,8L);/* These numbers are magic! */ - seg(exp)=SEG_ABSOLUTE; - adds(exp)=0; - subs(exp)=0; - offs(exp)=words[1]|(words[0]<<16); - } else if(ok!=0) { - seg(exp)=SEG_ABSOLUTE; - adds(exp)=0; - subs(exp)=0; - offs(exp)= (ok==10) ? 1 : 0; - as_warn("Can't deal with expression \"%s\": defaulting to %ld",exp->e_beg,offs(exp)); + as_fatal("failed sanity check."); } - break; - default: - as_fatal("failed sanity check."); - } - if(input_line_pointer!=exp->e_end+1) - as_bad("Ignoring junk after expression"); - exp->e_end[1]=c_save; - input_line_pointer=save_in; - if(exp->e_siz) { - switch(exp->e_siz) { - case 1: - if(!isbyte(offs(exp))) - as_warn("expression doesn't fit in BYTE"); - break; - case 2: - if(!isword(offs(exp))) - as_warn("expression doesn't fit in WORD"); - break; + if(input_line_pointer!=exp->e_end+1) + as_bad("Ignoring junk after expression"); + exp->e_end[1]=c_save; + input_line_pointer=save_in; + if(exp->e_siz) { + switch(exp->e_siz) { + case 1: + if(!isbyte(offs(exp))) + as_warn("expression doesn't fit in BYTE"); + break; + case 2: + if(!isword(offs(exp))) + as_warn("expression doesn't fit in WORD"); + break; + } } - } - return offs(exp); + return offs(exp); #endif } /* get_num() */ @@ -4105,35 +4105,35 @@ static int get_num(exp,ok) void demand_empty_rest_of_line(); /* Hate those extra verbose names */ static void s_data1() { - subseg_new(SEG_DATA,1); - demand_empty_rest_of_line(); + subseg_new(SEG_DATA,1); + demand_empty_rest_of_line(); } /* s_data1() */ static void s_data2() { - subseg_new(SEG_DATA,2); - demand_empty_rest_of_line(); + subseg_new(SEG_DATA,2); + demand_empty_rest_of_line(); } /* s_data2() */ static void s_bss() { - /* We don't support putting frags in the BSS segment, but we - can put them into initialized data for now... */ - subseg_new(SEG_DATA,255); /* FIXME-SOON */ - demand_empty_rest_of_line(); + /* We don't support putting frags in the BSS segment, but we + can put them into initialized data for now... */ + subseg_new(SEG_DATA,255); /* FIXME-SOON */ + demand_empty_rest_of_line(); } /* s_bss() */ static void s_even() { - register int temp; - register long temp_fill; - - temp = 1; /* JF should be 2? */ - temp_fill = get_absolute_expression (); - if ( ! need_pass_2 ) /* Never make frag if expect extra pass. */ - frag_align (temp, (int)temp_fill); - demand_empty_rest_of_line(); + register int temp; + register long temp_fill; + + temp = 1; /* JF should be 2? */ + temp_fill = get_absolute_expression (); + if ( ! need_pass_2 ) /* Never make frag if expect extra pass. */ + frag_align (temp, (int)temp_fill); + demand_empty_rest_of_line(); } /* s_even() */ static void s_proc() { - demand_empty_rest_of_line(); + demand_empty_rest_of_line(); } /* s_proc() */ /* s_space is defined in read.c .skip is simply an alias to it. */ @@ -4163,79 +4163,79 @@ static void s_proc() { #endif int md_parse_option(argP,cntP,vecP) - char **argP; - int *cntP; - char ***vecP; +char **argP; +int *cntP; +char ***vecP; { - switch(**argP) { - case 'l': /* -l means keep external to 2 bit offset - rather than 16 bit one */ - break; - - case 'S': /* -S means that jbsr's always turn into jsr's. */ - break; - - case 'A': - (*argP)++; - /* intentional fall-through */ - case 'm': - (*argP)++; - - if (**argP=='c') { - (*argP)++; - } /* allow an optional "c" */ - - if (!strcmp(*argP, "68000") - || !strcmp(*argP, "68008")) { - current_architecture |= m68000; - } else if (!strcmp(*argP, "68010")) { + switch(**argP) { + case 'l': /* -l means keep external to 2 bit offset + rather than 16 bit one */ + break; + + case 'S': /* -S means that jbsr's always turn into jsr's. */ + break; + + case 'A': + (*argP)++; + /* intentional fall-through */ + case 'm': + (*argP)++; + + if (**argP=='c') { + (*argP)++; + } /* allow an optional "c" */ + + if (!strcmp(*argP, "68000") + || !strcmp(*argP, "68008")) { + current_architecture |= m68000; + } else if (!strcmp(*argP, "68010")) { #ifdef TE_SUN - omagic= 1<<16|OMAGIC; + omagic= 1<<16|OMAGIC; #endif - current_architecture |= m68010; - - } else if (!strcmp(*argP, "68020")) { - current_architecture |= m68020 | MAYBE_FLOAT_TOO; - - } else if (!strcmp(*argP, "68030")) { - current_architecture |= m68030 | MAYBE_FLOAT_TOO; - - } else if (!strcmp(*argP, "68040")) { - current_architecture |= m68040 | MAYBE_FLOAT_TOO; - + current_architecture |= m68010; + + } else if (!strcmp(*argP, "68020")) { + current_architecture |= m68020 | MAYBE_FLOAT_TOO; + + } else if (!strcmp(*argP, "68030")) { + current_architecture |= m68030 | MAYBE_FLOAT_TOO; + + } else if (!strcmp(*argP, "68040")) { + current_architecture |= m68040 | MAYBE_FLOAT_TOO; + #ifndef NO_68881 - } else if (!strcmp(*argP, "68881")) { - current_architecture |= m68881; - - } else if (!strcmp(*argP, "68882")) { - current_architecture |= m68882; - + } else if (!strcmp(*argP, "68881")) { + current_architecture |= m68881; + + } else if (!strcmp(*argP, "68882")) { + current_architecture |= m68882; + #endif /* NO_68881 */ #ifndef NO_68851 - } else if (!strcmp(*argP,"68851")) { - current_architecture |= m68851; - + } else if (!strcmp(*argP,"68851")) { + current_architecture |= m68851; + #endif /* NO_68851 */ - } else { - as_warn("Unknown architecture, \"%s\". option ignored", *argP); - } /* switch on architecture */ - - while(**argP) (*argP)++; - - break; - - case 'p': - if (!strcmp(*argP,"pic")) { - (*argP) += 3; - break; /* -pic, Position Independent Code */ - } else { - return(0); - } /* pic or not */ - - default: - return 0; - } - return 1; + } else { + as_warn("Unknown architecture, \"%s\". option ignored", *argP); + } /* switch on architecture */ + + while(**argP) (*argP)++; + + break; + + case 'p': + if (!strcmp(*argP,"pic")) { + (*argP) += 3; + break; /* -pic, Position Independent Code */ + } else { + return(0); + } /* pic or not */ + + default: + return 0; + } + return 1; } @@ -4246,62 +4246,62 @@ int md_parse_option(argP,cntP,vecP) main() { - struct m68k_it the_ins; - char buf[120]; - char *cp; - int n; - - m68k_ip_begin(); - for(;;) { - if(!gets(buf) || !*buf) - break; - if(buf[0]=='|' || buf[1]=='.') - continue; - for(cp=buf;*cp;cp++) - if(*cp=='\t') - *cp=' '; - if(is_label(buf)) - continue; - bzero(&the_ins,sizeof(the_ins)); - m68k_ip(&the_ins,buf); - if(the_ins.error) { - printf("Error %s in %s\n",the_ins.error,buf); - } else { - printf("Opcode(%d.%s): ",the_ins.numo,the_ins.args); - for(n=0;nfr_next) { - printf("addr %lu next 0x%x fix %ld var %ld symbol 0x%x offset %ld\n", - fragP->fr_address,fragP->fr_next,fragP->fr_fix,fragP->fr_var,fragP->fr_symbol,fragP->fr_offset); - printf("opcode 0x%x type %d subtype %d\n\n",fragP->fr_opcode,fragP->fr_type,fragP->fr_subtype); - } - fflush(stdout); - return 0; + fragS *fragP; + extern fragS *text_frag_root; + + for(fragP=text_frag_root;fragP;fragP=fragP->fr_next) { + printf("addr %lu next 0x%x fix %ld var %ld symbol 0x%x offset %ld\n", + fragP->fr_address,fragP->fr_next,fragP->fr_fix,fragP->fr_var,fragP->fr_symbol,fragP->fr_offset); + printf("opcode 0x%x type %d subtype %d\n\n",fragP->fr_opcode,fragP->fr_type,fragP->fr_subtype); + } + fflush(stdout); + return 0; } #endif #ifdef DONTDEF /*VARARGS1*/ panic(format,args) - char *format; +char *format; { - fputs("Internal error:",stderr); - _doprnt(format,&args,stderr); - (void)putc('\n',stderr); - as_where(); - abort(); + fputs("Internal error:",stderr); + _doprnt(format,&args,stderr); + (void)putc('\n',stderr); + as_where(); + abort(); } #endif @@ -4384,7 +4367,7 @@ symbolS * md_undefined_symbol (name) char *name; { - return 0; + return 0; } /* Parse an operand that is machine-specific. @@ -4404,7 +4387,7 @@ long segT segment; long size; { - return size; /* Byte alignment is fine */ + return size; /* Byte alignment is fine */ } /* Exactly what point is a PC-relative offset relative TO? @@ -4414,89 +4397,89 @@ long md_pcrel_from (fixP) fixS *fixP; { - return fixP->fx_size + fixP->fx_where + fixP->fx_frag->fr_address; + return fixP->fx_size + fixP->fx_where + fixP->fx_frag->fr_address; } #ifdef MRI void s_ds(size) { - unsigned int fill = get_absolute_expression() * size; - char *p = frag_var (rs_fill, fill, fill, (relax_substateT)0, (symbolS *)0, - 1, (char *)0); - * p = 0; - demand_empty_rest_of_line(); + unsigned int fill = get_absolute_expression() * size; + char *p = frag_var (rs_fill, fill, fill, (relax_substateT)0, (symbolS *)0, + 1, (char *)0); + * p = 0; + demand_empty_rest_of_line(); } void s_dc(size) { - - cons(size); - - + + cons(size); + + } void s_dcb(size) { - int repeat = get_absolute_expression(); - int fill; - - if (*input_line_pointer == ',') - { - char *p; - input_line_pointer++; - - fill = get_absolute_expression(); - p = frag_var(rs_fill, - size, - size, - (relax_substateT)0, - (symbolS *)0, - repeat, - 0); - md_number_to_chars(p, fill, size); - } - demand_empty_rest_of_line(); - - + int repeat = get_absolute_expression(); + int fill; + + if (*input_line_pointer == ',') + { + char *p; + input_line_pointer++; + + fill = get_absolute_expression(); + p = frag_var(rs_fill, + size, + size, + (relax_substateT)0, + (symbolS *)0, + repeat, + 0); + md_number_to_chars(p, fill, size); + } + demand_empty_rest_of_line(); + + } void s_chip() { - unsigned int target = get_absolute_expression(); + unsigned int target = get_absolute_expression(); #define MACHINE_MASK (m68000 | m68008 | m68010 | m68020 | m68040) - switch (target) - { - case 68000: - case 68008: - current_architecture = (current_architecture & ~ MACHINE_MASK) | m68000; - break; - case 68010: - current_architecture = (current_architecture & ~ MACHINE_MASK) | m68010; - break; - case 68020: - current_architecture = (current_architecture & ~ MACHINE_MASK) | m68020; - break; - case 68030: - current_architecture = (current_architecture & ~ MACHINE_MASK) | m68030; - break; - case 68040: - current_architecture = (current_architecture & ~ MACHINE_MASK) | m68040; - break; - case 68881: - current_architecture |= m68881; - break; - case 68882: - current_architecture |= m68882; - break; - case 68851: - current_architecture |= m68851; - break; - - default: - as_bad("Unrecognised CHIP %d\n", target); - - } - demand_empty_rest_of_line(); + switch (target) + { + case 68000: + case 68008: + current_architecture = (current_architecture & ~ MACHINE_MASK) | m68000; + break; + case 68010: + current_architecture = (current_architecture & ~ MACHINE_MASK) | m68010; + break; + case 68020: + current_architecture = (current_architecture & ~ MACHINE_MASK) | m68020; + break; + case 68030: + current_architecture = (current_architecture & ~ MACHINE_MASK) | m68030; + break; + case 68040: + current_architecture = (current_architecture & ~ MACHINE_MASK) | m68040; + break; + case 68881: + current_architecture |= m68881; + break; + case 68882: + current_architecture |= m68882; + break; + case 68851: + current_architecture |= m68851; + break; + + default: + as_bad("Unrecognised CHIP %d\n", target); + + } + demand_empty_rest_of_line(); } #endif diff --git a/gas/config/tc-m68kmote.h b/gas/config/tc-m68kmote.h index e1904ff..95e0c15 100644 --- a/gas/config/tc-m68kmote.h +++ b/gas/config/tc-m68kmote.h @@ -45,7 +45,7 @@ #define LISTING_LHS_WIDTH 3 /* 3 word on the first line */ #define LISTING_LHS_WIDTH_SECOND 3 /* One word on the second line */ #define LISTING_LHS_CONT_LINES 4 /* And 4 lines max */ -#define LISTING_HEADER "TANDEM ST-2000 68K GAS " +#define LISTING_HEADER "68K GAS " /* Copied from write.c */ #define M68K_AIM_KLUDGE(aim, this_state,this_type) \ diff --git a/gas/config/tc-ns32k.c b/gas/config/tc-ns32k.c index 9676852..e34a204 100644 --- a/gas/config/tc-ns32k.c +++ b/gas/config/tc-ns32k.c @@ -33,10 +33,10 @@ #include "obstack.h" /* Macros */ -#define IIF_ENTRIES 13 /* number of entries in iif */ -#define PRIVATE_SIZE 256 /* size of my garbage memory */ +#define IIF_ENTRIES 13 /* number of entries in iif */ +#define PRIVATE_SIZE 256 /* size of my garbage memory */ #define MAX_ARGS 4 -#define DEFAULT -1 /* addr_mode returns this value when plain constant or label is encountered */ +#define DEFAULT -1 /* addr_mode returns this value when plain constant or label is encountered */ #define IIF(ptr,a1,c1,e1,g1,i1,k1,m1,o1,q1,s1,u1) \ iif.iifP[ptr].type= a1; \ @@ -68,17 +68,17 @@ char line_comment_chars[] = LINE_COMMENT_CHARS; #endif struct addr_mode { - char mode; /* addressing mode of operand (0-31) */ - char scaled_mode; /* mode combined with scaled mode */ - char scaled_reg; /* register used in scaled+1 (1-8) */ - char float_flag; /* set if R0..R7 was F0..F7 ie a floating-point-register */ - char am_size; /* estimated max size of general addr-mode parts*/ - char im_disp; /* if im_disp==1 we have a displacement */ - char pcrel; /* 1 if pcrel, this is really redundant info */ - char disp_suffix[2]; /* length of displacement(s), 0=undefined */ - char *disp[2]; /* pointer(s) at displacement(s) + char mode; /* addressing mode of operand (0-31) */ + char scaled_mode; /* mode combined with scaled mode */ + char scaled_reg; /* register used in scaled+1 (1-8) */ + char float_flag; /* set if R0..R7 was F0..F7 ie a floating-point-register */ + char am_size; /* estimated max size of general addr-mode parts*/ + char im_disp; /* if im_disp==1 we have a displacement */ + char pcrel; /* 1 if pcrel, this is really redundant info */ + char disp_suffix[2]; /* length of displacement(s), 0=undefined */ + char *disp[2]; /* pointer(s) at displacement(s) or immediates(s) (ascii) */ - char index_byte; /* index byte */ + char index_byte; /* index byte */ }; typedef struct addr_mode addr_modeS; @@ -100,27 +100,30 @@ char FLT_CHARS[] = "fd"; /* we don't want to support lowercase, do we */ /* internal structs */ struct option { - char *pattern; - unsigned long or; - unsigned long and; + char *pattern; + unsigned long or; + unsigned long and; }; typedef struct { - int type; /* how to interpret object */ - int size; /* Estimated max size of object */ - unsigned long object; /* binary data */ - int object_adjust; /* number added to object */ - int pcrel; /* True if object is pcrel */ - int pcrel_adjust; /* It's value reflects the length in bytes from the instruction start to the displacement */ - int im_disp; /* True if the object is a displacement */ - relax_substateT relax_substate; /* Initial relaxsubstate */ - bit_fixS *bit_fixP; /* Pointer at bit_fix struct */ - int addr_mode; /* What addrmode do we associate with this iif-entry */ - char bsr; /* Sequent hack */ -}iif_entryT; /* Internal Instruction Format */ + int type; /* how to interpret object */ + int size; /* Estimated max size of object */ + unsigned long object; /* binary data */ + int object_adjust; /* number added to object */ + int pcrel; /* True if object is pcrel */ + int pcrel_adjust; /* length in bytes from the + instruction start to the + displacement */ + int im_disp; /* True if the object is a displacement */ + relax_substateT relax_substate; /* Initial relaxsubstate */ + bit_fixS *bit_fixP; /* Pointer at bit_fix struct */ + int addr_mode; /* What addrmode do we associate with this iif-entry */ + char bsr; /* Sequent hack */ +}iif_entryT; /* Internal Instruction Format */ + struct int_ins_form { - int instr_size; /* Max size of instruction in bytes. */ - iif_entryT iifP[IIF_ENTRIES+1]; + int instr_size; /* Max size of instruction in bytes. */ + iif_entryT iifP[IIF_ENTRIES + 1]; }; struct int_ins_form iif; expressionS exprP; @@ -175,124 +178,124 @@ char *input_line_pointer; struct option opt1[]= /* restore, exit */ { -{ "r0", 0x80, 0xff }, -{ "r1", 0x40, 0xff }, -{ "r2", 0x20, 0xff }, -{ "r3", 0x10, 0xff }, -{ "r4", 0x08, 0xff }, -{ "r5", 0x04, 0xff }, -{ "r6", 0x02, 0xff }, -{ "r7", 0x01, 0xff }, -{ 0 , 0x00, 0xff } + { "r0", 0x80, 0xff }, + { "r1", 0x40, 0xff }, + { "r2", 0x20, 0xff }, + { "r3", 0x10, 0xff }, + { "r4", 0x08, 0xff }, + { "r5", 0x04, 0xff }, + { "r6", 0x02, 0xff }, + { "r7", 0x01, 0xff }, + { 0 , 0x00, 0xff } }; struct option opt2[]= /* save, enter */ { -{ "r0", 0x01, 0xff }, -{ "r1", 0x02, 0xff }, -{ "r2", 0x04, 0xff }, -{ "r3", 0x08, 0xff }, -{ "r4", 0x10, 0xff }, -{ "r5", 0x20, 0xff }, -{ "r6", 0x40, 0xff }, -{ "r7", 0x80, 0xff }, -{ 0 , 0x00, 0xff } + { "r0", 0x01, 0xff }, + { "r1", 0x02, 0xff }, + { "r2", 0x04, 0xff }, + { "r3", 0x08, 0xff }, + { "r4", 0x10, 0xff }, + { "r5", 0x20, 0xff }, + { "r6", 0x40, 0xff }, + { "r7", 0x80, 0xff }, + { 0 , 0x00, 0xff } }; struct option opt3[]= /* setcfg */ { -{ "c", 0x8, 0xff }, -{ "m", 0x4, 0xff }, -{ "f", 0x2, 0xff }, -{ "i", 0x1, 0xff }, -{ 0 , 0x0, 0xff } + { "c", 0x8, 0xff }, + { "m", 0x4, 0xff }, + { "f", 0x2, 0xff }, + { "i", 0x1, 0xff }, + { 0 , 0x0, 0xff } }; struct option opt4[]= /* cinv */ { -{ "a", 0x4, 0xff }, -{ "i", 0x2, 0xff }, -{ "d", 0x1, 0xff }, -{ 0 , 0x0, 0xff } + { "a", 0x4, 0xff }, + { "i", 0x2, 0xff }, + { "d", 0x1, 0xff }, + { 0 , 0x0, 0xff } }; struct option opt5[]= /* string inst */ { -{ "b", 0x2, 0xff }, -{ "u", 0xc, 0xff }, -{ "w", 0x4, 0xff }, -{ 0 , 0x0, 0xff } + { "b", 0x2, 0xff }, + { "u", 0xc, 0xff }, + { "w", 0x4, 0xff }, + { 0 , 0x0, 0xff } }; struct option opt6[]= /* plain reg ext,cvtp etc */ { -{ "r0", 0x00, 0xff }, -{ "r1", 0x01, 0xff }, -{ "r2", 0x02, 0xff }, -{ "r3", 0x03, 0xff }, -{ "r4", 0x04, 0xff }, -{ "r5", 0x05, 0xff }, -{ "r6", 0x06, 0xff }, -{ "r7", 0x07, 0xff }, -{ 0 , 0x00, 0xff } + { "r0", 0x00, 0xff }, + { "r1", 0x01, 0xff }, + { "r2", 0x02, 0xff }, + { "r3", 0x03, 0xff }, + { "r4", 0x04, 0xff }, + { "r5", 0x05, 0xff }, + { "r6", 0x06, 0xff }, + { "r7", 0x07, 0xff }, + { 0 , 0x00, 0xff } }; #if !defined(NS32032) && !defined(NS32532) #define NS32032 #endif - - struct option cpureg_532[]= /* lpr spr */ + +struct option cpureg_532[]= /* lpr spr */ { -{ "us", 0x0, 0xff }, -{ "dcr", 0x1, 0xff }, -{ "bpc", 0x2, 0xff }, -{ "dsr", 0x3, 0xff }, -{ "car", 0x4, 0xff }, -{ "fp", 0x8, 0xff }, -{ "sp", 0x9, 0xff }, -{ "sb", 0xa, 0xff }, -{ "usp", 0xb, 0xff }, -{ "cfg", 0xc, 0xff }, -{ "psr", 0xd, 0xff }, -{ "intbase", 0xe, 0xff }, -{ "mod", 0xf, 0xff }, -{ 0 , 0x00, 0xff } + { "us", 0x0, 0xff }, + { "dcr", 0x1, 0xff }, + { "bpc", 0x2, 0xff }, + { "dsr", 0x3, 0xff }, + { "car", 0x4, 0xff }, + { "fp", 0x8, 0xff }, + { "sp", 0x9, 0xff }, + { "sb", 0xa, 0xff }, + { "usp", 0xb, 0xff }, + { "cfg", 0xc, 0xff }, + { "psr", 0xd, 0xff }, + { "intbase", 0xe, 0xff }, + { "mod", 0xf, 0xff }, + { 0 , 0x00, 0xff } }; struct option mmureg_532[]= /* lmr smr */ { -{ "mcr", 0x9, 0xff }, -{ "msr", 0xa, 0xff }, -{ "tear", 0xb, 0xff }, -{ "ptb0", 0xc, 0xff }, -{ "ptb1", 0xd, 0xff }, -{ "ivar0", 0xe, 0xff }, -{ "ivar1", 0xf, 0xff }, -{ 0 , 0x0, 0xff } + { "mcr", 0x9, 0xff }, + { "msr", 0xa, 0xff }, + { "tear", 0xb, 0xff }, + { "ptb0", 0xc, 0xff }, + { "ptb1", 0xd, 0xff }, + { "ivar0", 0xe, 0xff }, + { "ivar1", 0xf, 0xff }, + { 0 , 0x0, 0xff } }; struct option cpureg_032[]= /* lpr spr */ { -{ "upsr", 0x0, 0xff }, -{ "fp", 0x8, 0xff }, -{ "sp", 0x9, 0xff }, -{ "sb", 0xa, 0xff }, -{ "psr", 0xd, 0xff }, -{ "intbase", 0xe, 0xff }, -{ "mod", 0xf, 0xff }, -{ 0 , 0x0, 0xff } + { "upsr", 0x0, 0xff }, + { "fp", 0x8, 0xff }, + { "sp", 0x9, 0xff }, + { "sb", 0xa, 0xff }, + { "psr", 0xd, 0xff }, + { "intbase", 0xe, 0xff }, + { "mod", 0xf, 0xff }, + { 0 , 0x0, 0xff } }; struct option mmureg_032[]= /* lmr smr */ { -{ "bpr0", 0x0, 0xff }, -{ "bpr1", 0x1, 0xff }, -{ "pf0", 0x4, 0xff }, -{ "pf1", 0x5, 0xff }, -{ "sc", 0x8, 0xff }, -{ "msr", 0xa, 0xff }, -{ "bcnt", 0xb, 0xff }, -{ "ptb0", 0xc, 0xff }, -{ "ptb1", 0xd, 0xff }, -{ "eia", 0xf, 0xff }, -{ 0 , 0x0, 0xff } + { "bpr0", 0x0, 0xff }, + { "bpr1", 0x1, 0xff }, + { "pf0", 0x4, 0xff }, + { "pf1", 0x5, 0xff }, + { "sc", 0x8, 0xff }, + { "msr", 0xa, 0xff }, + { "bcnt", 0xb, 0xff }, + { "ptb0", 0xc, 0xff }, + { "ptb1", 0xd, 0xff }, + { "eia", 0xf, 0xff }, + { 0 , 0x0, 0xff } }; #if defined(NS32532) - struct option *cpureg = cpureg_532; +struct option *cpureg = cpureg_532; struct option *mmureg = mmureg_532; #else struct option *cpureg = cpureg_032; @@ -301,57 +304,57 @@ struct option *mmureg = mmureg_032; const pseudo_typeS md_pseudo_table[]={ /* so far empty */ -{ 0, 0, 0 } + { 0, 0, 0 } }; #define IND(x,y) (((x)<<2)+(y)) - - /* those are index's to relax groups in md_relax_table - ie it must be multiplied by 4 to point at a group start. Viz IND(x,y) - Se function relax_segment in write.c for more info */ - + +/* those are index's to relax groups in md_relax_table + ie it must be multiplied by 4 to point at a group start. Viz IND(x,y) + Se function relax_segment in write.c for more info */ + #define BRANCH 1 #define PCREL 2 - - /* those are index's to entries in a relax group */ - + +/* those are index's to entries in a relax group */ + #define BYTE 0 #define WORD 1 #define DOUBLE 2 #define UNDEF 3 - /* Those limits are calculated from the displacement start in memory. - The ns32k uses the begining of the instruction as displacement base. - This type of displacements could be handled here by moving the limit window - up or down. I choose to use an internal displacement base-adjust as there - are other routines that must consider this. Also, as we have two various - offset-adjusts in the ns32k (acb versus br/brs/jsr/bcond), two set of limits - would have had to be used. - Now we dont have to think about that. */ - - - const relax_typeS md_relax_table[]={ -{ 1, 1, 0, 0 }, -{ 1, 1, 0, 0 }, -{ 1, 1, 0, 0 }, -{ 1, 1, 0, 0 }, - -{ (63), (-64), 1, IND(BRANCH,WORD) }, -{ (8192), (-8192), 2, IND(BRANCH,DOUBLE) }, -{ 0, 0, 4, 0 }, -{ 1, 1, 0, 0 } +/* Those limits are calculated from the displacement start in memory. + The ns32k uses the begining of the instruction as displacement base. + This type of displacements could be handled here by moving the limit window + up or down. I choose to use an internal displacement base-adjust as there + are other routines that must consider this. Also, as we have two various + offset-adjusts in the ns32k (acb versus br/brs/jsr/bcond), two set of limits + would have had to be used. + Now we dont have to think about that. */ + + +const relax_typeS md_relax_table[] = { + { 1, 1, 0, 0 }, + { 1, 1, 0, 0 }, + { 1, 1, 0, 0 }, + { 1, 1, 0, 0 }, + + { (63), (-64), 1, IND(BRANCH,WORD) }, + { (8192), (-8192), 2, IND(BRANCH,DOUBLE) }, + { 0, 0, 4, 0 }, + { 1, 1, 0, 0 } }; /* Array used to test if mode contains displacements. Value is true if mode contains displacement. */ -char disp_test[]={ 0,0,0,0,0,0,0,0, - 1,1,1,1,1,1,1,1, - 1,1,1,0,0,1,1,0, - 1,1,1,1,1,1,1,1 }; +char disp_test[] = { 0,0,0,0,0,0,0,0, + 1,1,1,1,1,1,1,1, + 1,1,1,0,0,1,1,0, + 1,1,1,1,1,1,1,1 }; /* Array used to calculate max size of displacements */ -char disp_size[]={ 4,1,2,0,4 }; +char disp_size[] = { 4,1,2,0,4 }; #if __STDC__ == 1 @@ -377,201 +380,201 @@ static void md_number_to_imm(); out: data in addr_mode struct */ int addr_mode(operand,addr_modeP,recursive_level) - char *operand; - register addr_modeS *addr_modeP; - int recursive_level; +char *operand; +register addr_modeS *addr_modeP; +int recursive_level; { - register char *str; - register int i; - register int strl; - register int mode; - int j; - mode = DEFAULT; /* default */ - addr_modeP->scaled_mode=0; /* why not */ - addr_modeP->scaled_reg=0; /* if 0, not scaled index */ - addr_modeP->float_flag=0; - addr_modeP->am_size=0; - addr_modeP->im_disp=0; - addr_modeP->pcrel=0; /* not set in this function */ - addr_modeP->disp_suffix[0]=0; - addr_modeP->disp_suffix[1]=0; - addr_modeP->disp[0]=NULL; - addr_modeP->disp[1]=NULL; - str=operand; - if (str[0]==0) {return (0);} /* we don't want this */ - strl=strlen(str); - switch (str[0]) { - /* the following three case statements controls the mode-chars - this is the place to ed if you want to change them */ + register char *str; + register int i; + register int strl; + register int mode; + int j; + mode = DEFAULT; /* default */ + addr_modeP->scaled_mode=0; /* why not */ + addr_modeP->scaled_reg=0; /* if 0, not scaled index */ + addr_modeP->float_flag=0; + addr_modeP->am_size=0; + addr_modeP->im_disp=0; + addr_modeP->pcrel=0; /* not set in this function */ + addr_modeP->disp_suffix[0]=0; + addr_modeP->disp_suffix[1]=0; + addr_modeP->disp[0]=NULL; + addr_modeP->disp[1]=NULL; + str=operand; + if (str[0]==0) {return (0);} /* we don't want this */ + strl=strlen(str); + switch (str[0]) { + /* the following three case statements controls the mode-chars + this is the place to ed if you want to change them */ #ifdef ABSOLUTE_PREFIX - case ABSOLUTE_PREFIX: - if (str[strl-1]==']') break; - addr_modeP->mode=21; /* absolute */ - addr_modeP->disp[0]=str+1; - return (-1); + case ABSOLUTE_PREFIX: + if (str[strl-1]==']') break; + addr_modeP->mode=21; /* absolute */ + addr_modeP->disp[0]=str+1; + return (-1); #endif #ifdef IMMEDIATE_PREFIX - case IMMEDIATE_PREFIX: - if (str[strl-1]==']') break; - addr_modeP->mode=20; /* immediate */ - addr_modeP->disp[0]=str+1; - return (-1); + case IMMEDIATE_PREFIX: + if (str[strl-1]==']') break; + addr_modeP->mode=20; /* immediate */ + addr_modeP->disp[0]=str+1; + return (-1); #endif - case '.': - if (str[strl-1]!=']') { - switch (str[1]) { - case'-':case'+': - if (str[2]!='\000') { - addr_modeP->mode=27; /* pc-relativ */ - addr_modeP->disp[0]=str+2; - return (-1); + case '.': + if (str[strl-1]!=']') { + switch (str[1]) { + case'-':case'+': + if (str[2]!='\000') { + addr_modeP->mode=27; /* pc-relativ */ + addr_modeP->disp[0]=str+2; + return (-1); + } + default: + as_warn("Invalid syntax in PC-relative addressing mode"); + return(0); + } } - default: - as_warn("Invalid syntax in PC-relative addressing mode"); - return(0); - } - } - break; - case'e': - if (str[strl-1]!=']') { - if((!strncmp(str,"ext(",4)) && strl>7) { /* external */ - addr_modeP->disp[0]=str+4; - i=0; - j=2; - do { /* disp[0]'s termination point */ - j+=1; - if (str[j]=='(') i++; - if (str[j]==')') i--; - } while (j7) { /* external */ + addr_modeP->disp[0]=str+4; + i=0; + j=2; + do { /* disp[0]'s termination point */ + j+=1; + if (str[j]=='(') i++; + if (str[j]==')') i--; + } while (jdisp[1]=str+j+2; + addr_modeP->mode=22; + return (-1); + } } - str[j]='\000'; /* null terminate disp[0] */ - addr_modeP->disp[1]=str+j+2; - addr_modeP->mode=22; - return (-1); - } - } - break; - default:; - } - strl=strlen(str); - switch(strl) { - case 2: - switch (str[0]) { - case'f':addr_modeP->float_flag=1; - case'r': - if (str[1]>='0' && str[1]<'8') { - addr_modeP->mode=str[1]-'0'; - return (-1); - } - } - case 3: - if (!strncmp(str,"tos",3)) { - addr_modeP->mode=23; /* TopOfStack */ - return (-1); + break; + default:; } - default:; - } - if (strl>4) { - if (str[strl-1]==')') { - if (str[strl-2]==')') { - if (!strncmp(&str[strl-5],"(fp",3)) { - mode=16; /* Memory Relative */ - } - if (!strncmp(&str[strl-5],"(sp",3)) { - mode=17; - } - if (!strncmp(&str[strl-5],"(sb",3)) { - mode=18; - } - if (mode!=DEFAULT) { /* memory relative */ - addr_modeP->mode=mode; - j=strl-5; /* temp for end of disp[0] */ - i=0; - do { - strl-=1; - if (str[strl]==')') i++; - if (str[strl]=='(') i--; - } while (strl>-1 && i!=0); - if (i!=0) { - as_warn("Invalid syntax in Memory Relative addressing mode"); - return(0); - } - addr_modeP->disp[1]=str; - addr_modeP->disp[0]=str+strl+1; - str[j]='\000'; /* null terminate disp[0] */ - str[strl]='\000'; /* null terminate disp[1] */ - return (-1); - } - } - switch (str[strl-3]) { - case'r':case'R': - if (str[strl-2]>='0' && str[strl-2]<'8' && str[strl-4]=='(') { - addr_modeP->mode=str[strl-2]-'0'+8; - addr_modeP->disp[0]=str; - str[strl-4]=0; - return (-1); /* reg rel */ - } - default: - if (!strncmp(&str[strl-4],"(fp",3)) { - mode=24; - } - if (!strncmp(&str[strl-4],"(sp",3)) { - mode=25; - } - if (!strncmp(&str[strl-4],"(sb",3)) { - mode=26; - } - if (!strncmp(&str[strl-4],"(pc",3)) { - mode=27; + strl=strlen(str); + switch(strl) { + case 2: + switch (str[0]) { + case'f':addr_modeP->float_flag=1; + case'r': + if (str[1]>='0' && str[1]<'8') { + addr_modeP->mode=str[1]-'0'; + return (-1); + } } - if (mode!=DEFAULT) { - addr_modeP->mode=mode; - addr_modeP->disp[0]=str; - str[strl-4]='\0'; - return (-1); /* memory space */ + case 3: + if (!strncmp(str,"tos",3)) { + addr_modeP->mode=23; /* TopOfStack */ + return (-1); } - } + default:; } - /* no trailing ')' do we have a ']' ? */ - if (str[strl-1]==']') { - switch (str[strl-2]) { - case'b':mode=28;break; - case'w':mode=29;break; - case'd':mode=30;break; - case'q':mode=31;break; - default:; - as_warn("Invalid scaled-indexed mode, use (b,w,d,q)"); - if (str[strl-3]!=':' || str[strl-6]!='[' || - str[strl-5]=='r' || str[strl-4]<'0' || str[strl-4]>'7') { - as_warn("Syntax in scaled-indexed mode, use [Rn:m] where n=[0..7] m={b,w,d,q}"); + if (strl>4) { + if (str[strl-1]==')') { + if (str[strl-2]==')') { + if (!strncmp(&str[strl-5],"(fp",3)) { + mode=16; /* Memory Relative */ + } + if (!strncmp(&str[strl-5],"(sp",3)) { + mode=17; + } + if (!strncmp(&str[strl-5],"(sb",3)) { + mode=18; + } + if (mode!=DEFAULT) { /* memory relative */ + addr_modeP->mode=mode; + j=strl-5; /* temp for end of disp[0] */ + i=0; + do { + strl-=1; + if (str[strl]==')') i++; + if (str[strl]=='(') i--; + } while (strl>-1 && i!=0); + if (i!=0) { + as_warn("Invalid syntax in Memory Relative addressing mode"); + return(0); + } + addr_modeP->disp[1]=str; + addr_modeP->disp[0]=str+strl+1; + str[j]='\000'; /* null terminate disp[0] */ + str[strl]='\000'; /* null terminate disp[1] */ + return (-1); + } + } + switch (str[strl-3]) { + case'r':case'R': + if (str[strl-2]>='0' && str[strl-2]<'8' && str[strl-4]=='(') { + addr_modeP->mode=str[strl-2]-'0'+8; + addr_modeP->disp[0]=str; + str[strl-4]=0; + return (-1); /* reg rel */ + } + default: + if (!strncmp(&str[strl-4],"(fp",3)) { + mode=24; + } + if (!strncmp(&str[strl-4],"(sp",3)) { + mode=25; + } + if (!strncmp(&str[strl-4],"(sb",3)) { + mode=26; + } + if (!strncmp(&str[strl-4],"(pc",3)) { + mode=27; + } + if (mode!=DEFAULT) { + addr_modeP->mode=mode; + addr_modeP->disp[0]=str; + str[strl-4]='\0'; + return (-1); /* memory space */ + } + } + } + /* no trailing ')' do we have a ']' ? */ + if (str[strl-1]==']') { + switch (str[strl-2]) { + case'b':mode=28;break; + case'w':mode=29;break; + case'd':mode=30;break; + case'q':mode=31;break; + default:; + as_warn("Invalid scaled-indexed mode, use (b,w,d,q)"); + if (str[strl-3]!=':' || str[strl-6]!='[' || + str[strl-5]=='r' || str[strl-4]<'0' || str[strl-4]>'7') { + as_warn("Syntax in scaled-indexed mode, use [Rn:m] where n=[0..7] m={b,w,d,q}"); + } + } /* scaled index */ + { + if (recursive_level>0) { + as_warn("Scaled-indexed addressing mode combined with scaled-index"); + return(0); + } + addr_modeP->am_size+=1; /* scaled index byte */ + j=str[strl-4]-'0'; /* store temporary */ + str[strl-6]='\000'; /* nullterminate for recursive call */ + i=addr_mode(str,addr_modeP,1); + if (!i || addr_modeP->mode==20) { + as_warn("Invalid or illegal addressing mode combined with scaled-index"); + return(0); + } + addr_modeP->scaled_mode=addr_modeP->mode; /* store the inferior mode */ + addr_modeP->mode=mode; + addr_modeP->scaled_reg=j+1; + return (-1); + } } - } /* scaled index */ - { - if (recursive_level>0) { - as_warn("Scaled-indexed addressing mode combined with scaled-index"); - return(0); - } - addr_modeP->am_size+=1; /* scaled index byte */ - j=str[strl-4]-'0'; /* store temporary */ - str[strl-6]='\000'; /* nullterminate for recursive call */ - i=addr_mode(str,addr_modeP,1); - if (!i || addr_modeP->mode==20) { - as_warn("Invalid or illegal addressing mode combined with scaled-index"); - return(0); - } - addr_modeP->scaled_mode=addr_modeP->mode; /* store the inferior mode */ - addr_modeP->mode=mode; - addr_modeP->scaled_reg=j+1; - return (-1); - } } - } - addr_modeP->mode = DEFAULT; /* default to whatever */ - addr_modeP->disp[0]=str; - return (-1); + addr_modeP->mode = DEFAULT; /* default to whatever */ + addr_modeP->disp[0]=str; + return (-1); } /* ptr points at string @@ -582,127 +585,127 @@ int addr_mode(operand,addr_modeP,recursive_level) Also builds index bytes if needed. */ int get_addr_mode(ptr,addr_modeP) - char *ptr; - addr_modeS *addr_modeP; +char *ptr; +addr_modeS *addr_modeP; { - int tmp; - addr_mode(ptr,addr_modeP,0); - if (addr_modeP->mode == DEFAULT || addr_modeP->scaled_mode == -1) { - /* resolve ambigious operands, this shouldn't - be necessary if one uses standard NSC operand - syntax. But the sequent compiler doesn't!!! - This finds a proper addressinging mode if it - is implicitly stated. See ns32k-opcode.h */ - (void)evaluate_expr(&exprP,ptr); /* this call takes time Sigh! */ - if (addr_modeP->mode == DEFAULT) { - if (exprP.X_add_symbol || exprP.X_subtract_symbol) { - addr_modeP->mode=desc->default_model; /* we have a label */ - } else { - addr_modeP->mode=desc->default_modec; /* we have a constant */ - } - } else { - if (exprP.X_add_symbol || exprP.X_subtract_symbol) { - addr_modeP->scaled_mode=desc->default_model; - } else { - addr_modeP->scaled_mode=desc->default_modec; - } + int tmp; + addr_mode(ptr,addr_modeP,0); + if (addr_modeP->mode == DEFAULT || addr_modeP->scaled_mode == -1) { + /* resolve ambigious operands, this shouldn't + be necessary if one uses standard NSC operand + syntax. But the sequent compiler doesn't!!! + This finds a proper addressinging mode if it + is implicitly stated. See ns32k-opcode.h */ + (void)evaluate_expr(&exprP,ptr); /* this call takes time Sigh! */ + if (addr_modeP->mode == DEFAULT) { + if (exprP.X_add_symbol || exprP.X_subtract_symbol) { + addr_modeP->mode=desc->default_model; /* we have a label */ + } else { + addr_modeP->mode=desc->default_modec; /* we have a constant */ + } + } else { + if (exprP.X_add_symbol || exprP.X_subtract_symbol) { + addr_modeP->scaled_mode=desc->default_model; + } else { + addr_modeP->scaled_mode=desc->default_modec; + } + } + /* must put this mess down in addr_mode to handle the scaled case better */ } - /* must put this mess down in addr_mode to handle the scaled case better */ - } - /* It appears as the sequent compiler wants an absolute when we have a - label without @. Constants becomes immediates besides the addr case. - Think it does so with local labels too, not optimum, pcrel is better. - When I have time I will make gas check this and select pcrel when possible - Actually that is trivial. - */ - if (tmp=addr_modeP->scaled_reg) { /* build indexbyte */ - tmp--; /* remember regnumber comes incremented for flagpurpose */ - tmp|=addr_modeP->scaled_mode<<3; - addr_modeP->index_byte=(char)tmp; - addr_modeP->am_size+=1; - } - if (disp_test[addr_modeP->mode]) { /* there was a displacement, probe for length specifying suffix*/ - { - register char c; - register char suffix; - register char suffix_sub; - register int i; - register char *toP; - register char *fromP; - - addr_modeP->pcrel=0; - if (disp_test[addr_modeP->mode]) { /* there is a displacement */ - if (addr_modeP->mode==27 || addr_modeP->scaled_mode==27) { /* do we have pcrel. mode */ - addr_modeP->pcrel=1; - } - addr_modeP->im_disp=1; - for(i=0;i<2;i++) { - suffix_sub=suffix=0; - if (toP=addr_modeP->disp[i]) { /* suffix of expression, the largest size rules */ - fromP=toP; - while (c = *fromP++) { - *toP++=c; - if (c==':') { - switch (*fromP) { - case '\0': - as_warn("Premature end of suffix--Defaulting to d"); - suffix=4; - continue; - case 'b':suffix_sub=1;break; - case 'w':suffix_sub=2;break; - case 'd':suffix_sub=4;break; - default: - as_warn("Bad suffix after ':' use {b|w|d} Defaulting to d"); - suffix=4; - } - fromP++; - toP--; /* So we write over the ':' */ - if (suffixscaled_reg) { /* build indexbyte */ + tmp--; /* remember regnumber comes incremented for flagpurpose */ + tmp|=addr_modeP->scaled_mode<<3; + addr_modeP->index_byte=(char)tmp; + addr_modeP->am_size+=1; + } + if (disp_test[addr_modeP->mode]) { /* there was a displacement, probe for length specifying suffix*/ + { + register char c; + register char suffix; + register char suffix_sub; + register int i; + register char *toP; + register char *fromP; + + addr_modeP->pcrel=0; + if (disp_test[addr_modeP->mode]) { /* there is a displacement */ + if (addr_modeP->mode==27 || addr_modeP->scaled_mode==27) { /* do we have pcrel. mode */ + addr_modeP->pcrel=1; + } + addr_modeP->im_disp=1; + for(i=0;i<2;i++) { + suffix_sub=suffix=0; + if (toP=addr_modeP->disp[i]) { /* suffix of expression, the largest size rules */ + fromP=toP; + while (c = *fromP++) { + *toP++=c; + if (c==':') { + switch (*fromP) { + case '\0': + as_warn("Premature end of suffix--Defaulting to d"); + suffix=4; + continue; + case 'b':suffix_sub=1;break; + case 'w':suffix_sub=2;break; + case 'd':suffix_sub=4;break; + default: + as_warn("Bad suffix after ':' use {b|w|d} Defaulting to d"); + suffix=4; + } + fromP++; + toP--; /* So we write over the ':' */ + if (suffixdisp_suffix[i]=suffix; + addr_modeP->am_size+=suffix ? suffix : 4; + } + } } - } - *toP='\0'; /* terminate properly */ - addr_modeP->disp_suffix[i]=suffix; - addr_modeP->am_size+=suffix ? suffix : 4; } - } + } else { + if (addr_modeP->mode==20) { /* look in ns32k_opcode for size */ + addr_modeP->disp_suffix[0]=addr_modeP->am_size=desc->im_size; + addr_modeP->im_disp=0; + } } - } -} else { - if (addr_modeP->mode==20) { /* look in ns32k_opcode for size */ - addr_modeP->disp_suffix[0]=addr_modeP->am_size=desc->im_size; - addr_modeP->im_disp=0; - } -} - return addr_modeP->mode; + return addr_modeP->mode; } /* read an optionlist */ void optlist(str,optionP,default_map) - char *str; /* the string to extract options from */ - struct option *optionP; /* how to search the string */ - unsigned long *default_map; /* default pattern and output */ +char *str; /* the string to extract options from */ +struct option *optionP; /* how to search the string */ +unsigned long *default_map; /* default pattern and output */ { - register int i,j,k,strlen1,strlen2; - register char *patternP,*strP; - strlen1=strlen(str); - if (strlen1<1) { - as_fatal("Very short instr to option, ie you can't do it on a NULLstr"); - } - for (i=0;optionP[i].pattern!=0;i++) { - strlen2=strlen(optionP[i].pattern); - for (j=0;j3) as_fatal("Internal consistency error. check ns32k-opcode.h"); - pcrel=0; - pcrel_adjust=0; - tmp=0; - switch (operandsP[(loop<<1)+1]) { - case 'f': /* operand of sfsr turns out to be a nasty specialcase */ - opcode_bit_ptr-=5; - case 'F': /* 32 bit float general form */ - case 'L': /* 64 bit float */ - case 'Q': /* quad-word */ - case 'B': /* byte */ - case 'W': /* word */ - case 'D': /* double-word */ - case 'A': /* double-word gen-address-form ie no regs allowed */ - get_addr_mode(argv[i],&addr_modeP); - iif.instr_size+=addr_modeP.am_size; - if (opcode_bit_ptr==desc->opcode_size) b=4; else b=6; - for (j=b;j<(b+2);j++) { - if (addr_modeP.disp[j-b]) { - IIF(j, - 2, - addr_modeP.disp_suffix[j-b], - (unsigned long)addr_modeP.disp[j-b], - 0, - addr_modeP.pcrel, - iif.instr_size-addr_modeP.am_size, /* this aint used (now) */ - addr_modeP.im_disp, - IND(BRANCH,BYTE), - NULL, - addr_modeP.scaled_reg ? addr_modeP.scaled_mode:addr_modeP.mode, - 0); + register int i,j; + int pcrel,tmp,b,loop,pcrel_adjust; + for(loop=0;loop3) as_fatal("Internal consistency error. check ns32k-opcode.h"); + pcrel=0; + pcrel_adjust=0; + tmp=0; + switch (operandsP[(loop<<1)+1]) { + case 'f': /* operand of sfsr turns out to be a nasty specialcase */ + opcode_bit_ptr-=5; + case 'F': /* 32 bit float general form */ + case 'L': /* 64 bit float */ + case 'Q': /* quad-word */ + case 'B': /* byte */ + case 'W': /* word */ + case 'D': /* double-word */ + case 'A': /* double-word gen-address-form ie no regs allowed */ + get_addr_mode(argv[i],&addr_modeP); + iif.instr_size+=addr_modeP.am_size; + if (opcode_bit_ptr==desc->opcode_size) b=4; else b=6; + for (j=b;j<(b+2);j++) { + if (addr_modeP.disp[j-b]) { + IIF(j, + 2, + addr_modeP.disp_suffix[j-b], + (unsigned long)addr_modeP.disp[j-b], + 0, + addr_modeP.pcrel, + iif.instr_size-addr_modeP.am_size, /* this aint used (now) */ + addr_modeP.im_disp, + IND(BRANCH,BYTE), + NULL, + addr_modeP.scaled_reg ? addr_modeP.scaled_mode:addr_modeP.mode, + 0); + } + } + opcode_bit_ptr-=5; + iif.iifP[1].object|=((long)addr_modeP.mode)<im_size); + argv[i]=freeptr; + freeptr=(char*)tmp; + pcrel-=1; /* make pcrel 0 inspite of what case 'p': wants */ + /* fall thru */ + case 'p': /* displacement - pc relative addressing */ + pcrel+=1; + /* fall thru */ + case 'd': /* displacement */ + iif.instr_size+=suffixP[i] ? suffixP[i] : 4; + IIF(12, 2, suffixP[i], (unsigned long)argv[i], 0, + pcrel, pcrel_adjust, 1, IND(BRANCH,BYTE), NULL,-1,0); + break; + case 'H': /* sequent-hack: the linker wants a bit set when bsr */ + pcrel=1; + iif.instr_size+=suffixP[i] ? suffixP[i] : 4; + IIF(12, 2, suffixP[i], (unsigned long)argv[i], 0, + pcrel, pcrel_adjust, 1, IND(BRANCH,BYTE), NULL,-1,1);break; + case 'q': /* quick */ + opcode_bit_ptr-=4; + IIF(11,2,42,(unsigned long)argv[i],0,0,0,0,0, + bit_fix_new(4,opcode_bit_ptr,-8,7,0,1,0),-1,0); + break; + case 'r': /* register number (3 bits) */ + list_search(argv[i],opt6,&tmp); + opcode_bit_ptr-=3; + iif.iifP[1].object|=tmp<im_size); - argv[i]=freeptr; - freeptr=(char*)tmp; - pcrel-=1; /* make pcrel 0 inspite of what case 'p': wants */ - /* fall thru */ - case 'p': /* displacement - pc relative addressing */ - pcrel+=1; - /* fall thru */ - case 'd': /* displacement */ - iif.instr_size+=suffixP[i] ? suffixP[i] : 4; - IIF(12, 2, suffixP[i], (unsigned long)argv[i], 0, - pcrel, pcrel_adjust, 1, IND(BRANCH,BYTE), NULL,-1,0); - break; - case 'H': /* sequent-hack: the linker wants a bit set when bsr */ - pcrel=1; - iif.instr_size+=suffixP[i] ? suffixP[i] : 4; - IIF(12, 2, suffixP[i], (unsigned long)argv[i], 0, - pcrel, pcrel_adjust, 1, IND(BRANCH,BYTE), NULL,-1,1);break; - case 'q': /* quick */ - opcode_bit_ptr-=4; - IIF(11,2,42,(unsigned long)argv[i],0,0,0,0,0, - bit_fix_new(4,opcode_bit_ptr,-8,7,0,1,0),-1,0); - break; - case 'r': /* register number (3 bits) */ - list_search(argv[i],opt6,&tmp); - opcode_bit_ptr-=3; - iif.iifP[1].object|=tmp<operands) { - if (*lineptr++!='\0') { - sqr='['; - sep=','; - while (*lineptr!='\0') { - if (desc->operands[argc<<1]) { - suffix[argc]=0; - arg_type=desc->operands[(argc<<1)+1]; - switch (arg_type) { - case 'd': case 'b': case 'p': case 'H': /* the operand is supposed to be a displacement */ - /* Hackwarning: do not forget to update the 4 cases above when editing ns32k-opcode.h */ - suffix_separator=':'; - break; - default: - suffix_separator='\255'; /* if this char occurs we loose */ - } - suffix[argc]=0; /* 0 when no ':' is encountered */ - argv[argc]=freeptr; - *freeptr='\0'; - while ((c = *lineptr)!='\0' && c!=sep) { - if (c==sqr) { - if (sqr=='[') { - sqr=']';sep='\0'; - } else { - sqr='[';sep=','; - } - } - if (c==suffix_separator) { /* ':' - label/suffix separator */ - switch (lineptr[1]) { - case 'b':suffix[argc]=1;break; - case 'w':suffix[argc]=2;break; - case 'd':suffix[argc]=4;break; - default: as_warn("Bad suffix, defaulting to d"); - suffix[argc]=4; - if (lineptr[1]=='\0' || lineptr[1]==sep) { - lineptr+=1; - continue; + argc=0; + if (*desc->operands) { + if (*lineptr++!='\0') { + sqr='['; + sep=','; + while (*lineptr!='\0') { + if (desc->operands[argc<<1]) { + suffix[argc]=0; + arg_type=desc->operands[(argc<<1)+1]; + switch (arg_type) { + case 'd': case 'b': case 'p': case 'H': /* the operand is supposed to be a displacement */ + /* Hackwarning: do not forget to update the 4 cases above when editing ns32k-opcode.h */ + suffix_separator=':'; + break; + default: + suffix_separator='\255'; /* if this char occurs we loose */ + } + suffix[argc]=0; /* 0 when no ':' is encountered */ + argv[argc]=freeptr; + *freeptr='\0'; + while ((c = *lineptr)!='\0' && c!=sep) { + if (c==sqr) { + if (sqr=='[') { + sqr=']';sep='\0'; + } else { + sqr='[';sep=','; + } + } + if (c==suffix_separator) { /* ':' - label/suffix separator */ + switch (lineptr[1]) { + case 'b':suffix[argc]=1;break; + case 'w':suffix[argc]=2;break; + case 'd':suffix[argc]=4;break; + default: as_warn("Bad suffix, defaulting to d"); + suffix[argc]=4; + if (lineptr[1]=='\0' || lineptr[1]==sep) { + lineptr+=1; + continue; + } + } + lineptr+=2; + continue; + } + *freeptr++=c; + lineptr++; + } + *freeptr++='\0'; + argc+=1; + if (*lineptr=='\0') continue; + lineptr+=1; + } else { + as_fatal("Too many operands passed to instruction"); } - } - lineptr+=2; - continue; } - *freeptr++=c; - lineptr++; - } - *freeptr++='\0'; - argc+=1; - if (*lineptr=='\0') continue; - lineptr+=1; + } + } + if (argc!=strlen(desc->operands)/2) { + if (strlen(desc->default_args)) { /* we can apply default, dont goof */ + if (parse(desc->default_args,1)!=1) { /* check error in default */ + as_fatal("Wrong numbers of operands in default, check ns32k-opcodes.h"); + } } else { - as_fatal("Too many operands passed to instruction"); + as_fatal("Wrong number of operands"); } - } + } - } - if (argc!=strlen(desc->operands)/2) { - if (strlen(desc->default_args)) { /* we can apply default, dont goof */ - if (parse(desc->default_args,1)!=1) { /* check error in default */ - as_fatal("Wrong numbers of operands in default, check ns32k-opcodes.h"); - } - } else { - as_fatal("Wrong number of operands"); + for (i=0;iopcode_size/8; - IIF(1,1,iif.instr_size,desc->opcode_seed,0,0,0,0,0,0,-1,0); - - /* this call encodes operands to iif format */ - if (argc) { - encode_operand(argc, - argv, - &desc->operands[0], - &suffix[0], - desc->im_size, - desc->opcode_size); - } - return recursive_level; + /* build opcode iif-entry */ + iif.instr_size=desc->opcode_size/8; + IIF(1,1,iif.instr_size,desc->opcode_seed,0,0,0,0,0,0,-1,0); + + /* this call encodes operands to iif format */ + if (argc) { + encode_operand(argc, + argv, + &desc->operands[0], + &suffix[0], + desc->im_size, + desc->opcode_size); + } + return recursive_level; } @@ -1011,254 +1016,257 @@ int parse(line,recursive_level) Note that iif was invented for the clean ns32k`s architecure. */ void convert_iif() { - register int i,j; - fragS *inst_frag; - char *inst_offset,*inst_opcode; - char *memP; - segT segment; - int l,k; - register int rem_size; /* count the remaining bytes of instruction */ - register char type; - register char size = 0; - int size_so_far=0; /* used to calculate pcrel_adjust */ - - rem_size=iif.instr_size; - memP=frag_more(iif.instr_size); /* make sure we have enough bytes for instruction */ - inst_opcode=memP; - inst_offset=(char*)(memP-frag_now->fr_literal); - inst_frag=frag_now; - for (i=0;ifx_bit_base) { /* expand fx_bit_base to point at opcode */ - iif.iifP[i].bit_fixP->fx_bit_base=(long)inst_opcode; - } - case 8: /* bignum or doublefloat */ - bzero (memP,8); - case 1:case 2:case 3:case 4:/* the final size in objectmemory is known */ - j=(unsigned long)iif.iifP[i].bit_fixP; - switch (type) { - case 1: /* the object is pure binary */ - if (j || iif.iifP[i].pcrel) { - fix_new_ns32k(frag_now, - (long)(memP-frag_now->fr_literal), - size, - 0, - 0, - iif.iifP[i].object, - iif.iifP[i].pcrel, - (char)size_so_far, /*iif.iifP[i].pcrel_adjust,*/ - iif.iifP[i].im_disp, - j, - iif.iifP[i].bsr); /* sequent hack */ - } else { /* good, just put them bytes out */ - switch (iif.iifP[i].im_disp) { - case 0: - md_number_to_chars(memP,iif.iifP[i].object,size);break; - case 1: - md_number_to_disp(memP,iif.iifP[i].object,size);break; - default: as_fatal("iif convert internal pcrel/binary"); - } - } - memP+=size; - rem_size-=size; - break; - case 2: /* the object is a pointer at an expression, so unpack - it, note that bignums may result from the expression - */ - if ((segment=evaluate_expr(&exprP,(char*)iif.iifP[i].object))==SEG_BIG || size==8) { - if ((k=exprP.X_add_number)>0) { /* we have a bignum ie a quad */ - /* this can only happens in a long suffixed instruction */ - bzero(memP,size); /* size normally is 8 */ - if (k*2>size) as_warn("Bignum too big for long"); - if (k==3) memP+=2; - for (l=0;k>0;k--,l+=2) { - md_number_to_chars(memP+l,generic_bignum[l>>1],sizeof(LITTLENUM_TYPE)); - } - } else { /* flonum */ - LITTLENUM_TYPE words[4]; - - switch(size) { - case 4: - gen_to_words(words,2,8); - md_number_to_imm(memP ,(long)words[0],sizeof(LITTLENUM_TYPE)); - md_number_to_imm(memP+sizeof(LITTLENUM_TYPE),(long)words[1],sizeof(LITTLENUM_TYPE)); + int i; + int j; + fragS *inst_frag; + char *inst_offset; + char **inst_opcode; + char *memP; + segT segment; + int l; + int k; + int rem_size; /* count the remaining bytes of instruction */ + char type; + char size = 0; + int size_so_far = 0; /* used to calculate pcrel_adjust */ + + rem_size=iif.instr_size; + memP=frag_more(iif.instr_size); /* make sure we have enough bytes for instruction */ + inst_opcode=memP; + inst_offset=(char*)(memP-frag_now->fr_literal); + inst_frag=frag_now; + for (i=0;ifx_bit_base) { /* expand fx_bit_base to point at opcode */ + iif.iifP[i].bit_fixP->fx_bit_base=(long)inst_opcode; + } + case 8: /* bignum or doublefloat */ + memset(memP, '\0', 8); + case 1:case 2:case 3:case 4:/* the final size in objectmemory is known */ + j=(unsigned long)iif.iifP[i].bit_fixP; + switch (type) { + case 1: /* the object is pure binary */ + if (j || iif.iifP[i].pcrel) { + fix_new_ns32k(frag_now, + (long)(memP-frag_now->fr_literal), + size, + 0, + 0, + iif.iifP[i].object, + iif.iifP[i].pcrel, + (char)size_so_far, /*iif.iifP[i].pcrel_adjust,*/ + iif.iifP[i].im_disp, + j, + iif.iifP[i].bsr); /* sequent hack */ + } else { /* good, just put them bytes out */ + switch (iif.iifP[i].im_disp) { + case 0: + md_number_to_chars(memP,iif.iifP[i].object,size);break; + case 1: + md_number_to_disp(memP,iif.iifP[i].object,size);break; + default: as_fatal("iif convert internal pcrel/binary"); + } + } + memP+=size; + rem_size-=size; + break; + case 2: /* the object is a pointer at an expression, so unpack + it, note that bignums may result from the expression + */ + if ((segment=evaluate_expr(&exprP,(char*)iif.iifP[i].object))==SEG_BIG || size==8) { + if ((k=exprP.X_add_number)>0) { /* we have a bignum ie a quad */ + /* this can only happens in a long suffixed instruction */ + memset(memP, '\0', size); /* size normally is 8 */ + if (k*2>size) as_warn("Bignum too big for long"); + if (k==3) memP+=2; + for (l=0;k>0;k--,l+=2) { + md_number_to_chars(memP+l,generic_bignum[l>>1],sizeof(LITTLENUM_TYPE)); + } + } else { /* flonum */ + LITTLENUM_TYPE words[4]; + + switch(size) { + case 4: + gen_to_words(words,2,8); + md_number_to_imm(memP ,(long)words[0],sizeof(LITTLENUM_TYPE)); + md_number_to_imm(memP+sizeof(LITTLENUM_TYPE),(long)words[1],sizeof(LITTLENUM_TYPE)); + break; + case 8: + gen_to_words(words,4,11); + md_number_to_imm(memP ,(long)words[0],sizeof(LITTLENUM_TYPE)); + md_number_to_imm(memP+sizeof(LITTLENUM_TYPE) ,(long)words[1],sizeof(LITTLENUM_TYPE)); + md_number_to_imm(memP+2*sizeof(LITTLENUM_TYPE),(long)words[2],sizeof(LITTLENUM_TYPE)); + md_number_to_imm(memP+3*sizeof(LITTLENUM_TYPE),(long)words[3],sizeof(LITTLENUM_TYPE)); + break; + } + } + memP+=size; + rem_size-=size; + break; + } + if (j || + exprP.X_add_symbol || + exprP.X_subtract_symbol || + iif.iifP[i].pcrel) { /* fixit */ + /* the expression was undefined due to an undefined label */ + /* create a fix so we can fix the object later */ + exprP.X_add_number+=iif.iifP[i].object_adjust; + fix_new_ns32k(frag_now, + (long)(memP-frag_now->fr_literal), + size, + exprP.X_add_symbol, + exprP.X_subtract_symbol, + exprP.X_add_number, + iif.iifP[i].pcrel, + (char)size_so_far, /*iif.iifP[i].pcrel_adjust,*/ + iif.iifP[i].im_disp, + j, + iif.iifP[i].bsr); /* sequent hack */ + + } else { /* good, just put them bytes out */ + switch (iif.iifP[i].im_disp) { + case 0: + md_number_to_imm(memP,exprP.X_add_number,size);break; + case 1: + md_number_to_disp(memP,exprP.X_add_number,size);break; + default: as_fatal("iif convert internal pcrel/pointer"); + } + } + memP+=size; + rem_size-=size; + break; + default: as_fatal("Internal logic error in iif.iifP[n].type"); + } break; - case 8: - gen_to_words(words,4,11); - md_number_to_imm(memP ,(long)words[0],sizeof(LITTLENUM_TYPE)); - md_number_to_imm(memP+sizeof(LITTLENUM_TYPE) ,(long)words[1],sizeof(LITTLENUM_TYPE)); - md_number_to_imm(memP+2*sizeof(LITTLENUM_TYPE),(long)words[2],sizeof(LITTLENUM_TYPE)); - md_number_to_imm(memP+3*sizeof(LITTLENUM_TYPE),(long)words[3],sizeof(LITTLENUM_TYPE)); + case 0: /* To bad, the object may be undefined as far as its final + nsize in object memory is concerned. The size of the object + in objectmemory is not explicitly given. + If the object is defined its length can be determined and + a fix can replace the frag. + */ + { + int temp; + segment=evaluate_expr(&exprP,(char*)iif.iifP[i].object); + if ((exprP.X_add_symbol || exprP.X_subtract_symbol) && + !iif.iifP[i].pcrel) { /* OVE: hack, clamp to 4 bytes */ + size=4; /* we dont wan't to frag this, use 4 so it reaches */ + fix_new_ns32k(frag_now, + (long)(memP-frag_now->fr_literal), + size, + exprP.X_add_symbol, + exprP.X_subtract_symbol, + exprP.X_add_number, + 0, /* never iif.iifP[i].pcrel, */ + (char)size_so_far, /*iif.iifP[i].pcrel_adjust,*/ + 1, /* always iif.iifP[i].im_disp, */ + 0,0); + memP+=size; + rem_size-=4; + break; /* exit this absolute hack */ + } + + if (exprP.X_add_symbol || exprP.X_subtract_symbol) { /* frag it */ + if (exprP.X_subtract_symbol) { /* We cant relax this case */ + as_fatal("Can't relax difference"); + } + else { + /* at this stage we must undo some of the effect caused + by frag_more, ie we must make sure that frag_var causes + frag_new to creat a valid fix-size in the frag it`s closing + */ + temp = -(rem_size-4); + obstack_blank_fast(&frags,temp); + /* we rewind none, some or all of the requested size we + requested by the first frag_more for this iif chunk. + Note: that we allocate 4 bytes to an object we NOT YET + know the size of, thus rem_size-4. + */ + (void)frag_variant(rs_machine_dependent, + 4, + 0, + IND(BRANCH,UNDEF), /* expecting the worst */ + exprP.X_add_symbol, + exprP.X_add_number, + (char*)inst_opcode, + (char)size_so_far, /*iif.iifP[i].pcrel_adjust);*/ + iif.iifP[i].bsr); /* sequent linker hack */ + rem_size-=4; + if (rem_size>0) { + memP=frag_more(rem_size); + } + } + } + else {/* Double work, this is done in md_number_to_disp */ + /* exprP.X_add_number; what was this supposed to be? + xoxorich. */ + if (-64<=exprP.X_add_number && exprP.X_add_number<=63) { + size=1; + } else { + if (-8192<=exprP.X_add_number && exprP.X_add_number<=8191) { + size=2; + } else { + if (-0x1f000000<=exprP.X_add_number && + exprP.X_add_number<=0x1fffffff) + /* if (-0x40000000<=exprP.X_add_number && + exprP.X_add_number<=0x3fffffff) */ + { + size=4; + } else { + as_warn("Displacement to large for :d"); + size=4; + } + } + } + /* rewind the bytes not used */ + temp = -(4-size); + md_number_to_disp(memP,exprP.X_add_number,size); + obstack_blank_fast(&frags,temp); + memP+=size; + rem_size-=4; /* we allocated this amount */ + } + } break; - } - } - memP+=size; - rem_size-=size; - break; - } - if (j || - exprP.X_add_symbol || - exprP.X_subtract_symbol || - iif.iifP[i].pcrel) { /* fixit */ - /* the expression was undefined due to an undefined label */ - /* create a fix so we can fix the object later */ - exprP.X_add_number+=iif.iifP[i].object_adjust; - fix_new_ns32k(frag_now, - (long)(memP-frag_now->fr_literal), - size, - exprP.X_add_symbol, - exprP.X_subtract_symbol, - exprP.X_add_number, - iif.iifP[i].pcrel, - (char)size_so_far, /*iif.iifP[i].pcrel_adjust,*/ - iif.iifP[i].im_disp, - j, - iif.iifP[i].bsr); /* sequent hack */ - - } else { /* good, just put them bytes out */ - switch (iif.iifP[i].im_disp) { - case 0: - md_number_to_imm(memP,exprP.X_add_number,size);break; - case 1: - md_number_to_disp(memP,exprP.X_add_number,size);break; - default: as_fatal("iif convert internal pcrel/pointer"); - } - } - memP+=size; - rem_size-=size; - break; - default: as_fatal("Internal logic error in iif.iifP[n].type"); - } - break; - case 0: /* To bad, the object may be undefined as far as its final - nsize in object memory is concerned. The size of the object - in objectmemory is not explicitly given. - If the object is defined its length can be determined and - a fix can replace the frag. - */ - { - int temp; - segment=evaluate_expr(&exprP,(char*)iif.iifP[i].object); - if ((exprP.X_add_symbol || exprP.X_subtract_symbol) && - !iif.iifP[i].pcrel) { /* OVE: hack, clamp to 4 bytes */ - size=4; /* we dont wan't to frag this, use 4 so it reaches */ - fix_new_ns32k(frag_now, - (long)(memP-frag_now->fr_literal), - size, - exprP.X_add_symbol, - exprP.X_subtract_symbol, - exprP.X_add_number, - 0, /* never iif.iifP[i].pcrel, */ - (char)size_so_far, /*iif.iifP[i].pcrel_adjust,*/ - 1, /* always iif.iifP[i].im_disp, */ - 0,0); - memP+=size; - rem_size-=4; - break; /* exit this absolute hack */ - } - - if (exprP.X_add_symbol || exprP.X_subtract_symbol) { /* frag it */ - if (exprP.X_subtract_symbol) { /* We cant relax this case */ - as_fatal("Can't relax difference"); - } - else { - /* at this stage we must undo some of the effect caused - by frag_more, ie we must make sure that frag_var causes - frag_new to creat a valid fix-size in the frag it`s closing - */ - temp = -(rem_size-4); - obstack_blank_fast(&frags,temp); - /* we rewind none, some or all of the requested size we - requested by the first frag_more for this iif chunk. - Note: that we allocate 4 bytes to an object we NOT YET - know the size of, thus rem_size-4. - */ - (void)frag_variant(rs_machine_dependent, - 4, - 0, - IND(BRANCH,UNDEF), /* expecting the worst */ - exprP.X_add_symbol, - exprP.X_add_number, - (char*)inst_opcode, - (char)size_so_far, /*iif.iifP[i].pcrel_adjust);*/ - iif.iifP[i].bsr); /* sequent linker hack */ - rem_size-=4; - if (rem_size>0) { - memP=frag_more(rem_size); - } - } - } - else {/* Double work, this is done in md_number_to_disp */ - /* exprP.X_add_number; what was this supposed to be? - xoxorich. */ - if (-64<=exprP.X_add_number && exprP.X_add_number<=63) { - size=1; - } else { - if (-8192<=exprP.X_add_number && exprP.X_add_number<=8191) { - size=2; - } else { - if (-0x1f000000<=exprP.X_add_number && - exprP.X_add_number<=0x1fffffff) - /* if (-0x40000000<=exprP.X_add_number && - exprP.X_add_number<=0x3fffffff) */ - { - size=4; - } else { - as_warn("Displacement to large for :d"); - size=4; - } + default: + as_fatal("Internal logic error in iif.iifP[].type"); } - } - /* rewind the bytes not used */ - temp = -(4-size); - md_number_to_disp(memP,exprP.X_add_number,size); - obstack_blank_fast(&frags,temp); - memP+=size; - rem_size-=4; /* we allocated this amount */ + size_so_far+=size; + size=0; } - } - break; - default: - as_fatal("Internal logic error in iif.iifP[].type"); - } - size_so_far+=size; - size=0; } - } } void md_assemble(line) - char *line; +char *line; { - freeptr=freeptr_static; - parse(line,0); /* explode line to more fix form in iif */ - convert_iif(); /* convert iif to frags, fix's etc */ + freeptr=freeptr_static; + parse(line,0); /* explode line to more fix form in iif */ + convert_iif(); /* convert iif to frags, fix's etc */ #ifdef SHOW_NUM - printf(" \t\t\t%s\n",line); + printf(" \t\t\t%s\n",line); #endif } void md_begin() { - /* build a hashtable of the instructions */ - register const struct ns32k_opcode *ptr; - register char *stat; - inst_hash_handle=hash_new(); - for (ptr=ns32k_opcodes;ptrname,(char*)ptr))) { - as_fatal("Can't hash %s: %s", ptr->name,stat); /*fatal*/ - exit(0); + /* build a hashtable of the instructions */ + register const struct ns32k_opcode *ptr; + register char *stat; + inst_hash_handle=hash_new(); + for (ptr=ns32k_opcodes;ptrname,(char*)ptr))) { + as_fatal("Can't hash %s: %s", ptr->name,stat); /*fatal*/ + exit(0); + } } - } - freeptr_static=(char*)malloc(PRIVATE_SIZE); /* some private space please! */ + freeptr_static=(char*)malloc(PRIVATE_SIZE); /* some private space please! */ } void md_end() { - free(freeptr_static); + free(freeptr_static); } /* Must be equal to MAX_PRECISON in atof-ieee.c */ @@ -1274,54 +1282,51 @@ char type; char *litP; int *sizeP; { - int prec; - LITTLENUM_TYPE words[MAX_LITTLENUMS]; - LITTLENUM_TYPE *wordP; - char *t; - - switch(type) { - case 'f': - prec = 2; - break; + int prec; + LITTLENUM_TYPE words[MAX_LITTLENUMS]; + LITTLENUM_TYPE *wordP; + char *t; - case 'd': - prec = 4; - break; - default: - *sizeP=0; - return "Bad call to MD_ATOF()"; - } - t=atof_ieee(input_line_pointer,type,words); - if(t) - input_line_pointer=t; - - *sizeP=prec * sizeof(LITTLENUM_TYPE); - for(wordP=words+prec;prec--;) { - md_number_to_chars(litP,(long)(*--wordP),sizeof(LITTLENUM_TYPE)); - litP+=sizeof(LITTLENUM_TYPE); - } - return ""; /* Someone should teach Dean about null pointers */ + switch(type) { + case 'f': + prec = 2; + break; + + case 'd': + prec = 4; + break; + default: + *sizeP=0; + return "Bad call to MD_ATOF()"; + } + t=atof_ieee(input_line_pointer,type,words); + if(t) + input_line_pointer=t; + + *sizeP=prec * sizeof(LITTLENUM_TYPE); + for(wordP=words+prec;prec--;) { + md_number_to_chars(litP,(long)(*--wordP),sizeof(LITTLENUM_TYPE)); + litP+=sizeof(LITTLENUM_TYPE); + } + return ""; /* Someone should teach Dean about null pointers */ } /* Convert number to chars in correct order */ void md_number_to_chars (buf, value, nbytes) -char *buf; -long value; -int nbytes; +char *buf; +long value; +int nbytes; { - while (nbytes--) - { + while (nbytes--) { #ifdef SHOW_NUM - printf("%x ",value & 0xff); + printf("%x ",value & 0xff); #endif - *buf++ = value; /* Lint wants & MASK_CHAR. */ - value >>= BITS_PER_CHAR; - } -} -/* Convert number to chars in correct order */ - + *buf++ = value; /* Lint wants & MASK_CHAR. */ + value >>= BITS_PER_CHAR; + } +} /* md_number_to_chars() */ /* This is a variant of md_numbers_to_chars. The reason for its' existence @@ -1329,111 +1334,112 @@ int nbytes; that the bit order is reversed in displacements and that they are prefixed with a size-tag. - binary: msb -> lsb 0xxxxxxx byte + binary: msb -> lsb + 0xxxxxxx byte 10xxxxxx xxxxxxxx word 11xxxxxx xxxxxxxx xxxxxxxx xxxxxxxx double word This must be taken care of and we do it here! */ -static void md_number_to_disp(buf,val,n) - char *buf; - long val; - char n; +static void md_number_to_disp(buf, val, n) +char *buf; +long val; +char n; { - switch(n) { - case 1: - if (val < -64 || val > 63) - as_warn("Byte displacement out of range. line number not valid"); - val&=0x7f; + switch(n) { + case 1: + if (val < -64 || val > 63) + as_warn("Byte displacement out of range. line number not valid"); + val&=0x7f; #ifdef SHOW_NUM - printf("%x ",val & 0xff); + printf("%x ",val & 0xff); #endif - *buf++=val; - break; - case 2: - if (val < -8192 || val > 8191) - as_warn("Word displacement out of range. line number not valid"); - val&=0x3fff; - val|=0x8000; + *buf++=val; + break; + case 2: + if (val < -8192 || val > 8191) + as_warn("Word displacement out of range. line number not valid"); + val&=0x3fff; + val|=0x8000; #ifdef SHOW_NUM - printf("%x ",val>>8 & 0xff); + printf("%x ",val>>8 & 0xff); #endif - *buf++=(val>>8); + *buf++=(val>>8); #ifdef SHOW_NUM - printf("%x ",val & 0xff); + printf("%x ",val & 0xff); #endif - *buf++=val; - break; - case 4: - if (val < -0x1f000000 || val >= 0x20000000) - /* if (val < -0x20000000 || val >= 0x20000000) */ - as_warn("Double word displacement out of range"); - val|=0xc0000000; + *buf++=val; + break; + case 4: + if (val < -0x1f000000 || val >= 0x20000000) + /* if (val < -0x20000000 || val >= 0x20000000) */ + as_warn("Double word displacement out of range"); + val|=0xc0000000; #ifdef SHOW_NUM - printf("%x ",val>>24 & 0xff); + printf("%x ",val>>24 & 0xff); #endif - *buf++=(val>>24); + *buf++=(val>>24); #ifdef SHOW_NUM - printf("%x ",val>>16 & 0xff); + printf("%x ",val>>16 & 0xff); #endif - *buf++=(val>>16); + *buf++=(val>>16); #ifdef SHOW_NUM - printf("%x ",val>>8 & 0xff); + printf("%x ",val>>8 & 0xff); #endif - *buf++=(val>>8); + *buf++=(val>>8); #ifdef SHOW_NUM - printf("%x ",val & 0xff); + printf("%x ",val & 0xff); #endif - *buf++=val; - break; - default: - as_fatal("Internal logic error. line %s, file \"%s\"", __LINE__, __FILE__); - } + *buf++=val; + break; + default: + as_fatal("Internal logic error. line %s, file \"%s\"", __LINE__, __FILE__); + } } static void md_number_to_imm(buf,val,n) - char *buf; - long val; - char n; +char *buf; +long val; +char n; { - switch(n) { - case 1: + switch(n) { + case 1: #ifdef SHOW_NUM - printf("%x ",val & 0xff); + printf("%x ",val & 0xff); #endif - *buf++=val; - break; - case 2: + *buf++=val; + break; + case 2: #ifdef SHOW_NUM - printf("%x ",val>>8 & 0xff); + printf("%x ",val>>8 & 0xff); #endif - *buf++=(val>>8); + *buf++=(val>>8); #ifdef SHOW_NUM - printf("%x ",val & 0xff); + printf("%x ",val & 0xff); #endif - *buf++=val; - break; - case 4: + *buf++=val; + break; + case 4: #ifdef SHOW_NUM - printf("%x ",val>>24 & 0xff); + printf("%x ",val>>24 & 0xff); #endif - *buf++=(val>>24); + *buf++=(val>>24); #ifdef SHOW_NUM - printf("%x ",val>>16 & 0xff); + printf("%x ",val>>16 & 0xff); #endif - *buf++=(val>>16); + *buf++=(val>>16); #ifdef SHOW_NUM - printf("%x ",val>>8 & 0xff); + printf("%x ",val>>8 & 0xff); #endif - *buf++=(val>>8); + *buf++=(val>>8); #ifdef SHOW_NUM - printf("%x ",val & 0xff); + printf("%x ",val & 0xff); #endif - *buf++=val; - break; - default: - as_fatal("Internal logic error. line %s, file \"%s\"", __LINE__, __FILE__); - } + *buf++=val; + break; + default: + as_fatal("Internal logic error. line %s, file \"%s\"", __LINE__, __FILE__); + } } /* Translate internal representation of relocation info into target format. @@ -1447,24 +1453,25 @@ static void md_number_to_imm(buf,val,n) This md_ri.... is tailored for sequent. */ +#ifdef comment void md_ri_to_chars(the_bytes, ri) char *the_bytes; struct reloc_info_generic *ri; { - if (ri->r_bsr) {ri->r_pcrel=0;} /* sequent seems to want this */ - md_number_to_chars(the_bytes, ri->r_address, sizeof(ri->r_address)); - md_number_to_chars(the_bytes+4, - (long)(ri->r_symbolnum ) | - (long)(ri->r_pcrel << 24 ) | - (long)(ri->r_length << 25 ) | - (long)(ri->r_extern << 27 ) | - (long)(ri->r_bsr << 28 ) | - (long)(ri->r_disp << 29 ), - 4); - /* the first and second md_number_to_chars never overlaps (32bit cpu case) */ + if (ri->r_bsr) { ri->r_pcrel = 0; } /* sequent seems to want this */ + md_number_to_chars(the_bytes, ri->r_address, sizeof(ri->r_address)); + md_number_to_chars(the_bytes+4, ((long)(ri->r_symbolnum ) + | (long)(ri->r_pcrel << 24 ) + | (long)(ri->r_length << 25 ) + | (long)(ri->r_extern << 27 ) + | (long)(ri->r_bsr << 28 ) + | (long)(ri->r_disp << 29 )), + 4); + /* the first and second md_number_to_chars never overlaps (32bit cpu case) */ } - +#endif /* comment */ + /* fast bitfiddling support */ /* mask used to zero bitfield before oring in the true field */ @@ -1476,7 +1483,7 @@ static unsigned long l_mask[]={ 0xffffffff, 0xfffffffe, 0xfffffffc, 0xfffffff8, 0xfff00000, 0xffe00000, 0xffc00000, 0xff800000, 0xff000000, 0xfe000000, 0xfc000000, 0xf8000000, 0xf0000000, 0xe0000000, 0xc0000000, 0x80000000, - }; + }; static unsigned long r_mask[]={ 0x00000000, 0x00000001, 0x00000003, 0x00000007, 0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f, 0x000000ff, 0x000001ff, 0x000003ff, 0x000007ff, @@ -1485,7 +1492,7 @@ static unsigned long r_mask[]={ 0x00000000, 0x00000001, 0x00000003, 0x00000007, 0x000fffff, 0x001fffff, 0x003fffff, 0x007fffff, 0x00ffffff, 0x01ffffff, 0x03ffffff, 0x07ffffff, 0x0fffffff, 0x1fffffff, 0x3fffffff, 0x7fffffff, - }; + }; #define MASK_BITS 31 /* Insert bitfield described by field_ptr and val at buf This routine is written for modification of the first 4 bytes pointed @@ -1500,62 +1507,62 @@ register char *buf; register long val; register bit_fixS *field_ptr; { - register unsigned long object; - register unsigned long mask; - /* define ENDIAN on a ns32k machine */ + register unsigned long object; + register unsigned long mask; + /* define ENDIAN on a ns32k machine */ #ifdef ENDIAN - register unsigned long *mem_ptr; + register unsigned long *mem_ptr; #else - register char *mem_ptr; + register char *mem_ptr; #endif - if (field_ptr->fx_bit_min<=val && val<=field_ptr->fx_bit_max) { + if (field_ptr->fx_bit_min<=val && val<=field_ptr->fx_bit_max) { #ifdef ENDIAN - if (field_ptr->fx_bit_base) { /* override buf */ - mem_ptr=(unsigned long*)field_ptr->fx_bit_base; - } else { - mem_ptr=(unsigned long*)buf; - } + if (field_ptr->fx_bit_base) { /* override buf */ + mem_ptr=(unsigned long*)field_ptr->fx_bit_base; + } else { + mem_ptr=(unsigned long*)buf; + } #else - if (field_ptr->fx_bit_base) { /* override buf */ - mem_ptr=(char*)field_ptr->fx_bit_base; - } else { - mem_ptr=buf; - } + if (field_ptr->fx_bit_base) { /* override buf */ + mem_ptr=(char*)field_ptr->fx_bit_base; + } else { + mem_ptr=buf; + } #endif - mem_ptr+=field_ptr->fx_bit_base_adj; + mem_ptr+=field_ptr->fx_bit_base_adj; #ifdef ENDIAN /* we have a nice ns32k machine with lowbyte at low-physical mem */ - object = *mem_ptr; /* get some bytes */ + object = *mem_ptr; /* get some bytes */ #else /* OVE Goof! the machine is a m68k or dito */ - /* That takes more byte fiddling */ - object=0; - object|=mem_ptr[3] & 0xff; - object<<=8; - object|=mem_ptr[2] & 0xff; - object<<=8; - object|=mem_ptr[1] & 0xff; - object<<=8; - object|=mem_ptr[0] & 0xff; + /* That takes more byte fiddling */ + object=0; + object|=mem_ptr[3] & 0xff; + object<<=8; + object|=mem_ptr[2] & 0xff; + object<<=8; + object|=mem_ptr[1] & 0xff; + object<<=8; + object|=mem_ptr[0] & 0xff; #endif - mask=0; - mask|=(r_mask[field_ptr->fx_bit_offset]); - mask|=(l_mask[field_ptr->fx_bit_offset+field_ptr->fx_bit_size]); - object&=mask; - val+=field_ptr->fx_bit_add; - object|=((val<fx_bit_offset) & (mask ^ 0xffffffff)); + mask=0; + mask|=(r_mask[field_ptr->fx_bit_offset]); + mask|=(l_mask[field_ptr->fx_bit_offset+field_ptr->fx_bit_size]); + object&=mask; + val+=field_ptr->fx_bit_add; + object|=((val<fx_bit_offset) & (mask ^ 0xffffffff)); #ifdef ENDIAN - *mem_ptr=object; + *mem_ptr=object; #else - mem_ptr[0]=(char)object; - object>>=8; - mem_ptr[1]=(char)object; - object>>=8; - mem_ptr[2]=(char)object; - object>>=8; - mem_ptr[3]=(char)object; + mem_ptr[0]=(char)object; + object>>=8; + mem_ptr[1]=(char)object; + object>>=8; + mem_ptr[2]=(char)object; + object>>=8; + mem_ptr[3]=(char)object; #endif - } else { - as_warn("Bit field out of range"); - } + } else { + as_warn("Bit field out of range"); + } } /* Apply a fixS (fixup of an instruction or data that we didn't have @@ -1570,26 +1577,26 @@ void fixS *fixP; long val; { - char *buf = fixP->fx_where + fixP->fx_frag->fr_literal; - - if (fixP->fx_bit_fixP) { /* Bitfields to fix, sigh */ - md_number_to_field (buf, val, fixP->fx_bit_fixP); - } else switch (fixP->fx_im_disp) { - - case 0: /* Immediate field */ - md_number_to_imm (buf, val, fixP->fx_size); - break; + char *buf = fixP->fx_where + fixP->fx_frag->fr_literal; - case 1: /* Displacement field */ - md_number_to_disp (buf, - fixP->fx_pcrel? val + fixP->fx_pcrel_adjust: val, - fixP->fx_size); - break; - - case 2: /* Pointer in a data object */ - md_number_to_chars (buf, val, fixP->fx_size); - break; - } + if (fixP->fx_bit_fixP) { /* Bitfields to fix, sigh */ + md_number_to_field (buf, val, fixP->fx_bit_fixP); + } else switch (fixP->fx_im_disp) { + + case 0: /* Immediate field */ + md_number_to_imm (buf, val, fixP->fx_size); + break; + + case 1: /* Displacement field */ + md_number_to_disp (buf, + fixP->fx_pcrel? val + fixP->fx_pcrel_adjust: val, + fixP->fx_size); + break; + + case 2: /* Pointer in a data object */ + md_number_to_chars (buf, val, fixP->fx_size); + break; + } } /* Convert a relaxed displacement to ditto in final output */ @@ -1599,35 +1606,35 @@ void object_headers *headers; register fragS *fragP; { - long disp; - long ext; - - /* Address in gas core of the place to store the displacement. */ - register char *buffer_address = fragP -> fr_fix + fragP -> fr_literal; - /* Address in object code of the displacement. */ - register int object_address = fragP -> fr_fix + fragP -> fr_address; - - know(fragP->fr_symbol); - - /* The displacement of the address, from current location. */ - disp = (S_GET_VALUE(fragP->fr_symbol) + fragP->fr_offset) - object_address; - disp+= fragP->fr_pcrel_adjust; - - switch(fragP->fr_subtype) { - case IND(BRANCH,BYTE): - ext=1; - break; + long disp; + long ext = 0; + + /* Address in gas core of the place to store the displacement. */ + register char *buffer_address = fragP->fr_fix + fragP->fr_literal; + /* Address in object code of the displacement. */ + register int object_address = fragP->fr_fix + fragP->fr_address; + + know(fragP->fr_symbol); + + /* The displacement of the address, from current location. */ + disp = (S_GET_VALUE(fragP->fr_symbol) + fragP->fr_offset) - object_address; + disp+= fragP->fr_pcrel_adjust; + + switch(fragP->fr_subtype) { + case IND(BRANCH,BYTE): + ext=1; + break; case IND(BRANCH,WORD): ext=2; - break; + break; case IND(BRANCH,DOUBLE): ext=4; - break; - } - if(ext) { - md_number_to_disp(buffer_address,(long)disp,(int)ext); - fragP->fr_fix+=ext; + break; } + if(ext) { + md_number_to_disp(buffer_address,(long)disp,(int)ext); + fragP->fr_fix+=ext; + } } @@ -1637,42 +1644,42 @@ register fragS *fragP; actually know it */ int md_estimate_size_before_relax(fragP, segment) - register fragS *fragP; - segT segment; +register fragS *fragP; +segT segment; { - int old_fix; - old_fix=fragP->fr_fix; - switch(fragP->fr_subtype) { - case IND(BRANCH,UNDEF): - if(S_GET_SEGMENT(fragP->fr_symbol) == segment) { - /* the symbol has been assigned a value */ - fragP->fr_subtype=IND(BRANCH,BYTE); - } else { - /* we don't relax symbols defined in an other segment - the thing to do is to assume the object will occupy 4 bytes */ - fix_new_ns32k(fragP, - (int)(fragP->fr_fix), - 4, - fragP->fr_symbol, - (symbolS *)0, - fragP->fr_offset, - 1, - fragP->fr_pcrel_adjust, - 1, - 0, - fragP->fr_bsr); /*sequent hack */ - fragP->fr_fix+=4; - /* fragP->fr_opcode[1]=0xff; */ - frag_wane(fragP); - break; - } + int old_fix; + old_fix=fragP->fr_fix; + switch(fragP->fr_subtype) { + case IND(BRANCH,UNDEF): + if(S_GET_SEGMENT(fragP->fr_symbol) == segment) { + /* the symbol has been assigned a value */ + fragP->fr_subtype=IND(BRANCH,BYTE); + } else { + /* we don't relax symbols defined in an other segment + the thing to do is to assume the object will occupy 4 bytes */ + fix_new_ns32k(fragP, + (int)(fragP->fr_fix), + 4, + fragP->fr_symbol, + (symbolS *)0, + fragP->fr_offset, + 1, + fragP->fr_pcrel_adjust, + 1, + 0, + fragP->fr_bsr); /*sequent hack */ + fragP->fr_fix+=4; + /* fragP->fr_opcode[1]=0xff; */ + frag_wane(fragP); + break; + } case IND(BRANCH,BYTE): fragP->fr_var+=1; - break; + break; default: - break; + break; } - return fragP->fr_var + fragP->fr_fix - old_fix; + return fragP->fr_var + fragP->fr_fix - old_fix; } int md_short_jump_size = 3; @@ -1687,11 +1694,11 @@ long from_addr, fragS *frag; symbolS *to_symbol; { - long offset; - - offset = to_addr - from_addr; - md_number_to_chars(ptr, (long)0xEA ,1); - md_number_to_disp(ptr+1,(long)offset,2); + long offset; + + offset = to_addr - from_addr; + md_number_to_chars(ptr, (long)0xEA ,1); + md_number_to_disp(ptr+1,(long)offset,2); } void @@ -1702,11 +1709,11 @@ long from_addr, fragS *frag; symbolS *to_symbol; { - long offset; - - offset= to_addr - from_addr; - md_number_to_chars(ptr, (long)0xEA, 2); - md_number_to_disp(ptr+2,(long)offset,4); + long offset; + + offset= to_addr - from_addr; + md_number_to_chars(ptr, (long)0xEA, 2); + md_number_to_disp(ptr+2,(long)offset,4); } /* JF this is a new function to parse machine-dep options */ @@ -1716,27 +1723,27 @@ char **argP; int *cntP; char ***vecP; { - switch(**argP) { - case 'm': - (*argP)++; - - if(!strcmp(*argP,"32032")) { - cpureg = cpureg_032; - mmureg = mmureg_032; - } else if(!strcmp(*argP, "32532")) { - cpureg = cpureg_532; - mmureg = mmureg_532; - } else - as_warn("Unknown -m option ignored"); - - while(**argP) - (*argP)++; - break; - - default: - return 0; - } - return 1; + switch(**argP) { + case 'm': + (*argP)++; + + if(!strcmp(*argP,"32032")) { + cpureg = cpureg_032; + mmureg = mmureg_032; + } else if(!strcmp(*argP, "32532")) { + cpureg = cpureg_532; + mmureg = mmureg_532; + } else + as_warn("Unknown -m option ignored"); + + while(**argP) + (*argP)++; + break; + + default: + return 0; + } + return 1; } /* @@ -1746,64 +1753,54 @@ char ***vecP; * This struct is used to profile the normal fix. If the bit_fixP is a * valid pointer (not NULL) the bit_fix data will be used to format the fix. */ -bit_fixS *bit_fix_new (size,offset,min,max,add,base_type,base_adj) - char size; /* Length of bitfield */ - char offset; /* Bit offset to bitfield */ - long base_type; /* 0 or 1, if 1 it's exploded to opcode ptr */ - long base_adj; - long min; /* Signextended min for bitfield */ - long max; /* Signextended max for bitfield */ - long add; /* Add mask, used for huffman prefix */ +bit_fixS *bit_fix_new(size, offset, min, max, add, base_type, base_adj) +char size; /* Length of bitfield */ +char offset; /* Bit offset to bitfield */ +long base_type; /* 0 or 1, if 1 it's exploded to opcode ptr */ +long base_adj; +long min; /* Signextended min for bitfield */ +long max; /* Signextended max for bitfield */ +long add; /* Add mask, used for huffman prefix */ { - register bit_fixS * bit_fixP; - - bit_fixP = (bit_fixS *)obstack_alloc(¬es,sizeof(bit_fixS)); - - bit_fixP -> fx_bit_size = size; - bit_fixP -> fx_bit_offset = offset; - bit_fixP -> fx_bit_base = base_type; - bit_fixP -> fx_bit_base_adj = base_adj; - bit_fixP -> fx_bit_max = max; - bit_fixP -> fx_bit_min = min; - bit_fixP -> fx_bit_add = add; - - return bit_fixP; + register bit_fixS * bit_fixP; + + bit_fixP = (bit_fixS *)obstack_alloc(¬es,sizeof(bit_fixS)); + + bit_fixP->fx_bit_size = size; + bit_fixP->fx_bit_offset = offset; + bit_fixP->fx_bit_base = base_type; + bit_fixP->fx_bit_base_adj = base_adj; + bit_fixP->fx_bit_max = max; + bit_fixP->fx_bit_min = min; + bit_fixP->fx_bit_add = add; + + return(bit_fixP); } void - fix_new_ns32k (frag, where, size, add_symbol, sub_symbol, offset, pcrel, + fix_new_ns32k(frag, where, size, add_symbol, sub_symbol, offset, pcrel, pcrel_adjust, im_disp, bit_fixP, bsr) -fragS * frag; /* Which frag? */ -int where; /* Where in that frag? */ -short int size; /* 1, 2 or 4 usually. */ -symbolS * add_symbol; /* X_add_symbol. */ -symbolS * sub_symbol; /* X_subtract_symbol. */ -long offset; /* X_add_number. */ -int pcrel; /* TRUE if PC-relative relocation. */ -char pcrel_adjust; /* not zero if adjustment of pcrel offset is needed */ -char im_disp; /* true if the value to write is a displacement */ -bit_fixS *bit_fixP; /* pointer at struct of bit_fix's, ignored if NULL */ -char bsr; /* sequent-linker-hack: 1 when relocobject is a bsr */ +fragS *frag; /* Which frag? */ +int where; /* Where in that frag? */ +int size; /* 1, 2 or 4 usually. */ +symbolS *add_symbol; /* X_add_symbol. */ +symbolS *sub_symbol; /* X_subtract_symbol. */ +long offset; /* X_add_number. */ +int pcrel; /* TRUE if PC-relative relocation. */ +char pcrel_adjust; /* not zero if adjustment of pcrel offset is needed */ +char im_disp; /* true if the value to write is a displacement */ +bit_fixS *bit_fixP; /* pointer at struct of bit_fix's, ignored if NULL */ +char bsr; /* sequent-linker-hack: 1 when relocobject is a bsr */ { - register fixS * fixP; - - fixP = (fixS *)obstack_alloc(¬es,sizeof(fixS)); - fixP -> fx_frag = frag; - fixP -> fx_where = where; - fixP -> fx_size = size; - fixP -> fx_addsy = add_symbol; - fixP -> fx_subsy = sub_symbol; - fixP -> fx_offset = offset; - fixP -> fx_pcrel = pcrel; - fixP -> fx_pcrel_adjust = pcrel_adjust; - fixP -> fx_im_disp = im_disp; - fixP -> fx_bit_fixP = bit_fixP; - fixP -> fx_bsr = bsr; - fixP -> fx_next = * seg_fix_rootP; - - * seg_fix_rootP = fixP; -} + fixS *fixP = fix_new(frag, where, size, add_symbol, sub_symbol, + offset, pcrel, NO_RELOC); + + fixP->fx_pcrel_adjust = pcrel_adjust; + fixP->fx_im_disp = im_disp; + fixP->fx_bit_fixP = bit_fixP; + fixP->fx_bsr = bsr; +} /* fix_new_ns32k() */ /* We have no need to default values of symbols. */ @@ -1811,7 +1808,7 @@ symbolS * md_undefined_symbol (name) char *name; { - return 0; + return 0; } /* Parse an operand that is machine-specific. @@ -1831,7 +1828,7 @@ long segT segment; long size; { - return size; /* Byte alignment is fine */ + return size; /* Byte alignment is fine */ } /* Exactly what point is a PC-relative offset relative TO? @@ -1842,13 +1839,18 @@ long md_pcrel_from (fixP) fixS *fixP; { - long res; - res = fixP->fx_where + fixP->fx_frag->fr_address; + long res; + res = fixP->fx_where + fixP->fx_frag->fr_address; #ifdef SEQUENT_COMPATABILITY - if (fixP->fx_frag->fr_bsr) - res += 0x12 /* FOO Kludge alert! */ + if (fixP->fx_frag->fr_bsr) + res += 0x12 /* FOO Kludge alert! */ #endif - return res; + return res; +} + +void tc_aout_fix_to_chars(char *where, struct fix *fixP, + relax_addressT segment_address) { + know(0); /* know nothing */ } /* diff --git a/gas/config/tc-sparc.c b/gas/config/tc-sparc.c index f17a7dc..b52043f 100644 --- a/gas/config/tc-sparc.c +++ b/gas/config/tc-sparc.c @@ -516,7 +516,7 @@ static void sparc_ip(str) argsStart = s; for (;;) { opcode = insn->match; - bzero(&the_insn, sizeof(the_insn)); + memset(&the_insn, '\0', sizeof(the_insn)); the_insn.reloc = NO_RELOC; /* @@ -1645,7 +1645,7 @@ void emit_sparc_reloc(fixP, segment_address_in_file) extern char *next_object_file_charP; /* long add_number; */ - bzero((char *) &ri, sizeof(ri)); + memset((char *) &ri, '\0', sizeof(ri)); for (; fixP; fixP = fixP->fx_next) { if (fixP->fx_r_type >= NO_RELOC) { diff --git a/gas/obstack.c b/gas/obstack.c new file mode 100644 index 0000000..6c0b830 --- /dev/null +++ b/gas/obstack.c @@ -0,0 +1,370 @@ +/* obstack.c - subroutines used implicitly by object stack macros + Copyright (C) 1988 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include "obstack.h" + +#ifdef __STDC__ +#define POINTER void * +#else +#define POINTER char * +#endif + +/* Determine default alignment. */ +struct fooalign {char x; double d;}; +#define DEFAULT_ALIGNMENT ((char *)&((struct fooalign *) 0)->d - (char *)0) +/* If malloc were really smart, it would round addresses to DEFAULT_ALIGNMENT. + But in fact it might be less smart and round addresses to as much as + DEFAULT_ROUNDING. So we prepare for it to do that. */ +union fooround {long x; double d;}; +#define DEFAULT_ROUNDING (sizeof (union fooround)) + +/* When we copy a long block of data, this is the unit to do it with. + On some machines, copying successive ints does not work; + in such a case, redefine COPYING_UNIT to `long' (if that works) + or `char' as a last resort. */ +#ifndef COPYING_UNIT +#define COPYING_UNIT int +#endif + +/* The non-GNU-C macros copy the obstack into this global variable + to avoid multiple evaluation. */ + +struct obstack *_obstack; + +/* Initialize an obstack H for use. Specify chunk size SIZE (0 means default). + Objects start on multiples of ALIGNMENT (0 means use default). + CHUNKFUN is the function to use to allocate chunks, + and FREEFUN the function to free them. */ + +void +_obstack_begin (h, size, alignment, chunkfun, freefun) + struct obstack *h; + int size; + int alignment; + POINTER (*chunkfun) (); + void (*freefun) (); +{ + register struct _obstack_chunk* chunk; /* points to new chunk */ + + if (alignment == 0) + alignment = DEFAULT_ALIGNMENT; + if (size == 0) + /* Default size is what GNU malloc can fit in a 4096-byte block. */ + { + /* 12 is sizeof (mhead) and 4 is EXTRA from GNU malloc. + Use the values for range checking, because if range checking is off, + the extra bytes won't be missed terribly, but if range checking is on + and we used a larger request, a whole extra 4096 bytes would be + allocated. + + These number are irrelevant to the new GNU malloc. I suspect it is + less sensitive to the size of the request. */ + int extra = ((((12 + DEFAULT_ROUNDING - 1) & ~(DEFAULT_ROUNDING - 1)) + + 4 + DEFAULT_ROUNDING - 1) + & ~(DEFAULT_ROUNDING - 1)); + size = 4096 - extra; + } + + h->chunkfun = (struct _obstack_chunk * (*)()) chunkfun; + h->freefun = freefun; + h->chunk_size = size; + h->alignment_mask = alignment - 1; + + chunk = h->chunk = (*h->chunkfun) (h->chunk_size); + h->next_free = h->object_base = chunk->contents; + h->chunk_limit = chunk->limit + = (char *) chunk + h->chunk_size; + chunk->prev = 0; + /* The initial chunk now contains no empty object. */ + h->maybe_empty_object = 0; +} + +/* Allocate a new current chunk for the obstack *H + on the assumption that LENGTH bytes need to be added + to the current object, or a new object of length LENGTH allocated. + Copies any partial object from the end of the old chunk + to the beginning of the new one. */ + +void +_obstack_newchunk (h, length) + struct obstack *h; + int length; +{ + register struct _obstack_chunk* old_chunk = h->chunk; + register struct _obstack_chunk* new_chunk; + register long new_size; + register int obj_size = h->next_free - h->object_base; + register int i; + int already; + + /* Compute size for new chunk. */ + new_size = (obj_size + length) + (obj_size >> 3) + 100; + if (new_size < h->chunk_size) + new_size = h->chunk_size; + + /* Allocate and initialize the new chunk. */ + new_chunk = h->chunk = (*h->chunkfun) (new_size); + new_chunk->prev = old_chunk; + new_chunk->limit = h->chunk_limit = (char *) new_chunk + new_size; + + /* Move the existing object to the new chunk. + Word at a time is fast and is safe if the object + is sufficiently aligned. */ + if (h->alignment_mask + 1 >= DEFAULT_ALIGNMENT) + { + for (i = obj_size / sizeof (COPYING_UNIT) - 1; + i >= 0; i--) + ((COPYING_UNIT *)new_chunk->contents)[i] + = ((COPYING_UNIT *)h->object_base)[i]; + /* We used to copy the odd few remaining bytes as one extra COPYING_UNIT, + but that can cross a page boundary on a machine + which does not do strict alignment for COPYING_UNITS. */ + already = obj_size / sizeof (COPYING_UNIT) * sizeof (COPYING_UNIT); + } + else + already = 0; + /* Copy remaining bytes one by one. */ + for (i = already; i < obj_size; i++) + new_chunk->contents[i] = h->object_base[i]; + + /* If the object just copied was the only data in OLD_CHUNK, + free that chunk and remove it from the chain. + But not if that chunk might contain an empty object. */ + if (h->object_base == old_chunk->contents && ! h->maybe_empty_object) + { + new_chunk->prev = old_chunk->prev; + (*h->freefun) (old_chunk); + } + + h->object_base = new_chunk->contents; + h->next_free = h->object_base + obj_size; + /* The new chunk certainly contains no empty object yet. */ + h->maybe_empty_object = 0; +} + +/* Return nonzero if object OBJ has been allocated from obstack H. + This is here for debugging. + If you use it in a program, you are probably losing. */ + +int +_obstack_allocated_p (h, obj) + struct obstack *h; + POINTER obj; +{ + register struct _obstack_chunk* lp; /* below addr of any objects in this chunk */ + register struct _obstack_chunk* plp; /* point to previous chunk if any */ + + lp = (h)->chunk; + /* We use >= rather than > since the object cannot be exactly at + the beginning of the chunk but might be an empty object exactly + at the end of an adjacent chunk. */ + while (lp != 0 && ((POINTER)lp >= obj || (POINTER)(lp)->limit < obj)) + { + plp = lp->prev; + lp = plp; + } + return lp != 0; +} + +/* Free objects in obstack H, including OBJ and everything allocate + more recently than OBJ. If OBJ is zero, free everything in H. */ + +#undef obstack_free + +/* This function has two names with identical definitions. + This is the first one, called from non-ANSI code. */ + +void +_obstack_free (h, obj) + struct obstack *h; + POINTER obj; +{ + register struct _obstack_chunk* lp; /* below addr of any objects in this chunk */ + register struct _obstack_chunk* plp; /* point to previous chunk if any */ + + lp = h->chunk; + /* We use >= because there cannot be an object at the beginning of a chunk. + But there can be an empty object at that address + at the end of another chunk. */ + while (lp != 0 && ((POINTER)lp >= obj || (POINTER)(lp)->limit < obj)) + { + plp = lp->prev; + (*h->freefun) (lp); + lp = plp; + /* If we switch chunks, we can't tell whether the new current + chunk contains an empty object, so assume that it may. */ + h->maybe_empty_object = 1; + } + if (lp) + { + h->object_base = h->next_free = (char *)(obj); + h->chunk_limit = lp->limit; + h->chunk = lp; + } + else if (obj != 0) + /* obj is not in any of the chunks! */ + abort (); +} + +/* This function is used from ANSI code. */ + +void +obstack_free (h, obj) + struct obstack *h; + POINTER obj; +{ + register struct _obstack_chunk* lp; /* below addr of any objects in this chunk */ + register struct _obstack_chunk* plp; /* point to previous chunk if any */ + + lp = h->chunk; + /* We use >= because there cannot be an object at the beginning of a chunk. + But there can be an empty object at that address + at the end of another chunk. */ + while (lp != 0 && ((POINTER)lp >= obj || (POINTER)(lp)->limit < obj)) + { + plp = lp->prev; + (*h->freefun) (lp); + lp = plp; + /* If we switch chunks, we can't tell whether the new current + chunk contains an empty object, so assume that it may. */ + h->maybe_empty_object = 1; + } + if (lp) + { + h->object_base = h->next_free = (char *)(obj); + h->chunk_limit = lp->limit; + h->chunk = lp; + } + else if (obj != 0) + /* obj is not in any of the chunks! */ + abort (); +} + +#if 0 +/* These are now turned off because the applications do not use it + and it uses bcopy via obstack_grow, which causes trouble on sysV. */ + +/* Now define the functional versions of the obstack macros. + Define them to simply use the corresponding macros to do the job. */ + +#ifdef __STDC__ +/* These function definitions do not work with non-ANSI preprocessors; + they won't pass through the macro names in parentheses. */ + +/* The function names appear in parentheses in order to prevent + the macro-definitions of the names from being expanded there. */ + +POINTER (obstack_base) (obstack) + struct obstack *obstack; +{ + return obstack_base (obstack); +} + +POINTER (obstack_next_free) (obstack) + struct obstack *obstack; +{ + return obstack_next_free (obstack); +} + +int (obstack_object_size) (obstack) + struct obstack *obstack; +{ + return obstack_object_size (obstack); +} + +int (obstack_room) (obstack) + struct obstack *obstack; +{ + return obstack_room (obstack); +} + +void (obstack_grow) (obstack, pointer, length) + struct obstack *obstack; + POINTER pointer; + int length; +{ + obstack_grow (obstack, pointer, length); +} + +void (obstack_grow0) (obstack, pointer, length) + struct obstack *obstack; + POINTER pointer; + int length; +{ + obstack_grow0 (obstack, pointer, length); +} + +void (obstack_1grow) (obstack, character) + struct obstack *obstack; + int character; +{ + obstack_1grow (obstack, character); +} + +void (obstack_blank) (obstack, length) + struct obstack *obstack; + int length; +{ + obstack_blank (obstack, length); +} + +void (obstack_1grow_fast) (obstack, character) + struct obstack *obstack; + int character; +{ + obstack_1grow_fast (obstack, character); +} + +void (obstack_blank_fast) (obstack, length) + struct obstack *obstack; + int length; +{ + obstack_blank_fast (obstack, length); +} + +POINTER (obstack_finish) (obstack) + struct obstack *obstack; +{ + return obstack_finish (obstack); +} + +POINTER (obstack_alloc) (obstack, length) + struct obstack *obstack; + int length; +{ + return obstack_alloc (obstack, length); +} + +POINTER (obstack_copy) (obstack, pointer, length) + struct obstack *obstack; + POINTER pointer; + int length; +{ + return obstack_copy (obstack, pointer, length); +} + +POINTER (obstack_copy0) (obstack, pointer, length) + struct obstack *obstack; + POINTER pointer; + int length; +{ + return obstack_copy0 (obstack, pointer, length); +} + +#endif /* __STDC__ */ + +#endif /* 0 */ diff --git a/gas/obstack.h b/gas/obstack.h new file mode 100644 index 0000000..efac356 --- /dev/null +++ b/gas/obstack.h @@ -0,0 +1,444 @@ +/* obstack.h - object stack macros + Copyright (C) 1988 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/* Summary: + +All the apparent functions defined here are macros. The idea +is that you would use these pre-tested macros to solve a +very specific set of problems, and they would run fast. +Caution: no side-effects in arguments please!! They may be +evaluated MANY times!! + +These macros operate a stack of objects. Each object starts life +small, and may grow to maturity. (Consider building a word syllable +by syllable.) An object can move while it is growing. Once it has +been "finished" it never changes address again. So the "top of the +stack" is typically an immature growing object, while the rest of the +stack is of mature, fixed size and fixed address objects. + +These routines grab large chunks of memory, using a function you +supply, called `obstack_chunk_alloc'. On occasion, they free chunks, +by calling `obstack_chunk_free'. You must define them and declare +them before using any obstack macros. + +Each independent stack is represented by a `struct obstack'. +Each of the obstack macros expects a pointer to such a structure +as the first argument. + +One motivation for this package is the problem of growing char strings +in symbol tables. Unless you are "fascist pig with a read-only mind" +[Gosper's immortal quote from HAKMEM item 154, out of context] you +would not like to put any arbitrary upper limit on the length of your +symbols. + +In practice this often means you will build many short symbols and a +few long symbols. At the time you are reading a symbol you don't know +how long it is. One traditional method is to read a symbol into a +buffer, realloc()ating the buffer every time you try to read a symbol +that is longer than the buffer. This is beaut, but you still will +want to copy the symbol from the buffer to a more permanent +symbol-table entry say about half the time. + +With obstacks, you can work differently. Use one obstack for all symbol +names. As you read a symbol, grow the name in the obstack gradually. +When the name is complete, finalize it. Then, if the symbol exists already, +free the newly read name. + +The way we do this is to take a large chunk, allocating memory from +low addresses. When you want to build a symbol in the chunk you just +add chars above the current "high water mark" in the chunk. When you +have finished adding chars, because you got to the end of the symbol, +you know how long the chars are, and you can create a new object. +Mostly the chars will not burst over the highest address of the chunk, +because you would typically expect a chunk to be (say) 100 times as +long as an average object. + +In case that isn't clear, when we have enough chars to make up +the object, THEY ARE ALREADY CONTIGUOUS IN THE CHUNK (guaranteed) +so we just point to it where it lies. No moving of chars is +needed and this is the second win: potentially long strings need +never be explicitly shuffled. Once an object is formed, it does not +change its address during its lifetime. + +When the chars burst over a chunk boundary, we allocate a larger +chunk, and then copy the partly formed object from the end of the old +chunk to the beginning of the new larger chunk. We then carry on +accreting characters to the end of the object as we normally would. + +A special macro is provided to add a single char at a time to a +growing object. This allows the use of register variables, which +break the ordinary 'growth' macro. + +Summary: + We allocate large chunks. + We carve out one object at a time from the current chunk. + Once carved, an object never moves. + We are free to append data of any size to the currently + growing object. + Exactly one object is growing in an obstack at any one time. + You can run one obstack per control block. + You may have as many control blocks as you dare. + Because of the way we do it, you can `unwind' a obstack + back to a previous state. (You may remove objects much + as you would with a stack.) +*/ + + +/* Don't do the contents of this file more than once. */ + +#ifndef __OBSTACKS__ +#define __OBSTACKS__ + +/* We use subtraction of (char *)0 instead of casting to int + because on word-addressable machines a simple cast to int + may ignore the byte-within-word field of the pointer. */ + +#ifndef __PTR_TO_INT +#define __PTR_TO_INT(P) ((P) - (char *)0) +#endif + +#ifndef __INT_TO_PTR +#define __INT_TO_PTR(P) ((P) + (char *)0) +#endif + +struct _obstack_chunk /* Lives at front of each chunk. */ +{ + char *limit; /* 1 past end of this chunk */ + struct _obstack_chunk *prev; /* address of prior chunk or NULL */ + char contents[4]; /* objects begin here */ +}; + +struct obstack /* control current object in current chunk */ +{ + long chunk_size; /* preferred size to allocate chunks in */ + struct _obstack_chunk* chunk; /* address of current struct obstack_chunk */ + char *object_base; /* address of object we are building */ + char *next_free; /* where to add next char to current object */ + char *chunk_limit; /* address of char after current chunk */ + int temp; /* Temporary for some macros. */ + int alignment_mask; /* Mask of alignment for each object. */ + struct _obstack_chunk *(*chunkfun) (); /* User's fcn to allocate a chunk. */ + void (*freefun) (); /* User's function to free a chunk. */ + /* Nonzero means there is a possibility the current chunk contains + a zero-length object. This prevents freeing the chunk + if we allocate a bigger chunk to replace it. */ + char maybe_empty_object; +}; + +/* Declare the external functions we use; they are in obstack.c. */ + +#ifdef __STDC__ + extern void _obstack_newchunk (struct obstack *, int); + extern void _obstack_free (struct obstack *, void *); + extern void _obstack_begin (struct obstack *, int, int, + void *(*) (), void (*) ()); +#else + extern void _obstack_newchunk (); + extern void _obstack_free (); + extern void _obstack_begin (); +#endif + +#ifdef __STDC__ + +/* Do the function-declarations after the structs + but before defining the macros. */ + +void obstack_init (struct obstack *obstack); + +void * obstack_alloc (struct obstack *obstack, int size); + +void * obstack_copy (struct obstack *obstack, void *address, int size); +void * obstack_copy0 (struct obstack *obstack, void *address, int size); + +void obstack_free (struct obstack *obstack, void *block); + +void obstack_blank (struct obstack *obstack, int size); + +void obstack_grow (struct obstack *obstack, void *data, int size); +void obstack_grow0 (struct obstack *obstack, void *data, int size); + +void obstack_1grow (struct obstack *obstack, int data_char); +void obstack_ptr_grow (struct obstack *obstack, void *data); +void obstack_int_grow (struct obstack *obstack, int data); + +void * obstack_finish (struct obstack *obstack); + +int obstack_object_size (struct obstack *obstack); + +int obstack_room (struct obstack *obstack); +void obstack_1grow_fast (struct obstack *obstack, int data_char); +void obstack_ptr_grow_fast (struct obstack *obstack, void *data); +void obstack_int_grow_fast (struct obstack *obstack, int data); +void obstack_blank_fast (struct obstack *obstack, int size); + +void * obstack_base (struct obstack *obstack); +void * obstack_next_free (struct obstack *obstack); +int obstack_alignment_mask (struct obstack *obstack); +int obstack_chunk_size (struct obstack *obstack); + +#endif /* __STDC__ */ + +/* Non-ANSI C cannot really support alternative functions for these macros, + so we do not declare them. */ + +/* Pointer to beginning of object being allocated or to be allocated next. + Note that this might not be the final address of the object + because a new chunk might be needed to hold the final size. */ + +#define obstack_base(h) ((h)->object_base) + +/* Size for allocating ordinary chunks. */ + +#define obstack_chunk_size(h) ((h)->chunk_size) + +/* Pointer to next byte not yet allocated in current chunk. */ + +#define obstack_next_free(h) ((h)->next_free) + +/* Mask specifying low bits that should be clear in address of an object. */ + +#define obstack_alignment_mask(h) ((h)->alignment_mask) + +#define obstack_init(h) \ + _obstack_begin ((h), 0, 0, \ + (void *(*) ()) obstack_chunk_alloc, (void (*) ())obstack_chunk_free) + +#define obstack_begin(h, size) \ + _obstack_begin ((h), (size), 0, \ + (void *(*) ()) obstack_chunk_alloc, (void (*) ())obstack_chunk_free) + +#define obstack_1grow_fast(h,achar) (*((h)->next_free)++ = achar) + +#define obstack_blank_fast(h,n) ((h)->next_free += (n)) + +#if defined (__GNUC__) && defined (__STDC__) +#if __GNUC__ < 2 +#define __extension__ +#endif + +/* For GNU C, if not -traditional, + we can define these macros to compute all args only once + without using a global variable. + Also, we can avoid using the `temp' slot, to make faster code. */ + +#define obstack_object_size(OBSTACK) \ + __extension__ \ + ({ struct obstack *__o = (OBSTACK); \ + (unsigned) (__o->next_free - __o->object_base); }) + +#define obstack_room(OBSTACK) \ + __extension__ \ + ({ struct obstack *__o = (OBSTACK); \ + (unsigned) (__o->chunk_limit - __o->next_free); }) + +/* Note that the call to _obstack_newchunk is enclosed in (..., 0) + so that we can avoid having void expressions + in the arms of the conditional expression. + Casting the third operand to void was tried before, + but some compilers won't accept it. */ +#define obstack_grow(OBSTACK,where,length) \ +__extension__ \ +({ struct obstack *__o = (OBSTACK); \ + int __len = (length); \ + ((__o->next_free + __len > __o->chunk_limit) \ + ? (_obstack_newchunk (__o, __len), 0) : 0); \ + memcpy (__o->next_free, where, __len); \ + __o->next_free += __len; \ + (void) 0; }) + +#define obstack_grow0(OBSTACK,where,length) \ +__extension__ \ +({ struct obstack *__o = (OBSTACK); \ + int __len = (length); \ + ((__o->next_free + __len + 1 > __o->chunk_limit) \ + ? (_obstack_newchunk (__o, __len + 1), 0) : 0), \ + memcpy (__o->next_free, where, __len), \ + __o->next_free += __len, \ + *(__o->next_free)++ = 0; \ + (void) 0; }) + +#define obstack_1grow(OBSTACK,datum) \ +__extension__ \ +({ struct obstack *__o = (OBSTACK); \ + ((__o->next_free + 1 > __o->chunk_limit) \ + ? (_obstack_newchunk (__o, 1), 0) : 0), \ + *(__o->next_free)++ = (datum); \ + (void) 0; }) + +/* These assume that the obstack alignment is good enough for pointers or ints, + and that the data added so far to the current object + shares that much alignment. */ + +#define obstack_ptr_grow(OBSTACK,datum) \ +__extension__ \ +({ struct obstack *__o = (OBSTACK); \ + ((__o->next_free + sizeof (void *) > __o->chunk_limit) \ + ? (_obstack_newchunk (__o, sizeof (void *)), 0) : 0), \ + *(*(void ***)&__o->next_free)++ = ((void *)datum); \ + (void) 0; }) + +#define obstack_int_grow(OBSTACK,datum) \ +__extension__ \ +({ struct obstack *__o = (OBSTACK); \ + ((__o->next_free + sizeof (int) > __o->chunk_limit) \ + ? (_obstack_newchunk (__o, sizeof (int)), 0) : 0), \ + *(*(int **)&__o->next_free)++ = ((int)datum); \ + (void) 0; }) + +#define obstack_ptr_grow_fast(h,aptr) (*(*(void ***)&(h)->next_free)++ = (void *)aptr) +#define obstack_int_grow_fast(h,aint) (*(*(int **)&(h)->next_free)++ = (int)aint) + +#define obstack_blank(OBSTACK,length) \ +__extension__ \ +({ struct obstack *__o = (OBSTACK); \ + int __len = (length); \ + ((__o->chunk_limit - __o->next_free < __len) \ + ? (_obstack_newchunk (__o, __len), 0) : 0); \ + __o->next_free += __len; \ + (void) 0; }) + +#define obstack_alloc(OBSTACK,length) \ +__extension__ \ +({ struct obstack *__h = (OBSTACK); \ + obstack_blank (__h, (length)); \ + obstack_finish (__h); }) + +#define obstack_copy(OBSTACK,where,length) \ +__extension__ \ +({ struct obstack *__h = (OBSTACK); \ + obstack_grow (__h, (where), (length)); \ + obstack_finish (__h); }) + +#define obstack_copy0(OBSTACK,where,length) \ +__extension__ \ +({ struct obstack *__h = (OBSTACK); \ + obstack_grow0 (__h, (where), (length)); \ + obstack_finish (__h); }) + +/* The local variable is named __o1 to avoid a name conflict + when obstack_blank is called. */ +#define obstack_finish(OBSTACK) \ +__extension__ \ +({ struct obstack *__o1 = (OBSTACK); \ + void *value = (void *) __o1->object_base; \ + if (__o1->next_free == value) \ + __o1->maybe_empty_object = 1; \ + __o1->next_free \ + = __INT_TO_PTR ((__PTR_TO_INT (__o1->next_free)+__o1->alignment_mask)\ + & ~ (__o1->alignment_mask)); \ + ((__o1->next_free - (char *)__o1->chunk \ + > __o1->chunk_limit - (char *)__o1->chunk) \ + ? (__o1->next_free = __o1->chunk_limit) : 0); \ + __o1->object_base = __o1->next_free; \ + value; }) + +#define obstack_free(OBSTACK, OBJ) \ +__extension__ \ +({ struct obstack *__o = (OBSTACK); \ + void *__obj = (OBJ); \ + if (__obj > (void *)__o->chunk && __obj < (void *)__o->chunk_limit) \ + __o->next_free = __o->object_base = __obj; \ + else (obstack_free) (__o, __obj); }) + +#else /* not __GNUC__ or not __STDC__ */ + +#define obstack_object_size(h) \ + (unsigned) ((h)->next_free - (h)->object_base) + +#define obstack_room(h) \ + (unsigned) ((h)->chunk_limit - (h)->next_free) + +#define obstack_grow(h,where,length) \ +( (h)->temp = (length), \ + (((h)->next_free + (h)->temp > (h)->chunk_limit) \ + ? (_obstack_newchunk ((h), (h)->temp), 0) : 0), \ + memcpy ((h)->next_free, where, (h)->temp), \ + (h)->next_free += (h)->temp) + +#define obstack_grow0(h,where,length) \ +( (h)->temp = (length), \ + (((h)->next_free + (h)->temp + 1 > (h)->chunk_limit) \ + ? (_obstack_newchunk ((h), (h)->temp + 1), 0) : 0), \ + memcpy ((h)->next_free, where, (h)->temp), \ + (h)->next_free += (h)->temp, \ + *((h)->next_free)++ = 0) + +#define obstack_1grow(h,datum) \ +( (((h)->next_free + 1 > (h)->chunk_limit) \ + ? (_obstack_newchunk ((h), 1), 0) : 0), \ + *((h)->next_free)++ = (datum)) + +#define obstack_ptr_grow(h,datum) \ +( (((h)->next_free + sizeof (char *) > (h)->chunk_limit) \ + ? (_obstack_newchunk ((h), sizeof (char *)), 0) : 0), \ + *(*(char ***)&(h)->next_free)++ = ((char *)datum)) + +#define obstack_int_grow(h,datum) \ +( (((h)->next_free + sizeof (int) > (h)->chunk_limit) \ + ? (_obstack_newchunk ((h), sizeof (int)), 0) : 0), \ + *(*(int **)&(h)->next_free)++ = ((int)datum)) + +#define obstack_ptr_grow_fast(h,aptr) (*(*(char ***)&(h)->next_free)++ = (char *)aptr) +#define obstack_int_grow_fast(h,aint) (*(*(int **)&(h)->next_free)++ = (int)aint) +#define obstack_blank(h,length) \ +( (h)->temp = (length), \ + (((h)->chunk_limit - (h)->next_free < (h)->temp) \ + ? (_obstack_newchunk ((h), (h)->temp), 0) : 0), \ + (h)->next_free += (h)->temp) + +#define obstack_alloc(h,length) \ + (obstack_blank ((h), (length)), obstack_finish ((h))) + +#define obstack_copy(h,where,length) \ + (obstack_grow ((h), (where), (length)), obstack_finish ((h))) + +#define obstack_copy0(h,where,length) \ + (obstack_grow0 ((h), (where), (length)), obstack_finish ((h))) + +#define obstack_finish(h) \ +( ((h)->next_free == (h)->object_base \ + ? (((h)->maybe_empty_object = 1), 0) \ + : 0), \ + (h)->temp = __PTR_TO_INT ((h)->object_base), \ + (h)->next_free \ + = __INT_TO_PTR ((__PTR_TO_INT ((h)->next_free)+(h)->alignment_mask) \ + & ~ ((h)->alignment_mask)), \ + (((h)->next_free - (char *)(h)->chunk \ + > (h)->chunk_limit - (char *)(h)->chunk) \ + ? ((h)->next_free = (h)->chunk_limit) : 0), \ + (h)->object_base = (h)->next_free, \ + __INT_TO_PTR ((h)->temp)) + +#ifdef __STDC__ +#define obstack_free(h,obj) \ +( (h)->temp = (char *)(obj) - (char *) (h)->chunk, \ + (((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\ + ? (int) ((h)->next_free = (h)->object_base \ + = (h)->temp + (char *) (h)->chunk) \ + : (((obstack_free) ((h), (h)->temp + (char *) (h)->chunk), 0), 0))) +#else +#define obstack_free(h,obj) \ +( (h)->temp = (char *)(obj) - (char *) (h)->chunk, \ + (((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\ + ? (int) ((h)->next_free = (h)->object_base \ + = (h)->temp + (char *) (h)->chunk) \ + : (_obstack_free ((h), (h)->temp + (char *) (h)->chunk), 0))) +#endif + +#endif /* not __GNUC__ or not __STDC__ */ + +#endif /* not __OBSTACKS__ */ diff --git a/gas/read.c b/gas/read.c index a12eaa0..717877f 100644 --- a/gas/read.c +++ b/gas/read.c @@ -36,7 +36,7 @@ #include "as.h" #include "obstack.h" -#include "listing.h" + char *input_line_pointer; /*->next char of source file to parse. */ @@ -171,11 +171,6 @@ void struct hash_control * po_hash = NULL; /* use before set up: NULL->address error */ -#ifdef DONTDEF -void s_gdbline(), s_gdblinetab(); -void s_gdbbeg(), s_gdbblock(), s_gdbend(), s_gdbsym(); -#endif - static const pseudo_typeS potable[] = { @@ -190,7 +185,11 @@ static const pseudo_typeS /* dim */ { "double", float_cons, 'd' }, /* dsect */ +#ifdef NO_LISTING + { "eject", s_ignore, 0 }, /* Formfeed listing */ +#else { "eject", listing_eject, 0 }, /* Formfeed listing */ +#endif /* NO_LISTING */ { "else", s_else, 0 }, { "end", s_end, 0 }, { "endif", s_endif, 0 }, @@ -203,14 +202,6 @@ static const pseudo_typeS { "file", s_app_file, 0 }, { "fill", s_fill, 0 }, { "float", float_cons, 'f' }, -#ifdef DONTDEF - { "gdbbeg", s_gdbbeg, 0 }, - { "gdbblock", s_gdbblock, 0 }, - { "gdbend", s_gdbend, 0 }, - { "gdbsym", s_gdbsym, 0 }, - { "gdbline", s_gdbline, 0 }, - { "gdblinetab",s_gdblinetab, 0 }, -#endif { "global", s_globl, 0 }, { "globl", s_globl, 0 }, { "hword", cons, 2 }, @@ -223,17 +214,34 @@ static const pseudo_typeS { "include", s_include, 0 }, { "int", cons, 4 }, { "lcomm", s_lcomm, 0 }, +#ifdef NO_LISTING + { "lflags", s_ignore, 0 }, /* Listing flags */ + { "list", s_ignore, 1 }, /* Turn listing on */ +#else { "lflags", listing_flags, 0 }, /* Listing flags */ { "list", listing_list, 1 }, /* Turn listing on */ +#endif /* NO_LISTING */ { "long", cons, 4 }, { "lsym", s_lsym, 0 }, +#ifdef NO_LISTING + { "nolist", s_ignore, 0 }, /* Turn listing off */ +#else { "nolist", listing_list, 0 }, /* Turn listing off */ +#endif /* NO_LISTING */ { "octa", big_cons, 16 }, { "org", s_org, 0 }, - { "psize", listing_psize, 0 }, /* set paper size */ +#ifdef NO_LISTING + { "psize", s_ignore, 0 }, /* set paper size */ +#else + { "psize", listing_psize, 0 }, /* set paper size */ +#endif /* NO_LISTING */ /* print */ { "quad", big_cons, 8 }, +#ifdef NO_LISTING + { "sbttl", s_ignore, 1 }, /* Subtitle of listing */ +#else { "sbttl", listing_title, 1 }, /* Subtitle of listing */ +#endif /* NO_LISTING */ /* scl */ /* sect */ { "set", s_set, 0 }, @@ -243,7 +251,11 @@ static const pseudo_typeS { "space", s_space, 0 }, /* tag */ { "text", s_text, 0 }, +#ifdef NO_LISTING + { "title", s_ignore, 0 }, /* Listing title */ +#else { "title", listing_title, 0 }, /* Listing title */ +#endif /* NO_LISTING */ /* type */ /* use */ /* val */ @@ -321,12 +333,6 @@ char *name; register int temp; /* register struct frag * fragP; JF unused */ /* a frag we just made */ pseudo_typeS *pop; -#ifdef DONTDEF - void gdb_block_beg(); - void gdb_block_position(); - void gdb_block_end(); - void gdb_symbols_fixup(); -#endif buffer = input_scrub_new_file(name); @@ -504,7 +510,7 @@ char *name; guarentee it. . . */ tmp_len=buffer_limit-s; tmp_buf=xmalloc(tmp_len); - bcopy(s,tmp_buf,tmp_len); + memcpy(tmp_buf, s, tmp_len); do { new_tmp = input_scrub_next_buffer(&buffer); if (!new_tmp) @@ -519,7 +525,7 @@ char *name; num=buffer_limit-buffer; tmp_buf = xrealloc(tmp_buf, tmp_len + num); - bcopy(buffer,tmp_buf+tmp_len,num); + memcpy(tmp_buf + tmp_len, buffer, num); tmp_len+=num; } while(!ends); @@ -773,7 +779,7 @@ void s_fill() { temp_fill = get_absolute_expression (); if (temp_size && !need_pass_2) { p = frag_var(rs_fill, (int)temp_size, (int)temp_size, (relax_substateT)0, (symbolS *)0, temp_repeat, (char *)0); - bzero (p, (int)temp_size); + memset(p, '\0', (int) temp_size); /* * The magic number BSD_FILL_SIZE_CROCK_4 is from BSD 4.2 VAX flavoured AS. * The following bizzare behaviour is to be compatible with above. @@ -791,118 +797,6 @@ void s_fill() { demand_empty_rest_of_line(); } -#ifdef DONTDEF -void - s_gdbbeg() -{ - register int temp; - - temp = get_absolute_expression (); - if (temp < 0) - as_warn("Block number <0. Ignored."); - else if (flagseen ['G']) - gdb_block_beg ((long) temp, frag_now, (long)(obstack_next_free(& frags) - frag_now->fr_literal)); - demand_empty_rest_of_line (); -} - -void - s_gdbblock() -{ - register int position; - int temp; - - if (get_absolute_expression_and_terminator (&temp) != ',') { - as_bad("expected comma before position in .gdbblock"); - --input_line_pointer; - ignore_rest_of_line (); - return; - } - position = get_absolute_expression (); - if (flagseen ['G']) - gdb_block_position ((long) temp, (long) position); - demand_empty_rest_of_line (); -} - -void - s_gdbend() -{ - register int temp; - - temp = get_absolute_expression (); - if (temp < 0) - as_warn("Block number <0. Ignored."); - else if (flagseen ['G']) - gdb_block_end ((long) temp, frag_now, (long)(obstack_next_free(& frags) - frag_now->fr_literal)); - demand_empty_rest_of_line (); -} - -void - s_gdbsym() -{ - register char *name, - *p; - register char c; - register symbolS * symbolP; - register int temp; - - name = input_line_pointer; - c = get_symbol_end(); - p = input_line_pointer; - symbolP = symbol_find_or_make(name); - *p = c; - SKIP_WHITESPACE(); - if (* input_line_pointer != ',') { - as_bad("Expected comma after name"); - ignore_rest_of_line(); - return; - } - input_line_pointer ++; - if ((temp = get_absolute_expression ()) < 0) { - as_bad("Bad GDB symbol file offset (%d.) <0! Ignored.", temp); - ignore_rest_of_line(); - return; - } - if (flagseen ['G']) - gdb_symbols_fixup (symbolP, (long)temp); - demand_empty_rest_of_line (); -} - -void - s_gdbline() -{ - int file_number, - lineno; - - if (get_absolute_expression_and_terminator(&file_number) != ',') { - as_bad("expected comman after filenum in .gdbline"); - ignore_rest_of_line(); - return; - } - lineno=get_absolute_expression(); - if (flagseen['G']) - gdb_line(file_number,lineno); - demand_empty_rest_of_line(); -} - - -void - s_gdblinetab() -{ - int file_number, - offset; - - if (get_absolute_expression_and_terminator(&file_number) != ',') { - as_bad("expected comma after filenum in .gdblinetab"); - ignore_rest_of_line(); - return; - } - offset=get_absolute_expression(); - if (flagseen['G']) - gdb_line_tab(file_number,offset); - demand_empty_rest_of_line(); -} -#endif - void s_globl() { register char *name; register int c; @@ -1645,13 +1539,13 @@ register unsigned int nbytes; /* 1=.byte, 2=.word, 4=.long */ default: case SEG_UNKNOWN: #ifdef TC_NS32K - fix_new_ns32k (frag_now, p - frag_now->fr_literal, nbytes, - exp . X_add_symbol, exp . X_subtract_symbol, - exp . X_add_number, 0, 0, 2, 0, 0); + fix_new_ns32k(frag_now, p - frag_now->fr_literal, nbytes, + exp.X_add_symbol, exp.X_subtract_symbol, + exp.X_add_number, 0, 0, 2, 0, 0); #else - fix_new (frag_now, p - frag_now->fr_literal, nbytes, - exp . X_add_symbol, exp . X_subtract_symbol, - exp . X_add_number, 0, RELOC_32); + fix_new(frag_now, p - frag_now->fr_literal, nbytes, + exp.X_add_symbol, exp.X_subtract_symbol, + exp.X_add_number, 0, RELOC_32); #endif /* TC_NS32K */ break; } /* switch(segment) */ @@ -1784,11 +1678,11 @@ register int nbytes; if (! need_pass_2) { p = frag_more (nbytes); - bcopy (bignum_low, p, (int)nbytes); + memcpy(p, bignum_low, (int) nbytes); } /* C contains character after number. */ SKIP_WHITESPACE(); - c = * input_line_pointer; + c = *input_line_pointer; /* C contains 1st non-blank character after number. */ } demand_empty_rest_of_line(); @@ -1854,45 +1748,40 @@ register int float_type; /* 'f':.ffloat ... 'F':.float ... */ { c = ','; /* Do loop. */ } - while (c == ',') - { - /* input_line_pointer->1st char of a flonum (we hope!). */ - SKIP_WHITESPACE(); - /* Skip any 0{letter} that may be present. Don't even check if the - * letter is legal. Someone may invent a "z" format and this routine - * has no use for such information. Lusers beware: you get - * diagnostics if your input is ill-conditioned. - */ - - if (input_line_pointer[0]=='0' && isalpha(input_line_pointer[1])) - input_line_pointer+=2; - - err = md_atof (float_type, temp, &length); - know(length <= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT); - know(length > 0); - if (* err) - { - as_bad("Bad floating literal: %s", err); - ignore_rest_of_line(); - /* Input_line_pointer->just after end-of-line. */ - c = 0; /* Break out of loop. */ - } - else - { - if (! need_pass_2) - { - p = frag_more (length); - bcopy (temp, p, length); - } - SKIP_WHITESPACE(); - c = * input_line_pointer ++; - /* C contains 1st non-white character after number. */ - /* input_line_pointer->just after terminator (c). */ + while (c == ',') { + /* input_line_pointer->1st char of a flonum (we hope!). */ + SKIP_WHITESPACE(); + /* Skip any 0{letter} that may be present. Don't even check if the + * letter is legal. Someone may invent a "z" format and this routine + * has no use for such information. Lusers beware: you get + * diagnostics if your input is ill-conditioned. + */ + + if (input_line_pointer[0]=='0' && isalpha(input_line_pointer[1])) + input_line_pointer+=2; + + err = md_atof (float_type, temp, &length); + know(length <= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT); + know(length > 0); + if (* err) { + as_bad("Bad floating literal: %s", err); + ignore_rest_of_line(); + /* Input_line_pointer->just after end-of-line. */ + c = 0; /* Break out of loop. */ + } else { + if (! need_pass_2) { + p = frag_more (length); + memcpy(p, temp, length); } - } - -- input_line_pointer; /*->terminator (is not ','). */ + SKIP_WHITESPACE(); + c = *input_line_pointer++; + /* C contains 1st non-white character after number. */ + /* input_line_pointer->just after terminator (c). */ + } + } + --input_line_pointer; /*->terminator (is not ','). */ demand_empty_rest_of_line(); -} /* float_cons() */ +} /* float_cons() */ /* * stringer() diff --git a/gas/strerror.c b/gas/strerror.c new file mode 100644 index 0000000..dbc403b --- /dev/null +++ b/gas/strerror.c @@ -0,0 +1,61 @@ +/* Version of strerror() for systems that need it. + Copyright (C) 1991, 1992 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + + +/* + +NAME + + strerror -- map an error number to an error message string + +SYNOPSIS + + #include + + char *strerror (int errnum) + +DESCRIPTION + + Returns a pointer to a string containing an error message, the + contents of which are implementation defined. The implementation + shall behave as if no library function calls strerror. The string + pointed to shall not be modified by the caller and is only guaranteed + to be valid until a subsequent call to strerror. + +BUGS + + Requires that the system have sys_errlist and sys_nerr. + +*/ + +#ifndef HAVE_STRERROR + +extern int sys_nerr; +extern char *sys_errlist[]; + +char * +strerror (code) + int code; +{ + return (((code < 0) || (code >= sys_nerr)) + ? "(unknown error)" + : sys_errlist [code]); +} + +#endif /* HAVE_STRERROR */ + + /* end of strerror.c */ diff --git a/gas/write.c b/gas/write.c index 63fee36..54d4952 100644 --- a/gas/write.c +++ b/gas/write.c @@ -86,9 +86,9 @@ long offset; /* X_add_number. */ int pcrel; /* TRUE if PC-relative relocation. */ enum reloc_type r_type; /* Relocation type */ { - register fixS * fixP; + fixS *fixP; - fixP = (fixS *)obstack_alloc(¬es,sizeof(fixS)); + fixP = (fixS *) obstack_alloc(¬es, sizeof(fixS)); fixP->fx_frag = frag; fixP->fx_where = where; @@ -100,10 +100,10 @@ enum reloc_type r_type; /* Relocation type */ fixP->fx_r_type = r_type; /* JF these 'cuz of the NS32K stuff */ - fixP->fx_im_disp = 0; + fixP->fx_im_disp = 0; fixP->fx_pcrel_adjust = 0; - fixP->fx_bsr = 0; - fixP->fx_bit_fixP = 0; + fixP->fx_bsr = 0; + fixP->fx_bit_fixP = 0; /* usually, we want relocs sorted numerically, but while comparing to older versions of gas that have relocs @@ -128,8 +128,9 @@ enum reloc_type r_type; /* Relocation type */ #endif /* REVERSE_SORT_RELOCS */ fixP->fx_callj = 0; - return fixP; -} + return(fixP); +} /* fix_new() */ + #ifndef BFD void write_object_file() { @@ -143,10 +144,6 @@ void write_object_file() /* register fixS * fixP; JF unused */ unsigned int data_siz; -#ifdef DONTDEF - void gdb_emit(); - void gdb_end(); -#endif long object_file_size; #ifdef VMS @@ -566,14 +563,6 @@ void write_object_file() output_file_append(the_object_file,object_file_size,out_file_name); #endif -#ifdef DONTDEF - if (flagseen['G']) /* GDB symbol file to be appended? */ - { - gdb_emit (out_file_name); - gdb_end (); - } -#endif /* DONTDEF */ - output_file_close(out_file_name); } /* non vms output */ #else /* VMS */ @@ -1138,8 +1127,8 @@ char **charPP; char *fromP; unsigned long length; { - if (length) { /* Don't trust bcopy() of 0 chars. */ - bcopy(fromP, *charPP, (int) length); + if (length) { /* Don't trust memcpy() of 0 chars. */ + memcpy(*charPP, fromP, (int) length); *charPP += length; } } -- 2.7.4