#title "Bastard Defines & Data"
	/* ----------- Bastard Constants & Variables --------- */
	struct DISASM_ENV {
	char	  home[128];
	char    p1[16];
	char    p2[16];
	char    p3[16];
	char    p4[16];
    int     flags;
	};
   
	struct DISASM_TGT {
	int     FD;
	int     image;
	int     size;
	int     entry;
	int     cpu;
	char    format[16];
	char    *header;
	char    name[64];
	char    path[128];
	char    dbname[256];
	};


	import DISASM_ENV disasm_env;
	import DISASM_TGT target;
	export main;
   
/* bastard.h constants */
#define DB_LOADED       0x00000001        /* .bdb loaded */
#define TGT_MAPPED      0x00000002        /* target bin image mmap'ed */
#define DB_MOD          0x00000004        /* .bdb has been modified */
#define TGT MOD         0x00000008        /* target bin image modified */
#define PASS_1          0x00000010        /* main disassembly pass */
#define PASS_2          0x00000020        /* subsequent passes */
#define CODE_INT        0x00000040        /* intermediate code rep is done */
#define CODE_FIN        0x00000080        /* final code rep is done */
#define PAGINATE        0x00000100
#define QUIET           0x00001000  /* print std msgs to STDOUT */
#define ANNOY_USER      0x00002000  /* bug user with save prompts, etc */
#define DISABLE_EXEC    0x00010000  /* do not allow shell escapes */
#define DEBUG_LIB       0x00020000  /* use SeeR debugging */

/* api.h constants */

 /* SECTION types and permissions */
#define SECTION_HDR     0x1000
#define SECTION_CODE 0x1100
#define SECTION_DATA 0x1200
#define SECTION_RSRC 0x1300
#define SECTION_IMPORT  0x1400
#define SECTION_EXPORT  0x1500
#define SECTION_DEBUG   0x1600
#define SECTION_CMT     0x1700
#define SECTION_RELOC   0x1800
#define SECTION_EXECUTE 0x01
#define SECTION_WRITE   0x02
#define SECTION_READ 0x04
	 /* ADDRESS types and permissions */
#define ADDR_CODE    0x01
#define ADDR_DATA    0x02
#define ADDR_IMPORT     0x10
#define ADDR_EXPORT     0x20
#define ADDR_SECTION 0x40
#define ADDR_STRUCT     0x100
#define ADDR_STRING     0x200
#define ADDR_FUNCTION   0x300
#define ADDR_INLINE     0x400
#define ADDR_NAME    0x1000
#define ADDR_COMMENT 0x2000
#define ADDR_SYMBOL  0x4000
 /* Operand and instruction types */
#define OP_R         0x001    /* operand is READ */
#define OP_W         0x002    /* operand is WRITTEN */
#define OP_X         0x004    /* operand is EXECUTED */
#define OP_REG       0x100    /* register */
#define OP_IMM       0x200    /* immediate value */
#define OP_IND       0x300    /* indirect memory reference */
#define OP_BPTR      0x400    /* BYTE Pointer */
#define OP_WPTR      0x500    /* WORD Pointer */
#define OP_DPTR      0x600    /* DWORD Pointer */
#define OP_UNK       0x900
#define INS_BRANCH   0x01     /* Unconditional branch */
#define INS_COND     0x02     /* Conditional branch */
#define INS_SUB      0x04     /* Jump to subroutine */
#define INS_RET      0x08     /* Return from subroutine */
	    /* modify ( 'w' ) instructions */
#define INS_ARITH    0x10     /* Arithmetic inst */
#define INS_LOGIC    0x20     /* logical inst */
#define INS_FPU      0x40     /* Floating Point inst */
#define INS_FLAG     0x80     /* Modify flags */
	    /* misc Instruction Types */
#define INS_MOVE     0x0100
#define INS_ARRAY    0x0200   /* String and XLAT ops */
#define INS_PTR      0x0400   /* Load EA/pointer */
#define INS_STACK    0x1000   /* PUSH, POP, etc */
#define INS_FRAME    0x2000   /* ENTER, LEAVE, etc */
#define INS_SYSTEM   0x4000   /* CPUID, WBINVD, etc */
   /* Xref Types */
#define XREF_READ    0x01
#define XREF_WRITE   0x02
#define XREF_EXEC    0x04
	   /* Name Types */
#define NAME_AUTO    0x01
#define NAME_SUB     0x02
#define NAME_USER    0x10
#define NAME_SYMBOL  0x20
	   /* Comment Types */
#define CMT_AUTO     0x01
#define CMT_USER     0x02
	   /* Macro Types */
