This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] add target z80 to gas


Hello,

Here is a a patch and some new files to support the Z80 cpu with 
gas. I volunteer to be the maintainer.

Note that the patch in 
http://sourceware.org/ml/binutils/2005-10/msg00245.html
is needed to make it pass the "macros dot" test.

Kind regards,
Arnold Metselaar

ChangeLog:

* Makefile.am: Add Z80 cpu.
* Makefile.in: Regenerated.
* Makefile: Regenerated.
* app.c (do_scrub_chars)<TC_Z80>: Correctly scrub "ex af,af'" 
and disallow newlines in quoted strings.
* configure.tgt: Add z80-*-coff.
* expr.c (integer_constant)<TC_Z80>: Use 'B' as suffix for 
binary numbers and 'b' for backreferences.
* expr.c (op_encoding)<TC_Z80>: Allow a single '=' as comparison 
operator.
* config/obj-coff.h: Add format "coff-z80".
* doc/Makefile.am: Add c-z80.texi.
* doc/Makefile.in: Regenerated.
* doc/all.texi: Add Z80.
* doc/as.texinfo: Add z80 options and some z80-related remarks.
* testsuite/gas/all/gas.exp: Exclude Z80-*-* from floating 
point, string, and cofftag test.
* testsuite/gas/macros/macros.exp: Expect z80-*-* to fail the 
strings test because it has no string escapes.
* config/tc-z80.c: New file
* config/tc-z80.h: New file
* doc/c-z80.texi: New file
* testsuite/gas/z80/quotes.d: New file
* testsuite/gas/z80/quotes.s: New file
* testsuite/gas/z80/redef.d: New file
* testsuite/gas/z80/redef.s: New file
* testsuite/gas/z80/z80.exp: New file

Index: Makefile.am
===================================================================
RCS file: /cvs/src/src/gas/Makefile.am,v
retrieving revision 1.122
diff -u -p -r1.122 Makefile.am
--- Makefile.am	18 Oct 2005 16:10:59 -0000	1.122
+++ Makefile.am	21 Oct 2005 13:14:06 -0000
@@ -88,6 +88,7 @@ CPU_TYPES = \
 	v850 \
 	xstormy16 \
 	xtensa \
+	z80 \
 	z8k
 
 # Object format types.  This is only used for dependency information.
@@ -270,6 +271,7 @@ TARGET_CPU_CFILES = \
 	config/tc-v850.c \
 	config/tc-xstormy16.c \
 	config/tc-xtensa.c \
+	config/tc-z80.c \
 	config/tc-z8k.c
 
 TARGET_CPU_HFILES = \
@@ -319,6 +321,7 @@ TARGET_CPU_HFILES = \
 	config/tc-v850.h \
 	config/tc-xstormy16.h \
 	config/tc-xtensa.h \
+	config/tc-z80.h \
 	config/tc-z8k.h
 
 # OBJ files in config
Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gas/Makefile.in,v
retrieving revision 1.133
diff -u -p -r1.133 Makefile.in
--- Makefile.in	18 Oct 2005 16:10:59 -0000	1.133
+++ Makefile.in	21 Oct 2005 13:14:12 -0000
@@ -318,6 +318,7 @@ CPU_TYPES = \
 	v850 \
 	xstormy16 \
 	xtensa \
+	z80 \
 	z8k
 
 
@@ -498,6 +499,7 @@ TARGET_CPU_CFILES = \
 	config/tc-v850.c \
 	config/tc-xstormy16.c \
 	config/tc-xtensa.c \
+	config/tc-z80.c \
 	config/tc-z8k.c
 
 TARGET_CPU_HFILES = \
@@ -547,6 +549,7 @@ TARGET_CPU_HFILES = \
 	config/tc-v850.h \
 	config/tc-xstormy16.h \
 	config/tc-xtensa.h \
+	config/tc-z80.h \
 	config/tc-z8k.h
 
 
Index: app.c
===================================================================
RCS file: /cvs/src/src/gas/app.c,v
retrieving revision 1.32
diff -u -p -r1.32 app.c
--- app.c	29 Sep 2005 02:20:50 -0000	1.32
+++ app.c	21 Oct 2005 13:14:13 -0000
@@ -376,7 +376,11 @@ do_scrub_chars (int (*get) (char *, int)
 	 15: After seeing a `(' at state 1, looking for a `)' as
 	     predicate.
 #endif
