]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - opcodes/rl78-decode.opc
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / opcodes / rl78-decode.opc
index df4b91c4e6c9ec57c0b4e2b892299493a3624455..5db3081e116de018e633571bfda1803c94a5844d 100644 (file)
@@ -1,9 +1,31 @@
 /* -*- c -*- */
+/* Copyright (C) 2012-2021 Free Software Foundation, Inc.
+   Contributed by Red Hat.
+   Written by DJ Delorie.
+
+   This file is part of the GNU opcodes library.
+
+   This library is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3, or (at your option)
+   any later version.
+
+   It is distributed in the hope that it will be useful, but WITHOUT
+   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+   License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+   MA 02110-1301, USA.  */
+
 #include "sysdep.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include "ansidecl.h"
+#include "bfd.h"
+#include "opintl.h"
 #include "opcode/rl78.h"
 
 static int trace = 0;
@@ -29,7 +51,9 @@ typedef struct
 #define W() rl78->size = RL78_Word
 
 #define AU ATTRIBUTE_UNUSED
-#define GETBYTE() (ld->op [ld->rl78->n_bytes++] = ld->getbyte (ld->ptr))
+
+#define OP_BUF_LEN 20
+#define GETBYTE() (ld->rl78->n_bytes < (OP_BUF_LEN - 1) ? ld->op [ld->rl78->n_bytes++] = ld->getbyte (ld->ptr): 0)
 #define B ((unsigned long) GETBYTE())
 
 #define SYNTAX(x) rl78->syntax = x
@@ -77,7 +101,10 @@ immediate (int bytes, int sign_extend, LocalData * ld)
        i -= 0x1000000;
       break;
     default:
-      fprintf (stderr, "Programmer error: immediate() called with invalid byte count %d\n", bytes);
+      opcodes_error_handler
+       /* xgettext:c-format */
+       (_("internal error: immediate() called with invalid byte count %d"),
+          bytes);
       abort();
     }
   return i;
