Debian Codegraph @

src/asm/alu.c

raw symbols SCIP
1 //cxx . . $ `<file>/src/asm/alu.c`/
2 // ACME - a crossassembler for producing 6502/65c02/65816 code.
3 // Copyright (C) 1998-2006 Marco Baye
4 // Have a look at "acme.c" for further info
5 //
6 // Arithmetic/logic unit
7 // 11 Oct 006 Improved float reading in parse_decimal_value()
8
9 #include <stdlib.h>
10 #include <math.h> // only for experimental fp support
11 #include "platform.h"cxx . . $ `<file>/src/asm/platform.h`/ // done first in case "inline" is redefined
12 #include "alu.h"cxx . . $ `<file>/src/asm/alu.h`/
13 #include "cpu.h"cxx . . $ `<file>/src/asm/cpu.h`/
14 #include "dynabuf.h"cxx . . $ `<file>/src/asm/dynabuf.h`/
15 #include "encoding.h"cxx . . $ `<file>/src/asm/encoding.h`/
16 #include "global.h"cxx . . $ `<file>/src/asm/global.h`/
17 #include "input.h"cxx . . $ `<file>/src/asm/input.h`/
18 #include "label.h"cxx . . $ `<file>/src/asm/label.h`/
19 #include "section.h"cxx . . $ `<file>/src/asm/section.h`/
20 #include "tree.h"cxx . . $ `<file>/src/asm/tree.h`/
21
22
23 // Constants
24
25 #define FUNCION_DYNABUF_INITIALSIZEcxx . . $ `src/asm/alu.c:25:9`! 8 // enough for "arctan"
26 #define HALF_INITIAL_STACK_SIZEcxx . . $ `src/asm/alu.c:26:9`! 8
27 static const char exception_div_by_zerocxx . . $ exception_div_by_zero.[] = "Division by zero.";
28 static const char exception_no_valuecxx . . $ exception_no_value.[] = "No value given.";
29 static const char exception_paren_opencxx . . $ exception_paren_open.[] = "Too many '('.";
30 static const char exception_undefinedcxx . . $ exception_undefined.[] = "Value not defined.";
31 #define s_orcxx . . $ `src/asm/alu.c:31:9`! (s_eor+1) // Yes, I know I'm sick
32 #define s_xorcxx . . $ `src/asm/alu.c:32:9`! (s_scrxor+3) // Yes, I know I'm sick
33 static const char s_arcsincxx . . $ s_arcsin.[] = "arcsin";
34 #define s_sincxx . . $ `src/asm/alu.c:34:9`! (s_arcsin+3) // Yes, I know I'm sick
35 static const char s_arccoscxx . . $ s_arccos.[] = "arccos";
36 #define s_coscxx . . $ `src/asm/alu.c:36:9`! (s_arccos+3) // Yes, I know I'm sick
37 static const char s_arctancxx . . $ s_arctan.[] = "arctan";
38 #define s_tancxx . . $ `src/asm/alu.c:38:9`! (s_arctan+3) // Yes, I know I'm sick
39
40 // Operator handles (FIXME - use function pointers instead? or too slow?)
41 enum op_handle_tcxx . . $ op_handle_t# {
42 // special values (pseudo operators)
43 OPHANDLE_ENDcxx . . $ OPHANDLE_END., // "reached end of expression"
44 OPHANDLE_RETURNcxx . . $ OPHANDLE_RETURN., // "return value to caller"
45 // functions
46 OPHANDLE_INTcxx . . $ OPHANDLE_INT., // int(v)
47 OPHANDLE_FLOATcxx . . $ OPHANDLE_FLOAT., // float(v)
48 OPHANDLE_SINcxx . . $ OPHANDLE_SIN., // sin(v)
49 OPHANDLE_COScxx . . $ OPHANDLE_COS., // cos(v)
50 OPHANDLE_TANcxx . . $ OPHANDLE_TAN., // tan(v)
51 OPHANDLE_ARCSINcxx . . $ OPHANDLE_ARCSIN., // arcsin(v)
52 OPHANDLE_ARCCOScxx . . $ OPHANDLE_ARCCOS., // arccos(v)
53 OPHANDLE_ARCTANcxx . . $ OPHANDLE_ARCTAN., // arctan(v)
54 // monadic operators
55 OPHANDLE_OPENINGcxx . . $ OPHANDLE_OPENING., // (v '(', starts subexpression
56 OPHANDLE_NOTcxx . . $ OPHANDLE_NOT., // !v NOT v bit-wise NOT
57 OPHANDLE_NEGATEcxx . . $ OPHANDLE_NEGATE., // -v Negate
58 OPHANDLE_LOWBYTEOFcxx . . $ OPHANDLE_LOWBYTEOF., // <v Lowbyte of
59 OPHANDLE_HIGHBYTEOFcxx . . $ OPHANDLE_HIGHBYTEOF., // >v Highbyte of
60 OPHANDLE_BANKBYTEOFcxx . . $ OPHANDLE_BANKBYTEOF., // ^v Bankbyte of
61 // dyadic operators
62 OPHANDLE_CLOSINGcxx . . $ OPHANDLE_CLOSING., // v) ')', ends subexpression
63 OPHANDLE_POWEROFcxx . . $ OPHANDLE_POWEROF., // v^w
64 OPHANDLE_MULTIPLYcxx . . $ OPHANDLE_MULTIPLY., // v*w
65 OPHANDLE_DIVIDEcxx . . $ OPHANDLE_DIVIDE., // v/w (Integer) Division
66 OPHANDLE_INTDIVcxx . . $ OPHANDLE_INTDIV., // v/w v DIV w Integer Division
67 OPHANDLE_MODULOcxx . . $ OPHANDLE_MODULO., // v%w v MOD w Remainder
68 OPHANDLE_SLcxx . . $ OPHANDLE_SL., // v<<w v ASL w v LSL w Shift left
69 OPHANDLE_ASRcxx . . $ OPHANDLE_ASR., // v>>w v ASR w Arithmetic shift right
70 OPHANDLE_LSRcxx . . $ OPHANDLE_LSR., // v>>>w v LSR w Logical shift right
71 OPHANDLE_ADDcxx . . $ OPHANDLE_ADD., // v+w
72 OPHANDLE_SUBTRACTcxx . . $ OPHANDLE_SUBTRACT., // v-w
73 OPHANDLE_EQUALScxx . . $ OPHANDLE_EQUALS., // v=w
74 OPHANDLE_LEcxx . . $ OPHANDLE_LE., // v<=w
75 OPHANDLE_LESSTHANcxx . . $ OPHANDLE_LESSTHAN., // v< w
76 OPHANDLE_GEcxx . . $ OPHANDLE_GE., // v>=w
77 OPHANDLE_GREATERTHANcxx . . $ OPHANDLE_GREATERTHAN., // v> w
78 OPHANDLE_NOTEQUALcxx . . $ OPHANDLE_NOTEQUAL., // v!=w v<>w v><w
79 OPHANDLE_ANDcxx . . $ OPHANDLE_AND., // v&w v AND w
80 OPHANDLE_ORcxx . . $ OPHANDLE_OR., // v|w v OR w
81 OPHANDLE_EORcxx . . $ OPHANDLE_EOR., // v EOR w v XOR w (remove)
82 OPHANDLE_XORcxx . . $ OPHANDLE_XOR., // v XOR w
83 };
84 struct operator_tcxx . . $ operator_t# {
85 enum op_handle_tcxx . . $ op_handle_t# handlecxx . . $ operator_t#handle.;
86 int prioritycxx . . $ operator_t#priority.;
87 };
88 typedef struct operator_tcxx . . $ operator_t# op_tcxx . . $ op_t#;
89
90 // operator structs (only hold handle and priority value)
91 static op_tcxx . . $ op_t# ops_endcxx . . $ ops_end. = {OPHANDLE_ENDcxx . . $ OPHANDLE_END., 0}; // special
92 static op_tcxx . . $ op_t# ops_returncxx . . $ ops_return. = {OPHANDLE_RETURNcxx . . $ OPHANDLE_RETURN., 1}; // special
93 static op_tcxx . . $ op_t# ops_closingcxx . . $ ops_closing. = {OPHANDLE_CLOSINGcxx . . $ OPHANDLE_CLOSING., 2}; // dyadic
94 static op_tcxx . . $ op_t# ops_openingcxx . . $ ops_opening. = {OPHANDLE_OPENINGcxx . . $ OPHANDLE_OPENING., 3}; // monadic
95 static op_tcxx . . $ op_t# ops_orcxx . . $ ops_or. = {OPHANDLE_ORcxx . . $ OPHANDLE_OR., 4}; // dyadic
96 static op_tcxx . . $ op_t# ops_eorcxx . . $ ops_eor. = {OPHANDLE_EORcxx . . $ OPHANDLE_EOR., 5}; // (remove)
97 static op_tcxx . . $ op_t# ops_xorcxx . . $ ops_xor. = {OPHANDLE_XORcxx . . $ OPHANDLE_XOR., 5}; // dyadic
98 static op_tcxx . . $ op_t# ops_andcxx . . $ ops_and. = {OPHANDLE_ANDcxx . . $ OPHANDLE_AND., 6}; // dyadic
99 static op_tcxx . . $ op_t# ops_equalscxx . . $ ops_equals. = {OPHANDLE_EQUALScxx . . $ OPHANDLE_EQUALS., 7}; // dyadic
100 static op_tcxx . . $ op_t# ops_notequalcxx . . $ ops_notequal. = {OPHANDLE_NOTEQUALcxx . . $ OPHANDLE_NOTEQUAL., 8}; // dyadic
101 // same priority for all comparison operators
102 static op_tcxx . . $ op_t# ops_lecxx . . $ ops_le. = {OPHANDLE_LEcxx . . $ OPHANDLE_LE., 9}; // dyadic
103 static op_tcxx . . $ op_t# ops_lessthancxx . . $ ops_lessthan. = {OPHANDLE_LESSTHANcxx . . $ OPHANDLE_LESSTHAN., 9}; // dyadic
104 static op_tcxx . . $ op_t# ops_gecxx . . $ ops_ge. = {OPHANDLE_GEcxx . . $ OPHANDLE_GE., 9}; // dyadic
105 static op_tcxx . . $ op_t# ops_greaterthancxx . . $ ops_greaterthan. = {OPHANDLE_GREATERTHANcxx . . $ OPHANDLE_GREATERTHAN., 9}; // dyadic
106 // same priority for all byte extraction operators
107 static op_tcxx . . $ op_t# ops_lowbyteofcxx . . $ ops_lowbyteof. = {OPHANDLE_LOWBYTEOFcxx . . $ OPHANDLE_LOWBYTEOF., 10}; // monadic
108 static op_tcxx . . $ op_t# ops_highbyteofcxx . . $ ops_highbyteof. = {OPHANDLE_HIGHBYTEOFcxx . . $ OPHANDLE_HIGHBYTEOF., 10}; // monadic
109 static op_tcxx . . $ op_t# ops_bankbyteofcxx . . $ ops_bankbyteof. = {OPHANDLE_BANKBYTEOFcxx . . $ OPHANDLE_BANKBYTEOF., 10}; // monadic
110 // same priority for all shift operators
111 static op_tcxx . . $ op_t# ops_slcxx . . $ ops_sl. = {OPHANDLE_SLcxx . . $ OPHANDLE_SL., 11}; // dyadic
112 static op_tcxx . . $ op_t# ops_asrcxx . . $ ops_asr. = {OPHANDLE_ASRcxx . . $ OPHANDLE_ASR., 11}; // dyadic
113 static op_tcxx . . $ op_t# ops_lsrcxx . . $ ops_lsr. = {OPHANDLE_LSRcxx . . $ OPHANDLE_LSR., 11}; // dyadic
114 // same priority for "+" and "-"
115 static op_tcxx . . $ op_t# ops_addcxx . . $ ops_add. = {OPHANDLE_ADDcxx . . $ OPHANDLE_ADD., 12}; // dyadic
116 static op_tcxx . . $ op_t# ops_subtractcxx . . $ ops_subtract. = {OPHANDLE_SUBTRACTcxx . . $ OPHANDLE_SUBTRACT., 12}; // dyadic
117 // same priority for "*", "/" and "%"
118 static op_tcxx . . $ op_t# ops_multiplycxx . . $ ops_multiply. = {OPHANDLE_MULTIPLYcxx . . $ OPHANDLE_MULTIPLY., 13}; // dyadic
119 static op_tcxx . . $ op_t# ops_dividecxx . . $ ops_divide. = {OPHANDLE_DIVIDEcxx . . $ OPHANDLE_DIVIDE., 13}; // dyadic
120 static op_tcxx . . $ op_t# ops_intdivcxx . . $ ops_intdiv. = {OPHANDLE_INTDIVcxx . . $ OPHANDLE_INTDIV., 13}; // dyadic
121 static op_tcxx . . $ op_t# ops_modulocxx . . $ ops_modulo. = {OPHANDLE_MODULOcxx . . $ OPHANDLE_MODULO., 13}; // dyadic
122 // highest "real" priorities
123 static op_tcxx . . $ op_t# ops_negatecxx . . $ ops_negate. = {OPHANDLE_NEGATEcxx . . $ OPHANDLE_NEGATE., 14}; // monadic
124 static op_tcxx . . $ op_t# ops_powerofcxx . . $ ops_powerof. = {OPHANDLE_POWEROFcxx . . $ OPHANDLE_POWEROF., 15}; // dyadic
125 static op_tcxx . . $ op_t# ops_notcxx . . $ ops_not. = {OPHANDLE_NOTcxx . . $ OPHANDLE_NOT., 16}; // monadic
126 // function calls act as if they were monadic operators
127 static op_tcxx . . $ op_t# ops_intcxx . . $ ops_int. = {OPHANDLE_INTcxx . . $ OPHANDLE_INT., 17}; // function
128 static op_tcxx . . $ op_t# ops_floatcxx . . $ ops_float. = {OPHANDLE_FLOATcxx . . $ OPHANDLE_FLOAT., 17}; // function
129 static op_tcxx . . $ op_t# ops_sincxx . . $ ops_sin. = {OPHANDLE_SINcxx . . $ OPHANDLE_SIN., 17}; // function
130 static op_tcxx . . $ op_t# ops_coscxx . . $ ops_cos. = {OPHANDLE_COScxx . . $ OPHANDLE_COS., 17}; // function
131 static op_tcxx . . $ op_t# ops_tancxx . . $ ops_tan. = {OPHANDLE_TANcxx . . $ OPHANDLE_TAN., 17}; // function
132 static op_tcxx . . $ op_t# ops_arcsincxx . . $ ops_arcsin. = {OPHANDLE_ARCSINcxx . . $ OPHANDLE_ARCSIN., 17}; // function
133 static op_tcxx . . $ op_t# ops_arccoscxx . . $ ops_arccos. = {OPHANDLE_ARCCOScxx . . $ OPHANDLE_ARCCOS., 17}; // function
134 static op_tcxx . . $ op_t# ops_arctancxx . . $ ops_arctan. = {OPHANDLE_ARCTANcxx . . $ OPHANDLE_ARCTAN., 17}; // function
135
136
137 // Variables
138
139 static dynabuf_tcxx . . $ dynabuf_t#* function_dyna_bufcxx . . $ function_dyna_buf.; // dynamic buffer for fn names
140 static op_tcxx . . $ op_t#** operator_stackcxx . . $ operator_stack. = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!;
141 static int operator_stk_sizecxx . . $ operator_stk_size. = HALF_INITIAL_STACK_SIZEcxx . . $ `src/asm/alu.c:26:9`!;
142 static int operator_spcxx . . $ operator_sp.; // operator stack pointer
143 static struct result_tcxx . . $ result_t#* operand_stackcxx . . $ operand_stack. = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!; // flags and value
144 static int operand_stk_sizecxx . . $ operand_stk_size. = HALF_INITIAL_STACK_SIZEcxx . . $ `src/asm/alu.c:26:9`!;
145 static int operand_spcxx . . $ operand_sp.; // value stack pointer
146 static int indirect_flagcxx . . $ indirect_flag.; // Flag for indirect addressing
147 // (indicated by useless parentheses)
148 // Contains either 0 or MVALUE_INDIRECT
149 enum alu_state_tcxx . . $ alu_state_t# {
150 STATE_EXPECT_OPERAND_OR_MONADIC_OPERATORcxx . . $ STATE_EXPECT_OPERAND_OR_MONADIC_OPERATOR.,
151 STATE_EXPECT_DYADIC_OPERATORcxx . . $ STATE_EXPECT_DYADIC_OPERATOR.,
152 STATE_TRY_TO_REDUCE_STACKScxx . . $ STATE_TRY_TO_REDUCE_STACKS.,
153 STATE_MAX_GO_ONcxx . . $ STATE_MAX_GO_ON., // "border value" to find the stoppers:
154 STATE_ERRORcxx . . $ STATE_ERROR., // error has occured
155 STATE_ENDcxx . . $ STATE_END., // standard end
156 };
157 static enum alu_state_tcxx . . $ alu_state_t# alu_statecxx . . $ alu_state.; // deterministic finite automaton
158 // predefined stuff
159 static node_tcxx . . $ node_t#* operator_treecxx . . $ operator_tree. = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!;// tree to hold operators
160 static node_tcxx . . $ node_t# operator_listcxx . . $ operator_list.[] = {
161 PREDEFNODEcxx . . $ `src/asm/tree.h:15:9`!(s_asr, &ops_asr),
162 PREDEFNODEcxx . . $ `src/asm/tree.h:15:9`!(s_lsr, &ops_lsr),
163 PREDEFNODEcxx . . $ `src/asm/tree.h:15:9`!(s_asl, &ops_sl),
164 PREDEFNODEcxx . . $ `src/asm/tree.h:15:9`!("lsl", &ops_sl),
165 PREDEFNODEcxx . . $ `src/asm/tree.h:15:9`!("div", &ops_intdiv),
166 PREDEFNODEcxx . . $ `src/asm/tree.h:15:9`!("mod", &ops_modulo),
167 PREDEFNODEcxx . . $ `src/asm/tree.h:15:9`!(s_and, &ops_and),
168 PREDEFNODEcxx . . $ `src/asm/tree.h:15:9`!(s_orcxx . . $ `src/asm/alu.c:31:9`!, &ops_or),
169 PREDEFNODEcxx . . $ `src/asm/tree.h:15:9`!(s_eor, &ops_eor), // remove sometime
170 PREDEFLASTcxx . . $ `src/asm/tree.h:16:9`!(s_xorcxx . . $ `src/asm/alu.c:32:9`!, &ops_xor),
171 // ^^^^ this marks the last element
172 };
173 static node_tcxx . . $ node_t#* function_treecxx . . $ function_tree. = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!;// tree to hold functions
174 static node_tcxx . . $ node_t# function_listcxx . . $ function_list.[] = {
175 PREDEFNODEcxx . . $ `src/asm/tree.h:15:9`!("int", &ops_int),
176 PREDEFNODEcxx . . $ `src/asm/tree.h:15:9`!("float", &ops_float),
177 PREDEFNODEcxx . . $ `src/asm/tree.h:15:9`!(s_arcsin, &ops_arcsin),
178 PREDEFNODEcxx . . $ `src/asm/tree.h:15:9`!(s_arccos, &ops_arccos),
179 PREDEFNODEcxx . . $ `src/asm/tree.h:15:9`!(s_arctan, &ops_arctan),
180 PREDEFNODEcxx . . $ `src/asm/tree.h:15:9`!(s_sincxx . . $ `src/asm/alu.c:34:9`!, &ops_sin),
181 PREDEFNODEcxx . . $ `src/asm/tree.h:15:9`!(s_coscxx . . $ `src/asm/alu.c:36:9`!, &ops_cos),
182 PREDEFLASTcxx . . $ `src/asm/tree.h:16:9`!(s_tancxx . . $ `src/asm/alu.c:38:9`!, &ops_tan),
183 // ^^^^ this marks the last element
184 };
185
186 #define LEFT_FLAGScxx . . $ `src/asm/alu.c:186:9`! (operand_stack[operand_sp-2].flags)
187 #define RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! (operand_stack[operand_sp-1].flags)
188 #define LEFT_INTVALcxx . . $ `src/asm/alu.c:188:9`! (operand_stack[operand_sp-2].val.intval)
189 #define RIGHT_INTVALcxx . . $ `src/asm/alu.c:189:9`! (operand_stack[operand_sp-1].val.intval)
190 #define LEFT_FPVALcxx . . $ `src/asm/alu.c:190:9`! (operand_stack[operand_sp-2].val.fpval)
191 #define RIGHT_FPVALcxx . . $ `src/asm/alu.c:191:9`! (operand_stack[operand_sp-1].val.fpval)
192
193 #define PUSH_OPERATORcxx . . $ `src/asm/alu.c:193:9`!(x) operator_stack[operator_sp++] = (x)
194
195 #define PUSH_INTOPERANDcxx . . $ `src/asm/alu.c:195:9`!(i, f) do {\
196 operand_stack[operand_sp].flags = (f);\
197 operand_stack[operand_sp++].val.intval = (i);\
198 } while(0)
199 #define PUSH_FPOPERANDcxx . . $ `src/asm/alu.c:199:9`!(fp, f) do {\
200 operand_stack[operand_sp].flags = (f) | MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!;\
201 operand_stack[operand_sp++].val.fpval = (fp);\
202 } while(0)
203
204
205 // Functions
206
207 // Handle "NeedValue" type errors: problems that may be solved by performing
208 // further passes. This function only counts, it will not show the errors to
209 // the user.
210 static void just_countcxx . . $ just_count(49f6e7a06ebc5aa8).(void) {
211 pass_undefined_countcxx . . $ pass_undefined_count.++;
212 }
213
214 // Handle "NeedValue" type errors: problems that may be solved by performing
215 // further passes. This function counts these errors and shows them to the user.
216 static void count_and_throwcxx . . $ count_and_throw(49f6e7a06ebc5aa8).(void) {
217 pass_undefined_countcxx . . $ pass_undefined_count.++;
218 Throw_errorcxx . . $ Throw_error(85c52e162fed56f9).(exception_undefinedcxx . . $ exception_undefined.);
219 }
220
221 // Function pointer for "result is undefined" type errors.
222 static void (*result_is_undefinedcxx . . $ result_is_undefined.)(void) = just_countcxx . . $ just_count(49f6e7a06ebc5aa8).;
223
224 // Activate error output for "value undefined"
225 void ALU_throw_errorscxx . . $ ALU_throw_errors(49f6e7a06ebc5aa8).(void) {
226 result_is_undefinedcxx . . $ result_is_undefined. = count_and_throwcxx . . $ count_and_throw(49f6e7a06ebc5aa8).;
227 }
228
229 // Enlarge operator stack
230 static void enlarge_operator_stackcxx . . $ enlarge_operator_stack(49f6e7a06ebc5aa8).(void) {
231 operator_stk_sizecxx . . $ operator_stk_size. *= 2;
232 operator_stackcxx . . $ operator_stack. =
233 realloccxx . . $ realloc(417ab160f6baadc6).(operator_stackcxx . . $ operator_stack., operator_stk_sizecxx . . $ operator_stk_size. * sizeof(op_tcxx . . $ op_t#*));
234 if(operator_stackcxx . . $ operator_stack. == NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!)
235 Throw_serious_errorcxx . . $ Throw_serious_error(85c52e162fed56f9).(exception_no_memory_leftcxx . . $ exception_no_memory_left.);
236 }
237
238 // Enlarge operand stack
239 static void enlarge_operand_stackcxx . . $ enlarge_operand_stack(49f6e7a06ebc5aa8).(void) {
240 operand_stk_sizecxx . . $ operand_stk_size. *= 2;
241 operand_stackcxx . . $ operand_stack. =
242 realloccxx . . $ realloc(417ab160f6baadc6).(operand_stackcxx . . $ operand_stack., operand_stk_sizecxx . . $ operand_stk_size. * sizeof(struct result_tcxx . . $ result_t#));
243 if(operand_stackcxx . . $ operand_stack. == NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!)
244 Throw_serious_errorcxx . . $ Throw_serious_error(85c52e162fed56f9).(exception_no_memory_leftcxx . . $ exception_no_memory_left.);
245 }
246
247 // create dynamic buffer, operator/function trees and operator/operand stacks
248 void ALU_initcxx . . $ ALU_init(49f6e7a06ebc5aa8).(void) {
249 function_dyna_bufcxx . . $ function_dyna_buf. = DynaBuf_createcxx . . $ DynaBuf_create(139370366a5bf8f7).(FUNCION_DYNABUF_INITIALSIZEcxx . . $ `src/asm/alu.c:25:9`!);
250 Tree_add_tablecxx . . $ Tree_add_table(90ba9e887489f1c).(&operator_treecxx . . $ operator_tree., operator_listcxx . . $ operator_list.);
251 Tree_add_tablecxx . . $ Tree_add_table(90ba9e887489f1c).(&function_treecxx . . $ function_tree., function_listcxx . . $ function_list.);
252 enlarge_operator_stackcxx . . $ enlarge_operator_stack(49f6e7a06ebc5aa8).();
253 enlarge_operand_stackcxx . . $ enlarge_operand_stack(49f6e7a06ebc5aa8).();
254 }
255
256 // not-so-braindead algorithm for calculating "to the power of" function for
257 // integer operands.
258 // my_pow(whatever, 0) returns 1. my_pow(0, whatever_but_zero) returns 0.
259 static inline intval_tcxx . . $ intval_t# my_powcxx . . $ my_pow(d0a0e4c270da0eca).(intval_tcxx . . $ intval_t# mantissa, intval_tcxx . . $ intval_t# exponent) {
260 intval_tcxx . . $ intval_t# result = 1;
261
262 while(exponent) {
263 // handle exponent's lowmost bit
264 if(exponent & 1)
265 result *= mantissa;
266 // square the mantissa, halve the exponent
267 mantissa *= mantissa;
268 exponent >>= 1;
269 }
270 return(result);
271 }
272
273 // arithmetic shift right (works even if C compiler does not support it)
274 static inline intval_tcxx . . $ intval_t# my_asrcxx . . $ my_asr(d0a0e4c270da0eca).(intval_tcxx . . $ intval_t# left, intval_tcxx . . $ intval_t# right) {
275 intval_tcxx . . $ intval_t# result = left >> right; // perform shift right
276
277 // if left operand >= 0, then ASR and LSR are equivalent, so ok
278 // if result < 0, then ASR has been performed, so ok
279 if((left >= 0) || (result < 0))
280 return(result);
281 // otherwise, correct result and return that
282 return(result | (-1L << (8 * sizeof(intval_tcxx . . $ intval_t#) - right)));
283 }
284
285 // Lookup (and create, if necessary) label tree item and return its value.
286 // DynaBuf holds the label's name and "zone" its zone.
287 // This function is not allowed to change DynaBuf because that's where the
288 // label name is stored!
289 static void get_label_valuecxx . . $ get_label_value(cb2f890c2fdad230).(zone_tcxx . . $ zone_t# zone) {
290 label_tcxx . . $ label_t#* label;
291
292 // If the label gets created now, mark it as unsure
293 label = Label_findcxx . . $ Label_find(dc7499a14ef462f5).(zone, MVALUE_UNSUREcxx . . $ `src/asm/alu.h:22:9`!);
294 // in first pass, count usage
295 if(pass_countcxx . . $ pass_count. == 0)
296 label->usagecxx . . $ label_t#usage.++;
297 // push operand, regardless of whether int or float
298 operand_stackcxx . . $ operand_stack.[operand_spcxx . . $ operand_sp.] = label->resultcxx . . $ label_t#result.;
299 operand_stackcxx . . $ operand_stack.[operand_spcxx . . $ operand_sp.++].flagscxx . . $ result_t#flags. |= MVALUE_EXISTScxx . . $ `src/asm/alu.h:20:9`!;
300 }
301
302 // Parse quoted character.
303 // The character will be converted using the current encoding.
304 static inline void parse_quoted_charactercxx . . $ parse_quoted_character(44b6ea1973a07080).(char closing_quote) {
305 intval_tcxx . . $ intval_t# value;
306
307 // read character to parse - make sure not at end of statement
308 if(GetQuotedBytecxx . . $ GetQuotedByte(6e9c618e4dd2eafc).() == CHAR_EOScxx . . $ `src/asm/input.h:48:9`!)
309 return;
310 // on empty string, complain
311 if(GotBytecxx . . $ GotByte. == closing_quote) {
312 Throw_errorcxx . . $ Throw_error(85c52e162fed56f9).(exception_missing_stringcxx . . $ exception_missing_string.);
313 Input_skip_remaindercxx . . $ Input_skip_remainder(49f6e7a06ebc5aa8).();
314 return;
315 }
316 // parse character
317 value = (intval_tcxx . . $ intval_t#) Encoding_encode_charcxx . . $ Encoding_encode_char.(GotBytecxx . . $ GotByte.);
318 // Read closing quote (hopefully)
319 if(GetQuotedBytecxx . . $ GetQuotedByte(6e9c618e4dd2eafc).() == closing_quote)
320 GetBytecxx . . $ GetByte(6e9c618e4dd2eafc).();// If length == 1, proceed with next byte
321 else
322 if(GotBytecxx . . $ GotByte.) {
323 // If longer than one character
324 Throw_errorcxx . . $ Throw_error(85c52e162fed56f9).("There's more than one character.");
325 Input_skip_remaindercxx . . $ Input_skip_remainder(49f6e7a06ebc5aa8).();
326 }
327 PUSH_INTOPERANDcxx . . $ `src/asm/alu.c:195:9`!(value, MVALUE_GIVENcxx . . $ `src/asm/alu.h:38:9`! | MVALUE_ISBYTEcxx . . $ `src/asm/alu.h:29:9`!);
328 // Now GotByte = char following closing quote (or CHAR_EOS on error)
329 }
330
331 // Parse hexadecimal value. It accepts "0" to "9", "a" to "f" and "A" to "F".
332 // Capital letters will be converted to lowercase letters using the flagtable.
333 // The current value is stored as soon as a character is read that is none of
334 // those given above.
335 static void parse_hexadecimal_valuecxx . . $ parse_hexadecimal_value(49f6e7a06ebc5aa8).(void) {// Now GotByte = "$" or "x"
336 char byte;
337 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! go_on; // continue loop flag
338 int digits = -1, // digit counter
339 flags = MVALUE_GIVENcxx . . $ `src/asm/alu.h:38:9`!;
340 intval_tcxx . . $ intval_t# value = 0;
341
342 do {
343 digits++;
344 go_on = FALSEcxx . . $ `src/asm/config.h:54:9`!;
345 byte = GetBytecxx . . $ GetByte(6e9c618e4dd2eafc).();
346 // first, convert "A-F" to "a-f"
347 byte |= (BYTEFLAGScxx . . $ `src/asm/global.h:42:9`!(byte) & BYTEIS_UPCASEcxx . . $ `src/asm/global.h:45:9`!);
348 // if digit, add digit value
349 if((byte >= '0') && (byte <= '9')) {
350 value = (value << 4) + (byte - '0');
351 go_on = TRUEcxx . . $ `src/asm/config.h:55:9`!;// keep going
352 }
353 // if legal ("a-f") character, add character value
354 if((byte >= 'a') && (byte <= 'f')) {
355 value = (value << 4) + (byte - 'a') + 10;
356 go_on = TRUEcxx . . $ `src/asm/config.h:55:9`!;// keep going
357 }
358 } while(go_on);
359 // set force bits
360 if(digits > 2) {
361 if(digits > 4) {
362 if(value < 65536)
363 flags |= MVALUE_FORCE24cxx . . $ `src/asm/alu.h:31:9`!;
364 } else {
365 if(value < 256)
366 flags |= MVALUE_FORCE16cxx . . $ `src/asm/alu.h:33:9`!;
367 }
368 }
369 PUSH_INTOPERANDcxx . . $ `src/asm/alu.c:195:9`!(value, flags);
370 // Now GotByte = non-hexadecimal char
371 }
372
373 // Parse a decimal value. As decimal values don't use any prefixes, this
374 // function expects the first digit to be read already. If the first two digits
375 // are "0x", this function branches to the one for parsing hexadecimal values.
376 // This function accepts '0' through '9' and one dot ('.') as the decimal
377 // point. The current value is stored as soon as a character is read that is
378 // none of those given above. Float usage is only activated when a decimal
379 // point has been found, so don't expect "100000000000000000000" to work.
380 static inline void parse_decimal_valuecxx . . $ parse_decimal_value(49f6e7a06ebc5aa8).(void) {// Now GotByte = first digit
381 double fpval,
382 denominator;
383 intval_tcxx . . $ intval_t# intval = (GotBytecxx . . $ GotByte. & 15);// this works. it's ASCII.
384
385 GetBytecxx . . $ GetByte(6e9c618e4dd2eafc).();
386 if((intval == 0) && (GotBytecxx . . $ GotByte. == 'x'))
387 return(parse_hexadecimal_valuecxx . . $ parse_hexadecimal_value(49f6e7a06ebc5aa8).());
388 // parse digits until no more
389 while((GotBytecxx . . $ GotByte. >= '0') && (GotBytecxx . . $ GotByte. <= '9')) {
390 intval *= 10;
391 intval += (GotBytecxx . . $ GotByte. & 15);// this works. it's ASCII.
392 GetBytecxx . . $ GetByte(6e9c618e4dd2eafc).();
393 }
394 // check whether it's a float
395 if(GotBytecxx . . $ GotByte. == '.') {
396 // read fractional part and store as fp value
397 GetBytecxx . . $ GetByte(6e9c618e4dd2eafc).();
398 fpval = intval;
399 denominator = 1;
400 // parse digits until no more
401 while((GotBytecxx . . $ GotByte. >= '0') && (GotBytecxx . . $ GotByte. <= '9')) {
402 fpval *= 10;
403 fpval += (GotBytecxx . . $ GotByte. & 15);// this works. it' ASCII.
404 denominator *= 10;
405 GetBytecxx . . $ GetByte(6e9c618e4dd2eafc).();
406 }
407 fpval /= denominator;
408 PUSH_FPOPERANDcxx . . $ `src/asm/alu.c:199:9`!(fpval, MVALUE_GIVENcxx . . $ `src/asm/alu.h:38:9`!);
409 } else {
410 // integer
411 PUSH_INTOPERANDcxx . . $ `src/asm/alu.c:195:9`!(intval, MVALUE_GIVENcxx . . $ `src/asm/alu.h:38:9`!);
412 }
413 // Now GotByte = non-decimal char
414 }
415
416 // Parse octal value. It accepts "0" to "7". The current value is stored as
417 // soon as a character is read that is none of those given above.
418 static inline void parse_octal_valuecxx . . $ parse_octal_value(49f6e7a06ebc5aa8).(void) {// Now GotByte = "&"
419 intval_tcxx . . $ intval_t# value = 0;
420 int flags = MVALUE_GIVENcxx . . $ `src/asm/alu.h:38:9`!,
421 digits = 0; // digit counter
422
423 GetBytecxx . . $ GetByte(6e9c618e4dd2eafc).();
424 while((GotBytecxx . . $ GotByte. >= '0') && (GotBytecxx . . $ GotByte. <= '7')) {
425 value = (value << 3) + (GotBytecxx . . $ GotByte. & 7);// this works. it's ASCII.
426 digits++;
427 GetBytecxx . . $ GetByte(6e9c618e4dd2eafc).();
428 }
429 // set force bits
430 if(digits > 3) {
431 if(digits > 6) {
432 if(value < 65536)
433 flags |= MVALUE_FORCE24cxx . . $ `src/asm/alu.h:31:9`!;
434 } else {
435 if(value < 256)
436 flags |= MVALUE_FORCE16cxx . . $ `src/asm/alu.h:33:9`!;
437 }
438 }
439 PUSH_INTOPERANDcxx . . $ `src/asm/alu.c:195:9`!(value, flags);
440 // Now GotByte = non-octal char
441 }
442
443 // Parse binary value. Apart from '0' and '1', it also accepts the characters
444 // '.' and '#', this is much more readable. The current value is stored as soon
445 // as a character is read that is none of those given above.
446 static inline void parse_binary_valuecxx . . $ parse_binary_value(49f6e7a06ebc5aa8).(void) {// Now GotByte = "%"
447 intval_tcxx . . $ intval_t# value = 0;
448 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! go_on = TRUEcxx . . $ `src/asm/config.h:55:9`!; // continue loop flag
449 int flags = MVALUE_GIVENcxx . . $ `src/asm/alu.h:38:9`!,
450 digits = -1; // digit counter
451
452 do {
453 digits++;
454 switch(GetBytecxx . . $ GetByte(6e9c618e4dd2eafc).()) {
455
456 case '0':
457 case '.':
458 value <<= 1;
459 break;
460
461 case '1':
462 case '#':
463 value = (value << 1) | 1;
464 break;
465
466 default:
467 go_on = FALSEcxx . . $ `src/asm/config.h:54:9`!;
468 }
469 } while(go_on);
470 // set force bits
471 if(digits > 8) {
472 if(digits > 16) {
473 if(value < 65536)
474 flags |= MVALUE_FORCE24cxx . . $ `src/asm/alu.h:31:9`!;
475 } else {
476 if(value < 256)
477 flags |= MVALUE_FORCE16cxx . . $ `src/asm/alu.h:33:9`!;
478 }
479 }
480 PUSH_INTOPERANDcxx . . $ `src/asm/alu.c:195:9`!(value, flags);
481 // Now GotByte = non-binary char
482 }
483
484 // Parse function call (sin(), cos(), arctan(), ...)
485 static inline void parse_function_callcxx . . $ parse_function_call(49f6e7a06ebc5aa8).(void) {
486 void* node_body;
487
488 // make lower case version of name in local dynamic buffer
489 DynaBuf_to_lowercxx . . $ DynaBuf_to_lower(a0224c2fdd28a46d).(function_dyna_bufcxx . . $ function_dyna_buf., GlobalDynaBufcxx . . $ GlobalDynaBuf.);
490 // search for tree item
491 if(Tree_easy_scancxx . . $ Tree_easy_scan(7f10be3e8224db50).(function_treecxx . . $ function_tree., &node_body, function_dyna_bufcxx . . $ function_dyna_buf.))
492 PUSH_OPERATORcxx . . $ `src/asm/alu.c:193:9`!((op_t*) node_body);
493 else
494 Throw_errorcxx . . $ Throw_error(85c52e162fed56f9).("Unknown function.");
495 }
496
497 // Expect operand or monadic operator (hopefully inlined)
498 static inline void expect_operand_or_monadic_operatorcxx . . $ expect_operand_or_monadic_operator(49f6e7a06ebc5aa8).(void) {
499 op_tcxx . . $ op_t#* operator;
500 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! perform_negation;
501
502 SKIPSPACEcxx . . $ `src/asm/global.h:75:9`!();
503 switch(GotBytecxx . . $ GotByte.) {
504
505 case '+':// anonymous forward label
506 // count plus signs to build name of anonymous label
507 DYNABUF_CLEARcxx . . $ `src/asm/dynabuf.h:14:9`!(GlobalDynaBuf);
508 do
509 DYNABUF_APPENDcxx . . $ `src/asm/dynabuf.h:15:9`!(GlobalDynaBuf, '+');
510 while(GetBytecxx . . $ GetByte(6e9c618e4dd2eafc).() == '+');
511 Label_fix_forward_namecxx . . $ Label_fix_forward_name(ff90e8cf7a39c739).();
512 get_label_valuecxx . . $ get_label_value(cb2f890c2fdad230).(Section_nowcxx . . $ Section_now.->zonecxx . . $ $anonymous_type_4270326a5ce8d2d2_0#zone.);
513 goto now_expect_dyadic;
514
515 case '-':// NEGATION operator or anonymous backward label
516 // count minus signs in case it's an anonymous backward label
517 perform_negation = FALSEcxx . . $ `src/asm/config.h:54:9`!;
518 DYNABUF_CLEARcxx . . $ `src/asm/dynabuf.h:14:9`!(GlobalDynaBuf);
519 do {
520 DYNABUF_APPENDcxx . . $ `src/asm/dynabuf.h:15:9`!(GlobalDynaBuf, '-');
521 perform_negation = !perform_negation;
522 } while(GetBytecxx . . $ GetByte(6e9c618e4dd2eafc).() == '-');
523 SKIPSPACEcxx . . $ `src/asm/global.h:75:9`!();
524 if(BYTEFLAGScxx . . $ `src/asm/global.h:42:9`!(GotByte) & FOLLOWS_ANONcxx . . $ `src/asm/global.h:48:9`!) {
525 DynaBuf_appendcxx . . $ DynaBuf_append(11d1e1bb7092144).(GlobalDynaBufcxx . . $ GlobalDynaBuf., '\0');
526 get_label_valuecxx . . $ get_label_value(cb2f890c2fdad230).(Section_nowcxx . . $ Section_now.->zonecxx . . $ $anonymous_type_4270326a5ce8d2d2_0#zone.);
527 goto now_expect_dyadic;
528 } // goto means we don't need an "else {" here
529 if(perform_negation)
530 PUSH_OPERATORcxx . . $ `src/asm/alu.c:193:9`!(&ops_negate);
531 // State doesn't change
532 break;
533
534 // Real monadic operators (state doesn't change, still ExpectMonadic)
535
536 case '!':// NOT operator
537 operator = &ops_notcxx . . $ ops_not.;
538 goto get_byte_and_push_monadic;
539
540 case '<':// LOWBYTE operator
541 operator = &ops_lowbyteofcxx . . $ ops_lowbyteof.;
542 goto get_byte_and_push_monadic;
543
544 case '>':// HIGHBYTE operator
545 operator = &ops_highbyteofcxx . . $ ops_highbyteof.;
546 goto get_byte_and_push_monadic;
547
548 case '^':// BANKBYTE operator
549 operator = &ops_bankbyteofcxx . . $ ops_bankbyteof.;
550 goto get_byte_and_push_monadic;
551
552 // Faked monadic operators
553
554 case '(':// left parenthesis
555 operator = &ops_openingcxx . . $ ops_opening.;
556 goto get_byte_and_push_monadic;
557
558 case ')':// right parenthesis
559 // this makes "()" also throw a syntax error
560 Throw_errorcxx . . $ Throw_error(85c52e162fed56f9).(exception_syntaxcxx . . $ exception_syntax.);
561 alu_statecxx . . $ alu_state. = STATE_ERRORcxx . . $ STATE_ERROR.;
562 break;
563
564 // Operands (values, state changes to ExpectDyadic)
565
566 // Quoted character
567 case '"':
568 case '\'':
569 // Character will be converted using current encoding
570 parse_quoted_charactercxx . . $ parse_quoted_character(44b6ea1973a07080).(GotBytecxx . . $ GotByte.);
571 // Now GotByte = char following closing quote
572 goto now_expect_dyadic;
573
574 // Binary value
575 case '%':
576 parse_binary_valuecxx . . $ parse_binary_value(49f6e7a06ebc5aa8).();// Now GotByte = non-binary char
577 goto now_expect_dyadic;
578
579 // Octal value
580 case '&':
581 parse_octal_valuecxx . . $ parse_octal_value(49f6e7a06ebc5aa8).();// Now GotByte = non-octal char
582 goto now_expect_dyadic;
583
584 // Hexadecimal value
585 case '$':
586 parse_hexadecimal_valuecxx . . $ parse_hexadecimal_value(49f6e7a06ebc5aa8).();
587 // Now GotByte = non-hexadecimal char
588 goto now_expect_dyadic;
589
590 // Program counter
591 case '*':
592 GetBytecxx . . $ GetByte(6e9c618e4dd2eafc).();// proceed with next char
593 PUSH_INTOPERANDcxx . . $ `src/asm/alu.c:195:9`!(CPU_pc.intval, CPU_pc.flags | MVALUE_EXISTScxx . . $ `src/asm/alu.h:20:9`!);
594 // Now GotByte = char after closing quote
595 goto now_expect_dyadic;
596
597 // Local label
598 case '.':
599 GetBytecxx . . $ GetByte(6e9c618e4dd2eafc).();// start after '.'
600 if(Input_read_keywordcxx . . $ Input_read_keyword(b126dc7c1de90089).()) {
601 // Now GotByte = illegal char
602 get_label_valuecxx . . $ get_label_value(cb2f890c2fdad230).(Section_nowcxx . . $ Section_now.->zonecxx . . $ $anonymous_type_4270326a5ce8d2d2_0#zone.);
603 goto now_expect_dyadic;
604 } // goto means we don't need an "else {" here
605 alu_statecxx . . $ alu_state. = STATE_ERRORcxx . . $ STATE_ERROR.;
606 break;
607
608 // Decimal values and global labels
609 default:// (all other characters)
610 if((GotBytecxx . . $ GotByte. >= '0') && (GotBytecxx . . $ GotByte. <= '9')) {
611 parse_decimal_valuecxx . . $ parse_decimal_value(49f6e7a06ebc5aa8).();
612 // Now GotByte = non-decimal char
613 goto now_expect_dyadic;
614 } // goto means we don't need an "else {" here
615 if(BYTEFLAGScxx . . $ `src/asm/global.h:42:9`!(GotByte) & STARTS_KEYWORDcxx . . $ `src/asm/global.h:43:9`!) {
616 register int length;
617 // Read global label (or "NOT")
618 length = Input_read_keywordcxx . . $ Input_read_keyword(b126dc7c1de90089).();
619 // Now GotByte = illegal char
620 // Check for NOT. Okay, it's hardcoded,
621 // but so what? Sue me...
622 if((length == 3)
623 && ((GlobalDynaBufcxx . . $ GlobalDynaBuf.->buffercxx . . $ dynabuf_t#buffer.[0] | 32) == 'n')
624 && ((GlobalDynaBufcxx . . $ GlobalDynaBuf.->buffercxx . . $ dynabuf_t#buffer.[1] | 32) == 'o')
625 && ((GlobalDynaBufcxx . . $ GlobalDynaBuf.->buffercxx . . $ dynabuf_t#buffer.[2] | 32) == 't')) {
626 PUSH_OPERATORcxx . . $ `src/asm/alu.c:193:9`!(&ops_not);
627 // state doesn't change
628 } else {
629 if(GotBytecxx . . $ GotByte. == '(')
630 parse_function_callcxx . . $ parse_function_call(49f6e7a06ebc5aa8).();
631 else {
632 get_label_valuecxx . . $ get_label_value(cb2f890c2fdad230).(ZONE_GLOBALcxx . . $ `src/asm/section.h:23:9`!);
633 goto now_expect_dyadic;
634 }
635 }
636 } else {
637 // illegal character read - so don't go on
638 PUSH_INTOPERANDcxx . . $ `src/asm/alu.c:195:9`!(0, 0);
639 // push pseudo value, EXISTS flag is clear
640 if(operator_stackcxx . . $ operator_stack.[operator_spcxx . . $ operator_sp.-1] == &ops_returncxx . . $ ops_return.) {
641 PUSH_OPERATORcxx . . $ `src/asm/alu.c:193:9`!(&ops_end);
642 alu_statecxx . . $ alu_state. = STATE_TRY_TO_REDUCE_STACKScxx . . $ STATE_TRY_TO_REDUCE_STACKS.;
643 } else {
644 Throw_errorcxx . . $ Throw_error(85c52e162fed56f9).(exception_syntaxcxx . . $ exception_syntax.);
645 alu_statecxx . . $ alu_state. = STATE_ERRORcxx . . $ STATE_ERROR.;
646 }
647 }
648 break;
649
650 // no other possibilities, so here are the shared endings
651
652 get_byte_and_push_monadic:
653 GetBytecxx . . $ GetByte(6e9c618e4dd2eafc).();
654 PUSH_OPERATORcxx . . $ `src/asm/alu.c:193:9`!(operator);
655 // State doesn't change
656 break;
657
658 now_expect_dyadic:
659 alu_statecxx . . $ alu_state. = STATE_EXPECT_DYADIC_OPERATORcxx . . $ STATE_EXPECT_DYADIC_OPERATOR.;
660 break;
661
662 }
663 }
664
665 // Expect dyadic operator (hopefully inlined)
666 static inline void expect_dyadic_operatorcxx . . $ expect_dyadic_operator(49f6e7a06ebc5aa8).(void) {
667 void* node_body;
668 op_tcxx . . $ op_t#* operator;
669
670 SKIPSPACEcxx . . $ `src/asm/global.h:75:9`!();
671 switch(GotBytecxx . . $ GotByte.) {
672
673 // Single-character dyadic operators
674
675 case '^':// "to the power of"
676 operator = &ops_powerofcxx . . $ ops_powerof.;
677 goto get_byte_and_push_dyadic;
678
679 case '+':// add
680 operator = &ops_addcxx . . $ ops_add.;
681 goto get_byte_and_push_dyadic;
682
683 case '-':// subtract
684 operator = &ops_subtractcxx . . $ ops_subtract.;
685 goto get_byte_and_push_dyadic;
686
687 case '*':// multiply
688 operator = &ops_multiplycxx . . $ ops_multiply.;
689 goto get_byte_and_push_dyadic;
690
691 case '/':// divide
692 operator = &ops_dividecxx . . $ ops_divide.;
693 goto get_byte_and_push_dyadic;
694
695 case '%':// modulo
696 operator = &ops_modulocxx . . $ ops_modulo.;
697 goto get_byte_and_push_dyadic;
698
699 case '&':// bitwise AND
700 operator = &ops_andcxx . . $ ops_and.;
701 goto get_byte_and_push_dyadic;
702
703 case '|':// bitwise OR
704 operator = &ops_orcxx . . $ ops_or.;
705 goto get_byte_and_push_dyadic;
706
707 // This part is commented out because there is no XOR character defined
708 // case ???:// bitwise exclusive OR
709 // operator = &ops_xor;
710 // goto get_byte_and_push_dyadic;
711
712 case '=':// is equal
713 operator = &ops_equalscxx . . $ ops_equals.;
714 goto get_byte_and_push_dyadic;
715
716 case ')':// closing parenthesis
717 operator = &ops_closingcxx . . $ ops_closing.;
718 goto get_byte_and_push_dyadic;
719
720 // Multi-character dyadic operators
721
722 // "!="
723 case '!':
724 if(GetBytecxx . . $ GetByte(6e9c618e4dd2eafc).() == '=') {
725 operator = &ops_notequalcxx . . $ ops_notequal.;
726 goto get_byte_and_push_dyadic;
727 } // goto means we don't need an "else {" here
728 Throw_errorcxx . . $ Throw_error(85c52e162fed56f9).(exception_syntaxcxx . . $ exception_syntax.);
729 alu_statecxx . . $ alu_state. = STATE_ERRORcxx . . $ STATE_ERROR.;
730 break;
731
732 // "<", "<=", "<<" and "<>"
733 case '<':
734 switch(GetBytecxx . . $ GetByte(6e9c618e4dd2eafc).()) {
735
736 case '=':// "<=", less or equal
737 operator = &ops_lecxx . . $ ops_le.;
738 goto get_byte_and_push_dyadic;
739
740 case '<':// "<<", shift left
741 operator = &ops_slcxx . . $ ops_sl.;
742 goto get_byte_and_push_dyadic;
743
744 case '>':// "<>", not equal
745 operator = &ops_notequalcxx . . $ ops_notequal.;
746 goto get_byte_and_push_dyadic;
747
748 default:// "<", less than
749 operator = &ops_lessthancxx . . $ ops_lessthan.;
750 goto push_dyadic;
751 }
752 break;
753
754 // ">", ">=", ">>", ">>>" and "><"
755 case '>':
756 switch(GetBytecxx . . $ GetByte(6e9c618e4dd2eafc).()) {
757
758 case '=':// ">=", greater or equal
759 operator = &ops_gecxx . . $ ops_ge.;
760 goto get_byte_and_push_dyadic;
761
762 case '<':// "><", not equal
763 operator = &ops_notequalcxx . . $ ops_notequal.;
764 goto get_byte_and_push_dyadic;
765
766 case '>':// ">>" or ">>>", shift right
767 operator = &ops_asrcxx . . $ ops_asr.;// arithmetic shift right
768 if(GetBytecxx . . $ GetByte(6e9c618e4dd2eafc).() != '>')
769 goto push_dyadic;
770 operator = &ops_lsrcxx . . $ ops_lsr.;// logical shift right
771 goto get_byte_and_push_dyadic;
772
773 default:// ">", greater than
774 operator = &ops_greaterthancxx . . $ ops_greaterthan.;
775 goto push_dyadic;
776 }
777 break;
778
779 // end of expression or text version of dyadic operator
780 default:
781 // check string version of operators
782 if(BYTEFLAGScxx . . $ `src/asm/global.h:42:9`!(GotByte) & STARTS_KEYWORDcxx . . $ `src/asm/global.h:43:9`!) {
783 Input_read_and_lower_keywordcxx . . $ Input_read_and_lower_keyword(b126dc7c1de90089).();
784 // Now GotByte = illegal char
785 // search for tree item
786 if(Tree_easy_scancxx . . $ Tree_easy_scan(7f10be3e8224db50).(operator_treecxx . . $ operator_tree., &node_body, GlobalDynaBufcxx . . $ GlobalDynaBuf.)) {
787 operator = node_body;
788 goto push_dyadic;
789 }
790 // goto means we don't need an "else {" here
791 Throw_errorcxx . . $ Throw_error(85c52e162fed56f9).("Unknown operator.");
792 alu_statecxx . . $ alu_state. = STATE_ERRORcxx . . $ STATE_ERROR.;
793 } else {
794 operator = &ops_endcxx . . $ ops_end.;
795 goto push_dyadic;
796 }
797 break;
798
799 // no other possibilities, so here are the shared endings
800
801 get_byte_and_push_dyadic:
802 GetBytecxx . . $ GetByte(6e9c618e4dd2eafc).();
803 push_dyadic:
804 PUSH_OPERATORcxx . . $ `src/asm/alu.c:193:9`!(operator);
805 alu_statecxx . . $ alu_state. = STATE_TRY_TO_REDUCE_STACKScxx . . $ STATE_TRY_TO_REDUCE_STACKS.;
806 break;
807
808 }
809 }
810
811 // call C's sin/cos/tan function
812 static void perform_fpcxx . . $ perform_fp(40db9e5e35a950bf).(double (*fn)(double)) {
813 if((RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! & MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!) == 0) {
814 RIGHT_FPVALcxx . . $ `src/asm/alu.c:191:9`! = RIGHT_INTVALcxx . . $ `src/asm/alu.c:189:9`!;
815 RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! |= MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!;
816 }
817 RIGHT_FPVALcxx . . $ `src/asm/alu.c:191:9`! = fn(RIGHT_FPVALcxx . . $ `src/asm/alu.c:191:9`!);
818 }
819
820 // make sure arg is in [-1, 1] range before calling function
821 static void perform_ranged_fpcxx . . $ perform_ranged_fp(40db9e5e35a950bf).(double (*fn)(double)) {
822 if((RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! & MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!) == 0) {
823 RIGHT_FPVALcxx . . $ `src/asm/alu.c:191:9`! = RIGHT_INTVALcxx . . $ `src/asm/alu.c:189:9`!;
824 RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! |= MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!;
825 }
826 if((RIGHT_FPVALcxx . . $ `src/asm/alu.c:191:9`! >= -1) && (RIGHT_FPVALcxx . . $ `src/asm/alu.c:191:9`! <= 1))
827 RIGHT_FPVALcxx . . $ `src/asm/alu.c:191:9`! = fn(RIGHT_FPVALcxx . . $ `src/asm/alu.c:191:9`!);
828 else {
829 if(RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! & MVALUE_DEFINEDcxx . . $ `src/asm/alu.h:27:9`!)
830 Throw_errorcxx . . $ Throw_error(85c52e162fed56f9).("Argument out of range.");
831 RIGHT_FPVALcxx . . $ `src/asm/alu.c:191:9`! = 0;
832 }
833 }
834
835 // convert right-hand value from fp to int
836 static void right_fp_to_intcxx . . $ right_fp_to_int(d878ad36e69247c7).() {
837 RIGHT_INTVALcxx . . $ `src/asm/alu.c:189:9`! = RIGHT_FPVALcxx . . $ `src/asm/alu.c:191:9`!;
838 RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! &= ~MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!;
839 }
840
841 // check both left-hand and right-hand values. if float, convert to int.
842 // in first pass, throw warning
843 static void both_ensure_intcxx . . $ both_ensure_int(b45ddcbc8423892c).(boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! warn) {
844 if(LEFT_FLAGScxx . . $ `src/asm/alu.c:186:9`! & MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!) {
845 LEFT_INTVALcxx . . $ `src/asm/alu.c:188:9`! = LEFT_FPVALcxx . . $ `src/asm/alu.c:190:9`!;
846 LEFT_FLAGScxx . . $ `src/asm/alu.c:186:9`! &= ~MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!;
847 }
848 if(RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! & MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!) {
849 RIGHT_INTVALcxx . . $ `src/asm/alu.c:189:9`! = RIGHT_FPVALcxx . . $ `src/asm/alu.c:191:9`!;
850 RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! &= ~MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!;
851 }
852 Throw_first_pass_warningcxx . . $ Throw_first_pass_warning(85c52e162fed56f9).("Converted to integer for binary logic operator.");
853 }
854
855 // check both left-hand and right-hand values. if int, convert to float.
856 static void both_ensure_fpcxx . . $ both_ensure_fp(d878ad36e69247c7).() {
857 if((LEFT_FLAGScxx . . $ `src/asm/alu.c:186:9`! & MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!) == 0) {
858 LEFT_FPVALcxx . . $ `src/asm/alu.c:190:9`! = LEFT_INTVALcxx . . $ `src/asm/alu.c:188:9`!;
859 LEFT_FLAGScxx . . $ `src/asm/alu.c:186:9`! |= MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!;
860 }
861 if((RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! & MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!) == 0) {
862 RIGHT_FPVALcxx . . $ `src/asm/alu.c:191:9`! = RIGHT_INTVALcxx . . $ `src/asm/alu.c:189:9`!;
863 RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! |= MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!;
864 }
865 }
866
867 // make sure both values are float, but mark left one as int (will become one)
868 static void ensure_int_from_fpcxx . . $ ensure_int_from_fp(d878ad36e69247c7).() {
869 both_ensure_fpcxx . . $ both_ensure_fp(d878ad36e69247c7).();
870 LEFT_FLAGScxx . . $ `src/asm/alu.c:186:9`! &= ~MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!;
871 }
872
873 // Try to reduce stacks by performing high-priority operations
874 static inline void try_to_reduce_stackscxx . . $ try_to_reduce_stacks(11b0e290e57a7e53).(int* open_parentheses) {
875 if(operator_spcxx . . $ operator_sp. < 2) {
876 alu_statecxx . . $ alu_state. = STATE_EXPECT_OPERAND_OR_MONADIC_OPERATORcxx . . $ STATE_EXPECT_OPERAND_OR_MONADIC_OPERATOR.;
877 return;
878 }
879 if(operator_stackcxx . . $ operator_stack.[operator_spcxx . . $ operator_sp.-2]->prioritycxx . . $ operator_t#priority. < operator_stackcxx . . $ operator_stack.[operator_spcxx . . $ operator_sp.-1]->prioritycxx . . $ operator_t#priority.) {
880 alu_statecxx . . $ alu_state. = STATE_EXPECT_OPERAND_OR_MONADIC_OPERATORcxx . . $ STATE_EXPECT_OPERAND_OR_MONADIC_OPERATOR.;
881 return;
882 }
883 switch(operator_stackcxx . . $ operator_stack.[operator_spcxx . . $ operator_sp.-2]->handlecxx . . $ operator_t#handle.) {
884
885 // special (pseudo) operators
886
887 case OPHANDLE_RETURNcxx . . $ OPHANDLE_RETURN.:
888 // don't touch indirect_flag; needed for INDIRECT flag
889 operator_spcxx . . $ operator_sp.--;// decrement operator stack pointer
890 alu_statecxx . . $ alu_state. = STATE_ENDcxx . . $ STATE_END.;
891 break;
892
893 case OPHANDLE_OPENINGcxx . . $ OPHANDLE_OPENING.:
894 indirect_flagcxx . . $ indirect_flag. = MVALUE_INDIRECTcxx . . $ `src/asm/alu.h:18:9`!;// parentheses found
895 switch(operator_stackcxx . . $ operator_stack.[operator_spcxx . . $ operator_sp.-1]->handlecxx . . $ operator_t#handle.) {
896
897 case OPHANDLE_CLOSINGcxx . . $ OPHANDLE_CLOSING.:// matching parentheses
898 operator_spcxx . . $ operator_sp. -= 2;// remove both of them
899 alu_statecxx . . $ alu_state. = STATE_EXPECT_DYADIC_OPERATORcxx . . $ STATE_EXPECT_DYADIC_OPERATOR.;
900 break;
901
902 case OPHANDLE_ENDcxx . . $ OPHANDLE_END.:// unmatched parenthesis
903 (*open_parentheses)++;// count
904 goto RNTLObutDontTouchIndirectFlag;
905
906 default:
907 Bug_foundcxx . . $ Bug_found(34d26762b42c433a).("StrangeParenthesis", operator_stackcxx . . $ operator_stack.[operator_spcxx . . $ operator_sp.-1]->handlecxx . . $ operator_t#handle.);
908 }
909 break;
910
911 case OPHANDLE_CLOSINGcxx . . $ OPHANDLE_CLOSING.:
912 Throw_errorcxx . . $ Throw_error(85c52e162fed56f9).("Too many ')'.");
913 goto remove_next_to_last_operator;
914
915 // functions
916
917 case OPHANDLE_INTcxx . . $ OPHANDLE_INT.:
918 if(RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! & MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!)
919 right_fp_to_intcxx . . $ right_fp_to_int(d878ad36e69247c7).();
920 goto remove_next_to_last_operator;
921
922 case OPHANDLE_FLOATcxx . . $ OPHANDLE_FLOAT.:
923 // convert right-hand value from int to fp
924 if((RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! & MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!) == 0) {
925 RIGHT_FPVALcxx . . $ `src/asm/alu.c:191:9`! = RIGHT_INTVALcxx . . $ `src/asm/alu.c:189:9`!;
926 RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! |= MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!;
927 }
928 goto remove_next_to_last_operator;
929
930 case OPHANDLE_SINcxx . . $ OPHANDLE_SIN.:
931 perform_fpcxx . . $ perform_fp(40db9e5e35a950bf).(sin);
932 goto remove_next_to_last_operator;
933
934 case OPHANDLE_COScxx . . $ OPHANDLE_COS.:
935 perform_fpcxx . . $ perform_fp(40db9e5e35a950bf).(cos);
936 goto remove_next_to_last_operator;
937
938 case OPHANDLE_TANcxx . . $ OPHANDLE_TAN.:
939 perform_fpcxx . . $ perform_fp(40db9e5e35a950bf).(tan);
940 goto remove_next_to_last_operator;
941
942 case OPHANDLE_ARCSINcxx . . $ OPHANDLE_ARCSIN.:
943 perform_ranged_fpcxx . . $ perform_ranged_fp(40db9e5e35a950bf).(asin);
944 goto remove_next_to_last_operator;
945
946 case OPHANDLE_ARCCOScxx . . $ OPHANDLE_ARCCOS.:
947 perform_ranged_fpcxx . . $ perform_ranged_fp(40db9e5e35a950bf).(acos);
948 goto remove_next_to_last_operator;
949
950 case OPHANDLE_ARCTANcxx . . $ OPHANDLE_ARCTAN.:
951 perform_fpcxx . . $ perform_fp(40db9e5e35a950bf).(atan);
952 goto remove_next_to_last_operator;
953
954 // monadic operators
955
956 case OPHANDLE_NOTcxx . . $ OPHANDLE_NOT.:
957 // different operations for fp and int
958 if(RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! & MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!)
959 right_fp_to_intcxx . . $ right_fp_to_int(d878ad36e69247c7).();
960 RIGHT_INTVALcxx . . $ `src/asm/alu.c:189:9`! = ~(RIGHT_INTVALcxx . . $ `src/asm/alu.c:189:9`!);
961 RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! &= ~MVALUE_ISBYTEcxx . . $ `src/asm/alu.h:29:9`!;
962 goto remove_next_to_last_operator;
963
964 case OPHANDLE_NEGATEcxx . . $ OPHANDLE_NEGATE.:
965 // different operations for fp and int
966 if(RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! & MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!)
967 RIGHT_FPVALcxx . . $ `src/asm/alu.c:191:9`! = -(RIGHT_FPVALcxx . . $ `src/asm/alu.c:191:9`!);
968 else
969 RIGHT_INTVALcxx . . $ `src/asm/alu.c:189:9`! = -(RIGHT_INTVALcxx . . $ `src/asm/alu.c:189:9`!);
970 RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! &= ~MVALUE_ISBYTEcxx . . $ `src/asm/alu.h:29:9`!;
971 goto remove_next_to_last_operator;
972
973 case OPHANDLE_LOWBYTEOFcxx . . $ OPHANDLE_LOWBYTEOF.:
974 // fp becomes int
975 if(RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! & MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!)
976 right_fp_to_intcxx . . $ right_fp_to_int(d878ad36e69247c7).();
977 RIGHT_INTVALcxx . . $ `src/asm/alu.c:189:9`! = (RIGHT_INTVALcxx . . $ `src/asm/alu.c:189:9`!) & 255;
978 RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! |= MVALUE_ISBYTEcxx . . $ `src/asm/alu.h:29:9`!;
979 RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! &= ~MVALUE_FORCEBITScxx . . $ `src/asm/alu.h:37:9`!;
980 goto remove_next_to_last_operator;
981
982 case OPHANDLE_HIGHBYTEOFcxx . . $ OPHANDLE_HIGHBYTEOF.:
983 // fp becomes int
984 if(RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! & MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!)
985 right_fp_to_intcxx . . $ right_fp_to_int(d878ad36e69247c7).();
986 RIGHT_INTVALcxx . . $ `src/asm/alu.c:189:9`! = ((RIGHT_INTVALcxx . . $ `src/asm/alu.c:189:9`!) >> 8) & 255;
987 RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! |= MVALUE_ISBYTEcxx . . $ `src/asm/alu.h:29:9`!;
988 RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! &= ~MVALUE_FORCEBITScxx . . $ `src/asm/alu.h:37:9`!;
989 goto remove_next_to_last_operator;
990
991 case OPHANDLE_BANKBYTEOFcxx . . $ OPHANDLE_BANKBYTEOF.:
992 // fp becomes int
993 if(RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! & MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!)
994 right_fp_to_intcxx . . $ right_fp_to_int(d878ad36e69247c7).();
995 RIGHT_INTVALcxx . . $ `src/asm/alu.c:189:9`! = ((RIGHT_INTVALcxx . . $ `src/asm/alu.c:189:9`!) >> 16) & 255;
996 RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! |= MVALUE_ISBYTEcxx . . $ `src/asm/alu.h:29:9`!;
997 RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! &= ~MVALUE_FORCEBITScxx . . $ `src/asm/alu.h:37:9`!;
998 goto remove_next_to_last_operator;
999
1000 // dyadic operators
1001
1002 case OPHANDLE_POWEROFcxx . . $ OPHANDLE_POWEROF.:
1003 if((RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! | LEFT_FLAGScxx . . $ `src/asm/alu.c:186:9`!) & MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!) {
1004 both_ensure_fpcxx . . $ both_ensure_fp(d878ad36e69247c7).();
1005 LEFT_FPVALcxx . . $ `src/asm/alu.c:190:9`! = pow(LEFT_FPVALcxx . . $ `src/asm/alu.c:190:9`!, RIGHT_FPVALcxx . . $ `src/asm/alu.c:191:9`!);
1006 goto handle_flags_and_dec_stacks;
1007 }
1008 if(RIGHT_INTVALcxx . . $ `src/asm/alu.c:189:9`! >= 0)
1009 LEFT_INTVALcxx . . $ `src/asm/alu.c:188:9`! = my_powcxx . . $ my_pow(d0a0e4c270da0eca).(LEFT_INTVALcxx . . $ `src/asm/alu.c:188:9`!, RIGHT_INTVALcxx . . $ `src/asm/alu.c:189:9`!);
1010 else {
1011 if(RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! & MVALUE_DEFINEDcxx . . $ `src/asm/alu.h:27:9`!)
1012 Throw_errorcxx . . $ Throw_error(85c52e162fed56f9).("Exponent is negative.");
1013 LEFT_INTVALcxx . . $ `src/asm/alu.c:188:9`! = 0;
1014 }
1015 goto handle_flags_and_dec_stacks;
1016
1017 case OPHANDLE_MULTIPLYcxx . . $ OPHANDLE_MULTIPLY.:
1018 if((RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! | LEFT_FLAGScxx . . $ `src/asm/alu.c:186:9`!) & MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!) {
1019 both_ensure_fpcxx . . $ both_ensure_fp(d878ad36e69247c7).();
1020 LEFT_FPVALcxx . . $ `src/asm/alu.c:190:9`! *= RIGHT_FPVALcxx . . $ `src/asm/alu.c:191:9`!;
1021 } else
1022 LEFT_INTVALcxx . . $ `src/asm/alu.c:188:9`! *= RIGHT_INTVALcxx . . $ `src/asm/alu.c:189:9`!;
1023 goto handle_flags_and_dec_stacks;
1024
1025 case OPHANDLE_DIVIDEcxx . . $ OPHANDLE_DIVIDE.:
1026 if((RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! | LEFT_FLAGScxx . . $ `src/asm/alu.c:186:9`!) & MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!) {
1027 both_ensure_fpcxx . . $ both_ensure_fp(d878ad36e69247c7).();
1028 if(RIGHT_FPVALcxx . . $ `src/asm/alu.c:191:9`!)
1029 LEFT_FPVALcxx . . $ `src/asm/alu.c:190:9`! /= RIGHT_FPVALcxx . . $ `src/asm/alu.c:191:9`!;
1030 else {
1031 if(RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! & MVALUE_DEFINEDcxx . . $ `src/asm/alu.h:27:9`!)
1032 Throw_errorcxx . . $ Throw_error(85c52e162fed56f9).(exception_div_by_zerocxx . . $ exception_div_by_zero.);
1033 LEFT_FPVALcxx . . $ `src/asm/alu.c:190:9`! = 0;
1034 }
1035 } else {
1036 if(RIGHT_INTVALcxx . . $ `src/asm/alu.c:189:9`!)
1037 LEFT_INTVALcxx . . $ `src/asm/alu.c:188:9`! /= RIGHT_INTVALcxx . . $ `src/asm/alu.c:189:9`!;
1038 else {
1039 if(RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! & MVALUE_DEFINEDcxx . . $ `src/asm/alu.h:27:9`!)
1040 Throw_errorcxx . . $ Throw_error(85c52e162fed56f9).(exception_div_by_zerocxx . . $ exception_div_by_zero.);
1041 LEFT_INTVALcxx . . $ `src/asm/alu.c:188:9`! = 0;
1042 }
1043 }
1044 goto handle_flags_and_dec_stacks;
1045
1046 case OPHANDLE_INTDIVcxx . . $ OPHANDLE_INTDIV.:
1047 if((RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! | LEFT_FLAGScxx . . $ `src/asm/alu.c:186:9`!) & MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!) {
1048 both_ensure_fpcxx . . $ both_ensure_fp(d878ad36e69247c7).();
1049 if(RIGHT_FPVALcxx . . $ `src/asm/alu.c:191:9`!)
1050 LEFT_INTVALcxx . . $ `src/asm/alu.c:188:9`! = LEFT_FPVALcxx . . $ `src/asm/alu.c:190:9`! / RIGHT_FPVALcxx . . $ `src/asm/alu.c:191:9`!;
1051 else {
1052 if(RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! & MVALUE_DEFINEDcxx . . $ `src/asm/alu.h:27:9`!)
1053 Throw_errorcxx . . $ Throw_error(85c52e162fed56f9).(exception_div_by_zerocxx . . $ exception_div_by_zero.);
1054 LEFT_INTVALcxx . . $ `src/asm/alu.c:188:9`! = 0;
1055 }
1056 LEFT_FLAGScxx . . $ `src/asm/alu.c:186:9`! &= ~MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!;
1057 } else {
1058 if(RIGHT_INTVALcxx . . $ `src/asm/alu.c:189:9`!)
1059 LEFT_INTVALcxx . . $ `src/asm/alu.c:188:9`! /= RIGHT_INTVALcxx . . $ `src/asm/alu.c:189:9`!;
1060 else {
1061 if(RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! & MVALUE_DEFINEDcxx . . $ `src/asm/alu.h:27:9`!)
1062 Throw_errorcxx . . $ Throw_error(85c52e162fed56f9).(exception_div_by_zerocxx . . $ exception_div_by_zero.);
1063 LEFT_INTVALcxx . . $ `src/asm/alu.c:188:9`! = 0;
1064 }
1065 }
1066 goto handle_flags_and_dec_stacks;
1067
1068 case OPHANDLE_MODULOcxx . . $ OPHANDLE_MODULO.:
1069 if((RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! | LEFT_FLAGScxx . . $ `src/asm/alu.c:186:9`!) & MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!)
1070 both_ensure_intcxx . . $ both_ensure_int(b45ddcbc8423892c).(FALSEcxx . . $ `src/asm/config.h:54:9`!);
1071 if(RIGHT_INTVALcxx . . $ `src/asm/alu.c:189:9`!)
1072 LEFT_INTVALcxx . . $ `src/asm/alu.c:188:9`! %= RIGHT_INTVALcxx . . $ `src/asm/alu.c:189:9`!;
1073 else {
1074 if(RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! & MVALUE_DEFINEDcxx . . $ `src/asm/alu.h:27:9`!)
1075 Throw_errorcxx . . $ Throw_error(85c52e162fed56f9).(exception_div_by_zerocxx . . $ exception_div_by_zero.);
1076 LEFT_INTVALcxx . . $ `src/asm/alu.c:188:9`! = 0;
1077 }
1078 goto handle_flags_and_dec_stacks;
1079
1080 case OPHANDLE_ADDcxx . . $ OPHANDLE_ADD.:
1081 if((RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! | LEFT_FLAGScxx . . $ `src/asm/alu.c:186:9`!) & MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!) {
1082 both_ensure_fpcxx . . $ both_ensure_fp(d878ad36e69247c7).();
1083 LEFT_FPVALcxx . . $ `src/asm/alu.c:190:9`! += RIGHT_FPVALcxx . . $ `src/asm/alu.c:191:9`!;
1084 } else
1085 LEFT_INTVALcxx . . $ `src/asm/alu.c:188:9`! += RIGHT_INTVALcxx . . $ `src/asm/alu.c:189:9`!;
1086 goto handle_flags_and_dec_stacks;
1087
1088 case OPHANDLE_SUBTRACTcxx . . $ OPHANDLE_SUBTRACT.:
1089 if((RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! | LEFT_FLAGScxx . . $ `src/asm/alu.c:186:9`!) & MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!) {
1090 both_ensure_fpcxx . . $ both_ensure_fp(d878ad36e69247c7).();
1091 LEFT_FPVALcxx . . $ `src/asm/alu.c:190:9`! -= RIGHT_FPVALcxx . . $ `src/asm/alu.c:191:9`!;
1092 } else
1093 LEFT_INTVALcxx . . $ `src/asm/alu.c:188:9`! -= RIGHT_INTVALcxx . . $ `src/asm/alu.c:189:9`!;
1094 goto handle_flags_and_dec_stacks;
1095
1096 case OPHANDLE_SLcxx . . $ OPHANDLE_SL.:
1097 if(RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! & MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!)
1098 right_fp_to_intcxx . . $ right_fp_to_int(d878ad36e69247c7).();
1099 if(LEFT_FLAGScxx . . $ `src/asm/alu.c:186:9`! & MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!)
1100 LEFT_FPVALcxx . . $ `src/asm/alu.c:190:9`! *= (1 << RIGHT_INTVALcxx . . $ `src/asm/alu.c:189:9`!);
1101 else
1102 LEFT_INTVALcxx . . $ `src/asm/alu.c:188:9`! <<= RIGHT_INTVALcxx . . $ `src/asm/alu.c:189:9`!;
1103 goto handle_flags_and_dec_stacks;
1104
1105 case OPHANDLE_ASRcxx . . $ OPHANDLE_ASR.:
1106 if(RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! & MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!)
1107 right_fp_to_intcxx . . $ right_fp_to_int(d878ad36e69247c7).();
1108 if(LEFT_FLAGScxx . . $ `src/asm/alu.c:186:9`! & MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!)
1109 LEFT_FPVALcxx . . $ `src/asm/alu.c:190:9`! /= (1 << RIGHT_INTVALcxx . . $ `src/asm/alu.c:189:9`!);
1110 else
1111 LEFT_INTVALcxx . . $ `src/asm/alu.c:188:9`! = my_asrcxx . . $ my_asr(d0a0e4c270da0eca).(LEFT_INTVALcxx . . $ `src/asm/alu.c:188:9`!, RIGHT_INTVALcxx . . $ `src/asm/alu.c:189:9`!);
1112 goto handle_flags_and_dec_stacks;
1113
1114 case OPHANDLE_LSRcxx . . $ OPHANDLE_LSR.:
1115 if((RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! | LEFT_FLAGScxx . . $ `src/asm/alu.c:186:9`!) & MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!)
1116 both_ensure_intcxx . . $ both_ensure_int(b45ddcbc8423892c).(TRUEcxx . . $ `src/asm/config.h:55:9`!);
1117 LEFT_INTVALcxx . . $ `src/asm/alu.c:188:9`! = ((uintval_tcxx . . $ uintval_t#) LEFT_INTVALcxx . . $ `src/asm/alu.c:188:9`!) >> RIGHT_INTVALcxx . . $ `src/asm/alu.c:189:9`!;
1118 goto handle_flags_and_dec_stacks;
1119
1120 case OPHANDLE_LEcxx . . $ OPHANDLE_LE.:
1121 if((RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! | LEFT_FLAGScxx . . $ `src/asm/alu.c:186:9`!) & MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!) {
1122 ensure_int_from_fpcxx . . $ ensure_int_from_fp(d878ad36e69247c7).();
1123 LEFT_INTVALcxx . . $ `src/asm/alu.c:188:9`! = (LEFT_FPVALcxx . . $ `src/asm/alu.c:190:9`! <= RIGHT_FPVALcxx . . $ `src/asm/alu.c:191:9`!);
1124 } else
1125 LEFT_INTVALcxx . . $ `src/asm/alu.c:188:9`! = (LEFT_INTVALcxx . . $ `src/asm/alu.c:188:9`! <= RIGHT_INTVALcxx . . $ `src/asm/alu.c:189:9`!);
1126 goto handle_flags_and_dec_stacks;
1127
1128 case OPHANDLE_LESSTHANcxx . . $ OPHANDLE_LESSTHAN.:
1129 if((RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! | LEFT_FLAGScxx . . $ `src/asm/alu.c:186:9`!) & MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!) {
1130 ensure_int_from_fpcxx . . $ ensure_int_from_fp(d878ad36e69247c7).();
1131 LEFT_INTVALcxx . . $ `src/asm/alu.c:188:9`! = (LEFT_FPVALcxx . . $ `src/asm/alu.c:190:9`! < RIGHT_FPVALcxx . . $ `src/asm/alu.c:191:9`!);
1132 } else
1133 LEFT_INTVALcxx . . $ `src/asm/alu.c:188:9`! = (LEFT_INTVALcxx . . $ `src/asm/alu.c:188:9`! < RIGHT_INTVALcxx . . $ `src/asm/alu.c:189:9`!);
1134 goto handle_flags_and_dec_stacks;
1135
1136 case OPHANDLE_GEcxx . . $ OPHANDLE_GE.:
1137 if((RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! | LEFT_FLAGScxx . . $ `src/asm/alu.c:186:9`!) & MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!) {
1138 ensure_int_from_fpcxx . . $ ensure_int_from_fp(d878ad36e69247c7).();
1139 LEFT_INTVALcxx . . $ `src/asm/alu.c:188:9`! = (LEFT_FPVALcxx . . $ `src/asm/alu.c:190:9`! >= RIGHT_FPVALcxx . . $ `src/asm/alu.c:191:9`!);
1140 } else
1141 LEFT_INTVALcxx . . $ `src/asm/alu.c:188:9`! = (LEFT_INTVALcxx . . $ `src/asm/alu.c:188:9`! >= RIGHT_INTVALcxx . . $ `src/asm/alu.c:189:9`!);
1142 goto handle_flags_and_dec_stacks;
1143
1144 case OPHANDLE_GREATERTHANcxx . . $ OPHANDLE_GREATERTHAN.:
1145 if((RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! | LEFT_FLAGScxx . . $ `src/asm/alu.c:186:9`!) & MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!) {
1146 ensure_int_from_fpcxx . . $ ensure_int_from_fp(d878ad36e69247c7).();
1147 LEFT_INTVALcxx . . $ `src/asm/alu.c:188:9`! = (LEFT_FPVALcxx . . $ `src/asm/alu.c:190:9`! > RIGHT_FPVALcxx . . $ `src/asm/alu.c:191:9`!);
1148 } else
1149 LEFT_INTVALcxx . . $ `src/asm/alu.c:188:9`! = (LEFT_INTVALcxx . . $ `src/asm/alu.c:188:9`! > RIGHT_INTVALcxx . . $ `src/asm/alu.c:189:9`!);
1150 goto handle_flags_and_dec_stacks;
1151
1152 case OPHANDLE_NOTEQUALcxx . . $ OPHANDLE_NOTEQUAL.:
1153 if((RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! | LEFT_FLAGScxx . . $ `src/asm/alu.c:186:9`!) & MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!) {
1154 ensure_int_from_fpcxx . . $ ensure_int_from_fp(d878ad36e69247c7).();
1155 LEFT_INTVALcxx . . $ `src/asm/alu.c:188:9`! = (LEFT_FPVALcxx . . $ `src/asm/alu.c:190:9`! != RIGHT_FPVALcxx . . $ `src/asm/alu.c:191:9`!);
1156 } else
1157 LEFT_INTVALcxx . . $ `src/asm/alu.c:188:9`! = (LEFT_INTVALcxx . . $ `src/asm/alu.c:188:9`! != RIGHT_INTVALcxx . . $ `src/asm/alu.c:189:9`!);
1158 goto handle_flags_and_dec_stacks;
1159
1160 case OPHANDLE_EQUALScxx . . $ OPHANDLE_EQUALS.:
1161 if((RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! | LEFT_FLAGScxx . . $ `src/asm/alu.c:186:9`!) & MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!) {
1162 ensure_int_from_fpcxx . . $ ensure_int_from_fp(d878ad36e69247c7).();
1163 LEFT_INTVALcxx . . $ `src/asm/alu.c:188:9`! = (LEFT_FPVALcxx . . $ `src/asm/alu.c:190:9`! == RIGHT_FPVALcxx . . $ `src/asm/alu.c:191:9`!);
1164 } else
1165 LEFT_INTVALcxx . . $ `src/asm/alu.c:188:9`! = (LEFT_INTVALcxx . . $ `src/asm/alu.c:188:9`! == RIGHT_INTVALcxx . . $ `src/asm/alu.c:189:9`!);
1166 goto handle_flags_and_dec_stacks;
1167
1168 case OPHANDLE_ANDcxx . . $ OPHANDLE_AND.:
1169 if((RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! | LEFT_FLAGScxx . . $ `src/asm/alu.c:186:9`!) & MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!)
1170 both_ensure_intcxx . . $ both_ensure_int(b45ddcbc8423892c).(TRUEcxx . . $ `src/asm/config.h:55:9`!);
1171 LEFT_INTVALcxx . . $ `src/asm/alu.c:188:9`! &= RIGHT_INTVALcxx . . $ `src/asm/alu.c:189:9`!;
1172 goto handle_flags_and_dec_stacks;
1173
1174 case OPHANDLE_EORcxx . . $ OPHANDLE_EOR.:
1175 Throw_first_pass_warningcxx . . $ Throw_first_pass_warning(85c52e162fed56f9).("\"EOR\" is deprecated; use \"XOR\" instead.");
1176 /*FALLTHROUGH*/
1177
1178 case OPHANDLE_XORcxx . . $ OPHANDLE_XOR.:
1179 if((RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! | LEFT_FLAGScxx . . $ `src/asm/alu.c:186:9`!) & MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!)
1180 both_ensure_intcxx . . $ both_ensure_int(b45ddcbc8423892c).(TRUEcxx . . $ `src/asm/config.h:55:9`!);
1181 LEFT_INTVALcxx . . $ `src/asm/alu.c:188:9`! ^= RIGHT_INTVALcxx . . $ `src/asm/alu.c:189:9`!;
1182 goto handle_flags_and_dec_stacks;
1183
1184 case OPHANDLE_ORcxx . . $ OPHANDLE_OR.:
1185 if((RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! | LEFT_FLAGScxx . . $ `src/asm/alu.c:186:9`!) & MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!)
1186 both_ensure_intcxx . . $ both_ensure_int(b45ddcbc8423892c).(TRUEcxx . . $ `src/asm/config.h:55:9`!);
1187 LEFT_INTVALcxx . . $ `src/asm/alu.c:188:9`! |= RIGHT_INTVALcxx . . $ `src/asm/alu.c:189:9`!;
1188 goto handle_flags_and_dec_stacks;
1189
1190 default:
1191 Bug_foundcxx . . $ Bug_found(34d26762b42c433a).("IllegalOperatorHandle", operator_stackcxx . . $ operator_stack.[operator_spcxx . . $ operator_sp.-2]->handlecxx . . $ operator_t#handle.);
1192 break;
1193
1194 // no other possibilities, so here are the shared endings
1195
1196 // entry point for dyadic operators
1197 handle_flags_and_dec_stacks:
1198 // Handle flags and decrement value stack pointer
1199 // "OR" EXISTS, UNSURE and FORCEBIT flags
1200 LEFT_FLAGScxx . . $ `src/asm/alu.c:186:9`! |= RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! &
1201 (MVALUE_EXISTScxx . . $ `src/asm/alu.h:20:9`!|MVALUE_UNSUREcxx . . $ `src/asm/alu.h:22:9`!|MVALUE_FORCEBITScxx . . $ `src/asm/alu.h:37:9`!);
1202 // "AND" DEFINED flag
1203 LEFT_FLAGScxx . . $ `src/asm/alu.c:186:9`! &= (RIGHT_FLAGScxx . . $ `src/asm/alu.c:187:9`! | ~MVALUE_DEFINEDcxx . . $ `src/asm/alu.h:27:9`!);
1204 LEFT_FLAGScxx . . $ `src/asm/alu.c:186:9`! &= ~MVALUE_ISBYTEcxx . . $ `src/asm/alu.h:29:9`!;// clear ISBYTE flag
1205 operand_spcxx . . $ operand_sp.--;
1206 /*FALLTHROUGH*/
1207
1208 // entry point for monadic operators
1209 remove_next_to_last_operator:
1210 // toplevel operation was something other than parentheses
1211 indirect_flagcxx . . $ indirect_flag. = 0;
1212 /*FALLTHROUGH*/
1213
1214 // entry point for '(' operator (has set indirect_flag, so don't clear now)
1215 RNTLObutDontTouchIndirectFlag:
1216 // Remove operator and shift down next one
1217 operator_stackcxx . . $ operator_stack.[operator_spcxx . . $ operator_sp.-2] = operator_stackcxx . . $ operator_stack.[operator_spcxx . . $ operator_sp.-1];
1218 operator_spcxx . . $ operator_sp.--;// decrement operator stack pointer
1219 break;
1220 }
1221 }
1222
1223 // The core of it. Returns number of parentheses left open.
1224 // FIXME - make state machine using function pointers? or too slow?
1225 static int parse_expressioncxx . . $ parse_expression(52717c57e950a302).(result_tcxx . . $ result_t#* result) {
1226 int open_parentheses = 0;
1227
1228 operator_spcxx . . $ operator_sp. = 0; // operator stack pointer
1229 operand_spcxx . . $ operand_sp. = 0; // value stack pointer
1230 // begin by reading value (or monadic operator)
1231 alu_statecxx . . $ alu_state. = STATE_EXPECT_OPERAND_OR_MONADIC_OPERATORcxx . . $ STATE_EXPECT_OPERAND_OR_MONADIC_OPERATOR.;
1232 indirect_flagcxx . . $ indirect_flag. = 0; // Contains either 0 or MVALUE_INDIRECT
1233 PUSH_OPERATORcxx . . $ `src/asm/alu.c:193:9`!(&ops_return);
1234 do {
1235 // check stack sizes. enlarge if needed
1236 if(operator_spcxx . . $ operator_sp. >= operator_stk_sizecxx . . $ operator_stk_size.)
1237 enlarge_operator_stackcxx . . $ enlarge_operator_stack(49f6e7a06ebc5aa8).();
1238 if(operand_spcxx . . $ operand_sp. >= operand_stk_sizecxx . . $ operand_stk_size.)
1239 enlarge_operand_stackcxx . . $ enlarge_operand_stack(49f6e7a06ebc5aa8).();
1240 switch(alu_statecxx . . $ alu_state.) {
1241
1242 case STATE_EXPECT_OPERAND_OR_MONADIC_OPERATORcxx . . $ STATE_EXPECT_OPERAND_OR_MONADIC_OPERATOR.:
1243 expect_operand_or_monadic_operatorcxx . . $ expect_operand_or_monadic_operator(49f6e7a06ebc5aa8).();
1244 break;
1245
1246 case STATE_EXPECT_DYADIC_OPERATORcxx . . $ STATE_EXPECT_DYADIC_OPERATOR.:
1247 expect_dyadic_operatorcxx . . $ expect_dyadic_operator(49f6e7a06ebc5aa8).();
1248 break;// no fallthrough; state might
1249 // have been changed to END or ERROR
1250
1251 case STATE_TRY_TO_REDUCE_STACKScxx . . $ STATE_TRY_TO_REDUCE_STACKS.:
1252 try_to_reduce_stackscxx . . $ try_to_reduce_stacks(11b0e290e57a7e53).(&open_parentheses);
1253 break;
1254
1255 case STATE_MAX_GO_ONcxx . . $ STATE_MAX_GO_ON.: // suppress
1256 case STATE_ERRORcxx . . $ STATE_ERROR.: // compiler
1257 case STATE_ENDcxx . . $ STATE_END.: // warnings
1258 break;
1259
1260 }
1261 } while(alu_statecxx . . $ alu_state. < STATE_MAX_GO_ONcxx . . $ STATE_MAX_GO_ON.);
1262 // done. check state.
1263 if(alu_statecxx . . $ alu_state. == STATE_ENDcxx . . $ STATE_END.) {
1264 // check for bugs
1265 if(operand_spcxx . . $ operand_sp. != 1)
1266 Bug_foundcxx . . $ Bug_found(34d26762b42c433a).("OperandStackNotEmpty", operand_spcxx . . $ operand_sp.);
1267 if(operator_spcxx . . $ operator_sp. != 1)
1268 Bug_foundcxx . . $ Bug_found(34d26762b42c433a).("OperatorStackNotEmpty", operator_spcxx . . $ operator_sp.);
1269 // copy result
1270 *result = operand_stackcxx . . $ operand_stack.[0];
1271 result->flagscxx . . $ result_t#flags. |= indirect_flagcxx . . $ indirect_flag.; // OR indirect flag
1272 // only allow *one* force bit
1273 if(result->flagscxx . . $ result_t#flags. & MVALUE_FORCE24cxx . . $ `src/asm/alu.h:31:9`!)
1274 result->flagscxx . . $ result_t#flags. &= ~(MVALUE_FORCE16cxx . . $ `src/asm/alu.h:33:9`! | MVALUE_FORCE08cxx . . $ `src/asm/alu.h:35:9`!);
1275 else if(result->flagscxx . . $ result_t#flags. & MVALUE_FORCE16cxx . . $ `src/asm/alu.h:33:9`!)
1276 result->flagscxx . . $ result_t#flags. &= ~MVALUE_FORCE08cxx . . $ `src/asm/alu.h:35:9`!;
1277 // if there was nothing to parse, mark as undefined
1278 // (so ALU_defined_int() can react)
1279 if((result->flagscxx . . $ result_t#flags. & MVALUE_EXISTScxx . . $ `src/asm/alu.h:20:9`!) == 0)
1280 result->flagscxx . . $ result_t#flags. &= ~MVALUE_DEFINEDcxx . . $ `src/asm/alu.h:27:9`!;
1281 // do some checks depending on int/float
1282 if(result->flagscxx . . $ result_t#flags. & MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!) {
1283 /*float*/ // if undefined, return zero
1284 if((result->flagscxx . . $ result_t#flags. & MVALUE_DEFINEDcxx . . $ `src/asm/alu.h:27:9`!) == 0)
1285 result->valcxx . . $ result_t#val..fpvalcxx . . $ result_t#$anonymous_type_0#fpval. = 0;
1286 // if value is sure, check to set ISBYTE
1287 else if(((result->flagscxx . . $ result_t#flags. & MVALUE_UNSUREcxx . . $ `src/asm/alu.h:22:9`!) == 0)
1288 && (result->valcxx . . $ result_t#val..fpvalcxx . . $ result_t#$anonymous_type_0#fpval. <= 255.0)
1289 && (result->valcxx . . $ result_t#val..fpvalcxx . . $ result_t#$anonymous_type_0#fpval. >= -128.0))
1290 result->flagscxx . . $ result_t#flags. |= MVALUE_ISBYTEcxx . . $ `src/asm/alu.h:29:9`!;
1291 } else {
1292 /*int*/ // if undefined, return zero
1293 if((result->flagscxx . . $ result_t#flags. & MVALUE_DEFINEDcxx . . $ `src/asm/alu.h:27:9`!) == 0)
1294 result->valcxx . . $ result_t#val..intvalcxx . . $ result_t#$anonymous_type_0#intval. = 0;
1295 // if value is sure, check to set ISBYTE
1296 else if(((result->flagscxx . . $ result_t#flags. & MVALUE_UNSUREcxx . . $ `src/asm/alu.h:22:9`!) == 0)
1297 && (result->valcxx . . $ result_t#val..intvalcxx . . $ result_t#$anonymous_type_0#intval. <= 255)
1298 && (result->valcxx . . $ result_t#val..intvalcxx . . $ result_t#$anonymous_type_0#intval. >= -128))
1299 result->flagscxx . . $ result_t#flags. |= MVALUE_ISBYTEcxx . . $ `src/asm/alu.h:29:9`!;
1300 }
1301 } else {
1302 // State is STATE_ERROR. But actually, nobody cares.
1303 // ...errors have already been reported anyway. :)
1304 }
1305 // return number of open (unmatched) parentheses
1306 return(open_parentheses);
1307 }
1308
1309 // These functions handle numerical expressions. There are operators for
1310 // arithmetic, logic, shift and comparison operations.
1311 // There are several different ways to call the core function:
1312 // intval_t ALU_any_int(void);
1313 // returns int value (0 if result was undefined)
1314 // intval_t ALU_defined_int(void);
1315 // returns int value
1316 // if result was undefined, serious error is thrown
1317 // void ALU_int_result(result_int_t*);
1318 // stores int value and flags (floats are transformed to int)
1319 // void ALU_any_result(result_t*);
1320 // stores value and flags (result may be either int or float)
1321 // int ALU_liberal_int(result_int_t*);
1322 // stores int value and flags. allows one '(' too many (for x-
1323 // indirect addressing). returns number of additional '(' (1 or 0).
1324 // bool ALU_optional_defined_int(intval_t*);
1325 // stores int value if given. Returns whether stored.
1326 // Throws error if undefined.
1327
1328 // return int value (if result is undefined, returns zero)
1329 // It the result's "exists" flag is clear (=empty expression), it throws an
1330 // error.
1331 // If the result's "defined" flag is clear, result_is_undefined() is called.
1332 intval_tcxx . . $ intval_t# ALU_any_intcxx . . $ ALU_any_int(da6335ded91d79c2).(void) {
1333 result_tcxx . . $ result_t# result;
1334
1335 if(parse_expressioncxx . . $ parse_expression(52717c57e950a302).(&result))
1336 Throw_errorcxx . . $ Throw_error(85c52e162fed56f9).(exception_paren_opencxx . . $ exception_paren_open.);
1337 if((result.flagscxx . . $ result_t#flags. & MVALUE_EXISTScxx . . $ `src/asm/alu.h:20:9`!) == 0)
1338 Throw_errorcxx . . $ Throw_error(85c52e162fed56f9).(exception_no_valuecxx . . $ exception_no_value.);
1339 else if((result.flagscxx . . $ result_t#flags. & MVALUE_DEFINEDcxx . . $ `src/asm/alu.h:27:9`!) == 0)
1340 result_is_undefinedcxx . . $ result_is_undefined.();
1341 if(result.flagscxx . . $ result_t#flags. & MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!)
1342 return(result.valcxx . . $ result_t#val..fpvalcxx . . $ result_t#$anonymous_type_0#fpval.);
1343 else
1344 return(result.valcxx . . $ result_t#val..intvalcxx . . $ result_t#$anonymous_type_0#intval.);
1345 }
1346
1347 // return int value (if result is undefined, serious error is thrown)
1348 intval_tcxx . . $ intval_t# ALU_defined_intcxx . . $ ALU_defined_int(da6335ded91d79c2).(void) {
1349 result_tcxx . . $ result_t# result;
1350
1351 if(parse_expressioncxx . . $ parse_expression(52717c57e950a302).(&result))
1352 Throw_errorcxx . . $ Throw_error(85c52e162fed56f9).(exception_paren_opencxx . . $ exception_paren_open.);
1353 if((result.flagscxx . . $ result_t#flags. & MVALUE_DEFINEDcxx . . $ `src/asm/alu.h:27:9`!) == 0)
1354 Throw_serious_errorcxx . . $ Throw_serious_error(85c52e162fed56f9).(exception_undefinedcxx . . $ exception_undefined.);
1355 if(result.flagscxx . . $ result_t#flags. & MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!)
1356 return(result.valcxx . . $ result_t#val..fpvalcxx . . $ result_t#$anonymous_type_0#fpval.);
1357 else
1358 return(result.valcxx . . $ result_t#val..intvalcxx . . $ result_t#$anonymous_type_0#intval.);
1359 }
1360
1361 // Store int value if given. Returns whether stored. Throws error if undefined.
1362 // This function needs either a defined value or no expression at all. So
1363 // empty expressions are accepted, but undefined ones are not.
1364 // If the result's "defined" flag is clear and the "exists" flag is set, it
1365 // throws a serious error and therefore stops assembly.
1366 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! ALU_optional_defined_intcxx . . $ ALU_optional_defined_int(c894b17f3c089378).(intval_tcxx . . $ intval_t#* target) {
1367 result_tcxx . . $ result_t# result;
1368
1369 if(parse_expressioncxx . . $ parse_expression(52717c57e950a302).(&result))
1370 Throw_errorcxx . . $ Throw_error(85c52e162fed56f9).(exception_paren_opencxx . . $ exception_paren_open.);
1371 if((result.flagscxx . . $ result_t#flags. & MVALUE_GIVENcxx . . $ `src/asm/alu.h:38:9`!) == MVALUE_EXISTScxx . . $ `src/asm/alu.h:20:9`!)
1372 Throw_serious_errorcxx . . $ Throw_serious_error(85c52e162fed56f9).(exception_undefinedcxx . . $ exception_undefined.);
1373 if((result.flagscxx . . $ result_t#flags. & MVALUE_EXISTScxx . . $ `src/asm/alu.h:20:9`!) == 0)
1374 return(FALSEcxx . . $ `src/asm/config.h:54:9`!);
1375 // something was given, so store
1376 if(result.flagscxx . . $ result_t#flags. & MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!)
1377 *target = result.valcxx . . $ result_t#val..fpvalcxx . . $ result_t#$anonymous_type_0#fpval.;
1378 else
1379 *target = result.valcxx . . $ result_t#val..intvalcxx . . $ result_t#$anonymous_type_0#intval.;
1380 return(TRUEcxx . . $ `src/asm/config.h:55:9`!);
1381 }
1382
1383 // Store int value and flags (floats are transformed to int)
1384 // It the result's "exists" flag is clear (=empty expression), it throws an
1385 // error.
1386 // If the result's "defined" flag is clear, result_is_undefined() is called.
1387 void ALU_int_resultcxx . . $ ALU_int_result(1ba379088691677b).(result_int_tcxx . . $ result_int_t#* intresult) {
1388 result_tcxx . . $ result_t# result;
1389
1390 if(parse_expressioncxx . . $ parse_expression(52717c57e950a302).(&result))
1391 Throw_errorcxx . . $ Throw_error(85c52e162fed56f9).(exception_paren_opencxx . . $ exception_paren_open.);
1392 if((result.flagscxx . . $ result_t#flags. & MVALUE_EXISTScxx . . $ `src/asm/alu.h:20:9`!) == 0)
1393 Throw_errorcxx . . $ Throw_error(85c52e162fed56f9).(exception_no_valuecxx . . $ exception_no_value.);
1394 else if((result.flagscxx . . $ result_t#flags. & MVALUE_DEFINEDcxx . . $ `src/asm/alu.h:27:9`!) == 0)
1395 result_is_undefinedcxx . . $ result_is_undefined.();
1396 if(result.flagscxx . . $ result_t#flags. & MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!) {
1397 intresult->intvalcxx . . $ result_int_t#intval. = result.valcxx . . $ result_t#val..fpvalcxx . . $ result_t#$anonymous_type_0#fpval.;
1398 intresult->flagscxx . . $ result_int_t#flags. = result.flagscxx . . $ result_t#flags. & ~MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!;
1399 } else {
1400 intresult->intvalcxx . . $ result_int_t#intval. = result.valcxx . . $ result_t#val..intvalcxx . . $ result_t#$anonymous_type_0#intval.;
1401 intresult->flagscxx . . $ result_int_t#flags. = result.flagscxx . . $ result_t#flags.;
1402 }
1403 }
1404
1405 // Store int value and flags.
1406 // This function allows for one '(' too many. Needed when parsing indirect
1407 // addressing modes where internal indices have to be possible. Returns number
1408 // of parentheses still open (either 0 or 1).
1409 int ALU_liberal_intcxx . . $ ALU_liberal_int(ee210d144587f61c).(result_int_tcxx . . $ result_int_t#* intresult) {
1410 result_tcxx . . $ result_t# result;
1411 int parentheses_still_open;
1412
1413 parentheses_still_open = parse_expressioncxx . . $ parse_expression(52717c57e950a302).(&result);
1414 if(parentheses_still_open > 1) {
1415 parentheses_still_open = 0;
1416 Throw_errorcxx . . $ Throw_error(85c52e162fed56f9).(exception_paren_opencxx . . $ exception_paren_open.);
1417 }
1418 if((result.flagscxx . . $ result_t#flags. & MVALUE_EXISTScxx . . $ `src/asm/alu.h:20:9`!)
1419 && ((result.flagscxx . . $ result_t#flags. & MVALUE_DEFINEDcxx . . $ `src/asm/alu.h:27:9`!) == 0))
1420 result_is_undefinedcxx . . $ result_is_undefined.();
1421 if(result.flagscxx . . $ result_t#flags. & MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!) {
1422 intresult->intvalcxx . . $ result_int_t#intval. = result.valcxx . . $ result_t#val..fpvalcxx . . $ result_t#$anonymous_type_0#fpval.;
1423 intresult->flagscxx . . $ result_int_t#flags. = result.flagscxx . . $ result_t#flags. & ~MVALUE_IS_FPcxx . . $ `src/asm/alu.h:16:9`!;
1424 } else {
1425 intresult->intvalcxx . . $ result_int_t#intval. = result.valcxx . . $ result_t#val..intvalcxx . . $ result_t#$anonymous_type_0#intval.;
1426 intresult->flagscxx . . $ result_int_t#flags. = result.flagscxx . . $ result_t#flags.;
1427 }
1428 return(parentheses_still_open);
1429 }
1430
1431 // Store value and flags (result may be either int or float)
1432 // It the result's "exists" flag is clear (=empty expression), it throws an
1433 // error.
1434 // If the result's "defined" flag is clear, result_is_undefined() is called.
1435 void ALU_any_resultcxx . . $ ALU_any_result(64a63ef514ec9b8a).(result_tcxx . . $ result_t#* result) {
1436 if(parse_expressioncxx . . $ parse_expression(52717c57e950a302).(result))
1437 Throw_errorcxx . . $ Throw_error(85c52e162fed56f9).(exception_paren_opencxx . . $ exception_paren_open.);
1438 if((result->flagscxx . . $ result_t#flags. & MVALUE_EXISTScxx . . $ `src/asm/alu.h:20:9`!) == 0)
1439 Throw_errorcxx . . $ Throw_error(85c52e162fed56f9).(exception_no_valuecxx . . $ exception_no_value.);
1440 else if((result->flagscxx . . $ result_t#flags. & MVALUE_DEFINEDcxx . . $ `src/asm/alu.h:27:9`!) == 0)
1441 result_is_undefinedcxx . . $ result_is_undefined.();
1442 }