summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog13
-rw-r--r--src/arch/arm/v7/opdefs/Makefile.am4
-rw-r--r--src/arch/arm/v7/opdefs/mov_A88102.d127
-rw-r--r--tools/d2c/d2c_gram.y6
-rw-r--r--tools/d2c/d2c_tok.l3
-rw-r--r--tools/d2c/spec.c6
6 files changed, 151 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 95de94c..7bd7182 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+14-12-02 Cyrille Bagard <nocbos@gmail.com>
+
+ * src/arch/arm/v7/opdefs/Makefile.am:
+ Distinguish Thumb 16 and Thumb 32. Add 'mov_A88102.d' to ARMV7_DEFS.
+
+ * src/arch/arm/v7/opdefs/mov_A88102.d:
+ New entry: define a new ARMv7 instruction. Need to be improved.
+
+ * tools/d2c/d2c_gram.y:
+ * tools/d2c/d2c_tok.l:
+ * tools/d2c/spec.c:
+ Extend the compiler by allowing more than one type of Thumb.
+
14-12-01 Cyrille Bagard <nocbos@gmail.com>
* src/arch/arm/v7/arm.h:
diff --git a/src/arch/arm/v7/opdefs/Makefile.am b/src/arch/arm/v7/opdefs/Makefile.am
index a8ae089..ad52bd2 100644
--- a/src/arch/arm/v7/opdefs/Makefile.am
+++ b/src/arch/arm/v7/opdefs/Makefile.am
@@ -11,7 +11,8 @@ D2C_HEADER = _ARCH_ARM_V7
D2C_ENCODINGS = \
-e a= \
- -e t=thumb_
+ -e t=thumb16_ \
+ -e T=thumb32_
D2C_MACROS = \
-M SetFlags=g_armv7_instruction_define_setflags \
@@ -39,6 +40,7 @@ ARMV7_DEFS = \
eor_A8847.d \
mla_A88100.d \
mls_A88101.d \
+ mov_A88102.d \
mov_A88104.d \
mul_A88114.d \
mvn_A88115.d \
diff --git a/src/arch/arm/v7/opdefs/mov_A88102.d b/src/arch/arm/v7/opdefs/mov_A88102.d
new file mode 100644
index 0000000..2401df2
--- /dev/null
+++ b/src/arch/arm/v7/opdefs/mov_A88102.d
@@ -0,0 +1,127 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * ##FILE## - traduction d'instructions ARMv7
+ *
+ * Copyright (C) 2014 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chrysalide is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+@title MOV (immediate)
+
+@encoding(t1) {
+
+ @half 0 0 1 0 0 Rd(3) imm8(8)
+
+ @syntax <Rd> <const>
+
+ @conv {
+
+ Rd = Register(Rd)
+ const = ZeroExtend(imm8, 32)
+
+ }
+
+}
+
+@encoding(T2) {
+
+ @word 1 1 1 1 0 i(1) 0 0 0 1 0 S(1) 1 1 1 1 0 imm3(3) Rd(4) imm8(8)
+
+ @syntax {S} <Rd> <const>
+
+ @conv {
+
+ S = SetFlags(S)
+ Rd = Register(Rd)
+ const = ThumbExpandImm_C(i:imm3:imm8, 0)
+
+ }
+
+ @rules {
+
+ //if d IN {13,15} then UNPREDICTABLE;
+
+ }
+
+}
+
+@encoding(T3) {
+
+ @word 1 1 1 1 0 i(1) 1 0 0 1 0 0 imm4(4) 0 imm3(3) Rd(4) imm8(8)
+
+ @syntax <Rd> <const>
+
+ @conv {
+
+ Rd = Register(Rd)
+ const = ZeroExtend(imm4:i:imm3:imm8, 32)
+
+ }
+
+ @rules {
+
+ //if d IN {13,15} then UNPREDICTABLE;
+
+ }
+
+}
+
+@encoding(A1) {
+
+ @word cond(4) 0 0 1 1 1 0 1 S(1) 0 0 0 0 Rd(4) imm12(12)
+
+ @syntax {S} {c} <Rd> <const>
+
+ @conv {
+
+ S = SetFlags(S)
+ c = Condition(cond)
+ Rd = Register(Rd)
+ const = ARMExpandImm_C(imm12, 0)
+
+ }
+
+ @rules {
+
+ if ((Rd == '1111') && (S == '1')) ; see SUBS PC, LR and related instructions (ARM)
+
+ }
+
+}
+
+@encoding(A2) {
+
+ @word cond(4) 0 0 1 1 0 0 0 0 imm4(4) Rd(4) imm12(12)
+
+ @syntax {c} <Rd> <const>
+
+ @conv {
+
+ c = Condition(cond)
+ Rd = Register(Rd)
+ const = ZeroExtend(imm4:imm12, 32)
+
+ }
+
+ @rules {
+
+ //if d == 15 then UNPREDICTABLE;
+
+ }
+
+}
diff --git a/tools/d2c/d2c_gram.y b/tools/d2c/d2c_gram.y
index 7195e21..1c25b17 100644
--- a/tools/d2c/d2c_gram.y
+++ b/tools/d2c/d2c_gram.y
@@ -133,7 +133,7 @@ struct action_tmp
%token INS_NAME INS_DETAILS
%token ENCODING
-%token THUMB ARCH NUMBER
+%token TYPE NUMBER
%token ENC_START ENC_END
%token WORD HALF NAME SIZE BIT
@@ -148,6 +148,7 @@ struct action_tmp
%type <string> COPYRIGHT INS_NAME
%type <cstring> INS_DETAILS
+%type <string> TYPE
%type <integer> NUMBER
%type <string> NAME
@@ -182,8 +183,7 @@ name : COPYRIGHT TITLE INS_NAME { save_notes_for_coder(coder, $1, $3
encodings : /* empty */
| encoding encodings
-encoding : ENCODING THUMB NUMBER content { push_encoding_spec(coder, strdup("t"), $3); }
- | ENCODING ARCH NUMBER content { push_encoding_spec(coder, strdup("a"), $3); }
+encoding : ENCODING TYPE NUMBER content { push_encoding_spec(coder, $2, $3); }
content : /* empty */
diff --git a/tools/d2c/d2c_tok.l b/tools/d2c/d2c_tok.l
index 4d31783..e40f10d 100644
--- a/tools/d2c/d2c_tok.l
+++ b/tools/d2c/d2c_tok.l
@@ -65,8 +65,7 @@ void free_flex_memory(void) ;
<encoding>[ ] { }
<encoding>"(" { BEGIN(encoding_type); }
-<encoding_type>"T" { return THUMB; }
-<encoding_type>"A" { return ARCH; }
+<encoding_type>[A-Za-z] { d2c_lval.string = strdup(yytext); return TYPE; }
<encoding_type>[0-9] { d2c_lval.integer = atoi(yytext); return NUMBER; }
<encoding_type>")" { BEGIN(encoding); }
diff --git a/tools/d2c/spec.c b/tools/d2c/spec.c
index a957587..675fd05 100644
--- a/tools/d2c/spec.c
+++ b/tools/d2c/spec.c
@@ -53,6 +53,7 @@
struct _encoding_spec
{
char *prefix; /* Distinction principale */
+ char *lprefix; /* Distinction en minuscules */
unsigned int index; /* Distinction secondaire */
coding_bits *bits; /* Encodage des bits associƩs */
@@ -138,6 +139,7 @@ void delete_encoding_spec(encoding_spec *spec)
void define_encoding_spec_code_name(encoding_spec *spec, char *prefix, unsigned int index)
{
spec->prefix = prefix;
+ spec->lprefix = make_string_lower(strdup(prefix));
spec->index = index;
}
@@ -269,7 +271,7 @@ bool write_encoding_spec_disass(const encoding_spec *spec, int fd, const char *a
keyword = make_callable(ins, false);
dprintf(fd, "\tGArchInstruction *%s_decode_%s%s_%s%u(uint%u_t _raw)\n",
- arch, keyword, details, spec->prefix, spec->index, wide);
+ arch, keyword, details, spec->lprefix, spec->index, wide);
dprintf(fd, "\t{\n");
@@ -338,7 +340,7 @@ bool write_encoding_spec_disass(const encoding_spec *spec, int fd, const char *a
dprintf(fd, "\tif (result == NULL)\n");
dprintf(fd, "\t\tresult = %s_decode_%s%s_%s%u(raw);\n",
- arch, keyword, details, spec->prefix, spec->index);
+ arch, keyword, details, spec->lprefix, spec->index);
dprintf(fd, "\n");