mirror of
https://github.com/tuz358/cpu-emulator.git
synced 2025-12-18 21:14:35 +03:00
Delete redundant processing on opcode_81/83
This commit is contained in:
@@ -5,9 +5,14 @@
|
|||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
|
// eflags
|
||||||
const uint32_t CF = 1;
|
const uint32_t CF = 1;
|
||||||
const uint32_t ZF = 1 << 6;
|
const uint32_t ZF = 1 << 6;
|
||||||
|
|
||||||
|
// used by opcode_81 and opcode_83
|
||||||
|
const int IMM8 = 0;
|
||||||
|
const int IMM32 = 1;
|
||||||
|
|
||||||
class Instructions{
|
class Instructions{
|
||||||
private:
|
private:
|
||||||
void init_instructions();
|
void init_instructions();
|
||||||
@@ -109,10 +114,7 @@ public:
|
|||||||
void hlt(); // 0xf4
|
void hlt(); // 0xf4
|
||||||
void opcode_ff(); // 0xff
|
void opcode_ff(); // 0xff
|
||||||
|
|
||||||
// called by opcode_81
|
// called by opcode_81 and opcode_83
|
||||||
void add_rm32_imm32();
|
void add_rm32_imm(int imm_flag);
|
||||||
|
|
||||||
// called by opcode_83
|
|
||||||
void add_rm32_imm8();
|
|
||||||
void cmp_rm32_imm8();
|
void cmp_rm32_imm8();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1166,7 +1166,7 @@ void Instructions::opcode_81(){
|
|||||||
|
|
||||||
switch (this->R) {
|
switch (this->R) {
|
||||||
case 0:
|
case 0:
|
||||||
add_rm32_imm32();
|
add_rm32_imm(IMM32);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
// TODO: or_rm32_imm32();
|
// TODO: or_rm32_imm32();
|
||||||
@@ -1202,7 +1202,7 @@ void Instructions::opcode_83(){
|
|||||||
|
|
||||||
switch (this->R) {
|
switch (this->R) {
|
||||||
case 0:
|
case 0:
|
||||||
add_rm32_imm8();
|
add_rm32_imm(IMM8);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
// TODO: or_rm32_imm8();
|
// TODO: or_rm32_imm8();
|
||||||
@@ -1478,25 +1478,20 @@ void Instructions::opcode_ff(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Instructions::add_rm32_imm32(){
|
void Instructions::add_rm32_imm(int imm_flag){
|
||||||
//printf("add_rm32_imm32 called.\n");
|
//printf("add_rm32_imm called.\n");
|
||||||
|
|
||||||
this->eip++;
|
this->eip++;
|
||||||
uint32_t imm32 = memory.read_uint32(this->eip);
|
|
||||||
imm32 = swap_endian32(imm32);
|
|
||||||
//printf("imm32: 0x%08x (%d)\n", imm32, imm32);
|
|
||||||
this->registers[this->M] += imm32;
|
|
||||||
|
|
||||||
this->eip++;
|
if(imm_flag == IMM8){
|
||||||
}
|
uint8_t imm8 = memory.read_uint8(this->eip);
|
||||||
|
this->registers[this->M] += imm8;
|
||||||
void Instructions::add_rm32_imm8(){
|
} else if(imm_flag == IMM32){
|
||||||
//printf("add_rm32_imm8 called.\n");
|
uint32_t imm32 = memory.read_uint32(this->eip);
|
||||||
|
imm32 = swap_endian32(imm32);
|
||||||
this->eip++;
|
this->registers[this->M] += imm32;
|
||||||
uint8_t imm8 = memory.read_uint8(this->eip);
|
} else {
|
||||||
//printf("imm8: 0x%08x (%d)\n", imm8, imm8);
|
}
|
||||||
this->registers[this->M] += imm8;
|
|
||||||
|
|
||||||
this->eip++;
|
this->eip++;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user