# HG changeset patch # User lost # Date 1235868801 0 # Node ID bf69160da467f89579c8639e574171f1667dce04 # Parent 99300be2d3bd2d457cac6ca563cd8467329283de Added ability to use 0x and 0X as prefixes for hexadecimal numbers diff -r 99300be2d3bd -r bf69160da467 ChangeLog --- a/ChangeLog Sun Feb 08 03:00:44 2009 +0000 +++ b/ChangeLog Sun Mar 01 00:53:21 2009 +0000 @@ -22,6 +22,7 @@ BSS sections. The "!bss" flag can be used to remove that assumption. [+] ignore lines starting with # to permit C pre-processor output to be used as input to lwasm +[+] allow "0x" and "0X" as prefixes to identify hexadecimal numbers [b] actually show assembly errors when no list requested [b] pragma and --pragma now actually take multiple pragmas as documented diff -r 99300be2d3bd -r bf69160da467 lwasm/expr.c --- a/lwasm/expr.c Sun Feb 08 03:00:44 2009 +0000 +++ b/lwasm/expr.c Sun Mar 01 00:53:21 2009 +0000 @@ -382,6 +382,27 @@ lwasm_expr_term_free(t); return 0; } + else if (**p == '0' && tolower(*(*p + 1)) == 'x') + { + // "C" style hexadecimal constant + int val = 0, val2; + + (*p)+=2; + debug_message(3, "Found \"C\" style prefix hex constant: %s", *p); + while (**p && strchr("0123456789ABCDEFabcdef", **p)) + { + val2 = toupper(**p) - '0'; + if (val2 > 9) + val2 -= 7; + debug_message(3, "Got char: %c (%d)", **p, val2); + val = val * 16 + val2; + (*p)++; + } + t = lwasm_expr_term_create_int(val); + lwasm_expr_stack_push(s, t); + lwasm_expr_term_free(t); + return 0; + } // an @ followed by a digit is an octal number // but if it's followed by anything else, it is a symbol else if (**p == '@' && isdigit(*(*p + 1))) @@ -400,7 +421,7 @@ lwasm_expr_term_free(t); return 0; } - + // symbol or bare decimal or suffix identified constant here // all numbers will start with a digit at this point if (**p < '0' || **p > '9')