diff -rc /dca/local/gnu/gas/gas-1.36/gas-1.36/as.c ./as.c
*** /dca/local/gnu/gas/gas-1.36/gas-1.36/as.c	Tue Mar 20 10:33:57 1990
--- ./as.c	Sun Aug 19 16:25:43 1990
***************
*** 124,130 ****
--- 124,140 ----
  			switch (a) {
  			case 'f':
  				break;	/* -f means fast - no need for "app" preprocessor. */
+ 			case 'C': 
+ 				/* write coff file instead of a.out this run */
+ 				break;
  
+ 			case 'M': 
+ 				/* write MACHO file instead of a.out this run
+ 				 * Not yet implemented. (Waiting for MACH
+ 				 * tape  to arrive.)
+ 				 */
+ 				break;
+ 
  			case 'D':
  				/* DEBUG is implemented: it debugs different */
  				/* things to other people's assemblers. */
***************
*** 209,214 ****
--- 219,239 ----
  	if (gdb_begin(gdb_symbol_file_name) == 0)
  		flagseen ['G'] = 0;	/* Don't do any gdbsym stuff. */
  #endif
+ 
+ 	/* Notice: the way this is coded makes it necessary to not define
+ 	   more than one of COFF_OPTION and MACHO_OPTION.  This will change
+ 	   when I do the macho work, after which the same binary of
+ 	   gas will be able to produce any of a.out, coff, or macho. */
+ 
+ #ifdef COFF_OPTION
+ 	    aout_is_intermediate_only = (flagseen ['C'] == COFF_OPTION );
+ #endif
+ 	/* Notice: MACHO_OPTION is not yet implemented. Should have something
+ 	   to support this shortly after we receive the MACH tape. */
+ #ifdef MACHO_OPTION 
+ 	    aout_is_intermediate_only = (flagseen ['M'] == MACHO_OPTION );
+ #endif
+ 
  	/* Here with flags set up in flagseen[]. */
  	perform_an_assembly_pass(argc,argv); /* Assemble it. */
  	if (seen_at_least_1_file() && !bad_error)
diff -rc /dca/local/gnu/gas/gas-1.36/gas-1.36/as.h ./as.h
*** /dca/local/gnu/gas/gas-1.36/gas-1.36/as.h	Wed Mar  1 14:49:37 1989
--- ./as.h	Sun Aug 19 15:50:15 1990
***************
*** 282,287 ****
--- 282,295 ----
  
  COMMON int	need_pass_2;	/* TRUE if we need a second pass. */
  
+ /* 
+   This is for the benefit of an alternate object file type back end (such
+   as one that produces COFF or MACHO).
+   If aout_is_intermediate_only is TRUE, byte swaps are only performed for the
+   raw data of the object, not the for the a.out structures which only
+   guide the generation of our target object and are not written out.
+  */
+ COMMON int 	aout_is_intermediate_only;
  
  #endif				/* #ifdef asH */
  
diff -rc /dca/local/gnu/gas/gas-1.36/gas-1.36/i386-opcode.h ./i386-opcode.h
*** /dca/local/gnu/gas/gas-1.36/gas-1.36/i386-opcode.h	Tue Jan 23 11:26:34 1990
--- ./i386-opcode.h	Sat Aug 18 14:09:46 1990
***************
*** 383,389 ****
  #define IS_STRING_INSTRUCTION(o) \
    ((o) == 0xa6 || (o) == 0x6c || (o) == 0x6e || (o) == 0x6e || \
     (o) == 0xac || (o) == 0xa4 || (o) == 0xae || (o) == 0xaa || \
!    (o) == 0xd7)
  
  /* string manipulation */
  {"cmps", 0, 0xa6, _, W|NoModrm, 0, 0, 0},
--- 383,389 ----
  #define IS_STRING_INSTRUCTION(o) \
    ((o) == 0xa6 || (o) == 0x6c || (o) == 0x6e || (o) == 0x6e || \
     (o) == 0xac || (o) == 0xa4 || (o) == 0xae || (o) == 0xaa || \
!    (o) == 0xd7 || (o) == 0xa5 )
  
  /* string manipulation */
  {"cmps", 0, 0xa6, _, W|NoModrm, 0, 0, 0},
***************
*** 391,396 ****
--- 391,397 ----
  {"outs", 0, 0x6e, _, W|NoModrm, 0, 0, 0},
  {"lods", 0, 0xac, _, W|NoModrm, 0, 0, 0},
  {"movs", 0, 0xa4, _, W|NoModrm, 0, 0, 0},
+ {"smovl", 0, 0xa5, _,  NoModrm, 0, 0, 0},
  {"scas", 0, 0xae, _, W|NoModrm, 0, 0, 0},
  {"stos", 0, 0xaa, _, W|NoModrm, 0, 0, 0},
  {"xlat", 0, 0xd7, _, NoModrm, 0, 0, 0},
diff -rc /dca/local/gnu/gas/gas-1.36/gas-1.36/i386.c ./i386.c
*** /dca/local/gnu/gas/gas-1.36/gas-1.36/i386.c	Wed May 16 08:29:04 1990
--- ./i386.c	Wed Jul 18 21:10:47 1990
***************
*** 169,174 ****
--- 169,175 ----
  	{ "value",      cons,           2 },
  	{ "ident",      dummy,          0   }, /* ignore these directives */
  	{ "def",        dummy,          0   },
+ 	{ "optim",	dummy,          0   }, /* generated by sun 386i cc */
  	{ "version",    dummy,          0   },
  	{ "ln",    dummy,          0   },
  	{ 0, 0, 0 }
***************
*** 1132,1143 ****
        /* Now the modrm byte and base index byte (if present). */
        if (t->opcode_modifier & Modrm) {
  	p =  frag_more (1);
! 	md_number_to_chars (p, i.rm, 1);
  	/* If i.rm.regmem == ESP (4) && i.rm.mode != Mode 3 (Register mode)
  	   ==> need second modrm byte. */
  	if (i.rm.regmem == ESCAPE_TO_TWO_BYTE_ADDRESSING && i.rm.mode != 3) {
  	  p =  frag_more (1);
! 	  md_number_to_chars (p, i.bi, 1);
  	}
        }
        
--- 1133,1144 ----
        /* Now the modrm byte and base index byte (if present). */
        if (t->opcode_modifier & Modrm) {
  	p =  frag_more (1);
! 	md_number_to_chars (p, (i.rm.regmem<<0 | i.rm.reg<<3 | i.rm.mode<<6), 1);
  	/* If i.rm.regmem == ESP (4) && i.rm.mode != Mode 3 (Register mode)
  	   ==> need second modrm byte. */
  	if (i.rm.regmem == ESCAPE_TO_TWO_BYTE_ADDRESSING && i.rm.mode != 3) {
  	  p =  frag_more (1);
! 	  md_number_to_chars (p,(i.bi.base<<0 | i.bi.index<<3 | i.bi.scale<<6), 1);
  	}
        }
        
diff -rc /dca/local/gnu/gas/gas-1.36/gas-1.36/m68k.c ./m68k.c
*** /dca/local/gnu/gas/gas-1.36/gas-1.36/m68k.c	Wed May 16 08:47:44 1990
--- ./m68k.c	Wed Jul 18 21:10:47 1990
***************
*** 444,454 ****
  	register int n = 0,
  		ret;
  
  	c1=mklower(ccp[0][0]);
  	c2=mklower(ccp[0][1]);
  	c3=mklower(ccp[0][2]);
  	c4=mklower(ccp[0][3]);
! 
  	switch(c1) {
  	case 'a':
  		if(c2>='0' && c2<='7') {
--- 444,463 ----
  	register int n = 0,
  		ret;
  
+ #ifdef REGISTER_PREFIX
  	c1=mklower(ccp[0][0]);
+ 	if (c1 != REGISTER_PREFIX)
+ 		return FAIL;
+ 	c1=mklower(ccp[0][1]);
+ 	c2=mklower(ccp[0][2]);
+ 	c3=mklower(ccp[0][3]);
+ 	c4=mklower(ccp[0][4]);
+ #else
+ 	c1=mklower(ccp[0][0]);
  	c2=mklower(ccp[0][1]);
  	c3=mklower(ccp[0][2]);
  	c4=mklower(ccp[0][3]);
! #endif
  	switch(c1) {
  	case 'a':
  		if(c2>='0' && c2<='7') {
***************
*** 628,633 ****
--- 637,645 ----
  		break;
  	}
  	if(n) {
+ #ifdef REGISTER_PREFIX
+ 		n++;			/* account for REGISTER_PRIFIX ('%') */
+ #endif
  		if(isalnum(ccp[0][n]) || ccp[0][n]=='_')
  			ret=FAIL;
  		else
***************
*** 2498,2503 ****
--- 2510,2518 ----
  	alt_notend_table['#'] = 1;
  	alt_notend_table['f'] = 1;
  	alt_notend_table['F'] = 1;
+ #ifdef REGISTER_PREFIX
+ 	alt_notend_table[REGISTER_PREFIX] = 1;
+ #endif
  }
  
  #if 0
diff -rc /dca/local/gnu/gas/gas-1.36/gas-1.36/write.c ./write.c
*** /dca/local/gnu/gas/gas-1.36/gas-1.36/write.c	Thu Apr 12 09:23:42 1990
--- ./write.c	Sun Aug 19 16:21:36 1990
***************
*** 48,53 ****
--- 48,73 ----
  #define EXEC_MACHINE_TYPE HP9000S200_ID
  #endif
  
+ #ifdef DOT_LABEL_PREFIX
+ #define LOCAL_LABEL(name) (name[0] =='.' \
+ 			   && ( name [1] == 'L' || name [1] == '.' ))
+ #else  /* not defined DOT_LABEL_PREFIX */
+ #define LOCAL_LABEL(name) (name [0] == 'L' )
+ #endif /* not defined DOT_LABEL_PREFIX */
+ 
+ /* COND_MD_NUMBER_TO_CHARS is called instead of md_number_to_chars for a.out
+    objects that appear in a.out files but not in other types of object files.
+    Such objects are needed in un-byteswapped form when writing alternate
+    types of object files.
+    Note that one does NOT typecast the first argument to this macro when
+    calling  it.  */
+ 
+ #define COND_MD_NUMBER_TO_CHARS(destp, src, size) 	\
+   if (aout_is_intermediate_only)			\
+     *(destp) = src;					\
+   else							\
+     md_number_to_chars((char *) (destp),src, size );
+ 
  /*
   * In: length of relocation (or of address) in chars: 1, 2 or 4.
   * Out: GNU LD relocation length code: 0, 1, or 2.
***************
*** 266,272 ****
    text_siz= (text_siz+7)&(~7);
    text_last_frag->fr_address=text_siz;
  #endif
!   md_number_to_chars((char *)&the_exec.a_text,text_siz, sizeof(the_exec.a_text));
    /* the_exec . a_text = text_last_frag -> fr_address; */
  
    /*
--- 286,292 ----
    text_siz= (text_siz+7)&(~7);
    text_last_frag->fr_address=text_siz;
  #endif
!   COND_MD_NUMBER_TO_CHARS(&the_exec.a_text,text_siz, sizeof(the_exec.a_text));
    /* the_exec . a_text = text_last_frag -> fr_address; */
  
    /*
***************
*** 286,292 ****
        data_siz += (8 - (data_siz % 8)) % 8;
        data_last_frag->fr_address = data_siz;
  #endif
!       md_number_to_chars((char *)&the_exec.a_data,data_siz,sizeof(the_exec.a_data));
        /* the_exec . a_data = data_last_frag -> fr_address; */
        slide = text_siz; /* Address in file of the data segment. */
        for (fragP = data_frag_root;
--- 306,313 ----
        data_siz += (8 - (data_siz % 8)) % 8;
        data_last_frag->fr_address = data_siz;
  #endif
!       COND_MD_NUMBER_TO_CHARS(&the_exec.a_data,data_siz,
! 			      sizeof(the_exec.a_data));
        /* the_exec . a_data = data_last_frag -> fr_address; */
        slide = text_siz; /* Address in file of the data segment. */
        for (fragP = data_frag_root;
***************
*** 299,305 ****
        text_last_frag -> fr_next = data_frag_root;
      }
    else {
!       md_number_to_chars((char *)&the_exec.a_data,0,sizeof(the_exec.a_data));
        data_siz = 0;
    }
  
--- 320,326 ----
        text_last_frag -> fr_next = data_frag_root;
      }
    else {
!       COND_MD_NUMBER_TO_CHARS(&the_exec.a_data,0,sizeof(the_exec.a_data));
        data_siz = 0;
    }
  
***************
*** 307,313 ****
  #ifdef SPARC
    local_bss_counter=(local_bss_counter+7)&(~7);
  #endif
!   md_number_to_chars((char *)&the_exec.a_bss,local_bss_counter,sizeof(the_exec.a_bss));
  
  	      
    /*
--- 328,335 ----
  #ifdef SPARC
    local_bss_counter=(local_bss_counter+7)&(~7);
  #endif
!   COND_MD_NUMBER_TO_CHARS(&the_exec.a_bss,local_bss_counter,
! 			 sizeof(the_exec.a_bss));
  
  	      
    /*
***************
*** 364,372 ****
  	   used instead of 128. */
  		/* JF the \001 bit is to make sure that local labels
  		   ( 1: - 9: don't make it into the symtable either */
  #ifndef	VMS	/* Under VMS we need to keep local symbols */
  	if ( !name || (symbolP->sy_nlist.n_type&N_STAB)
! 	    || (name[0]!='\001' && (flagseen ['L'] || name [0] != 'L' )))
  #endif	/* not VMS */
  	  {
  	    symbolP -> sy_number = symbol_number ++;
--- 386,395 ----
  	   used instead of 128. */
  		/* JF the \001 bit is to make sure that local labels
  		   ( 1: - 9: don't make it into the symtable either */
+ 	/* mb@ttidca.tti.com: the 001 bit is in the 3rd byte, not the 1st! */
  #ifndef	VMS	/* Under VMS we need to keep local symbols */
  	if ( !name || (symbolP->sy_nlist.n_type&N_STAB)
! 	    || (name[2]!='\001' && (flagseen ['L'] || ! LOCAL_LABEL(name) )))
  #endif	/* not VMS */
  	  {
  	    symbolP -> sy_number = symbol_number ++;
***************
*** 388,394 ****
        }				/* for each symbol */
  
      syms_siz = sizeof( struct nlist) * symbol_number;
!     md_number_to_chars((char *)&the_exec.a_syms,syms_siz,sizeof(the_exec.a_syms));
      /* the_exec . a_syms = sizeof( struct nlist) * symbol_number; */
    }
  
--- 411,417 ----
        }				/* for each symbol */
  
      syms_siz = sizeof( struct nlist) * symbol_number;
!     COND_MD_NUMBER_TO_CHARS(&the_exec.a_syms,syms_siz,sizeof(the_exec.a_syms));
      /* the_exec . a_syms = sizeof( struct nlist) * symbol_number; */
    }
  
***************
*** 559,570 ****
      = sizeof(struct relocation_info) * fixup_segment (data_fix_root, N_DATA); */
  
    tr_siz=sizeof(struct relocation_info) * fixup_segment (text_fix_root, N_TEXT);
-   md_number_to_chars((char *)&the_exec.a_trsize, tr_siz ,sizeof(the_exec.a_trsize));
    dr_siz=sizeof(struct relocation_info) * fixup_segment (data_fix_root, N_DATA);
-   md_number_to_chars((char *)&the_exec.a_drsize, dr_siz, sizeof(the_exec.a_drsize));
-   md_number_to_chars((char *)&the_exec.a_magic,omagic,sizeof(the_exec.a_magic));
-   md_number_to_chars((char *)&the_exec.a_entry,0,sizeof(the_exec.a_entry));
  
  #ifdef EXEC_MACHINE_TYPE
    md_number_to_chars((char *)&the_exec.a_machtype, EXEC_MACHINE_TYPE, sizeof(the_exec.a_machtype));
  #endif
--- 582,594 ----
      = sizeof(struct relocation_info) * fixup_segment (data_fix_root, N_DATA); */
  
    tr_siz=sizeof(struct relocation_info) * fixup_segment (text_fix_root, N_TEXT);
    dr_siz=sizeof(struct relocation_info) * fixup_segment (data_fix_root, N_DATA);
  
+   COND_MD_NUMBER_TO_CHARS(&the_exec.a_trsize, tr_siz ,sizeof(the_exec.a_trsize));
+   COND_MD_NUMBER_TO_CHARS(&the_exec.a_drsize, dr_siz, sizeof(the_exec.a_drsize));
+   COND_MD_NUMBER_TO_CHARS(&the_exec.a_magic,omagic,sizeof(the_exec.a_magic));
+   COND_MD_NUMBER_TO_CHARS(&the_exec.a_entry,0,sizeof(the_exec.a_entry));
+ 
  #ifdef EXEC_MACHINE_TYPE
    md_number_to_chars((char *)&the_exec.a_machtype, EXEC_MACHINE_TYPE, sizeof(the_exec.a_machtype));
  #endif
***************
*** 624,632 ****
  
        temp = symbolP -> sy_nlist . n_un . n_name;
        /* JF fix the numbers up. Call by value RULES! */
!       md_number_to_chars((char *)&(symbolP -> sy_nlist  . n_un . n_strx ),symbolP -> sy_name_offset,sizeof(symbolP -> sy_nlist  . n_un . n_strx ));
!       md_number_to_chars((char *)&(symbolP->sy_nlist.n_desc),symbolP->sy_nlist.n_desc,sizeof(symbolP -> sy_nlist  . n_desc));
!       md_number_to_chars((char *)&(symbolP->sy_nlist.n_value),symbolP->sy_nlist.n_value,sizeof(symbolP->sy_nlist.n_value));
        /* symbolP -> sy_nlist  . n_un . n_strx = symbolP -> sy_name_offset; JF replaced by md above */
        if (symbolP -> sy_type == N_UNDF)
  	  symbolP -> sy_type |= N_EXT; /* Any undefined symbols become N_EXT. */
--- 648,662 ----
  
        temp = symbolP -> sy_nlist . n_un . n_name;
        /* JF fix the numbers up. Call by value RULES! */
!       COND_MD_NUMBER_TO_CHARS(&(symbolP -> sy_nlist  . n_un . n_strx ),
! 			     symbolP -> sy_name_offset,
! 			     sizeof(symbolP -> sy_nlist  . n_un . n_strx ));
!       COND_MD_NUMBER_TO_CHARS(&(symbolP->sy_nlist.n_desc),
! 			     symbolP->sy_nlist.n_desc,
! 			     sizeof(symbolP -> sy_nlist  . n_desc));
!       COND_MD_NUMBER_TO_CHARS(&(symbolP->sy_nlist.n_value),
! 			     symbolP->sy_nlist.n_value,
! 			     sizeof(symbolP->sy_nlist.n_value));
        /* symbolP -> sy_nlist  . n_un . n_strx = symbolP -> sy_name_offset; JF replaced by md above */
        if (symbolP -> sy_type == N_UNDF)
  	  symbolP -> sy_type |= N_EXT; /* Any undefined symbols become N_EXT. */
***************
*** 641,647 ****
     * Find strings by crawling along symbol table chain.
     */
  /* Gotta do md_ byte-ordering stuff for string_byte_count first - KWK */
!   md_number_to_chars((char *)&string_byte_count, string_byte_count, sizeof(string_byte_count));
  
    append (& next_object_file_charP, (char *)&string_byte_count, (unsigned long)sizeof(string_byte_count));
    for (   symbolP = symbol_rootP;   symbolP;   symbolP = symbolP -> sy_next   )
--- 671,678 ----
     * Find strings by crawling along symbol table chain.
     */
  /* Gotta do md_ byte-ordering stuff for string_byte_count first - KWK */
!   COND_MD_NUMBER_TO_CHARS(&string_byte_count, string_byte_count,
! 			 sizeof(string_byte_count));
  
    append (& next_object_file_charP, (char *)&string_byte_count, (unsigned long)sizeof(string_byte_count));
    for (   symbolP = symbol_rootP;   symbolP;   symbolP = symbolP -> sy_next   )
***************
*** 655,660 ****
--- 686,701 ----
  
    know( next_object_file_charP == the_object_file + size_of_the_object_file );
  
+   /* warning: COFF_OPTION and MACHO_OPTION are mutually exclusive (but
+      probably don't have to be). */
+ #ifdef COFF_OPTION
+   if (flagseen['C'] == COFF_OPTION )	/* write a.out in COFF format */
+     convert_to_coff (&the_object_file, &size_of_the_object_file);
+ #endif
+ #ifdef MACHO_OPTION
+   if (flagseen['M'] == MACHO_OPTION )	/* write a.out in MACHO format */
+     convert_to_macho (&the_object_file, &size_of_the_object_file);
+ #endif
    output_file_append (the_object_file, size_of_the_object_file, out_file_name);
  
  #ifdef DONTDEF
***************
*** 1203,1209 ****
  	    Thus we need a machine dependent routine to make
  	    sure the structure is written out correctly.  FUN!
  	   */
! 	  md_ri_to_chars((char *) &ri, ri); 
  	  append (&next_object_file_charP, (char *)& ri, (unsigned long)sizeof(ri));
  	}
      }
--- 1244,1251 ----
  	    Thus we need a machine dependent routine to make
  	    sure the structure is written out correctly.  FUN!
  	   */
! 	  if ( ! aout_is_intermediate_only)
!   	    md_ri_to_chars((char *) &ri, ri); 
  	  append (&next_object_file_charP, (char *)& ri, (unsigned long)sizeof(ri));
  	}
      }
