/* m32c.opc --- semantics for m32c opcodes. -*- mode: c -*-
-Copyright (C) 2005, 2007-2012 Free Software Foundation, Inc.
+Copyright (C) 2005-2021 Free Software Foundation, Inc.
Contributed by Red Hat, Inc.
This file is part of the GNU simulators.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* This must come before any other includes. */
+#include "defs.h"
#include <stdio.h>
#include <stdlib.h>
+#include "ansidecl.h"
#include "cpu.h"
#include "mem.h"
#include "misc.h"
#include "int.h"
-#define AU __attribute__((unused))
-
#define tprintf if (trace) printf
static unsigned char
-getbyte ()
+getbyte (void)
{
int tsave = trace;
unsigned char b;
/* Indicate which sorts of prefixes are allowed for the current
opcode. */
-void
-prefix (src_allowed, dest_allowed, index_bytewidth)
+static void
+prefix (int src_allowed, int dest_allowed, int index_bytewidth)
{
/* At the moment, we don't do anything with this information. We
just wanted to get the information entered in some
static int ipcs = 0;
int
-decode_m32c()
+decode_m32c (void)
{
unsigned char op[40];
int opi;
/** 1101 sss1 ss01 1dst MOVA src,dest */
+ {
static reg_id map[8] = { r2r0, r3r1, a0, a1 };
prefix (0, 0, 0);
sc = decode_src23 (sss, ss, 1);
if (!sc.mem || !map[dst])
UNSUPPORTED();
put_reg (map[dst], sc.u.addr);
+ }
/** 0000 0001 1011 ddd0 dd hl 1110 MOVdir R0L,dest */
/** 1000 1110 POPM dest */
+ {
static int map[] = { r0, r1, r2, r3, a0, a1, sb, fb };
prefix (0, 0, 0);
imm = IMM(1);
put_reg (map[a], v);
put_reg (sp, get_reg (sp) + 4);
}
+ }
/** 1010 111w PUSH.size #IMM */
+ {
+ int a;
prefix (0, 0, 0);
imm = IMM(w+1);
tprintf("push%s: %x\n", w ? "hi" : "qi", imm);
- int a = get_reg (sp) - 2;
+ a = get_reg (sp) - 2;
if (w)
mem_put_hi (a, imm);
else
mem_put_qi (a, imm);
put_reg (sp, a);
+ }
/** 1100 sss w ss00 1110 PUSH.size src */
/** 1000 1111 PUSHM src */
+ {
static int map[] = { fb, sb, a1, a0, r3, r2, r1, r0 };
imm = IMM(1);
tprintf("pushm: %x\n", imm);
v = get_reg (map[a]);
mem_put_hi (get_reg (sp), v);
}
+ }
/** 1001 1110 REIT */
/** 1011 1000 010w 0011 RMPA.size */
+ {
int count = get_reg (r3);
int list1 = get_reg (a0);
int list2 = get_reg (a1);
put_reg (a1, list2);
put_reg (r2r0, (int)(sum & 0xffffffffU));
put_reg (r1, (int)(sum >> 32));
+ }
/** 1011 ddd w dd10 1110 ROLC.size dest */