mirror of
https://github.com/tuz358/cpu-emulator.git
synced 2025-12-18 13:04:35 +03:00
Add functions of ModRM
This commit is contained in:
@@ -13,9 +13,13 @@ public:
|
||||
uint32_t eflags; // EFLAGS register
|
||||
uint32_t eip; // Instruction pointer
|
||||
|
||||
uint8_t modrm, mod, R, M; // ModRM
|
||||
|
||||
void (Instructions::*instructions[256])(void);
|
||||
|
||||
void init(uint32_t eip, uint32_t esp, Memory memory);
|
||||
void init_modrm();
|
||||
void calc_modrm();
|
||||
void execute_opcode(uint8_t opcode);
|
||||
|
||||
void nop();
|
||||
|
||||
@@ -14,6 +14,7 @@ void Instructions::init(uint32_t eip, uint32_t esp, Memory memory){
|
||||
this->memory = memory;
|
||||
|
||||
this->init_instructions();
|
||||
this->init_modrm();
|
||||
}
|
||||
|
||||
void Instructions::init_instructions(){
|
||||
@@ -23,6 +24,19 @@ void Instructions::init_instructions(){
|
||||
this->instructions[0xf4] = &Instructions::hlt;
|
||||
}
|
||||
|
||||
void Instructions::init_modrm(){
|
||||
this->modrm = 0;
|
||||
this->mod = 0;
|
||||
this->R = 0;
|
||||
this->M = 0;
|
||||
}
|
||||
|
||||
void Instructions::calc_modrm(){
|
||||
this->mod = (this->modrm & 0xc0) >> 6;
|
||||
this->R = (this->modrm & 0x38) >> 3;
|
||||
this->M = this->modrm & 0x07;
|
||||
}
|
||||
|
||||
void Instructions::execute_opcode(uint8_t opcode){
|
||||
(this->*instructions[opcode])();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user