145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org/* nasm.h main header file for the Netwide Assembler: inter-module interface 245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * 345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * The Netwide Assembler is copyright (C) 1996 Simon Tatham and 445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * Julian Hall. All rights reserved. The software is 545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * redistributable under the licence given in the file "Licence" 645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * distributed in the NASM archive. 745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * 845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * initial version: 27/iii/95 by Simon Tatham 945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org */ 1045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#ifndef YASM_NASM_H 1145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#define YASM_NASM_H 1245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 1345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#ifndef NULL 1445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#define NULL 0 1545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#endif 1645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 1745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#ifndef FALSE 1845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#define FALSE 0 /* comes in handy */ 1945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#endif 2045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#ifndef TRUE 2145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#define TRUE 1 2245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#endif 2345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 2445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#ifndef FILENAME_MAX 2545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#define FILENAME_MAX 256 2645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#endif 2745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 2845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#ifndef PREFIX_MAX 2945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#define PREFIX_MAX 10 3045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#endif 3145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 3245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#ifndef POSTFIX_MAX 3345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#define POSTFIX_MAX 10 3445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#endif 3545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 3645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#define IDLEN_MAX 4096 3745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 3845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org/* 3945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * ------------------------- 4045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * Error reporting functions 4145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * ------------------------- 4245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org */ 4345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 4445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org/* 4545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * An error reporting function should look like this. 4645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org */ 4745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgtypedef void (*efunc) (int severity, const char *fmt, ...); 4845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 4945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org/* 5045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * These are the error severity codes which get passed as the first 5145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * argument to an efunc. 5245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org */ 5345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 5445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#define ERR_DEBUG 0x00000008 /* put out debugging message */ 5545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#define ERR_WARNING 0x00000000 /* warn only: no further action */ 5645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#define ERR_NONFATAL 0x00000001 /* terminate assembly after phase */ 5745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#define ERR_FATAL 0x00000002 /* instantly fatal: exit with error */ 5845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#define ERR_PANIC 0x00000003 /* internal error: panic instantly 5945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * and dump core for reference */ 6045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#define ERR_MASK 0x0000000F /* mask off the above codes */ 6145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#define ERR_NOFILE 0x00000010 /* don't give source file name/line */ 6245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#define ERR_USAGE 0x00000020 /* print a usage message */ 6345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#define ERR_PASS1 0x00000040 /* only print this error on pass one */ 6445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 6545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org/* 6645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * These codes define specific types of suppressible warning. 6745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org */ 6845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 6945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#define ERR_WARN_MASK 0x0000FF00 /* the mask for this feature */ 7045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#define ERR_WARN_SHR 8 /* how far to shift right */ 7145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 7245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#define ERR_WARN_MNP 0x00000100 /* macro-num-parameters warning */ 7345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#define ERR_WARN_MSR 0x00000200 /* macro self-reference */ 7445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#define ERR_WARN_OL 0x00000300 /* orphan label (no colon, and 7545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * alone on line) */ 7645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#define ERR_WARN_NOV 0x00000400 /* numeric overflow */ 7745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#define ERR_WARN_GNUELF 0x00000500 /* using GNU ELF extensions */ 7845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#define ERR_WARN_MAX 5 /* the highest numbered one */ 7945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 8045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org/* 8145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * ----------------------- 8245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * Other function typedefs 8345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * ----------------------- 8445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org */ 8545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 8645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org/* 8745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * List-file generators should look like this: 8845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org */ 8945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgtypedef struct { 9045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org /* 9145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * Called to initialise the listing file generator. Before this 9245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * is called, the other routines will silently do nothing when 9345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * called. The `char *' parameter is the file name to write the 9445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * listing to. 9545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org */ 9645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org void (*init) (char *, efunc); 9745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 9845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org /* 9945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * Called to clear stuff up and close the listing file. 10045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org */ 10145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org void (*cleanup) (void); 10245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 10345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org /* 10445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * Called to output binary data. Parameters are: the offset; 10545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * the data; the data type. Data types are similar to the 10645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * output-format interface, only OUT_ADDRESS will _always_ be 10745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * displayed as if it's relocatable, so ensure that any non- 10845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * relocatable address has been converted to OUT_RAWDATA by 10945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * then. Note that OUT_RAWDATA+0 is a valid data type, and is a 11045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * dummy call used to give the listing generator an offset to 11145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * work with when doing things like uplevel(LIST_TIMES) or 11245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * uplevel(LIST_INCBIN). 11345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org */ 11445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org void (*output) (long, const void *, unsigned long); 11545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 11645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org /* 11745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * Called to send a text line to the listing generator. The 11845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * `int' parameter is LIST_READ or LIST_MACRO depending on 11945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * whether the line came directly from an input file or is the 12045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * result of a multi-line macro expansion. 12145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org */ 12245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org void (*line) (int, char *); 12345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 12445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org /* 12545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * Called to change one of the various levelled mechanisms in 12645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * the listing generator. LIST_INCLUDE and LIST_MACRO can be 12745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * used to increase the nesting level of include files and 12845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * macro expansions; LIST_TIMES and LIST_INCBIN switch on the 12945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * two binary-output-suppression mechanisms for large-scale 13045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * pseudo-instructions. 13145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * 13245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * LIST_MACRO_NOLIST is synonymous with LIST_MACRO except that 13345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * it indicates the beginning of the expansion of a `nolist' 13445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * macro, so anything under that level won't be expanded unless 13545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * it includes another file. 13645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org */ 13745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org void (*uplevel) (int); 13845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 13945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org /* 14045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * Reverse the effects of uplevel. 14145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org */ 14245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org void (*downlevel) (int); 14345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org} ListGen; 14445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 14545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org/* 14645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * The expression evaluator must be passed a scanner function; a 14745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * standard scanner is provided as part of nasmlib.c. The 14845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * preprocessor will use a different one. Scanners, and the 14945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * token-value structures they return, look like this. 15045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * 15145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * The return value from the scanner is always a copy of the 15245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * `t_type' field in the structure. 15345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org */ 15445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgstruct tokenval { 15545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org int t_type; 15645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org yasm_intnum *t_integer, *t_inttwo; 15745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org char *t_charptr; 15845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org}; 15945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgtypedef int (*scanner) (void *private_data, struct tokenval *tv); 16045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 16145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org/* 16245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * Token types returned by the scanner, in addition to ordinary 16345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * ASCII character values, and zero for end-of-string. 16445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org */ 16545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgenum { /* token types, other than chars */ 16645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org TOKEN_INVALID = -1, /* a placeholder value */ 16745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org TOKEN_EOS = 0, /* end of string */ 16845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org TOKEN_EQ = '=', TOKEN_GT = '>', TOKEN_LT = '<', /* aliases */ 16945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org TOKEN_ID = 256, TOKEN_NUM, TOKEN_REG, TOKEN_INSN, /* major token types */ 17045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org TOKEN_ERRNUM, /* numeric constant with error in */ 17145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org TOKEN_HERE, TOKEN_BASE, /* $ and $$ */ 17245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org TOKEN_SPECIAL, /* BYTE, WORD, DWORD, FAR, NEAR, etc */ 17345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org TOKEN_PREFIX, /* A32, O16, LOCK, REPNZ, TIMES, etc */ 17445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org TOKEN_SHL, TOKEN_SHR, /* << and >> */ 17545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org TOKEN_SDIV, TOKEN_SMOD, /* // and %% */ 17645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org TOKEN_GE, TOKEN_LE, TOKEN_NE, /* >=, <= and <> (!= is same as <>) */ 17745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org TOKEN_DBL_AND, TOKEN_DBL_OR, TOKEN_DBL_XOR, /* &&, || and ^^ */ 17845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org TOKEN_SEG, TOKEN_WRT, /* SEG and WRT */ 17945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org TOKEN_FLOAT /* floating-point constant */ 18045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org}; 18145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 18245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org/* 18345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * The actual expression evaluator function looks like this. When 18445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * called, it expects the first token of its expression to already 18545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * be in `*tv'; if it is not, set tv->t_type to TOKEN_INVALID and 18645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * it will start by calling the scanner. 18745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * 18845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * `critical' is non-zero if the expression may not contain forward 18945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * references. The evaluator will report its own error if this 19045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * occurs; if `critical' is 1, the error will be "symbol not 19145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * defined before use", whereas if `critical' is 2, the error will 19245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * be "symbol undefined". 19345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * 19445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * If `critical' has bit 8 set (in addition to its main value: 0x101 19545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * and 0x102 correspond to 1 and 2) then an extended expression 19645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * syntax is recognised, in which relational operators such as =, < 19745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * and >= are accepted, as well as low-precedence logical operators 19845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * &&, ^^ and ||. 19945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org */ 20045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#define CRITICAL 0x100 20145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgtypedef yasm_expr *(*evalfunc) (scanner sc, void *scprivate, struct tokenval *tv, 20245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org int critical, efunc error); 20345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 20445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org/* 20545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * Preprocessors ought to look like this: 20645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org */ 20745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgtypedef struct { 20845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org /* 20945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * Called at the start of a pass; given a file name, the number 21045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * of the pass, an error reporting function, an evaluator 21145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * function, and a listing generator to talk to. 21245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org */ 21345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org void (*reset) (FILE *, const char *, int, efunc, evalfunc, ListGen *); 21445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 21545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org /* 21645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * Called to fetch a line of preprocessed source. The line 21745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * returned has been malloc'ed, and so should be freed after 21845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * use. 21945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org */ 22045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org char *(*getline) (void); 22145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 22245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org /* 22345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * Called at the end of a pass. 22445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org */ 22545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org void (*cleanup) (int); 22645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org} Preproc; 22745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 22845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org/* 22945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * ---------------------------------------------------------------- 23045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * Some lexical properties of the NASM source language, included 23145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * here because they are shared between the parser and preprocessor 23245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * ---------------------------------------------------------------- 23345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org */ 23445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 23545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org/* 23645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * isidstart matches any character that may start an identifier, and isidchar 23745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * matches any character that may appear at places other than the start of an 23845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * identifier. E.g. a period may only appear at the start of an identifier 23945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * (for local labels), whereas a number may appear anywhere *but* at the 24045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * start. 24145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org */ 24245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 24345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#define isidstart(c) ( isalpha(c) || (c)=='_' || (c)=='.' || (c)=='?' \ 24445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org || (c)=='@' ) 24545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#define isidchar(c) ( isidstart(c) || isdigit(c) || (c)=='$' || (c)=='#' \ 24645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org || (c)=='~' ) 24745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 24845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org/* Ditto for numeric constants. */ 24945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 25045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#define isnumstart(c) ( isdigit(c) || (c)=='$' ) 25145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#define isnumchar(c) ( isalnum(c) ) 25245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 25345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org/* This returns the numeric value of a given 'digit'. */ 25445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 25545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#define numvalue(c) ((c)>='a' ? (c)-'a'+10 : (c)>='A' ? (c)-'A'+10 : (c)-'0') 25645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 25745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org/* 25845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * Data-type flags that get passed to listing-file routines. 25945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org */ 26045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgenum { 26145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org LIST_READ, LIST_MACRO, LIST_MACRO_NOLIST, LIST_INCLUDE, 26245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org LIST_INCBIN, LIST_TIMES 26345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org}; 26445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 26545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org/* 26645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * ----- 26745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * Other 26845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * ----- 26945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org */ 27045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 27145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org/* 27245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * This is a useful #define which I keep meaning to use more often: 27345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * the number of elements of a statically defined array. 27445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org */ 27545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 27645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#define elements(x) ( sizeof(x) / sizeof(*(x)) ) 27745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 27845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgextern int tasm_compatible_mode; 27945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgextern int tasm_locals; 28045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgextern const char *tasm_segment; 28145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgconst char *tasm_get_segment_register(const char *segment); 28245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 28345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#endif 284