Delete redundant processing on ***_rm32_r32 instruction

This commit is contained in:
tuz358
2018-03-16 15:04:36 +09:00
parent d1db40a6e1
commit 9210d82fec

View File

@@ -297,372 +297,31 @@ void Instructions::template_eax_imm32(int calc_type){
} }
} }
void Instructions::add_rm32_r32(){ void Instructions::add_rm32_r32() { this->template_rm32_r32(ADD); }
//printf("add_rm32_r32 called.\n"); void Instructions::add_r32_rm32() { this->template_r32_rm32(ADD); }
uint32_t addr, dst, imm32;
uint8_t imm8;
this->modrm = memory.read_uint8(this->eip);
this->calc_modrm();
switch (this->mod) {
case 0:
// add [M], R
// addr : M
this->eip++;
addr = this->registers[this->M];
// dst : data of [M]
dst = memory.read_uint32(addr);
memory.write_uint32(addr, dst + this->registers[this->R]);
break;
case 1:
// add [M+imm8], R
this->eip++;
imm8 = memory.read_uint8(this->eip);
// addr : M
addr = this->registers[this->M];
// dst : data of [M+imm8]
dst = memory.read_uint32(addr + imm8);
memory.write_uint32(addr + imm8, dst + this->registers[this->R]);
this->eip++;
break;
case 2:
// add [M+imm32], R
this->eip++;
imm32 = memory.read_uint32(this->eip);
imm32 = swap_endian32(imm32);
// addr : M
addr = this->registers[this->M];
// dst : data of [M+imm32]
dst = memory.read_uint32(addr + imm32);
memory.write_uint32(addr, dst + this->registers[this->R]);
this->eip += 4;
break;
default:
// case mod == 3
// add M, R
this->eip++;
this->registers[this->M] += this->registers[this->R];
break;
}
}
void Instructions::add_r32_rm32(){ this->template_r32_rm32(ADD); }
void Instructions::add_eax_imm32(){ this->template_eax_imm32(ADD); } void Instructions::add_eax_imm32(){ this->template_eax_imm32(ADD); }
void Instructions::or_rm32_r32(){ void Instructions::or_rm32_r32() { this->template_rm32_r32(OR); }
//printf("or_rm32_r32 called.\n"); void Instructions::or_r32_rm32() { this->template_r32_rm32(OR); }
uint32_t addr, dst, imm32;
uint8_t imm8;
this->modrm = memory.read_uint8(this->eip);
this->calc_modrm();
switch (this->mod) {
case 0:
// or [M], R
// addr : M
this->eip++;
addr = this->registers[this->M];
// dst : data of [M]
dst = memory.read_uint32(addr);
memory.write_uint32(addr, dst | this->registers[this->R]);
break;
case 1:
// or [M+imm8], R
this->eip++;
imm8 = memory.read_uint8(this->eip);
// addr : M
addr = this->registers[this->M];
// dst : data of [M+imm8]
dst = memory.read_uint32(addr + imm8);
memory.write_uint32(addr + imm8, dst | this->registers[this->R]);
this->eip++;
break;
case 2:
// or [M+imm32], R
this->eip++;
imm32 = memory.read_uint32(this->eip);
imm32 = swap_endian32(imm32);
// addr : M
addr = this->registers[this->M];
// dst : data of [M+imm32]
dst = memory.read_uint32(addr + imm32);
memory.write_uint32(addr, dst | this->registers[this->R]);
this->eip += 4;
break;
default:
// case mod == 3
// or M, R
this->eip++;
this->registers[this->M] |= this->registers[this->R];
break;
}
}
void Instructions::or_r32_rm32(){ this->template_r32_rm32(OR); }
void Instructions::or_eax_imm32(){ this->template_eax_imm32(OR); } void Instructions::or_eax_imm32(){ this->template_eax_imm32(OR); }
void Instructions::adc_rm32_r32(){ void Instructions::adc_rm32_r32() { this->template_rm32_r32(ADC); }
//printf("adc_rm32_r32 called.\n"); void Instructions::adc_r32_rm32() { this->template_r32_rm32(ADC); }
uint32_t addr, dst, imm32;
uint8_t imm8;
this->modrm = memory.read_uint8(this->eip);
this->calc_modrm();
switch (this->mod) {
case 0:
// adc [M], R
// addr : M
this->eip++;
addr = this->registers[this->M];
// dst : data of [M]
dst = memory.read_uint32(addr);
memory.write_uint32(addr, dst + this->registers[this->R] + get_flag(CF));
break;
case 1:
// adc [M+imm8], R
this->eip++;
imm8 = memory.read_uint8(this->eip);
// addr : M
addr = this->registers[this->M];
// dst : data of [M+imm8]
dst = memory.read_uint32(addr + imm8);
memory.write_uint32(addr + imm8, dst + this->registers[this->R] + get_flag(CF));
this->eip++;
break;
case 2:
// adc [M+imm32], R
this->eip++;
imm32 = memory.read_uint32(this->eip);
imm32 = swap_endian32(imm32);
// addr : M
addr = this->registers[this->M];
// dst : data of [M+imm32]
dst = memory.read_uint32(addr + imm32);
memory.write_uint32(addr, dst + this->registers[this->R] + get_flag(CF));
this->eip += 4;
break;
default:
// case mod == 3
// adc M, R
this->eip++;
this->registers[this->M] += this->registers[this->R] + get_flag(CF);
break;
}
}
void Instructions::adc_r32_rm32(){ this->template_r32_rm32(ADC); }
void Instructions::adc_eax_imm32(){ this->template_eax_imm32(ADC); } void Instructions::adc_eax_imm32(){ this->template_eax_imm32(ADC); }
void Instructions::sbb_rm32_r32(){ void Instructions::sbb_rm32_r32() { this->template_rm32_r32(SBB); }
//printf("sbb_rm32_r32 called.\n"); void Instructions::sbb_r32_rm32() { this->template_r32_rm32(SBB); }
uint32_t addr, dst, imm32;
uint8_t imm8;
this->modrm = memory.read_uint8(this->eip);
this->calc_modrm();
switch (this->mod) {
case 0:
// sbb [M], R
// addr : M
this->eip++;
addr = this->registers[this->M];
// dst : data of [M]
dst = memory.read_uint32(addr);
memory.write_uint32(addr, dst - (this->registers[this->R] + get_flag(CF)));
break;
case 1:
// sbb [M+imm8], R
this->eip++;
imm8 = memory.read_uint8(this->eip);
// addr : M
addr = this->registers[this->M];
// dst : data of [M+imm8]
dst = memory.read_uint32(addr + imm8);
memory.write_uint32(addr + imm8, dst - (this->registers[this->R] + get_flag(CF)));
this->eip++;
break;
case 2:
// sbb [M+imm32], R
this->eip++;
imm32 = memory.read_uint32(this->eip);
imm32 = swap_endian32(imm32);
// addr : M
addr = this->registers[this->M];
// dst : data of [M+imm32]
dst = memory.read_uint32(addr + imm32);
memory.write_uint32(addr, dst - (this->registers[this->R] + get_flag(CF)));
this->eip += 4;
break;
default:
// case mod == 3
// sbb M, R
this->eip++;
this->registers[this->M] -= this->registers[this->R] + get_flag(CF);
break;
}
}
void Instructions::sbb_r32_rm32(){ this->template_r32_rm32(SBB); }
void Instructions::sbb_eax_imm32(){ this->template_eax_imm32(SBB); } void Instructions::sbb_eax_imm32(){ this->template_eax_imm32(SBB); }
void Instructions::and_rm32_r32(){ void Instructions::and_rm32_r32() { this->template_rm32_r32(AND); }
//printf("and_rm32_r32 called.\n");
uint32_t addr, dst, imm32;
uint8_t imm8;
this->modrm = memory.read_uint8(this->eip);
this->calc_modrm();
switch (this->mod) {
case 0:
// and [M], R
// addr : M
this->eip++;
addr = this->registers[this->M];
// dst : data of [M]
dst = memory.read_uint32(addr);
memory.write_uint32(addr, dst & this->registers[this->R]);
break;
case 1:
// and [M+imm8], R
this->eip++;
imm8 = memory.read_uint8(this->eip);
// addr : M
addr = this->registers[this->M];
// dst : data of [M+imm8]
dst = memory.read_uint32(addr + imm8);
memory.write_uint32(addr + imm8, dst & this->registers[this->R]);
this->eip++;
break;
case 2:
// and [M+imm32], R
this->eip++;
imm32 = memory.read_uint32(this->eip);
imm32 = swap_endian32(imm32);
// addr : M
addr = this->registers[this->M];
// dst : data of [M+imm32]
dst = memory.read_uint32(addr + imm32);
memory.write_uint32(addr, dst & this->registers[this->R]);
this->eip += 4;
break;
default:
// case mod == 3
// and M, R
this->eip++;
this->registers[this->M] &= this->registers[this->R];
break;
}
}
void Instructions::and_r32_rm32() { this->template_r32_rm32(AND); } void Instructions::and_r32_rm32() { this->template_r32_rm32(AND); }
void Instructions::and_eax_imm32(){ this->template_eax_imm32(AND); } void Instructions::and_eax_imm32(){ this->template_eax_imm32(AND); }
void Instructions::sub_rm32_r32(){ void Instructions::sub_rm32_r32() { this->template_rm32_r32(SUB); }
//printf("sub_rm32_r32 called.\n");
uint32_t addr, dst, imm32;
uint8_t imm8;
this->modrm = memory.read_uint8(this->eip);
this->calc_modrm();
switch (this->mod) {
case 0:
// sub [M], R
// addr : M
this->eip++;
addr = this->registers[this->M];
// dst : data of [M]
dst = memory.read_uint32(addr);
memory.write_uint32(addr, dst - this->registers[this->R]);
break;
case 1:
// sub [M+imm8], R
this->eip++;
imm8 = memory.read_uint8(this->eip);
// addr : M
addr = this->registers[this->M];
// dst : data of [M+imm8]
dst = memory.read_uint32(addr + imm8);
memory.write_uint32(addr + imm8, dst - this->registers[this->R]);
break;
case 2:
// sub [M+imm32], R
this->eip++;
imm32 = memory.read_uint32(this->eip);
imm32 = swap_endian32(imm32);
// addr : M
addr = this->registers[this->M];
// dst : data of [M+imm32]
dst = memory.read_uint32(addr + imm32);
memory.write_uint32(addr, dst - this->registers[this->R]);
this->eip += 4;
break;
default:
// case mod == 3
// sub M, R
this->eip++;
this->registers[this->M] -= this->registers[this->R];
break;
}
}
void Instructions::sub_r32_rm32() { this->template_r32_rm32(SUB); } void Instructions::sub_r32_rm32() { this->template_r32_rm32(SUB); }
void Instructions::sub_eax_imm32(){ this->template_eax_imm32(SUB); } void Instructions::sub_eax_imm32(){ this->template_eax_imm32(SUB); }
void Instructions::xor_rm32_r32(){ void Instructions::xor_rm32_r32() { this->template_rm32_r32(XOR); }
//printf("xor_rm32_r32 called.\n");
uint32_t addr, dst, imm32;
uint8_t imm8;
this->modrm = memory.read_uint8(this->eip);
this->calc_modrm();
switch (this->mod) {
case 0:
// xor [M], R
// addr : M
this->eip++;
addr = this->registers[this->M];
// dst : data of [M]
dst = memory.read_uint32(addr);
memory.write_uint32(addr, dst ^ this->registers[this->R]);
break;
case 1:
// xor [M+imm8], R
this->eip++;
imm8 = memory.read_uint8(this->eip);
// addr : M
addr = this->registers[this->M];
// dst : data of [M+imm8]
dst = memory.read_uint32(addr + imm8);
memory.write_uint32(addr + imm8, dst ^ this->registers[this->R]);
break;
case 2:
// xor [M+imm32], R
this->eip++;
imm32 = memory.read_uint32(this->eip);
imm32 = swap_endian32(imm32);
// addr : M
addr = this->registers[this->M];
// dst : data of [M+imm32]
dst = memory.read_uint32(addr + imm32);
memory.write_uint32(addr, dst ^ this->registers[this->R]);
this->eip += 4;
break;
default:
// case mod == 3
// xor M, R
this->eip++;
this->registers[this->M] ^= this->registers[this->R];
break;
}
}
void Instructions::xor_r32_rm32() { this->template_r32_rm32(XOR); } void Instructions::xor_r32_rm32() { this->template_r32_rm32(XOR); }
void Instructions::xor_eax_imm32(){ this->template_eax_imm32(XOR); } void Instructions::xor_eax_imm32(){ this->template_eax_imm32(XOR); }