Add xchg_eax_r32(0x91~0x97) instruction

This commit is contained in:
tuz358
2018-03-06 10:00:07 +09:00
parent 35addee260
commit 1caebfc67e
2 changed files with 12 additions and 0 deletions

View File

@@ -65,6 +65,7 @@ public:
void opcode_83(); // 0x83 void opcode_83(); // 0x83
void mov_rm32_r32(); // 0x89 void mov_rm32_r32(); // 0x89
void nop(); // 0x90 void nop(); // 0x90
void xchg_eax_r32(); // 0x91 ~ 0x97
void mov_eax_imm32(); // 0xb8 void mov_eax_imm32(); // 0xb8
void mov_ecx_imm32(); // 0xb9 void mov_ecx_imm32(); // 0xb9
void mov_edx_imm32(); // 0xba void mov_edx_imm32(); // 0xba

View File

@@ -58,6 +58,9 @@ void Instructions::init_instructions(){
this->instructions[0x83] = &Instructions::opcode_83; this->instructions[0x83] = &Instructions::opcode_83;
this->instructions[0x89] = &Instructions::mov_rm32_r32; this->instructions[0x89] = &Instructions::mov_rm32_r32;
this->instructions[0x90] = &Instructions::nop; this->instructions[0x90] = &Instructions::nop;
for(int i=0;i<7;i++){
this->instructions[0x91+i] = &Instructions::xchg_eax_r32;
}
this->instructions[0xb8] = &Instructions::mov_eax_imm32; this->instructions[0xb8] = &Instructions::mov_eax_imm32;
this->instructions[0xb9] = &Instructions::mov_ecx_imm32; this->instructions[0xb9] = &Instructions::mov_ecx_imm32;
this->instructions[0xba] = &Instructions::mov_edx_imm32; this->instructions[0xba] = &Instructions::mov_edx_imm32;
@@ -448,6 +451,14 @@ void Instructions::nop(){
//printf("nop called.\n"); //printf("nop called.\n");
} }
void Instructions::xchg_eax_r32(){
//printf("xchg_eax_r32 called.\n");
uint8_t opcode = memory.read_uint8(this->eip - 1);
this->registers[0] ^= this->registers[opcode - 0x90];
this->registers[opcode - 0x90] ^= this->registers[0];
this->registers[0] ^= this->registers[opcode - 0x90];
}
void Instructions::mov_eax_imm32(){ void Instructions::mov_eax_imm32(){
//printf("mov_eax_imm32 called.\n"); //printf("mov_eax_imm32 called.\n");