Mercurial > hg-old > index.cgi
changeset 170:bf69160da467
Added ability to use 0x and 0X as prefixes for hexadecimal numbers
author | lost |
---|---|
date | Sun, 01 Mar 2009 00:53:21 +0000 |
parents | 99300be2d3bd |
children | d610b8aef91b |
files | ChangeLog lwasm/expr.c |
diffstat | 2 files changed, 23 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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')