1 /*-------------------------------------------------------------------------
3 device.c - Accomodates subtle variations in PIC16 devices
5 Written By - Scott Dattalo scott@dattalo.com
7 This program is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 2, or (at your option) any
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 -------------------------------------------------------------------------*/
23 PIC device abstraction
25 There are dozens of variations of PIC microcontrollers. This include
26 file attempts to abstract those differences so that SDCC can easily
33 #if defined(__BORLANDC__) || defined(_MSC_VER)
34 #define STRCASECMP stricmp
36 #define STRCASECMP strcasecmp
40 #define PROCESSOR_NAMES 4
41 /* Processor unique attributes */
42 typedef struct PIC16_device {
43 char *name[PROCESSOR_NAMES];/* aliases for the processor name */
45 int maxRAMaddress; /* maximum value for a data address */
46 int bankMask; /* Bitmask that is ANDed with address to extract banking bits */
47 int RAMsize; /* size of Data RAM - VR 031120 */
48 int extMIface; /* device has external memory interface */
51 /* Given a pointer to a register, this macro returns the bank that it is in */
52 #define REG_ADDR(r) ((r)->isBitField ? (((r)->address)>>3) : (r)->address)
53 //#define REG_BANK(r) (pic16_finalMapping[REG_ADDR(r)].bank)
54 //#define REG_isALIASED(r) (pic16_finalMapping[REG_ADDR(r)].alias != 0)
55 //#define REG_isVALID(r) (pic16_finalMapping[REG_ADDR(r)].isValid)
67 #define STACK_MODEL_SMALL (pic16_options.stack_model == 0)
68 #define STACK_MODEL_LARGE (pic16_options.stack_model == 1)
70 extern set *idataSymSet;
72 extern pic16_options_t pic16_options;
73 extern PIC16_device *pic16;
75 /****************************************/
76 void pic16_assignConfigWordValue(int address, int value);
77 int pic16_getConfigWord(int address);
78 int pic16_isREGinBank(regs *reg, int bank);
79 int pic16_REGallBanks(regs *reg);
80 void pic16_setMaxRAM(int size);
82 int checkAddReg(set **set, regs *reg);
83 int checkAddSym(set **set, symbol *reg);
85 #endif /* __DEVICE_H__ */