Fix bug in PDP11 assembler when handling a JSr instruction with deferred auto increment.
authorJames Patrick Conlon <cptjustice@gmail.com>
Wed, 1 Aug 2018 14:14:46 +0000 (15:14 +0100)
committerNick Clifton <nickc@redhat.com>
Wed, 1 Aug 2018 14:14:46 +0000 (15:14 +0100)
PR 14480
* config/tc-pdp11.c (parse_op_noreg): Check for and handle auto
increment deferred.
* testsuite/gas/pdp11/pr14480.d: New test driver file.
* testsuite/gas/pdp11/pr14480.s: New test source file file.
* testsuite/gas/pdp11/pdp11.exp: Run the new test.

gas/ChangeLog
gas/config/tc-pdp11.c
gas/testsuite/gas/pdp11/pdp11.exp
gas/testsuite/gas/pdp11/pr14480.d [new file with mode: 0644]
gas/testsuite/gas/pdp11/pr14480.s [new file with mode: 0644]

index 2976c79200f09042de450c2e38ee1638f0470471..4ba57b8ba9ce55584fdf47c1a0a5f63b0c7a43e4 100644 (file)
@@ -1,3 +1,13 @@
+2018-08-01  James Patrick Conlon <cptjustice@gmail.com>
+           Nick Clifton  <nickc@redhat.com>
+
+       PR 14480
+       * config/tc-pdp11.c (parse_op_noreg): Check for and handle auto
+       increment deferred.
+       * testsuite/gas/pdp11/pr14480.d: New test driver file.
+       * testsuite/gas/pdp11/pr14480.s: New test source file file.
+       * testsuite/gas/pdp11/pdp11.exp: Run the new test.
+
 2018-08-01  Nick Clifton  <nickc@redhat.com>
 
        * config/tc-ns32k.c (addr_mode): Replace "Drop through" comment
index 2ad688295851dd6b1550b1fe032a70ac87f98540..e151b274f6c5c8e3fc0b4d7b18c482baad5751a7 100644 (file)
@@ -581,7 +581,21 @@ parse_op_noreg (char *str, struct pdp11_code *operand)
 
   if (*str == '@' || *str == '*')
     {
-      str = parse_op_no_deferred (str + 1, operand);
+      /* @(Rn) == @0(Rn): Mode 7, Indexed deferred.
+        Check for auto-increment deferred.  */
+      if (str[1] == '('
+         && str[2] != 0
+         && str[3] != 0
+         && str[4] != 0
+         && str[5] != '+')
+        {
+         /* Change implied to explicit index deferred.  */
+          *str = '0';
+          str = parse_op_no_deferred (str, operand);
+        }
+      else
+        str = parse_op_no_deferred (str + 1, operand);
+
       if (operand->error)
        return str;
       operand->code |= 010;
index a6dbf88fafeb3a52a24da551ddece29ed4f05fe8..b3609f9ba06efe6129dd93178cb74dfca23ea4b2 100644 (file)
@@ -19,8 +19,7 @@
 #
 
 if [expr [istarget "pdp11-*-*"]]  then {
-
     run_dump_test "opcode"
     run_dump_test "absreloc"
-
+    run_dump_test "pr14480"
 }
diff --git a/gas/testsuite/gas/pdp11/pr14480.d b/gas/testsuite/gas/pdp11/pr14480.d
new file mode 100644 (file)
index 0000000..ca85441
--- /dev/null
@@ -0,0 +1,14 @@
+#name: PR 14480 - correct assembly of 'jsr pc, @(r0)'
+#objdump: -dw
+
+dump.o: +file format .*
+
+Disassembly of section .text:
+
+0+00 <start>:
+[      ]+0:[   ]+15c0 0014[    ]+mov[  ]+\$24, r0
+[      ]+4:[   ]+09c8[         ]+jsr[  ]+pc, \(r0\)
+[      ]+6:[   ]+09f8 0000[    ]+jsr[  ]+pc, \*0\(r0\)
+[      ]+a:[   ]+09f8 0000[    ]+jsr[  ]+pc, \*0\(r0\)
+[      ]+e:[   ]+09f8 0002[    ]+jsr[  ]+pc, \*2\(r0\)
+#pass
diff --git a/gas/testsuite/gas/pdp11/pr14480.s b/gas/testsuite/gas/pdp11/pr14480.s
new file mode 100644 (file)
index 0000000..505ca5d
--- /dev/null
@@ -0,0 +1,17 @@
+start: mov     $ind,r0
+        jsr     pc,(r0)
+       jsr     pc,@(r0)
+       jsr     pc,@0(r0)
+       jsr     pc,@2(r0)
+       halt
+
+
+ind:   .WORD   dest
+       .WORD   dest2
+
+dest:  rts     pc
+
+dest2: rts     pc
+       
+       .END
+