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
75
76
77
78
79
|
use yaxpeax_x86::real_mode::{ConditionCode, Opcode};
#[test]
fn conditional_instructions() {
const JCC: &'static [(Opcode, ConditionCode); 16] = &[
(Opcode::JO, ConditionCode::O),
(Opcode::JNO, ConditionCode::NO),
(Opcode::JB, ConditionCode::B),
(Opcode::JNB, ConditionCode::AE),
(Opcode::JZ, ConditionCode::Z),
(Opcode::JNZ, ConditionCode::NZ),
(Opcode::JA, ConditionCode::A),
(Opcode::JNA, ConditionCode::BE),
(Opcode::JS, ConditionCode::S),
(Opcode::JNS, ConditionCode::NS),
(Opcode::JP, ConditionCode::P),
(Opcode::JNP, ConditionCode::NP),
(Opcode::JL, ConditionCode::L),
(Opcode::JGE, ConditionCode::GE),
(Opcode::JG, ConditionCode::G),
(Opcode::JLE, ConditionCode::LE),
];
for (opc, cond) in JCC.iter() {
assert!(opc.is_jcc());
assert!(!opc.is_setcc());
assert!(!opc.is_cmovcc());
assert_eq!(opc.condition(), Some(*cond));
}
const SETCC: &'static [(Opcode, ConditionCode); 16] = &[
(Opcode::SETO, ConditionCode::O),
(Opcode::SETNO, ConditionCode::NO),
(Opcode::SETB, ConditionCode::B),
(Opcode::SETAE, ConditionCode::AE),
(Opcode::SETZ, ConditionCode::Z),
(Opcode::SETNZ, ConditionCode::NZ),
(Opcode::SETA, ConditionCode::A),
(Opcode::SETBE, ConditionCode::BE),
(Opcode::SETS, ConditionCode::S),
(Opcode::SETNS, ConditionCode::NS),
(Opcode::SETP, ConditionCode::P),
(Opcode::SETNP, ConditionCode::NP),
(Opcode::SETL, ConditionCode::L),
(Opcode::SETGE, ConditionCode::GE),
(Opcode::SETG, ConditionCode::G),
(Opcode::SETLE, ConditionCode::LE),
];
for (opc, cond) in SETCC.iter() {
assert!(!opc.is_jcc());
assert!(opc.is_setcc());
assert!(!opc.is_cmovcc());
assert_eq!(opc.condition(), Some(*cond));
}
const CMOVCC: &'static [(Opcode, ConditionCode); 16] = &[
(Opcode::CMOVO, ConditionCode::O),
(Opcode::CMOVNO, ConditionCode::NO),
(Opcode::CMOVB, ConditionCode::B),
(Opcode::CMOVNB, ConditionCode::AE),
(Opcode::CMOVZ, ConditionCode::Z),
(Opcode::CMOVNZ, ConditionCode::NZ),
(Opcode::CMOVA, ConditionCode::A),
(Opcode::CMOVNA, ConditionCode::BE),
(Opcode::CMOVS, ConditionCode::S),
(Opcode::CMOVNS, ConditionCode::NS),
(Opcode::CMOVP, ConditionCode::P),
(Opcode::CMOVNP, ConditionCode::NP),
(Opcode::CMOVL, ConditionCode::L),
(Opcode::CMOVGE, ConditionCode::GE),
(Opcode::CMOVG, ConditionCode::G),
(Opcode::CMOVLE, ConditionCode::LE),
];
for (opc, cond) in CMOVCC.iter() {
assert!(!opc.is_jcc());
assert!(!opc.is_setcc());
assert!(opc.is_cmovcc());
assert_eq!(opc.condition(), Some(*cond));
}
}
|