mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 23:48:11 +00:00
UserspaceEmulator: Give SoftCPU an API for evaluating jump conditions
There are 16 conditions and they're all based on a combination of the CPU flags.
This commit is contained in:
parent
133803b8a7
commit
12ab46def9
1 changed files with 41 additions and 0 deletions
|
@ -214,6 +214,47 @@ public:
|
|||
void write_memory16(X86::LogicalAddress, u16);
|
||||
void write_memory32(X86::LogicalAddress, u32);
|
||||
|
||||
bool evaluate_condition(u8 condition) const
|
||||
{
|
||||
switch (condition) {
|
||||
case 0:
|
||||
return of(); // O
|
||||
case 1:
|
||||
return !of(); // NO
|
||||
case 2:
|
||||
return cf(); // B, C, NAE
|
||||
case 3:
|
||||
return !cf(); // NB, NC, AE
|
||||
case 4:
|
||||
return zf(); // E, Z
|
||||
case 5:
|
||||
return !zf(); // NE, NZ
|
||||
case 6:
|
||||
return (cf() | zf()); // BE, NA
|
||||
case 7:
|
||||
return !(cf() | zf()); // NBE, A
|
||||
case 8:
|
||||
return sf(); // S
|
||||
case 9:
|
||||
return !sf(); // NS
|
||||
case 10:
|
||||
return pf(); // P, PE
|
||||
case 11:
|
||||
return !pf(); // NP, PO
|
||||
case 12:
|
||||
return sf() ^ of(); // L, NGE
|
||||
case 13:
|
||||
return !(sf() ^ of()); // NL, GE
|
||||
case 14:
|
||||
return (sf() ^ of()) | zf(); // LE, NG
|
||||
case 15:
|
||||
return !((sf() ^ of()) | zf()); // NLE, G
|
||||
default:
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private:
|
||||
virtual void AAA(const X86::Instruction&) override;
|
||||
virtual void AAD(const X86::Instruction&) override;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue