@@ -17,7 +17,7 @@ static void test_mips_el_ori(void)
17
17
char code [] = "\x56\x34\x21\x34" ; // ori $at, $at, 0x3456;
18
18
int r_r1 = 0x6789 ;
19
19
20
- uc_common_setup (& uc , UC_ARCH_MIPS , UC_MODE_32 | UC_MODE_LITTLE_ENDIAN , code ,
20
+ uc_common_setup (& uc , UC_ARCH_MIPS , UC_MODE_MIPS32 | UC_MODE_LITTLE_ENDIAN , code ,
21
21
sizeof (code ) - 1 );
22
22
OK (uc_reg_write (uc , UC_MIPS_REG_1 , & r_r1 ));
23
23
@@ -36,7 +36,7 @@ static void test_mips_eb_ori(void)
36
36
char code [] = "\x34\x21\x34\x56" ; // ori $at, $at, 0x3456;
37
37
int r_r1 = 0x6789 ;
38
38
39
- uc_common_setup (& uc , UC_ARCH_MIPS , UC_MODE_32 | UC_MODE_BIG_ENDIAN , code ,
39
+ uc_common_setup (& uc , UC_ARCH_MIPS , UC_MODE_MIPS32 | UC_MODE_BIG_ENDIAN , code ,
40
40
sizeof (code ) - 1 );
41
41
OK (uc_reg_write (uc , UC_MIPS_REG_1 , & r_r1 ));
42
42
@@ -56,7 +56,7 @@ static void test_mips_stop_at_branch(void)
56
56
"\x02\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00" ; // j 0x8; nop;
57
57
int r_pc = 0x0 ;
58
58
59
- uc_common_setup (& uc , UC_ARCH_MIPS , UC_MODE_32 | UC_MODE_LITTLE_ENDIAN , code ,
59
+ uc_common_setup (& uc , UC_ARCH_MIPS , UC_MODE_MIPS32 | UC_MODE_LITTLE_ENDIAN , code ,
60
60
sizeof (code ) - 1 );
61
61
62
62
// Execute one instruction with branch delay slot.
@@ -78,7 +78,7 @@ static void test_mips_stop_at_delay_slot(void)
78
78
"\x02\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00" ; // j 0x8; nop;
79
79
int r_pc = 0x0 ;
80
80
81
- uc_common_setup (& uc , UC_ARCH_MIPS , UC_MODE_32 | UC_MODE_LITTLE_ENDIAN , code ,
81
+ uc_common_setup (& uc , UC_ARCH_MIPS , UC_MODE_MIPS32 | UC_MODE_LITTLE_ENDIAN , code ,
82
82
sizeof (code ) - 1 );
83
83
84
84
// Stop at the delay slot by design.
@@ -99,7 +99,7 @@ static void test_mips_lwx_exception_issue_1314(void)
99
99
char code [] = "\x0a\xc8\x79\x7e" ; // lwx $t9, $t9($s3)
100
100
int reg ;
101
101
102
- uc_common_setup (& uc , UC_ARCH_MIPS , UC_MODE_32 | UC_MODE_LITTLE_ENDIAN , code ,
102
+ uc_common_setup (& uc , UC_ARCH_MIPS , UC_MODE_MIPS32 | UC_MODE_LITTLE_ENDIAN , code ,
103
103
sizeof (code ) - 1 );
104
104
OK (uc_mem_map (uc , 0x10000 , 0x4000 , UC_PROT_ALL ));
105
105
@@ -126,10 +126,31 @@ static void test_mips_lwx_exception_issue_1314(void)
126
126
OK (uc_close (uc ));
127
127
}
128
128
129
+ static void test_mips_mips16 (void )
130
+ {
131
+ uc_engine * uc ;
132
+ char code [] = "\xC4\x6B\x49\xE3" ; // li $v1, 0xC4; addu $v0, $v1, $v0
133
+ int r_v0 = 0x6789 ;
134
+ int mips16_lowbit = 1 ;
135
+
136
+ uc_common_setup (& uc , UC_ARCH_MIPS , UC_MODE_MIPS32 | UC_MODE_LITTLE_ENDIAN , code ,
137
+ sizeof (code ) - 1 );
138
+ OK (uc_reg_write (uc , UC_MIPS_REG_V0 , & r_v0 ));
139
+
140
+ OK (uc_emu_start (uc , code_start | mips16_lowbit , code_start + sizeof (code ) - 1 , 0 , 0 ));
141
+
142
+ OK (uc_reg_read (uc , UC_MIPS_REG_V0 , & r_v0 ));
143
+
144
+ TEST_CHECK (r_v0 == 0x684D );
145
+
146
+ OK (uc_close (uc ));
147
+ }
148
+
129
149
TEST_LIST = {
130
150
{"test_mips_stop_at_branch" , test_mips_stop_at_branch },
131
151
{"test_mips_stop_at_delay_slot" , test_mips_stop_at_delay_slot },
132
152
{"test_mips_el_ori" , test_mips_el_ori },
133
153
{"test_mips_eb_ori" , test_mips_eb_ori },
134
154
{"test_mips_lwx_exception_issue_1314" , test_mips_lwx_exception_issue_1314 },
155
+ {"test_mips_mips16" , test_mips_mips16 },
135
156
{NULL , NULL }};
0 commit comments