Debian Codegraph @

tests/data/fdef152.txt

raw
1 FDEF[], 152
2 /* Function 152 takes 1 argument, a "bitfield" flag. */
3 /* VERSION 1.0 20111117 */
4 /*
5 Function 152 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 there is at least one
7 of these resultant bits that are set.
8
9 Function 152 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 bit 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, 2
43 RS[]
44 SWAP[]
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 */
53 DUP[]
54 NOT[]
55 IF[] /* Exit the loop when done */
56 POP[]
57 POP[]
58 POP[]
59 #PUSH, 0, BDEnd /* 73 End */
60
61 JMPR[], (BDEnd=#LEndFn)
62
63 EIF[]
64 ROLL[]
65 ROLL[]
66 DUP[]
67 ROLL[]
68 DUP[]
69 ROLL[]
70 SWAP[]
71 /* STACK
72 Updated (shifted) FN 84 Flag
73 Updated (shifted) Input Value
74 Updated (shifted) FN 84 Flag
75 Updated (Shifted) Input Value
76 Loop Interation Count
77 */
78
79 /* Check to see if the lower-order bit is set in the FN 84 Flag */
80 #PUSH, 4096 /* Convert to 26.6 by multiply by 64 x 64 */
81 MUL[]
82 ODD[]
83 IF[]
84 /* Check to see if the lower-order bit is set in the Input Value */
85 #PUSH, 4096
86 MUL[]
87 ODD[]
88 IF[]
89 /* We can early out here once we find our first match */
90 POP[]
91 POP[]
92 POP[]
93 #PUSH, 1, BTEnd /* 1 is the TRUE return code */
94 JMPR[], (BTEnd=#LEndFn)
95 EIF[]
96 ELSE[]
97 POP[]
98 EIF[]
99 /* STACK
100 Updated (shifted) FN 84 Flag
101 Updated (shifted) Input Value
102 Loop Interation Count
103 */
104 /* Shift both the Input Value and the FN 84 Flag each one bit right */
105 #PUSH, 128 /* 2 in 26.6 */
106 DIV[]
107 DUP[]
108 NOT[]
109 IF[]
110 POP[]
111 POP[]
112 POP[]
113 #PUSH, 0, BPEnd /* 0 is end condition of FALSE */
114
115 JMPR[], (BPEnd=#LEndFn)
116
117 EIF[]
118 SWAP[]
119 #PUSH, 128 /* 2 in 26.6 */
120 DIV[]
121 DUP[]
122 NOT[]
123 IF[]
124 POP[]
125 POP[]
126 POP[]
127 #PUSH, 0, BZEnd /* End */
128
129 JMPR[], (BZEnd=#LEndFn)
130
131 EIF[]
132 ROLL[]
133 #PUSH, 1
134 SUB[]
135 #PUSH, WReLoop /* -77 TopLoop */
136
137 JMPR[], (WReLoop=#LTopLoop)
138
139 /* EndClear: */
140 #LEndClear:
141 SWAP[]
142 POP[]
143 #LEndFn:
144 /* End: */
145 #END
146 #PUSHON
147 ENDF[]