📄 armtest.cpp
字号:
CPPUNIT_ASSERT( STR_4_buf3 == 0x10);
CPPUNIT_ASSERT( r1 == 0x000000E2);
//-------------------------------------------------------- pre-indexed offset with shif
// MOV r0,#0x10000002
// MOV r1,#0x000000E5
// MOV r2,#0x00000002
// STR r0,[r1,-r2,ASR #1]!
Core::Wukong_Get_System().load_binary((Core::Binary_Loader &)(*loader), "ARM", "str_5.axf");
( (ARM::CPU_7TDMI *) Core::Wukong_Get_System().get_cpu() )->run();
std::vector<u8> STR_5_buf;
( (ARM::CPU_7TDMI *)Core::Wukong_Get_System().get_cpu() )->\
get_mmu().access(Memory_32Bit::MEMORY_READ,0xe4,4,STR_5_buf);
( (ARM::CPU_7TDMI *)Core::Wukong_Get_System().get_cpu() )->read_register(1,r1);
u8 STR_5_buf0 = STR_5_buf[0];
u8 STR_5_buf1 = STR_5_buf[1];
u8 STR_5_buf2 = STR_5_buf[2];
u8 STR_5_buf3 = STR_5_buf[3];
CPPUNIT_ASSERT( STR_5_buf0 == 0x02);
CPPUNIT_ASSERT( STR_5_buf1 == 0x00);
CPPUNIT_ASSERT( STR_5_buf2 == 0x00);
CPPUNIT_ASSERT( STR_5_buf3 == 0x10);
CPPUNIT_ASSERT(r1 == 0x000000E4);
//-------------------------------------------------------- use R15 as Rd
// MOV r1,#0x000000E0
// STR r15,[r1]
Core::Wukong_Get_System().load_binary((Core::Binary_Loader &)(*loader), "ARM", "str_6.axf");
( (ARM::CPU_7TDMI *) Core::Wukong_Get_System().get_cpu() )->run();
std::vector<u8> STR_6_buf;
( (ARM::CPU_7TDMI *)Core::Wukong_Get_System().get_cpu() )->\
get_mmu().access(Memory_32Bit::MEMORY_READ,0xe0,4,STR_6_buf);
( (ARM::CPU_7TDMI *)Core::Wukong_Get_System().get_cpu() )->read_register(1,r1);
u8 STR_6_buf0 = STR_6_buf[0];
u8 STR_6_buf1 = STR_6_buf[1];
u8 STR_6_buf2 = STR_6_buf[2];
u8 STR_6_buf3 = STR_6_buf[3];
CPPUNIT_ASSERT( STR_6_buf0 == 0x10);
CPPUNIT_ASSERT( STR_6_buf1 == 0x80);
CPPUNIT_ASSERT( STR_6_buf2 == 0x00);
CPPUNIT_ASSERT( STR_6_buf3 == 0x00);
CPPUNIT_ASSERT( r1 == 0x000000E0);
//-------------------------------------------------------- programme-relative
// MOV r0,#0x10000002
// STR r0,DATA
Core::Wukong_Get_System().load_binary((Core::Binary_Loader &)(*loader), "ARM", "str_7.axf");
( (ARM::CPU_7TDMI *) Core::Wukong_Get_System().get_cpu() )->run();
std::vector<u8> STR_7_buf;
( (ARM::CPU_7TDMI *)Core::Wukong_Get_System().get_cpu() )->\
get_mmu().access(Memory_32Bit::MEMORY_READ,0x800c,4,STR_7_buf);
( (ARM::CPU_7TDMI *)Core::Wukong_Get_System().get_cpu() )->read_register(1,r1);
u8 STR_7_buf0 = STR_7_buf[0];
u8 STR_7_buf1 = STR_7_buf[1];
u8 STR_7_buf2 = STR_7_buf[2];
u8 STR_7_buf3 = STR_7_buf[3];
CPPUNIT_ASSERT( STR_7_buf0 == 0x02);
CPPUNIT_ASSERT( STR_7_buf1 == 0x00);
CPPUNIT_ASSERT( STR_7_buf2 == 0x00);
CPPUNIT_ASSERT( STR_7_buf3 == 0x10);
#endif
//____________________________________________________________________________
#ifdef TEST_STRB
//-------------------------------------------------------- zero offset
// MOV r0,#0x10000002
// MOV r1,#0x000000E0
// STRB r0,[r1]
Core::Wukong_Get_System().load_binary((Core::Binary_Loader &)(*loader), "ARM", "strb_1.axf");
( (ARM::CPU_7TDMI *) Core::Wukong_Get_System().get_cpu() )->run();
std::bitset<32> temp(0x000000E0);
( (ARM::CPU_7TDMI *)Core::Wukong_Get_System().get_cpu() )->\
get_mmu().access(Memory_32Bit::MEMORY_READ,0xe0,1,buf);
( (ARM::CPU_7TDMI *)Core::Wukong_Get_System().get_cpu() )->read_register(1,r1);
buf0 = buf[0];
CPPUNIT_ASSERT( buf0 == 0x02);
CPPUNIT_ASSERT( r1 == 0x000000E0);
//-------------------------------------------------------- pre-indexed offset
// MOV r0,#0x30000004
// MOV r1,#0x000000E1
// STRB r0,[r1,#0x3]
Core::Wukong_Get_System().load_binary((Core::Binary_Loader &)(*loader), "ARM", "strb_2.axf");
( (ARM::CPU_7TDMI *) Core::Wukong_Get_System().get_cpu() )->run();
std::vector<u8> STRB_2_buf;
( (ARM::CPU_7TDMI *)Core::Wukong_Get_System().get_cpu() )->\
get_mmu().access(Memory_32Bit::MEMORY_READ,0xe4,1,STRB_2_buf);
( (ARM::CPU_7TDMI *)Core::Wukong_Get_System().get_cpu() )->read_register(1,r1);
u8 STRB_2_buf0 = STRB_2_buf[0];
CPPUNIT_ASSERT( STRB_2_buf0 == 0x04);
CPPUNIT_ASSERT( r1 == 0x000000E1);
//-------------------------------------------------------- pre-indexed offset with write-back
// MOV r0,#0x10000002
// MOV r1,#0x000000E1
// STRB r0,[r1,#0x00000003]!
Core::Wukong_Get_System().load_binary((Core::Binary_Loader &)(*loader), "ARM", "strb_3.axf");
( (ARM::CPU_7TDMI *) Core::Wukong_Get_System().get_cpu() )->run();
std::vector<u8> STRB_3_buf;
( (ARM::CPU_7TDMI *)Core::Wukong_Get_System().get_cpu() )->\
get_mmu().access(Memory_32Bit::MEMORY_READ,0xe4,1,STRB_3_buf);
( (ARM::CPU_7TDMI *)Core::Wukong_Get_System().get_cpu() )->read_register(1,r1);
u8 STRB_3_buf0 = STRB_3_buf[0];
CPPUNIT_ASSERT( STRB_3_buf0 == 0x02);
CPPUNIT_ASSERT( r1 == 0x000000E4);
//-------------------------------------------------------- post-indexed offset
// MOV r0,#0x10000002
// MOV r1,#0x000000E0
// STRB r0,[r1],#0x00000002
Core::Wukong_Get_System().load_binary((Core::Binary_Loader &)(*loader), "ARM", "strb_4.axf");
( (ARM::CPU_7TDMI *) Core::Wukong_Get_System().get_cpu() )->run();
std::vector<u8> STRB_4_buf;
( (ARM::CPU_7TDMI *)Core::Wukong_Get_System().get_cpu() )->\
get_mmu().access(Memory_32Bit::MEMORY_READ,0xe0,1,STRB_4_buf);
( (ARM::CPU_7TDMI *)Core::Wukong_Get_System().get_cpu() )->read_register(1,r1);
u8 STRB_4_buf0 = STRB_4_buf[0];
CPPUNIT_ASSERT( STRB_4_buf0 == 0x02);
CPPUNIT_ASSERT( r1 == 0x000000E2);
#endif
//____________________________________________________________________________
#ifdef TEST_STRH
//-------------------------------------------------------- zero offset
// MOV r0,#0x960
// MOV r1,#0x000000E0
// STRH r0,[r1]
Core::Wukong_Get_System().load_binary((Core::Binary_Loader &)(*loader), "ARM", "strh_1.axf");
( (ARM::CPU_7TDMI *) Core::Wukong_Get_System().get_cpu() )->run();
( (ARM::CPU_7TDMI *)Core::Wukong_Get_System().get_cpu() )->\
get_mmu().access(Memory_32Bit::MEMORY_READ,0xe0,2,buf);
( (ARM::CPU_7TDMI *)Core::Wukong_Get_System().get_cpu() )->read_register(1,r1);
buf0 = buf[0];
buf1 = buf[1];
CPPUNIT_ASSERT( buf0 == 0x60);
CPPUNIT_ASSERT( buf1 == 0x09);
CPPUNIT_ASSERT(r1 == 0x000000E0);
//-------------------------------------------------------- pre-indexed offset
// MOV r0,#0x30000004
// MOV r1,#0x000000E1
// STRH r0,[r1,#3]
Core::Wukong_Get_System().load_binary((Core::Binary_Loader &)(*loader), "ARM", "strh_2.axf");
( (ARM::CPU_7TDMI *) Core::Wukong_Get_System().get_cpu() )->run();
std::vector<u8> STRH_2_buf;
( (ARM::CPU_7TDMI *)Core::Wukong_Get_System().get_cpu() )->\
get_mmu().access(Memory_32Bit::MEMORY_READ,0xe4,2,STRH_2_buf);
( (ARM::CPU_7TDMI *)Core::Wukong_Get_System().get_cpu() )->read_register(1,r1);
u8 STRH_2_buf0 = STRH_2_buf[0];
u8 STRH_2_buf1 = STRH_2_buf[1];
CPPUNIT_ASSERT( STRH_2_buf0 == 0x04);
CPPUNIT_ASSERT( STRH_2_buf1 == 0x00);
CPPUNIT_ASSERT( r1 == 0x000000E1);
//-------------------------------------------------------- pre-indexed offset with write-back
// MOV r0,#0x10000002
// MOV r1,#0x000000E1
// STRH r0,[r1,#0x00000003]!
Core::Wukong_Get_System().load_binary((Core::Binary_Loader &)(*loader), "ARM", "strh_3.axf");
( (ARM::CPU_7TDMI *) Core::Wukong_Get_System().get_cpu() )->run();
std::vector<u8> STRH_3_buf;
( (ARM::CPU_7TDMI *)Core::Wukong_Get_System().get_cpu() )->\
get_mmu().access(Memory_32Bit::MEMORY_READ,0xe4,2,STRH_3_buf);
( (ARM::CPU_7TDMI *)Core::Wukong_Get_System().get_cpu() )->read_register(1,r1);
u8 STRH_3_buf0 = STRH_3_buf[0];
u8 STRH_3_buf1 = STRH_3_buf[1];
CPPUNIT_ASSERT( STRH_3_buf0 == 0x02);
CPPUNIT_ASSERT( STRH_3_buf1 == 0x00);
CPPUNIT_ASSERT( r1 == 0x000000E4);
#endif
//____________________________________________________________________________
#ifdef TEST_SWP
//--------------------------------------------------------
Core::Wukong_Get_System().load_binary((Core::Binary_Loader &)(*loader), "ARM", "swp_1.axf");
( (ARM::CPU_7TDMI *) Core::Wukong_Get_System().get_cpu() )->run();
( (ARM::CPU_7TDMI *)Core::Wukong_Get_System().get_cpu() )->\
get_mmu().access(Memory_32Bit::MEMORY_READ,0xe0,4,buf);
( (ARM::CPU_7TDMI *)Core::Wukong_Get_System().get_cpu() )->read_register(1,r1);
buf0 = buf[0];
buf1 = buf[1];
buf2 = buf[2];
buf3 = buf[3];
CPPUNIT_ASSERT( buf0 == 0x0A);
CPPUNIT_ASSERT( buf1 == 0x00);
CPPUNIT_ASSERT( buf2 == 0x00);
CPPUNIT_ASSERT( buf3 == 0x00);
CPPUNIT_ASSERT( r1 == 0x10000002);
//--------------------------------------------------------
Core::Wukong_Get_System().load_binary((Core::Binary_Loader &)(*loader), "ARM", "swp_2.axf");
( (ARM::CPU_7TDMI *) Core::Wukong_Get_System().get_cpu() )->run();
( (ARM::CPU_7TDMI *)Core::Wukong_Get_System().get_cpu() )->\
get_mmu().access(Memory_32Bit::MEMORY_READ,0xe0,4,buf);
( (ARM::CPU_7TDMI *)Core::Wukong_Get_System().get_cpu() )->read_register(1,r1);
buf0 = buf[0];
buf1 = buf[1];
buf2 = buf[2];
buf3 = buf[3];
CPPUNIT_ASSERT( buf0 == 0x0A);
CPPUNIT_ASSERT( buf1 == 0x00);
CPPUNIT_ASSERT( buf2 == 0x00);
CPPUNIT_ASSERT( buf3 == 0x00);
CPPUNIT_ASSERT( r1 == 0x02100000);
//--------------------------------------------------------
Core::Wukong_Get_System().load_binary((Core::Binary_Loader &)(*loader), "ARM", "swp_3.axf");
( (ARM::CPU_7TDMI *) Core::Wukong_Get_System().get_cpu() )->run();
( (ARM::CPU_7TDMI *)Core::Wukong_Get_System().get_cpu() )->\
get_mmu().access(Memory_32Bit::MEMORY_READ,0xe0,4,buf);
( (ARM::CPU_7TDMI *)Core::Wukong_Get_System().get_cpu() )->read_register(1,r1);
buf0 = buf[0];
buf1 = buf[1];
buf2 = buf[2];
buf3 = buf[3];
CPPUNIT_ASSERT( buf0 == 0x0A);
CPPUNIT_ASSERT( buf1 == 0x00);
CPPUNIT_ASSERT( buf2 == 0x00);
CPPUNIT_ASSERT( buf3 == 0x00);
CPPUNIT_ASSERT( r1 == 0x00021000);
//--------------------------------------------------------
Core::Wukong_Get_System().load_binary((Core::Binary_Loader &)(*loader), "ARM", "swp_4.axf");
( (ARM::CPU_7TDMI *) Core::Wukong_Get_System().get_cpu() )->run();
( (ARM::CPU_7TDMI *)Core::Wukong_Get_System().get_cpu() )->\
get_mmu().access(Memory_32Bit::MEMORY_READ,0xe0,4,buf);
( (ARM::CPU_7TDMI *)Core::Wukong_Get_System().get_cpu() )->read_register(1,r1);
buf0 = buf[0];
buf1 = buf[1];
buf2 = buf[2];
buf3 = buf[3];
CPPUNIT_ASSERT( buf0 == 0x0A);
CPPUNIT_ASSERT( buf1 == 0x00);
CPPUNIT_ASSERT( buf2 == 0x00);
CPPUNIT_ASSERT( buf3 == 0x00);
CPPUNIT_ASSERT( r1 == 0x00000210);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -