mirror of
https://github.com/tuz358/cpu-emulator.git
synced 2025-12-18 13:04:35 +03:00
Add sbb_rm32_r32(0x19) instruction
This commit is contained in:
@@ -37,6 +37,7 @@ public:
|
||||
void adc_rm32_r32(); // 0x11
|
||||
void adc_r32_rm32(); // 0x13
|
||||
void adc_eax_imm32(); // 0x15
|
||||
void sbb_rm32_r32(); // 0x19
|
||||
void and_rm32_r32(); // 0x21
|
||||
void and_r32_rm32(); // 0x23
|
||||
void and_eax_imm32(); // 0x25
|
||||
|
||||
@@ -29,6 +29,7 @@ void Instructions::init_instructions(){
|
||||
this->instructions[0x11] = &Instructions::adc_rm32_r32;
|
||||
this->instructions[0x13] = &Instructions::adc_r32_rm32;
|
||||
this->instructions[0x15] = &Instructions::adc_eax_imm32;
|
||||
this->instructions[0x19] = &Instructions::sbb_rm32_r32;
|
||||
this->instructions[0x21] = &Instructions::and_rm32_r32;
|
||||
this->instructions[0x23] = &Instructions::and_r32_rm32;
|
||||
this->instructions[0x25] = &Instructions::and_eax_imm32;
|
||||
@@ -441,6 +442,56 @@ void Instructions::adc_eax_imm32(){
|
||||
this->registers[0] += imm32 + get_flag(CF);
|
||||
}
|
||||
|
||||
void Instructions::sbb_rm32_r32(){
|
||||
//printf("sbb_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:
|
||||
// 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::and_rm32_r32(){
|
||||
//printf("and_rm32_r32 called.\n");
|
||||
uint32_t addr, dst, imm32;
|
||||
|
||||
Reference in New Issue
Block a user