| 1 | // |
| 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 | // ALU stuff (the expression parser) |
| 7 | #ifndef alu_H |
| 8 | #define alu_H |
| 9 | |
| 10 | #include "config.h" |
| 11 | |
| 12 | |
| 13 | // Constants |
| 14 | |
| 15 | // Meaning of bits in "flags" of result_t and result_int_t structures: |
| 16 | #define MVALUE_IS_FP (1u << 8) |
| 17 | // Floating point value (never set in result_int_t) |
| 18 | #define MVALUE_INDIRECT (1u << 7) |
| 19 | // Needless parentheses indicate use of indirect addressing modes |
| 20 | #define MVALUE_EXISTS (1u << 6) |
| 21 | // 0: expression was empty. 1: there was *something* to parse. |
| 22 | #define MVALUE_UNSURE (1u << 5) |
| 23 | // Value once was related to undefined expression. Needed for producing |
| 24 | // the same addresses in all passes; because in the first pass there |
| 25 | // will almost for sure be labels that are undefined, you can't simply |
| 26 | // get the addressing mode from looking at the parameter's value. |
| 27 | #define MVALUE_DEFINED (1u << 4) |
| 28 | // 0: undefined expression (value will be zero). 1: known result |
| 29 | #define MVALUE_ISBYTE (1u << 3) |
| 30 | // Value is guaranteed to fit in one byte |
| 31 | #define MVALUE_FORCE24 (1u << 2) |
| 32 | // Value usage forces 24-bit usage |
| 33 | #define MVALUE_FORCE16 (1u << 1) |
| 34 | // Value usage forces 16-bit usage |
| 35 | #define MVALUE_FORCE08 (1u << 0) |
| 36 | // Value usage forces 8-bit usage |
| 37 | #define MVALUE_FORCEBITS (MVALUE_FORCE08|MVALUE_FORCE16|MVALUE_FORCE24) |
| 38 | #define MVALUE_GIVEN (MVALUE_DEFINED | MVALUE_EXISTS) |
| 39 | // Bit mask for fixed values (defined and existing) |
| 40 | |
| 41 | |
| 42 | // Prototypes |
| 43 | |
| 44 | // create dynamic buffer, operator/function trees and operator/operand stacks |
| 45 | extern void ALU_init(void); |
| 46 | // Activate error output for "value undefined" |
| 47 | extern void ALU_throw_errors(void); |
| 48 | // returns int value (0 if result was undefined) |
| 49 | extern intval_t ALU_any_int(void); |
| 50 | // returns int value (if result was undefined, serious error is thrown) |
| 51 | extern intval_t ALU_defined_int(void); |
| 52 | // stores int value if given. Returns whether stored. Throws error if undefined. |
| 53 | extern bool ALU_optional_defined_int(intval_t*); |
| 54 | // stores int value and flags (floats are transformed to int) |
| 55 | extern void ALU_int_result(result_int_t*); |
| 56 | // stores int value and flags, allowing for one '(' too many (x-indirect addr) |
| 57 | extern int ALU_liberal_int(result_int_t*); |
| 58 | // stores value and flags (result may be either int or float) |
| 59 | extern void ALU_any_result(result_t*); |
| 60 | |
| 61 | |
| 62 | #endif |