+2008-08-07 Borut Razem <borut.razem AT siol.net>
+
+ * src/SDCCval.c, src/SDCCmain.c, src/SDCC.lex,
+ device/lib/pic/Makefile.rules, device/lib/ds390/Makefile.in,
+ device/lib/ds400/Makefile.in, device/lib/hc08/Makefile.in,
+ support/cpp/libcpp/lex.c, doc/sdccman.lyx:
+ applied modified patsh 2038174: Add support for binary constants v2
+ thanks Mauro Giachero
+
2008-08-04 Raphael Neider <rneider AT web.de>
* doc/sdccman.lyx,
2007-11-12 Borut Razem <borut.razem AT siol.net>
- * as\z80\asmain.c, as\z80\asm.h, as\z80\assym.c, as\z80\asdata.c,
- as\z80\asout.c, as\z80\aslist.c:
+ * as/z80/asmain.c, as/z80/asm.h, as/z80/assym.c, as/z80/asdata.c,
+ as/z80/asout.c, as/z80/aslist.c:
fixed bug #1817005 - as-z80 chokes on long labels
2007-11-11 Maarten Brock <sourceforge.brock AT dse.nl>
2006-04-18 Borut Razem <borut.razem AT siol.net>
- * support/scripts/sdcc.nsi: removed unexisting ${DEV_ROOT}\lib\pic\*.o,
- ${DEV_ROOT}\lib\src\pic\libdev\*.S, ${DEV_ROOT}\lib\src\pic\libdev\*.inc
+ * support/scripts/sdcc.nsi: removed unexisting ${DEV_ROOT}/lib/pic/*.o,
+ ${DEV_ROOT}/lib/src/pic/libdev/*.S, ${DEV_ROOT}/lib/src/pic/libdev/*.inc
2006-04-17 Borut Razem <borut.razem AT siol.net>
value *constVal (const char *s)
{
value *val;
- bool hex = FALSE, octal = FALSE;
char *p;
double dval;
+ bool is_integral = 0;
val = newValue (); /* alloc space for value */
SPEC_NOUN (val->type) = V_CHAR;
SPEC_USIGN (val->type) = 0;
- if (s[0] == '0')
- {
- if (s[1] == 'x' || s[1] == 'X')
- hex = TRUE;
- else if (isdigit(s[1]))
- octal = TRUE;
- }
-
errno = 0;
- if (hex || octal)
+ if (s[0] == '0')
{
- dval = strtoul (s, &p, 0);
- if (errno)
- {
- dval = 4294967295.0;
- werror (W_INVALID_INT_CONST, s, dval);
- }
+ if (s[1] == 'b' || s[1] == 'B')
+ dval = strtoul (s + 2, &p, 2);
+ else
+ dval = strtoul (s, &p, 0);
+ is_integral = 1;
}
else
+ dval = strtod (s, &p);
+
+ if (errno)
{
- dval = strtod(s, &p);
+ dval = 4294967295.0;
+ werror (W_INVALID_INT_CONST, s, dval);
}
/* Setup the flags first */
}
else if (dval > 0x7fff && !SPEC_USIGN (val->type))
{ /* check if we have to promote to long int */
- if ((hex || octal) && /* hex or octal constants may be stored in unsigned type */
+ if (is_integral && /* integral (hex, octal and binary) constants may be stored in unsigned type */
dval <= 0xffff)
{
SPEC_USIGN (val->type) = 1;
#define get_effective_char(pfile) (*pfile->buffer->cur++)
#define BACKUP() (--pfile->buffer->cur)
- enum num_type_e { NT_DEC, NT_HEX } num_type = NT_DEC;
+ enum num_type_e { NT_DEC, NT_HEX, NT_BIN } num_type = NT_DEC;
enum num_part_e { NP_WHOLE, NP_FRACT, NP_EXP, NP_INT_SUFFIX, NP_FLOAT_SUFFIX } num_part = NP_WHOLE;
uchar c = *(pfile->buffer->cur - 1);
num_part = NP_FRACT;
++len;
obstack_1grow (stack, '.');
- c = get_effective_char(pfile);
+ c = get_effective_char (pfile);
}
else
{
has_whole = 1;
++len;
obstack_1grow (stack, c);
- c = get_effective_char(pfile);
+ c = get_effective_char (pfile);
switch (c)
{
num_type = NT_HEX;
++len;
obstack_1grow (stack, c);
- c = get_effective_char(pfile);
+ c = get_effective_char (pfile);
+ break;
+
+ case 'B':
+ case 'b':
+ if (!CPP_OPTION (pfile, std))
+ {
+ num_type = NT_BIN;
+ ++len;
+ obstack_1grow (stack, c);
+ c = get_effective_char (pfile);
+ }
break;
case '.':
num_part = NP_FRACT;
++len;
obstack_1grow (stack, c);
- c = get_effective_char(pfile);
+ c = get_effective_char (pfile);
break;
}
}
has_whole = 1;
++len;
obstack_1grow (stack, c);
- c = get_effective_char(pfile);
+ c = get_effective_char (pfile);
}
if ('.' == c)
num_part = NP_FRACT;
++len;
obstack_1grow (stack, c);
- c = get_effective_char(pfile);
+ c = get_effective_char (pfile);
continue;
}
else if ('E' == c || 'e' == c)
num_part = NP_EXP;
++len;
obstack_1grow (stack, c);
- c = get_effective_char(pfile);
+ c = get_effective_char (pfile);
continue;
}
else
break;
}
}
- else
+ else if (NT_HEX == num_type)
{
while (ISXDIGIT (c))
{
has_whole = 1;
++len;
obstack_1grow (stack, c);
- c = get_effective_char(pfile);
+ c = get_effective_char (pfile);
+ }
+
+ if ('.' == c)
+ {
+ num_part = NP_FRACT;
+ ++len;
+ obstack_1grow (stack, c);
+ c = get_effective_char (pfile);
+ continue;
+ }
+ else if ('P' == c || 'p' == c)
+ {
+ if (has_whole || has_fract)
+ {
+ num_part = NP_EXP;
+ ++len;
+ obstack_1grow (stack, c);
+ c = get_effective_char (pfile);
+ continue;
+ }
+ else
+ break;
+ }
+ }
+ else /* (NT_BIN == num_type) */
+ {
+ while ((c=='0') || (c=='1'))
+ {
+ has_whole = 1;
+ ++len;
+ obstack_1grow (stack, c);
+ c = get_effective_char (pfile);
}
if ('.' == c)
num_part = NP_FRACT;
++len;
obstack_1grow (stack, c);
- c = get_effective_char(pfile);
+ c = get_effective_char (pfile);
continue;
}
else if ('P' == c || 'p' == c)
num_part = NP_EXP;
++len;
obstack_1grow (stack, c);
- c = get_effective_char(pfile);
+ c = get_effective_char (pfile);
continue;
}
else
has_fract = 1;
++len;
obstack_1grow (stack, c);
- c = get_effective_char(pfile);
+ c = get_effective_char (pfile);
}
if ('E' == c || 'e' == c)
num_part = NP_EXP;
++len;
obstack_1grow (stack, c);
- c = get_effective_char(pfile);
+ c = get_effective_char (pfile);
continue;
}
}
has_fract = 1;
++len;
obstack_1grow (stack, c);
- c = get_effective_char(pfile);
+ c = get_effective_char (pfile);
}
if ('P' == c || 'p' == c)
num_part = NP_EXP;
++len;
obstack_1grow (stack, c);
- c = get_effective_char(pfile);
+ c = get_effective_char (pfile);
continue;
}
}
{
++len;
obstack_1grow (stack, c);
- c = get_effective_char(pfile);
+ c = get_effective_char (pfile);
}
while (ISDIGIT (c))
{
++len;
obstack_1grow (stack, c);
- c = get_effective_char(pfile);
+ c = get_effective_char (pfile);
}
num_part = NP_FLOAT_SUFFIX;
++len;
obstack_1grow (stack, c);
- c = get_effective_char(pfile);
+ c = get_effective_char (pfile);
if (c == prevc)
{
++len;
obstack_1grow (stack, c);
- c = get_effective_char(pfile);
+ c = get_effective_char (pfile);
}
}
else if ('U' == c || 'u' == c)
{
++len;
obstack_1grow (stack, c);
- c = get_effective_char(pfile);
+ c = get_effective_char (pfile);
}
break;
{
++len;
obstack_1grow (stack, c);
- c = get_effective_char(pfile);
+ c = get_effective_char (pfile);
}
else if ('L' == c || 'l' == c)
{
++len;
obstack_1grow (stack, c);
- c = get_effective_char(pfile);
+ c = get_effective_char (pfile);
}
break;
}
{
struct normalize_state nst = INITIAL_NORMALIZE_STATE;
result->type = CPP_NUMBER;
- if (CPP_OPTION(pfile, pedantic_parse_number))
+ if (CPP_OPTION (pfile, pedantic_parse_number))
pedantic_lex_number (pfile, &result->val.str);
else
lex_number (pfile, &result->val.str, &nst);
/* SDCC _asm specific */
/* handle _asm ... _endasm ; */
- if (CPP_OPTION(pfile, preproc_asm) == 0 && result->val.node == pfile->spec_nodes.n__asm)
+ if (CPP_OPTION (pfile, preproc_asm) == 0 && result->val.node == pfile->spec_nodes.n__asm)
{
comment_start = buffer->cur;
result->type = CPP_ASM;
{
struct normalize_state nst = INITIAL_NORMALIZE_STATE;
result->type = CPP_NUMBER;
- if (CPP_OPTION(pfile, pedantic_parse_number))
+ if (CPP_OPTION (pfile, pedantic_parse_number))
pedantic_lex_number (pfile, &result->val.str);
else
lex_number (pfile, &result->val.str, &nst);