1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
|
/*
* picasm.h
*
* Copyright 1995-2005 Timo Rossi, <trossi@iki.fi>
* See the file LICENSE for license terms.
*
* http://www.iki.fi/trossi/pic/
*
*/
#define VERSION "v1.14"
#define I_VERSION 114
#if defined(__SASC) || defined(__TURBOC__) || defined(__WATCOMC__) || defined(_MSC_VER)
#define strcasecmp stricmp
#define strncasecmp strnicmp
#endif
#define PIC_16BIT_SUPPORT 1
/* hex output end-of-line. if you need CRLFs in hex files
* when running on a system which does not normally generate
* them (such as Unix), use "\r\n", else "\n".
*/
#define HEX_EOL "\r\n"
/* maximum number of errors before aborting assembly */
#define MAX_ERRORS 20
/* output formats */
enum {
IHX8M,
IHX16
};
/* org mode */
typedef enum {
O_NONE,
O_PROGRAM,
O_REGFILE,
O_EDATA
} org_mode_t ;
#ifdef PIC_16BIT_SUPPORT
typedef unsigned long pic_instr_t;
#define INVALID_INSTR 0xfffff
#define INVALID_DATA 0xfffff
#define INVALID_CONFIG 0xfffff
#define INVALID_ID 0xfffff
#else
typedef unsigned short pic_instr_t;
#define INVALID_INSTR 0xffff
#define INVALID_DATA 0xffff
#define INVALID_CONFIG 0xffff
#define INVALID_ID 0xffff
#endif /* PIC_16BIT_SUPPORT */
/* list flags */
#define LIST_LOC 1
#define LIST_PROG 2
#define LIST_EDATA 4
#define LIST_FORWARD 8
#define LIST_VAL 0x10
#define LIST_PTR 0x20
/* inc_file types */
typedef enum {
INC_FILE,
INC_MACRO
} inctype_t;
/*
* structure for include files/macros
*/
struct inc_file {
struct inc_file *next;
union {
struct {
FILE *fp;
char *fname;
} f; /* file */
struct {
struct symbol *sym;
struct macro_line *ml;
struct macro_arg *args;
int uniq_id;
} m; /* macro */
} v;
inctype_t type;
int linenum;
int cond_nest_count;
int config_flag;
};
/*
* structure to hold one macro line
*/
struct macro_line {
struct macro_line *next;
char text[1];
};
/* Macro argument */
struct macro_arg {
struct macro_arg *next;
char text[1];
};
/*
* structure for patching forward jumps
*/
typedef enum {
PATCH11, /* 14-bit instr. set PICs */
PATCH9, /* 12-bit, goto */
PATCH8, /* 12-bit, call */
PATCH_UPPER_BYTE /* hibyte() */
} patchtype_t;
struct patch {
struct patch *next;
struct symbol *label;
int location;
patchtype_t type;
};
#define PROGMEM_MAX 16384
#define EEPROM_MAX 256
/*
* Definitions for different types of PIC processors
*/
typedef enum {
PIC_NONE,
PIC12BIT=1,
PIC14BIT,
PIC16BIT_NOMUL,
PIC16BIT
} instrset_t;
/*
* truth values for boolean functions
*/
#define EXPR_FALSE (0)
#define EXPR_TRUE (~0)
/* number of bits in an expression value */
#define EXPR_NBITS 32
/*
* Success/failure return codes for functions
*/
#define OK (0)
#define FAIL (-1)
/*
* variable declarations
*/
/* picasm.c */
extern struct inc_file *current_file;
extern char *line_buf_ptr;
extern char line_buffer[256];
extern int unique_id_count;
extern int cond_nest_count;
extern org_mode_t O_Mode;
extern int prog_location, reg_location, edata_location, org_val;
extern int warnlevel;
extern struct patch **local_patch_list_ptr;
extern int prog_mem_size;
extern unsigned short list_flags;
extern long list_val;
extern int listing_on;
extern instrset_t pic_instr_set;
extern pic_instr_t config_fuses;
extern int local_level;
extern char pic_name[256];
extern int default_radix;
/*
* function prototypes
*/
/* picasm.c */
void *mem_alloc(int size);
#define mem_free(p) free(p)
void fatal_error(char *, ...), error(int, char *, ...), warning(char *, ...);
void write_listing_line(int cond_flag);
void gen_code(int val);
void add_patch(int tab, struct symbol *sym, patchtype_t type);
int gen_byte_c(int instr_code);
/* config.c */
void parse_config(void);
void config_done(void);
/* expr.c */
int get_expression(long *);
/* pic12bit.c */
int assemble_12bit_mnemonic(int op);
/* pic14bit.c */
int assemble_14bit_mnemonic(int op);
/* pic16bit.c */
int assemble_16bit_mnemonic(int op);
|