#define SEERC_CODE   0x01
#define SEERC_FILE   0x02
	 /* Other info */
#define BIG_ENDIAN_ORDER 0
#define LITTLE_ENDIAN_ORDER 1

	/* db.h constants */
/*---------- record names ----------*/
#define ADDRESS 1000
#define SECTION 2000
#define XREF 3000
#define CODE 4000
#define INT_CODE 5000
#define FIN_CODE 6000
#define EXPORT 7000
#define IMPORT 8000
#define LIB 9000
#define STRING 10000
#define NAME 11000
#define COMMENT 12000
#define FUNCTION 13000
#define FUNC_PARAM 14000
#define FUNC_LOCAL 15000
#define F_INLINE 16000
#define INLINE_TYPE 17000
#define STRUCTURE 18000
#define STRUCT_MEMBER 19000
#define DATA_TYPE 20000
#define CONSTANT 21000
#define SEER_MACRO 22000
/* ---------- Index Names ------------*/
#define ADDRESS_RVA 1001
#define PA 1002
#define ADDRESS_SIZE 1003
#define ADDRESS_FLAGS 1004
#define DATACONST 1005
#define ADDRESS_STRUCTURE 1006
#define ADDRESS_COMMENT 1007
#define SECTION_NAME 2001
#define SECTION_RVA 2002
#define SECTION_SIZE 2003
#define SECTION_FLAGS 2004
#define XREF_ID 3001
#define FROM_RVA 3002
#define TO_RVA 3003
#define XREF_TYPE 3004
#define CODE_RVA 4001
#define CODE_FLAGS 4002
#define MNEMONIC 4003
#define DEST 4004
#define SRC 4005
#define AUX 4006
#define MNEMTYPE 4007
#define DESTTYPE 4008
#define SRCTYPE 4009
#define AUXTYPE 4010
#define DESTCONST 4011
#define SRCCONST 4012
#define AUXCONST 4013
#define INT_CODE_ID 5001
#define INT_CODE_RVA 5002
#define INT_CODE_SIZE 5003
#define LVALUE 5004
#define RVALUE 5005
#define FIN_CODE_ID 6001
#define FIN_CODE_RVA 6002
#define FIN_CODE_SIZE 6003
#define LINE 6004
#define EXPORT_RVA 7001
#define EXPORT_NAME 7002
#define LIBRARY 8001
#define IMPORT_NAME 8002
#define IMPORT_TYPE 8003
#define IMPORT_RVA 8004
#define LIB_ID 9001
#define LIB_NAME 9002
#define VER_HI 9003
#define VER_LO 9004
#define STRING_RVA 10001
#define LENGTH 10002
#define STRING_TEXT 10003
#define NAME_RVA 11001
#define NAME_TYPE 11002
#define NAME_NAME 11003
#define COMMENT_ID 12001
#define COMMENT_TYPE 12002
#define COMMENT_TEXT 12003
#define FUNCTION_ID 13001
#define FUNCTION_RVA 13002
#define FUNCTION_NAME 13003
#define FUNCTION_SIZE 13004
#define FUNCTION_COMMENT 13005
#define FUNC_PARAM_ID 14001
#define FUNC_PARAM_FUNC 14002
#define FUNC_PARAM_TYPE 14003
#define FUNC_PARAM_OFFSET 14004
#define FUNC_PARAM_NAME 14005
#define FUNC_LOCAL_ID 15001
#define FUNC_LOCAL_FUNC 15002
#define FUNC_LOCAL_TYPE 15003
#define FUNC_LOCAL_OFFSET 15004
#define FUNC_LOCAL_NAME 15005
#define F_INLINE_ID 16001
#define F_INLINE_TYPE 16002
#define INLINE_TYPE_ID 17001
#define INLINE_TYPE_NAME 17002
#define INLINE_TYPE_RVA 17003
#define INLINE_TYPE_SIZE 17004
#define STRUCTURE_ID 18001
#define STRUCTURE_NAME 18002
#define STRUCTURE_SIZE 18003
#define STRUCT_MEMBER_ID 19001
#define STRUCT_MEMBER_TYPE 19002
#define STRUCT_MEMBER_STRUCTURE 19003
#define ORDER 19004
#define STRUCT_MEMBER_NAME 19005
#define DATA_TYPE_ID 20001
#define DATA_TYPE_SIZE 20002
#define DATA_TYPE_NAME 20003
#define CONSTANT_ID 21001
#define CONSTANT_NAME 21002
#define VALUE 21003
#define SEER_MACRO_ID 22001
#define SEER_MACRO_TYPE 22002
#define SEER_MACRO_NAME 22003
#define MACRO 22004
