Mercurial > hg-old > index.cgi
comparison src/expr.c @ 47:804d7465e0f9
Implemented ORG and fixed problems with constants using $, &, or @ to specify base
author | lost |
---|---|
date | Sun, 04 Jan 2009 07:25:03 +0000 |
parents | 2330b88f9600 |
children | 73423b66e511 |
comparison
equal
deleted
inserted
replaced
46:b962cee20bf4 | 47:804d7465e0f9 |
---|---|
316 { | 316 { |
317 // decimal constant | 317 // decimal constant |
318 int val = 0; | 318 int val = 0; |
319 | 319 |
320 (*p)++; | 320 (*p)++; |
321 while (strchr("0123456789", **p)) | 321 while (**p && strchr("0123456789", **p)) |
322 { | 322 { |
323 val = val * 10 + (**p - '0'); | 323 val = val * 10 + (**p - '0'); |
324 (*p)++; | 324 (*p)++; |
325 } | 325 } |
326 t = lwasm_expr_term_create_int(val); | 326 t = lwasm_expr_term_create_int(val); |
348 { | 348 { |
349 // hexadecimal constant | 349 // hexadecimal constant |
350 int val = 0, val2; | 350 int val = 0, val2; |
351 | 351 |
352 (*p)++; | 352 (*p)++; |
353 while (strchr("0123456789ABCDEFabcdef", **p)) | 353 debug_message(3, "Found prefix hex constant: %s", *p); |
354 while (**p && strchr("0123456789ABCDEFabcdef", **p)) | |
354 { | 355 { |
355 val2 = toupper(**p) - '0'; | 356 val2 = toupper(**p) - '0'; |
356 if (val2 > 9) | 357 if (val2 > 9) |
357 val2 -= 7; | 358 val2 -= 7; |
359 debug_message(3, "Got char: %c (%d)", **p, val2); | |
358 val = val * 16 + val2; | 360 val = val * 16 + val2; |
359 (*p)++; | 361 (*p)++; |
360 } | 362 } |
361 t = lwasm_expr_term_create_int(val); | 363 t = lwasm_expr_term_create_int(val); |
362 lwasm_expr_stack_push(s, t); | 364 lwasm_expr_stack_push(s, t); |
369 { | 371 { |
370 // octal constant | 372 // octal constant |
371 int val = 0; | 373 int val = 0; |
372 | 374 |
373 (*p)++; | 375 (*p)++; |
374 while (strchr("01234567", **p)) | 376 while (**p && strchr("01234567", **p)) |
375 { | 377 { |
376 val = val * 8 + (**p - '0'); | 378 val = val * 8 + (**p - '0'); |
377 (*p)++; | 379 (*p)++; |
378 } | 380 } |
379 t = lwasm_expr_term_create_int(val); | 381 t = lwasm_expr_term_create_int(val); |