| @@ -32,6 +32,8 @@ ST_FUNC int asm_get_local_label_name(TCCState *s1, unsigned int n) · 31 unmodified lines |
| 32 | } | 32 | } |
| 33 | | 33 | |
| 34 | ST_FUNC void asm_expr(TCCState *s1, ExprValue *pe); | 34 | ST_FUNC void asm_expr(TCCState *s1, ExprValue *pe); |
| | 35 | static int tcc_assemble_internal(TCCState *s1, int do_preprocess); |
| | 36 | static Sym sym_dot; |
| 35 | | 37 | |
| 36 | /* We do not use the C expression parser to handle symbols. Maybe the | 38 | /* We do not use the C expression parser to handle symbols. Maybe the |
| 37 | C expression parser could be tweaked to do so. */ | 39 | C expression parser could be tweaked to do so. */ |
| @@ -101,6 +103,14 @@ static void asm_expr_unary(TCCState *s1, ExprValue *pe) · 63 unmodified lines |
| 101 | asm_expr(s1, pe); | 103 | asm_expr(s1, pe); |
| 102 | skip(')'); | 104 | skip(')'); |
| 103 | break; | 105 | break; |
| | 106 | case '.': |
| | 107 | pe->v = 0; |
| | 108 | pe->sym = &sym_dot; |
| | 109 | sym_dot.type.t = VT_VOID | VT_STATIC; |
| | 110 | sym_dot.r = cur_text_section->sh_num; |
| | 111 | sym_dot.jnext = ind; |
| | 112 | next(); |
| | 113 | break; |
| 104 | default: | 114 | default: |
| 105 | if (tok >= TOK_IDENT) { | 115 | if (tok >= TOK_IDENT) { |
| 106 | /* label case : if the label was not found, add one */ | 116 | /* label case : if the label was not found, add one */ |
| @@ -474,6 +484,33 @@ static void asm_parse_directive(TCCState *s1) · 367 unmodified lines |
| 474 | } | 484 | } |
| 475 | } | 485 | } |
| 476 | break; | 486 | break; |
| | 487 | case TOK_ASMDIR_rept: |
| | 488 | { |
| | 489 | int repeat; |
| | 490 | TokenString init_str; |
| | 491 | ParseState saved_parse_state = {0}; |
| | 492 | next(); |
| | 493 | repeat = asm_int_expr(s1); |
| | 494 | tok_str_new(&init_str); |
| | 495 | next(); |
| | 496 | while ((tok != TOK_ASMDIR_endr) && (tok != CH_EOF)) { |
| | 497 | tok_str_add_tok(&init_str); |
| | 498 | next(); |
| | 499 | } |
| | 500 | if (tok == CH_EOF) tcc_error("we at end of file, .endr not found"); |
| | 501 | next(); |
| | 502 | tok_str_add(&init_str, -1); |
| | 503 | tok_str_add(&init_str, 0); |
| | 504 | save_parse_state(&saved_parse_state); |
| | 505 | begin_macro(&init_str, 0); |
| | 506 | while (repeat-- > 0) { |
| | 507 | tcc_assemble_internal(s1, (parse_flags & PARSE_FLAG_PREPROCESS)); |
| | 508 | macro_ptr = init_str.str; |
| | 509 | } |
| | 510 | end_macro(); |
| | 511 | restore_parse_state(&saved_parse_state); |
| | 512 | break; |
| | 513 | } |
| 477 | case TOK_ASMDIR_org: | 514 | case TOK_ASMDIR_org: |
| 478 | { | 515 | { |
| 479 | unsigned long n; | 516 | unsigned long n; |