-
Notifications
You must be signed in to change notification settings - Fork 0
/
ops_0x7.cpp
29 lines (25 loc) · 914 Bytes
/
ops_0x7.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
#include "modrm.hpp"
#include "hw/cpu.hpp"
#define DEFINE_NEAR_JX(flag, flag_name) \
void j##flag(Pentium* cpu) \
{ \
int diff = cpu->eflags & flag_name ? cpu->bus->read(cpu->getLinearAddr() + 2) : 0; \
cpu->ip.regs_32 += (diff + 2); \
} \
void jn##flag(Pentium* cpu) \
{ \
int diff = cpu->eflags & flag_name ? 0 : cpu->bus->read(cpu->getLinearAddr() + 2); \
cpu->ip.regs_32 += (diff + 2); \
}
DEFINE_NEAR_JX(z, ZERO_FLAG);
DEFINE_NEAR_JX(o, OVERFLOW_FLAG);
void jge(Pentium* cpu)
{
int diff = ((cpu->eflags & SIGN_FLAG) == (cpu->eflags & OVERFLOW_FLAG)) ? cpu->bus->read(cpu->getLinearAddr() + 1) : 0;
cpu->ip.regs_32 += (diff + 2);
}
void jg(Pentium* cpu)
{
int diff = (!cpu->eflags & ZERO_FLAG && (cpu->eflags & SIGN_FLAG == cpu->eflags & OVERFLOW_FLAG)) ? cpu->bus->read(cpu->getLinearAddr() + 1) : 0;
cpu->ip.regs_32 += (diff + 2);
}