@@ -143,10 +170,11 @@ int
 rl78_decode_opcode (unsigned long pc AU,
                  RL78_Opcode_Decoded * rl78,
                  int (* getbyte)(void *),
-                 void * ptr)
+                 void * ptr,
+                 RL78_Dis_Isa isa)
 {
   LocalData lds, * ld = &lds;
-  unsigned char op_buf[20] = {0};
+  unsigned char op_buf[OP_BUF_LEN] = {0};
   unsigned char *op = op_buf;
   int op0, op1;
 
@@ -184,9 +212,9 @@ rl78_decode_opcode (unsigned long pc AU,
 /** 0110 0001 1000 000         add     %0, %e1                         */
   ID(add); DR(A); SM2(HL, B, 0); Fzac;
 
-/** 0000 1110                  add     %0, %e                        */
+/** 0000 1110                  add     %0, %ea1                        */
   ID(add); DR(A); SM(HL, IMMU(1)); Fzac;
-  
+
 /** 0110 0001 1000 0010                add     %0, %e1                         */
   ID(add); DR(A); SM2(HL, C, 0); Fzac;
 
@@ -219,7 +247,7 @@ rl78_decode_opcode (unsigned long pc AU,
 /** 0110 0001 1001 0010                addc    %0, %e1                         */
   ID(addc); DR(A); SM2(HL, C, 0); Fzac;
 
-/** 0001 1110                  addc    %0, %e                        */
+/** 0001 1110                  addc    %0, %ea1                        */
   ID(addc); DR(A); SM(HL, IMMU(1)); Fzac;
 
 /** 0001 1100                  addc    %0, #%1                         */
@@ -242,7 +270,7 @@ rl78_decode_opcode (unsigned long pc AU,
 /** 0000 0010                  addw    %0, %e!1                        */
   ID(add); W(); DR(AX); SM(None, IMMU(2)); Fzac;
 
-/** 0110 0001 0000 1001                addw    %0, %e1                 */
+/** 0110 0001 0000 1001                addw    %0, %ea1                        */
   ID(add); W(); DR(AX); SM(HL, IMMU(1)); Fzac;
 
 /** 0000 0100                  addw    %0, #%1                         */
@@ -268,7 +296,7 @@ rl78_decode_opcode (unsigned long pc AU,
 /** 0110 0001 1101 0000                and     %0, %e1                 */
   ID(and); DR(A); SM2(HL, B, 0); Fz;
 
-/** 0101 1110                  and     %0, %e1                 */
+/** 0101 1110                  and     %0, %ea1                        */
   ID(and); DR(A); SM(HL, IMMU(1)); Fz;
 
 /** 0110 0001 1101 0010                and     %0, %e1                 */
@@ -472,7 +500,7 @@ rl78_decode_opcode (unsigned long pc AU,
 /** 0110 0001 1100 0010                cmp     %0, %e1                         */
   ID(cmp); DR(A); SM2(HL, C, 0); Fzac;
 
-/** 0100 1110                  cmp     %0, %e                        */
+/** 0100 1110                  cmp     %0, %ea1                        */
   ID(cmp); DR(A); SM(HL, IMMU(1)); Fzac;
 
 /** 0100 1100                  cmp     %0, #%1                         */
@@ -500,7 +528,7 @@ rl78_decode_opcode (unsigned long pc AU,
 
 /*----------------------------------------------------------------------*/
 
-/** 0110 0001 1101 1110                cmps    %0, %e                        */
+/** 0110 0001 1101 1110                cmps    %0, %ea1                        */
   ID(cmp); DR(X); SM(HL, IMMU(1)); Fzac;
 
 /*----------------------------------------------------------------------*/
@@ -508,7 +536,7 @@ rl78_decode_opcode (unsigned long pc AU,
 /** 0100 0010                  cmpw    %0, %e!1                        */
   ID(cmp); W(); DR(AX); SM(None, IMMU(2)); Fzac;
 
-/** 0110 0001 0100 1001                cmpw    %0, %e                        */
+/** 0110 0001 0100 1001                cmpw    %0, %ea1                        */
   ID(cmp); W(); DR(AX); SM(HL, IMMU(1)); Fzac;
 
 /** 0100 0100                  cmpw    %0, #%1                         */
@@ -525,7 +553,7 @@ rl78_decode_opcode (unsigned long pc AU,
 /** 1011 0000                  dec     %e!0                            */
   ID(sub); DM(None, IMMU(2)); SC(1); Fza;
 
-/** 0110 0001 0110 1001                dec     %e                            */
+/** 0110 0001 0110 1001                dec     %ea0                            */
   ID(sub); DM(HL, IMMU(1)); SC(1); Fza;
 
 /** 1001 0reg                  dec     %0                              */
@@ -539,7 +567,7 @@ rl78_decode_opcode (unsigned long pc AU,
 /** 1011 0010                  decw    %e!0                            */
   ID(sub); W(); DM(None, IMMU(2)); SC(1);
 
-/** 0110 0001 1000 1001                decw    %e                            */
+/** 0110 0001 1000 1001                decw    %ea0                            */
   ID(sub); W(); DM(HL, IMMU(1)); SC(1);
 
 /** 1011 0rg1                  decw    %0                              */
@@ -558,7 +586,7 @@ rl78_decode_opcode (unsigned long pc AU,
 /** 1010 0000                  inc     %e!0                            */
   ID(add); DM(None, IMMU(2)); SC(1); Fza;
 
-/** 0110 0001 0101 1001                inc     %e                            */
+/** 0110 0001 0101 1001                inc     %ea0                            */
   ID(add); DM(HL, IMMU(1)); SC(1); Fza;
 
 /** 1000 0reg                  inc     %0                              */
@@ -572,7 +600,7 @@ rl78_decode_opcode (unsigned long pc AU,
 /** 1010 0010                  incw    %e!0                            */
   ID(add); W(); DM(None, IMMU(2)); SC(1);
 
-/** 0110 0001 0111 1001                incw    %e                            */
+/** 0110 0001 0111 1001                incw    %ea0                            */
   ID(add); W(); DM(HL, IMMU(1)); SC(1);
 
 /** 1010 0rg1                  incw    %0                              */
@@ -589,34 +617,34 @@ rl78_decode_opcode (unsigned long pc AU,
 /** 1001 1111                  mov     %e!0, %1                        */
   ID(mov); DM(None, IMMU(2)); SR(A);
 
-/** 1001 1001                  mov     %e0,%1                          */
+/** 1001 1001                  mov     %e0, %1                         */
   ID(mov); DM(DE, 0); SR(A);
 
-/** 1100 1010                  mov     %e0, #%1                        */
+/** 1100 1010                  mov     %ea0, #%1                       */
   ID(mov); DM(DE, IMMU(1)); SC(IMMU(1));
 
-/** 1001 1010                  mov     %e0, %1                         */
+/** 1001 1010                  mov     %ea0, %1                                */
   ID(mov); DM(DE, IMMU(1)); SR(A);
 
-/** 1001 1011                  mov     %e0,%1                          */
+/** 1001 1011                  mov     %e0, %1                         */
   ID(mov); DM(HL, 0); SR(A);
 
 /** 0110 0001 1101 1001                mov     %e0, %1                         */
   ID(mov); DM2(HL, B, 0); SR(A);
 
-/** 1100 1100                  mov     %e0, #%1                        */
+/** 1100 1100                  mov     %ea0, #%1                       */
   ID(mov); DM(HL, IMMU(1)); SC(IMMU(1));
 
-/** 1001 1100                  mov     %e0, %1                         */
+/** 1001 1100                  mov     %ea0, %1                        */
   ID(mov); DM(HL, IMMU(1)); SR(A);
 
 /** 0110 0001 1111 1001                mov     %e0, %1                         */
   ID(mov); DM2(HL, C, 0); SR(A);
 
-/** 1100 1000                  mov     %0, #%1                         */
+/** 1100 1000                  mov     %a0, #%1                        */
   ID(mov); DM(SP, IMMU(1)); SC(IMMU(1));
 
-/** 1001 1000                  mov     %0, %1                          */
+/** 1001 1000                  mov     %a0, %1                         */
   ID(mov); DM(SP, IMMU(1)); SR(A);
 
 /** 1000 1111                  mov     %0, %e!1                        */
@@ -625,13 +653,13 @@ rl78_decode_opcode (unsigned long pc AU,
 /** 1000 1001                  mov     %0, %e1                         */
   ID(mov); DR(A); SM(DE, 0);
 
-/** 1000 1010                  mov     %0, %e                        */
+/** 1000 1010                  mov     %0, %ea1                        */
   ID(mov); DR(A); SM(DE, IMMU(1));
 
 /** 1000 1011                  mov     %0, %e1                         */
   ID(mov); DR(A); SM(HL, 0);
 
-/** 1000 1100                  mov     %0, %e                        */
+/** 1000 1100                  mov     %0, %ea1                        */
   ID(mov); DR(A); SM(HL, IMMU(1));
 
 /** 0110 0001 1100 1001                mov     %0, %e1                         */
@@ -640,7 +668,7 @@ rl78_decode_opcode (unsigned long pc AU,
 /** 0110 0001 1110 1001                mov     %0, %e1                         */
   ID(mov); DR(A); SM2(HL, C, 0);
 
-/** 1000 1000                  mov     %0, %e                        */
+/** 1000 1000                  mov     %0, %ea1                        */
   ID(mov); DR(A); SM(SP, IMMU(1));
 
 /** 0101 0reg                  mov     %0, #%1                         */
@@ -692,28 +720,28 @@ rl78_decode_opcode (unsigned long pc AU,
   ID(mov); DR(CS); SR(A);
 
 /** 0100 0001                  mov     %0, #%1                         */
-  ID(mov); DR(ES); SC(IMMU(1));        
+  ID(mov); DR(ES); SC(IMMU(1));
 
 /** 1001 1110 1111 1101                mov     %0, %1                          */
-  ID(mov); DR(ES); SR(A);      
+  ID(mov); DR(ES); SR(A);
 
 /** 0110 0001 1011 1000                mov     %0, %1                          */
-  ID(mov); DR(ES); SM(None, SADDR);    
+  ID(mov); DR(ES); SM(None, SADDR);
 
 /** 0001 1001                  mov     %e0, #%1                        */
-  ID(mov); DM(B, IMMU(2)); SC(IMMU(1));        
+  ID(mov); DM(B, IMMU(2)); SC(IMMU(1));
 
 /** 0001 1000                  mov     %e0, %1                         */
-  ID(mov); DM(B, IMMU(2)); SR(A);      
+  ID(mov); DM(B, IMMU(2)); SR(A);
 
 /** 0011 1001                  mov     %e0, #%1                        */
-  ID(mov); DM(BC, IMMU(2)); SC(IMMU(1));       
+  ID(mov); DM(BC, IMMU(2)); SC(IMMU(1));
 
 /** 0100 1000                  mov     %e0, %1                         */
-  ID(mov); DM(BC, IMMU(2)); SR(A);     
+  ID(mov); DM(BC, IMMU(2)); SR(A);
 
 /** 0011 1000                  mov     %e0, #%1                        */
-  ID(mov); DM(C, IMMU(2)); SC(IMMU(1));        
+  ID(mov); DM(C, IMMU(2)); SC(IMMU(1));
 
 /** 0010 1000                  mov     %e0, %1                         */
   ID(mov); DM(C, IMMU(2)); SR(A);
@@ -728,7 +756,7 @@ rl78_decode_opcode (unsigned long pc AU,
   op0 = SFR;
   op1 = IMMU(1);
   ID(mov); DM(None, op0); SC(op1);
-  if (op0 == 0xffffb)
+  if (op0 == 0xffffb && isa == RL78_ISA_G14)
     switch (op1)
       {
       case 0x01:
@@ -741,7 +769,7 @@ rl78_decode_opcode (unsigned long pc AU,
        rl78->syntax = "divhu"; ID(divhu);
        break;
       case 0x04:
-       rl78->syntax = "divwu"; ID(divwu);
+       rl78->syntax = "divwu <old-encoding>"; ID(divwu);
        break;
       case 0x05:
        rl78->syntax = "machu"; ID(machu);
@@ -749,9 +777,12 @@ rl78_decode_opcode (unsigned long pc AU,
       case 0x06:
        rl78->syntax = "mach"; ID(mach);
        break;
+      case 0x0b:
+       rl78->syntax = "divwu"; ID(divwu);
+       break;
       }
 
-/** 1001 1110                  mov     %0, %1                          */
+/** 1001 1110                  mov     %s0, %1                         */
   ID(mov); DM(None, SFR); SR(A);
 
 /*----------------------------------------------------------------------*/
@@ -782,7 +813,7 @@ rl78_decode_opcode (unsigned long pc AU,
 
 /*----------------------------------------------------------------------*/
 
-/** 0110 0001 1100 1110                movs    %e0, %1                         */
+/** 0110 0001 1100 1110                movs    %ea0, %1                        */
   ID(mov); DM(HL, IMMU(1)); SR(X); Fzc;
 
 /*----------------------------------------------------------------------*/
@@ -793,16 +824,16 @@ rl78_decode_opcode (unsigned long pc AU,
 /** 1011 1001                  movw    %e0, %1                         */
   ID(mov); W(); DM(DE, 0); SR(AX);
 
-/** 1011 1010                  movw    %e0, %1                         */
+/** 1011 1010                  movw    %ea0, %1                                */
   ID(mov); W(); DM(DE, IMMU(1)); SR(AX);
 
 /** 1011 1011                  movw    %e0, %1                         */
   ID(mov); W(); DM(HL, 0); SR(AX);
 
-/** 1011 1100                  movw    %e0, %1                         */
+/** 1011 1100                  movw    %ea0, %1                        */
   ID(mov); W(); DM(HL, IMMU(1)); SR(AX);
 
-/** 1011 1000                  movw    %0, %1                          */
+/** 1011 1000                  movw    %a0, %1                         */
   ID(mov); W(); DM(SP, IMMU(1)); SR(AX);
 
 /** 1010 1111                  movw    %0, %e!1                        */
@@ -812,16 +843,16 @@ rl78_decode_opcode (unsigned long pc AU,
 /** 1010 1001                  movw    %0, %e1                         */
   ID(mov); W(); DR(AX); SM(DE, 0);
 
-/** 1010 1010                  movw    %0, %e1                         */
+/** 1010 1010                  movw    %0, %ea1                                */
   ID(mov); W(); DR(AX); SM(DE, IMMU(1));
 
 /** 1010 1011                  movw    %0, %e1                         */
   ID(mov); W(); DR(AX); SM(HL, 0);
 
-/** 1010 1100                  movw    %0, %e                        */
+/** 1010 1100                  movw    %0, %ea1                        */
   ID(mov); W(); DR(AX); SM(HL, IMMU(1));
 
-/** 1010 1000                  movw    %0, %                         */
+/** 1010 1000                  movw    %0, %a1                         */
   ID(mov); W(); DR(AX); SM(SP, IMMU(1));
 
 /** 0011 0rg0                  movw    %0, #%1                         */
@@ -857,7 +888,7 @@ rl78_decode_opcode (unsigned long pc AU,
 /** 1010 1110                  movw    %0, %s1                         */
   ID(mov); W(); DR(AX); SM(None, SFR);
 
-/** 11ra 1011                  movw    %0, %e!1                        */
+/** 11ra 1011                  movw    %0, %es!1                       */
   ID(mov); W(); DRW(ra); SM(None, IMMU(2));
 
 /** 11ra 1010                  movw    %0, %1                          */
@@ -869,10 +900,10 @@ rl78_decode_opcode (unsigned long pc AU,
 /** 1011 1101                  movw    %0, %1                          */
   ID(mov); W(); DM(None, SADDR); SR(AX);
 
-/** 1100 1011                  movw    %0, #%1                         */
+/** 1100 1011                  movw    %s0, #%1                        */
   ID(mov); W(); DM(None, SFR); SC(IMMU(2));
 
-/** 1011 1110                  movw    %0, %1                          */
+/** 1011 1110                  movw    %s0, %1                         */
   ID(mov); W(); DM(None, SFR); SR(AX);
 
 /*----------------------------------------------------------------------*/
@@ -920,7 +951,7 @@ rl78_decode_opcode (unsigned long pc AU,
 /** 0110 0001 1110 0000                or      %0, %e1                         */
   ID(or); DR(A); SM2(HL, B, 0); Fz;
 
-/** 0110 1110                  or      %0, %e                        */
+/** 0110 1110                  or      %0, %ea1                        */
   ID(or); DR(A); SM(HL, IMMU(1)); Fz;
 
 /** 0110 0001 1110 0010                or      %0, %e1                         */
@@ -1099,7 +1130,7 @@ rl78_decode_opcode (unsigned long pc AU,
 /** 0110 0001 1010 000         sub     %0, %e1                         */
   ID(sub); DR(A); SM2(HL, B, 0); Fzac;
 
-/** 0010 1110                  sub     %0, %e                        */
+/** 0010 1110                  sub     %0, %ea1                        */
   ID(sub); DR(A); SM(HL, IMMU(1)); Fzac;
 
 /** 0110 0001 1010 0010                sub     %0, %e1                         */
@@ -1134,7 +1165,7 @@ rl78_decode_opcode (unsigned long pc AU,
 /** 0110 0001 1011 0010                subc    %0, %e1                         */
   ID(subc); DR(A); SM2(HL, C, 0); Fzac;
 
-/** 0011 1110                  subc    %0, %e                        */
+/** 0011 1110                  subc    %0, %ea1                        */
   ID(subc); DR(A); SM(HL, IMMU(1)); Fzac;
 
 /** 0011 1100                  subc    %0, #%1                         */
@@ -1157,7 +1188,7 @@ rl78_decode_opcode (unsigned long pc AU,
 /** 0010 0010                  subw    %0, %e!1                        */
   ID(sub); W(); DR(AX); SM(None, IMMU(2)); Fzac;
 
-/** 0110 0001 0010 1001                subw    %0, %e                        */
+/** 0110 0001 0010 1001                subw    %0, %ea1                        */
   ID(sub); W(); DR(AX); SM(HL, IMMU(1)); Fzac;
 
 /** 0010 0100                  subw    %0, #%1                         */
@@ -1180,7 +1211,7 @@ rl78_decode_opcode (unsigned long pc AU,
 /** 0110 0001 1010 1110                xch     %0, %e1                         */
   ID(xch); DR(A); SM(DE, 0);
 
-/** 0110 0001 1010 1111                xch     %0, %e1                         */
+/** 0110 0001 1010 1111                xch     %0, %ea1                                */
   ID(xch); DR(A); SM(DE, IMMU(1));
 
 /** 0110 0001 1010 1100                xch     %0, %e1                         */
@@ -1189,7 +1220,7 @@ rl78_decode_opcode (unsigned long pc AU,
 /** 0110 0001 1011 1001                xch     %0, %e1                         */
   ID(xch); DR(A); SM2(HL, B, 0);
 
-/** 0110 0001 1010 1101                xch     %0, %e                        */
+/** 0110 0001 1010 1101                xch     %0, %ea1                        */
   ID(xch); DR(A); SM(HL, IMMU(1));
 
 /** 0110 0001 1010 1001                xch     %0, %e1                         */
@@ -1202,7 +1233,7 @@ rl78_decode_opcode (unsigned long pc AU,
 /** 0110 0001 1010 1000                xch     %0, %1                          */
   ID(xch); DR(A); SM(None, SADDR);
 
-/** 0110 0001 1010 1011                xch     %0, %                         */
+/** 0110 0001 1010 1011                xch     %0, %s1                         */
   ID(xch); DR(A); SM(None, SFR);
 
 /** 0000 1000                  xch     a, x                            */
@@ -1224,7 +1255,7 @@ rl78_decode_opcode (unsigned long pc AU,
 /** 0110 0001 1111 0000                xor     %0, %e1                         */
   ID(xor); DR(A); SM2(HL, B, 0); Fz;
 
-/** 0111 1110                  xor     %0, %e                        */
+/** 0111 1110                  xor     %0, %ea1                        */
   ID(xor); DR(A); SM(HL, IMMU(1)); Fz;
 
 /** 0110 0001 1111 0010                xor     %0, %e1                         */