Add adc_r32_rm32(0x13) instruction

This commit is contained in:
tuz358
2018-03-12 12:47:46 +09:00
parent 584179ee7d
commit 79868a7665
2 changed files with 52 additions and 0 deletions

View File

@@ -35,6 +35,7 @@ public:
void or_r32_rm32(); // 0x0b void or_r32_rm32(); // 0x0b
void or_eax_imm32(); // 0x0d void or_eax_imm32(); // 0x0d
void adc_rm32_r32(); // 0x11 void adc_rm32_r32(); // 0x11
void adc_r32_rm32(); // 0x13
void and_rm32_r32(); // 0x21 void and_rm32_r32(); // 0x21
void and_r32_rm32(); // 0x23 void and_r32_rm32(); // 0x23
void and_eax_imm32(); // 0x25 void and_eax_imm32(); // 0x25

View File

@@ -27,6 +27,7 @@ void Instructions::init_instructions(){
this->instructions[0x0b] = &Instructions::or_r32_rm32; this->instructions[0x0b] = &Instructions::or_r32_rm32;
this->instructions[0x0d] = &Instructions::or_eax_imm32; this->instructions[0x0d] = &Instructions::or_eax_imm32;
this->instructions[0x11] = &Instructions::adc_rm32_r32; this->instructions[0x11] = &Instructions::adc_rm32_r32;
this->instructions[0x13] = &Instructions::adc_r32_rm32;
this->instructions[0x21] = &Instructions::and_rm32_r32; this->instructions[0x21] = &Instructions::and_rm32_r32;
this->instructions[0x23] = &Instructions::and_r32_rm32; this->instructions[0x23] = &Instructions::and_r32_rm32;
this->instructions[0x25] = &Instructions::and_eax_imm32; this->instructions[0x25] = &Instructions::and_eax_imm32;
@@ -382,6 +383,56 @@ void Instructions::adc_rm32_r32(){
} }
} }
void Instructions::adc_r32_rm32(){
//printf("adc_r32_rm32 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:
// adc R, [M]
// addr : M
this->eip++;
addr = this->registers[this->M];
// dst : data of [M]
dst = memory.read_uint32(addr);
this->registers[this->R] += dst + CF;
break;
case 1:
// adc R, [M+imm8]
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);
this->registers[this->R] += dst + CF;
this->eip++;
break;
case 2:
// adc R, [M+imm32]
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);
this->registers[this->R] += dst + CF;
this->eip += 4;
break;
default:
// case mod == 3
// adc R, M
this->eip++;
this->registers[this->R] += this->registers[this->M] + CF;
break;
}
}
void Instructions::and_rm32_r32(){ void Instructions::and_rm32_r32(){
//printf("and_rm32_r32 called.\n"); //printf("and_rm32_r32 called.\n");
uint32_t addr, dst, imm32; uint32_t addr, dst, imm32;