mirror of
https://github.com/tuz358/cpu-emulator.git
synced 2025-12-19 05:24:35 +03:00
Add opcode_83(0x83) instruction
This commit is contained in:
@@ -29,6 +29,7 @@ public:
|
|||||||
void add_rm32_r32(); // 0x01
|
void add_rm32_r32(); // 0x01
|
||||||
void xor_rm32_r32(); // 0x31
|
void xor_rm32_r32(); // 0x31
|
||||||
void dec_ecx(); // 0x49
|
void dec_ecx(); // 0x49
|
||||||
|
void opcode_83(); // 0x83
|
||||||
void mov_rm32_r32(); // 0x89
|
void mov_rm32_r32(); // 0x89
|
||||||
void nop(); // 0x90
|
void nop(); // 0x90
|
||||||
void mov_ecx_imm32(); // 0xb9
|
void mov_ecx_imm32(); // 0xb9
|
||||||
@@ -37,5 +38,5 @@ public:
|
|||||||
void hlt(); // 0xf4
|
void hlt(); // 0xf4
|
||||||
void opcode_ff(); // 0xff
|
void opcode_ff(); // 0xff
|
||||||
|
|
||||||
void cmp_rm32_imm8();
|
void cmp_rm32_imm8(); // called by opcode_83
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ void Instructions::init_instructions(){
|
|||||||
this->instructions[0x01] = &Instructions::add_rm32_r32;
|
this->instructions[0x01] = &Instructions::add_rm32_r32;
|
||||||
this->instructions[0x31] = &Instructions::xor_rm32_r32;
|
this->instructions[0x31] = &Instructions::xor_rm32_r32;
|
||||||
this->instructions[0x49] = &Instructions::dec_ecx;
|
this->instructions[0x49] = &Instructions::dec_ecx;
|
||||||
|
this->instructions[0x83] = &Instructions::opcode_83;
|
||||||
this->instructions[0x89] = &Instructions::mov_rm32_r32;
|
this->instructions[0x89] = &Instructions::mov_rm32_r32;
|
||||||
this->instructions[0x90] = &Instructions::nop;
|
this->instructions[0x90] = &Instructions::nop;
|
||||||
this->instructions[0xb9] = &Instructions::mov_ecx_imm32;
|
this->instructions[0xb9] = &Instructions::mov_ecx_imm32;
|
||||||
@@ -153,6 +154,21 @@ void Instructions::dec_ecx(){
|
|||||||
this->registers[1]--;
|
this->registers[1]--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Instructions::opcode_83(){
|
||||||
|
printf("opcode_83 called.\n");
|
||||||
|
|
||||||
|
this->modrm = memory.read_uint8(this->eip);
|
||||||
|
this->calc_modrm();
|
||||||
|
|
||||||
|
switch (this->R) {
|
||||||
|
case 7:
|
||||||
|
cmp_rm32_imm8();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Instructions::mov_rm32_r32(){
|
void Instructions::mov_rm32_r32(){
|
||||||
printf("mov_rm32_r32 called.\n");
|
printf("mov_rm32_r32 called.\n");
|
||||||
uint32_t addr, imm32;
|
uint32_t addr, imm32;
|
||||||
@@ -255,14 +271,14 @@ void Instructions::opcode_ff(){
|
|||||||
void Instructions::cmp_rm32_imm8(){
|
void Instructions::cmp_rm32_imm8(){
|
||||||
printf("cmp_rm32_imm8 called.\n");
|
printf("cmp_rm32_imm8 called.\n");
|
||||||
|
|
||||||
this->modrm = memory.read_uint8(this->eip);
|
|
||||||
this->calc_modrm();
|
|
||||||
|
|
||||||
this->eip++;
|
this->eip++;
|
||||||
uint8_t imm8 = memory.read_uint8(this->eip);
|
uint8_t imm8 = memory.read_uint8(this->eip);
|
||||||
|
printf("imm8: 0x%08x (%d)\n", imm8, imm8);
|
||||||
uint32_t result = this->registers[this->M] - imm8;
|
uint32_t result = this->registers[this->M] - imm8;
|
||||||
|
|
||||||
set_flag(!result, ZF);
|
set_flag(!result, ZF);
|
||||||
|
|
||||||
|
this->eip++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Instructions::set_flag(int flag, uint32_t flag_type){
|
void Instructions::set_flag(int flag, uint32_t flag_type){
|
||||||
|
|||||||
Reference in New Issue
Block a user