]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: fix size of z80 "add ii,rr" and "ld (ii+d),n" instructions
authorAaron Griffith <aargri@gmail.com>
Mon, 9 Jun 2025 19:19:41 +0000 (15:19 -0400)
committerTom Tromey <tromey@adacore.com>
Wed, 11 Jun 2025 19:36:45 +0000 (13:36 -0600)
The tables in z80-tdep.c previously either gave these instructions the
wrong size, or failed to recognize them by using the wrong masks, or
both. The fixed instructions alongside their representation in octal are:

* add ii,rr:   [0335] 00r1 (where r & 1 == 1)
               [0375] 00r1
* ld (ii+d,n): [0335] 0066 <d> <n>
               [0375] 0066 <d> <n>

Prefix bytes inside [] do not count towards instruction length in
these tables.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33066
Approved-By: Tom Tromey <tom@tromey.com>
gdb/z80-tdep.c

index bfa52dd0df18c51dfbb8aba32853d446b0bdf26a..5fc71fac6d65d9a3b712b59c89376cd2918c7812 100644 (file)
@@ -1331,14 +1331,14 @@ ez80_ddfd_insn_table[] =
   { 0007, 0307, 2, insn_default }, //"ld rr,(ii+d)"
   { 0061, 0377, 2, insn_default }, //"ld ii,(ii+d)"
   /* common instructions */
-  { 0011, 0367, 2, insn_default }, //"add ii,rr"
+  { 0011, 0317, 1, insn_default }, //"add ii,rr"
   { 0041, 0377, 3, insn_default }, //"ld ii,nn"
   { 0042, 0367, 3, insn_default }, //"ld (nn),ii", "ld ii,(nn)"
   { 0043, 0367, 1, insn_default }, //"inc ii", "dec ii"
   { 0044, 0366, 1, insn_default }, //"inc/dec iih/iil"
   { 0046, 0367, 2, insn_default }, //"ld iih,n", "ld iil,n"
   { 0064, 0376, 2, insn_default }, //"inc (ii+d)", "dec (ii+d)"
-  { 0066, 0377, 2, insn_default }, //"ld (ii+d),n"
+  { 0066, 0377, 3, insn_default }, //"ld (ii+d),n"
   { 0166, 0377, 0, insn_default }, //not an instruction
   { 0160, 0370, 2, insn_default }, //"ld (ii+d),r"
   { 0104, 0306, 1, insn_default }, //"ld r,iih", "ld r,iil"
@@ -1360,7 +1360,7 @@ ez80_adl_ddfd_insn_table[] =
 {
   { 0007, 0307, 2, insn_default }, //"ld rr,(ii+d)"
   { 0061, 0377, 2, insn_default }, //"ld ii,(ii+d)"
-  { 0011, 0367, 1, insn_default }, //"add ii,rr"
+  { 0011, 0317, 1, insn_default }, //"add ii,rr"
   { 0041, 0377, 4, insn_default }, //"ld ii,nn"
   { 0042, 0367, 4, insn_default }, //"ld (nn),ii", "ld ii,(nn)"
   { 0043, 0367, 1, insn_default }, //"inc ii", "dec ii"