| 1 | //cxx . . $ `<file>/src/asm/input.h`/ |
| 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 | // Input stuff |
| 7 | #ifndef input_H |
| 8 | #define input_Hcxx . . $ `src/asm/input.h:8:9`! |
| 9 | |
| 10 | #include <stdio.h> |
| 11 | #include <string.h> |
| 12 | |
| 13 | // type definitions |
| 14 | |
| 15 | // values for input_t component "Src.State" |
| 16 | enum inputstate_tcxx . . $ inputstate_t# { |
| 17 | INPUTSTATE_NORMALcxx . . $ INPUTSTATE_NORMAL., // everything's fine |
| 18 | INPUTSTATE_AGAINcxx . . $ INPUTSTATE_AGAIN., // re-process last byte |
| 19 | INPUTSTATE_SKIPBLANKScxx . . $ INPUTSTATE_SKIPBLANKS., // shrink multiple spaces |
| 20 | INPUTSTATE_LFcxx . . $ INPUTSTATE_LF., // send start-of-line after end-of-statement |
| 21 | INPUTSTATE_CRcxx . . $ INPUTSTATE_CR., // same, but also remember to skip LF |
| 22 | INPUTSTATE_SKIPLFcxx . . $ INPUTSTATE_SKIPLF., // skip LF if that's next |
| 23 | INPUTSTATE_COMMENTcxx . . $ INPUTSTATE_COMMENT., // skip characters until newline or EOF |
| 24 | INPUTSTATE_EOBcxx . . $ INPUTSTATE_EOB., // send end-of-block after end-of-statement |
| 25 | INPUTSTATE_EOFcxx . . $ INPUTSTATE_EOF., // send end-of-file after end-of-statement |
| 26 | }; |
| 27 | |
| 28 | |
| 29 | |
| 30 | typedef structcxx . . $ $anonymous_type_5e15f442b66098d4_0# { |
| 31 | const char* original_filenamecxx . . $ $anonymous_type_5e15f442b66098d4_0#original_filename.;// during RAM reads, too |
| 32 | int line_numbercxx . . $ $anonymous_type_5e15f442b66098d4_0#line_number.; // in file (on RAM reads, too) |
| 33 | boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! source_is_ramcxx . . $ $anonymous_type_5e15f442b66098d4_0#source_is_ram.; // TRUE if RAM, FALSE if file |
| 34 | enum inputstate_tcxx . . $ inputstate_t# statecxx . . $ $anonymous_type_5e15f442b66098d4_0#state.; // state of input |
| 35 | unioncxx . . $ $anonymous_type_5e15f442b66098d4_0#$anonymous_type_1# { |
| 36 | FILEcxx . . $ FILE#* fdcxx . . $ $anonymous_type_5e15f442b66098d4_0#$anonymous_type_1#fd.; // file descriptor |
| 37 | char* ram_ptrcxx . . $ $anonymous_type_5e15f442b66098d4_0#$anonymous_type_1#ram_ptr.; // RAM read ptr (loop or macro block) |
| 38 | } srccxx . . $ $anonymous_type_5e15f442b66098d4_0#src.; |
| 39 | char *string_sourcecxx . . $ $anonymous_type_5e15f442b66098d4_0#string_source.; |
| 40 | int string_source_lengthcxx . . $ $anonymous_type_5e15f442b66098d4_0#string_source_length.; |
| 41 | int string_source_positioncxx . . $ $anonymous_type_5e15f442b66098d4_0#string_source_position.; |
| 42 | } input_tcxx . . $ input_t#; |
| 43 | |
| 44 | // Constants |
| 45 | extern const char FILE_READBINARYcxx . . $ FILE_READBINARY.[]; |
| 46 | // Special characters |
| 47 | // The program *heavily* relies on CHAR_EOS (end of statement) being 0x00! |
| 48 | #define CHAR_EOScxx . . $ `src/asm/input.h:48:9`! (0) // end of statement (in high-level format) |
| 49 | #define CHAR_SOBcxx . . $ `src/asm/input.h:49:9`! '{' // start of block |
| 50 | #define CHAR_EOBcxx . . $ `src/asm/input.h:50:9`! '}' // end of block |
| 51 | #define CHAR_SOLcxx . . $ `src/asm/input.h:51:9`! (10) // start of line (in high-level format) |
| 52 | #define CHAR_EOFcxx . . $ `src/asm/input.h:52:9`! (13) // end of file (in high-level format) |
| 53 | // If the characters above are changed, don't forget to adjust Byte_flags[]! |
| 54 | |
| 55 | |
| 56 | // Variables |
| 57 | extern input_tcxx . . $ input_t#* Input_nowcxx . . $ Input_now.; // current input structure |
| 58 | |
| 59 | |
| 60 | // Prototypes |
| 61 | |
| 62 | // register pseudo opcodes |
| 63 | extern void Input_initcxx . . $ Input_init(49f6e7a06ebc5aa8).(void); |
| 64 | // Let current input point to start of file |
| 65 | extern void Input_new_filecxx . . $ Input_new_file(fda57c8427c60377).(char *); |
| 66 | // get next byte from currently active byte source in shortened high-level |
| 67 | // format. When inside quotes, use GetQuotedByte() instead! |
| 68 | extern char GetBytecxx . . $ GetByte(6e9c618e4dd2eafc).(void); |
| 69 | // get next byte from currently active byte source in un-shortened high-level |
| 70 | // format. Complains if CHAR_EOS (end of statement) is read. |
| 71 | extern char GetQuotedBytecxx . . $ GetQuotedByte(6e9c618e4dd2eafc).(void); |
| 72 | // Skip remainder of statement, for example on error |
| 73 | extern void Input_skip_remaindercxx . . $ Input_skip_remainder(49f6e7a06ebc5aa8).(void); |
| 74 | // Ensure that the remainder of the current statement is empty, for example |
| 75 | // after mnemonics using implied addressing. |
| 76 | extern void Input_ensure_EOScxx . . $ Input_ensure_EOS(49f6e7a06ebc5aa8).(void); |
| 77 | // Skip or store block (starting with next byte, so call directly after |
| 78 | // reading opening brace). |
| 79 | // If "Store" is TRUE, the block is read into GlobalDynaBuf, then a copy |
| 80 | // is made and a pointer to that is returned. |
| 81 | // If "Store" is FALSE, NULL is returned. |
| 82 | // After calling this function, GotByte holds '}'. Unless EOF was found first, |
| 83 | // but then a serious error would have been thrown. |
| 84 | extern char* Input_skip_or_store_blockcxx . . $ Input_skip_or_store_block(cd68a792b21c61df).(boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! store); |
| 85 | // Read bytes and add to GlobalDynaBuf until the given terminator (or CHAR_EOS) |
| 86 | // is found. Act upon single and double quotes by entering (and leaving) quote |
| 87 | // mode as needed (So the terminator does not terminate when inside quotes). |
| 88 | extern void Input_until_terminatorcxx . . $ Input_until_terminator(44b6ea1973a07080).(char terminator); |
| 89 | // Append to GlobalDynaBuf while characters are legal for keywords. |
| 90 | // Throws "missing string" error if none. Returns number of characters added. |
| 91 | extern int Input_append_keyword_to_global_dynabufcxx . . $ Input_append_keyword_to_global_dynabuf(b126dc7c1de90089).(void); |
| 92 | // Check whether GotByte is a dot. |
| 93 | // If not, store global zone value. |
| 94 | // If yes, store current zone value and read next byte. |
| 95 | // Then jump to Input_read_keyword(), which returns length of keyword. |
| 96 | extern int Input_read_zone_and_keywordcxx . . $ Input_read_zone_and_keyword(4ebf403dd87dd80).(zone_tcxx . . $ zone_t#*); |
| 97 | // Clear dynamic buffer, then append to it until an illegal (for a keyword) |
| 98 | // character is read. Zero-terminate the string. Return its length (without |
| 99 | // terminator). |
| 100 | // Zero lengths will produce a "missing string" error. |
| 101 | extern int Input_read_keywordcxx . . $ Input_read_keyword(b126dc7c1de90089).(void); |
| 102 | // Clear dynamic buffer, then append to it until an illegal (for a keyword) |
| 103 | // character is read. Zero-terminate the string, then convert to lower case. |
| 104 | // Return its length (without terminator). |
| 105 | // Zero lengths will produce a "missing string" error. |
| 106 | extern int Input_read_and_lower_keywordcxx . . $ Input_read_and_lower_keyword(b126dc7c1de90089).(void); |
| 107 | // Try to read a file name. If "allow_library" is TRUE, library access by using |
| 108 | // <...> quoting is possible as well. The file name given in the assembler |
| 109 | // source code is converted from UNIX style to platform style. |
| 110 | // Returns whether error occurred (TRUE on error). Filename in GlobalDynaBuf. |
| 111 | // Errors are handled and reported, but caller should call |
| 112 | // Input_skip_remainder() then. |
| 113 | extern boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! Input_read_filenamecxx . . $ Input_read_filename(efaadfb7dc14930a).(boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! library_allowed); |
| 114 | // Try to read a comma, skipping spaces before and after. Return TRUE if comma |
| 115 | // found, otherwise FALSE. |
| 116 | extern boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! Input_accept_commacxx . . $ Input_accept_comma(c9857a73d68e59ba).(void); |
| 117 | // read optional info about parameter length |
| 118 | extern int Input_get_force_bitcxx . . $ Input_get_force_bit(b126dc7c1de90089).(void); |
| 119 | |
| 120 | |
| 121 | #endif |