-	  */
+#ifdef TC_Z80
+	 16: After seeing an 'a' or an 'A' at the start of a symbol
+	 17: After seeing an 'f' or an 'F' in state 16
+#endif
+  */
 
   /* I added states 9 and 10 because the MIPS ECOFF assembler uses
      constructs like ``.loc 1 20''.  This was turning into ``.loc
@@ -555,6 +559,17 @@ do_scrub_chars (int (*get) (char *, int)
 	  }
 
 	  ch = GET ();
+
+#ifdef TC_Z80
+	  if (ch == '\n' || ch == EOF)
+	    {
+	      state = old_state;
+	      UNGET ('\n');
+	      as_warn (_("end of %s in string; inserted '%c'"),
+		       (ch == EOF) ? "file" : "line" ,quotechar);
+	      PUT (quotechar);
+	    }
+#else
 	  if (ch == EOF)
 	    {
 	      as_warn (_("end of file in string; '%c' inserted"), quotechar);
@@ -562,6 +577,7 @@ do_scrub_chars (int (*get) (char *, int)
 	      UNGET ('\n');
 	      PUT (quotechar);
 	    }
+#endif
 	  else if (ch == quotechar)
 	    {
 	      state = old_state;
@@ -665,6 +681,31 @@ do_scrub_chars (int (*get) (char *, int)
 	  PUT ('|');
 	  continue;
 #endif
+#ifdef TC_Z80
+	case 16:
+	  /* we have seen an 'a' at the start of a symbol, look for an 'f' */
+	  ch = GET ();
+	  if (ch == 'f' || ch == 'F') 
+	    {
+	      state = 17;
+	      PUT (ch);
+	    }
+	  else
+	    {
+	      state = 9;
+	      break;
+	    }
+	case 17:
+	  /* we have seen "af" at the start of a symbol,
+	     a '\'' here is a part of that symbol */
+	  ch = GET ();
+	  state = 9;
+	  if (ch == '\'')
+	    PUT ('`'); /* change to avoid warning about unclosed string */
+	  else
+	    UNGET (ch);
+	  break;
+#endif
 	}
 
       /* OK, we are somewhere in states 0 through 4 or 9 through 11.  */
@@ -1241,6 +1282,30 @@ do_scrub_chars (int (*get) (char *, int)
 	      PUT (' ');
 	      break;
 	    }
+#ifdef TC_Z80
+	  /* "af'" is a symbol containing '\'' */
+	  if (state == 3 && (ch=='a' || ch=='A')) 
+	    {
+	      state = 16;
+	      PUT (ch);
+	      ch = GET ();
+	      if (ch=='f' || ch=='F') 
+		{
+		  state = 17;
+		  PUT (ch);
+		  break;
+		}
+	      else
+		{
+		  state = 9;
+		  if (!IS_SYMBOL_COMPONENT (ch)) 
+		    {
+		      UNGET (ch);
+		      break;
+		    }
+		}
+	    }
+#endif
 
 	  if (state == 3)
 	    state = 9;
Index: configure.tgt
===================================================================
RCS file: /cvs/src/src/gas/configure.tgt,v
retrieving revision 1.19
diff -u -p -r1.19 configure.tgt
--- configure.tgt	30 Sep 2005 15:05:04 -0000	1.19
+++ configure.tgt	21 Oct 2005 13:14:14 -0000
@@ -377,6 +377,8 @@ case ${generic_target} in
 
   z8k-*-coff | z8k-*-sim)		fmt=coff ;;
 
+  z80-*-coff)				fmt=coff ;;
+
   *-*-aout | *-*-scout)			fmt=aout ;;
   *-*-freebsd* | *-*-kfreebsd*-gnu)	fmt=elf em=freebsd ;;
   *-*-bsd*)				fmt=aout em=sun3 ;;
@@ -390,7 +392,7 @@ case ${generic_target} in
 esac
 
 case ${cpu_type} in
-  alpha | arm | i386 | ia64 | mips | ns32k | pdp11 | ppc | sparc | z8k)
+  alpha | arm | i386 | ia64 | mips | ns32k | pdp11 | ppc | sparc | z80 | z8k)
     bfd_gas=yes
     ;;
 esac
