mirror of
https://github.com/tuz358/cpu-emulator.git
synced 2025-12-18 13:04:35 +03:00
Minor fixes
This commit is contained in:
@@ -47,7 +47,7 @@ public:
|
|||||||
void template_rm32_r32(int calc_type);
|
void template_rm32_r32(int calc_type);
|
||||||
void calc_rm32_r32_case0to2(uint32_t addr, uint32_t dst, int calc_type);
|
void calc_rm32_r32_case0to2(uint32_t addr, uint32_t dst, int calc_type);
|
||||||
void template_r32_rm32(int calc_type);
|
void template_r32_rm32(int calc_type);
|
||||||
void calc_r32_rm32(uint32_t *src, uint32_t *dst, int calc_type);
|
void calc_r32_rm32(uint32_t *dst, uint32_t *src, int calc_type);
|
||||||
void template_eax_imm32(int calc_type);
|
void template_eax_imm32(int calc_type);
|
||||||
|
|
||||||
void add_rm32_r32(); // 0x01
|
void add_rm32_r32(); // 0x01
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ void Instructions::calc_rm32_r32_case0to2(uint32_t addr, uint32_t dst, int calc_
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Instructions::template_r32_rm32(int calc_type){
|
void Instructions::template_r32_rm32(int calc_type){
|
||||||
uint32_t addr, dst, imm32;
|
uint32_t addr, src, imm32;
|
||||||
uint8_t imm8;
|
uint8_t imm8;
|
||||||
|
|
||||||
this->modrm = memory.read_uint8(this->eip);
|
this->modrm = memory.read_uint8(this->eip);
|
||||||
@@ -211,9 +211,9 @@ void Instructions::template_r32_rm32(int calc_type){
|
|||||||
// addr : M
|
// addr : M
|
||||||
this->eip++;
|
this->eip++;
|
||||||
addr = this->registers[this->M];
|
addr = this->registers[this->M];
|
||||||
// dst : data of [M]
|
// src : data of [M]
|
||||||
dst = memory.read_uint32(addr);
|
src = memory.read_uint32(addr);
|
||||||
calc_r32_rm32(&this->registers[this->R], &dst, calc_type);
|
calc_r32_rm32(&this->registers[this->R], &src, calc_type);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
// operation R, [M+imm8]
|
// operation R, [M+imm8]
|
||||||
@@ -221,9 +221,9 @@ void Instructions::template_r32_rm32(int calc_type){
|
|||||||
imm8 = memory.read_uint8(this->eip);
|
imm8 = memory.read_uint8(this->eip);
|
||||||
// addr : M
|
// addr : M
|
||||||
addr = this->registers[this->M];
|
addr = this->registers[this->M];
|
||||||
// dst : data of [M+imm8]
|
// src : data of [M+imm8]
|
||||||
dst = memory.read_uint32(addr + imm8);
|
src = memory.read_uint32(addr + imm8);
|
||||||
calc_r32_rm32(&this->registers[this->R], &dst, calc_type);
|
calc_r32_rm32(&this->registers[this->R], &src, calc_type);
|
||||||
this->eip++;
|
this->eip++;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
@@ -233,9 +233,9 @@ void Instructions::template_r32_rm32(int calc_type){
|
|||||||
imm32 = swap_endian32(imm32);
|
imm32 = swap_endian32(imm32);
|
||||||
// addr : M
|
// addr : M
|
||||||
addr = this->registers[this->M];
|
addr = this->registers[this->M];
|
||||||
// dst : data of [M+imm32]
|
// src : data of [M+imm32]
|
||||||
dst = memory.read_uint32(addr + imm32);
|
src = memory.read_uint32(addr + imm32);
|
||||||
calc_r32_rm32(&this->registers[this->R], &dst, calc_type);
|
calc_r32_rm32(&this->registers[this->R], &src, calc_type);
|
||||||
this->eip += 4;
|
this->eip += 4;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -247,22 +247,22 @@ void Instructions::template_r32_rm32(int calc_type){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Instructions::calc_r32_rm32(uint32_t *src, uint32_t *dst, int calc_type){
|
void Instructions::calc_r32_rm32(uint32_t *dst, uint32_t *src, int calc_type){
|
||||||
switch (calc_type) {
|
switch (calc_type) {
|
||||||
case ADD:
|
case ADD:
|
||||||
*src += *dst; break;
|
*dst += *src; break;
|
||||||
case OR:
|
case OR:
|
||||||
*src |= *dst; break;
|
*dst |= *src; break;
|
||||||
case ADC:
|
case ADC:
|
||||||
*src += *dst + get_flag(CF); break;
|
*dst += *src + get_flag(CF); break;
|
||||||
case SBB:
|
case SBB:
|
||||||
*src -= *dst + get_flag(CF); break;
|
*dst -= *src + get_flag(CF); break;
|
||||||
case AND:
|
case AND:
|
||||||
*src &= *dst; break;
|
*dst &= *src; break;
|
||||||
case SUB:
|
case SUB:
|
||||||
*src -= *dst; break;
|
*dst -= *src; break;
|
||||||
case XOR:
|
case XOR:
|
||||||
*src ^= *dst; break;
|
*dst ^= *src; break;
|
||||||
case CMP:
|
case CMP:
|
||||||
// TODO: implement
|
// TODO: implement
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user