Debian Codegraph @

tests/data/fdef153.txt

raw
1 FDEF[], 153
2 /* Function 153 takes 1 argument, a "bitfield" flag. */
3 /* VERSION 1.0 20111117 */
4 /*
5 Function 153 is intended to take a set of one or more bits as input and do an AND (e.g. mask) of those
6 bits with the set of flags returned by Function 84. Then determine if ALL
7 of these resultant bits from the mask are set.
8
9 Function 153 returns TRUE if the match is successful, and FALSE if it is not successful.
10
11 If the parameter is zero, indicating no flags, then the function returns FALSE.
12
13 This function takes a maxiumum of 32 flags.
14
15 USES: Storage 2 (FN 84)
16 RETURNS: 0 or 1
17 */
18
19 #BEGIN
20 #PUSHOFF
21 /* Input parameter is a set of one or more flags */
22
23 DUP[]
24 #PUSH, 2 /* Read FN 84 flags */
25 RS[]
26 EQ[] /* If a simple match, return TRUE */
27 #PUSH, 1
28 SWAP[]
29
30 #PUSH, BEcln
31 SWAP[]
32 JROT[], (BEcln=#LEndClear) /* Jump to end and clean up stack. */
33 POP[]
34 #PUSH, 0, 2
35 RS[] /* Read FN 84 flags */
36 #PUSH, BEclr /* If no FN 84 flags, return FALSE */
37 SWAP[]
38
39 JROF[], (BEclr=#LEndClear)
40
41 POP[]
42 #PUSH, 0, 2 /* 0 is the boolean tracking success, start off with FALSE */
43 RS[]
44 ROLL[]
45 #PUSH, 32 /* Maximum number of bits to loop through */
46 /* TopLoop: */
47 #LTopLoop:
48 /* STACK
49 Loop Iteration Count
50 Updated (shifted) Input Value
51 Updated (shifted) FN 84 Flag
52 Conditional boolean tracking success
53 */
54 DUP[]
55 NOT[]
56 IF[] /* Exit the loop when done */
57 POP[]
58 POP[]
59 POP[]
60 #PUSH, BDEnd /* 73 End */
61
62 JMPR[], (BDEnd=#LEndFn)
63
64 EIF[]
65 ROLL[]
66 ROLL[]
67 DUP[]
68 ROLL[]
69 DUP[]
70 ROLL[]
71 SWAP[]
72 /* STACK
73 Updated (shifted) FN 84 Flag
74 Updated (shifted) Input Value
75 Updated (shifted) FN 84 Flag
76 Updated (Shifted) Input Value
77 Loop Interation Count
78 Conditional boolean tracking success
79 */
80
81 /* Check to see if the lower-order bit is set in the FN 84 Flag */
82 #PUSH, 4096 /* Convert to 26.6 by multiply by 64 x 64 */
83 MUL[]
84 ODD[]
85 IF[]
86 /* Check to see if the lower-order bit is set in the Input Value */
87 #PUSH, 4096
88 MUL[]
89 ODD[]
90 IF[]
91 #PUSH, 4
92 MINDEX[]
93 #PUSH, 1 /* Set TRUE return code */
94 OR[] /* We OR this because we will immediately exit if we fail this test */
95 #PUSH, 4
96 MINDEX[]
97 #PUSH, 4
98 MINDEX[]
99 #PUSH, 4
100 MINDEX[]
101 ELSE[]
102 POP[]
103 POP[]
104 POP[]
105 POP[]
106 #PUSH, BTEnd , 0 /* 0 is the FALSE return code */
107 SWAP[]
108 JMPR[], (BTEnd=#LEndFn)
109
110 EIF[]
111 ELSE[]
112 POP[]
113 EIF[]
114 #PUSH, 4 /* Can this be cleaned up and integrated with the code below? */
115 MINDEX[]
116 SWAP[]
117 /* STACK
118 Updated (shifted) FN 84 Flag
119 Conditional boolean tracking success
120 Updated (shifted) Input Value
121 Loop Interation Count
122 */
123 /* Shift both the Input Value and the FN 84 Flag each one bit right */
124 #PUSH, 128 /* 2 in 26.6 */
125 DIV[]
126 DUP[]
127 NOT[]
128 IF[]
129 ROLL[]
130 NOT[]
131 ROLL[]
132 AND[]
133 SWAP[]
134 POP[]
135 SWAP[]
136 POP[]
137 #PUSH, BPEnd /* 29 End */
138
139 JMPR[], (BPEnd=#LEndFn)
140
141 EIF[]
142 ROLL[]
143 #PUSH, 128 /* 2 in 26.6 */
144 DIV[]
145 DUP[]
146 NOT[]
147 IF[]
148 POP[]
149 POP[]
150 SWAP[]
151 POP[]
152 #PUSH, BZEnd /* End */
153
154 JMPR[], (BZEnd=#LEndFn)
155
156 EIF[]
157 #PUSH, 4
158 MINDEX[]
159 #PUSH, 1
160 SUB[]
161 #PUSH, WReLoop /* -77 TopLoop */
162
163 JMPR[], (WReLoop=#LTopLoop)
164
165 /* EndClear: */
166 #LEndClear:
167 SWAP[]
168 POP[]
169 #LEndFn:
170 /* End: */
171 #END
172 #PUSHON
173 ENDF[]