Ghidra is a software reverse engineering (SRE) framework
Moved SuperH4 processor for release.
ghidorahrex864235ee7d95
diff --git a/Ghidra/Processors/SuperH4/Module.manifest b/Ghidra/Processors/SuperH4/Module.manifestnew file mode 100644index 0000000000..e69de29bb2diff --git a/Ghidra/Processors/SuperH4/build.gradle b/Ghidra/Processors/SuperH4/build.gradlenew file mode 100644index 0000000000..c8c9ab6cbd--- /dev/null+++ b/Ghidra/Processors/SuperH4/build.gradle@@ -0,0 +1,11 @@+apply from: "$rootProject.projectDir/gradle/distributableGhidraModule.gradle"+apply from: "$rootProject.projectDir/gradle/javaProject.gradle"+apply from: "$rootProject.projectDir/gradle/jacocoProject.gradle"+apply from: "$rootProject.projectDir/gradle/javaTestProject.gradle"+apply from: "$rootProject.projectDir/gradle/processorProject.gradle"+apply plugin: 'eclipse'+eclipse.project.name = 'Processors SuperH4'++dependencies {+ compile project(':Base')+}\ No newline at end of filediff --git a/Ghidra/Processors/SuperH4/certification.manifest b/Ghidra/Processors/SuperH4/certification.manifestnew file mode 100644index 0000000000..915d68d36f--- /dev/null+++ b/Ghidra/Processors/SuperH4/certification.manifest@@ -0,0 +1,19 @@+##VERSION: 2.0+.project||GHIDRA||||END|+Module.manifest||GHIDRA||||END|+build.gradle||GHIDRA||||END|+data/build.xml||GHIDRA||||END|+data/languages/SuperH4.cspec||GHIDRA||||END|+data/languages/SuperH4.ldefs||GHIDRA||||END|+data/languages/SuperH4.opinion||GHIDRA||||END|+data/languages/SuperH4.pspec||GHIDRA||||END|+data/languages/SuperH4.sinc||GHIDRA||||END|+data/languages/SuperH4_be.slaspec||GHIDRA||||END|+data/languages/SuperH4_le.slaspec||GHIDRA||||END|+data/languages/old/SuperH4-BE-16.lang||GHIDRA||||END|+data/languages/old/SuperH4-BE-16.trans||GHIDRA||||END|+data/languages/old/SuperH4-LE-16.lang||GHIDRA||||END|+data/languages/old/SuperH4-LE-16.trans||GHIDRA||||END|+data/manuals/superh4.idx||GHIDRA||||END|+data/patterns/SuperH4_patterns.xml||GHIDRA||||END|+data/patterns/patternconstraints.xml||GHIDRA||||END|diff --git a/Ghidra/Processors/SuperH4/data/languages/SuperH4.cspec b/Ghidra/Processors/SuperH4/data/languages/SuperH4.cspecnew file mode 100644index 0000000000..31ac4b892e--- /dev/null+++ b/Ghidra/Processors/SuperH4/data/languages/SuperH4.cspec@@ -0,0 +1,212 @@+<?xml version="1.0" encoding="UTF-8"?>++<compiler_spec>+ <data_organization>+ <absolute_max_alignment value="0" />+ <machine_alignment value="2" />+ <default_alignment value="1" />+ <default_pointer_alignment value="4" />+ <pointer_size value="4" />+ <wchar_size value="4" />+ <short_size value="2" />+ <integer_size value="4" />+ <long_size value="4" />+ <float_size value="4" />+ <double_size value="8" />+ <size_alignment_map>+ <entry size="1" alignment="1" />+ <entry size="2" alignment="2" />+ <entry size="4" alignment="4" />+ <entry size="8" alignment="4" />+ </size_alignment_map>+ </data_organization>+ <global>+ <range space="ram"/>+ </global>+ <stackpointer register="r15" space="ram" growth="negative"/>+ <default_proto>+ <prototype name="__stdcall" extrapop="0" stackshift="0" strategy="register">+ <input>+ <pentry minsize="1" maxsize="4">+ <register name="r4"/>+ </pentry>+ <pentry minsize="1" maxsize="4">+ <register name="r5"/>+ </pentry>+ <pentry minsize="1" maxsize="4">+ <register name="r6"/>+ </pentry>+ <pentry minsize="1" maxsize="4">+ <register name="r7"/>+ </pentry>+ <pentry minsize="1" maxsize="4">+ <register name="fr4"/>+ </pentry>+ <pentry minsize="1" maxsize="4">+ <register name="fr5"/>+ </pentry>+ <pentry minsize="1" maxsize="4">+ <register name="fr6"/>+ </pentry>+ <pentry minsize="1" maxsize="4">+ <register name="fr7"/>+ </pentry>+ <pentry minsize="1" maxsize="4">+ <register name="dr4"/>+ </pentry>+ <pentry minsize="1" maxsize="4">+ <register name="dr6"/>+ </pentry>+ <pentry minsize="1" maxsize="4">+ <register name="dr8"/>+ </pentry>+ <pentry minsize="1" maxsize="4">+ <register name="dr10"/>+ </pentry>+ <pentry minsize="1" maxsize="500" align="4">+ <addr offset="0" space="stack"/>+ </pentry>+ </input>+ <output>+ <pentry minsize="1" maxsize="4">+ <register name="r0"/>+ </pentry>+ </output>+ <unaffected>+ <register name="r15"/>+ <register name="r14"/>+ <register name="r13"/>+ <register name="r12"/>+ <register name="r11"/>+ <register name="r10"/>+ <register name="r9"/>+ <register name="r8"/>+ </unaffected>+ <killedbycall>+ <register name="r0"/>+ </killedbycall>+ </prototype>+ </default_proto>+ <prototype name="__floatret" extrapop="0" stackshift="0" strategy="register">+ <input>+ <pentry minsize="1" maxsize="4">+ <register name="r4"/>+ </pentry>+ <pentry minsize="1" maxsize="4">+ <register name="r5"/>+ </pentry>+ <pentry minsize="1" maxsize="4">+ <register name="r6"/>+ </pentry>+ <pentry minsize="1" maxsize="4">+ <register name="r7"/>+ </pentry>+ <pentry minsize="1" maxsize="4">+ <register name="fr4"/>+ </pentry>+ <pentry minsize="1" maxsize="4">+ <register name="fr5"/>+ </pentry>+ <pentry minsize="1" maxsize="4">+ <register name="fr6"/>+ </pentry>+ <pentry minsize="1" maxsize="4">+ <register name="fr7"/>+ </pentry>+ <pentry minsize="1" maxsize="4">+ <register name="dr4"/>+ </pentry>+ <pentry minsize="1" maxsize="4">+ <register name="dr6"/>+ </pentry>+ <pentry minsize="1" maxsize="4">+ <register name="dr8"/>+ </pentry>+ <pentry minsize="1" maxsize="4">+ <register name="dr10"/>+ </pentry>+ <pentry minsize="1" maxsize="500" align="4">+ <addr offset="0" space="stack"/>+ </pentry>+ </input>+ <output>+ <pentry minsize="1" maxsize="4">+ <register name="fr0"/>+ </pentry>+ </output>+ <unaffected>+ <register name="r15"/>+ <register name="r14"/>+ <register name="r13"/>+ <register name="r12"/>+ <register name="r11"/>+ <register name="r10"/>+ <register name="r9"/>+ <register name="r8"/>+ </unaffected>+ <killedbycall>+ <register name="fr0"/>+ </killedbycall>+ </prototype>+ <prototype name="__doubleret" extrapop="0" stackshift="0" strategy="register">+ <input>+ <pentry minsize="1" maxsize="4">+ <register name="r4"/>+ </pentry>+ <pentry minsize="1" maxsize="4">+ <register name="r5"/>+ </pentry>+ <pentry minsize="1" maxsize="4">+ <register name="r6"/>+ </pentry>+ <pentry minsize="1" maxsize="4">+ <register name="r7"/>+ </pentry>+ <pentry minsize="1" maxsize="4">+ <register name="fr4"/>+ </pentry>+ <pentry minsize="1" maxsize="4">+ <register name="fr5"/>+ </pentry>+ <pentry minsize="1" maxsize="4">+ <register name="fr6"/>+ </pentry>+ <pentry minsize="1" maxsize="4">+ <register name="fr7"/>+ </pentry>+ <pentry minsize="1" maxsize="4">+ <register name="dr4"/>+ </pentry>+ <pentry minsize="1" maxsize="4">+ <register name="dr6"/>+ </pentry>+ <pentry minsize="1" maxsize="4">+ <register name="dr8"/>+ </pentry>+ <pentry minsize="1" maxsize="4">+ <register name="dr10"/>+ </pentry>+ <pentry minsize="1" maxsize="500" align="4">+ <addr offset="0" space="stack"/>+ </pentry>+ </input>+ <output>+ <pentry minsize="1" maxsize="4">+ <register name="dr0"/>+ </pentry>+ </output>+ <unaffected>+ <register name="r15"/>+ <register name="r14"/>+ <register name="r13"/>+ <register name="r12"/>+ <register name="r11"/>+ <register name="r10"/>+ <register name="r9"/>+ <register name="r8"/>+ </unaffected>+ <killedbycall>+ <register name="dr0"/>+ </killedbycall>+ </prototype>+</compiler_spec>diff --git a/Ghidra/Processors/SuperH4/data/languages/SuperH4.ldefs b/Ghidra/Processors/SuperH4/data/languages/SuperH4.ldefsnew file mode 100644index 0000000000..fe5807545a--- /dev/null+++ b/Ghidra/Processors/SuperH4/data/languages/SuperH4.ldefs@@ -0,0 +1,31 @@+<?xml version="1.0" encoding="UTF-8"?>++<language_definitions>+ <language processor="SuperH4"+ endian="big"+ size="32"+ variant="default"+ version="1.01"+ slafile="SuperH4_be.sla"+ processorspec="SuperH4.pspec"+ manualindexfile="../manuals/superh4.idx"+ id="SuperH4:BE:32:default">+ <description>SuperH-4(a) (SH4) big endian</description>+ <compiler name="default" spec="SuperH4.cspec" id="default"/>+ <external_name tool="IDA-PRO" name="sh4b"/>+ </language>+ <language processor="SuperH4"+ endian="little"+ size="32"+ variant="default"+ version="1.01"+ slafile="SuperH4_le.sla"+ processorspec="SuperH4.pspec"+ manualindexfile="../manuals/superh4.idx"+ id="SuperH4:LE:32:default">+ <description>SuperH-4(a) (SH4) little endian</description>+ <compiler name="default" spec="SuperH4.cspec" id="default"/>+ <compiler name="Visual Studio" spec="SuperH4.cspec" id="windows"/>+ <external_name tool="IDA-PRO" name="sh4"/>+ </language>+</language_definitions>diff --git a/Ghidra/Processors/SuperH4/data/languages/SuperH4.opinion b/Ghidra/Processors/SuperH4/data/languages/SuperH4.opinionnew file mode 100644index 0000000000..42cc3a7e78--- /dev/null+++ b/Ghidra/Processors/SuperH4/data/languages/SuperH4.opinion@@ -0,0 +1,12 @@+<opinions>+ <constraint loader="Portable Executable (PE)" compilerSpecID="windows">+ <constraint primary="422" processor="SuperH4" endian="little" size="32" />+ </constraint>+ <constraint loader="MS Common Object File Format (COFF)" compilerSpecID="windows">+ <constraint primary="422" processor="SuperH4" endian="little" size="32" />+ </constraint>+ <constraint loader="Executable and Linking Format (ELF)" compilerSpecID="default">+ <constraint primary="42" processor="SuperH4" endian="little" size="32" />+ <constraint primary="42" processor="SuperH4" endian="big" size="32" />+ </constraint>+</opinions>diff --git a/Ghidra/Processors/SuperH4/data/languages/SuperH4.pspec b/Ghidra/Processors/SuperH4/data/languages/SuperH4.pspecnew file mode 100644index 0000000000..cd44a33b86--- /dev/null+++ b/Ghidra/Processors/SuperH4/data/languages/SuperH4.pspec@@ -0,0 +1,9 @@+<?xml version="1.0" encoding="UTF-8"?>++<processor_spec>+ <properties>+ <property key="assemblyRating:SuperH4:BE:32:default" value="PLATINUM"/>+ <property key="assemblyRating:SuperH4:LE:32:default" value="PLATINUM"/>+ </properties>+ <programcounter register="PC"/>+</processor_spec>diff --git a/Ghidra/Processors/SuperH4/data/languages/SuperH4.sinc b/Ghidra/Processors/SuperH4/data/languages/SuperH4.sincnew file mode 100644index 0000000000..f3e7dcfd89--- /dev/null+++ b/Ghidra/Processors/SuperH4/data/languages/SuperH4.sinc@@ -0,0 +1,4001 @@+# This module defines SuperH version 4, but should work against versions 1,2, and 3.+# There is a SuperH version 4A (which has 4 byte instruction length) which has instructions incompatable+# with this.++# Based on "Renesas SH-4 Software Manual: Rev 6.00 2006.09 (i.e. rej09b0318_sh_4sm.pdf)++# Here's a nice webpage with all the insns clearly shown+# http://shared-ptr.com/sh_insns.html++# Address Space:+# SuperH 4A has a 29-bit and a 32-bit address space mode,+# and can do 32-bit addressing in 29-bit mode with virtual addressing.+# The SH4 has a 29-bit physical address space, but can do 32-bit with virtual addressing.+#+# WARNING:+# WARNING:+# WARNING: Currently set up for 29-bit only for computed jumps/calls. This needs to be configurable.+# WARNING:++# NOTE: SuperH 4 and floating point disassembly and decompiling precision.+# Many of the floating point instructions can do either single or double precision calculations depending+# on a flag FPSCR_PR at runtime. This means at disassembly stage we don't have all the information required+# determine the arguments to some floating point instructions.++# NOTE: SuperH 4 and floating point disassembly and decompiling (fmov lengths).+# Some of the instructions can read and write floating point values in 4 or 8 byte values depending on the+# flag FPSCR_SZ. This means at disassembly stage we don't have all the information required to determine the+# arguments to some floating point instructions.+# Note that the FPSCR_PR flag is never examined during any of the fmov insns.++# NOTE: SuperH and banking+# When the RB flag is not set R1->R7 come from bank0 and when RB is set R1->R7 come from bank1. The RB mode is+# set in privileged mode. We don't currently simulate this behavior.++# NOTE: SuperH and floating point banking+# When the flag FPSCR_FR is not set fr0->fr15 come from bank0 and when FPSCR.FR is set fr0->fr15 come from bank1.+# We don't currently simulate this behavior.++# NOTE: SuperH and memory map registers+# There are 7 32bit control registers (SR, GBR, SSR, SPC, SGR, DBR, VBR) these are mapped to 2 different memory+# areas 0x1C000000 and 0xFC000000. We don't currently simulate this behavior.++# NOTE: SuperH/Renesas return value convention.+# Renesas and gcc return most values from a function in r0 but floats are return in fr0 and doubles in dr0.+# Ghidra calling spec has no way of specifying this behavior so such return values are not handled correctly.++# NOTE: SuperH/Renesas calling convention+# Renesas and gcc pass most values to a function via r4-r7 but floats are passed by fr4-fr7 and doubles in+# dr4, dr6, dr8, and dr10.++# NOTE: floating point errors+# In implementing the floating point pcode we ignored many of the possible error conditions floating point+# could cause. This allows us to produce much better looking decompiled code.++# NOTE: SuperH 4 Memory model+# SuperH 4 has a Memory Management Unit (i.e. MMU). Which means that depending on mode the memory can+# look very different. We don't model this behavior. We also don't simulate the MMU address translation,+# so all addresses are raw.+++# NOTE: Implementation of pcode for floating point instructions.+# The floating point code was originally designed to test the FPSCR_PR and PFSCR_SZ flags at run time and+# do the correct floating point operation, but the decompiled code look very ugly, so we now allow compile+# time choice of these options.++#Note: Define TEST_FLOATS only during development!!! Not for production.+# @define TEST_FLOATS "0"++# Set FLOAT_TYPE to "RUNTIME_FLOAT" to get original behavior.+# Set FLOAT_TYPE to "double" to always get double behavior.+# Set FLOAT_TYPE to "float" to always get float behavior.+# Set FLOAT_LENGTH to 8 to read and write floats in 8 byte values.+# Set FLOAT_LENGTH to 4 to read and write floats in 4 byte values.++# The three valid choices are:+# FLOAT_TYPE double FLOAT_LENGTH 8+# FLOAT_TYPE float FLOAT_LENGTH 4+# FLOAT_TYPE float FLOAT_LENGTH 8++@define FLOAT_TYPE "RUNTIME_FLOAT"+# @define FLOAT_TYPE "double"+# @define FLOAT_TYPE "float"++# @define FLOAT_LENGTH 8+@define FLOAT_LENGTH 4+++# Basic ================================================================================++define endian=$(ENDIAN); # Defined in file that includes this file+define alignment=2;++define space ram type=ram_space size=4 default;+define space register type=register_space size=4;++# Registers ============================================================================++# TODO deal with the 2 banks of registers++# TODO move os corret memory address+define register offset=0 size=4 [+ r0 r1 r2 r3 r4 r5 r6 r7+ r8 r9 r10 r11 r12 r13 r14 r15+ R0_BANK R1_BANK R2_BANK R3_BANK R4_BANK R5_BANK R6_BANK R7_BANK+];++# This is where "BANK0" is with RB=0 (normal), causes duplicate pair error in SLEIGH+#define register offset=0 size=4 [+# R0_BANK0 R1_BANK0 R2_BANK0 R3_BANK0 R4_BANK0 R5_BANK0 R6_BANK0 R7_BANK0+#];++# This is where "BANK1" is with RB=1 (privileged), causes duplicate pair error in SLEIGH+#define register offset=0 size=4 [+# R0_BANK1 R1_BANK1 R2_BANK1 R3_BANK1 R4_BANK1 R5_BANK1 R6_BANK1 R7_BANK1+#];++@if ENDIAN == "big"+define register offset=512 size=4 [+ fr0 fr1 fr2 fr3 fr4 fr5 fr6 fr7 fr8 fr9 fr10 fr11 fr12 fr13 fr14 fr15+ xf0 xf1 xf2 xf3 xf4 xf5 xf6 xf7 xf8 xf9 xf10 xf11 xf12 xf13 xf14 xf15+];+@endif++@if ENDIAN == "little"+define register offset=512 size=4 [+ fr1 fr0 fr3 fr2 fr5 fr4 fr7 fr6 fr9 fr8 fr11 fr10 fr13 fr12 fr15 fr14+ xf0 xf1 xf2 xf3 xf4 xf5 xf6 xf7 xf8 xf9 xf10 xf11 xf12 xf13 xf14 xf15++];+@endif++define register offset=512 size=8 [+ dr0 dr2 dr4 dr6 dr8 dr10 dr12 dr14+ xd0 xd2 xd4 xd6 xd8 xd10 xd12 xd14+];++define register offset=512 size=16 [+ fv0 fv4 fv8 fv12+];++# Control registers+define register offset=1024 size=4 [+ GBR SR SSR SPC VBR SGR DBR+];++# SR component register fields (pseudo)+define register offset=1536 size=1 [+ MD RB BL FD M Q IMASK S T+];++# System registers+define register offset=2048 size=4 [+ MACH MACL PR PC FPSCR FPUL+];++# FPSCR component register fields (pseudo)+define register offset=2560 size=1 [+ FPSCR_RM+ FPSCR_FLAG+ FPSCR_ENABLE+ FPSCR_CAUSE+ FPSCR_DN+ FPSCR_PR+ FPSCR_SZ+ FPSCR_FR+];+++#+# SR pack and unpack support+#++# 0000 0000 0000 0000 0000 0000 0000 0001+@define T_MASK "0x00000001"++# 0000 0000 0000 0000 0000 0000 0000 0010+@define S_MASK "0x00000002"++# 0000 0000 0000 0000 0000 0000 1111 0000+@define IMASK_MASK "0x000000F0"++# 0000 0000 0000 0000 0000 0001 0000 0000+@define Q_MASK "0x00000100"++# 0000 0000 0000 0000 0000 0010 0000 0000+@define M_MASK "0x00000200"++# 0000 0000 0000 0000 1000 0000 0000 0000+@define FD_MASK "0x00008000"++# 0001 0000 0000 0000 0000 0000 0000 0000+@define BL_MASK "0x10000000"++# 0010 0000 0000 0000 0000 0000 0000 0000+@define RB_MASK "0x20000000"++# 0100 0000 0000 0000 0000 0000 0000 0000+@define MD_MASK "0x40000000"++@define T_SHIFT " 0"+@define S_SHIFT " 1"+@define IMASK_SHIFT " 4"+@define Q_SHIFT " 8"+@define M_SHIFT " 9"+@define FD_SHIFT "15"+@define BL_SHIFT "28"+@define RB_SHIFT "29"+@define MD_SHIFT "30"++macro genSRregister() {++ SR =+ (zext(T) << $(T_SHIFT)) |+ (zext(S) << $(S_SHIFT)) |+ (zext(IMASK) << $(IMASK_SHIFT)) |+ (zext(Q) << $(Q_SHIFT)) |+ (zext(M) << $(M_SHIFT)) |+ (zext(FD) << $(FD_SHIFT)) |+ (zext(BL) << $(BL_SHIFT)) |+ (zext(RB) << $(RB_SHIFT)) |+ (zext(MD) << $(MD_SHIFT));+}++macro splitSRregister() {++ splitTemp:4 = (SR & $(T_MASK)) >> $(T_SHIFT);+ T = splitTemp:1;++ splitTemp = (SR & $(S_MASK)) >> $(S_SHIFT);+ S = splitTemp:1;++ splitTemp = (SR & $(IMASK_MASK)) >> $(IMASK_SHIFT);+ IMASK = splitTemp:1;++ splitTemp = (SR & $(Q_MASK)) >> $(Q_SHIFT);+ Q = splitTemp:1;++ splitTemp = (SR & $(M_MASK)) >> $(M_SHIFT);+ M = splitTemp:1;++ splitTemp = (SR & $(FD_MASK)) >> $(FD_SHIFT);+ FD = splitTemp:1;++ splitTemp = (SR & $(BL_MASK)) >> $(BL_SHIFT);+ BL = splitTemp:1;++ splitTemp = (SR & $(RB_MASK)) >> $(RB_SHIFT);+ RB = splitTemp:1;++ splitTemp = (SR & $(MD_MASK)) >> $(MD_SHIFT);+ MD = splitTemp:1;+}++++#+# FPSCR pack and unpack support+#++@define FPSCR_RM_SHIFT " 0"+@define FPSCR_FLAG_SHIFT " 2"+@define FPSCR_ENABLE_SHIFT " 7"+@define FPSCR_CAUSE_SHIFT "12"+@define FPSCR_DN_SHIFT "18"+@define FPSCR_PR_SHIFT "19"+@define FPSCR_SZ_SHIFT "20"+@define FPSCR_FR_SHIFT "21"+++# 0000 0000 0000 0000 0000 0000 0000 0011+@define FPSCR_RM_MASK "0x00000003"++# 0000 0000 0000 0000 0000 0000 0111 1100+@define FPSCR_FLAG_MASK "0x0000007C"++# 0000 0000 0000 0000 0000 1111 1000 0000+@define FPSCR_ENABLE_MASK "0x00000F80"++# 0000 0000 0000 0011 1111 0000 0000 0000+@define FPSCR_CAUSE_MASK "0x0003F000"++# 0000 0000 0000 0100 0000 0000 0000 0000+@define FPSCR_DN_MASK "0x00040000"++# 0000 0000 0000 1000 0000 0000 0000 0000+@define FPSCR_PR_MASK "0x00080000"++# 0000 0000 0001 0000 0000 0000 0000 0000+@define FPSCR_SZ_MASK "0x00100000"++# 0000 0000 0010 0000 0000 0000 0000 0000+@define FPSCR_FR_MASK "0x00200000"++# Bits 22-31 are not used++macro genFPSCRregister() {++ FPSCR =+ (zext(FPSCR_RM) << $(FPSCR_RM_SHIFT)) |+ (zext(FPSCR_FLAG) << $(FPSCR_FLAG_SHIFT)) |+ (zext(FPSCR_ENABLE) << $(FPSCR_ENABLE_SHIFT)) |+ (zext(FPSCR_CAUSE) << $(FPSCR_CAUSE_SHIFT)) |+ (zext(FPSCR_DN) << $(FPSCR_DN_SHIFT)) |+ (zext(FPSCR_PR) << $(FPSCR_PR_SHIFT)) |+ (zext(FPSCR_SZ) << $(FPSCR_SZ_SHIFT)) |+ (zext(FPSCR_FR) << $(FPSCR_FR_SHIFT));+}++macro splitFPSCRregister() {++ splitTemp:4 = (FPSCR & $(FPSCR_RM_MASK)) >> $(FPSCR_RM_SHIFT);+ FPSCR_RM = splitTemp:1;++ splitTemp = (FPSCR & $(FPSCR_FLAG_MASK)) >> $(FPSCR_FLAG_SHIFT);+ FPSCR_FLAG = splitTemp:1;++ splitTemp = (FPSCR & $(FPSCR_ENABLE_MASK)) >> $(FPSCR_ENABLE_SHIFT);+ FPSCR_ENABLE = splitTemp:1;++ splitTemp = (FPSCR & $(FPSCR_CAUSE_MASK)) >> $(FPSCR_CAUSE_SHIFT);+ FPSCR_CAUSE = splitTemp:1;++ splitTemp = (FPSCR & $(FPSCR_DN_MASK)) >> $(FPSCR_DN_SHIFT);+ FPSCR_DN = splitTemp:1;++ splitTemp = (FPSCR & $(FPSCR_PR_MASK)) >> $(FPSCR_PR_SHIFT);+ FPSCR_PR = splitTemp:1;++ splitTemp = (FPSCR & $(FPSCR_SZ_MASK)) >> $(FPSCR_SZ_SHIFT);+ FPSCR_SZ = splitTemp:1;++ splitTemp = (FPSCR & $(FPSCR_FR_MASK)) >> $(FPSCR_FR_SHIFT);+ FPSCR_FR = splitTemp:1;+}+++# Fields =================================================================================+++define token instr(16)+ OP_0=(12,15)+ OP_1=(0,3)+ OP_2=(8,15)+ OP_3=(0,15)+ OP_4=(0,7)+ OP_5=(0,8)+ OP_6=(8,8)+ OP_7=(0,4)+ OP_8=(0,9)+ OP_9=(7,7)+ OP_10=(4,4)++ BANK=(4,6) # bank register id++ M_0=(4,7) # register id+ M_1=(5,7) # register id+ M_2=(8,9) # register id+ FRM_0=(4,7) # float register id+ DRM_1=(5,7) # double register id+ XDM_1=(5,7) # double register id+ FVM_2=(8,9) # fv register id++ N_0=(8,11) # register id+ N_1=(9,11) # register id+ N_2=(10,11) # register id+ FRN_0=(8,11) # float register id+ DRN_1=(9,11) # double register id+ XDN_1=(9,11) # double register id+ FVN_2=(10,11) # fv register id++ I_0=(0,7) signed # immediate+ I_1=(0,11) signed # immediate+ I_2=(0,3) signed # immediate++ U_0=(0,7) # immediate+ U_1=(0,11) # immediate+ U_2=(0,3) # immediate+ ;+++# Context variables ====================================================++define context FPSCR+ doublePrecMode = (19,19) # floating point single/double precision operation mode and extended moves+ doubleWidthMoveMode = (20,20) # floating point single/double width moves+;++# Attach variables =====================================================++# attach normal registers+attach variables [ N_0 M_0 ] [+ r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 r13 r14 r15+];++# attach float registers+attach variables [ FRN_0 FRM_0] [+ fr0 fr1 fr2 fr3 fr4 fr5 fr6 fr7 fr8 fr9 fr10 fr11 fr12 fr13 fr14 fr15+];++# attach extended float registers ????? support?+#attach variables [ FRN_0 FRM_0] [+# xf0 xf1 xf2 xf3 xf4 xf5 xf6 xf7 xf8 xf9 xf10 xf11 xf12 xf13 xf14 xf15+#];++# attach double registers+attach variables [ DRN_1 DRM_1 ] [+ dr0 dr2 dr4 dr6 dr8 dr10 dr12 dr14+];++# attach extended double registers+attach variables [ XDN_1 XDM_1 ] [+ xd0 xd2 xd4 xd6 xd8 xd10 xd12 xd14+];++# attach vf registers+attach variables [ FVN_2 FVM_2 ] [+ fv0 fv4 fv8 fv12+];++attach variables [ BANK ] [+ R0_BANK R1_BANK R2_BANK R3_BANK R4_BANK R5_BANK R6_BANK R7_BANK+];+++# Tables ================================================================++# Addressing Modes+#+# Register direct+# Rn EA is Rn.+#+# Register indirect+# @Rn Rn contains EA+#+# Register indirect with postincrement+# @Rn+ Rn contains EA+# After EA calculation:+# increment Rn by 1 for byte, 2 for word, 4 for long word, 8 quadword operand+#+# Register indirect with predecrement+# @-Rn Rn contains EA,+# Before EA calculation:+# increment Rn by 1 for byte, 2 for word, 4 for long word, 8 quadword operand+#+# Register indirect with displacement+# @(disp:4, Rn) EA is Rn + 4-bit displacement disp added. disp is zero extended,+# then multiplied by 1 for byte, 2 for word, 4 for long word operand size+#+# Indexed register indirect+# @(R0, Rn) EA is Rn + R0+#+# GBR indirect with displacement+# @(disp:8,GBR) EA is GBR contents with 8-bit displacement added.+# 8-bit displacement disp added. disp is zero extended,+# then multiplied by 1 for byte, 2 for word, 4 for long word operand size+#+# Indexed GBR indirect+# @(R0, GBR) EA is GBR + R0+#+# PC-relative with displacement+# @(disp:8, PC) EA is PC+4 + 8bit displacement. disp is zero extended,+# then multiplied by 1 for byte, 2 for word, 4 for long word operand size+#+# PC-relative+# disp:8 EA is PC+4 + 8-bit displacement.+# disp is sign-extended and multiplied by 2.+#+# PC-relative+# disp:12 EA is PC+4 + 12-bit displacement.+# disp is sign-extended and multiplied by 2.+#+# Rn EA is PC+4 + Rn.+#++M_0t: M_0 is M_0 { export M_0; }+N_0t: N_0 is N_0 { export N_0; }++N_0tjmp: @^N_0 is N_0 { export N_0; }++I_0t: "#"^I_0 is I_0 { tmp:4 = I_0; export tmp; }+U_0t: "#"^U_0 is U_0 { tmp:4 = U_0; export tmp; }+U_0t1: "#"^U_0^",@("^r0^","^GBR^")" is U_0 & r0 & GBR { tmp:1 = U_0; export tmp; }+I_0t_r0: "#"I_0^","^r0 is I_0 & r0 { tmp:4 = I_0; export tmp; }+U_0t_r0: "#"U_0^","^r0 is U_0 & r0 { tmp:4 = U_0; export tmp; }++I_0tbranch: dest is I_0 [ dest = inst_start + I_0*2 + 4; ] { export *:4 dest; }+I_1tbranch: dest is I_1 [ dest = inst_start + I_1*2 + 4; ] { export *:4 dest; }++sr_N_0t: SR^","^N_0 is N_0 & SR { export N_0; }+gbr_N_0t: GBR^","^N_0 is N_0 & GBR { export N_0; }+vbr_N_0t: VBR^","^N_0 is N_0 & VBR { export N_0; }+ssr_N_0t: SSR^","^N_0 is N_0 & SSR { export N_0; }+spc_N_0t: SPC^","^N_0 is N_0 & SPC { export N_0; }+sgr_N_0t: SGR^","^N_0 is N_0 & SGR { export N_0; }+dbr_N_0t: DBR^","^N_0 is N_0 & DBR { export N_0; }++sr_t: SR is OP_0 & SR { x:4 = 0; export x; } # dummy export, just looking for the display+gbr_t: GBR is OP_0 & GBR { x:4 = 0; export x; } # dummy export, just looking for the display+vbr_t: VBR is OP_0 & VBR { x:4 = 0; export x; } # dummy export, just looking for the display+ssr_t: SSR is OP_0 & SSR { x:4 = 0; export x; } # dummy export, just looking for the display+spc_t: SPC is OP_0 & SPC { x:4 = 0; export x; } # dummy export, just looking for the display+sgr_t: SGR is OP_0 & SGR { x:4 = 0; export x; } # dummy export, just looking for the display+dbr_t: DBR is OP_0 & DBR { x:4 = 0; export x; } # dummy export, just looking for the display++N_0t_sr: N_0^","^SR is N_0 & SR { export N_0; }+N_0t_gbr: N_0^","^GBR is N_0 & GBR { export N_0; }+N_0t_vbr: N_0^","^VBR is N_0 & VBR { export N_0; }+N_0t_ssr: N_0^","^SSR is N_0 & SSR { export N_0; }+N_0t_spc: N_0^","^SPC is N_0 & SPC { export N_0; }+# N_0t_sgr: N_0^","^SGR is N_0 & SGR { export N_0; }+N_0t_dbr: N_0^","^DBR is N_0 & DBR { export N_0; }+N_0t_bank: N_0 is N_0 { export N_0; }++N_0t_sr1: @^N_0^"+,"^SR is N_0 & SR { export N_0; }+N_0t_gbr1: @^N_0^"+,"^GBR is N_0 & GBR { export N_0; }+N_0t_vbr1: @^N_0^"+,"^VBR is N_0 & VBR { export N_0; }+N_0t_ssr1: @^N_0^"+,"^SSR is N_0 & SSR { export N_0; }+N_0t_spc1: @^N_0^"+,"^SPC is N_0 & SPC { export N_0; }+# N_0t_sgr1: @^N_0^"+,"^SGR is N_0 & SGR { export N_0;}+N_0t_dbr1: @^N_0^"+,"^DBR is N_0 & DBR { export N_0; }+N_0t_bank1: @^N_0^"+" is N_0 { export N_0; }+++FR0_t: fr0 is OP_0 & fr0 { x:4 = 0; export x; } # dummy export, just looking for the display+XMTRX_t: "xmtrx" is OP_0 { x:4 = 0; export x; } # dummy export, just looking for the display++mach_t: MACH is OP_0 & MACH { x:4 = 0; export x; } # dummy export, just looking for the display+macl_t: MACL is OP_0 & MACL { x:4 = 0; export x; } # dummy export, just looking for the display+fpul_t: FPUL is OP_0 & FPUL { x:4 = 0; export x; } # dummy export, just looking for the display+fpscr_t: "FPSCR" is OP_0 { x:4 = 0; export x; } # dummy export, just looking for the display++mach_N_0t: MACH^","^N_0 is N_0 & MACH { export N_0; }+macl_N_0t: MACL^","^N_0 is N_0 & MACL { export N_0; }+pr_N_0t: PR^","^N_0 is N_0 & PR { export N_0; }+fpul_N_0t: FPUL^","N_0 is N_0 & FPUL { export N_0; }+fpscr_N_0t: "FPSCR"^","N_0 is N_0 { export N_0; }++N_0t_mach: N_0^","^MACH is N_0 & MACH { export N_0; }+N_0t_macl: N_0^","^MACL is N_0 & MACL { export N_0; }+N_0t_pr: N_0^","^PR is N_0 & PR { export N_0; }+N_0t_fpul: N_0^","^FPUL is N_0 & FPUL { export N_0; }+N_0t_fpscr: N_0^",fpscr" is N_0 { export N_0; }++N_0t_mach1: @^N_0^"+,"^MACH is N_0 & MACH { export N_0; }+N_0t_macl1: @^N_0^"+,"^MACL is N_0 & MACL { export N_0; }+N_0t_pr1: @^N_0^"+,"^PR is N_0 & PR { export N_0; }+N_0t_fpul1: @^N_0^"+,"^FPUL is N_0 & FPUL { export N_0; }+N_0t_fpscr1: @^N_0^"+,fpscr" is N_0 { export N_0; }++M_0t_at1: @^M_0 is M_0 { export M_0; }+N_0t_at1: @^N_0 is N_0 { export N_0; }++M_0t_at: @^M_0^+ is M_0 { export M_0; }+N_0t_at: @^N_0^+ is N_0 { export N_0; }++FRM_0t: FRM_0 is FRM_0 { export FRM_0; }+FRN_0t: FRN_0 is FRN_0 { export FRN_0; }++DRM_1t: DRM_1 is DRM_1 { export DRM_1; }+DRN_1t: DRN_1 is DRN_1 { export DRN_1; }++FVM_2t: FVM_2 is FVM_2 { export FVM_2; }+FVN_2t: FVN_2 is FVN_2 { export FVN_2; }++N_0t_at_with_r0: "@("^r0^","^N_0^")" is N_0 & r0 { export N_0; }+M_0t_at_with_r0: "@("^r0^","^M_0^")" is M_0 & r0 { export M_0; }++N_0t_at_neg: "@-"^N_0 is N_0 { export N_0; }++U_2t_M0_dispr01: "@("^disp^","^M_0^")" is U_2 & M_0 [ disp = U_2 * 1; ] { tmp4:4 = disp; export tmp4; }+U_2t_M0_dispr02: "@("^disp^","^M_0^")" is U_2 & M_0 [ disp = U_2 * 2; ] { tmp4:4 = disp; export tmp4; }+U_2t_M0_dispr04: "@("^disp^","^M_0^")" is U_2 & M_0 [ disp = U_2 * 4; ] { tmp4:4 = disp; export tmp4; }++U_2t_N0_dispr04: "@("^disp^","^N_0^")" is U_2 & N_0 [ disp = U_2 * 4; ] { tmp4:4 = disp; export tmp4; }++# Bug in SLEIGH, needed "* 1"+U_0t_gbr_at_1: "@("^disp,GBR^")" is U_0 & GBR [ disp = U_0 * 1; ] { tmp4:4 = disp + GBR; export tmp4; }+U_0t_gbr_at_2: "@("^disp,GBR^")" is U_0 & GBR [ disp = U_0 * 2; ] { tmp4:4 = disp + GBR; export tmp4; }+U_0t_gbr_at_4: "@("^disp,GBR^")" is U_0 & GBR [ disp = U_0 * 4; ] { tmp4:4 = disp + GBR; export tmp4; }++# Note: The 4 byte (MOVA) case needs the masking of the PC bottom 2 bits, page 345, paragraph 1:+# "a value with the lower 2 bits adjusted to B00 is used in address calculation."+# Note: Only the 4 byte case needs the masking of the PC bottom 2 bits, page 336, paragraph 3:+# "A value with the lower 2 bits adjusted to B00 is used in address calculation."+# (The 2 byte case always has the PC LSBit at 0 because all instructions are 2 byte aligned.)+U_0t_2pc: dest is U_0 [ dest = inst_start + U_0*2 + 4; ] { export *:2 dest; }+U_0t_4pc: dest is U_0 [ dest = ( inst_start & 0xfffffffc ) + U_0*4 + 4; ] { export *:4 dest; }++BANKt: BANK is BANK { export BANK; }++N_0txx: r0",@"^N_0 is r0 & N_0 { tmp:4 = N_0; export tmp; }++++# Special Test Only Constructors======================================================+++@ifdef TEST_FLOATS++# Set FPSCR_PR=0 and FPSCR_SZ=0+# pattern 0000000010001000+:__FPSCR_PR_0_SZ_0 is OP_3=0x88+ [doublePrecMode=0; doubleWidthMoveMode=0; globalset(inst_next,doublePrecMode); globalset(inst_next,doubleWidthMoveMode);] {+ FPSCR_PR = 0;+ FPSCR_SZ = 0;+}++# Set FPSCR_PR=0 and FPSCR_SZ=1+# pattern 0000000100001000+:__FPSCR_PR_0_SZ_1 is OP_3=0x108+ [doublePrecMode=0; doubleWidthMoveMode=1; globalset(inst_next,doublePrecMode); globalset(inst_next,doubleWidthMoveMode);] {+ FPSCR_PR = 0;+ FPSCR_SZ = 1;+}++# Set FPSCR_PR=1 and FPSCR_SZ=0+# pattern 0000001000001000+:__FPSCR_PR_1_SZ_0 is OP_3=0x208+ [doublePrecMode=1; doubleWidthMoveMode=0; globalset(inst_next,doublePrecMode); globalset(inst_next,doubleWidthMoveMode);] {+ FPSCR_PR = 1;+ FPSCR_SZ = 0;+}++# end TEST_FLOATS+@endif++# Constructors =======================================================================++# Binary Addition+# pattern 0011nnnnmmmm1100+# text add <REG_M>,<REG_N>+# arch arch_sh_up+:add M_0t,N_0t is OP_0=0x3 & N_0t & M_0t & OP_1=0xc {++ N_0t = N_0t + M_0t;+}+++# Binary Addition+# pattern 0111nnnniiiiiiii+# text add #<imm>,<REG_N>+# arch arch_sh_up+:add I_0t,N_0t is OP_0=0x7 & N_0t & I_0t {++ N_0t = I_0t + N_0t; # NOTE I_0t already signed extended+}+++# Binary Addition with Carry+# pattern 0011nnnnmmmm1110+# text addc <REG_M>,<REG_N>+# arch arch_sh_up+:addc M_0t,N_0t is OP_0=0x3 & N_0t & M_0t & OP_1=0xe {++ tmp1:4 = N_0t + M_0t;+ tmp0:4 = N_0t;+ N_0t = tmp1 + zext(T);+ T = (tmp0 > tmp1);+ if (tmp1 <= N_0t) goto <skip>;+ T = 1;+ <skip>+}+++# Binary Addition with Overflow Check+# pattern 0011nnnnmmmm1111+# text addv <REG_M>,<REG_N>+# arch arch_sh_up+:addv M_0t,N_0t is OP_0=0x3 & N_0t & M_0t & OP_1=0xf {++ dest:4 = 0;+ dest = zext((!(N_0t s>= 0)));+ src:4 = 0;+ src = zext((!(M_0t s>= 0)));+ src = src + dest;+ N_0t = N_0t + M_0t;+ ans:4 = 0;+ ans = zext((!(N_0t s>= 0)));+ ans = ans + dest;++ bool:1 = ((src == 0) || (src == 2));+ T = bool * (ans == 1) + !bool * ( 0 );+}+++# Logical AND+# pattern 0010nnnnmmmm1001+# text and <REG_M>,<REG_N>+# arch arch_sh_up+:and M_0t,N_0t is OP_0=0x2 & N_0t & M_0t & OP_1=0x9 {++ N_0t = N_0t & M_0t;+}++# Logical AND+# pattern 11001001iiiiiiii+# text and #<imm>,R0+# arch arch_sh_up+:and U_0t_r0 is OP_2=0xc9 & U_0t_r0 {++ r0 = r0 & U_0t_r0;+}++# Logical AND+# pattern 11001101iiiiiiii+# text and.b #<imm>,@(R0,GBR)+# arch arch_sh_up+:and.b U_0t1 is OP_2=0xcd & U_0t1 {++ *:1 (GBR + r0) = (*:1 (GBR + r0)) & U_0t1;+}+++# Conditional Branch+# pattern 10001011iiiiiiii+# text bf <bdisp8>+# arch arch_sh_up+:bf I_0tbranch is OP_2=0x8b & I_0tbranch {++ if ( T == 0 ) goto I_0tbranch;+}+++# Conditional Branch with Delay+# pattern 10001111iiiiiiii+# text bf/s <bdisp8>+# arch arch_sh2_up+:bf^"/s" I_0tbranch is OP_2=0x8f & I_0tbranch {++ local cond = T;+ delayslot(1);+ if ( cond == 0 ) goto I_0tbranch;+}+++# Unconditional Branch+# pattern 1010iiiiiiiiiiii+# text bra <bdisp12>+# arch arch_sh_up+:bra I_1tbranch is OP_0=0xa & I_1tbranch {++ delayslot(1);+ goto I_1tbranch;+}+++# Unconditional Branch+# pattern 0000nnnn00100011+# text braf <REG_N>+# arch arch_sh2_up+:braf N_0 is OP_0=0x0 & N_0 & OP_4=0x23 {++ local dest = N_0 + inst_next;+ delayslot(1);+ goto [dest];+}+++# Branch to Subroutine Procedure+# pattern 1011iiiiiiiiiiii+# text bsr <bdisp12>+# arch arch_sh_up+:bsr I_1tbranch is OP_0=0xb & I_1tbranch {++ delayslot(1);+ call I_1tbranch;+}+++# Branch to Subroutine Procedure+# pattern 0000nnnn00000011+# text bsrf <REG_N>+# arch arch_sh2_up+:bsrf N_0 is OP_0=0x0 & N_0 & OP_4=0x3 {++ PR = inst_next;+ local dest = N_0 + inst_next;+ delayslot(1);+ call [dest];+}+++# Conditional Branch+# pattern 10001001iiiiiiii+# text bt <bdisp8>+# arch arch_sh_up+:bt I_0tbranch is OP_2=0x89 & I_0tbranch {++ if ( T == 1 ) goto I_0tbranch;+}+++# Conditional Branch with Delay+# pattern 10001101iiiiiiii+# text bt/s <bdisp8>+# arch arch_sh2_up+:bt^"/s" I_0tbranch is OP_2=0x8d & I_0tbranch {+ local cond = T;+ delayslot(1);+ if ( cond == 1 ) goto I_0tbranch;+}+++# MAC Register Clear+# pattern 0000000000101000+# text clrmac+# arch arch_sh_up+:clrmac is OP_3=0x28 {++ MACH = 0;+ MACL = 0;+}+++# S Bit Clear+# pattern 0000000001001000+# text clrs+# arch arch_sh_up+:clrs is OP_3=0x48 {++ S = 0;+}+++# T Bit Clear+# pattern 0000000000001000+# text clrt+# arch arch_sh_up+:clrt is OP_3=0x8 {++ T = 0;+}+++# Compare+# pattern 0011nnnnmmmm0000+# text cmp/eq <REG_M>,<REG_N>+# arch arch_sh_up+:cmp^"/eq" M_0t,N_0t is OP_0=0x3 & N_0t & M_0t & OP_1=0x0 {++ T = ( N_0t == M_0t );+}+++# Compare+# pattern 0011nnnnmmmm0011+# text cmp/ge <REG_M>,<REG_N>+# arch arch_sh_up+:cmp^"/ge" M_0t,N_0t is OP_0=0x3 & N_0t & M_0t & OP_1=0x3 {++ T = ( N_0t s>= M_0t );+}++# Compare+# pattern 0011nnnnmmmm0111+# text cmp/gt <REG_M>,<REG_N>+# arch arch_sh_up+:cmp^"/gt" M_0t,N_0t is OP_0=0x3 & N_0t & M_0t & OP_1=0x7 {++ T = ( N_0t s> M_0t);+}+++# Compare+# pattern 0011nnnnmmmm0110+# text cmp/hi <REG_M>,<REG_N>+# arch arch_sh_up+:cmp^"/hi" M_0t,N_0t is OP_0=0x3 & N_0t & M_0t & OP_1=0x6 {++ T = ( N_0t > M_0t );+}+++# Compare+# pattern 0011nnnnmmmm0010+# text cmp/hs <REG_M>,<REG_N>+# arch arch_sh_up+:cmp^"/hs" M_0t,N_0t is OP_0=0x3 & N_0t & M_0t & OP_1=0x2 {++ T = ( N_0t >= M_0t );+}+++# Compare+# pattern 0100nnnn00010101+# text cmp/pl <REG_N>+# arch arch_sh_up+:cmp^"/pl" N_0t is OP_0=0x4 & N_0t & OP_4=0x15 {++ T = ( N_0t s> 0 );+}++# Compare+# pattern 0100nnnn00010001+# text cmp/pz <REG_N>+# arch arch_sh_up+:cmp^"/pz" N_0t is OP_0=0x4 & N_0t & OP_4=0x11 {++ T = ( N_0t s>= 0 );+}+++# Compare+# pattern 0010nnnnmmmm1100+# text cmp/str <REG_M>,<REG_N>+# arch arch_sh_up+:cmp^"/str" M_0t,N_0t is OP_0=0x2 & N_0t & M_0t & OP_1=0xc {++ temp:4 = M_0t ^ N_0t;+ HH:4 = (temp & 0xFF000000) >> 24;+ HL:4 = (temp & 0x00FF0000) >> 16;+ LH:4 = (temp & 0x0000FF00) >> 8;+ LL:4 = temp & 0x000000FF;+ T = !((HH:1) && (HL:1) && (LH:1) && (LL:1));+}+++# Compare+# pattern 10001111iiiiiiii+# pattern 10001000iiiiiiii+# text cmp/eq #<imm>,R0+# arch arch_sh_up+:cmp^"/eq" I_0t_r0 is OP_2=0x88 & I_0t_r0 {++ T = ( r0 == I_0t_r0 );+}+++# Initialization for Signed Division+# pattern 0010nnnnmmmm0111+# text div0s <REG_M>,<REG_N>+# arch arch_sh_up+:div0s M_0t,N_0t is OP_0=0x2 & N_0t & M_0t & OP_1=0x7 {++ Q = ( (N_0t & 0x80000000) != 0 );+ M = ( (M_0t & 0x80000000) != 0 );+ T = ( M != Q );+}+++# Initialization for Unsigned Division+# pattern 0000000000011001+# text div0u+# arch arch_sh_up+:div0u is OP_3=0x19 {++ M = 0;+ Q = 0;+ T = 0;+}+++# Division+# pattern 0011nnnnmmmm0100+# text div1 <REG_M>,<REG_N>+# arch arch_sh_up+:div1 M_0t,N_0t is OP_0=0x3 & OP_1=0x4 & M_0t & N_0t {++@ifdef DIV1_ORIGINAL_IS_BROKEN+ tmp2:4 = M_0t;+ N_0t = N_0t << 1;+ N_0t = N_0t | zext(T); # ???+ tmp0:4 = N_0t;+ N_0t = N_0t - zext(((Q+M)!=1))*tmp2 + zext((Q+M)==1)*tmp2;+ tmp1:1 = ( ((Q+M)!=1)*(N_0t > tmp0) + ((Q+M)==1)*(N_0t < tmp0));+ Q = ((0x80000000 & N_0t)!=0);+ Q1:1 = tmp1*(Q!=0) + (tmp1==0)*(Q==0);+ Q2:1 = tmp1*(Q==0) + (tmp1==0)*(Q!=0);+ Q = ((M==1)*Q1 + (M!=1)*Q2);+ T = (Q==M);+@endif # DIV1_ORIGINAL_IS_BROKEN++# DIV1_WITH_FORWARD_BRANCHES_WORKS_OK++Rm:4 = M_0t;+Rn:4 = N_0t;+old_Q:1 = Q;+Q = ((0x80000000 & Rn)!=0);+tmp2:4 = Rm;+Rn = Rn << 1;+Rn = Rn | zext(T);+tmp0:4 = Rn;+tmp1:1 = 0;++if (old_Q == 0) && (M == 0) goto <section_1>;+if (old_Q == 0) && (M == 1) goto <section_2>;+if (old_Q == 1) && (M == 0) goto <section_3>;+# if (old_Q == 1) && (M == 1) ...+Rn = Rn - tmp2;+tmp1 = Rn > tmp0;+if (Q == 0) goto <section_4a>;+# (Q == 1)+Q = tmp1;+goto <done>;+<section_4a>+Q = tmp1 == 0;+goto <done>;++<section_3> # (old_Q == 1) && (M == 0)+Rn = Rn + tmp2;+tmp1 = Rn < tmp0;+if (Q == 0) goto <section_3a>;+# (Q == 1)+Q = tmp1 == 0;+goto <done>;+<section_3a>+Q = tmp1;+goto <done>;++<section_2> # (old_Q == 0) && (M == 1)+Rn = Rn + tmp2;+tmp1 = Rn < tmp0;+if (Q == 0) goto <section_2a>;+# (Q == 1)+Q = tmp1;+goto <done>;+<section_2a>+Q = tmp1 == 0;+goto <done>;++<section_1> # (old_Q == 0) && (M == 0)+Rn = Rn - tmp2;+tmp1 = Rn > tmp0;+if (Q == 0) goto <section_1a>;+# (Q == 1)+Q = tmp1 == 0;+goto <done>;+<section_1a>+Q = tmp1;++<done>+T = Q == M;+N_0t = Rn;++# DIV1_WITH_GOTOs_WORKS_OK++# TODO: the following is currently broken, it should be fixed to eliminate gotos in the code above++@ifdef DIV1_STRAIGHT_CODE # BROKEN+Rm:4 = M_0t;+Rn:4 = N_0t;+old_Q:1 = Q;+Q = ((0x80000000 & Rn)!=0);+tmp2:4 = Rm;+Rn = Rn << 1;+Rn = Rn | zext(T);+tmp0:4 = Rn;++oldQM_10_01_bool:1 = ( ( (old_Q == 1) && (M == 0) ) || ( (old_Q == 1) && (M == 0) ) );+oldQM_10_01:4 = zext(oldQM_10_01_bool) * 0xffffffff;++oldQM_11_00_bool:1 = ( (old_Q == 1) && (M == 1) ) || ( (old_Q == 0) && (M == 0) );+oldQM_11_00:4 = zext(oldQM_11_00_bool) * 0xffffffff;++Rn = (oldQM_10_01 & (Rn + tmp2)) | (oldQM_11_00 & (Rn - tmp2));++tmp1:1 = ( (oldQM_11_00 != 0) && (Rn > tmp0) ) | ( (oldQM_10_01 != 0) && (Rn < tmp0) );++QM_10_01:1 = ( ( (Q == 1) && (M == 0) ) || ( (Q == 1) && (M == 0) ) ) * 0xff;+QM_11_00:1 = ( ( (Q == 1) && (M == 1) ) || ( (Q == 0) && (M == 0) ) ) * 0xff;++Q = (QM_10_01 & tmp1) || (QM_11_00 & (tmp1 == 0));++T = Q == M;+N_0t = Rn;+@endif # DIV1_STRAIGHT_CODE+}++# Signed Double-Length Multiplication+# pattern 0011nnnnmmmm1101+# text dmuls.l <REG_M>,<REG_N>+# arch arch_sh2_up+:dmuls.l M_0t,N_0t is OP_0=0x3 & OP_1=0xd & M_0t & N_0t {+ tempn:4 = N_0t;+ tempm:4 = M_0t;+ tempn = zext(tempn s> 0)*tempn - zext(tempn s< 0)*tempn;+ tempm = zext(tempm s> 0)*tempm - zext(tempm s< 0)*tempm;+ fnLmL:4 = zext((N_0t^M_0t) s< 0)*-1;+ temp1:4 = tempn;+ temp2:4 = tempm;+ RnL:4 = temp1 & 0x0000FFFF;+ RnH:4 = (temp1 >> 16) & 0x0000FFFF;+ RmL:4 = temp2 & 0x0000FFFF;+ RmH:4 = (temp2 >> 16) & 0x0000FFFF;+ temp0:4 = RmL*RnL;+ temp1 = RmH*RnL;+ temp2 = RmL*RnH;+ temp3:4 = RmH*RnH;+ Res2:4 = 0;+ Res1:4 = temp1 + temp2;+ Res2 = Res2 + 0x00010000*zext(Res1 s< temp1);+ temp1 = (Res1 << 16) & 0xFFFF0000;+ Res0:4 = temp0 + temp1;+ Res2 = Res2 + 1*zext(Res0 s< temp0);+ Res2 = Res2 + ((Res1 >> 16) & 0x0000FFFF) + temp3;++ if (!(fnLmL s< 0 )) goto <jmp1>;+ Res2 = ~Res2;+ Res2 = Res2*zext(Res0 != 0) + (Res2 + 1)*zext(Res0 == 0);+ Res0 = (Res0*zext((Res0 == 0)) + (1+(~Res0))*zext((Res0 != 0)));+ <jmp1>++ MACH = Res2;+ MACL = Res0;+}++# Unsigned Double-Length Multiplication+# pattern 0011nnnnmmmm0101+# text dmulu.l <REG_M>,<REG_N>+# arch arch_sh2_up+:dmulu.l M_0t,N_0t is OP_0=0x3 & OP_1=0x5 & M_0t & N_0t {+ RnL:4 = N_0t & 0x0000FFFF;+ RnH:4 = (N_0t >> 16) & 0x0000FFFF;+ RmL:4 = M_0t & 0x0000FFFF;+ RmH:4 = (M_0t >> 16) & 0x0000FFFF;+ temp0:4 = RmL*RnL;+ temp1:4 = RmH*RnL;+ temp2:4 = RmL*RnH;+ temp3:4 = RmH*RnH;+ Res2:4 = 0;+ Res1:4 = temp1 + temp2;+ Res2 = Res2 + zext(Res1<temp1)*0x00010000;+ temp1 = (Res1 << 16) & 0xFFFF0000;+ Res0:4 = temp0 + temp1;+ Res2 = Res2 + zext(Res0<temp1)*1;+ Res2 = Res2 + ((Res1 >> 16) & 0x0000FFFF) + temp3;+ MACH = Res2;+ MACL = Res0;+}++# Decrement and Test+# pattern 0100nnnn00010000+# text dt <REG_N>+# arch arch_sh2_up+:dt N_0t is OP_0=0x4 & N_0t & OP_4=0x10 {++ N_0t = N_0t - 1;+ T = ( N_0t == 0 );+}+++# Sign Extension+# pattern 0110nnnnmmmm1110+# text exts.b <REG_M>,<REG_N>+# arch arch_sh_up+:exts.b M_0t,N_0t is OP_0=0x6 & N_0t & M_0t & OP_1=0xe {++ N_0t = sext(M_0t:1);+}++# Sign Extension+# pattern 0110nnnnmmmm1111+# text exts.w <REG_M>,<REG_N>+# arch arch_sh_up+:exts.w M_0t,N_0t is OP_0=0x6 & N_0t & M_0t & OP_1=0xf {++ N_0t = sext(M_0t:2);+}+++# Zero Extension+# pattern 0110nnnnmmmm1100+# text extu.b <REG_M>,<REG_N>+# arch arch_sh_up+:extu.b M_0t,N_0t is OP_0=0x6 & N_0t & M_0t & OP_1=0xc {++ N_0t = zext(M_0t:1);+}+++# Zero Extension+# pattern 0110nnnnmmmm1101+# text extu.w <REG_M>,<REG_N>+# arch arch_sh_up+:extu.w M_0t,N_0t is OP_0=0x6 & N_0t & M_0t & OP_1=0xd {++ N_0t = zext(M_0t:2);+}+++# Floating-Point Absolute Value+# pattern 1111nnnn01011101+# text fabs <F_REG_N>+# arch arch_sh2e_up+:fabs FRN_0 is+ doublePrecMode = 0 &+ OP_0=0xf & FRN_0 & DRN_1 & OP_4=0x5d {++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ if (!( FPSCR_PR == 0 )) goto <doublePrecision>;+@endif+@if (FLOAT_TYPE == "float") || FLOAT_TYPE == "RUNTIME_FLOAT"+ FRN_0 = abs(FRN_0);+ goto <skip>;+@endif++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ <doublePrecision>+ DRN_1 = abs(DRN_1);+@endif+ <skip>+}++# pattern 1111nnn001011101+# text fabs <D_REG_N>+# arch arch_sh2a_or_sh4_up+:fabs DRN_1 is+ doublePrecMode = 1 &+ OP_0=0xf & DRN_1 & FRN_0 & OP_5=0x5d {++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ if (!( FPSCR_PR == 0 )) goto <doublePrecision>;+@endif+@if (FLOAT_TYPE == "float") || FLOAT_TYPE == "RUNTIME_FLOAT"+ FRN_0 = abs(FRN_0);+ goto <skip>;+@endif++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ <doublePrecision>+ DRN_1 = abs(DRN_1);+@endif+ <skip>+}++# Floating-Point Addition+# pattern 1111nnnnmmmm0000+# text fadd <F_REG_M>,<F_REG_N>+# arch arch_sh2a_or_sh4_up+:fadd FRM_0,FRN_0 is+ doublePrecMode = 0 &+ OP_0=0xf & FRN_0 & DRN_1 & FRM_0 & DRM_1 & OP_1=0x0 {++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ if (!( FPSCR_PR == 0 )) goto <doublePrecision>;+@endif+@if (FLOAT_TYPE == "float") || FLOAT_TYPE == "RUNTIME_FLOAT"+ FRN_0 = FRN_0 f+ FRM_0;+ goto <skip>;+@endif++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ <doublePrecision>+ DRN_1 = DRN_1 f+ DRM_1;+@endif+ <skip>+}++# Floating-Point Addition+# pattern 1111nnn0mmm00000+# text fadd <D_REG_M>,<D_REG_N>+# arch arch_sh2e_up+:fadd DRM_1,DRN_1 is+ doublePrecMode = 1 &+ OP_0=0xf & DRN_1 & FRN_0 & OP_6=0x0 & DRM_1 & FRM_0 & OP_7=0x0 {++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ if (!( FPSCR_PR == 0 )) goto <doublePrecision>;+@endif+@if (FLOAT_TYPE == "float") || FLOAT_TYPE == "RUNTIME_FLOAT"+ FRN_0 = FRN_0 f+ FRM_0;+ goto <skip>;+@endif++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ <doublePrecision>+ DRN_1 = DRN_1 f+ DRM_1;+@endif+ <skip>+}++# Floating-Point Comparison+# pattern 1111nnnnmmmm0100+# text fcmp/eq <F_REG_M>,<F_REG_N>+# arch arch_sh2e_up+:fcmp^"/eq" FRM_0t,FRN_0t is+ doublePrecMode = 0 &+ OP_0=0xf & FRN_0t & DRN_1t & FRM_0t & DRM_1t & OP_6 & OP_10 & OP_1=0x4+{+@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ if (!( FPSCR_PR == 0 ) ) && (OP_6:1 == 0) && (OP_10:1 == 0) goto <doublePrecision>;+@endif+@if (FLOAT_TYPE == "float") || FLOAT_TYPE == "RUNTIME_FLOAT"+ T = ( FRN_0t f== FRM_0t );+ goto <skip>;+@endif++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ <doublePrecision>+ T = ( DRN_1t f== DRM_1t );+@endif+ <skip>+}++# Floating-Point Comparison+# pattern 1111nnn0mmm00100+# text fcmp/eq <D_REG_M>,<D_REG_N>+# arch arch_sh2a_or_sh4_up+:fcmp^"/eq" DRM_1t,DRN_1t is+ doublePrecMode = 1 &+ OP_0=0xf & DRN_1t & FRN_0t & OP_6=0x0 & DRM_1t & FRM_0t & OP_7=0x4 {++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ if (!( FPSCR_PR == 0 )) goto <doublePrecision>;+@endif+@if (FLOAT_TYPE == "float") || FLOAT_TYPE == "RUNTIME_FLOAT"+ T = ( FRN_0t f== FRM_0t );+ goto <skip>;+@endif++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ <doublePrecision>+ T = ( DRN_1t f== DRM_1t );+@endif+ <skip>+}++# Floating-Point Comparison+# pattern 1111nnnnmmmm0101+# text fcmp/gt <F_REG_M>,<F_REG_N>+# arch arch_sh2e_up+:fcmp^"/gt" FRM_0t,FRN_0t is+ doublePrecMode = 0 &+ OP_0=0xf & FRM_0t & DRM_1t & FRN_0t & DRN_1t & OP_1=0x5 {++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ if (!( FPSCR_PR == 0 )) goto <doublePrecision>;+@endif+@if (FLOAT_TYPE == "float") || FLOAT_TYPE == "RUNTIME_FLOAT"+ T = ( FRN_0t f> FRM_0t );+ goto <skip>;+@endif++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ <doublePrecision>+ T = ( DRN_1t f> DRM_1t );+@endif+ <skip>+}++# Floating-Point Comparison+# pattern 1111nnn0mmm00101+# text fcmp/gt <D_REG_M>,<D_REG_N>+# arch arch_sh2a_or_sh4_up+:fcmp^"/gt" DRM_1t,DRN_1t is+ doublePrecMode = 1 &+ OP_0=0xf & DRM_1t & FRM_0t & OP_6=0x0 & DRN_1t & FRN_0t & OP_7=0x5 {++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ if (!( FPSCR_PR == 0 )) goto <doublePrecision>;+@endif+@if (FLOAT_TYPE == "float") || FLOAT_TYPE == "RUNTIME_FLOAT"+ T = ( FRN_0t f> FRM_0t );+ goto <skip>;+@endif++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ <doublePrecision>+ T = ( DRN_1t f> DRM_1t );+@endif+ <skip>+}+++# Double-Precision to Single-Precision Conversion+# pattern 1111nnn010111101+# text fcnvds <D_REG_N>,FPUL+# even though reserved to DblPrec, should decode, may not know at the time.+# if this instruction shows up, it is most likely in DblPrec mode but not set+# arch arch_sh2a_or_sh4_up+:fcnvds DRN_1t,FPUL is OP_0=0xf & DRN_1t & OP_5=0x0bd & FPUL {++ # note: this instruction is undefined if not running in DblPrec mode.+ FPUL = float2float( DRN_1t );+}+++# Single-Precision to Double-Precision Conversion+# pattern 1111nnn010101101+# text fcnvsd FPUL,<D_REG_N>+# even though reserved to DblPrec, should decode, may not know at the time.+# if this instruction shows up, it is most likely in DblPrec mode but not set+# arch arch_sh2a_or_sh4_up+:fcnvsd FPUL,DRN_1t is OP_0=0xf & DRN_1t & OP_5=0xad & FPUL {++ # note: this instruction is undefined if not running in DblPrec mode.+ DRN_1t = float2float( FPUL );+}+++# Floating-Point Division+# pattern 1111nnnnmmmm0011+# text fdiv <F_REG_M>,<F_REG_N>+# arch arch_sh2e_up+:fdiv FRM_0t,FRN_0t is+ doublePrecMode = 0 &+ OP_0=0xf & FRN_0t & DRN_1t & FRM_0t & DRM_1t & OP_1=0x3 {++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ if (!( FPSCR_PR == 0 )) goto <doublePrecision>;+@endif+@if (FLOAT_TYPE == "float") || FLOAT_TYPE == "RUNTIME_FLOAT"+ FRN_0t = ( FRN_0t f/ FRM_0t );+ goto <skip>;+@endif++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ <doublePrecision>+ DRN_1t = ( DRN_1t f/ DRM_1t );+@endif+ <skip>+}++# Floating-Point Division+# pattern 1111nnn0mmm00011+# text fdiv <D_REG_M>,<D_REG_N>+# arch arch_sh2a_or_sh4_up++:fdiv DRM_1t,DRN_1t is+ doublePrecMode = 1 &+ OP_0=0xf & DRN_1t & FRN_0t & OP_6=0x0 & DRM_1t & FRM_0t & OP_7=0x3 {++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ if (!( FPSCR_PR == 0 )) goto <doublePrecision>;+@endif+@if (FLOAT_TYPE == "float") || FLOAT_TYPE == "RUNTIME_FLOAT"+ FRN_0t = ( FRN_0t f/ FRM_0t );+ goto <skip>;+@endif++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ <doublePrecision>+ DRN_1t = ( DRN_1t f/ DRM_1t );+@endif+ <skip>+}++# Floating-Point Inner Product+# pattern 1111nnmm11101101+# text fipr <V_REG_M>,<V_REG_N>+# even though reserved to DblPrec, should decode, may not know at the time.+# if this instruction shows up, it is most likely in DblPrec mode but not set+# arch arch_sh4_up+:fipr FVM_2t,FVN_2t is OP_0=0xf & FVN_2t & FVM_2t & OP_4=0xed {++ # note: this instruction is undefined if not running in SinglePrec mode.++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ if (!( FPSCR_PR == 0 )) goto <skip>;+@endif+@if (FLOAT_TYPE == "float") || FLOAT_TYPE == "RUNTIME_FLOAT"+ # FVn dot FVm+ temp1:4 = ( *[register]:4 (&:4 FVN_2t + 0) f* *[register]:4 (&:4 FVM_2t + 0) );+ temp1 = temp1 f+ ( *[register]:4 (&:4 FVN_2t + 4) f* *[register]:4 (&:4 FVM_2t + 4) );+ temp1 = temp1 f+ ( *[register]:4 (&:4 FVN_2t + 8) f* *[register]:4 (&:4 FVM_2t + 8) );+ temp1 = temp1 f+ ( *[register]:4 (&:4 FVN_2t + 12) f* *[register]:4 (&:4 FVM_2t + 12) );++ # summation goes to FR[n + 3]+ *[register]:4 (&:4 FVN_2t + 12) = temp1;+@endif+ <skip>+}++# 0.0 Load+# pattern 1111nnnn10001101+# text fldi0 <F_REG_N>+# arch arch_sh2e_up+#+# Note- The manual says this applies only to single float destination regs+#+:fldi0 FRN_0t is OP_0=0xf & DRN_1t & FRN_0t & OP_4=0x8d {+ tmp1:4 = 0;+ FRN_0t = int2float(tmp1);+}++# 1.0 Load+# pattern 1111nnnn10011101+# text fldi1 <F_REG_N>+# arch arch_sh2e_up+#+# Note- the manual says FPSCR_PR applies only to single float regs, not to doubles.+# Manual also says FPSCR_PR should be 0, but gcc generates code where it's set to 1.+#+:fldi1 FRN_0t is OP_0=0xf & FRN_0t & DRN_1t & OP_4=0x9d {+ tmp1:4 = 1;+ FRN_0t = int2float(tmp1);+}++# Transfer to System Register+# pattern 1111nnnn00011101+# text flds <F_REG_N>,FPUL+# arch # arch_sh2e_up+# Note: Field usage indicates FR[n], not FR[m].+:flds FRN_0t,FPUL is OP_0=0xf & FRN_0t & OP_4=0x1d & FPUL {++ FPUL = FRN_0t;+}++# Integer to Floating-Point Conversion+# pattern 1111nnnn00101101+# text float FPUL,<F_REG_N>+# arch # arch_sh2e_up+:float FPUL,FRN_0t is+ doublePrecMode = 0 &+ OP_0=0xf & OP_6 & FRN_0t & DRN_1t & OP_4=0x2d & FPUL+{+ # If bit 6 is set this this is an odd FP register number, so need to do single float operation.+ # This is not in the manual but this seems to be the correct behavior.+ # if (!( FPSCR_PR == 0 ) && !(OP_6 == 0) ) goto <doublePrecision>;+ # if (!( FPSCR_PR == 0 )) goto <doublePrecision>;++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ if (!( FPSCR_PR == 0 ) ) && (OP_6:1 == 0x0) goto <doublePrecision>;+@endif+@if (FLOAT_TYPE == "float") || FLOAT_TYPE == "RUNTIME_FLOAT"+ FRN_0t = int2float( FPUL );+ goto <skip>;+@endif++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ <doublePrecision>+ DRN_1t = int2float( FPUL );+@endif+ <skip>+}++# Integer to Floating-Point Conversion+# pattern 1111nnn000101101+# text float FPUL,<D_REG_N>+# arch arch_sh2a_or_sh4_up+:float FPUL,DRN_1t is+ doublePrecMode = 1 &+ OP_0=0xf & DRN_1t & FRN_0t & OP_5=0x2d & FPUL {++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ if (!( FPSCR_PR == 0 )) goto <doublePrecision>;+@endif+@if (FLOAT_TYPE == "float") || FLOAT_TYPE == "RUNTIME_FLOAT"+ FRN_0t = int2float( FPUL );+ goto <skip>;+@endif++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ <doublePrecision>+ DRN_1t = int2float( FPUL );+@endif+ <skip>+}+++# Floating-Point Multiply and Accumulate+# pattern 1111nnnnmmmm1110+# text fmac FR0,<F_REG_M>,<F_REG_N>+# arch arch_sh2e_up+:fmac FR0_t,FRM_0t,FRN_0t is OP_0=0xf & FRN_0t & FRM_0t & OP_1=0xe & FR0_t {++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ if (!( FPSCR_PR == 0 )) goto <skip>;+@endif+@if (FLOAT_TYPE == "float") || FLOAT_TYPE == "RUNTIME_FLOAT"+ FRN_0t = ( FR0_t f* FRM_0t ) f+ FRN_0t;+@endif+ <skip>+}++# Floating-Point Transfer #1a (related to Extended FMOV #7)+# pattern 1111nnn1mmm11100+# text fmov <F_REG_M>,<F_REG_N>+# arch arch_sh2e_up+#+# Note- The manual says all the fmov insns should only look at the FPSCR_SZ flag+# to determine if this is a single or double float move. Ie, don't reference FPSCR_PR.+#+:fmov FRM_0,FRN_0 is+ doublePrecMode=0 & doubleWidthMoveMode=0 &+ OP_0=0xf & FRN_0 & XDN_1 & OP_6=0x1 & FRM_0 & XDM_1 & OP_10=0x1 & OP_1=0xc+{+@if (FLOAT_LENGTH == "8") || FLOAT_TYPE == "RUNTIME_FLOAT"+ if (!( FPSCR_SZ == 0 )) goto <doubleWidth>;+@endif+@if (FLOAT_LENGTH == "4") || FLOAT_TYPE == "RUNTIME_FLOAT"+ FRN_0 = FRM_0;+ goto <skip>;+@endif+@if (FLOAT_LENGTH == "8") || FLOAT_TYPE == "RUNTIME_FLOAT"+ <doubleWidth>+ XDN_1 = XDM_1;+@endif+ <skip>++@ifdef FMOV_ORIGINAL+@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ if (!( FPSCR_PR == 0 )) goto <doubleWidthPR>;+@endif+@if (FLOAT_TYPE == "float") || FLOAT_TYPE == "RUNTIME_FLOAT"+ FRN_0 = FRM_0;+ goto <skip>;+@endif++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ <doubleWidthPR>+ # Extended #7+ XDN_1 = XDM_1;+@endif+ <skip>+@endif+}++# Floating-Point Transfer #1b (related to Extended FMOV #8)+# pattern 1111nnn0mmm11100+# text fmov <F_REG_M>,<F_REG_N>+# arch arch_sh2e_up+:fmov FRM_0,FRN_0 is+ doublePrecMode=0 & doubleWidthMoveMode=0 &+ OP_0=0xf & FRN_0 & DRN_1 & OP_6=0x0 & FRM_0 & XDM_1 & OP_10=0x1 & OP_1=0xc {++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+# if (!( FPSCR_PR == 0 )) goto <doubleWidthPR>;+ if (!( FPSCR_SZ == 0 )) goto <doubleWidthPR>;+@endif+@if (FLOAT_TYPE == "float") || FLOAT_TYPE == "RUNTIME_FLOAT"+ FRN_0 = FRM_0;+ goto <skip>;+@endif++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ <doubleWidthPR>+ # Extended #8+ DRN_1 = XDM_1;+@endif+ <skip>+}++# Floating-Point Transfer #1c (related to Extended FMOV #9)+# pattern 1111nnn1mmm01100+# text fmov <F_REG_M>,<F_REG_N>+# arch arch_sh2e_up+:fmov FRM_0,FRN_0 is+ doublePrecMode=0 & doubleWidthMoveMode=0 &+ OP_0=0xf & FRN_0 & XDN_1 & OP_6=0x1 & FRM_0 & DRM_1 & OP_10=0x0 & OP_1=0xc {++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+# if (!( FPSCR_PR == 0 )) goto <doubleWidthPR>;+ if (!( FPSCR_SZ == 0 )) goto <doubleWidthPR>;+@endif+@if (FLOAT_TYPE == "float") || FLOAT_TYPE == "RUNTIME_FLOAT"+ FRN_0 = FRM_0;+ goto <skip>;+@endif++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ <doubleWidthPR>+ # Extended #9+ XDN_1 = DRM_1;+@endif+ <skip>+}++# Floating-Point Transfer #1d (No PR case, single precision operation mode only)+# pattern 1111nnn0mmm01100+# text fmov <F_REG_M>,<F_REG_N>+# arch arch_sh2e_up+:fmov FRM_0,FRN_0 is+ doublePrecMode=0 & doubleWidthMoveMode=0 &+ OP_0=0xf & FRN_0 & DRN_1 & OP_6=0x0 & FRM_0 & DRM_1 & OP_10=0x0 & OP_1=0xc {++@if (FLOAT_LENGTH == "8") || FLOAT_TYPE == "RUNTIME_FLOAT"+ if (!( FPSCR_SZ == 0 )) goto <doubleWidthSZ>;+@endif+@if (FLOAT_LENGTH == "4") || FLOAT_TYPE == "RUNTIME_FLOAT"+ FRN_0 = FRM_0;+ goto <skip>;+@endif++@if (FLOAT_LENGTH == "8") || FLOAT_TYPE == "RUNTIME_FLOAT"+ <doubleWidthSZ>+ DRN_1 = DRM_1;+@endif+ <skip>+}++# Floating-Point Transfer #2 (derived)+# pattern 1111nnn0mmm01100+# text fmov <F_REG_M>,<F_REG_N>+# arch arch_sh2e_up+:fmov DRM_1,DRN_1 is+ doublePrecMode=0 & doubleWidthMoveMode=1 &+ OP_0=0xf & DRN_1 & FRN_0 & DRM_1 & FRM_0 & OP_1=0xc {++@if (FLOAT_LENGTH == "8") || FLOAT_TYPE == "RUNTIME_FLOAT"+ if (!( FPSCR_SZ == 0 )) goto <doubleWidth>;+@endif+@if (FLOAT_LENGTH == "4") || FLOAT_TYPE == "RUNTIME_FLOAT"+ FRN_0 = FRM_0;+ goto <skip>;+@endif++@if (FLOAT_LENGTH == "8") || FLOAT_TYPE == "RUNTIME_FLOAT"+ <doubleWidth>+ DRN_1 = DRM_1;+@endif+ <skip>+}++# Floating-Point Transfer #3 (related to Extended FMOV #1)+# pattern 1111nnnnmmmm1010+# text fmov <F_REG_M>,@<REG_N>+# arch arch_sh2e_up+#+# Note- Manual says to ignore FPSCR_PR but FPSCR_SZ must = 0+#+:fmov.s FRM_0,N_0t_at1 is+ # doublePrecMode=0 &+ doubleWidthMoveMode=0 &+ OP_0=0xf & N_0t_at1 & FRM_0 & DRM_1 & XDM_1 & OP_1=0xa+{+ *:4 N_0t_at1 = FRM_0;+}++# Floating-Point Transfer #4 (derived)+# pattern 1111nnnnmmm01010+# text fmov <F_REG_M>,@<REG_N>+# arch arch_sh2e_up+:fmov DRM_1,N_0t_at1 is+ doublePrecMode=0 & doubleWidthMoveMode=1 &+ OP_0=0xf & N_0t_at1 & DRM_1 & FRM_0 & OP_7=0xa {++@if (FLOAT_LENGTH == "8") || FLOAT_TYPE == "RUNTIME_FLOAT"+ if (!( FPSCR_SZ == 0 )) goto <doubleWidth>;+@endif+@if (FLOAT_LENGTH == "4") || FLOAT_TYPE == "RUNTIME_FLOAT"+ *:4 N_0t_at1 = FRM_0;+ goto <skip>;+@endif++@if (FLOAT_LENGTH == "8") || FLOAT_TYPE == "RUNTIME_FLOAT"+ <doubleWidth>+ *:8 N_0t_at1 = DRM_1;+@endif+ <skip>+}++# Floating-Point Transfer #5 (related to Extended FMOV #2)+# pattern 1111nnnnmmmm1000+# text fmov @<REG_M>,<F_REG_N>+# arch arch_sh2e_up+#+# Note- Manual says to ignore FPSCR_PR but FPSCR_SZ must = 0+#+:fmov.s M_0t_at1,FRN_0 is+ # doublePrecMode=0 &+ doubleWidthMoveMode=0 &+ OP_0=0xf & FRN_0 & DRN_1 & XDN_1 & M_0t_at1 & OP_1=0x8+{+ FRN_0 = *:4 M_0t_at1;+}++# Floating-Point Transfer #6 (derived)+# pattern 1111nnn0mmmm1000+# text fmov @<REG_M>,<F_REG_N>+# arch arch_sh2e_up+:fmov M_0t_at1,DRN_1 is+ doublePrecMode=0 & doubleWidthMoveMode=1 &+ OP_0=0xf & DRN_1 & FRN_0 & OP_6=0x0 & M_0t_at1 & OP_1=0x8 {++@if (FLOAT_LENGTH == "8") || FLOAT_TYPE == "RUNTIME_FLOAT"+ if (!( FPSCR_SZ == 0 )) goto <doubleWidth>;+@endif+@if (FLOAT_LENGTH == "4") || FLOAT_TYPE == "RUNTIME_FLOAT"+ FRN_0 = *:4 M_0t_at1;+ goto <skip>;+@endif++@if (FLOAT_LENGTH == "8") || FLOAT_TYPE == "RUNTIME_FLOAT"+ <doubleWidth>+ DRN_1 = *:8 M_0t_at1;+@endif+ <skip>+}++# Floating-Point Transfer #7 (related to Extended FMOV #3)+# pattern 1111nnnnmmmm1001+# text fmov @<REG_M>+,<F_REG_N>+# arch arch_sh2e_up+#+# Note- Manual says to ignore FPSCR_PR but FPSCR_SZ must = 0+#+:fmov.s M_0t_at,FRN_0 is+ # doublePrecMode=0 &+ doubleWidthMoveMode=0 &+ OP_0=0xf & FRN_0 & DRN_1 & XDN_1 & M_0t_at & OP_1=0x9+{+ FRN_0 = *:4 M_0t_at;+ M_0t_at = M_0t_at + 4;+}++# Floating-Point Transfer #8 (derived)+# pattern 1111nnnnmmmm1001+# text fmov @<REG_M>+,<F_REG_N>+# arch arch_sh2e_up+:fmov M_0t_at,DRN_1 is+ doublePrecMode=0 & doubleWidthMoveMode=1 &+ OP_0=0xf & DRN_1 & FRN_0 & OP_6=0x0 & M_0t_at & OP_1=0x9 {++@if (FLOAT_LENGTH == "8") || FLOAT_TYPE == "RUNTIME_FLOAT"+ if (!( FPSCR_SZ == 0 )) goto <doubleWidth>;+@endif+@if (FLOAT_LENGTH == "4") || FLOAT_TYPE == "RUNTIME_FLOAT"+ FRN_0 = *:4 M_0t_at;+ M_0t_at = M_0t_at + 4;+ goto <skip>;+@endif++@if (FLOAT_LENGTH == "8") || FLOAT_TYPE == "RUNTIME_FLOAT"+ <doubleWidth>+ DRN_1 = *:8 M_0t_at;+ M_0t_at = M_0t_at + 8;+@endif+ <skip>+}++# Floating-Point Transfer #9 (related to Extended FMOV #4)+# pattern 1111nnnnmmmm1011+# text fmov <F_REG_M>,@-<REG_N>+# arch arch_sh2e_up+#+# Note- Manual says to ignore FPSCR_PR but FPSCR_SZ must = 0+#+:fmov.s FRM_0,N_0t_at_neg is+ # doublePrecMode=0 &+ doubleWidthMoveMode=0 &+ OP_0=0xf & N_0t_at_neg & FRM_0 & DRM_1 & XDM_1 & OP_1=0xb+{+ N_0t_at_neg = N_0t_at_neg - 4;+ *:4 N_0t_at_neg = FRM_0;+}++# Floating-Point Transfer #10 (derived)+# pattern 1111nnnnmmmm1011+# text fmov <F_REG_M>,@-<REG_N>+# arch arch_sh2e_up+:fmov DRM_1,N_0t_at_neg is+ doublePrecMode=0 & doubleWidthMoveMode=1 &+ OP_0=0xf & N_0t_at_neg & DRM_1 & FRM_0 & OP_7=0xb {++@if (FLOAT_LENGTH == "8") || FLOAT_TYPE == "RUNTIME_FLOAT"+ if (!( FPSCR_SZ == 0 )) goto <doubleWidth>;+@endif+@if (FLOAT_LENGTH == "4") || FLOAT_TYPE == "RUNTIME_FLOAT"+ *:4 N_0t_at_neg = FRM_0;+ N_0t_at_neg = N_0t_at_neg - 4;+ goto <skip>;+@endif++@if (FLOAT_LENGTH == "8") || FLOAT_TYPE == "RUNTIME_FLOAT"+ <doubleWidth>+ *:8 N_0t_at_neg = DRM_1;+ N_0t_at_neg = N_0t_at_neg - 8;+@endif+ <skip>+}++# Floating-Point Transfer #11 (related to Extended FMOV #5)+# pattern 1111nnnnmmmm0110+# text fmov @(R0,<REG_M>),<F_REG_N>+# arch arch_sh2e_up+#+# Note- Manual says to ignore FPSCR_PR but FPSCR_SZ must = 0+#+:fmov.s M_0t_at_with_r0,FRN_0 is+ # doublePrecMode=0 &+ doubleWidthMoveMode=0 &+ OP_0=0xf & DRN_1 & FRN_0 & XDN_1 & M_0t_at_with_r0 & OP_1=0x6+{+ FRN_0 = *:4 (r0 + M_0t_at_with_r0);+}++# Floating-Point Transfer #12 (derived)+# pattern 1111nnnnmmmm0110+# text fmov @(R0,<REG_M>),<F_REG_N>+# arch arch_sh2e_up+:fmov M_0t_at_with_r0,DRN_1 is+ doublePrecMode=0 & doubleWidthMoveMode=1 &+ OP_0=0xf & DRN_1 & FRN_0 & OP_6=0x0 & M_0t_at_with_r0 & OP_1=0x6 {++@if (FLOAT_LENGTH == "8") || FLOAT_TYPE == "RUNTIME_FLOAT"+ if (!( FPSCR_SZ == 0 )) goto <doubleWidth>;+@endif+@if (FLOAT_LENGTH == "4") || FLOAT_TYPE == "RUNTIME_FLOAT"+ FRN_0 = *:4 (r0 + M_0t_at_with_r0);+ goto <skip>;+@endif++@if (FLOAT_LENGTH == "8") || FLOAT_TYPE == "RUNTIME_FLOAT"+ <doubleWidth>+ DRN_1 = *:8 (r0 + M_0t_at_with_r0);+@endif+ <skip>+}++# Floating-Point Transfer #13 (related to Extended FMOV #6)+# pattern 1111nnnnmmmm0111+# text fmov <F_REG_M>,@(R0,<REG_N>)+# arch arch_sh2e_up+#+# Note- Manual says to ignore FPSCR_PR but FPSCR_SZ must = 0+#+:fmov.s FRM_0,N_0t_at_with_r0 is+ # doublePrecMode=0 &+ doubleWidthMoveMode=0 &+ OP_0=0xf & N_0t_at_with_r0 & FRM_0 & DRM_1 & XDM_1 & OP_1=0x7+{+ *:4 (r0 + N_0t_at_with_r0) = FRM_0;+}++# Floating-Point Transfer #14 (derived)+# pattern 1111nnnnmmm00110+# text fmov @(R0,<REG_M>),<F_REG_N>+# arch arch_sh2e_up+:fmov DRM_1,N_0t_at_with_r0 is+ doublePrecMode=0 & doubleWidthMoveMode=1 &+ OP_0=0xf & N_0t_at_with_r0 & DRM_1 & FRM_0 & OP_7=0x7 {++@if (FLOAT_LENGTH == "8") || FLOAT_TYPE == "RUNTIME_FLOAT"+ if (!( FPSCR_SZ == 0 )) goto <doubleWidth>;+@endif+@if (FLOAT_LENGTH == "4") || FLOAT_TYPE == "RUNTIME_FLOAT"+ *:4 (r0 + N_0t_at_with_r0) = FRM_0;+ goto <skip>;+@endif++@if (FLOAT_LENGTH == "8") || FLOAT_TYPE == "RUNTIME_FLOAT"+ <doubleWidth>+ *:8 (r0 + N_0t_at_with_r0) = DRM_1;+@endif+ <skip>+}++# Floating-Point Transfer Extended #1+# pattern 1111nnnnmmm11010+# text fmov <DX_REG_M>,@<REG_N>+# arch arch_sh2a_or_sh4_up+# Note: the use of both XDM_1 & FRM_0 in this constructor: modal ?????+:fmov XDM_1,N_0t_at1 is+ doublePrecMode=1 & doubleWidthMoveMode=0 &+ OP_0=0xf & N_0t_at1 & XDM_1 & FRM_0 & OP_7=0x1a {++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+# if (!( FPSCR_PR == 0 )) goto <doubleWidth>;+ if (!( FPSCR_SZ == 0 )) goto <doubleWidth>;+@endif+@if (FLOAT_TYPE == "float") || FLOAT_TYPE == "RUNTIME_FLOAT"+ *:4 N_0t_at1 = FRM_0;+ goto <skip>;+@endif++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ <doubleWidth>+ *:8 N_0t_at1 = XDM_1;+@endif+ <skip>+}++# Floating-Point Transfer Extended #2 (based upon FPT #5 above)+# pattern 1111nnn1mmmm1000+# text fmov @<REG_M>,<DX_REG_N>+# arch arch_sh2a_or_sh4_up+# Note: the use of both XDN_1 & FRN_0 in this constructor: modal ?????+:fmov M_0t_at1,XDN_1 is+ doublePrecMode=1 & doubleWidthMoveMode=0 &+ OP_0=0xf & XDN_1 & FRN_0 & OP_6=0x1 & M_0t_at1 & OP_1=0x8 {++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+# if (!( FPSCR_PR == 0 )) goto <doubleWidth>;+ if (!( FPSCR_SZ == 0 )) goto <doubleWidth>;+@endif+@if (FLOAT_TYPE == "float") || FLOAT_TYPE == "RUNTIME_FLOAT"+ FRN_0 = *:4 M_0t_at1;+ goto <skip>;+@endif++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ <doubleWidth>+ XDN_1 = *:8 M_0t_at1;+@endif+ <skip>+}++# Floating-Point Transfer Extended #3+# pattern 1111nnn1mmmm1001+# text fmov @<REG_M>+,<DX_REG_N>+# arch arch_sh2a_or_sh4_up+# Note: the use of both XDN_1 & FRN_0 in this constructor: modal ?????+:fmov M_0t_at,XDN_1 is+ doublePrecMode=1 & doubleWidthMoveMode=0 &+ OP_0=0xf & XDN_1 & FRN_0 & OP_6=0x1 & M_0t_at & OP_1=0x9 {++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+# if (!( FPSCR_PR == 0 )) goto <doubleWidth>;+ if (!( FPSCR_SZ == 0 )) goto <doubleWidth>;+@endif+@if (FLOAT_TYPE == "float") || FLOAT_TYPE == "RUNTIME_FLOAT"+ FRN_0 = *:4 M_0t_at;+ M_0t_at = M_0t_at + 4;+ goto <skip>;+@endif++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ <doubleWidth>+ XDN_1 = *:8 M_0t_at;+ M_0t_at = M_0t_at + 8;+@endif+ <skip>+}++# Floating-Point Transfer Extended #4+# pattern 1111nnnnmmm11011+# text fmov <DX_REG_M>,@-<REG_N>+# arch arch_sh2a_or_sh4_up+# Note: the use of both XDM_1 & FRM_0 in this constructor: modal ?????+:fmov XDM_1,N_0t_at_neg is+ doublePrecMode=1 & doubleWidthMoveMode=0 &+ OP_0=0xf & N_0t_at_neg & XDM_1 & FRM_0 & OP_7=0x1b {++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+# if (!( FPSCR_PR == 0 )) goto <doubleWidth>;+ if (!( FPSCR_SZ == 0 )) goto <doubleWidth>;+@endif+@if (FLOAT_TYPE == "float") || FLOAT_TYPE == "RUNTIME_FLOAT"+ N_0t_at_neg = N_0t_at_neg - 4;+ *:4 N_0t_at_neg = FRM_0;+ goto <skip>;+@endif++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ <doubleWidth>+ N_0t_at_neg = N_0t_at_neg - 8;+ *:8 N_0t_at_neg = XDM_1;+@endif+ <skip>+}++# Floating-Point Transfer Extended #5 (based upon FPT #11 above)+# pattern 1111nnn1mmmm0110+# text fmov @(R0,<REG_M>),<DX_REG_N>+# arch arch_sh2a_or_sh4_up+# Note: the use of both XDN_1 & FRN_0 in this constructor: modal ?????+:fmov M_0t_at_with_r0,XDN_1 is+ doublePrecMode=1 & doubleWidthMoveMode=0 &+ OP_0=0xf & XDN_1 & FRN_0 & OP_6=0x1 & M_0t_at_with_r0 & OP_1=0x6 {++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+# if (!( FPSCR_PR == 0 )) goto <doubleWidth>;+ if (!( FPSCR_SZ == 0 )) goto <doubleWidth>;+@endif+@if (FLOAT_TYPE == "float") || FLOAT_TYPE == "RUNTIME_FLOAT"+ FRN_0 = *:4 (r0 + M_0t_at_with_r0);+ goto <skip>;+@endif++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ <doubleWidth>+ XDN_1 = *:8 (r0 + M_0t_at_with_r0);+@endif+ <skip>+}++# Floating-Point Transfer Extended #6+# pattern 1111nnnnmmm10111+# text fmov <DX_REG_M>,@(R0,<REG_N>)+# arch arch_sh2a_or_sh4_up+# Note: the use of both XDM_1 & FRM_0 in this constructor: modal ?????+:fmov XDM_1,N_0t_at_with_r0 is+ doublePrecMode=1 & doubleWidthMoveMode=0 &+ OP_0=0xf & N_0t_at_with_r0 & XDM_1 & FRM_0 & OP_7=0x17 {++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+# if (!( FPSCR_PR == 0 )) goto <doubleWidth>;+ if (!( FPSCR_SZ == 0 )) goto <doubleWidth>;+@endif+@if (FLOAT_TYPE == "float") || FLOAT_TYPE == "RUNTIME_FLOAT"+ *:4 (r0 + N_0t_at_with_r0) = FRM_0;+ goto <skip>;+@endif++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ <doubleWidth>+ *:8 (r0 + N_0t_at_with_r0) = XDM_1;+@endif+ <skip>+}++# Floating-Point Transfer Extended #7 (based upon FPT #1a above)+# pattern 1111nnn1mmm11100+# text fmov <DX_REG_M>,<DX_REG_N>+# arch arch_sh2a_or_sh4_up+:fmov XDM_1,XDN_1 is+ doublePrecMode=1 & doubleWidthMoveMode=0 &+ OP_0=0xf & XDN_1 & FRN_0 & OP_6=0x1 & XDM_1 & FRM_0 & OP_10=0x1 & OP_1=0xc {++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+# if (!( FPSCR_PR == 0 )) goto <doubleWidth>;+ if (!( FPSCR_SZ == 0 )) goto <doubleWidth>;+@endif+@if (FLOAT_TYPE == "float") || FLOAT_TYPE == "RUNTIME_FLOAT"+ FRN_0 = FRM_0;+ goto <skip>;+@endif++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ <doubleWidth>+ XDN_1 = XDM_1;+@endif+ <skip>+}++# Floating-Point Transfer Extended #8 (based upon FPT #1b above)+# pattern 1111nnn0mmm11100+# text fmov <DX_REG_M>,<D_REG_N>+# arch arch_sh2a_or_sh4_up+:fmov XDM_1,DRN_1 is+ doublePrecMode=1 & doubleWidthMoveMode=0 &+ OP_0=0xf & DRN_1 & FRN_0 & OP_6=0x0 & FRM_0 & XDM_1 & OP_10=0x1 & OP_1=0xc {++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+# if (!( FPSCR_PR == 0 )) goto <doubleWidth>;+ if (!( FPSCR_SZ == 0 )) goto <doubleWidth>;+@endif+@if (FLOAT_TYPE == "float") || FLOAT_TYPE == "RUNTIME_FLOAT"+ FRN_0 = FRM_0;+ goto <skip>;+@endif++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ <doubleWidth>+ DRN_1 = XDM_1;+@endif+ <skip>+}++# Floating-Point Transfer Extended #9 (based upon FPT #1c above)+# pattern 1111nnn0mmm11100+# text fmov <D_REG_M>,<DX_REG_N>+# arch arch_sh2a_or_sh4_up+:fmov DRM_1,XDN_1 is+ doublePrecMode=1 & doubleWidthMoveMode=0 &+ OP_0=0xf & XDN_1 & FRN_0 & OP_6=0x1 & DRM_1 & FRM_0 & OP_10=0x0 & OP_1=0xc {++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+# if (!( FPSCR_PR == 0 )) goto <doubleWidth>;+ if (!( FPSCR_SZ == 0 )) goto <doubleWidth>;+@endif+@if (FLOAT_TYPE == "float") || FLOAT_TYPE == "RUNTIME_FLOAT"+ FRN_0 = FRM_0;+ goto <skip>;+@endif++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ <doubleWidth>+ XDN_1 = DRM_1;+@endif+ <skip>+}++# Floating-Point Multiplication+# pattern 1111nnnnmmmm0010+# text fmul <F_REG_M>,<F_REG_N>+# arch arch_sh2e_up+:fmul FRM_0t,FRN_0t is+ doublePrecMode = 0 &+ OP_0=0xf & FRN_0t & DRN_1t & FRM_0t & DRM_1t & OP_1=0x2 {++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ if (!( FPSCR_PR == 0 )) goto <doublePrecision>;+@endif+@if (FLOAT_TYPE == "float") || FLOAT_TYPE == "RUNTIME_FLOAT"+ FRN_0t = FRN_0t f* FRM_0t;+ goto <skip>;+@endif++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ <doublePrecision>+ DRN_1t = DRN_1t f* DRM_1t;+@endif+ <skip>+}++# Floating-Point Multiplication+# pattern 1111nnn0mmm00010+# text fmul <D_REG_M>,<D_REG_N>+# arch arch_sh2a_or_sh4_up+:fmul DRM_1t,DRN_1t is+ doublePrecMode = 1 &+ OP_0=0xf & DRN_1t & FRN_0t & OP_6=0x0 & DRM_1t & FRM_0t & OP_7=0x2 {++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ if (!( FPSCR_PR == 0 )) goto <doublePrecision>;+@endif+@if (FLOAT_TYPE == "float") || FLOAT_TYPE == "RUNTIME_FLOAT"+ FRN_0t = FRN_0t f* FRM_0t;+ goto <skip>;+@endif++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ <doublePrecision>+ DRN_1t = DRN_1t f* DRM_1t;+@endif+ <skip>+}++# Floating-Point Sign Inversion+# pattern 1111nnnn01001101+# text fneg <F_REG_N>+# arch arch_sh2e_up+:fneg FRN_0t is+ doublePrecMode = 0 &+ OP_0=0xf & FRN_0t & DRN_1t & OP_6 & OP_4=0x4d {++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ if (!( FPSCR_PR == 0 )) && (OP_6:1 == 0) goto <doublePrecision>;+@endif+@if (FLOAT_TYPE == "float") || FLOAT_TYPE == "RUNTIME_FLOAT"+ FRN_0t = f- FRN_0t;+ goto <skip>;+@endif++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ <doublePrecision>+ DRN_1t = f- DRN_1t;+@endif+ <skip>+}++# Floating-Point Sign Inversion+# pattern 1111nnn001001101+# text fneg <D_REG_N>+# arch arch_sh2a_or_sh4_up+:fneg DRN_1t is+ doublePrecMode = 1 &+ OP_0=0xf & DRN_1t & FRN_0t & OP_5=0x4d {++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ if (!( FPSCR_PR == 0 )) goto <doublePrecision>;+@endif+@if (FLOAT_TYPE == "float") || FLOAT_TYPE == "RUNTIME_FLOAT"+ FRN_0t = f- FRN_0t;+ goto <skip>;+@endif++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ <doublePrecision>+ DRN_1t = f- DRN_1t;+@endif+ <skip>+}++# FR Bit Inversion+# pattern 1111101111111101+# text frchg+# arch # arch_sh4_up+:frchg is+ doublePrecMode = 0 &+ OP_3=0xfbfd {++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ if (!( FPSCR_PR == 0 )) goto <skip>;+@endif+@if (FLOAT_TYPE == "float") || FLOAT_TYPE == "RUNTIME_FLOAT"+ FPSCR_FR = !FPSCR_FR;+ FPSCR = FPSCR ^ 0x00200000;+@endif+ <skip>+}+++# SZ Bit Inversion+# pattern 1111001111111101+# text fschg+# arch arch_sh2a_or_sh4a_up (not in sh4)+:fschg is+ doublePrecMode = 0 &+ OP_3=0xf3fd [ doubleWidthMoveMode = (1 - doubleWidthMoveMode); globalset(inst_next,doubleWidthMoveMode); ] {++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ if (!( FPSCR_PR == 0 )) goto <skip>;+@endif+@if (FLOAT_TYPE == "float") || FLOAT_TYPE == "RUNTIME_FLOAT"+ FPSCR_SZ = !FPSCR_SZ;+ FPSCR = FPSCR ^ 0x00100000;+@endif+ <skip>+}++# PR Bit Inversion+# pattern 1111011111111101+# text fpchg+# arch arch_sh2a_or_sh4_up+:fpchg is+ OP_3=0xf7fd [ doubleWidthMoveMode = (1 - doubleWidthMoveMode); globalset(inst_next,doubleWidthMoveMode); ]+{+@if (FLOAT_TYPE == "float") || FLOAT_TYPE == "RUNTIME_FLOAT"+ FPSCR_PR = !FPSCR_PR;+ FPSCR = FPSCR ^ 0x00080000;+@endif+}++# Floating-Point Square Root+# pattern 1111nnnn01101101+# text fsqrt <F_REG_N>+# arch # arch_sh2a_or_sh3e_up+:fsqrt FRN_0t is+ doublePrecMode = 0 &+ OP_0=0xf & FRN_0t & DRN_1t & OP_4=0x6d {++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ if (!( FPSCR_PR == 0 )) goto <doublePrecision>;+@endif+@if (FLOAT_TYPE == "float") || FLOAT_TYPE == "RUNTIME_FLOAT"+ FRN_0t = sqrt( FRN_0t );+ goto <skip>;+@endif++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ <doublePrecision>+ DRN_1t = sqrt( DRN_1t );+@endif+ <skip>+}++# Floating-Point Square Root+# pattern 1111nnn001101101+# text fsqrt <D_REG_N>+# arch arch_sh2a_or_sh4_up+:fsqrt DRN_1t is+ doublePrecMode = 1 &+ OP_0=0xf & DRN_1t & FRN_0t & OP_5=0x6d {++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ if (!( FPSCR_PR == 0 )) goto <doublePrecision>;+@endif+@if (FLOAT_TYPE == "float") || FLOAT_TYPE == "RUNTIME_FLOAT"+ FRN_0t = sqrt( FRN_0t );+ goto <skip>;+@endif++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ <doublePrecision>+ DRN_1t = sqrt( DRN_1t );+@endif+ <skip>+}++# Transfer from System Register+# pattern 1111nnnn00001101+# text fsts FPUL,<F_REG_N>+# arch arch_sh2e_up+:fsts FPUL,FRN_0t is OP_0=0xf & FRN_0t & OP_4=0xd & FPUL {++ FRN_0t = FPUL;+}++# Floating-Point Subtraction+# pattern 1111nnnnmmmm0001+# text fsub <F_REG_M>,<F_REG_N>+# arch arch_sh2e_up+:fsub FRM_0t,FRN_0t is+ doublePrecMode = 0 &+ OP_0=0xf & FRN_0t & DRN_1t & FRM_0t & DRM_1t & OP_1=0x1 {++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ if (!( FPSCR_PR == 0 )) goto <doublePrecision>;+@endif+@if (FLOAT_TYPE == "float") || FLOAT_TYPE == "RUNTIME_FLOAT"+ FRN_0t = FRN_0t f- FRM_0t;+ goto <skip>;+@endif++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ <doublePrecision>+ DRN_1t = DRN_1t f- DRM_1t;+@endif+ <skip>+}++# Floating-Point Subtraction+# pattern 1111nnn0mmm00001+# text fsub <D_REG_M>,<D_REG_N>+# arch arch_sh2a_or_sh4_up+:fsub DRM_1t,DRN_1t is+ doublePrecMode = 1 &+ OP_0=0xf & DRN_1t & FRN_0t & OP_6=0x0 & DRM_1t & FRM_0t & OP_7=0x1 {++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ if (!( FPSCR_PR == 0 )) goto <doublePrecision>;+@endif+@if (FLOAT_TYPE == "float") || FLOAT_TYPE == "RUNTIME_FLOAT"+ FRN_0t = FRN_0t f- FRM_0t;+ goto <skip>;+@endif++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ <doublePrecision>+ DRN_1t = DRN_1t f- DRM_1t;+@endif+ <skip>+}+++# Conversion to Integer+# pattern 1111nnnn00111101+# text ftrc <F_REG_N>,FPUL+# # arch arch_sh2e_up+# Note: Field usage indicates FR[n], not FR[m].+:ftrc FRN_0t,FPUL is+ doublePrecMode = 0 &+ OP_0=0xf & FRN_0t & DRN_1t & OP_4=0x3d & FPUL {++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ if (!( FPSCR_PR == 0 )) goto <doublePrecision>;+@endif+@if (FLOAT_TYPE == "float") || FLOAT_TYPE == "RUNTIME_FLOAT"+ FPUL = trunc( FRN_0t );+ goto <skip>;+@endif++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ <doublePrecision>+ FPUL = trunc( DRN_1t );+@endif+ <skip>+}++# Conversion to Integer+# pattern 1111nnn000111101+# text ftrc <D_REG_N>,FPUL+# arch arch_sh2e_up+:ftrc DRN_1t,FPUL is+ doublePrecMode = 1 &+ OP_0=0xf & DRN_1t & FRN_0t & OP_5=0x3d & FPUL {++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ if (!( FPSCR_PR == 0 )) goto <doublePrecision>;+@endif+@if (FLOAT_TYPE == "float") || FLOAT_TYPE == "RUNTIME_FLOAT"+ FPUL = trunc( FRN_0t );+ goto <skip>;+@endif++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ <doublePrecision>+ FPUL = trunc( DRN_1t );+@endif+ <skip>+}++# Vector Transformation+# pattern 1111nn0111111101+# text ftrv XMTRX_M4,<V_REG_n>+# arch # arch_sh4_up+:ftrv XMTRX_t,FVN_2t is OP_0=0xf & FVN_2t & OP_8=0x1fd & XMTRX_t {++@if (FLOAT_TYPE == "double") || FLOAT_TYPE == "RUNTIME_FLOAT"+ if (!( FPSCR_PR == 0 )) goto <skip>;+@endif+@if (FLOAT_TYPE == "float") || FLOAT_TYPE == "RUNTIME_FLOAT"+ temp1:4 = ( xf0 f* *[register]:4 (&:4 FVN_2t + 0) );+ temp1 = temp1 f+ ( xf4 f* *[register]:4 (&:4 FVN_2t + 4) );+ temp1 = temp1 f+ ( xf8 f* *[register]:4 (&:4 FVN_2t + 8) );+ temp1 = temp1 f+ ( xf12 f* *[register]:4 (&:4 FVN_2t + 12) );++ temp2:4 = ( xf1 f* *[register]:4 (&:4 FVN_2t + 0) );+ temp2 = temp2 f+ ( xf5 f* *[register]:4 (&:4 FVN_2t + 4) );+ temp2 = temp2 f+ ( xf9 f* *[register]:4 (&:4 FVN_2t + 8) );+ temp2 = temp2 f+ ( xf13 f* *[register]:4 (&:4 FVN_2t + 12) );++ temp3:4 = ( xf2 f* *[register]:4 (&:4 FVN_2t + 0) );+ temp3 = temp3 f+ ( xf6 f* *[register]:4 (&:4 FVN_2t + 4) );+ temp3 = temp3 f+ ( xf10 f* *[register]:4 (&:4 FVN_2t + 8) );+ temp3 = temp3 f+ ( xf14 f* *[register]:4 (&:4 FVN_2t + 12) );++ temp4:4 = ( xf3 f* *[register]:4 (&:4 FVN_2t + 0) );+ temp4 = temp4 f+ ( xf7 f* *[register]:4 (&:4 FVN_2t + 4) );+ temp4 = temp4 f+ ( xf11 f* *[register]:4 (&:4 FVN_2t + 8) );+ temp4 = temp4 f+ ( xf15 f* *[register]:4 (&:4 FVN_2t + 12) );++ # summation goes to FR[n + 0] through FR[n + 3]+ *[register]:4 (&:4 FVN_2t + 0) = temp1;+ *[register]:4 (&:4 FVN_2t + 4) = temp2;+ *[register]:4 (&:4 FVN_2t + 8) = temp3;+ *[register]:4 (&:4 FVN_2t + 12) = temp4;+@endif+ <skip>+}+++# Invalidate Instruction Cache block+# pattern 0000nnnn11100011+# text icib @<REG_N>+# arch arch_sh_up+define pcodeop InvalidateCacheBlock;+:icbi N_0t_at1 is OP_0=0x0 & N_0t_at1 & OP_4=0xe3 {+ tmp:4 = N_0t_at1;+ InvalidateCacheBlock(N_0t_at1);+}++# Unconditional Branch+# pattern 0100nnnn00101011+# text jmp @<REG_N>+# arch arch_sh_up+:jmp N_0tjmp is OP_0=0x4 & N_0tjmp & OP_4=0x2b {++ PC = N_0tjmp;+ tmp:4 = PC;+ delayslot(1);+ goto [tmp];+}+++# Branch to Subroutine Procedure+# pattern 0100nnnn00001011+# text jsr @<REG_N>+# arch arch_sh_up+:jsr N_0tjmp is OP_0=0x4 & N_0tjmp & OP_4=0xb {++ PR = inst_next;+ PC = N_0tjmp;+ tmp:4 = PC;+ delayslot(1);+ call [tmp];+}+++# Load to Control Register+# pattern 0100nnnn00001110+# text ldc <REG_N>,SR+# arch arch_sh_up+:ldc N_0t_sr is OP_0=0x4 & N_0t_sr & OP_4=0xe {++ SR = (N_0t_sr & 0x700083f3);+ splitSRregister();+}+++# Load to Control Register+# pattern 0100nnnn00011110+# text ldc <REG_N>,GBR+# arch arch_sh_up+:ldc N_0t_gbr is OP_0=0x4 & N_0t_gbr & OP_4=0x1e {++ GBR = N_0t_gbr;+}+++# Load to Control Register+# pattern 0100nnnn00101110+# text ldc <REG_N>,VBR+# arch arch_sh_up+:ldc N_0t_vbr is OP_0=0x4 & N_0t_vbr & OP_4=0x2e {++ VBR = N_0t_vbr;+}+++# pattern 0100nnnn00111110+# text ldc <REG_N>,SSR+# arch arch_sh3_nommu_up+:ldc N_0t_ssr is OP_0=0x4 & N_0t_ssr & OP_4=0x3e {++ SSR = N_0t_ssr;+}+++# pattern 0100nnnn01001110+# text ldc <REG_N>,SPC+# arch arch_sh3_nommu_up+:ldc N_0t_spc is OP_0=0x4 & N_0t_spc & OP_4=0x4e {++ SPC = N_0t_spc;+}+++# pattern 0100nnnn11111010+# text ldc <REG_N>,DBR+# arch arch_sh4_nommu_nofpu_up+:ldc N_0t_dbr is OP_0=0x4 & N_0t_dbr & OP_4=0xfa {++ DBR = N_0t_dbr;+}++# pattern 0100nnnn1xxx1110+# text ldc <REG_N>,Rn_BANK+# arch arch_sh3_nommu_up+:ldc N_0t_bank,BANKt is OP_0=0x4 & N_0t_bank & OP_9=0x1 & BANKt & OP_1=0xe {++ BANKt = N_0t_bank;+}+++# Load to Control Register+# pattern 0100nnnn00000111+# text ldc.l @<REG_N>+,SR+# arch arch_sh_up+:ldc.l N_0t_sr1 is OP_0=0x4 & N_0t_sr1 & OP_4=0x7 {++ SR = (*:4 ( N_0t_sr1 )) & 0x700083F3;+ splitSRregister();+ N_0t_sr1 = N_0t_sr1 + 4;+}+++# Load to Control Register+# pattern 0100nnnn00010111+# text ldc.l @<REG_N>+,GBR+# arch arch_sh_up+:ldc.l N_0t_gbr1 is OP_0=0x4 & N_0t_gbr1 & OP_4=0x17 {++ GBR = *:4 ( N_0t_gbr1 );+ N_0t_gbr1 = N_0t_gbr1 + 4;+}+++# Load to Control Register+# pattern 0100nnnn00100111+# text ldc.l @<REG_N>+,VBR+# arch arch_sh_up+:ldc.l N_0t_vbr1 is OP_0=0x4 & N_0t_vbr1 & OP_4=0x27 {++ VBR = *:4 ( N_0t_vbr1 );+ N_0t_vbr1 = N_0t_vbr1 + 4;+}+++# pattern 0100nnnn00110111+# text ldc.l @<REG_N>+,SSR+# arch arch_sh3_nommu_up+:ldc.l N_0t_ssr1 is OP_0=0x4 & N_0t_ssr1 & OP_4=0x37 {++ SSR = *:4 ( N_0t_ssr1 );+ N_0t_ssr1 = N_0t_ssr1 + 4;+}+++# pattern 0100nnnn01000111+# text ldc.l @<REG_N>+,SPC+# arch arch_sh3_nommu_up+:ldc.l N_0t_spc1 is OP_0=0x4 & N_0t_spc1 & OP_4=0x47 {++ SPC = *:4 ( N_0t_spc1 );+ N_0t_spc1 = N_0t_spc1 + 4;+}+++# pattern 0100nnnn11110110+# text ldc.l @<REG_N>+,DBR+# arch arch_sh4_nommu_nofpu_up+:ldc.l N_0t_dbr1 is OP_0=0x4 & N_0t_dbr1 & OP_4=0xf6 {++ DBR = *:4 ( N_0t_dbr1 );+ N_0t_dbr1 = N_0t_dbr1 + 4;+}+++# pattern 0100nnnn1xxx0111+# text ldc.l @<REG_N>+,Rn_BANK+# arch arch_sh3_nommu_up+:ldc.l N_0t_bank1,BANKt is OP_0=0x4 & N_0t_bank1 & OP_9=0x1 & BANKt & OP_1=0x7 {++ BANKt = *:4 ( N_0t_bank1 );+ N_0t_bank1 = N_0t_bank1 + 4;+}+++# Load to FPU System Register+# pattern 0100nnnn01011010+# text lds <REG_N>,FPUL+# arch arch_sh2e_up+:lds N_0t_fpul is OP_0=0x4 & N_0t_fpul & OP_4=0x5a {++ FPUL = N_0t_fpul;+}+++# Load to FPU System Register+# pattern 0100nnnn01010110+# text lds.l @<REG_M>+,FPUL+# arch arch_sh2e_up+:lds.l N_0t_fpul1 is OP_0=0x4 & N_0t_fpul1 & OP_4=0x56 {++ FPUL = *:4 ( N_0t_fpul1 );+ N_0t_fpul1 = N_0t_fpul1 + 4;+}+++# Load to FPU System Register+# pattern 0100nnnn01101010+# text lds <REG_M>,FPSCR+# arch arch_sh2e_up+# Note: FPSCR context cannot be supported from this instruction; contents of N_0 not known at disassembly time.+:lds N_0t_fpscr is OP_0=0x4 & N_0t_fpscr & OP_4=0x6a {++ FPSCR = N_0t_fpscr & 0x003FFFFF;+ splitFPSCRregister();+}+++# Load to FPU System Register+# pattern 0100nnnn01100110+# text lds.l @<REG_M>+,FPSCR+# arch arch_sh2e_up+# Note: FPSCR context cannot be supported from this instruction; contents of N_0 not known at disassembly time.+:lds.l N_0t_fpscr1 is OP_0=0x4 & N_0t_fpscr1 & OP_4=0x66 {++ FPSCR = (*:4 ( N_0t_fpscr1 )) & 0x003FFFFF;+ splitFPSCRregister();+ N_0t_fpscr1 = N_0t_fpscr1 + 4;+}+++# Load to FPU System Register+# pattern 0100nnnn00001010+# text lds <REG_N>,MACH+# arch arch_sh_up+:lds N_0t_mach is OP_0=0x4 & N_0t_mach & OP_4=0xa {++ MACH = N_0t_mach;+}+++# Load to FPU System Register+# pattern 0100nnnn00011010+# text lds <REG_N>,MACL+# arch arch_sh_up+:lds N_0t_macl is OP_0=0x4 & N_0t_macl & OP_4=0x1a {++ MACL = N_0t_macl;+}+++# Load to FPU System Register+# pattern 0100nnnn00101010+# text lds <REG_N>,PR+# arch arch_sh_up+:lds N_0t_pr is OP_0=0x4 & N_0t_pr & OP_4=0x2a {++ PR = N_0t_pr;+}+++# Load to FPU System Register+# pattern 0100nnnn00000110+# text lds.l @<REG_N>+,MACH+# arch arch_sh_up+:lds.l N_0t_mach1 is OP_0=0x4 & N_0t_mach1 & OP_4=0x6 {++ MACH = *:4 ( N_0t_mach1 );+ N_0t_mach1 = N_0t_mach1 + 4;+}+++# Load to FPU System Register+# pattern 0100nnnn00010110+# text lds.l @<REG_N>+,MACL+# arch arch_sh_up+:lds.l N_0t_macl1 is OP_0=0x4 & N_0t_macl1 & OP_4=0x16 {++ MACL = *:4 ( N_0t_macl1 );+ N_0t_macl1 = N_0t_macl1 + 4;+}+++# Load to FPU System Register+# pattern 0100nnnn00100110+# text lds.l @<REG_N>+,PR+# arch arch_sh_up+:lds.l N_0t_pr1 is OP_0=0x4 & N_0t_pr1 & OP_4=0x26 {++ PR = *:4 ( N_0t_pr1 );+ N_0t_pr1 = N_0t_pr1 + 4;+}+++define pcodeop LoadTranslationLookasideBuffer;+# Load to TLB+# pattern 0000000000111000+# text ldtlb+# arch arch_sh3_up+:ldtlb is OP_3=0x38 { LoadTranslationLookasideBuffer(); }++# Double-Precision Multiply-and-Accumulate Operation+# pattern 0000nnnnmmmm1111+# text mac.l @<REG_M>+,@<REG_N>++# arch arch_sh2_up+define pcodeop mac_lOp;+++:mac.l M_0t_at,N_0t_at is OP_0=0x0 & OP_1=0xf & M_0t_at & N_0t_at {+ tmpM:4 = *:4 M_0t_at;+ tmpN:4 = *:4 N_0t_at;+ mac:8 = mac_lOp(tmpN,tmpM,MACH,MACL);+# POSSIBLE THIS WILL WORK WELL ENOUGH+# mac:8 = zext(MACH) << 4 + zext(MACL);+# mac = zext(tmpN) * zext(tmpM) + mac;+# mac = saturate(mac);+ MACL = mac:4;+ mac = mac >> 32;+ MACH = mac:4;+ M_0t_at = M_0t_at + 4;+ N_0t_at = N_0t_at + 4;+}++# Single-Precision Multiply-and-Accumulate Operation+# pattern 0100nnnnmmmm1111+# text mac.w @<REG_M>+,@<REG_N>++# arch arch_sh_up+define pcodeop mac_wOp;+++:mac.w M_0t_at,N_0t_at is OP_0=0x4 & OP_1=0xf & M_0t_at & N_0t_at {+ tmpM:4 = *:2 M_0t_at;+ tmpN:4 = *:2 N_0t_at;+ mac:8 = mac_wOp(tmpN,tmpM,MACH,MACL);+# POSSIBLE THIS WILL WORK WELL ENOUGH+# mac:8 = zext(MACH) << 4 + zext(MACL);+# mac = zext(tmpN) * zext(tmpM) + mac;+# mac = saturate(mac);+ MACL = mac:4;+ mac = mac >> 32;+ MACH = mac:4;+ M_0t_at = M_0t_at + 2;+ N_0t_at = N_0t_at + 2;+}++# Data Transfer+# pattern 0110nnnnmmmm0011+# text mov <REG_M>,<REG_N>+# arch arch_sh_up+:mov M_0t,N_0t is OP_0=0x6 & N_0t & M_0t & OP_1=0x3 {++ N_0t = M_0t;+}+++# Data Transfer+# pattern 0010nnnnmmmm0000+# text mov.b <REG_M>,@<REG_N>+# arch arch_sh_up+:mov.b M_0t,N_0t_at1 is OP_0=0x2 & N_0t_at1 & M_0t & OP_1=0x0 {++ *:1 ( N_0t_at1 ) = M_0t:1;+}+++# Data Transfer+# pattern 0010nnnnmmmm0001+# text mov.w <REG_M>,@<REG_N>+# arch arch_sh_up+:mov.w M_0t,N_0t_at1 is OP_0=0x2 & N_0t_at1 & M_0t & OP_1=0x1 {++ *:2 ( N_0t_at1 ) = M_0t:2;+}+++# Data Transfer+# pattern 0010nnnnmmmm0010+# text mov.l <REG_M>,@<REG_N>+# arch arch_sh_up+:mov.l M_0t,N_0t_at1 is OP_0=0x2 & N_0t_at1 & M_0t & OP_1=0x2 {++ *:4 ( N_0t_at1 ) = M_0t;+}+++# Data Transfer+# pattern 0110nnnnmmmm0000+# text mov.b @<REG_M>,<REG_N>+# arch arch_sh_up+:mov.b M_0t_at1,N_0t is OP_0=0x6 & N_0t & M_0t_at1 & OP_1=0x0 {++ N_0t = sext( *:1 ( M_0t_at1 ) );+}+++# Data Transfer+# pattern 0110nnnnmmmm0001+# text mov.w @<REG_M>,<REG_N>+# arch arch_sh_up+:mov.w M_0t_at1,N_0t is OP_0=0x6 & N_0t & M_0t_at1 & OP_1=0x1 {++ N_0t = sext( *:2 ( M_0t_at1 ) );+}+++# Data Transfer+# pattern 0110nnnnmmmm0010+# text mov.l @<REG_M>,<REG_N>+# arch arch_sh_up+:mov.l M_0t_at1,N_0t is OP_0=0x6 & N_0t & M_0t_at1 & OP_1=0x2 {++ N_0t = *:4 ( M_0t_at1 );+}+++# Data Transfer+# pattern 0010nnnnmmmm0100+# text mov.b <REG_M>,@-<REG_N>+# arch arch_sh_up+:mov.b M_0t,N_0t_at_neg is OP_0=0x2 & N_0t_at_neg & M_0t & OP_1=0x4 {++ N_0t_at_neg = N_0t_at_neg - 1;+ *:1 ( N_0t_at_neg ) = M_0t:1;+}+++# Data Transfer+# pattern 0010nnnnmmmm0101+# text mov.w <REG_M>,@-<REG_N>+# arch arch_sh_up+:mov.w M_0t,N_0t_at_neg is OP_0=0x2 & N_0t_at_neg & M_0t & OP_1=0x5 {++ N_0t_at_neg = N_0t_at_neg - 2;+ *:2 ( N_0t_at_neg ) = M_0t:2;+}+++# Data Transfer+# pattern 0010nnnnmmmm0110+# text mov.l <REG_M>,@-<REG_N>+# arch arch_sh_up+:mov.l M_0t,N_0t_at_neg is OP_0=0x2 & N_0t_at_neg & M_0t & OP_1=0x6 {++ N_0t_at_neg = N_0t_at_neg - 4;+ *:4 ( N_0t_at_neg ) = M_0t;+}+++# Data Transfer+# pattern 0110nnnnmmmm0100+# text mov.b @<REG_M>+,<REG_N>+# arch arch_sh_up+:mov.b M_0t_at,N_0t is OP_0=0x6 & N_0t & M_0t_at & OP_1=0x4 {++ N_0t = sext( *:1 ( M_0t_at ) );+ M_0t_at = M_0t_at + 1;+}+++# Data Transfer+# pattern 0110nnnnmmmm0101+# text mov.w @<REG_M>+,<REG_N>+# arch arch_sh_up+:mov.w M_0t_at,N_0t is OP_0=0x6 & N_0t & M_0t_at & OP_1=0x5 {++ N_0t = sext( *:2 ( M_0t_at ) );+ M_0t_at = M_0t_at + 2;+}+++# Data Transfer+# pattern 0110nnnnmmmm0110+# text mov.l @<REG_M>+,<REG_N>+# arch arch_sh_up+:mov.l M_0t_at,N_0t is OP_0=0x6 & N_0t & M_0t_at & OP_1=0x6 {++ N_0t = *:4 ( M_0t_at );+ M_0t_at = M_0t_at + 4;+}+++# Data Transfer+# pattern 0000nnnnmmmm0100+# text mov.b <REG_M>,@(R0,<REG_N>)+# arch arch_sh_up+:mov.b M_0t,N_0t_at_with_r0 is OP_0=0x0 & N_0t_at_with_r0 & M_0t & OP_1=0x4 {++ *:1 ( r0 + N_0t_at_with_r0 ) = M_0t:1;+}+++# Data Transfer+# pattern 0000nnnnmmmm0101+# text mov.w <REG_M>,@(R0,<REG_N>)+# arch arch_sh_up+:mov.w M_0t,N_0t_at_with_r0 is OP_0=0x0 & N_0t_at_with_r0 & M_0t & OP_1=0x5 {++ *:2 ( r0 + N_0t_at_with_r0 ) = M_0t:2;+}+++# Data Transfer+# pattern 0000nnnnmmmm0110+# text mov.l <REG_M>,@(R0,<REG_N>)+# arch arch_sh_up+:mov.l M_0t,N_0t_at_with_r0 is OP_0=0x0 & N_0t_at_with_r0 & M_0t & OP_1=0x6 {++ *:4 ( r0 + N_0t_at_with_r0 ) = M_0t;+}+++# Data Transfer+# pattern 0000nnnnmmmm1100+# text mov.b @(R0,<REG_M>),<REG_N>+# arch arch_sh_up+:mov.b M_0t_at_with_r0,N_0t is OP_0=0x0 & N_0t & M_0t_at_with_r0 & OP_1=0xc {++ N_0t = sext( *:1 ( r0 + M_0t_at_with_r0 ) );+}+++# Data Transfer+# pattern 0000nnnnmmmm1101+# text mov.w @(R0,<REG_M>),<REG_N>+# arch arch_sh_up+:mov.w M_0t_at_with_r0,N_0t is OP_0=0x0 & N_0t & M_0t_at_with_r0 & OP_1=0xd {++ N_0t = sext( *:2 ( r0 + M_0t_at_with_r0 ) );+}+++# Data Transfer+# pattern 0000nnnnmmmm1110+# text mov.l @(R0,<REG_M>),<REG_N>+# arch arch_sh_up+:mov.l M_0t_at_with_r0,N_0t is OP_0=0x0 & N_0t & M_0t_at_with_r0 & OP_1=0xe {++ N_0t = *:4 ( r0 + M_0t_at_with_r0 );+}+++# Data Transfer+# pattern 1110nnnniiiiiiii+# text mov #<imm>,<REG_N>+# arch arch_sh_up+:mov I_0t,N_0t is OP_0=0xe & N_0t & I_0t {++ N_0t = I_0t; # NOTE I_0t already signed extended+}+++# Data Transfer+# pattern 1001nnnndddddddd+# text mov.w @(<disp>,PC),<REG_N>+# arch arch_sh_up+:mov.w U_0t_2pc,N_0t is OP_0=0x9 & N_0t & U_0t_2pc {++ N_0t = sext( U_0t_2pc ); # NOTE U_0t_2pc units is bytes+}+++# Data Transfer+# pattern 1101nnnndddddddd+# text mov.l @(<disp>,PC),<REG_N>+# arch arch_sh_up+:mov.l U_0t_4pc,N_0t is OP_0=0xd & N_0t & U_0t_4pc {++ N_0t = U_0t_4pc; # NOTE U_0t_4pc units is bytes+}+++# Data Transfer+# pattern 11000100dddddddd+# text mov.b @(<disp>,GBR),R0+# arch arch_sh_up+:mov.b U_0t_gbr_at_1,r0 is OP_2=0xc4 & U_0t_gbr_at_1 & r0 {++ r0 = sext( *:1 ( U_0t_gbr_at_1 ) );+}+++# Data Transfer+# pattern 11000101dddddddd+# text mov.w @(<disp>,GBR),R0+# arch arch_sh_up+:mov.w U_0t_gbr_at_2,r0 is OP_2=0xc5 & U_0t_gbr_at_2 & r0 {++ r0 = sext( *:2 ( U_0t_gbr_at_2 ) ); # NOTE U_0t_gbr_at_2 units is bytes+}+++# Data Transfer+# pattern 11000110dddddddd+# text mov.l @(<disp>,GBR),R0+# arch arch_sh_up+:mov.l U_0t_gbr_at_4,r0 is OP_2=0xc6 & U_0t_gbr_at_4 & r0 {++ r0 = *:4 ( U_0t_gbr_at_4 ); # NOTE U_0t_gbr_at_4 units is bytes+}+++# Data Transfer+# pattern 11000000dddddddd+# text mov.b R0,@(<disp>,GBR)+# arch arch_sh_up+:mov.b r0,U_0t_gbr_at_1 is OP_2=0xc0 & U_0t_gbr_at_1 & r0 {++ *:1 ( U_0t_gbr_at_1 ) = r0:1;+}+++# Data Transfer+# pattern 11000001dddddddd+# text mov.w R0,@(<disp>,GBR)+# arch arch_sh_up+:mov.w r0,U_0t_gbr_at_2 is OP_2=0xc1 & U_0t_gbr_at_2 & r0 {++ *:2 ( U_0t_gbr_at_2 ) = r0:2; # NOTE U_0t_gbr_at_2 units is bytes+}+++# Data Transfer+# pattern 11000010dddddddd+# text mov.l R0,@(<disp>,GBR)+# arch arch_sh_up+:mov.l r0, U_0t_gbr_at_4 is OP_2=0xc2 & U_0t_gbr_at_4 & r0 {++ *:4 ( U_0t_gbr_at_4 ) = r0; # NOTE U_0t_4_at_gbr_r0_1 units is bytes+}+++# Data Transfer+# pattern 10000000mmmmdddd+# text mov.b R0,@(<disp>,<REG_M>)+# arch arch_sh_up+:mov.b r0,U_2t_M0_dispr01 is OP_2=0x80 & M_0t & U_2t_M0_dispr01 & r0 {++ *:1 ( U_2t_M0_dispr01 + M_0t ) = r0:1;+}+++# Data Transfer+# pattern 10000001mmmmdddd+# text mov.w R0,@(<disp>,<REG_M>)+# arch arch_sh_up+:mov.w r0,U_2t_M0_dispr02 is OP_2=0x81 & M_0t & U_2t_M0_dispr02 & r0 {++ *:2 ( U_2t_M0_dispr02 + M_0t ) = r0:2; # NOTE U_2t_M0_dispr02 units is bytes+}+++# Data Transfer+# pattern 0001nnnnmmmmdddd+# text mov.l <REG_M>,@(<disp>,<REG_N>)+# arch arch_sh_up+:mov.l M_0t,U_2t_N0_dispr04 is OP_0=0x1 & M_0t & N_0t & U_2t_N0_dispr04 {++ *:4 ( U_2t_N0_dispr04 + N_0t ) = M_0t; # NOTE U_2t_N0_dispr04 units is bytes+}+++# Data Transfer+# pattern 10000100mmmmdddd+# text mov.b @(<disp>,<REG_M>),R0+# arch arch_sh_up+:mov.b U_2t_M0_dispr01,r0 is OP_2=0x84 & M_0t & U_2t_M0_dispr01 & r0 {++ r0 = sext( *:1 ( U_2t_M0_dispr01 + M_0t ) );+}+++# Data Transfer+# pattern 10000101mmmmdddd+# text mov.w @(<disp>,<REG_M>),R0+# arch arch_sh_up+:mov.w U_2t_M0_dispr02,r0 is OP_2=0x85 & U_2t_M0_dispr02 & M_0t & r0 {++ r0 = sext( *:2 ( U_2t_M0_dispr02 + M_0t ) ); # NOTE U_2t_M0_dispr02 units is bytes+}+++# Data Transfer+# pattern 0101nnnnmmmmdddd+# text mov.l @(<disp>,<REG_M>),<REG_N>+# arch arch_sh_up+:mov.l U_2t_M0_dispr04,N_0t is OP_0=0x5 & N_0t & M_0t & U_2t_M0_dispr04 {++ N_0t = *:4 ( U_2t_M0_dispr04 + M_0t ); # NOTE U_2t_M0_dispr04 units is bytes+}+++# Effective Address Transfer+# pattern 11000111iiiiiiii+# text mova @(<disp>,PC),R0+# arch arch_sh_up+:mova U_0t_4pc,r0 is OP_2=0xc7 & U_0t_4pc & r0 {++ r0 = &U_0t_4pc; # NOTE U_0t_4pc units is bytes+}+++# MOVe with Cache block Allocation+# pattern 0000nnnn11000011+# text movca.l R0,@<REG_N>+# arch arch_sh4_nommu_nofpu_up+:movca.l N_0txx is OP_0=0x0 & N_0txx & OP_4=0xc3 {++ *:4 ( N_0txx ) = r0; # NOTE ignore cache issues+}++# T Bit Transfer+# pattern 0000nnnn00101001+# text movt <REG_N>+# arch+:movt N_0t is OP_0=0x0 & N_0t & OP_4=0x29 {++ N_0t = zext(T);+}+++# Double-Precision Multiplication+# pattern 0000nnnnmmmm0111+# text mul.l <REG_M>,<REG_N>+# arch+:mul.l M_0t,N_0t is OP_0=0x0 & N_0t & M_0t & OP_1=0x7 {++ MACL = N_0t * M_0t;+}+++# Signed Multiplication+# pattern 0010nnnnmmmm1111+# text muls.w <REG_M>,<REG_N>+# arch+:muls.w M_0t,N_0t is OP_0=0x2 & N_0t & M_0t & OP_1=0xf {++ MACL = sext(N_0t:2) * sext(M_0t:2);+}+++# Unsigned Multiplication+# pattern 0010nnnnmmmm1110+# text mulu.w <REG_M>,<REG_N>+# arch+:mulu.w M_0t,N_0t is OP_0=0x2 & N_0t & M_0t & OP_1=0xe {++ MACL = zext(N_0t:2) * zext(M_0t:2);+}+++# Sign Inversion+# pattern 0110nnnnmmmm1011+# text neg <REG_M>,<REG_N>+# arch+:neg M_0t,N_0t is OP_0=0x6 & N_0t & M_0t & OP_1=0xb {++ N_0t = -M_0t;+}+++# Sign Inversion with Borrow+# pattern 0110nnnnmmmm1010+# text negc <REG_M>,<REG_N>+# arch+:negc M_0t,N_0t is OP_0=0x6 & N_0t & M_0t & OP_1=0xa {++ temp:4 = -M_0t;+ N_0t = temp - zext(T);+ T = ( 0 < temp );+ if ( temp >= N_0t ) goto <skip>;+ T = 1;+ <skip>+}+++# No Operation+# pattern 0000000000001001+# text nop+# arch+:nop is OP_3=0x9 { } # Empty on purpose+++# Bit Inversion+# pattern 0110nnnnmmmm0111+# text not <REG_M>,<REG_N>+# arch+:not M_0t,N_0t is OP_0=0x6 & N_0t & M_0t & OP_1=0x7 {++ N_0t = ~M_0t;+}+++define pcodeop CacheBlockInvalidate;+# Operand Cache Block Invalidate+# pattern 0000nnnn10010011+# text ocbi @<REG_N>+# arch+:ocbi N_0t_at1 is OP_0=0x0 & N_0t_at1 & OP_4=0x93 { CacheBlockInvalidate(N_0t_at1); }+++define pcodeop CacheBlockPurge;+# Cache Block Purge+# pattern 0000nnnn10100011+# text ocbp @<REG_N>+# arch+:ocbp N_0t_at1 is OP_0=0x0 & N_0t_at1 & OP_4=0xa3 { CacheBlockPurge(N_0t_at1); }+++define pcodeop CacheBlockWriteBack;+# TODO ocbwb+# Cache Block Write-Back+# pattern 0000nnnn10110011+# text ocbwb @<REG_N>+# arch+:ocbwb N_0t_at1 is OP_0=0x0 & N_0t_at1 & OP_4=0xb3 { CacheBlockWriteBack(N_0t_at1); }+++# Logical OR+# pattern 0010nnnnmmmm1011+# text or <REG_M>,<REG_N>+# arch+:or M_0t,N_0t is OP_0=0x2 & N_0t & M_0t & OP_1=0xb {++ N_0t = N_0t | M_0t;+}+++# Logical OR+# pattern 11001011iiiiiiii+# text or #<imm>,R0+# arch+:or U_0t_r0 is OP_2=0xcb & U_0t_r0 {++ r0 = r0 | U_0t_r0;+}+++# Logical OR+# pattern 11001111iiiiiiii+# text or.b #<imm>,@(R0,GBR)+# arch+:or.b U_0t1 is OP_2=0xcf & U_0t1 {++ *:1 (GBR + r0) = ( *:1 (GBR + r0) ) | U_0t1;+}+++# Prefetch to Data Cache+# pattern 0000nnnn10000011+# text pref @<REG_N>+# arch+:pref N_0tjmp is OP_0=0x0 & N_0tjmp & OP_4=0x83 { } # Empty on purpose+++# One-Bit Left Rotation through T Bit+# pattern 0100nnnn00100100+# text rotcl <REG_N>+# arch+:rotcl N_0t is OP_0=0x4 & N_0t & OP_4=0x24 {++ temp:1 = ( (N_0t & 0x80000000) != 0 );+ N_0t = (N_0t << 1) | zext(T);+ T = temp;+}++# One-Bit Right Rotation through T Bit+# pattern 0100nnnn00100101+# text rotcr <REG_N>+# arch+:rotcr N_0t is OP_0=0x4 & N_0t & OP_4=0x25 {++ temp:1 = ( (N_0t & 0x00000001) != 0 );+ N_0t = ( N_0t >> 1 ) | ( zext(T) << 31 );+ T = temp;+}+++# One-Bit Left Rotation+# pattern 0100nnnn00000100+# text rotl <REG_N>+# arch+:rotl N_0t is OP_0=0x4 & N_0t & OP_4=0x4{++ T = ( (N_0t & 0x80000000) != 0 );+ N_0t = (N_0t << 1) | zext(T);+}+++# One-Bit Right Rotation+# pattern 0100nnnn00000101+# text rotr <REG_N>+# arch+:rotr N_0t is OP_0=0x4 & N_0t & OP_4=0x5 {++ T = ( (N_0t & 0x00000001) != 0 );+ N_0t = ( N_0t >> 1 ) | ( zext(T) << 31 );+}+++# Return from Exception Handling+# pattern 0000000000101011+# text rte+# arch+:rte is OP_3=0x2b {++ SR = SSR;+ splitSRregister();+ PC = SPC;+ delayslot(1);+ return [PC];+}+++# Return from Subroutine Procedure+# pattern 0000000000001011+# text rts+# arch+:rts is OP_3=0xb {++ PC = PR;+ delayslot(1);+ return [PC];+}+++# S Bit Setting+# pattern 0000000001011000+# text sets+# arch+:sets is OP_3=0x58 {++ S = 1;+}+++# T Bit Setting+# pattern 0000000000011000+# text sett+# arch+:sett is OP_3=0x18 {++ T = 1;+}+++# Note: this constructor follows the description on page 393 precisely, though simpler,+# it should produce identical results to the pseudo-code above+:shad M_0t,N_0t is OP_0=0x4 & N_0t & M_0t & OP_1=0xc {++ if ( M_0t s< 0 ) goto <shiftRight>;+ N_0t = N_0t << ( M_0t & 0x1f );+ goto <skip>;++ <shiftRight>+ N_0t = N_0t s>> ( ( ~M_0t & 0x1f ) + 1 );+ <skip>+}+++# One-Bit Left Arithmetic Shift+# pattern 0100nnnn00100000+# text shal <REG_N>+# arch+:shal N_0t is OP_0=0x4 & N_0t & OP_4=0x20 {++ T = ( ( N_0t & 0x80000000 ) != 0 );+ N_0t = N_0t << 1;+}+++# One-Bit Right Arithmetic Shift+# pattern 0100nnnn00100001+# text shar <REG_N>+# arch+:shar N_0t is OP_0=0x4 & N_0t & OP_4=0x21 {++ T = ( ( N_0t & 0x00000001 ) != 0 );+ N_0t = N_0t s>> 1;+}+++# Note: this constructor follows the description on page 397 precisely, though simpler,+# it should produce identical results to the pseudo-code above+:shld M_0t,N_0t is OP_0=0x4 & N_0t & M_0t & OP_1=0xd {++ if ( M_0t s< 0 ) goto <shiftRight>;+ N_0t = N_0t << ( M_0t & 0x1f );+ goto <skip>;++ <shiftRight>+ N_0t = N_0t >> ( ( ~M_0t & 0x1f ) + 1 );+ <skip>+}+++# n-Bit Left Logical Shift+# One-Bit Left Logical Shift+# pattern 0100nnnn00000000+# text shll <REG_N>+# arch+:shll N_0t is OP_0=0x4 & N_0t & OP_4=0x0 {++ T = ( ( N_0t & 0x80000000 ) != 0 );+ N_0t = N_0t << 1;+}+++# n-Bit Left Logical Shift+# pattern 0100nnnn00001000+# text shll2 <REG_N>+# arch+:shll2 N_0t is OP_0=0x4 & N_0t & OP_4=0x8 {++ N_0t = ( N_0t << 2 );+}+++# n-Bit Left Logical Shift+# pattern 0100nnnn00011000+# text shll8 <REG_N>+# arch+:shll8 N_0t is OP_0=0x4 & N_0t & OP_4=0x18 {++ N_0t = ( N_0t << 8 );+}+++# pattern 0100nnnn00101000+# text shll16 <REG_N>+# arch+:shll16 N_0t is OP_0=0x4 & N_0t & OP_4=0x28 {++ N_0t = ( N_0t << 16 );+}+++# One-Bit Right Logical Shift+# pattern 0100nnnn00000001+# text shlr <REG_N>+# arch+:shlr N_0t is OP_0=0x4 & N_0t & OP_4=0x1 {++ T = ( ( N_0t & 0x00000001 ) != 0 );+ N_0t = N_0t >> 1;+}+++# n-Bit Left Logical Shift+# pattern 0100nnnn00001001+# text shlr2 <REG_N>+# arch+:shlr2 N_0t is OP_0=0x4 & N_0t & OP_4=0x9 {++ N_0t = N_0t >> 2;+}+++# n-Bit Left Logical Shift+# pattern 0100nnnn00011001+# text shlr8 <REG_N>+# arch+:shlr8 N_0t is OP_0=0x4 & N_0t & OP_4=0x19 {++ N_0t = N_0t >> 8;+}+++# n-Bit Left Logical Shift+# pattern 0100nnnn00101001+# text shlr16 <REG_N>+# arch+:shlr16 N_0t is OP_0=0x4 & N_0t & OP_4=0x29 {++ N_0t = N_0t >> 16;+}+++# Transition to Power-Down Mode+# pattern 0000000000011011+# text sleep+# arch+:sleep is OP_3=0x1b { } # empty on purpose+++# Store from Control Register+# pattern 0000nnnn00000010+# text stc SR,<REG_N>+# arch arch_sh_up+:stc sr_N_0t is OP_0=0x0 & sr_N_0t & OP_4=0x2 {++ genSRregister();+ sr_N_0t = SR;+}+++# Store from Control Register+# pattern 0000nnnn00010010+# text stc GBR,<REG_N>+# arch+:stc gbr_N_0t is OP_0=0x0 & gbr_N_0t & OP_4=0x12 {++ gbr_N_0t = GBR;+}+++# Store from Control Register+# pattern 0000nnnn00100010+# text stc VBR,<REG_N>+# arch arch_sh_up+:stc vbr_N_0t is OP_0=0x0 & vbr_N_0t & OP_4=0x22 {++ vbr_N_0t = VBR;+}+++# pattern 0000nnnn00110010+# text stc SSR,<REG_N>+# arch arch_sh3_nommu_up+:stc ssr_N_0t is OP_0=0x0 & ssr_N_0t & OP_4=0x32 {++ ssr_N_0t = SSR;+}+++# pattern 0000nnnn01000010+# text stc SPC,<REG_N>+# arch arch_sh3_nommu_up+#+:stc spc_N_0t is OP_0=0x0 & spc_N_0t & OP_4=0x42 {++ spc_N_0t = SPC;+}+++# pattern 0000nnnn00111010+# text stc SGR,<REG_N>+# arch arch_sh4_nommu_nofpu_up+:stc sgr_N_0t is OP_0=0x0 & sgr_N_0t & OP_4=0x3a {++ sgr_N_0t = SGR;+}+++# pattern 0000nnnn11111010+# text stc DBR,<REG_N>+# arch arch_sh4_nommu_nofpu_up+:stc dbr_N_0t is OP_0=0x0 & dbr_N_0t & OP_4=0xfa {++ dbr_N_0t = DBR;+}+++# pattern 0000nnnn1xxx0010+# text stc Rn_BANK,<REG_N>+# arch arch_sh3_nommu_up+:stc BANKt,N_0t_bank is OP_0=0x0 & N_0t_bank & OP_9=0x1 & BANKt & OP_1=0x2 {++ N_0t_bank = BANKt;+}+++# Store from Control Register+# pattern 0100nnnn00000011+# text stc.l SR,@-<REG_N>+# arch arch_sh_up+:stc.l sr_t,N_0t_at_neg is OP_0=0x4 & N_0t_at_neg & OP_4=0x3 & sr_t {++ N_0t_at_neg = N_0t_at_neg - 4;+ genSRregister();+ *:4 ( N_0t_at_neg ) = SR;+}+++# Store from Control Register+# pattern 0100nnnn00010011+# text stc.l GBR,@-<REG_N>+# arch arch_sh_up+:stc.l gbr_t,N_0t_at_neg is OP_0=0x4 & N_0t_at_neg & OP_4=0x13 & gbr_t {++ N_0t_at_neg = N_0t_at_neg - 4;+ *:4 ( N_0t_at_neg ) = GBR;+}+++# Store from Control Register+# pattern 0100nnnn00100011+# text stc.l VBR,@-<REG_N>+# arch arch_sh_up+:stc.l vbr_t,N_0t_at_neg is OP_0=0x4 & N_0t_at_neg & OP_4=0x23 & vbr_t {++ N_0t_at_neg = N_0t_at_neg - 4;+ *:4 ( N_0t_at_neg ) = VBR;+}+++# pattern 0100nnnn00110011+# text stc.l SSR,@-<REG_N>+# arch arch_sh3_nommu_up+:stc.l ssr_t,N_0t_at_neg is OP_0=0x4 & N_0t_at_neg & OP_4=0x33 & ssr_t {++ N_0t_at_neg = N_0t_at_neg - 4;+ *:4 ( N_0t_at_neg ) = SSR;+}+++# pattern 0100nnnn01000011+# text stc.l SPC,@-<REG_N>+# arch arch_sh3_nommu_up+:stc.l spc_t,N_0t_at_neg is OP_0=0x4 & N_0t_at_neg & OP_4=0x43 & spc_t {++ N_0t_at_neg = N_0t_at_neg - 4;+ *:4 ( N_0t_at_neg ) = SPC;+}+++# pattern 0100nnnn00110010+# text stc.l SGR,@-<REG_N>+# arch arch_sh4_nommu_nofpu_up+:stc.l sgr_t,N_0t_at_neg is OP_0=0x4 & N_0t_at_neg & OP_4=0x32 & sgr_t {++ N_0t_at_neg = N_0t_at_neg - 4;+ *:4 ( N_0t_at_neg ) = SGR;+}+++# pattern 0100nnnn11110010+# text stc.l DBR,@-<REG_N>+# arch arch_sh4_nommu_nofpu_up+:stc.l dbr_t,N_0t_at_neg is OP_0=0x4 & N_0t_at_neg & OP_4=0xf2 & dbr_t {++ N_0t_at_neg = N_0t_at_neg - 4;+ *:4 ( N_0t_at_neg ) = DBR;+}+++# pattern 0100nnnn1xxx0011+# text stc.l Rn_BANK,@-<REG_N>+# arch arch_sh3_nommu_up+:stc.l BANKt,N_0t_at_neg is OP_0=0x4 & N_0t_at_neg & OP_9=0x1 & BANKt & OP_1=0x3 {++ N_0t_at_neg = N_0t_at_neg - 4;+ *:4 ( N_0t_at_neg ) = BANKt;+}+++# Store from System Register+# pattern 0000nnnn00001010+# text sts MACH,<REG_N>+# arch arch_sh_up+:sts mach_N_0t is OP_0=0x0 & mach_N_0t & OP_4=0xa {++ mach_N_0t = MACH;+}+++# Store from System Register+# pattern 0000nnnn00011010+# text sts MACL,<REG_N>+# arch arch_sh_up+:sts macl_N_0t is OP_0=0x0 & macl_N_0t & OP_4=0x1a {++ macl_N_0t = MACL;+}+++# Store from System Register+# pattern 0000nnnn00101010+# text sts PR,<REG_N>+# arch arch_sh_up+:sts pr_N_0t is OP_0=0x0 & pr_N_0t & OP_4=0x2a {++ pr_N_0t = PR;+}+++# Store from Control Register+# pattern 0100nnnn00000010+# text sts.l MACH,@-<REG_N>+# arch arch_sh_up+:sts.l mach_t,N_0t_at_neg is OP_0=0x4 & N_0t_at_neg & OP_4=0x2 & mach_t {++ N_0t_at_neg = N_0t_at_neg - 4;+ *:4 ( N_0t_at_neg ) = MACH;+}+++# Store from Control Register+# pattern 0100nnnn00010010+# text sts.l MACL,@-<REG_N>+# arch arch_sh_up+:sts.l macl_t,N_0t_at_neg is OP_0=0x4 & N_0t_at_neg & OP_4=0x12 & macl_t {++ N_0t_at_neg = N_0t_at_neg - 4;+ *:4 ( N_0t_at_neg ) = MACL;+}+++# Store from Control Register+# pattern 0100nnnn00100010+# text sts.l PR,@-<REG_N>+# arch arch_sh_up+:sts.l PR,N_0t_at_neg is OP_0=0x4 & N_0t_at_neg & OP_4=0x22 & PR {++ N_0t_at_neg = N_0t_at_neg - 4;+ *:4 ( N_0t_at_neg ) = PR;+}+++# Store from System Register+# pattern 0000nnnn01011010+# text sts FPUL,<REG_N>+# arch arch_sh2e_up+:sts fpul_N_0t is OP_0=0x0 & fpul_N_0t & OP_4=0x5a {++ fpul_N_0t = FPUL;+}+++# Store from System Register+# pattern 0000nnnn01101010+# text sts FPSCR,<REG_N>+# arch arch_sh2e_up+:sts fpscr_N_0t is OP_0=0x0 & fpscr_N_0t & OP_4=0x6a {++ genFPSCRregister();+ fpscr_N_0t = FPSCR;+}+++# Store from Control Register+# pattern 0100nnnn01010010+# text sts.l FPUL,@-<REG_N>+# arch arch_sh2e_up+:sts.l fpul_t,N_0t_at_neg is OP_0=0x4 & N_0t_at_neg & OP_4=0x52 & fpul_t {++ N_0t_at_neg = N_0t_at_neg - 4;+ *:4 ( N_0t_at_neg ) = FPUL;+}+++# Store from Control Register+# pattern 0100nnnn01100010+# text sts.l FPSCR,@-<REG_N>+# arch arch_sh2e_up+:sts.l fpscr_t,N_0t_at_neg is OP_0=0x4 & N_0t_at_neg & OP_4=0x62 & fpscr_t {++ N_0t_at_neg = N_0t_at_neg - 4;+ genFPSCRregister();+ *:4 ( N_0t_at_neg ) = FPSCR;+}+++# Binary Subtraction+# pattern 0011nnnnmmmm1000+# text sub <REG_M>,<REG_N>+# arch arch_sh_up+:sub M_0t,N_0t is OP_0=0x3 & N_0t & M_0t & OP_1=0x8 {++ N_0t = N_0t - M_0t;+}+++# Binary Subtraction with Borrow+# pattern 0011nnnnmmmm1010+# text subc <REG_M>,<REG_N>+# arch arch_sh_up+:subc M_0t,N_0t is OP_0=0x3 & N_0t & M_0t & OP_1=0xa {++ tmp1:4 = N_0t - M_0t;+ tmp0:4 = N_0t;+ N_0t = tmp1 - zext(T);+ T = ( tmp0 < tmp1 );+ if ( tmp1 >= N_0t ) goto <skip>;+ T = 1;+ <skip>+}+++# Binary Subtraction with Underflow Check+# pattern 0011nnnnmmmm1011+# text subv <REG_M>,<REG_N>+# arch arch_sh_up+:subv M_0t,N_0t is OP_0=0x3 & N_0t & M_0t & OP_1=0xb {++ local dest = ( N_0t s< 0 );+ local src = ( M_0t s< 0 );+ src = src + dest;+ N_0t = N_0t - M_0t;+ local ans = ( N_0t s< 0 );+ ans = ans + dest;+ T = ( (src == 1) && (ans == 1) );+}+++# Upper-/Lower-Half Swap+# pattern 0110nnnnmmmm1000+# text swap.b <REG_M>,<REG_N>+# arch arch_sh_up+:swap.b M_0t,N_0t is OP_0=0x6 & N_0t & M_0t & OP_1=0x8 {++ N_0t = ( M_0t & 0xFFFF0000 ) |+ ( ( M_0t & 0x000000FF ) << 8 ) |+ ( ( M_0t & 0x0000FF00 ) >> 8 );+}+++# Upper-/Lower-Half Swap+# pattern 0110nnnnmmmm1001+# text swap.w <REG_M>,<REG_N>+# arch arch_sh_up+:swap.w M_0t,N_0t is OP_0=0x6 & N_0t & M_0t & OP_1=0x9 {++ N_0t = ( M_0t << 16 ) | ( M_0t >> 16 );+}++# Synchronize Data Operation+# pattern 0000000010101011+# text synco+# arch arch_sh4a_up+define pcodeop SynchronizeDataOperation;+:synco is OP_3=0x00ab {+ SynchronizeDataOperation();+}+++# Memory Test and Bit Setting+# pattern 0100nnnn00011011+# text tas.b @<REG_N>+# arch arch_sh_up+:tas.b N_0t_at1 is OP_0=0x4 & N_0t_at1 & OP_4=0x1b {++ temp:1 = *:1 ( N_0t_at1 );+ T = ( temp == 0 );+ temp = temp | 0x80;+ *:1 ( N_0t_at1 ) = temp;+}+++define pcodeop TrapAlways;+# Trap Exception Handling+# pattern 11000011iiiiiiii+# text trapa #<imm>+# arch arch_sh_up+:trapa U_0t is OP_2=0xc3 & U_0t { TrapAlways(U_0t); }+++# AND Operation T Bit Setting+# pattern 0010nnnnmmmm1000+# text tst <REG_M>,<REG_N>+# arch arch_sh_up+:tst M_0t,N_0t is OP_0=0x2 & N_0t & M_0t & OP_1=0x8 {++ T = ( (N_0t & M_0t) == 0 );+}+++# AND Operation T Bit Setting+# pattern 11001000iiiiiiii+# text tst #<imm>,R0+# arch arch_sh_up+:tst U_0t_r0 is OP_2=0xc8 & U_0t_r0 {++ T = ( ( r0 & U_0t_r0 ) == 0 );+}+++# AND Operation T Bit Setting+# pattern 11001100iiiiiiii+# text tst.b #<imm>,@(R0,GBR)+# arch arch_sh_up+:tst.b U_0t1 is OP_2=0xcc & U_0t1 {++ T = ( ( (*:1 ( GBR + r0 )) & U_0t1 ) == 0 );+}+++# pattern 0010nnnnmmmm1010+# text xor <REG_M>,<REG_N>+# arch arch_sh_up+:xor M_0t,N_0t is OP_0=0x2 & N_0t & M_0t & OP_1=0xa {++ N_0t = N_0t ^ M_0t;+}+++# Exclusive Logical OR+# pattern 11001010iiiiiiii+# text xor #<imm>,R0+# arch arch_sh_up+:xor U_0t_r0 is OP_2=0xca & U_0t_r0 {++ r0 = r0 ^ U_0t_r0;+}+++# Exclusive Logical OR+# pattern 11001110iiiiiiii+# text xor.b #<imm>,@(R0,GBR)+# arch arch_sh_up+:xor.b U_0t1 is OP_2=0xce & U_0t1 {++ *:1 (GBR + r0) = ( *:1 (GBR + r0) ) ^ U_0t1;+}+++# Middle Extraction from Linked Registers+# pattern 0010nnnnmmmm1101+# text xtrct <REG_M>,<REG_N>+# arch arch_sh_up+:xtrct M_0t,N_0t is OP_0=0x2 & N_0t & M_0t & OP_1=0xd {++ N_0t = (M_0t << 16) | (N_0t >> 16);+}+diff --git a/Ghidra/Processors/SuperH4/data/languages/SuperH4_be.slaspec b/Ghidra/Processors/SuperH4/data/languages/SuperH4_be.slaspecnew file mode 100644index 0000000000..0c2d7e7950--- /dev/null+++ b/Ghidra/Processors/SuperH4/data/languages/SuperH4_be.slaspec@@ -0,0 +1,8 @@+# This module defines SuperH version 4a, but should work against versions 1,2, and 3.+# DSP Extensions are not yet added++# Based on "Renesas SH-4 Software Manual: Rev 6.00 2006.09 (i.e. rej09b0318_sh_4sm.pdf)++@define ENDIAN "big"++@include "SuperH4.sinc"diff --git a/Ghidra/Processors/SuperH4/data/languages/SuperH4_le.slaspec b/Ghidra/Processors/SuperH4/data/languages/SuperH4_le.slaspecnew file mode 100644index 0000000000..130c77f35d--- /dev/null+++ b/Ghidra/Processors/SuperH4/data/languages/SuperH4_le.slaspec@@ -0,0 +1,9 @@+# This module defines SuperH version 4, but should work against versions 1,2, and 3.+# There is a SuperH version 4A (which has 4 byte instruction length) which has instructions incompatable+# with this.++# Based on "Renesas SH-4 Software Manual: Rev 6.00 2006.09 (i.e. rej09b0318_sh_4sm.pdf)++@define ENDIAN "little"++@include "SuperH4.sinc"diff --git a/Ghidra/Processors/SuperH4/data/languages/old/SuperH4-BE-16.lang b/Ghidra/Processors/SuperH4/data/languages/old/SuperH4-BE-16.langnew file mode 100644index 0000000000..4967b581ce--- /dev/null+++ b/Ghidra/Processors/SuperH4/data/languages/old/SuperH4-BE-16.lang@@ -0,0 +1,131 @@+<?xml version="1.0" encoding="UTF-8"?>+<language version="1" endian="big">+ <description>+ <id>SuperH4:BE:16:default</id>+ <processor>SuperH4</processor>+ <variant>default</variant>+ <size>16</size>+ </description>+ <compiler name="default" id="default" />+ <spaces>+ <space name="ram" type="ram" size="4" default="yes" />+ <space name="register" type="register" size="4" />+ </spaces>+ <registers>+ <context_register name="FPSCR" offset="0x810" bitsize="32">+ <field name="doubleWidthMoveMode" range="1,1" />+ <field name="doublePrecMode" range="0,0" />+ </context_register>+ <register name="r0" offset="0x0" bitsize="32" />+ <register name="r1" offset="0x4" bitsize="32" />+ <register name="r2" offset="0x8" bitsize="32" />+ <register name="r3" offset="0xc" bitsize="32" />+ <register name="r4" offset="0x10" bitsize="32" />+ <register name="r5" offset="0x14" bitsize="32" />+ <register name="r6" offset="0x18" bitsize="32" />+ <register name="r7" offset="0x1c" bitsize="32" />+ <register name="r8" offset="0x20" bitsize="32" />+ <register name="r9" offset="0x24" bitsize="32" />+ <register name="r10" offset="0x28" bitsize="32" />+ <register name="r11" offset="0x2c" bitsize="32" />+ <register name="r12" offset="0x30" bitsize="32" />+ <register name="r13" offset="0x34" bitsize="32" />+ <register name="r14" offset="0x38" bitsize="32" />+ <register name="r15" offset="0x3c" bitsize="32" />+ <register name="R0_BANK" offset="0x40" bitsize="32" />+ <register name="R1_BANK" offset="0x44" bitsize="32" />+ <register name="R2_BANK" offset="0x48" bitsize="32" />+ <register name="R3_BANK" offset="0x4c" bitsize="32" />+ <register name="R4_BANK" offset="0x50" bitsize="32" />+ <register name="R5_BANK" offset="0x54" bitsize="32" />+ <register name="R6_BANK" offset="0x58" bitsize="32" />+ <register name="R7_BANK" offset="0x5c" bitsize="32" />+ <register name="R_BANK0" offset="0x0" bitsize="256" />+ <register name="R_UNBANKED" offset="0x20" bitsize="256" />+ <register name="R_BANK1" offset="0x40" bitsize="256" />+ <register name="fr0" offset="0x200" bitsize="32" />+ <register name="fr1" offset="0x204" bitsize="32" />+ <register name="fr2" offset="0x208" bitsize="32" />+ <register name="fr3" offset="0x20c" bitsize="32" />+ <register name="fr4" offset="0x210" bitsize="32" />+ <register name="fr5" offset="0x214" bitsize="32" />+ <register name="fr6" offset="0x218" bitsize="32" />+ <register name="fr7" offset="0x21c" bitsize="32" />+ <register name="fr8" offset="0x220" bitsize="32" />+ <register name="fr9" offset="0x224" bitsize="32" />+ <register name="fr10" offset="0x228" bitsize="32" />+ <register name="fr11" offset="0x22c" bitsize="32" />+ <register name="fr12" offset="0x230" bitsize="32" />+ <register name="fr13" offset="0x234" bitsize="32" />+ <register name="fr14" offset="0x238" bitsize="32" />+ <register name="fr15" offset="0x23c" bitsize="32" />+ <register name="xf0" offset="0x240" bitsize="32" />+ <register name="xf1" offset="0x244" bitsize="32" />+ <register name="xf2" offset="0x248" bitsize="32" />+ <register name="xf3" offset="0x24c" bitsize="32" />+ <register name="xf4" offset="0x250" bitsize="32" />+ <register name="xf5" offset="0x254" bitsize="32" />+ <register name="xf6" offset="0x258" bitsize="32" />+ <register name="xf7" offset="0x25c" bitsize="32" />+ <register name="xf8" offset="0x260" bitsize="32" />+ <register name="xf9" offset="0x264" bitsize="32" />+ <register name="xf10" offset="0x268" bitsize="32" />+ <register name="xf11" offset="0x26c" bitsize="32" />+ <register name="xf12" offset="0x270" bitsize="32" />+ <register name="xf13" offset="0x274" bitsize="32" />+ <register name="xf14" offset="0x278" bitsize="32" />+ <register name="xf15" offset="0x27c" bitsize="32" />+ <register name="dr0" offset="0x200" bitsize="64" />+ <register name="dr2" offset="0x208" bitsize="64" />+ <register name="dr4" offset="0x210" bitsize="64" />+ <register name="dr6" offset="0x218" bitsize="64" />+ <register name="dr8" offset="0x220" bitsize="64" />+ <register name="dr10" offset="0x228" bitsize="64" />+ <register name="dr12" offset="0x230" bitsize="64" />+ <register name="dr14" offset="0x238" bitsize="64" />+ <register name="xd0" offset="0x240" bitsize="64" />+ <register name="xd2" offset="0x248" bitsize="64" />+ <register name="xd4" offset="0x250" bitsize="64" />+ <register name="xd6" offset="0x258" bitsize="64" />+ <register name="xd8" offset="0x260" bitsize="64" />+ <register name="xd10" offset="0x268" bitsize="64" />+ <register name="xd12" offset="0x270" bitsize="64" />+ <register name="xd14" offset="0x278" bitsize="64" />+ <register name="fv0" offset="0x200" bitsize="128" />+ <register name="fv4" offset="0x210" bitsize="128" />+ <register name="fv8" offset="0x220" bitsize="128" />+ <register name="fv12" offset="0x230" bitsize="128" />+ <register name="FPR_BANK0" offset="0x200" bitsize="512" />+ <register name="FPR_BANK1" offset="0x240" bitsize="512" />+ <register name="GBR" offset="0x400" bitsize="32" />+ <register name="SR" offset="0x404" bitsize="32" />+ <register name="SSR" offset="0x408" bitsize="32" />+ <register name="SPC" offset="0x40c" bitsize="32" />+ <register name="VBR" offset="0x410" bitsize="32" />+ <register name="SGR" offset="0x414" bitsize="32" />+ <register name="DBR" offset="0x418" bitsize="32" />+ <register name="MD" offset="0x600" bitsize="8" />+ <register name="RB" offset="0x601" bitsize="8" />+ <register name="BL" offset="0x602" bitsize="8" />+ <register name="FD" offset="0x603" bitsize="8" />+ <register name="M" offset="0x604" bitsize="8" />+ <register name="Q" offset="0x605" bitsize="8" />+ <register name="IMASK" offset="0x606" bitsize="8" />+ <register name="S" offset="0x607" bitsize="8" />+ <register name="T" offset="0x608" bitsize="8" />+ <register name="MACH" offset="0x800" bitsize="32" />+ <register name="MACL" offset="0x804" bitsize="32" />+ <register name="PR" offset="0x808" bitsize="32" />+ <register name="PC" offset="0x80c" bitsize="32" />+ <register name="FPUL" offset="0x814" bitsize="32" />+ <register name="FPSCR_RM" offset="0xa00" bitsize="8" />+ <register name="FPSCR_FLAG" offset="0xa01" bitsize="8" />+ <register name="FPSCR_ENABLE" offset="0xa02" bitsize="8" />+ <register name="FPSCR_CAUSE" offset="0xa03" bitsize="8" />+ <register name="FPSCR_DN" offset="0xa04" bitsize="8" />+ <register name="FPSCR_PR" offset="0xa05" bitsize="8" />+ <register name="FPSCR_SZ" offset="0xa06" bitsize="8" />+ <register name="FPSCR_FR" offset="0xa07" bitsize="8" />+ </registers>+</language>+diff --git a/Ghidra/Processors/SuperH4/data/languages/old/SuperH4-BE-16.trans b/Ghidra/Processors/SuperH4/data/languages/old/SuperH4-BE-16.transnew file mode 100644index 0000000000..e7430739f8--- /dev/null+++ b/Ghidra/Processors/SuperH4/data/languages/old/SuperH4-BE-16.trans@@ -0,0 +1,7 @@+<?xml version="1.0" encoding="UTF-8"?>+<language_translation>+ <from_language version="1">SuperH4:BE:16:default</from_language>+ <to_language version="1">SuperH4:BE:32:default</to_language>+ <map_compiler_spec from="default" to="default" />+</language_translation>+diff --git a/Ghidra/Processors/SuperH4/data/languages/old/SuperH4-LE-16.lang b/Ghidra/Processors/SuperH4/data/languages/old/SuperH4-LE-16.langnew file mode 100644index 0000000000..13a227fea4--- /dev/null+++ b/Ghidra/Processors/SuperH4/data/languages/old/SuperH4-LE-16.lang@@ -0,0 +1,131 @@+<?xml version="1.0" encoding="UTF-8"?>+<language version="1" endian="little">+ <description>+ <id>SuperH4:LE:16:default</id>+ <processor>SuperH4</processor>+ <variant>default</variant>+ <size>16</size>+ </description>+ <compiler name="default" id="default" />+ <spaces>+ <space name="ram" type="ram" size="4" default="yes" />+ <space name="register" type="register" size="4" />+ </spaces>+ <registers>+ <context_register name="FPSCR" offset="0x810" bitsize="32">+ <field name="doubleWidthMoveMode" range="1,1" />+ <field name="doublePrecMode" range="0,0" />+ </context_register>+ <register name="r0" offset="0x0" bitsize="32" />+ <register name="r1" offset="0x4" bitsize="32" />+ <register name="r2" offset="0x8" bitsize="32" />+ <register name="r3" offset="0xc" bitsize="32" />+ <register name="r4" offset="0x10" bitsize="32" />+ <register name="r5" offset="0x14" bitsize="32" />+ <register name="r6" offset="0x18" bitsize="32" />+ <register name="r7" offset="0x1c" bitsize="32" />+ <register name="r8" offset="0x20" bitsize="32" />+ <register name="r9" offset="0x24" bitsize="32" />+ <register name="r10" offset="0x28" bitsize="32" />+ <register name="r11" offset="0x2c" bitsize="32" />+ <register name="r12" offset="0x30" bitsize="32" />+ <register name="r13" offset="0x34" bitsize="32" />+ <register name="r14" offset="0x38" bitsize="32" />+ <register name="r15" offset="0x3c" bitsize="32" />+ <register name="R0_BANK" offset="0x40" bitsize="32" />+ <register name="R1_BANK" offset="0x44" bitsize="32" />+ <register name="R2_BANK" offset="0x48" bitsize="32" />+ <register name="R3_BANK" offset="0x4c" bitsize="32" />+ <register name="R4_BANK" offset="0x50" bitsize="32" />+ <register name="R5_BANK" offset="0x54" bitsize="32" />+ <register name="R6_BANK" offset="0x58" bitsize="32" />+ <register name="R7_BANK" offset="0x5c" bitsize="32" />+ <register name="R_BANK0" offset="0x0" bitsize="256" />+ <register name="R_UNBANKED" offset="0x20" bitsize="256" />+ <register name="R_BANK1" offset="0x40" bitsize="256" />+ <register name="fr0" offset="0x200" bitsize="32" />+ <register name="fr1" offset="0x204" bitsize="32" />+ <register name="fr2" offset="0x208" bitsize="32" />+ <register name="fr3" offset="0x20c" bitsize="32" />+ <register name="fr4" offset="0x210" bitsize="32" />+ <register name="fr5" offset="0x214" bitsize="32" />+ <register name="fr6" offset="0x218" bitsize="32" />+ <register name="fr7" offset="0x21c" bitsize="32" />+ <register name="fr8" offset="0x220" bitsize="32" />+ <register name="fr9" offset="0x224" bitsize="32" />+ <register name="fr10" offset="0x228" bitsize="32" />+ <register name="fr11" offset="0x22c" bitsize="32" />+ <register name="fr12" offset="0x230" bitsize="32" />+ <register name="fr13" offset="0x234" bitsize="32" />+ <register name="fr14" offset="0x238" bitsize="32" />+ <register name="fr15" offset="0x23c" bitsize="32" />+ <register name="xf0" offset="0x240" bitsize="32" />+ <register name="xf1" offset="0x244" bitsize="32" />+ <register name="xf2" offset="0x248" bitsize="32" />+ <register name="xf3" offset="0x24c" bitsize="32" />+ <register name="xf4" offset="0x250" bitsize="32" />+ <register name="xf5" offset="0x254" bitsize="32" />+ <register name="xf6" offset="0x258" bitsize="32" />+ <register name="xf7" offset="0x25c" bitsize="32" />+ <register name="xf8" offset="0x260" bitsize="32" />+ <register name="xf9" offset="0x264" bitsize="32" />+ <register name="xf10" offset="0x268" bitsize="32" />+ <register name="xf11" offset="0x26c" bitsize="32" />+ <register name="xf12" offset="0x270" bitsize="32" />+ <register name="xf13" offset="0x274" bitsize="32" />+ <register name="xf14" offset="0x278" bitsize="32" />+ <register name="xf15" offset="0x27c" bitsize="32" />+ <register name="dr0" offset="0x200" bitsize="64" />+ <register name="dr2" offset="0x208" bitsize="64" />+ <register name="dr4" offset="0x210" bitsize="64" />+ <register name="dr6" offset="0x218" bitsize="64" />+ <register name="dr8" offset="0x220" bitsize="64" />+ <register name="dr10" offset="0x228" bitsize="64" />+ <register name="dr12" offset="0x230" bitsize="64" />+ <register name="dr14" offset="0x238" bitsize="64" />+ <register name="xd0" offset="0x240" bitsize="64" />+ <register name="xd2" offset="0x248" bitsize="64" />+ <register name="xd4" offset="0x250" bitsize="64" />+ <register name="xd6" offset="0x258" bitsize="64" />+ <register name="xd8" offset="0x260" bitsize="64" />+ <register name="xd10" offset="0x268" bitsize="64" />+ <register name="xd12" offset="0x270" bitsize="64" />+ <register name="xd14" offset="0x278" bitsize="64" />+ <register name="fv0" offset="0x200" bitsize="128" />+ <register name="fv4" offset="0x210" bitsize="128" />+ <register name="fv8" offset="0x220" bitsize="128" />+ <register name="fv12" offset="0x230" bitsize="128" />+ <register name="FPR_BANK0" offset="0x200" bitsize="512" />+ <register name="FPR_BANK1" offset="0x240" bitsize="512" />+ <register name="GBR" offset="0x400" bitsize="32" />+ <register name="SR" offset="0x404" bitsize="32" />+ <register name="SSR" offset="0x408" bitsize="32" />+ <register name="SPC" offset="0x40c" bitsize="32" />+ <register name="VBR" offset="0x410" bitsize="32" />+ <register name="SGR" offset="0x414" bitsize="32" />+ <register name="DBR" offset="0x418" bitsize="32" />+ <register name="MD" offset="0x600" bitsize="8" />+ <register name="RB" offset="0x601" bitsize="8" />+ <register name="BL" offset="0x602" bitsize="8" />+ <register name="FD" offset="0x603" bitsize="8" />+ <register name="M" offset="0x604" bitsize="8" />+ <register name="Q" offset="0x605" bitsize="8" />+ <register name="IMASK" offset="0x606" bitsize="8" />+ <register name="S" offset="0x607" bitsize="8" />+ <register name="T" offset="0x608" bitsize="8" />+ <register name="MACH" offset="0x800" bitsize="32" />+ <register name="MACL" offset="0x804" bitsize="32" />+ <register name="PR" offset="0x808" bitsize="32" />+ <register name="PC" offset="0x80c" bitsize="32" />+ <register name="FPUL" offset="0x814" bitsize="32" />+ <register name="FPSCR_RM" offset="0xa00" bitsize="8" />+ <register name="FPSCR_FLAG" offset="0xa01" bitsize="8" />+ <register name="FPSCR_ENABLE" offset="0xa02" bitsize="8" />+ <register name="FPSCR_CAUSE" offset="0xa03" bitsize="8" />+ <register name="FPSCR_DN" offset="0xa04" bitsize="8" />+ <register name="FPSCR_PR" offset="0xa05" bitsize="8" />+ <register name="FPSCR_SZ" offset="0xa06" bitsize="8" />+ <register name="FPSCR_FR" offset="0xa07" bitsize="8" />+ </registers>+</language>+diff --git a/Ghidra/Processors/SuperH4/data/languages/old/SuperH4-LE-16.trans b/Ghidra/Processors/SuperH4/data/languages/old/SuperH4-LE-16.transnew file mode 100644index 0000000000..85a9f27425--- /dev/null+++ b/Ghidra/Processors/SuperH4/data/languages/old/SuperH4-LE-16.trans@@ -0,0 +1,7 @@+<?xml version="1.0" encoding="UTF-8"?>+<language_translation>+ <from_language version="1">SuperH4:LE:16:default</from_language>+ <to_language version="1">SuperH4:LE:32:default</to_language>+ <map_compiler_spec from="default" to="default" />+</language_translation>+diff --git a/Ghidra/Processors/SuperH4/data/manuals/superh4.idx b/Ghidra/Processors/SuperH4/data/manuals/superh4.idxnew file mode 100644index 0000000000..3c936059b8--- /dev/null+++ b/Ghidra/Processors/SuperH4/data/manuals/superh4.idx@@ -0,0 +1,132 @@+@ rej09b0318_sh_4sm.pdf[SH-4 Software Manual Rev 6.00 2006.09]+add, 229+addc, 231+addv, 232+and, 234+and.b, 234+bf, 236+bf/s, 238+bra, 240+braf, 242+bsr, 244+bsrf, 246+bt, 248+bt/s, 250+clrmac, 252+clrs, 253+clrt, 254+cmp/eq, 255+cmp/ge, 255+cmp/gt, 255+cmp/hi, 255+cmp/hs, 255+cmp/pl, 255+cmp/pz, 255+cmp/str, 255+cmp/eq, 255+cmp/str, 255+div0s, 259+div0u, 260+div1, 261+dmuls.l, 266+dmulu.l, 268+dt, 270+exts.b, 271+exts.w, 271+extu.b, 273+extu.w, 273+jmp, 331+jsr, 332+ldc, 334+ldc.l, 334+lds, 339+lds.l, 339+ldtlb, 343+mac.l, 345+mac, 349+mac.w, 349+mov, 352+mov.b, 352+mov.w, 352+mov.l, 352+mova, 367+movca.l, 368+movt, 369+mul.l, 370+muls.w, 371+muls, 371+mulu.w, 372+mulu, 372+neg, 373+negc, 374+nop, 375+not, 376+ocbi, 377+ocbp, 378+ocbwb, 379+or, 380+or.b, 380+pref, 382+rotcl, 383+rotcr, 384+rotl, 385+rotr, 386+rte, 387+rts, 389+sets, 391+sett, 392+shad, 393+shal, 395+shar, 396+shld, 397+shll, 399+shll2, 400+shll8, 400+shll16, 400+shlr, 402+shlr2, 403+shlr8, 403+shlr16, 403+sleep, 405+stc, 406+stc.l, 406+sts, 411+sts.l, 411+sub, 416+subc, 417+subv, 418+swap.b, 420+swap.w, 420+tas.b, 422+trapa, 424+tst, 426+tst.b, 426+xor, 428+xor.b, 428+xtrct, 430+fabs, 275+fadd, 276+fcmp/eq, 279+fcmp/gt, 279+fcnvds, 283+fcnvsd, 286+fdiv, 288+fipr, 292+fldi0, 294+fldi1, 295+flds, 296+float, 297+fmac, 299+fmov, 305+fmov.s, 305+fmul, 312+fneg, 315+frchg, 316+fschg, 317+fsqrt, 318+fsts, 321+fsub, 322+ftrc, 325+ftrv, 328++diff --git a/Ghidra/Processors/SuperH4/data/patterns/SuperH4_patterns.xml b/Ghidra/Processors/SuperH4/data/patterns/SuperH4_patterns.xmlnew file mode 100644index 0000000000..b823389f89--- /dev/null+++ b/Ghidra/Processors/SuperH4/data/patterns/SuperH4_patterns.xml@@ -0,0 +1,17 @@+<patternlist>+ <patternpairs totalbits="32" postbits="16">+ <prepatterns>+ <data>0x0b 0x00 0x09 0x00 </data> <!-- rts _nop -->+ <data>0x0b 0x00 0xf6 0x6. </data> <!-- rts _mov.l @r15+,<rx> -->+ <data>0x0b 0x00 0x09 0x00 0x00 0x00 </data> <!-- rts _nop filler -->+ <data>0x0b 0x00 0x.. 0x7f </data> <!-- rts add <#x>,r15 -->+ </prepatterns>+ <postpatterns>+ <data>10011101 11100011 10111... ........</data> <!-- save sp, xx, sp -->+ <data>0x22 0x4f </data> <!-- sts.l pr,@-r15 -->+ <data>0x22 0x4f 1....... 0x7f </data> <!-- sts.l pr,@-r15 add#-<x>,r15 -->+ <data> 1....... 0x7f </data> <!-- add #-<x>, r15 -->+ <funcstart/>+ </postpatterns>+ </patternpairs>+ </patternlist>diff --git a/Ghidra/Processors/SuperH4/data/patterns/patternconstraints.xml b/Ghidra/Processors/SuperH4/data/patterns/patternconstraints.xmlnew file mode 100644index 0000000000..9df5d2d05c--- /dev/null+++ b/Ghidra/Processors/SuperH4/data/patterns/patternconstraints.xml@@ -0,0 +1,5 @@+<patternconstraints>+ <language id="SuperH4:LE:32:*">+ <patternfile>SuperH4_patterns.xml</patternfile>+ </language>+</patternconstraints>diff --git a/Ghidra/Processors/SuperH4/src/test.processors/java/ghidra/test/processors/SuperH4_BE_O0_EmulatorTest.java b/Ghidra/Processors/SuperH4/src/test.processors/java/ghidra/test/processors/SuperH4_BE_O0_EmulatorTest.javanew file mode 100644index 0000000000..d8fae446cf--- /dev/null+++ b/Ghidra/Processors/SuperH4/src/test.processors/java/ghidra/test/processors/SuperH4_BE_O0_EmulatorTest.java@@ -0,0 +1,41 @@+/* ###+ * IP: GHIDRA+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+package ghidra.test.processors;++import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;+import junit.framework.Test;++public class SuperH4_BE_O0_EmulatorTest extends ProcessorEmulatorTestAdapter {++ private static final String LANGUAGE_ID = "SuperH4:BE:32:default";+ private static final String COMPILER_SPEC_ID = "default";++ private static final String[] REG_DUMP_SET = new String[] {};++ public SuperH4_BE_O0_EmulatorTest(String name) throws Exception {+ super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);+ }++ @Override+ protected String getProcessorDesignator() {+ return "SH4_GCC_O0";+ }++ public static Test suite() {+ return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(+ SuperH4_BE_O0_EmulatorTest.class);+ }+}diff --git a/Ghidra/Processors/SuperH4/src/test.processors/java/ghidra/test/processors/SuperH4_BE_O3_EmulatorTest.java b/Ghidra/Processors/SuperH4/src/test.processors/java/ghidra/test/processors/SuperH4_BE_O3_EmulatorTest.javanew file mode 100644index 0000000000..74ec7d0024--- /dev/null+++ b/Ghidra/Processors/SuperH4/src/test.processors/java/ghidra/test/processors/SuperH4_BE_O3_EmulatorTest.java@@ -0,0 +1,41 @@+/* ###+ * IP: GHIDRA+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+package ghidra.test.processors;++import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;+import junit.framework.Test;++public class SuperH4_BE_O3_EmulatorTest extends ProcessorEmulatorTestAdapter {++ private static final String LANGUAGE_ID = "SuperH4:BE:32:default";+ private static final String COMPILER_SPEC_ID = "default";++ private static final String[] REG_DUMP_SET = new String[] {};++ public SuperH4_BE_O3_EmulatorTest(String name) throws Exception {+ super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);+ }++ @Override+ protected String getProcessorDesignator() {+ return "SH4_GCC_O3";+ }++ public static Test suite() {+ return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(+ SuperH4_BE_O3_EmulatorTest.class);+ }+}diff --git a/Ghidra/Processors/SuperH4/src/test.processors/java/ghidra/test/processors/SuperH4_O0_EmulatorTest.java b/Ghidra/Processors/SuperH4/src/test.processors/java/ghidra/test/processors/SuperH4_O0_EmulatorTest.javanew file mode 100644index 0000000000..ce5ee1d38e--- /dev/null+++ b/Ghidra/Processors/SuperH4/src/test.processors/java/ghidra/test/processors/SuperH4_O0_EmulatorTest.java@@ -0,0 +1,40 @@+/* ###+ * IP: GHIDRA+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+package ghidra.test.processors;++import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;+import junit.framework.Test;++public class SuperH4_O0_EmulatorTest extends ProcessorEmulatorTestAdapter {++ private static final String LANGUAGE_ID = "SuperH4:LE:32:default";+ private static final String COMPILER_SPEC_ID = "default";++ private static final String[] REG_DUMP_SET = new String[] {};++ public SuperH4_O0_EmulatorTest(String name) throws Exception {+ super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);+ }++ @Override+ protected String getProcessorDesignator() {+ return "SH4_LE_GCC_O0";+ }++ public static Test suite() {+ return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(SuperH4_O0_EmulatorTest.class);+ }+}diff --git a/Ghidra/Processors/SuperH4/src/test.processors/java/ghidra/test/processors/SuperH4_O3_EmulatorTest.java b/Ghidra/Processors/SuperH4/src/test.processors/java/ghidra/test/processors/SuperH4_O3_EmulatorTest.javanew file mode 100644index 0000000000..1bb8a0904f--- /dev/null+++ b/Ghidra/Processors/SuperH4/src/test.processors/java/ghidra/test/processors/SuperH4_O3_EmulatorTest.java@@ -0,0 +1,40 @@+/* ###+ * IP: GHIDRA+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+package ghidra.test.processors;++import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;+import junit.framework.Test;++public class SuperH4_O3_EmulatorTest extends ProcessorEmulatorTestAdapter {++ private static final String LANGUAGE_ID = "SuperH4:LE:32:default";+ private static final String COMPILER_SPEC_ID = "default";++ private static final String[] REG_DUMP_SET = new String[] {};++ public SuperH4_O3_EmulatorTest(String name) throws Exception {+ super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);+ }++ @Override+ protected String getProcessorDesignator() {+ return "SH4_LE_GCC_O3";+ }++ public static Test suite() {+ return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(SuperH4_O3_EmulatorTest.class);+ }+}