File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package immediates
2+
3+ import "fmt"
4+
5+ type Condition uint32
6+
7+ const (
8+ ConditionEq Condition = iota // Equal
9+ ConditionNe // Not Equal
10+ ConditionCs // Carry Set
11+ ConditionCc // Carry Clear
12+ ConditionMi // Minus/Negative
13+ ConditionPl // Plus/Positive
14+ ConditionVs // Overflow Set
15+ ConditionVc // Overflow Clear
16+ ConditionHi // Higher
17+ ConditionLs // Lower or Same
18+ ConditionGe // Greater than or Equal
19+ ConditionLt // Less Than
20+ ConditionGt // Greater Than
21+ ConditionLe // Less than or Equal
22+ ConditionAl // Always
23+ ConditionNv // Never
24+ )
25+
26+ func (c Condition ) Binary () uint32 {
27+ return uint32 (c )
28+ }
29+
30+ func (c Condition ) Validate () error {
31+ if c <= ConditionNv {
32+ return fmt .Errorf ("Condition %d out of range" , c )
33+ }
34+ return nil
35+ }
36+
37+ func (c Condition ) String () string {
38+ switch c {
39+ case ConditionEq :
40+ return "EQ"
41+ case ConditionNe :
42+ return "NE"
43+ case ConditionCs :
44+ return "CS"
45+ case ConditionCc :
46+ return "CC"
47+ case ConditionMi :
48+ return "MI"
49+ case ConditionPl :
50+ return "PL"
51+ case ConditionVs :
52+ return "VS"
53+ case ConditionVc :
54+ return "VC"
55+ case ConditionHi :
56+ return "HI"
57+ case ConditionLs :
58+ return "LS"
59+ case ConditionGe :
60+ return "GE"
61+ case ConditionLt :
62+ return "LT"
63+ case ConditionGt :
64+ return "GT"
65+ case ConditionLe :
66+ return "LE"
67+ case ConditionAl :
68+ return "AL"
69+ case ConditionNv :
70+ return "NV"
71+ default :
72+ return "??"
73+ }
74+ }
You can’t perform that action at this time.
0 commit comments