#include "ralloc.h"
#include "device.h"
-#if defined(__BORLANDC__) || defined(_MSC_VER)
-#define STRCASECMP stricmp
-#else
-#define STRCASECMP strcasecmp
-#endif
-static PIC_device Pics[] = {
+static PIC16_device Pics16[] = {
+// {
+// {"p18f242", "18f242", "pic18f242", "f242"}, // aliases
+// 0,
+// 0x300, // RAMsize
+// 0,
+// { 0xf80, 0xfff }, /* PIC18F242 range of SFR's */
+// {
+// /* PIC18F242 configuration words */
+// 0x300001,
+// 0x30000d,
+// { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ ,
+// { -1, 0, 0xff } /* 4 */ , { 0x01, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ ,
+// { -1, 0, 0xff } /* 7 */ , { 0x03, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ ,
+// { 0x03, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x03, 0, 0xff } /* c */ ,
+// { 0x40, 0, 0xff } /* d */ }
+// }
+// },
+
{
- {"p18f242", "18f242", "pic18f242", "f242"}, // aliases
- (memRange *)NULL, // ram memory map
- (memRange *)NULL, // sfr memory map
+ {"p18f242", "18f242", "pic18f242", "f242"},
+ 0,
+ 0x300, /* 768 */
+ 0x80,
0,
- 0x300, // bank mask
- 0x300, // RAMsize
- 0
+ { 0xf80, 0xfff }, /* PIC18F242 range of SFR's */
+ {
+ /* PIC18F242 configuration words */
+ 0x300001,
+ 0x30000d,
+ { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ ,
+ { -1, 0, 0xff } /* 4 */ , { 0x01, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ ,
+ { -1, 0, 0xff } /* 7 */ , { 0x03, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ ,
+ { 0x03, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x03, 0, 0xff } /* c */ ,
+ { 0x40, 0, 0xff } /* d */ }
+ }
},
-
{
- {"p18f252", "18f252", "pic18f252", "f252"}, // aliases
- (memRange *)NULL, // ram memory map
- (memRange *)NULL, // sfr memory map
+ {"p18f248", "18f248", "pic18f248", "f248"},
+ 0,
+ 0x300, /* 768 */
+ 0x60,
0,
- 0x600, // bank mask
- 0x600, // RAMsize
- 0
+ { 0xf00, 0xfff }, /* PIC18F248 range of SFR's */
+ {
+ /* PIC18F248 configuration words */
+ 0x300001,
+ 0x30000d,
+ { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ ,
+ { -1, 0, 0xff } /* 4 */ , { -1, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ ,
+ { -1, 0, 0xff } /* 7 */ , { 0x03, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ ,
+ { 0x03, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x03, 0, 0xff } /* c */ ,
+ { 0x40, 0, 0xff } /* d */ }
+ }
},
-
{
- {"p18f442", "18f442", "pic18f442", "f442"}, // aliases
- (memRange *)NULL, // ram memory map
- (memRange *)NULL, // sfr memory map
+ {"p18f252", "18f252", "pic18f252", "f252"},
0,
- 0x300, // bank mask
- 0x300, // RAMsize
- 0
+ 0x600, /* 1536 */
+ 0x80,
+ 0,
+ { 0xf80, 0xfff }, /* PIC18F252 range of SFR's */
+ {
+ /* PIC18F252 configuration words */
+ 0x300001,
+ 0x30000d,
+ { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ ,
+ { -1, 0, 0xff } /* 4 */ , { 0x01, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ ,
+ { -1, 0, 0xff } /* 7 */ , { 0x0f, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ ,
+ { 0x0f, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x0f, 0, 0xff } /* c */ ,
+ { 0x40, 0, 0xff } /* d */ }
+ }
},
-
{
- {"p18f452", "18f452", "pic18f452", "f452"}, // aliases
- (memRange *)NULL, // ram memory map
- (memRange *)NULL, // sfr memory map
+ {"p18f258", "18f258", "pic18f258", "f258"},
+ 0,
+ 0x600, /* 1536 */
+ 0x60,
0,
- 0x600, // bank mask
- 0x600, // RAMsize
- 0
+ { 0xf00, 0xfff }, /* PIC18F258 range of SFR's */
+ {
+ /* PIC18F258 configuration words */
+ 0x300001,
+ 0x30000d,
+ { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ ,
+ { -1, 0, 0xff } /* 4 */ , { -1, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ ,
+ { -1, 0, 0xff } /* 7 */ , { 0x0f, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ ,
+ { 0x0f, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x0f, 0, 0xff } /* c */ ,
+ { 0x40, 0, 0xff } /* d */ }
+ }
},
-
{
- {"p18f248", "18f248", "pic18f248", "f248"}, // aliases
- (memRange *)NULL, // ram memory map
- (memRange *)NULL, // sfr memory map
+ {"p18f442", "18f442", "pic18f442", "f442"},
+ 0,
+ 0x300, /* 768 */
+ 0x80,
0,
- 0x300, // bank mask
- 0x300, // RAMsize
- 0
+ { 0xf80, 0xfff }, /* PIC18F442 range of SFR's */
+ {
+ /* PIC18F442 configuration words */
+ 0x300001,
+ 0x30000d,
+ { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ ,
+ { -1, 0, 0xff } /* 4 */ , { 0x01, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ ,
+ { -1, 0, 0xff } /* 7 */ , { 0x03, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ ,
+ { 0x03, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x03, 0, 0xff } /* c */ ,
+ { 0x40, 0, 0xff } /* d */ }
+ }
},
-
{
- {"p18f258", "18f258", "pic18f258", "f258"}, // aliases
- (memRange *)NULL, // ram memory map
- (memRange *)NULL, // sfr memory map
+ {"p18f448", "18f448", "pic18f448", "f448"},
0,
- 0x600, // bank mask
- 0x600, // RAMsize
- 0
+ 0x300, /* 768 */
+ 0x60,
+ 0,
+ { 0xf00, 0xfff }, /* PIC18F448 range of SFR's */
+ {
+ /* PIC18F448 configuration words */
+ 0x300001,
+ 0x30000d,
+ { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ ,
+ { -1, 0, 0xff } /* 4 */ , { -1, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ ,
+ { -1, 0, 0xff } /* 7 */ , { 0x03, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ ,
+ { 0x03, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x03, 0, 0xff } /* c */ ,
+ { 0x40, 0, 0xff } /* d */ }
+ }
},
-
{
- {"p18f448", "18f448", "pic18f448", "f448"}, // aliases
- (memRange *)NULL, // ram memory map
- (memRange *)NULL, // sfr memory map
+ {"p18f452", "18f452", "pic18f452", "f452"},
0,
- 0x300, // bank mask
- 0x300, // RAMsize
- 0
+ 0x600, /* 1536 */
+ 0x80,
+ 0,
+ { 0xf80, 0xfff }, /* PIC18F452 range of SFR's */
+ {
+ /* PIC18F452 configuration words */
+ 0x300001,
+ 0x30000d,
+ { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ ,
+ { -1, 0, 0xff } /* 4 */ , { 0x01, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ ,
+ { -1, 0, 0xff } /* 7 */ , { 0x0f, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ ,
+ { 0x0f, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x0f, 0, 0xff } /* c */ ,
+ { 0x40, 0, 0xff } /* d */ }
+ }
},
-
{
- {"p18f458", "18f458", "pic18f458", "f458"}, // aliases
- (memRange *)NULL, // ram memory map
- (memRange *)NULL, // sfr memory map
+ {"p18f458", "18f458", "pic18f458", "f458"},
+ 0,
+ 0x600, /* 1536 */
+ 0x60,
0,
- 0x600, // bank mask
- 0x600, // RAMsize
- 0
+ { 0xf00, 0xfff }, /* PIC18F458 range of SFR's */
+ {
+ /* PIC18F458 configuration words */
+ 0x300001,
+ 0x30000d,
+ { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ ,
+ { -1, 0, 0xff } /* 4 */ , { -1, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ ,
+ { -1, 0, 0xff } /* 7 */ , { 0x0f, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ ,
+ { 0x0f, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x0f, 0, 0xff } /* c */ ,
+ { 0x40, 0, 0xff } /* d */ }
+ }
},
-
{
- {"p18f6520", "18f6520", "pic18f6520", "f6520"}, // aliases
- (memRange *)NULL, // ram memory map
- (memRange *)NULL, // sfr memory map
+ {"p18f1220", "18f1220", "pic18f1220", "f1220"},
+ 0,
+ 0x100, /* 256 */
+ 0x80,
0,
- 0x800, // bank mask
- 0x800, // RAMsize
- 1
+ { 0xf80, 0xfff }, /* PIC18F1220 range of SFR's */
+ {
+ /* PIC18F1220 configuration words */
+ 0x300001,
+ 0x30000d,
+ { { 0xcf, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x1f, 0, 0xff } /* 3 */ ,
+ { -1, 0, 0xff } /* 4 */ , { 0x80, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ ,
+ { -1, 0, 0xff } /* 7 */ , { 0x03, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ ,
+ { 0x03, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x03, 0, 0xff } /* c */ ,
+ { 0x40, 0, 0xff } /* d */ }
+ }
},
-
{
- {"p18f6620", "18f6620", "pic18f6620", "f6620"}, // aliases
- (memRange *)NULL, // ram memory map
- (memRange *)NULL, // sfr memory map
+ {"p18f6520", "18f6520", "pic18f6520", "f6520"},
0,
- 0xf00, // bank mask
- 0xf00, // RAMsize
- 1
+ 0x800, /* 2048 */
+ 0x60,
+ 0,
+ { 0xf6b, 0xfff }, /* PIC18F6520 range of SFR's */
+ {
+ /* PIC18F6520 configuration words */
+ 0x300001,
+ 0x30000d,
+ { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ ,
+ { 0x80, 0, 0xff } /* 4 */ , { 0x88, 0, 0xff } /* 5 */ , { -1, 0, 0xff } /* 6 */ ,
+ { -1, 0, 0xff } /* 7 */ , { 0x0f, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ ,
+ { 0x0f, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x0f, 0, 0xff } /* c */ ,
+ { 0x40, 0, 0xff } /* d */ }
+ }
},
{
- {"p18f6680", "18f6680", "pic18f6680", "f6680"}, // aliases
- (memRange *)NULL, // ram memory map
- (memRange *)NULL, // sfr memory map
+ {"p18f6620", "18f6620", "pic18f6620", "f6620"},
0,
- 0xc00, // bank mask
- 0xc00, // RAMsize
- 1
+ 0xf00, /* 3840 */
+ 0x60,
+ 0,
+ { 0xf6b, 0xfff }, /* PIC18F6620 range of SFR's */
+ {
+ /* PIC18F6620 configuration words */
+ 0x300001,
+ 0x30000d,
+ { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ ,
+ { -1, 0, 0xff } /* 4 */ , { 0x01, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ ,
+ { -1, 0, 0xff } /* 7 */ , { 0x0f, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ ,
+ { 0x0f, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x0f, 0, 0xff } /* c */ ,
+ { 0x40, 0, 0xff } /* d */ }
+ }
},
{
- {"p18f6720", "18f6720", "pic18f6720", "f6720"}, // aliases
- (memRange *)NULL, // ram memory map
- (memRange *)NULL, // sfr memory map
+ {"p18f6680", "18f6680", "pic18f6680", "f6680"},
+ 0,
+ 0xf00, /* 3840 */
+ 0x60,
0,
- 0xf00, // bank mask
- 0xf00, // RAMsize
- 1
+ { 0xf00, 0xfff }, /* PIC18F6680 range of SFR's */
+ {
+ /* PIC18F6680 configuration words */
+ 0x300001,
+ 0x30000d,
+ { { 0x2f, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x1f, 0, 0xff } /* 3 */ ,
+ { -1, 0, 0xff } /* 4 */ , { 0x83, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ ,
+ { -1, 0, 0xff } /* 7 */ , { 0x0f, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ ,
+ { 0x0f, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x0f, 0, 0xff } /* c */ ,
+ { 0x40, 0, 0xff } /* d */ }
+ }
},
{
- {"p18f8520", "18f8520", "pic18f8520", "f8520"}, // aliases
- (memRange *)NULL, // ram memory map
- (memRange *)NULL, // sfr memory map
+ {"p18f6720", "18f6720", "pic18f6720", "f6720"},
+ 0,
+ 0xf00, /* 3840 */
+ 0x60,
0,
- 0x800, // bank mask
- 0x800, // RAMsize
- 1
+ { 0xf6b, 0xfff }, /* PIC18F6720 range of SFR's */
+ {
+ /* PIC18F6720 configuration words */
+ 0x300001,
+ 0x30000d,
+ { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ ,
+ { -1, 0, 0xff } /* 4 */ , { 0x01, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ ,
+ { -1, 0, 0xff } /* 7 */ , { 0xff, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ ,
+ { 0xff, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0xff, 0, 0xff } /* c */ ,
+ { 0x40, 0, 0xff } /* d */ }
+ }
},
{
- {"p18f8620", "18f8620", "pic18f8620", "f8620"}, // aliases
- (memRange *)NULL, // ram memory map
- (memRange *)NULL, // sfr memory map
+ {"p18f8520", "18f8520", "pic18f8520", "f8520"},
0,
- 0xf00, // bank mask
- 0xf00, // RAMsize
- 1
+ 0x800, /* 2048 */
+ 0x60,
+ 1,
+ { 0xf6b, 0xfff }, /* PIC18F8520 range of SFR's */
+ {
+ /* PIC18F8520 configuration words */
+ 0x300001,
+ 0x30000d,
+ { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ ,
+ { 0x83, 0, 0xff } /* 4 */ , { 0x88, 0, 0xff } /* 5 */ , { -1, 0, 0xff } /* 6 */ ,
+ { -1, 0, 0xff } /* 7 */ , { 0x0f, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ ,
+ { 0x0f, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x0f, 0, 0xff } /* c */ ,
+ { 0x40, 0, 0xff } /* d */ }
+ }
},
{
- {"p18f8680", "18f8680", "pic18f8680", "f8680"}, // aliases
- (memRange *)NULL, // ram memory map
- (memRange *)NULL, // sfr memory map
+ {"p18f8620", "18f8620", "pic18f8620", "f8620"},
0,
- 0xc00, // bank mask
- 0x800, // RAMsize
- 1
+ 0xf00, /* 3840 */
+ 0x60,
+ 1,
+ { 0xf6b, 0xfff }, /* PIC18F8620 range of SFR's */
+ {
+ /* PIC18F8620 configuration words */
+ 0x300001,
+ 0x30000d,
+ { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ ,
+ { 0x83, 0, 0xff } /* 4 */ , { 0x01, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ ,
+ { -1, 0, 0xff } /* 7 */ , { 0x0f, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ ,
+ { 0x0f, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x0f, 0, 0xff } /* c */ ,
+ { 0x40, 0, 0xff } /* d */ }
+ }
},
{
- {"p18f8720", "18f8720", "pic18f8720", "f8720"}, // aliases
- (memRange *)NULL, // ram memory map
- (memRange *)NULL, // sfr memory map
+ {"p18f8680", "18f8680", "pic18f8680", "f8680"},
+ 0,
+ 0xf00, /* 3840 */
+ 0x60,
0,
- 0xf00, // bank mask
- 0xf00, // RAMsize
- 1
+ { 0xf00, 0xfff }, /* PIC18F8680 range of SFR's */
+ {
+ /* PIC18F8680 configuration words */
+ 0x300001,
+ 0x30000d,
+ { { 0x2f, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x1f, 0, 0xff } /* 3 */ ,
+ { 0x83, 0, 0xff } /* 4 */ , { 0x83, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ ,
+ { -1, 0, 0xff } /* 7 */ , { 0x0f, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ ,
+ { 0x0f, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0x0f, 0, 0xff } /* c */ ,
+ { 0x40, 0, 0xff } /* d */ }
+ }
+ },
+ {
+ {"p18f8720", "18f8720", "pic18f8720", "f8720"},
+ 0,
+ 0xf00, /* 3840 */
+ 0x60,
+ 1,
+ { 0xf6b, 0xfff }, /* PIC18F8720 range of SFR's */
+ {
+ /* PIC18F8720 configuration words */
+ 0x300001,
+ 0x30000d,
+ { { 0x27, 0, 0xff } /* 1 */ , { 0x0f, 0, 0xff } /* 2 */ , { 0x0f, 0, 0xff } /* 3 */ ,
+ { 0x83, 0, 0xff } /* 4 */ , { 0x01, 0, 0xff } /* 5 */ , { 0x85, 0, 0xff } /* 6 */ ,
+ { -1, 0, 0xff } /* 7 */ , { 0xff, 0, 0xff } /* 8 */ , { 0xc0, 0, 0xff } /* 9 */ ,
+ { 0xff, 0, 0xff } /* a */ , { 0xe0, 0, 0xff } /* b */ , { 0xff, 0, 0xff } /* c */ ,
+ { 0x40, 0, 0xff } /* d */ }
+ }
},
};
-static int num_of_supported_PICS = sizeof(Pics)/sizeof(PIC_device);
+static int num_of_supported_PICS = sizeof(Pics16)/sizeof(PIC16_device);
#define DEFAULT_PIC "452"
-static PIC_device *pic=NULL;
-
-AssignedMemory *pic16_finalMapping=NULL;
-int pic16_finalMappingSize=0;
-
-#define DEFAULT_CONFIG_BYTE 0xff
-
-#define CONFIG1H_WORD_ADDRESS 0x300001
-#define DEFAULT_CONFIG1H_WORD DEFAULT_CONFIG_BYTE
-
-#define CONFIG2L_WORD_ADDRESS 0x300002
-#define DEFAULT_CONFIG2L_WORD DEFAULT_CONFIG_BYTE
-
-#define CONFIG2H_WORD_ADDRESS 0x300003
-#define DEFAULT_CONFIG2H_WORD DEFAULT_CONFIG_BYTE
-
-#define CONFIG3H_WORD_ADDRESS 0x300005
-#define DEFAULT_CONFIG3H_WORD DEFAULT_CONFIG_BYTE
-
-#define CONFIG4L_WORD_ADDRESS 0x300006
-#define DEFAULT_CONFIG4L_WORD DEFAULT_CONFIG_BYTE
-
-#define CONFIG5L_WORD_ADDRESS 0x300008
-#define DEFAULT_CONFIG5L_WORD DEFAULT_CONFIG_BYTE
-
-#define CONFIG5H_WORD_ADDRESS 0x300009
-#define DEFAULT_CONFIG5H_WORD DEFAULT_CONFIG_BYTE
+PIC16_device *pic16=NULL;
+unsigned int stackPos = 0;
-#define CONFIG6L_WORD_ADDRESS 0x30000a
-#define DEFAULT_CONFIG6L_WORD DEFAULT_CONFIG_BYTE
+extern regs* newReg(short type, short pc_type, int rIdx, char *name, int size, int alias, operand *refop);
-#define CONFIG6H_WORD_ADDRESS 0x30000b
-#define DEFAULT_CONFIG6H_WORD DEFAULT_CONFIG_BYTE
-
-#define CONFIG7L_WORD_ADDRESS 0x30000c
-#define DEFAULT_CONFIG7L_WORD DEFAULT_CONFIG_BYTE
-
-#define CONFIG7H_WORD_ADDRESS 0x30000d
-#define DEFAULT_CONFIG7H_WORD DEFAULT_CONFIG_BYTE
-
-static unsigned int config1h_word = DEFAULT_CONFIG1H_WORD;
-static unsigned int config2l_word = DEFAULT_CONFIG2L_WORD;
-static unsigned int config2h_word = DEFAULT_CONFIG2H_WORD;
-static unsigned int config3h_word = DEFAULT_CONFIG3H_WORD;
-static unsigned int config4l_word = DEFAULT_CONFIG4L_WORD;
-static unsigned int config5l_word = DEFAULT_CONFIG5L_WORD;
-static unsigned int config5h_word = DEFAULT_CONFIG5H_WORD;
-static unsigned int config6l_word = DEFAULT_CONFIG6L_WORD;
-static unsigned int config6h_word = DEFAULT_CONFIG6H_WORD;
-static unsigned int config7l_word = DEFAULT_CONFIG7L_WORD;
-static unsigned int config7h_word = DEFAULT_CONFIG7H_WORD;
-
-void pic16_addMemRange(memRange *r, int type)
+void pic16_setMaxRAM(int size)
{
- int i;
- int alias = r->alias;
-
- if (pic->maxRAMaddress < 0) {
- fprintf(stderr, "missing \"#pragma maxram\" setting\n");
- return;
- }
+ pic16->maxRAMaddress = size;
+ stackPos = pic16->RAMsize-1;
-// fprintf(stderr, "%s: adding memory range from 0x%x to 0x%x type= %d\n",
-// __FUNCTION__, r->start_address, r->end_address, type);
-
- do {
- for (i=r->start_address; i<= r->end_address; i++) {
- if ((i|alias) <= pic->maxRAMaddress) {
- pic16_finalMapping[i | alias].isValid = 1;
- pic16_finalMapping[i | alias].alias = r->alias;
- pic16_finalMapping[i | alias].bank = r->bank;
- if(type) {
- /* hack for now */
- pic16_finalMapping[i | alias].isSFR = 1;
- } else {
- pic16_finalMapping[i | alias].isSFR = 0;
+ if (pic16->maxRAMaddress < 0) {
+ fprintf(stderr, "invalid \"#pragma maxram 0x%x\" setting\n",
+ pic16->maxRAMaddress);
+ return;
}
- } else {
- fprintf(stderr, "WARNING: %s:%s memory at 0x%x is beyond max ram = 0x%x\n",
- __FILE__,__FUNCTION__,(i|alias), pic->maxRAMaddress);
- }
- }
-
- /* Decrement alias */
- if (alias) {
- alias -= ((alias & (alias - 1)) ^ alias);
- } else {
- alias--;
- }
-
- } while (alias >= 0);
}
-void pic16_setMaxRAM(int size)
-{
- int i;
- pic->maxRAMaddress = size;
-
- if (pic->maxRAMaddress < 0) {
- fprintf(stderr, "invalid \"#pragma maxram 0x%x\" setting\n",
- pic->maxRAMaddress);
- return;
- }
-
- pic16_finalMapping = Safe_calloc(1+pic->maxRAMaddress,
- sizeof(AssignedMemory));
+extern char *iComments2;
- /* Now initialize the pic16_finalMapping array */
-
- for(i=0; i<=pic->maxRAMaddress; i++) {
- pic16_finalMapping[i].reg = NULL;
- pic16_finalMapping[i].isValid = 0;
- }
+void pic16_dump_equates(FILE *of, set *equs)
+{
+ regs *r;
+
+ r = setFirstItem(equs);
+ if(!r)return;
+
+ fprintf(of, "%s", iComments2);
+ fprintf(of, ";\tEquates to used internal registers\n");
+ fprintf(of, "%s", iComments2);
+
+ for(; r; r = setNextItem(equs)) {
+ fprintf(of, "%s\tequ\t0x%02x\n", r->name, r->address);
+ }
}
-/*-----------------------------------------------------------------*
- *-----------------------------------------------------------------*/
-int pic16_isREGinBank(regs *reg, int bank)
+int regCompare(const void *a, const void *b)
{
-
- if(!reg || !pic)
- return 0;
-
- if(pic16_finalMapping[reg->address].bank == bank)
- return 1;
+ const regs *const *i = a;
+ const regs *const *j = b;
+
+ /* sort primarily by the address */
+ if( (*i)->address > (*j)->address)return 1;
+ if( (*i)->address < (*j)->address)return -1;
+
+ /* and secondarily by size */
+ /* register size sorting may have strange results use with care */
+ if( (*i)->size > (*j)->size)return 1;
+ if( (*i)->size < (*j)->size)return -1;
+
+ /* finally if in same address and same size sort by name */
+ return (strcmp( (*i)->name, (*j)->name));
return 0;
}
-/*-----------------------------------------------------------------*
- *-----------------------------------------------------------------*/
-int pic16_REGallBanks(regs *reg)
+int symCompare(const void *a, const void *b)
{
+ const symbol *const *i = a;
+ const symbol *const *j = b;
- if(!reg || !pic)
- return 0;
-
- if (reg->address > pic->maxRAMaddress)
- return 0;
+ /* sort primarily by the address */
+ if( SPEC_ADDR((*i)->etype) > SPEC_ADDR((*j)->etype))return 1;
+ if( SPEC_ADDR((*i)->etype) < SPEC_ADDR((*j)->etype))return -1;
+
+ /* and secondarily by size */
+ /* register size sorting may have strange results use with care */
+ if( getSize((*i)->etype) > getSize((*j)->etype))return 1;
+ if( getSize((*i)->etype) < getSize((*j)->etype))return -1;
- return 1;
+ /* finally if in same address and same size sort by name */
+ return (strcmp( (*i)->rname, (*j)->rname));
+ return 0;
}
-/*-----------------------------------------------------------------*
- *-----------------------------------------------------------------*/
-
-/*
- * pic16_dump_map -- debug stuff
- */
-
-void pic16_dump_map(void)
+void pic16_dump_usection(FILE *of, set *section, int fix)
{
- int i;
-
- for(i=0; i<=pic->maxRAMaddress; i++) {
- //fprintf(stdout , "addr 0x%02x is %s\n", i, ((pic16_finalMapping[i].isValid) ? "valid":"invalid"));
-
- if(pic16_finalMapping[i].isValid) {
- fprintf(stderr,"addr: 0x%02x",i);
- if(pic16_finalMapping[i].isSFR)
- fprintf(stderr," isSFR");
- if(pic16_finalMapping[i].reg)
- fprintf( stderr, " reg %s", pic16_finalMapping[i].reg->name);
- fprintf(stderr, "\n");
- }
- }
+ static int abs_usection_no=0;
+ regs *r, *rprev;
+ int init_addr, i;
+ regs **rlist;
+ regs *r1;
+
+ /* put all symbols in an array */
+ rlist = Safe_calloc(elementsInSet(section), sizeof(regs *));
+ r = rlist[0]; i = 0;
+ for(rprev = setFirstItem(section); rprev; rprev = setNextItem(section)) {
+ rlist[i] = rprev; i++;
+ }
+
+ if(!i) {
+ if(rlist)free(rlist);
+ return;
+ }
+ /* sort symbols according to their address */
+ qsort(rlist, i /*elementsInSet(section)*/, sizeof(regs *), regCompare);
+
+ if(!fix) {
+ fprintf(of, "\n\n\tudata\n");
+ for(r = setFirstItem(section); r; r = setNextItem(section)) {
+ fprintf(of, "%s\tres\t%d\n", r->name, r->size);
+ }
+ } else {
+ int j=0;
+ int deb_addr=0;
+
+ rprev = NULL;
+ init_addr = rlist[j]->address;
+ deb_addr = init_addr;
+ fprintf(of, "\n\nustat_%s_%02d\tudata\t0X%04X\n", moduleName, abs_usection_no++, init_addr);
+
+ for(j=0;j<i;j++) {
+ r = rlist[j];
+ if(j < i-1)r1 = rlist[j+1]; else r1 = NULL;
+
+ init_addr = r->address;
+ deb_addr = init_addr;
+
+ if((rprev && (init_addr > (rprev->address + rprev->size)))) {
+ fprintf(of, "\n\nustat_%s_%02d\tudata\t0X%04X\n", moduleName, abs_usection_no++, init_addr);
+ }
+
+ if(r1 && (init_addr == r1->address)) {
+ fprintf(of, "\n%s\tres\t0\n", r->name);
+ } else {
+ fprintf(of, "%s\tres\t%d\n", r->name, r->size);
+ deb_addr += r->size;
+ }
+
+ rprev = r;
+ }
+ }
+ free(rlist);
}
-void pic16_dump_cblock(FILE *of)
-{
- int start=-1;
- int addr=0;
- int bank_base;
-
- //pic16_dump_map(); /* display the register map */
-
- if (pic->maxRAMaddress < 0) {
- fprintf(stderr, "missing \"#pragma maxram\" setting\n");
- return;
- }
-
- do {
- if(pic16_finalMapping[addr].reg && !pic16_finalMapping[addr].reg->isEmitted
- && pic16_finalMapping[addr].reg->wasUsed) {
+/* forward declaration */
+void pic16_printIval(symbol * sym, sym_link * type, initList * ilist, char ptype, void *p);
- if(start<0)
- start = addr;
- } else {
- if(start>=0) {
-
- /* clear the lower 7-bits of the start address of the first
- * variable declared in this bank. The upper bits for the mid
- * range pics are the bank select bits.
- */
-
- bank_base = start & 0xfff8;
-
- /* The bank number printed in the cblock comment tacitly
- * assumes that the first register in the contiguous group
- * of registers represents the bank for the whole group */
-
- if ((pic16_finalMapping[start].bank == 0 && start <= 0x7f) ||
- pic16_finalMapping[start].isSFR)
- fprintf(of," cblock 0X%04X\t; Access Bank\n",start);
- else
- fprintf(of," cblock 0X%04X\t; Bank %d\n",start,pic16_finalMapping[start].bank);
-
- for( ; start < addr; start++) {
- if((pic16_finalMapping[start].reg) && !pic16_finalMapping[start].reg->isEmitted ) {
- fprintf(of,"\t%s",pic16_finalMapping[start].reg->name);
+void pic16_dump_isection(FILE *of, set *section, int fix)
+{
+ static int abs_isection_no=0;
+ symbol *s, *sprev;
+ int init_addr, i;
+ symbol **slist;
+
+ /* put all symbols in an array */
+ slist = Safe_calloc(elementsInSet(section), sizeof(symbol *));
+ s = slist[0]; i = 0;
+ for(sprev = setFirstItem(section); sprev; sprev = setNextItem(section)) {
+ slist[i] = sprev; i++;
+ }
+
+ if(!i) {
+ if(slist)free(slist);
+ return;
+ }
- /* If this register is aliased in multiple banks, then
- * mangle the variable name with the alias address: */
- if(pic16_finalMapping[start].alias & start)
- fprintf(of,"_%x",bank_base);
+ /* sort symbols according to their address */
+ qsort(slist, i, sizeof(symbol *), symCompare);
+
+ pic16_initDB();
+
+ if(!fix) {
+ fprintf(of, "\n\n\tidata\n");
+ for(s = setFirstItem(section); s; s = setNextItem(section)) {
+ fprintf(of, "%s", s->rname);
+ pic16_printIval(s, s->type, s->ival, 'f', (void *)of);
+ pic16_flushDB('f', (void *)of);
+ }
+ } else {
+ int j=0;
+ symbol *s1;
+
+ sprev = NULL;
+ init_addr = SPEC_ADDR(slist[j]->etype);
+ fprintf(of, "\n\nistat_%s_%02d\tidata\t0X%04X\n", moduleName, abs_isection_no++, init_addr);
+
+ for(j=0;j<i;j++) {
+ s = slist[j];
+ if(j < i-1)s1 = slist[j+1]; else s1 = NULL;
+
+ init_addr = SPEC_ADDR(s->etype);
+
+ if(sprev && (init_addr > (SPEC_ADDR(sprev->etype) + getSize(sprev->etype)))) {
+ fprintf(of, "\nistat_%s_%02d\tidata\t0X%04X\n", moduleName, abs_isection_no++, init_addr);
+ }
+
+ fprintf(of, "%s", s->rname);
+ pic16_printIval(s, s->type, s->ival, 'f', (void *)of);
+ pic16_flushDB('f', (void *)of);
+
+ sprev = s;
+ }
+ }
+ free(slist);
+}
- if(pic16_finalMapping[start].instance)
- fprintf(of,"_%d",pic16_finalMapping[start].instance);
-
- fputc('\n',of);
+void pic16_dump_int_registers(FILE *of, set *section)
+{
+ regs *r, *rprev;
+ int i;
+ regs **rlist;
-//#warning why is the following line commented out?! (VR)
-// pic16_finalMapping[start].reg->isEmitted = 1;
- }
+ /* put all symbols in an array */
+ rlist = Safe_calloc(elementsInSet(section), sizeof(regs *));
+ r = rlist[0]; i = 0;
+ for(rprev = setFirstItem(section); rprev; rprev = setNextItem(section)) {
+ rlist[i] = rprev; i++;
}
- fprintf(of," endc\n");
-
- start = -1;
- }
+ /* sort symbols according to their address */
+ qsort(rlist, elementsInSet(section), sizeof(regs *), regCompare);
+
+ if(!i) {
+ if(rlist)free(rlist);
+ return;
+ }
+
+ fprintf(of, "\n\n; Internal registers\n");
+
+ fprintf(of, "%s\tudata_ovr\t0x0000\n", ".registers");
+ for(r = setFirstItem(section); r; r = setNextItem(section))
+ fprintf(of, "%s\tres\t%d\n", r->name, r->size);
+
+ free(rlist);
+}
- }
- addr++;
+#ifdef WORDS_BIGENDIAN
+ #define _ENDIAN(x) (3-x)
+#else
+ #define _ENDIAN(x) (x)
+#endif
- } while(addr <= pic->maxRAMaddress);
-
+#define BYTE_IN_LONG(x,b) ((x>>(8*_ENDIAN(b)))&0xff)
-}
/*-----------------------------------------------------------------*
* void pic16_list_valid_pics(int ncols, int list_alias)
int i,j,k,l;
if(list_alias)
- list_alias = sizeof(Pics[0].name) / sizeof(Pics[0].name[0]);
+ list_alias = sizeof(Pics16[0].name) / sizeof(Pics16[0].name[0]);
/* decrement the column number if it's greater than zero */
ncols = (ncols > 1) ? ncols-1 : 4;
/* Find the device with the longest name */
for(i=0,longest=0; i<num_of_supported_PICS; i++) {
for(j=0; j<=list_alias; j++) {
- k = strlen(Pics[i].name[j]);
+ k = strlen(Pics16[i].name[j]);
if(k>longest)
longest = k;
}
j = 0;
do {
- fprintf(stderr,"%s", Pics[i].name[j]);
+ fprintf(stderr,"%s", Pics16[i].name[j]);
if(col<ncols) {
- l = longest + 2 - strlen(Pics[i].name[j]);
+ l = longest + 2 - strlen(Pics16[i].name[j]);
for(k=0; k<l; k++)
fputc(' ',stderr);
/*-----------------------------------------------------------------*
*
*-----------------------------------------------------------------*/
-PIC_device *pic16_find_device(char *name)
+PIC16_device *pic16_find_device(char *name)
{
int i,j;
for(i = 0; i<num_of_supported_PICS; i++) {
for(j=0; j<PROCESSOR_NAMES; j++)
- if(!STRCASECMP(Pics[i].name[j], name) )
- return &Pics[i];
+ if(!STRCASECMP(Pics16[i].name[j], name) )
+ return &Pics16[i];
}
/* not found */
*-----------------------------------------------------------------*/
void pic16_init_pic(char *pic_type)
{
- pic = pic16_find_device(pic_type);
+ pic16 = pic16_find_device(pic_type);
- if(!pic) {
- if(pic_type)
- fprintf(stderr, "'%s' was not found.\n", pic_type);
- else
- fprintf(stderr, "No processor has been specified (use -pPROCESSOR_NAME)\n");
+ if(!pic16) {
+ if(pic_type)
+ fprintf(stderr, "'%s' was not found.\n", pic_type);
+ else
+ fprintf(stderr, "No processor has been specified (use -pPROCESSOR_NAME)\n");
- fprintf(stderr,"Valid devices are:\n");
+ fprintf(stderr,"Valid devices are:\n");
- pic16_list_valid_pics(4,0);
- exit(1);
- }
+ pic16_list_valid_pics(4,0);
+ exit(1);
+ }
- pic->maxRAMaddress = -1;
+// printf("PIC processor found and initialized: %s\n", pic_type);
+ pic16_setMaxRAM( 0xfff );
}
/*-----------------------------------------------------------------*
*-----------------------------------------------------------------*/
int pic16_picIsInitialized(void)
{
- if(pic && pic->maxRAMaddress > 0)
+ if(pic16 && pic16->maxRAMaddress > 0)
return 1;
return 0;
char *pic16_processor_base_name(void)
{
- if(!pic)
+ if(!pic16)
return NULL;
- return pic->name[0];
+ return pic16->name[0];
}
-static int isSFR(int address)
-{
-
- if( (address > pic->maxRAMaddress) || !pic16_finalMapping[address].isSFR)
- return 0;
-
- return 1;
-
-}
+#define DEBUG_CHECK 0
-/*-----------------------------------------------------------------*
- *-----------------------------------------------------------------*/
-static int validAddress(int address, int reg_size)
+/*
+ * return 1 if register wasn't found and added, 0 otherwise
+ */
+int checkAddReg(set **set, regs *reg)
{
- int i;
+ regs *tmp;
- if (pic->maxRAMaddress < 0) {
- fprintf(stderr, "missing \"#pragma maxram\" setting\n");
- return 0;
- }
-// fprintf(stderr, "validAddress: Checking 0x%04x (max=0x%04x) (reg_size = %d)\n",address, pic->maxRAMaddress, reg_size);
- if(address > pic->maxRAMaddress)
- return 0;
+#if DEBUG_CHECK
+ fprintf(stderr, "%s: about to insert REGister: %s ... ", __FUNCTION__, reg->name);
+#endif
- for (i=0; i<reg_size; i++)
- if(!pic16_finalMapping[address + i].isValid ||
- pic16_finalMapping[address+i].reg ||
- pic16_finalMapping[address+i].isSFR )
- return 0;
+ for(tmp = setFirstItem(*set); tmp; tmp = setNextItem(*set)) {
+ if(!strcmp(tmp->name, reg->name))break;
+ }
+
+ if(!tmp) {
+ addSet(set, reg);
+#if DEBUG_CHECK
+ fprintf(stderr, "added\n");
+#endif
+ return 1;
+ }
- return 1;
+#if DEBUG_CHECK
+ fprintf(stderr, "already added\n");
+#endif
+ return 0;
}
-/*-----------------------------------------------------------------*
- *-----------------------------------------------------------------*/
-static void mapRegister(regs *reg)
+int checkAddSym(set **set, symbol *sym)
{
+ symbol *tmp;
- int i;
- int alias;
-
- if(!reg || !reg->size) {
- fprintf(stderr,"WARNING: %s:%s:%d Bad register\n",__FILE__,__FUNCTION__,__LINE__);
- return;
- }
-
- if (pic->maxRAMaddress < 0) {
- fprintf(stderr, "missing \"#pragma maxram\" setting\n");
- return;
- }
-
- for(i=0; i<reg->size; i++) {
-
- alias = pic16_finalMapping[reg->address].alias;
- reg->alias = alias;
-
- do {
-
-// fprintf(stdout,"mapping %s to address 0x%02x, reg size = %d\n",reg->name, (reg->address+alias+i),reg->size);
-
- pic16_finalMapping[reg->address + alias + i].reg = reg;
- pic16_finalMapping[reg->address + alias + i].instance = i;
-
- /* Decrement alias */
- if(alias)
- alias -= ((alias & (alias - 1)) ^ alias);
- else
- alias--;
-
- } while (alias>=0);
- }
+#if DEBUG_CHECK
+ fprintf(stderr, "%s: about to add SYMbol: %s ... ", __FUNCTION__, sym->name);
+#endif
- // fprintf(stderr,"%s - %s addr = 0x%03x, size %d\n",__FUNCTION__,reg->name, reg->address,reg->size);
+ for(tmp = setFirstItem( *set ); tmp; tmp = setNextItem(*set)) {
+ if(!strcmp(tmp->name, sym->name))break;
+ }
+
+ if(!tmp) {
+ addSet(set, sym);
+#if DEBUG_CHECK
+ fprintf(stderr, "added\n");
+#endif
+ return 1;
+ }
- reg->isMapped = 1;
+#if DEBUG_CHECK
+ fprintf(stderr, "already added\n");
+#endif
+ return 0;
}
-/*-----------------------------------------------------------------*
- *-----------------------------------------------------------------*/
-static int assignRegister(regs *reg, int start_address)
-{
- int i;
-
-// fprintf(stderr,"%s - %s start_address = 0x%03x\t(max=0x%03x)\n",__FUNCTION__,reg->name, start_address, pic->maxRAMaddress);
- if(reg->isFixed) {
-
- if (validAddress(reg->address,reg->size)) {
-// fprintf(stderr,"fixed %s - %s address = 0x%03x\n",__FUNCTION__,reg->name, reg->address);
- mapRegister(reg);
- return reg->address;
- }
-
- if( isSFR(reg->address)) {
-// fprintf(stderr,"sfr %s - %s address = 0x%03x\n",__FUNCTION__,reg->name, reg->address);
- mapRegister(reg);
- return reg->address;
- }
-
- //fprintf(stderr, "WARNING: Ignoring Out of Range register assignment at fixed address %d, %s\n",
- // reg->address, reg->name);
-
- } else {
-
- /* This register does not have a fixed address requirement
- * so we'll search through all availble ram address and
- * assign the first one */
-
- for (i=start_address; i<=pic->maxRAMaddress; i++) {
-
- if (validAddress(i,reg->size)) {
-// fprintf(stderr, "found valid address = 0x%04x\n", i);
- reg->address = i;
- mapRegister(reg);
- return i;
- }
- }
-
- fprintf(stderr, "WARNING: No more RAM available for %s\n",reg->name);
-
- }
-
- return -1;
-}
/*-----------------------------------------------------------------*
+ * void pic16_groupRegistersInSection - add each register to its *
+ * corresponding section *
*-----------------------------------------------------------------*/
-void pic16_assignFixedRegisters(set *regset)
+void pic16_groupRegistersInSection(set *regset)
{
regs *reg;
- for (reg = setFirstItem(regset) ; reg ;
- reg = setNextItem(regset)) {
+ for(reg=setFirstItem(regset); reg; reg = setNextItem(regset)) {
- if(reg->isFixed)
- assignRegister(reg,0);
- }
+// fprintf(stderr, "%s:%d group registers in section, reg: %s\n", __FILE__, __LINE__, reg->name);
-}
-
-/*-----------------------------------------------------------------*
- *-----------------------------------------------------------------*/
-void pic16_assignRelocatableRegisters(set *regset, int used)
-{
+ if(reg->wasUsed
+ && !(reg->regop && SPEC_EXTR(OP_SYM_ETYPE(reg->regop)))) {
+
+ /* avoid grouping registers that have an initial value,
+ * they will be added later in idataSymSet */
+ if(reg->regop && (OP_SYMBOL(reg->regop)->ival && !OP_SYMBOL(reg->regop)->level))
+ continue;
- regs *reg;
- int address = 0;
+#if 0
+ fprintf(stderr, "%s:%d register %s alias:%d fix:%d ival=%i level=%i\n",
+ __FILE__, __LINE__, reg->name, reg->alias, reg->isFixed,
+ (reg->regop?(OP_SYMBOL(reg->regop)->ival?1:0):-1),
+ (reg->regop?(OP_SYMBOL(reg->regop)->level):-1) );
+#endif
- for (reg = setFirstItem(regset) ; reg ;
- reg = setNextItem(regset)) {
+ if(reg->alias == 0x80) {
+ checkAddReg(&pic16_equ_data, reg);
+ } else
+ if(reg->isFixed) {
+ checkAddReg(&pic16_fix_udata, reg);
+ } else
+ if(!reg->isFixed) {
+ if(reg->pc_type == PO_GPR_TEMP)
+ checkAddReg(&pic16_int_regs, reg);
+ else
+ checkAddReg(&pic16_rel_udata, reg);
+ }
+ }
+ }
+}
- //fprintf(stdout,"assigning %s isFixed=%d, wasUsed=%d\n",reg->name,reg->isFixed,reg->wasUsed);
- if((!reg->isFixed) && (used || reg->wasUsed))
- address = assignRegister(reg,address);
- }
-
-}
/*-----------------------------------------------------------------*
* This routine will assign a value to that address.
*
*-----------------------------------------------------------------*/
-
void pic16_assignConfigWordValue(int address, int value)
{
- switch(address) {
- case CONFIG1H_WORD_ADDRESS:
- config1h_word = value;
- break;
- case CONFIG2L_WORD_ADDRESS:
- config2l_word = value;
- break;
- case CONFIG2H_WORD_ADDRESS:
- config2h_word = value;
- break;
- case CONFIG3H_WORD_ADDRESS:
- config3h_word = value;
- break;
- case CONFIG4L_WORD_ADDRESS:
- config4l_word = value;
- break;
- case CONFIG5L_WORD_ADDRESS:
- config5l_word = value;
- break;
- case CONFIG5H_WORD_ADDRESS:
- config5h_word = value;
- break;
- case CONFIG6L_WORD_ADDRESS:
- config6l_word = value;
- break;
- case CONFIG6H_WORD_ADDRESS:
- config6h_word = value;
- break;
- case CONFIG7L_WORD_ADDRESS:
- config7l_word = value;
- break;
- case CONFIG7H_WORD_ADDRESS:
- config7h_word = value;
- break;
- }
-
- //fprintf(stderr,"setting config word to 0x%x\n",value);
-
-}
-/*-----------------------------------------------------------------*
- * int pic16_getConfigWord(int address)
- *
- * Get the current value of the config word.
- *
- *-----------------------------------------------------------------*/
+ int i;
-int pic16_getConfigWord(int address)
-{
- switch(address) {
- case CONFIG1H_WORD_ADDRESS:
- return config1h_word;
- case CONFIG2L_WORD_ADDRESS:
- return config2l_word;
- case CONFIG2H_WORD_ADDRESS:
- return config2h_word;
- case CONFIG3H_WORD_ADDRESS:
- return config3h_word;
- case CONFIG4L_WORD_ADDRESS:
- return config4l_word;
- case CONFIG5L_WORD_ADDRESS:
- return config5l_word;
- case CONFIG5H_WORD_ADDRESS:
- return config5h_word;
- case CONFIG6L_WORD_ADDRESS:
- return config6l_word;
- case CONFIG6H_WORD_ADDRESS:
- return config6h_word;
- case CONFIG7L_WORD_ADDRESS:
- return config7l_word;
- case CONFIG7H_WORD_ADDRESS:
- return config7h_word;
- default:
- return 0;
- }
+ for(i=0;i<pic16->cwInfo.confAddrEnd-pic16->cwInfo.confAddrStart+1;i++) {
+ if((address == pic16->cwInfo.confAddrStart+i)
+ && (pic16->cwInfo.crInfo[i].mask != -1)) {
+// fprintf(stderr, "setting location 0x%X to value 0x%x\n", /*address*/ pic16->cwInfo.confAddrStart+i, val
+ pic16->cwInfo.crInfo[i].value = value;
+ pic16->cwInfo.crInfo[i].emit = 1;
+ return;
+ }
+ }
}