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]

Z80 incorrect opcode emit


Whilst porting some Z80 code over to binutils and doing a sanity check binary 
compare of the original and binutils output, I discovered that for LD A,(BC) 
gas was producing the opcode for LD A,(DE) instead.

It turns out this was a simple one line error, patch supplied below.

Regards,
Chris

--
gas/

2008-08-31  Chris Smith <chris@zxdesign.info>

    * config/tc-z80.c: Opcode generation of ld a,(bc) and ld a,(de) was
    broken, as the opcode of ld a,(de) was being emitted for both.

--- binutils/gas/config/tc-z80.c    3 Jul 2007 11:01:05 -0000   1.7
+++ binutils/gas/config/tc-z80.c    31 Aug 2008 12:17:02 -0000
@@ -1471,7 +1471,7 @@ emit_ldreg (int dest, expressionS * src)
      && (src->X_add_number == REG_BC || src->X_add_number == REG_DE))
    {
      q = frag_more (1);
-     *q = 0x0A + ((dest & 1) << 4);
+     *q = 0x0A + ((src->X_add_number & 1) << 4);
      break;
    }


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