3 Copyright (C) 2009-2010 Borut Razem
5 This program is free software; you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published by the
7 Free Software Foundation; either version 3, or (at your option) any
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
28 #define NELEM(x) (sizeof (x) / sizeof (x)[0])
32 static enum sdas_target_e target
= TARGET_ID_UNKNOWN
;
36 *program_name (char *path
)
39 static char fname
[_MAX_FNAME
];
41 _splitpath (path
, NULL
, NULL
, fname
, NULL
);
44 return basename (path
);
54 fprintf(stderr
, "sdas_init not called!\n");
61 sdas_init (char *path
)
65 enum sdas_target_e target
;
67 { "gb", TARGET_ID_GB
},
68 { "z80", TARGET_ID_Z80
},
69 { "8051", TARGET_ID_8051
},
70 { "390", TARGET_ID_DS390
},
71 { "6808", TARGET_ID_6808
},
72 { "stm8", TARGET_ID_STM8
},
73 { "pdk13", TARGET_ID_PDK13
},
74 { "pdk14", TARGET_ID_PDK14
},
75 { "pdk15", TARGET_ID_PDK15
},
76 { "pdk16", TARGET_ID_PDK16
},
80 char *progname
= program_name (path
);
82 /* convert it to lower case:
83 on DOS and Windows 9x the file name in argv[0] is uppercase */
86 for (p
= progname
; '\0' != *p
; ++p
)
89 if ((sdas
= (strncmp(progname
, "sdas", 4) == 0)) != 0)
91 for (i
= 0; i
< NELEM (tgt
); ++i
)
93 if (strstr(progname
, tgt
[i
].str
))
95 target
= tgt
[i
].target
;
100 /* diagnostic message */
101 if (getenv ("SDAS_DIAG"))
103 printf ("sdas path: %s\n", path
);
104 printf ("is sdas: %d\n", sdas
);
106 printf ("sdas target: %s\n", (i
>= NELEM (tgt
)) ? "unknown" : tgt
[i
].str
);
120 get_sdas_target(void)
127 set_sdas_target(enum sdas_target_e newtarget
)
133 is_sdas_target_z80_like(void)
136 return target
== TARGET_ID_Z80
|| target
== TARGET_ID_GB
;
141 is_sdas_target_8051_like(void)
144 return target
== TARGET_ID_8051
|| target
== TARGET_ID_DS390
;
148 is_sdas_target_stm8(void)
151 return target
== TARGET_ID_STM8
;
155 is_sdas_target_pdk(void)
158 return target
== TARGET_ID_PDK13
||
159 target
== TARGET_ID_PDK14
||
160 target
== TARGET_ID_PDK15
;