Index: expr.c
===================================================================
RCS file: /cvs/src/src/gas/expr.c,v
retrieving revision 1.60
diff -u -p -r1.60 expr.c
--- expr.c	11 Oct 2005 11:16:16 -0000	1.60
+++ expr.c	21 Oct 2005 13:14:16 -0000
@@ -300,6 +300,11 @@ integer_constant (int radix, expressionS
       else
 	{
 	  c = *--suffix;
+#ifdef TC_Z80
+	  /* On Z80 suffix 'b' means a backward reference and 
+	     suffix 'B' means a binary number.  */
+	  if (c != 'b')
+#endif
 	  c = TOUPPER (c);
 	  if (c == 'B')
 	    radix = 2;
@@ -822,7 +827,13 @@ operand (expressionS *expressionP, enum 
 	  break;
 
 	case 'b':
-	  if (LOCAL_LABELS_FB && ! (flag_m68k_mri || NUMBERS_WITH_SUFFIX))
+	  /* On Z80 suffix 'b' means a backward reference and 
+	     suffix 'B' means a binary number.  */
+	  if (LOCAL_LABELS_FB
+#ifndef TC_Z80 
+	      && !(flag_m68k_mri || NUMBERS_WITH_SUFFIX)
+#endif
+	      )
 	    {
 	      /* This code used to check for '+' and '-' here, and, in
 		 some conditions, fall through to call
@@ -1092,10 +1103,14 @@ operand (expressionS *expressionP, enum 
       if (! flag_m68k_mri)
 	goto de_fault;
 #endif
-      if (flag_m68k_mri && hex_p (*input_line_pointer))
+      if (
+#ifndef TC_Z80 
+	  flag_m68k_mri &&
+#endif
+	  hex_p (*input_line_pointer))
 	{
-	  /* In MRI mode, '$' is also used as the prefix for a
-	     hexadecimal constant.  */
+	  /* In MRI mode and on Z80, '$' is also used as the prefix
+	     for a hexadecimal constant.  */
 	  integer_constant (16, expressionP);
 	  break;
 	}
@@ -1396,7 +1411,13 @@ static const operatorT op_encoding[256] 
   __, O_bit_or_not, __, __, __, O_modulus, O_bit_and, __,
   __, __, O_multiply, O_add, __, O_subtract, __, O_divide,
   __, __, __, __, __, __, __, __,
-  __, __, __, __, O_lt, __, O_gt, __,
+  __, __, __, __, O_lt,
+#ifdef TC_Z80
+  O_eq, /* We allow "=" in stead of "==" on Z80 */ 
+#else
+  __,
+#endif
+  O_gt, __,
   __, __, __, __, __, __, __, __,
   __, __, __, __, __, __, __, __,
   __, __, __, __, __, __, __, __,
Index: config/obj-coff.h
===================================================================
RCS file: /cvs/src/src/gas/config/obj-coff.h,v
retrieving revision 1.31
diff -u -p -r1.31 obj-coff.h
--- config/obj-coff.h	11 Aug 2005 01:25:24 -0000	1.31
+++ config/obj-coff.h	21 Oct 2005 13:14:18 -0000
@@ -85,6 +85,11 @@
 #define TARGET_FORMAT "coff-Intel-little"
 #endif
 
+#ifdef TC_Z80
+#include "coff/z80.h"
+#define TARGET_FORMAT "coff-z80"
+#endif
+
 #ifdef TC_Z8K
 #include "coff/z8k.h"
 #define TARGET_FORMAT "coff-z8k"
Index: doc/Makefile.am
===================================================================
RCS file: /cvs/src/src/gas/doc/Makefile.am,v
retrieving revision 1.36
diff -u -p -r1.36 Makefile.am
--- doc/Makefile.am	30 Sep 2005 15:05:07 -0000	1.36
+++ doc/Makefile.am	21 Oct 2005 13:14:20 -0000
@@ -55,6 +55,7 @@ CPU_DOCS = \
 	c-vax.texi \
 	c-v850.texi \
 	c-xtensa.texi \
+	c-z80.texi \
 	c-z8k.texi
 
 gasver.texi: $(srcdir)/../../bfd/configure
Index: doc/Makefile.in
===================================================================
RCS file: /cvs/src/src/gas/doc/Makefile.in,v
retrieving revision 1.69
diff -u -p -r1.69 Makefile.in
--- doc/Makefile.in	30 Sep 2005 15:05:07 -0000	1.69
+++ doc/Makefile.in	21 Oct 2005 13:14:21 -0000
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.2 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -246,6 +246,7 @@ CPU_DOCS = \
 	c-vax.texi \
 	c-v850.texi \
 	c-xtensa.texi \
+	c-z80.texi \
 	c-z8k.texi
 
 
@@ -347,7 +348,7 @@ as.html: as.texinfo 
 	$(DVIPS) -o $@ $<
 
 uninstall-info-am:
-	$(PRE_UNINSTALL)
+	@$(PRE_UNINSTALL)
 	@if (install-info --version && \
 	     install-info --version 2>&1 | sed 1q | grep -i -v debian) >/dev/null 2>&1; then \
 	  list='$(INFO_DEPS)'; \
@@ -363,7 +364,7 @@ uninstall-info-am:
 	  relfile=`echo "$$file" | sed 's|^.*/||'`; \
 	  relfile_i=`echo "$$relfile" | sed 's|\.info$$||;s|$$|.i|'`; \
 	  (if cd "$(DESTDIR)$(infodir)"; then \
-	     echo " rm -f $$relfile $$relfile-[0-9] $$relfile-[0-9][0-9] $$relfile_i[0-9] $$relfile_i[0-9][0-9])"; \
+	     echo " cd '$(DESTDIR)$(infodir)' && rm -f $$relfile $$relfile-[0-9] $$relfile-[0-9][0-9] $$relfile_i[0-9] $$relfile_i[0-9][0-9]"; \
 	     rm -f $$relfile $$relfile-[0-9] $$relfile-[0-9][0-9] $$relfile_i[0-9] $$relfile_i[0-9][0-9]; \
 	   else :; fi); \
 	done
Index: doc/all.texi
===================================================================
RCS file: /cvs/src/src/gas/doc/all.texi,v
retrieving revision 1.22
diff -u -p -r1.22 all.texi
--- doc/all.texi	30 Sep 2005 15:05:07 -0000	1.22
+++ doc/all.texi	21 Oct 2005 13:14:21 -0000
@@ -58,6 +58,7 @@
 @set V850
 @set VAX
 @set XTENSA
+@set Z80
 @set Z8000
 
 @c Does this version of the assembler use the difference-table kluge?
Index: doc/as.texinfo
===================================================================
RCS file: /cvs/src/src/gas/doc/as.texinfo,v
retrieving revision 1.135
diff -u -p -r1.135 as.texinfo
--- doc/as.texinfo	18 Oct 2005 07:47:01 -0000	1.135
+++ doc/as.texinfo	21 Oct 2005 13:14:30 -0000
@@ -420,6 +420,17 @@ gcc(1), ld(1), and the Info entries for 
  [@b{-mcpu=54[123589]}|@b{-mcpu=54[56]lp}] [@b{-mfar-mode}|@b{-mf}] 
  [@b{-merrors-to-file} @var{<filename>}|@b{-me} @var{<filename>}]
 @end ifset
+@ifset Z80
+
+@emph{Target Z80 options:}
+  [@b{-z80}] [@b{-r800}]
+  [@b{ -ignore-undocumented-instructions}] [@b{-Wnud}]
+  [@b{ -ignore-unportable-instructions}] [@b{-Wnup}]
+  [@b{ -warn-undocumented-instructions}] [@b{-Wud}]
+  [@b{ -warn-unportable-instructions}] [@b{-Wup}]
+  [@b{ -forbid-undocumented-instructions}] [@b{-Fud}]
+  [@b{ -forbid-unportable-instructions}] [@b{-Fup}]
+@end ifset
 @ifset Z8000
 @c Z8000 has no machine-dependent assembler options
 @end ifset
@@ -1138,6 +1149,35 @@ instructions must be exactly as specifie
 @end table
 @end ifset
 
+@ifset Z80
+The following options are available when @value{AS} is configured for
+a Z80 family processor.
+@table @gcctabopt
+@item -z80
+Assemble for Z80 processor.
+@item -r800
+Assemble for R800 processor.
+@item  -ignore-undocumented-instructions 
+@itemx -Wnud
+Assemble undocumented Z80 instructions that also work on R800 without warning.
+@item  -ignore-unportable-instructions 
+@itemx -Wnup
+Assemble all undocumented Z80 instructions without warning.
+@item  -warn-undocumented-instructions 
+@itemx -Wud
+Issue a warning for undocumented Z80 instructions that also work on R800.
+@item  -warn-unportable-instructions 
+@itemx -Wup
+Issue a warning for undocumented Z80 instructions that do notwork on R800.  
+@item  -forbid-undocumented-instructions 
+@itemx -Fud
+Treat all undocumented instructions as errors.
+@item  -forbid-unportable-instructions 
+@itemx -Fup
+Treat undocumented Z80 intructions that do notwork on R800 as errors.
+@end table
+@end ifset
+
 @c man end
 
 @menu
@@ -2130,6 +2170,9 @@ is considered a comment and is ignored. 
 @ifset VAX
 @samp{#} on the Vax;
 @end ifset
+@ifset Z80
+@samp{;} for the Z80;
+@end ifset
 @ifset Z8000
 @samp{!} for the Z8000;
 @end ifset
@@ -4271,6 +4314,13 @@ The syntax for @code{equ} on the HPPA is
 @samp{@var{symbol} .equ @var{expression}}.
 @end ifset
 
+@ifset Z80
+The syntax for @code{equ} on the Z80 is 
+@samp{@var{symbol} equ @var{expression}}. 
+On the Z80 it is an eror if @var{symbol} is already defined,
+compare @xref{Equiv}.
+@end ifset
+
 @node Equiv
 @section @code{.equiv @var{symbol}, @var{expression}}
 @cindex @code{equiv} directive
@@ -5511,6 +5561,11 @@ The syntax for @code{set} on the HPPA is
 @samp{@var{symbol} .set @var{expression}}.
 @end ifset
 
+@ifset Z80
+On Z80 @code{set} is a real instruction, use
+@samp{@var{symbol} defl @var{expression}} instead.
+@end ifset
+
 @node Short
 @section @code{.short @var{expressions}}
 
@@ -6176,6 +6231,9 @@ subject, see the hardware manufacturer's
 @ifset XTENSA
 * Xtensa-Dependent::            Xtensa Dependent Features
 @end ifset
+@ifset Z80
+* Z80-Dependent::               Z80 Dependent Features
+@end ifset
 @ifset Z8000
 * Z8000-Dependent::             Z8000 Dependent Features
 @end ifset
@@ -6330,6 +6388,10 @@ family.
 @include c-tic54x.texi
 @end ifset
 
+@ifset Z80
+@include c-z80.texi
+@end ifset
+
 @ifset Z8000
 @include c-z8k.texi
 @end ifset
Index: testsuite/gas/all/gas.exp
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/all/gas.exp,v
retrieving revision 1.30
diff -u -p -r1.30 gas.exp
--- testsuite/gas/all/gas.exp	11 Oct 2005 11:16:17 -0000	1.30
+++ testsuite/gas/all/gas.exp	21 Oct 2005 13:14:30 -0000
@@ -23,8 +23,9 @@ if { [istarget hppa*-*-*] || [istarget *
     gas_test "p1480.s" "" "-a>" "simplifiable double subtraction"
 }
 
-# No floating point support in assembly code for CRIS.
-if { ![istarget cris-*-*] && ![istarget crisv32-*-*] } then {
+# No floating point support in assembly code for CRIS and Z80.
+if { ![istarget cris-*-*] && ![istarget crisv32-*-*] 
+     && ![istarget z80-*-*] } then {
     gas_test "float.s" ""   "" "simple FP constants"
 }
 
@@ -78,6 +79,7 @@ case $target_triplet in {
     { iq2000*-*-* } { }
     { mips*-*-* } { }
     { *c54x*-*-* } { }
+    { z80-*-* } { }
     default {
 	setup_xfail "*c30*-*-*" "*c4x*-*-*" "pdp11-*-*"
 	run_dump_test redef
@@ -189,7 +191,8 @@ case $target_triplet in {
 # We omit the ARM toolchains because they define locals to
 #  start with '.', which eliminates .eos, .text etc from the output.
 # Omit c54x, since .tag and .def mean something different on that target
-if {   ([istarget *-*-coff*] && ![istarget *arm*-*-coff] && ![istarget thumb*-*-coff] && ![istarget xscale-*-coff] && ![istarget *c4x*-*-coff] && ![istarget *c54x*-*-coff]) \
+# Omit Z80, since octal numbers need a suffix on that target
+if {   ([istarget *-*-coff*] && ![istarget *arm*-*-coff] && ![istarget thumb*-*-coff] && ![istarget xscale-*-coff] && ![istarget *c4x*-*-coff] && ![istarget *c54x*-*-coff] && ![istarget z80-*-coff]) \
      ||([istarget *-*-pe*] && ![istarget arm*-*-pe*] && ![istarget thumb*-*-pe*]) \
      || [istarget i*86-*-aix*] \
      || [istarget i*86-*-sco*] \
Index: testsuite/gas/macros/macros.exp
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/macros/macros.exp,v
retrieving revision 1.24
diff -u -p -r1.24 macros.exp
--- testsuite/gas/macros/macros.exp	6 May 2005 06:50:31 -0000	1.24
+++ testsuite/gas/macros/macros.exp	21 Oct 2005 13:14:33 -0000
@@ -56,6 +56,7 @@ if { ![istarget hppa*-*-*] || [istarget 
     setup_xfail "powerpc*-*-aix*" "powerpc*-*-beos*" "powerpc*-*-macos*"
     setup_xfail "powerpc*-*-pe" "powerpc*-*-*win*"
     setup_xfail "rs6000-*-*"
+    setup_xfail "z80-*-*"
 
     # FIXME: Due to difference in what "consecutive octets" means.
     setup_xfail "*c4x*-*-*" "*c54x*-*"

Attachment: addz80.gas.tgz
Description: application/tgz


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]