[binutils-gdb] Add support for 8-bit and 24-bit shifts in the z80 assembler.

Nick Clifton nickc@sourceware.org
Mon May 10 12:36:54 GMT 2021


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e4b1ab2062e1d8458167534881248d5555bd82fa

commit e4b1ab2062e1d8458167534881248d5555bd82fa
Author: Sergey Belyashov <sergey.belyashov@gmail.com>
Date:   Mon May 10 13:36:08 2021 +0100

    Add support for 8-bit and 24-bit shifts in the z80 assembler.
    
            PR 27415
            * config/tc-z80.c (emit_data_val): Add support for 8-bit and
            24-bit shifts.
            * testsuite/gas/z80/z80_reloc.a: Update tests.
            * testsuite/gas/z80/z80_reloc.d: Update expected disassembly.

Diff:
---
 gas/ChangeLog                     |  8 ++++++++
 gas/config/tc-z80.c               | 17 +++++++++++++++++
 gas/testsuite/gas/z80/z80_reloc.d |  5 +++++
 gas/testsuite/gas/z80/z80_reloc.s |  7 +++++--
 4 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/gas/ChangeLog b/gas/ChangeLog
index 5892659c905..4b89aae25cc 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,11 @@
+2021-05-10  Sergey Belyashov  <sergey.belyashov@gmail.com>
+
+	PR 27415
+	* config/tc-z80.c (emit_data_val): Add support for 8-bit and
+	24-bit shifts.
+	* testsuite/gas/z80/z80_reloc.a: Update tests.
+	* testsuite/gas/z80/z80_reloc.d: Update expected disassembly.
+
 2021-05-08  Mike Frysinger  <vapier@gentoo.org>
 
 	* doc/Makefile.am (html-local, as/index.html): New targets.
diff --git a/gas/config/tc-z80.c b/gas/config/tc-z80.c
index e9c664db63e..b43a34f3dfb 100644
--- a/gas/config/tc-z80.c
+++ b/gas/config/tc-z80.c
@@ -1177,6 +1177,23 @@ emit_data_val (expressionS * val, int size)
 	    {
 	    case 0: r_type = BFD_RELOC_Z80_WORD0; break;
 	    case 16: r_type = BFD_RELOC_Z80_WORD1; break;
+	    case 8:
+	    case 24: /* add two byte fixups */
+	      val->X_op = O_symbol;
+	      val->X_op_symbol = NULL;
+	      val->X_add_number = 0;
+	      if (shift == 8)
+		{
+		  fix_new_exp (frag_now, p++ - frag_now->fr_literal, 1, val, false,
+			       BFD_RELOC_Z80_BYTE1);
+		  /* prepare to next byte */
+		  r_type = BFD_RELOC_Z80_BYTE2;
+		}
+	      else
+		r_type = BFD_RELOC_Z80_BYTE3; /* high byte will be 0 */
+	      size = 1;
+	      simplify = false;
+	      break;
 	    default: simplify = false;
 	    }
 	}
diff --git a/gas/testsuite/gas/z80/z80_reloc.d b/gas/testsuite/gas/z80/z80_reloc.d
index 7a17617ebac..8ca3b52dedd 100644
--- a/gas/testsuite/gas/z80/z80_reloc.d
+++ b/gas/testsuite/gas/z80/z80_reloc.d
@@ -24,4 +24,9 @@ OFFSET[   ]+TYPE[              ]+VALUE\s*
 0000002a[ ]+r_byte1[           ]+data16
 0000002b[ ]+r_word0[           ]+data32
 0000002d[ ]+r_word1[           ]+data32
+0000002f[ ]+r_byte3[           ]+data32
+00000031[ ]+r_byte1[           ]+data24
+00000032[ ]+r_byte2[           ]+data24
+00000033[ ]+r_byte1[           ]+data32
+00000034[ ]+r_byte2[           ]+data32
 #pass
diff --git a/gas/testsuite/gas/z80/z80_reloc.s b/gas/testsuite/gas/z80/z80_reloc.s
index 52d0335365e..0b75c55bb18 100644
--- a/gas/testsuite/gas/z80/z80_reloc.s
+++ b/gas/testsuite/gas/z80/z80_reloc.s
@@ -25,10 +25,13 @@
 .L_label:
 	.db	data8
 	.dw	data16
-	.d24 data24
-	.d32 data32
+	.d24	data24
+	.d32	data32
 	.db	data16 & 0xff
 	.db	data16 >> 8
 	.dw	data32 & 0xffff
 	.dw	data32 >> 16
+	.dw	data32 >> 24
+	.dw	data24 >> 8
+	.dw	data32 >> 8
 	.end


More information about the Binutils-cvs mailing list