-
Notifications
You must be signed in to change notification settings - Fork 0
/
Instruction16.cpp
75 lines (59 loc) · 1.47 KB
/
Instruction16.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//
// Created by emu on 19/06/06.
//
#include "Emulator.h"
#include "ModRM.h"
instruction_func_t* instructions16[0xffff];
namespace instruction16{
void cli(Emulator *emu){
emu->set_interrupt(false);
emu->EIP++;
}
//========= 16bit mode in 32 bit mode=================================
void mov_r8_imm8(Emulator *emu){
uint8_t reg = emu->GetCode8(0) - 0xB0;
emu->reg[reg].reg16 = emu->GetCode8(1);
emu->EIP += 2;
}
void add_rm16_r16(Emulator *emu) {
emu->EIP++;
ModRM modrm(emu);
uint16_t rm16 = modrm.GetR16();
uint16_t r16 = modrm.GetR16();
modrm.SetRM16(rm16 + r16);
emu->update_eflags_add(rm16, r16);
}
void mov_r16_rm32(Emulator *emu){
emu->EIP++;
ModRM modrm(emu);
uint32_t rm16 = modrm.GetRM16();
modrm.SetR16(rm16);
}
void mov_rm16_r16(Emulator *emu){
emu->EIP++;
ModRM modrm(emu);
uint16_t r16 = modrm.GetR16();
modrm.SetRM16(r16);
}
void mov_rm16_sreg(Emulator *emu){
emu->EIP++;
ModRM modrm(emu);
uint16_t sreg = emu->sreg[emu->instr.reg_index].sreg;
modrm.SetRM16(sreg);
}
//=========================================================================================================================================
}
using namespace instruction16;
void InitInstructions16(){
int i;
instruction_func_t** func = instructions16;
// func[0x00] = test;
func[0x1] = add_rm16_r16;
func[0x89] = mov_rm16_r16;
func[0x8B] = mov_r16_rm32;
func[0x8C] = mov_rm16_sreg;
for(i=0;i<8;i++){
func[0xB8 + i] = mov_r8_imm8;
}
func[0xFA] = cli;
}