Skip to content

Commit aded541

Browse files
committed
Add little endian support for TMS320c64x.
This requires now to initialize TMS320c64x with the CS_MODE_BIG_ENDIAN flag.
1 parent cc49ae6 commit aded541

File tree

5 files changed

+21
-2
lines changed

5 files changed

+21
-2
lines changed

arch/TMS320C64x/TMS320C64xDisassembler.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ bool TMS320C64x_getInstruction(csh ud, const uint8_t *code, size_t code_len,
600600
if(MI->flat_insn->detail)
601601
memset(MI->flat_insn->detail, 0, offsetof(cs_detail, tms320c64x)+sizeof(cs_tms320c64x));
602602

603-
insn = (code[3] << 0) | (code[2] << 8) | (code[1] << 16) | ((uint32_t) code[0] << 24);
603+
insn = readBytes32(MI, code);
604604
result = decodeInstruction_4(DecoderTable32, MI, insn, address, info, 0);
605605

606606
if(result == MCDisassembler_Success) {

arch/TMS320C64x/TMS320C64xModule.c

+10
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@ cs_err TMS320C64x_global_init(cs_struct *ud)
3333

3434
cs_err TMS320C64x_option(cs_struct *handle, cs_opt_type type, size_t value)
3535
{
36+
switch (type) {
37+
case CS_OPT_MODE:
38+
handle->mode |= (cs_mode)value;
39+
break;
40+
case CS_OPT_SYNTAX:
41+
handle->syntax |= (int)value;
42+
break;
43+
default:
44+
break;
45+
}
3646
return CS_ERR_OK;
3747
}
3848

cs.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ static const struct {
169169
{
170170
TMS320C64x_global_init,
171171
TMS320C64x_option,
172-
~(CS_MODE_BIG_ENDIAN),
172+
~(CS_MODE_LITTLE_ENDIAN | CS_MODE_BIG_ENDIAN),
173173
},
174174
#else
175175
{ NULL, NULL, 0 },

cstool/cstool.c

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ static struct {
6666
{ "m68k", CS_ARCH_M68K, CS_MODE_BIG_ENDIAN },
6767
{ "m68k40", CS_ARCH_M68K, CS_MODE_M68K_040 },
6868
{ "tms320c64x", CS_ARCH_TMS320C64X, CS_MODE_BIG_ENDIAN },
69+
{ "tms320c64xle", CS_ARCH_TMS320C64X, CS_MODE_LITTLE_ENDIAN },
6970
{ "m6800", CS_ARCH_M680X, CS_MODE_M680X_6800 },
7071
{ "m6801", CS_ARCH_M680X, CS_MODE_M680X_6801 },
7172
{ "m6805", CS_ARCH_M680X, CS_MODE_M680X_6805 },

suite/cstest/issues.cs

+8
Original file line numberDiff line numberDiff line change
@@ -1066,3 +1066,11 @@
10661066
!# issue 2424
10671067
!# CS_ARCH_SH, CS_MODE_SH2A | CS_MODE_BIG_ENDIAN, CS_OPT_DETAIL
10681068
0x0: 0x32,0x11,0x92,0x00 == movu.w @(1024,r1),r2 ; operands[0].type: MEM ; operands[0].mem.reg: REG = r1 ; operands[0].mem.disp: 0x400 ; address mode: Register Indirect with Predecrement ; operands[1].type: REG = r2
1069+
1070+
!# issue 2646
1071+
!# CS_ARCH_TMS320C64X, CS_MODE_LITTLE_ENDIAN, CS_OPT_DETAIL
1072+
0x0: 0xa9,0xff,0x7f,0x02 == mvk.S1 -1, a4 ||
1073+
1074+
!# issue 2646
1075+
!# CS_ARCH_TMS320C64X, CS_MODE_BIG_ENDIAN, CS_OPT_DETAIL
1076+
0x0: 0x02,0x7f,0xff,0xa9 == mvk.S1 -1, a4 ||

0 commit comments

Comments
 (0)